write photos to DCIM/Camera
This commit is contained in:
parent
282109db01
commit
c03a8b784f
|
@ -880,19 +880,25 @@ public class FileBackend {
|
||||||
public File getStorageLocation(final String filename, final String mime) {
|
public File getStorageLocation(final String filename, final String mime) {
|
||||||
final File parentDirectory;
|
final File parentDirectory;
|
||||||
if (Strings.isNullOrEmpty(mime)) {
|
if (Strings.isNullOrEmpty(mime)) {
|
||||||
parentDirectory = Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_DOWNLOADS);
|
parentDirectory =
|
||||||
|
Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_DOWNLOADS);
|
||||||
} else if (mime.startsWith("image/")) {
|
} else if (mime.startsWith("image/")) {
|
||||||
parentDirectory = Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_PICTURES);
|
parentDirectory =
|
||||||
|
Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_PICTURES);
|
||||||
} else if (mime.startsWith("video/")) {
|
} else if (mime.startsWith("video/")) {
|
||||||
parentDirectory = Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_MOVIES);
|
parentDirectory =
|
||||||
|
Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_MOVIES);
|
||||||
} else {
|
} else {
|
||||||
parentDirectory = Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_DOWNLOADS);
|
parentDirectory =
|
||||||
|
Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_DOWNLOADS);
|
||||||
}
|
}
|
||||||
final File appDirectory = new File(parentDirectory, mXmppConnectionService.getString(R.string.app_name));
|
final File appDirectory =
|
||||||
|
new File(parentDirectory, mXmppConnectionService.getString(R.string.app_name));
|
||||||
return new File(appDirectory, filename);
|
return new File(appDirectory, filename);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setupRelativeFilePath(final Message message, final String filename, final String mime) {
|
public void setupRelativeFilePath(
|
||||||
|
final Message message, final String filename, final String mime) {
|
||||||
final File file = getStorageLocation(filename, mime);
|
final File file = getStorageLocation(filename, mime);
|
||||||
message.setRelativeFilePath(file.getAbsolutePath());
|
message.setRelativeFilePath(file.getAbsolutePath());
|
||||||
}
|
}
|
||||||
|
@ -1147,14 +1153,19 @@ public class FileBackend {
|
||||||
}
|
}
|
||||||
|
|
||||||
public Uri getTakePhotoUri() {
|
public Uri getTakePhotoUri() {
|
||||||
final String filename = String.format("IMG_%s.%s", IMAGE_DATE_FORMAT.format(new Date()),"jpg");
|
final String filename =
|
||||||
File file;
|
String.format("IMG_%s.%s", IMAGE_DATE_FORMAT.format(new Date()), "jpg");
|
||||||
|
final File directory;
|
||||||
if (Config.ONLY_INTERNAL_STORAGE) {
|
if (Config.ONLY_INTERNAL_STORAGE) {
|
||||||
final File dcimCache = new File(mXmppConnectionService.getCacheDir(), "Camera");
|
directory = new File(mXmppConnectionService.getCacheDir(), "Camera");
|
||||||
file = new File(dcimCache, filename);
|
|
||||||
} else {
|
} else {
|
||||||
file = new File(Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_DCIM), filename);
|
directory =
|
||||||
|
new File(
|
||||||
|
Environment.getExternalStoragePublicDirectory(
|
||||||
|
Environment.DIRECTORY_DCIM),
|
||||||
|
"Camera");
|
||||||
}
|
}
|
||||||
|
final File file = new File(directory, filename);
|
||||||
file.getParentFile().mkdirs();
|
file.getParentFile().mkdirs();
|
||||||
return getUriForFile(mXmppConnectionService, file);
|
return getUriForFile(mXmppConnectionService, file);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue