Merge "Create directory on background thread."
This commit is contained in:
@ -83,15 +83,16 @@ class SaveImageInBackgroundTask extends AsyncTask<SaveImageInBackgroundData, Voi
|
|||||||
private static final String SCREENSHOT_FILE_NAME_TEMPLATE = "Screenshot_%s.png";
|
private static final String SCREENSHOT_FILE_NAME_TEMPLATE = "Screenshot_%s.png";
|
||||||
private static final String SCREENSHOT_SHARE_SUBJECT_TEMPLATE = "Screenshot (%s)";
|
private static final String SCREENSHOT_SHARE_SUBJECT_TEMPLATE = "Screenshot (%s)";
|
||||||
|
|
||||||
private int mNotificationId;
|
private final int mNotificationId;
|
||||||
private NotificationManager mNotificationManager;
|
private final NotificationManager mNotificationManager;
|
||||||
private Notification.Builder mNotificationBuilder;
|
private final Notification.Builder mNotificationBuilder;
|
||||||
private String mImageFileName;
|
private final File mScreenshotDir;
|
||||||
private String mImageFilePath;
|
private final String mImageFileName;
|
||||||
private long mImageTime;
|
private final String mImageFilePath;
|
||||||
private BigPictureStyle mNotificationStyle;
|
private final long mImageTime;
|
||||||
private int mImageWidth;
|
private final BigPictureStyle mNotificationStyle;
|
||||||
private int mImageHeight;
|
private final int mImageWidth;
|
||||||
|
private final int mImageHeight;
|
||||||
|
|
||||||
// WORKAROUND: We want the same notification across screenshots that we update so that we don't
|
// WORKAROUND: We want the same notification across screenshots that we update so that we don't
|
||||||
// spam a user's notification drawer. However, we only show the ticker for the saving state
|
// spam a user's notification drawer. However, we only show the ticker for the saving state
|
||||||
@ -109,12 +110,9 @@ class SaveImageInBackgroundTask extends AsyncTask<SaveImageInBackgroundData, Voi
|
|||||||
String imageDate = new SimpleDateFormat("yyyy-MM-dd-HH-mm-ss").format(new Date(mImageTime));
|
String imageDate = new SimpleDateFormat("yyyy-MM-dd-HH-mm-ss").format(new Date(mImageTime));
|
||||||
mImageFileName = String.format(SCREENSHOT_FILE_NAME_TEMPLATE, imageDate);
|
mImageFileName = String.format(SCREENSHOT_FILE_NAME_TEMPLATE, imageDate);
|
||||||
|
|
||||||
// Create screenshot directory if it doesn't exist
|
mScreenshotDir = new File(Environment.getExternalStoragePublicDirectory(
|
||||||
final File screenshotDir = new File(Environment.getExternalStoragePublicDirectory(
|
|
||||||
Environment.DIRECTORY_PICTURES), SCREENSHOTS_DIR_NAME);
|
Environment.DIRECTORY_PICTURES), SCREENSHOTS_DIR_NAME);
|
||||||
screenshotDir.mkdirs();
|
mImageFilePath = new File(mScreenshotDir, mImageFileName).getAbsolutePath();
|
||||||
|
|
||||||
mImageFilePath = new File(screenshotDir, mImageFileName).getAbsolutePath();
|
|
||||||
|
|
||||||
// Create the large notification icon
|
// Create the large notification icon
|
||||||
mImageWidth = data.image.getWidth();
|
mImageWidth = data.image.getWidth();
|
||||||
@ -177,6 +175,9 @@ class SaveImageInBackgroundTask extends AsyncTask<SaveImageInBackgroundData, Voi
|
|||||||
Resources r = context.getResources();
|
Resources r = context.getResources();
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
// Create screenshot directory if it doesn't exist
|
||||||
|
mScreenshotDir.mkdirs();
|
||||||
|
|
||||||
// Save the screenshot to the MediaStore
|
// Save the screenshot to the MediaStore
|
||||||
ContentValues values = new ContentValues();
|
ContentValues values = new ContentValues();
|
||||||
ContentResolver resolver = context.getContentResolver();
|
ContentResolver resolver = context.getContentResolver();
|
||||||
|
Reference in New Issue
Block a user