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

View file

@ -761,7 +761,7 @@ public class XmppConnectionService extends Service {
uri = DocumentsContract.buildDocumentUriUsingTree(uri, DocumentsContract.getTreeDocumentId(uri));
return new File(FileUtils.getPath(getBaseContext(), uri));
} 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 ConversationsActivity activity;
private boolean reInitRequiredOnStart = true;
private int identiconWidth = -1;
private File savingAsSticker = null;
private EmojiSearch emojiSearch = 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
private File[] files;
private String[] filesPaths;
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 keyboardHeightProvider = null;
@ -3417,7 +3416,7 @@ public class ConversationFragment extends XmppFragment
if (dir.startsWith("content://")) {
intent.putExtra("android.provider.extra.INITIAL_URI", Uri.parse(dir));
} 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;
if (Build.VERSION.SDK_INT >= 29) {
Intent tmp = ((StorageManager) activity.getSystemService(Context.STORAGE_SERVICE)).getPrimaryStorageVolume().createOpenDocumentTreeIntent();
@ -5530,10 +5529,10 @@ public class ConversationFragment extends XmppFragment
} else {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.S) {
parentDirectory =
Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_RECORDINGS);
Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_DOCUMENTS + "/monocles chat" + "/recordings");
} else {
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));

View file

@ -48,7 +48,7 @@ public class AttachmentsSettingsFragment extends XmppPreferenceFragment {
final var p = PreferenceManager.getDefaultSharedPreferences(requireActivity());
final var stickerDir = findPreference("sticker_directory");
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) -> {
final var intent = ((StorageManager) requireActivity().getSystemService(Context.STORAGE_SERVICE)).getPrimaryStorageVolume().createOpenDocumentTreeIntent();
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));
return new File(FileUtils.getPath(getBaseContext(), uri));
} else {
return new File(Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_PICTURES) + "/" + dir);
return new File(Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_DOCUMENTS) + "/monocles chat" + "/" + dir);
}
}