From a2be48029f3787028243ac01cb3d2cf17fb9cf9b Mon Sep 17 00:00:00 2001 From: junhuicoding Date: Wed, 31 Mar 2021 22:53:56 +0800 Subject: [PATCH] initial implementation --- .../DownloadsPreferencesFragment.java | 9 +++++++ .../awais/instagrabber/utils/Constants.java | 1 + .../instagrabber/utils/DownloadUtils.java | 25 +++++++++++++++---- .../instagrabber/utils/SettingsHelper.java | 3 ++- app/src/main/res/values-ca/strings.xml | 1 + app/src/main/res/values-cs/strings.xml | 1 + app/src/main/res/values-de/strings.xml | 1 + app/src/main/res/values-el/strings.xml | 1 + app/src/main/res/values-es/strings.xml | 1 + app/src/main/res/values-eu/strings.xml | 1 + app/src/main/res/values-fa/strings.xml | 1 + app/src/main/res/values-fr/strings.xml | 1 + app/src/main/res/values-hi/strings.xml | 1 + app/src/main/res/values-in/strings.xml | 1 + app/src/main/res/values-it/strings.xml | 1 + app/src/main/res/values-ja/strings.xml | 1 + app/src/main/res/values-kn/strings.xml | 1 + app/src/main/res/values-mk/strings.xml | 1 + app/src/main/res/values-nl/strings.xml | 1 + app/src/main/res/values-or/strings.xml | 1 + app/src/main/res/values-pl/strings.xml | 1 + app/src/main/res/values-pt/strings.xml | 1 + app/src/main/res/values-ru/strings.xml | 1 + app/src/main/res/values-sk/strings.xml | 1 + app/src/main/res/values-tr/strings.xml | 1 + app/src/main/res/values-vi/strings.xml | 1 + app/src/main/res/values-zh-rCN/strings.xml | 1 + app/src/main/res/values-zh-rTW/strings.xml | 1 + app/src/main/res/values/strings.xml | 1 + 29 files changed, 57 insertions(+), 6 deletions(-) diff --git a/app/src/main/java/awais/instagrabber/fragments/settings/DownloadsPreferencesFragment.java b/app/src/main/java/awais/instagrabber/fragments/settings/DownloadsPreferencesFragment.java index c2637b78..63a22dd8 100644 --- a/app/src/main/java/awais/instagrabber/fragments/settings/DownloadsPreferencesFragment.java +++ b/app/src/main/java/awais/instagrabber/fragments/settings/DownloadsPreferencesFragment.java @@ -29,6 +29,7 @@ public class DownloadsPreferencesFragment extends BasePreferencesFragment { if (context == null) return; screen.addPreference(getDownloadUserFolderPreference(context)); screen.addPreference(getSaveToCustomFolderPreference(context)); + screen.addPreference(getPrependUsernameToFilenamePreference(context)); } private Preference getDownloadUserFolderPreference(@NonNull final Context context) { @@ -49,6 +50,14 @@ public class DownloadsPreferencesFragment extends BasePreferencesFragment { .show(getParentFragmentManager(), null)); } + private Preference getPrependUsernameToFilenamePreference(@NonNull final Context context) { + final SwitchPreferenceCompat preference = new SwitchPreferenceCompat(context); + preference.setKey(Constants.DOWNLOAD_PREPEND_USER_NAME); + preference.setTitle("Prepend Username to Filename"); + preference.setIconSpaceReserved(false); + return preference; + } + public static class SaveToCustomFolderPreference extends Preference { private AppCompatTextView customPathTextView; private final OnSelectFolderButtonClickListener onSelectFolderButtonClickListener; diff --git a/app/src/main/java/awais/instagrabber/utils/Constants.java b/app/src/main/java/awais/instagrabber/utils/Constants.java index 969f5d6a..0f7618c4 100644 --- a/app/src/main/java/awais/instagrabber/utils/Constants.java +++ b/app/src/main/java/awais/instagrabber/utils/Constants.java @@ -20,6 +20,7 @@ public final class Constants { // boolean prefs public static final String DOWNLOAD_USER_FOLDER = "download_user_folder"; public static final String TOGGLE_KEYWORD_FILTER = "toggle_keyword_filter"; + public static final String DOWNLOAD_PREPEND_USER_NAME = "download_user_name"; // deprecated: public static final String BOTTOM_TOOLBAR = "bottom_toolbar"; public static final String FOLDER_SAVE_TO = "saved_to"; public static final String AUTOPLAY_VIDEOS = "autoplay_videos"; diff --git a/app/src/main/java/awais/instagrabber/utils/DownloadUtils.java b/app/src/main/java/awais/instagrabber/utils/DownloadUtils.java index 85f45a21..aab36cea 100644 --- a/app/src/main/java/awais/instagrabber/utils/DownloadUtils.java +++ b/app/src/main/java/awais/instagrabber/utils/DownloadUtils.java @@ -116,7 +116,15 @@ public final class DownloadUtils { private static File getDownloadSaveFile(final File finalDir, final String postId, final String displayUrl) { - return getDownloadSaveFile(finalDir, postId, "", displayUrl); + return getDownloadSaveFile(finalDir, postId, "", displayUrl, ""); + } + + @NonNull + private static File getDownloadSaveFile(final File finalDir, + final String postId, + final String displayUrl, + final String username) { + return getDownloadSaveFile(finalDir, postId, "", displayUrl, username); } private static File getDownloadChildSaveFile(final File downloadDir, @@ -131,8 +139,10 @@ public final class DownloadUtils { private static File getDownloadSaveFile(final File finalDir, final String postId, final String sliderPostfix, - final String displayUrl) { - final String fileName = postId + sliderPostfix + getFileExtensionFromUrl(displayUrl); + final String displayUrl, + final String username) { + String usernamePrepend = (username.equals("")) ? "" : "@" + username + "_"; + final String fileName = usernamePrepend + postId + sliderPostfix + getFileExtensionFromUrl(displayUrl); return new File(finalDir, fileName); } @@ -263,7 +273,7 @@ public final class DownloadUtils { ? storyModel.getVideoUrl() : storyModel.getStoryUrl(); final File saveFile = new File(downloadDir, - storyModel.getStoryMediaId() + storyModel.getUsername() + storyModel.getStoryMediaId() + "_" + storyModel.getTimestamp() + DownloadUtils.getFileExtensionFromUrl(url)); download(context, url, saveFile.getAbsolutePath()); @@ -297,7 +307,12 @@ public final class DownloadUtils { case MEDIA_TYPE_IMAGE: case MEDIA_TYPE_VIDEO: { final String url = getUrlOfType(media); - final File file = getDownloadSaveFile(downloadDir, media.getCode(), url); + final File file; + if (Utils.settingsHelper.getBoolean(Constants.DOWNLOAD_PREPEND_USER_NAME) && mediaUser != null) { + file = getDownloadSaveFile(downloadDir, media.getCode(), url, mediaUser.getUsername()); + } else { + file = getDownloadSaveFile(downloadDir, media.getCode(), url); + } map.put(url, file.getAbsolutePath()); break; } diff --git a/app/src/main/java/awais/instagrabber/utils/SettingsHelper.java b/app/src/main/java/awais/instagrabber/utils/SettingsHelper.java index 1ff49767..dd3437de 100755 --- a/app/src/main/java/awais/instagrabber/utils/SettingsHelper.java +++ b/app/src/main/java/awais/instagrabber/utils/SettingsHelper.java @@ -33,6 +33,7 @@ import static awais.instagrabber.utils.Constants.DATE_TIME_SELECTION; import static awais.instagrabber.utils.Constants.DEFAULT_TAB; import static awais.instagrabber.utils.Constants.DEVICE_UUID; import static awais.instagrabber.utils.Constants.DM_MARK_AS_SEEN; +import static awais.instagrabber.utils.Constants.DOWNLOAD_PREPEND_USER_NAME; import static awais.instagrabber.utils.Constants.DOWNLOAD_USER_FOLDER; import static awais.instagrabber.utils.Constants.FLAG_SECURE; import static awais.instagrabber.utils.Constants.FOLDER_PATH; @@ -158,7 +159,7 @@ public final class SettingsHelper { STORY_SORT, PREF_EMOJI_VARIANTS, PREF_REACTIONS, PREF_ENABLE_DM_AUTO_REFRESH_FREQ_UNIT}) public @interface StringSettings {} - @StringDef({DOWNLOAD_USER_FOLDER, FOLDER_SAVE_TO, AUTOPLAY_VIDEOS, SHOW_QUICK_ACCESS_DIALOG, MUTED_VIDEOS, + @StringDef({DOWNLOAD_USER_FOLDER, DOWNLOAD_PREPEND_USER_NAME, FOLDER_SAVE_TO, AUTOPLAY_VIDEOS, SHOW_QUICK_ACCESS_DIALOG, MUTED_VIDEOS, SHOW_CAPTIONS, CUSTOM_DATE_TIME_FORMAT_ENABLED, MARK_AS_SEEN, DM_MARK_AS_SEEN, CHECK_ACTIVITY, CHECK_UPDATES, SWAP_DATE_TIME_FORMAT_ENABLED, PREF_ENABLE_DM_NOTIFICATIONS, PREF_ENABLE_DM_AUTO_REFRESH, FLAG_SECURE, TOGGLE_KEYWORD_FILTER, PREF_ENABLE_SENTRY}) diff --git a/app/src/main/res/values-ca/strings.xml b/app/src/main/res/values-ca/strings.xml index 18b0557d..02092f94 100644 --- a/app/src/main/res/values-ca/strings.xml +++ b/app/src/main/res/values-ca/strings.xml @@ -23,6 +23,7 @@ Cerca actualitzacions a l\'inici Block screenshots & app preview Descarrega les publicacions a carpetes de nom d\'usuari + Prepend Username to Filename Marca les històries com a vistes després de visualitzar-es L\'autor de la història sabrà que l\'has vista Marca els missatges com a vists després de visualitzar-los diff --git a/app/src/main/res/values-cs/strings.xml b/app/src/main/res/values-cs/strings.xml index 0bb9e0ac..c5bc0f11 100644 --- a/app/src/main/res/values-cs/strings.xml +++ b/app/src/main/res/values-cs/strings.xml @@ -23,6 +23,7 @@ Zkontrolovat aktualizace při spuštění Block screenshots & app preview Stáhnout příspěvky do složek s uživatelským jménem + Prepend Username to Filename Označit příběhy po zhlédnutí jako zobrazené Autor příběhu bude vědět, že jsi si ho zobrazili Označovat přímou zprávu po zobrazení jako zobrazenou diff --git a/app/src/main/res/values-de/strings.xml b/app/src/main/res/values-de/strings.xml index 1f541fcd..e023c6b9 100644 --- a/app/src/main/res/values-de/strings.xml +++ b/app/src/main/res/values-de/strings.xml @@ -23,6 +23,7 @@ Beim Start auf Aktualisierungen prüfen Block screenshots & app preview Beiträge in Benutzernamen-Ordner herunterladen + Prepend Username to Filename Stories nach dem Ansehen als gesehen markieren Die Person wird wissen, dass du dir die Story angesehen hast Direktnachrichten nach dem Ansehen als gesehen markieren diff --git a/app/src/main/res/values-el/strings.xml b/app/src/main/res/values-el/strings.xml index f9817a0a..b8c7df56 100644 --- a/app/src/main/res/values-el/strings.xml +++ b/app/src/main/res/values-el/strings.xml @@ -23,6 +23,7 @@ Έλεγχος για ενημερώσεις στο ξεκίνημα Block screenshots & app preview Λήψη δημοσίευσης στους φακέλους με ονόματα χρηστών + Prepend Username to Filename Επισήμανση ιστοριών ως προβληθέντων μετά την προβολή Ο συντάκτης της ιστορίας θα ξέρει ότι την προβάλατε Σήμανση ΠΜ ως αναγνωσμένου μετά την προβολή diff --git a/app/src/main/res/values-es/strings.xml b/app/src/main/res/values-es/strings.xml index f392ec86..9ee7d1d0 100755 --- a/app/src/main/res/values-es/strings.xml +++ b/app/src/main/res/values-es/strings.xml @@ -23,6 +23,7 @@ Buscar actualizaciones al inicio Bloquea capturas de pantalla & vista previa de aplicaciones Usar subcarpetas con el nombre de usuario + Prepend Username to Filename Marcar historias como vistas después de verlas El autor de la historia sabrá que lo has visto Marcar Mensaje Directo como visto después de verlo diff --git a/app/src/main/res/values-eu/strings.xml b/app/src/main/res/values-eu/strings.xml index dd0321e2..8f217f17 100644 --- a/app/src/main/res/values-eu/strings.xml +++ b/app/src/main/res/values-eu/strings.xml @@ -23,6 +23,7 @@ Bilatu eguneratzeak abioan Block screenshots & app preview Deskargatu bidalketak erabiltzaile-izena duten karpetetara + Prepend Username to Filename Markatu istorioak ikusita gisa ikusi ondoren Istorioaren egileak ikusi duzula jakingo du Markatu MZ ikusita gisa ikusi ondoren diff --git a/app/src/main/res/values-fa/strings.xml b/app/src/main/res/values-fa/strings.xml index c6da89cf..75371835 100644 --- a/app/src/main/res/values-fa/strings.xml +++ b/app/src/main/res/values-fa/strings.xml @@ -23,6 +23,7 @@ بررسی بروزرسانی هنگام آغاز برنامه Block screenshots & app preview بارگیری پست ها در پوشه های به نام کاربر + Prepend Username to Filename نشان کرد استوری ها به عنوان دیده شده بعد از دیدن نویسنده استوری می داند که شما آن را دیده اید نشان کردن پیام خصوصی بعنوان دیده شده بعد از دیدن diff --git a/app/src/main/res/values-fr/strings.xml b/app/src/main/res/values-fr/strings.xml index 15f8a5cc..d2fd93dd 100755 --- a/app/src/main/res/values-fr/strings.xml +++ b/app/src/main/res/values-fr/strings.xml @@ -23,6 +23,7 @@ Rechercher les mises à jours au démarrage Bloquer les captures d\'écran & l\'aperçu de l\'application Télécharger les messages dans les dossiers des noms d\'utilisateurs + Prepend Username to Filename Marquer les stories comme vues après consultation L\'auteur de la story saura que vous l\'avez vue Marquer les messages privés comme vus après consultation diff --git a/app/src/main/res/values-hi/strings.xml b/app/src/main/res/values-hi/strings.xml index bc923135..623bc2ce 100644 --- a/app/src/main/res/values-hi/strings.xml +++ b/app/src/main/res/values-hi/strings.xml @@ -23,6 +23,7 @@ खुलने पर अपडेट के लिए जाँच करें Block screenshots & app preview पोस्ट को ब्यबहारकारी के नाम पर किये फोल्डरस में रखें + Prepend Username to Filename स्टोरि को दिखने के बाद \"दिखा गया\" दिखादें सटोरि के लेखक जानेगा कि तुम देखे हो इसको तुम देखने के बाद सीधा संदेश को \"दिखागया\" लिखा जाएगा diff --git a/app/src/main/res/values-in/strings.xml b/app/src/main/res/values-in/strings.xml index 462c1a2e..6801759b 100644 --- a/app/src/main/res/values-in/strings.xml +++ b/app/src/main/res/values-in/strings.xml @@ -23,6 +23,7 @@ Cek pembaruan saat memulai Block screenshots & app preview Unduh kiriman ke folder nama pengguna + Prepend Username to Filename Tandai cerita dibaca setelah melihat Pembuat cerita akan tahu Anda melihatnya Tandai DM dibaca setelah melihat diff --git a/app/src/main/res/values-it/strings.xml b/app/src/main/res/values-it/strings.xml index d8202389..eefead25 100755 --- a/app/src/main/res/values-it/strings.xml +++ b/app/src/main/res/values-it/strings.xml @@ -23,6 +23,7 @@ Verifica per aggiornamenti all\'avvio Blocca screenshot & anteprima app Scarica i post nelle cartelle del nome utente + Prepend Username to Filename Segna le storie come viste dopo la visualizzazione L\'autore della storia saprà che l\'hai visualizzata Segna il DM come visto dopo la visualizzazione diff --git a/app/src/main/res/values-ja/strings.xml b/app/src/main/res/values-ja/strings.xml index 5a11dc06..178f3726 100644 --- a/app/src/main/res/values-ja/strings.xml +++ b/app/src/main/res/values-ja/strings.xml @@ -23,6 +23,7 @@ 起動時にアップデートを確認 Block screenshots & app preview ユーザ名のフォルダに投稿をダウンロード + Prepend Username to Filename ストーリーズを表示後に既読にする ストーリーの作成者は、あなたが閲覧したことを知ることができます。 DMを表示後に既読にする diff --git a/app/src/main/res/values-kn/strings.xml b/app/src/main/res/values-kn/strings.xml index 80d8b915..85c0390c 100644 --- a/app/src/main/res/values-kn/strings.xml +++ b/app/src/main/res/values-kn/strings.xml @@ -23,6 +23,7 @@ Check for updates at startup Block screenshots & app preview Download posts to username folders + Prepend Username to Filename Mark stories as seen after viewing Story author will know you viewed it Mark DM as seen after viewing diff --git a/app/src/main/res/values-mk/strings.xml b/app/src/main/res/values-mk/strings.xml index abb89551..118e07f4 100644 --- a/app/src/main/res/values-mk/strings.xml +++ b/app/src/main/res/values-mk/strings.xml @@ -23,6 +23,7 @@ Провери за ажурирање Block screenshots & app preview Превземи објави во папката со кориснички имиња + Prepend Username to Filename Означи ги приказните како видени Авторот на приказната ќе знае дека сте ја погледнале приказната Означи порака како видена diff --git a/app/src/main/res/values-nl/strings.xml b/app/src/main/res/values-nl/strings.xml index fda4c863..b904bed6 100644 --- a/app/src/main/res/values-nl/strings.xml +++ b/app/src/main/res/values-nl/strings.xml @@ -23,6 +23,7 @@ Controleer op updates bij het opstarten Block screenshots & app preview Download berichten naar gebruikersnaam mappen + Prepend Username to Filename Markeer verhalen als gelezen na bekijken Verhaalmaker zal het weten als je het bekeken hebt Markeer privéberichten als gelezen na bekijken diff --git a/app/src/main/res/values-or/strings.xml b/app/src/main/res/values-or/strings.xml index ce4427ec..12b95d7b 100644 --- a/app/src/main/res/values-or/strings.xml +++ b/app/src/main/res/values-or/strings.xml @@ -23,6 +23,7 @@ ଖୋଲିବା ସମୟରେ ଅପଡେଟ ପାଇଁ ଯାଞ୍ଚ କରନ୍ତୁ Block screenshots & app preview ଡାଉନଲୋଡ ପୋଷ୍ଟକୁ ବ୍ୟବହାରକାରୀଙ୍କ ନାମରେ ହୋଇଥିବା ସ୍ଥାନ ରେ ରଖ + Prepend Username to Filename କାହାଣୀଗୁଡିକ ଦେଖିବା ପରେ \'ଦେଖାଗଲା\' ଚିହ୍ନିତ କରନ୍ତୁ | କାହାଣୀ ପ୍ରେରକ ଜାଣିବେ ତୁମେ ଏହାକୁ ଦେଖିଛ ବାର୍ତା ଦେଖିବା ପରେ \'ଦେଖାଗଲା\' ଚିହ୍ନିତ କରନ୍ତୁ | diff --git a/app/src/main/res/values-pl/strings.xml b/app/src/main/res/values-pl/strings.xml index 93fb3ff8..2c449634 100644 --- a/app/src/main/res/values-pl/strings.xml +++ b/app/src/main/res/values-pl/strings.xml @@ -23,6 +23,7 @@ Sprawdź aktualizacje przy starcie Blokuj zrzuty ekranu & podgląd aplikacji Pobierz posty do folderów o nazwie użytkownika + Prepend Username to Filename Oznacz relacje jako widoczne po wyświetleniu Autor relacji będzie widział, że to wyświetliłeś Oznacz wiadomość jako przeczytaną diff --git a/app/src/main/res/values-pt/strings.xml b/app/src/main/res/values-pt/strings.xml index 4c7bbbc4..f8c3f401 100644 --- a/app/src/main/res/values-pt/strings.xml +++ b/app/src/main/res/values-pt/strings.xml @@ -23,6 +23,7 @@ Verificar se há atualizações ao iniciar Block screenshots & app preview Baixar publicações para pastas com o nome de usuário + Prepend Username to Filename Marcar stories como vistos após a visualização O autor do story saberá que você viu Marcar DM como vista após a visualização diff --git a/app/src/main/res/values-ru/strings.xml b/app/src/main/res/values-ru/strings.xml index b491a1c5..ca3155ef 100644 --- a/app/src/main/res/values-ru/strings.xml +++ b/app/src/main/res/values-ru/strings.xml @@ -23,6 +23,7 @@ Проверять наличие обновлений при запуске Block screenshots & app preview Скачать публикации в папки с именем пользователя + Prepend Username to Filename Отметить истории как увиденные после просмотра Автор истории узнает, что вы просмотрели её Отметить ЛС как увиденные после просмотра diff --git a/app/src/main/res/values-sk/strings.xml b/app/src/main/res/values-sk/strings.xml index f12178ec..7b1c175a 100644 --- a/app/src/main/res/values-sk/strings.xml +++ b/app/src/main/res/values-sk/strings.xml @@ -23,6 +23,7 @@ Kontrolovať aktualizácie pri štarte Block screenshots & app preview Ukľadať do priečinkov podľa mena + Prepend Username to Filename Označiť príbehy po videní ako videné Autor príbehu bude vedieť že ste ho videli Po prečítaní, označiť správu ako prečítanú diff --git a/app/src/main/res/values-tr/strings.xml b/app/src/main/res/values-tr/strings.xml index 4ca6836d..fea3a299 100644 --- a/app/src/main/res/values-tr/strings.xml +++ b/app/src/main/res/values-tr/strings.xml @@ -23,6 +23,7 @@ Güncellemeleri başlangıçta kontrol et Block screenshots & app preview İndirmeleri kullanıcı adından oluşan bir alt klasörün içine yap + Prepend Username to Filename Hikayeleri gördükten sonra görüldü olarak işaretle Hikayeyi paylaşan gördüğünüzü bilecek DM\'leri gördükten sonra görüldü olarak işaretle diff --git a/app/src/main/res/values-vi/strings.xml b/app/src/main/res/values-vi/strings.xml index debb92fc..858193f6 100644 --- a/app/src/main/res/values-vi/strings.xml +++ b/app/src/main/res/values-vi/strings.xml @@ -23,6 +23,7 @@ Kiểm tra cập nhật khi khởi động Block screenshots & app preview Tải bài viết xuống theo thư mục tên người dùng trong Downloads + Prepend Username to Filename Đánh dấu story là đã xem sau khi xem Người đăng story sẽ biết bạn đã xem nó Đánh dấu DM là đã xem sau khi xem diff --git a/app/src/main/res/values-zh-rCN/strings.xml b/app/src/main/res/values-zh-rCN/strings.xml index a6fe9c77..0fb2193f 100644 --- a/app/src/main/res/values-zh-rCN/strings.xml +++ b/app/src/main/res/values-zh-rCN/strings.xml @@ -23,6 +23,7 @@ 启动时检查更新 屏蔽截图及应用预览 下载帖子到用户名文件夹 + Prepend Username to Filename 查看快拍后将其标记为已读 快拍作者会知道您已看过 查看私信后将其标记为已读 diff --git a/app/src/main/res/values-zh-rTW/strings.xml b/app/src/main/res/values-zh-rTW/strings.xml index 26371e94..3ce706fa 100644 --- a/app/src/main/res/values-zh-rTW/strings.xml +++ b/app/src/main/res/values-zh-rTW/strings.xml @@ -23,6 +23,7 @@ 啟動時檢查更新 Block screenshots & app preview 將貼文下載到用戶名資料夾 + Prepend Username to Filename 檢視完限時動態後標記為已讀 限時動態的作者會知道您已查看了此限時動態 檢視完訊息後標記為已讀 diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index d3b7cf2b..11a44e5d 100755 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -26,6 +26,7 @@ Check for updates at startup Block screenshots & app preview Download posts to username folders + Prepend Username to Filename Mark stories as seen after viewing Story author will know you viewed it Mark DM as seen after viewing