Change to files and backup folder to Documents/monocles chat/

This commit is contained in:
Arne 2025-01-08 16:00:01 +01:00
parent 87201045f5
commit 5dac7289a1
5 changed files with 21 additions and 28 deletions

View file

@ -193,7 +193,7 @@ public class FileBackend {
final File conversationsDownloadDirectory = final File conversationsDownloadDirectory =
new File( new File(
Environment.getExternalStoragePublicDirectory( Environment.getExternalStoragePublicDirectory(
Environment.DIRECTORY_DOWNLOADS), Environment.DIRECTORY_DOCUMENTS),
context.getString(R.string.app_name)); context.getString(R.string.app_name));
return new File(conversationsDownloadDirectory, "Backup"); return new File(conversationsDownloadDirectory, "Backup");
} }
@ -1124,23 +1124,18 @@ public class FileBackend {
public File getStorageLocation(final Message message, final String filename, final String mime) { public File getStorageLocation(final Message message, final String filename, final String mime) {
final File parentDirectory; final File parentDirectory;
if (Strings.isNullOrEmpty(mime)) { if (Strings.isNullOrEmpty(mime)) {
parentDirectory = parentDirectory = Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_DOCUMENTS + "/monocles chat");
Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_DOWNLOADS);
} else if (mime.startsWith("image/")) { } else if (mime.startsWith("image/")) {
parentDirectory = parentDirectory = Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_DOCUMENTS + "/monocles chat" + "/pictures");
Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_PICTURES);
} else if (mime.startsWith("video/")) { } else if (mime.startsWith("video/")) {
parentDirectory = parentDirectory = Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_DOCUMENTS + "/monocles chat" + "/videos");
Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_MOVIES);
} else if (MediaAdapter.DOCUMENT_MIMES.contains(mime)) { } else if (MediaAdapter.DOCUMENT_MIMES.contains(mime)) {
parentDirectory = parentDirectory = Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_DOCUMENTS + "/monocles chat" + "/documents");
Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_DOCUMENTS);
} else { } else {
parentDirectory = parentDirectory = Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_DOCUMENTS + "/monocles chat");
Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_DOWNLOADS);
} }
final File appDirectory = final File appDirectory =
new File(parentDirectory, mXmppConnectionService.getString(R.string.app_name)); new File(String.valueOf(parentDirectory));
if (message == null || message.getStatus() == Message.STATUS_DUMMY || (message.getConversation() instanceof Conversation && ((Conversation) message.getConversation()).storeInCache())) { if (message == null || message.getStatus() == Message.STATUS_DUMMY || (message.getConversation() instanceof Conversation && ((Conversation) message.getConversation()).storeInCache())) {
final var mediaCache = new File(mXmppConnectionService.getCacheDir(), "/media"); final var mediaCache = new File(mXmppConnectionService.getCacheDir(), "/media");
return new File(mediaCache, filename); return new File(mediaCache, filename);
@ -1150,11 +1145,10 @@ public class FileBackend {
} }
public void setupNomedia(final boolean nomedia) { public void setupNomedia(final boolean nomedia) {
final var pictures = Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_PICTURES); final var pictures = Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_DOCUMENTS + "/monocles chat" + "/pictures");
final var app = mXmppConnectionService.getString(R.string.app_name); final var picturesNomedia = new File(new File(String.valueOf(pictures)), ".nomedia");
final var picturesNomedia = new File(new File(pictures, app), ".nomedia"); final var movies = Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_DOCUMENTS + "/monocles chat" + "/videos");
final var movies = Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_MOVIES); final var moviesNomedia = new File(new File(String.valueOf(movies)), ".nomedia");
final var moviesNomedia = new File(new File(movies, app), ".nomedia");
var rescan = false; var rescan = false;
if (nomedia) { if (nomedia) {
rescan = rescan || picturesNomedia.mkdir(); rescan = rescan || picturesNomedia.mkdir();
@ -1164,8 +1158,8 @@ public class FileBackend {
rescan = rescan || moviesNomedia.delete(); rescan = rescan || moviesNomedia.delete();
} }
if (rescan) { if (rescan) {
updateMediaScanner(new File(pictures, app)); updateMediaScanner(new File(String.valueOf(pictures)));
updateMediaScanner(new File(movies, app)); updateMediaScanner(new File(String.valueOf(movies)));
} }
} }

View file

@ -761,7 +761,7 @@ public class XmppConnectionService extends Service {
uri = DocumentsContract.buildDocumentUriUsingTree(uri, DocumentsContract.getTreeDocumentId(uri)); uri = DocumentsContract.buildDocumentUriUsingTree(uri, DocumentsContract.getTreeDocumentId(uri));
return new File(FileUtils.getPath(getBaseContext(), uri)); return new File(FileUtils.getPath(getBaseContext(), uri));
} else { } else {
return new File(Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_PICTURES) + "/" + dir); return new File(Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_DOCUMENTS) + "/monocles chat" + "/" + dir);
} }
} }

View file

@ -321,16 +321,15 @@ public class ConversationFragment extends XmppFragment
private Toast messageLoaderToast; private Toast messageLoaderToast;
private ConversationsActivity activity; private ConversationsActivity activity;
private boolean reInitRequiredOnStart = true; private boolean reInitRequiredOnStart = true;
private int identiconWidth = -1;
private File savingAsSticker = null; private File savingAsSticker = null;
private EmojiSearch emojiSearch = null; private EmojiSearch emojiSearch = null;
private EmojiSearchOld emojiSearchOld = null; private EmojiSearchOld emojiSearchOld = null;
File dirStickers = new File(Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_PICTURES) + File.separator + "Stickers"); File dirStickers = new File(Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_DOCUMENTS) + "/monocles chat" + File.separator + "Stickers");
//Gifspaths //Gifspaths
private File[] files; private File[] files;
private String[] filesPaths; private String[] filesPaths;
private String[] filesNames; private String[] filesNames;
File dirGifs = new File(Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_PICTURES) + File.separator + "Stickers" + File.separator + "Animoji"); File dirGifs = new File(Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_DOCUMENTS) + "/monocles chat" + File.separator + "Stickers" + File.separator + "Animoji");
private KeyboardHeightProvider.KeyboardHeightListener keyboardHeightListener = null; private KeyboardHeightProvider.KeyboardHeightListener keyboardHeightListener = null;
private KeyboardHeightProvider keyboardHeightProvider = null; private KeyboardHeightProvider keyboardHeightProvider = null;
@ -3417,7 +3416,7 @@ public class ConversationFragment extends XmppFragment
if (dir.startsWith("content://")) { if (dir.startsWith("content://")) {
intent.putExtra("android.provider.extra.INITIAL_URI", Uri.parse(dir)); intent.putExtra("android.provider.extra.INITIAL_URI", Uri.parse(dir));
} else { } else {
new File(Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_PICTURES) + "/" + dir + "/User Pack").mkdirs(); new File(Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_DOCUMENTS) + "/monocles chat" + "/" + dir + "/User Pack").mkdirs();
Uri uri; Uri uri;
if (Build.VERSION.SDK_INT >= 29) { if (Build.VERSION.SDK_INT >= 29) {
Intent tmp = ((StorageManager) activity.getSystemService(Context.STORAGE_SERVICE)).getPrimaryStorageVolume().createOpenDocumentTreeIntent(); Intent tmp = ((StorageManager) activity.getSystemService(Context.STORAGE_SERVICE)).getPrimaryStorageVolume().createOpenDocumentTreeIntent();
@ -5530,10 +5529,10 @@ public class ConversationFragment extends XmppFragment
} else { } else {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.S) { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.S) {
parentDirectory = parentDirectory =
Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_RECORDINGS); Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_DOCUMENTS + "/monocles chat" + "/recordings");
} else { } else {
parentDirectory = parentDirectory =
Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_DOWNLOADS); Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_DOCUMENTS + "/monocles chat" + "/recordings");
} }
} }
final File conversationsDirectory = new File(parentDirectory, getString(R.string.app_name)); final File conversationsDirectory = new File(parentDirectory, getString(R.string.app_name));

View file

@ -48,7 +48,7 @@ public class AttachmentsSettingsFragment extends XmppPreferenceFragment {
final var p = PreferenceManager.getDefaultSharedPreferences(requireActivity()); final var p = PreferenceManager.getDefaultSharedPreferences(requireActivity());
final var stickerDir = findPreference("sticker_directory"); final var stickerDir = findPreference("sticker_directory");
if (Build.VERSION.SDK_INT >= 29) { if (Build.VERSION.SDK_INT >= 29) {
stickerDir.setSummary(p.getString("sticker_directory", "Pictures/Stickers")); stickerDir.setSummary(p.getString("sticker_directory", "Documents/monocles chat/Stickers"));
stickerDir.setOnPreferenceClickListener((pref) -> { stickerDir.setOnPreferenceClickListener((pref) -> {
final var intent = ((StorageManager) requireActivity().getSystemService(Context.STORAGE_SERVICE)).getPrimaryStorageVolume().createOpenDocumentTreeIntent(); final var intent = ((StorageManager) requireActivity().getSystemService(Context.STORAGE_SERVICE)).getPrimaryStorageVolume().createOpenDocumentTreeIntent();
startActivityForResult(Intent.createChooser(intent, "Choose sticker location"), 0); startActivityForResult(Intent.createChooser(intent, "Choose sticker location"), 0);

View file

@ -183,7 +183,7 @@ public class DownloadDefaultStickers extends Service {
uri = DocumentsContract.buildDocumentUriUsingTree(uri, DocumentsContract.getTreeDocumentId(uri)); uri = DocumentsContract.buildDocumentUriUsingTree(uri, DocumentsContract.getTreeDocumentId(uri));
return new File(FileUtils.getPath(getBaseContext(), uri)); return new File(FileUtils.getPath(getBaseContext(), uri));
} else { } else {
return new File(Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_PICTURES) + "/" + dir); return new File(Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_DOCUMENTS) + "/monocles chat" + "/" + dir);
} }
} }