1
0
mirror of https://github.com/KokaKiwi/BarInsta synced 2024-11-22 06:37:30 +00:00

initial implementation

This commit is contained in:
junhuicoding 2021-03-31 22:53:56 +08:00
parent cbb7b8654a
commit a2be48029f
29 changed files with 57 additions and 6 deletions

View File

@ -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;

View File

@ -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";

View File

@ -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;
}

View File

@ -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})

View File

@ -23,6 +23,7 @@
<string name="update_check">Cerca actualitzacions a l\'inici</string>
<string name="flag_secure">Block screenshots &amp; app preview</string>
<string name="download_user_folder">Descarrega les publicacions a carpetes de nom d\'usuari</string>
<string name="download_prepend_username">Prepend Username to Filename</string>
<string name="mark_as_seen_setting">Marca les històries com a vistes després de visualitzar-es</string>
<string name="mark_as_seen_setting_summary">L\'autor de la història sabrà que l\'has vista</string>
<string name="dm_mark_as_seen_setting">Marca els missatges com a vists després de visualitzar-los</string>

View File

@ -23,6 +23,7 @@
<string name="update_check">Zkontrolovat aktualizace při spuštění</string>
<string name="flag_secure">Block screenshots &amp; app preview</string>
<string name="download_user_folder">Stáhnout příspěvky do složek s uživatelským jménem</string>
<string name="download_prepend_username">Prepend Username to Filename</string>
<string name="mark_as_seen_setting">Označit příběhy po zhlédnutí jako zobrazené</string>
<string name="mark_as_seen_setting_summary">Autor příběhu bude vědět, že jsi si ho zobrazili</string>
<string name="dm_mark_as_seen_setting">Označovat přímou zprávu po zobrazení jako zobrazenou</string>

View File

@ -23,6 +23,7 @@
<string name="update_check">Beim Start auf Aktualisierungen prüfen</string>
<string name="flag_secure">Block screenshots &amp; app preview</string>
<string name="download_user_folder">Beiträge in Benutzernamen-Ordner herunterladen</string>
<string name="download_prepend_username">Prepend Username to Filename</string>
<string name="mark_as_seen_setting">Stories nach dem Ansehen als gesehen markieren</string>
<string name="mark_as_seen_setting_summary">Die Person wird wissen, dass du dir die Story angesehen hast</string>
<string name="dm_mark_as_seen_setting">Direktnachrichten nach dem Ansehen als gesehen markieren</string>

View File

@ -23,6 +23,7 @@
<string name="update_check">Έλεγχος για ενημερώσεις στο ξεκίνημα</string>
<string name="flag_secure">Block screenshots &amp; app preview</string>
<string name="download_user_folder">Λήψη δημοσίευσης στους φακέλους με ονόματα χρηστών</string>
<string name="download_prepend_username">Prepend Username to Filename</string>
<string name="mark_as_seen_setting">Επισήμανση ιστοριών ως προβληθέντων μετά την προβολή</string>
<string name="mark_as_seen_setting_summary">Ο συντάκτης της ιστορίας θα ξέρει ότι την προβάλατε</string>
<string name="dm_mark_as_seen_setting">Σήμανση ΠΜ ως αναγνωσμένου μετά την προβολή</string>

View File

@ -23,6 +23,7 @@
<string name="update_check">Buscar actualizaciones al inicio</string>
<string name="flag_secure">Bloquea capturas de pantalla &amp; vista previa de aplicaciones</string>
<string name="download_user_folder">Usar subcarpetas con el nombre de usuario</string>
<string name="download_prepend_username">Prepend Username to Filename</string>
<string name="mark_as_seen_setting">Marcar historias como vistas después de verlas</string>
<string name="mark_as_seen_setting_summary">El autor de la historia sabrá que lo has visto</string>
<string name="dm_mark_as_seen_setting">Marcar Mensaje Directo como visto después de verlo</string>

View File

@ -23,6 +23,7 @@
<string name="update_check">Bilatu eguneratzeak abioan</string>
<string name="flag_secure">Block screenshots &amp; app preview</string>
<string name="download_user_folder">Deskargatu bidalketak erabiltzaile-izena duten karpetetara</string>
<string name="download_prepend_username">Prepend Username to Filename</string>
<string name="mark_as_seen_setting">Markatu istorioak ikusita gisa ikusi ondoren</string>
<string name="mark_as_seen_setting_summary">Istorioaren egileak ikusi duzula jakingo du</string>
<string name="dm_mark_as_seen_setting">Markatu MZ ikusita gisa ikusi ondoren</string>

View File

@ -23,6 +23,7 @@
<string name="update_check">بررسی بروزرسانی هنگام آغاز برنامه</string>
<string name="flag_secure">Block screenshots &amp; app preview</string>
<string name="download_user_folder">بارگیری پست ها در پوشه های به نام کاربر</string>
<string name="download_prepend_username">Prepend Username to Filename</string>
<string name="mark_as_seen_setting">نشان کرد استوری ها به عنوان دیده شده بعد از دیدن</string>
<string name="mark_as_seen_setting_summary">نویسنده استوری می داند که شما آن را دیده اید</string>
<string name="dm_mark_as_seen_setting">نشان کردن پیام خصوصی بعنوان دیده شده بعد از دیدن</string>

View File

@ -23,6 +23,7 @@
<string name="update_check">Rechercher les mises à jours au démarrage</string>
<string name="flag_secure">Bloquer les captures d\'écran &amp; l\'aperçu de l\'application</string>
<string name="download_user_folder">Télécharger les messages dans les dossiers des noms d\'utilisateurs</string>
<string name="download_prepend_username">Prepend Username to Filename</string>
<string name="mark_as_seen_setting">Marquer les stories comme vues après consultation</string>
<string name="mark_as_seen_setting_summary">L\'auteur de la story saura que vous l\'avez vue</string>
<string name="dm_mark_as_seen_setting">Marquer les messages privés comme vus après consultation</string>

View File

@ -23,6 +23,7 @@
<string name="update_check">खुलने पर अपडेट के लिए जाँच करें</string>
<string name="flag_secure">Block screenshots &amp; app preview</string>
<string name="download_user_folder">पोस्ट को ब्यबहारकारी के नाम पर किये फोल्डरस में रखें</string>
<string name="download_prepend_username">Prepend Username to Filename</string>
<string name="mark_as_seen_setting">स्टोरि को दिखने के बाद \"दिखा गया\" दिखादें</string>
<string name="mark_as_seen_setting_summary">सटोरि के लेखक जानेगा कि तुम देखे हो इसको</string>
<string name="dm_mark_as_seen_setting">तुम देखने के बाद सीधा संदेश को \"दिखागया\" लिखा जाएगा</string>

View File

@ -23,6 +23,7 @@
<string name="update_check">Cek pembaruan saat memulai</string>
<string name="flag_secure">Block screenshots &amp; app preview</string>
<string name="download_user_folder">Unduh kiriman ke folder nama pengguna</string>
<string name="download_prepend_username">Prepend Username to Filename</string>
<string name="mark_as_seen_setting">Tandai cerita dibaca setelah melihat</string>
<string name="mark_as_seen_setting_summary">Pembuat cerita akan tahu Anda melihatnya</string>
<string name="dm_mark_as_seen_setting">Tandai DM dibaca setelah melihat</string>

View File

@ -23,6 +23,7 @@
<string name="update_check">Verifica per aggiornamenti all\'avvio</string>
<string name="flag_secure">Blocca screenshot &amp; anteprima app</string>
<string name="download_user_folder">Scarica i post nelle cartelle del nome utente</string>
<string name="download_prepend_username">Prepend Username to Filename</string>
<string name="mark_as_seen_setting">Segna le storie come viste dopo la visualizzazione</string>
<string name="mark_as_seen_setting_summary">L\'autore della storia saprà che l\'hai visualizzata</string>
<string name="dm_mark_as_seen_setting">Segna il DM come visto dopo la visualizzazione</string>

View File

@ -23,6 +23,7 @@
<string name="update_check">起動時にアップデートを確認</string>
<string name="flag_secure">Block screenshots &amp; app preview</string>
<string name="download_user_folder">ユーザ名のフォルダに投稿をダウンロード</string>
<string name="download_prepend_username">Prepend Username to Filename</string>
<string name="mark_as_seen_setting">ストーリーズを表示後に既読にする</string>
<string name="mark_as_seen_setting_summary">ストーリーの作成者は、あなたが閲覧したことを知ることができます。</string>
<string name="dm_mark_as_seen_setting">DMを表示後に既読にする</string>

View File

@ -23,6 +23,7 @@
<string name="update_check">Check for updates at startup</string>
<string name="flag_secure">Block screenshots &amp; app preview</string>
<string name="download_user_folder">Download posts to username folders</string>
<string name="download_prepend_username">Prepend Username to Filename</string>
<string name="mark_as_seen_setting">Mark stories as seen after viewing</string>
<string name="mark_as_seen_setting_summary">Story author will know you viewed it</string>
<string name="dm_mark_as_seen_setting">Mark DM as seen after viewing</string>

View File

@ -23,6 +23,7 @@
<string name="update_check">Провери за ажурирање</string>
<string name="flag_secure">Block screenshots &amp; app preview</string>
<string name="download_user_folder">Превземи објави во папката со кориснички имиња</string>
<string name="download_prepend_username">Prepend Username to Filename</string>
<string name="mark_as_seen_setting">Означи ги приказните како видени</string>
<string name="mark_as_seen_setting_summary">Авторот на приказната ќе знае дека сте ја погледнале приказната</string>
<string name="dm_mark_as_seen_setting">Означи порака како видена</string>

View File

@ -23,6 +23,7 @@
<string name="update_check">Controleer op updates bij het opstarten</string>
<string name="flag_secure">Block screenshots &amp; app preview</string>
<string name="download_user_folder">Download berichten naar gebruikersnaam mappen</string>
<string name="download_prepend_username">Prepend Username to Filename</string>
<string name="mark_as_seen_setting">Markeer verhalen als gelezen na bekijken</string>
<string name="mark_as_seen_setting_summary">Verhaalmaker zal het weten als je het bekeken hebt</string>
<string name="dm_mark_as_seen_setting">Markeer privéberichten als gelezen na bekijken</string>

View File

@ -23,6 +23,7 @@
<string name="update_check">ଖୋଲିବା ସମୟରେ ଅପଡେଟ ପାଇଁ ଯାଞ୍ଚ କରନ୍ତୁ</string>
<string name="flag_secure">Block screenshots &amp; app preview</string>
<string name="download_user_folder">ଡାଉନଲୋଡ ପୋଷ୍ଟକୁ ବ୍ୟବହାରକାରୀଙ୍କ ନାମରେ ହୋଇଥିବା ସ୍ଥାନ ରେ ରଖ</string>
<string name="download_prepend_username">Prepend Username to Filename</string>
<string name="mark_as_seen_setting">କାହାଣୀଗୁଡିକ ଦେଖିବା ପରେ \'ଦେଖାଗଲା\' ଚିହ୍ନିତ କରନ୍ତୁ |</string>
<string name="mark_as_seen_setting_summary">କାହାଣୀ ପ୍ରେରକ ଜାଣିବେ ତୁମେ ଏହାକୁ ଦେଖିଛ</string>
<string name="dm_mark_as_seen_setting">ବାର୍ତା ଦେଖିବା ପରେ \'ଦେଖାଗଲା\' ଚିହ୍ନିତ କରନ୍ତୁ |</string>

View File

@ -23,6 +23,7 @@
<string name="update_check">Sprawdź aktualizacje przy starcie</string>
<string name="flag_secure">Blokuj zrzuty ekranu &amp; podgląd aplikacji</string>
<string name="download_user_folder">Pobierz posty do folderów o nazwie użytkownika</string>
<string name="download_prepend_username">Prepend Username to Filename</string>
<string name="mark_as_seen_setting">Oznacz relacje jako widoczne po wyświetleniu</string>
<string name="mark_as_seen_setting_summary">Autor relacji będzie widział, że to wyświetliłeś</string>
<string name="dm_mark_as_seen_setting">Oznacz wiadomość jako przeczytaną</string>

View File

@ -23,6 +23,7 @@
<string name="update_check">Verificar se há atualizações ao iniciar</string>
<string name="flag_secure">Block screenshots &amp; app preview</string>
<string name="download_user_folder">Baixar publicações para pastas com o nome de usuário</string>
<string name="download_prepend_username">Prepend Username to Filename</string>
<string name="mark_as_seen_setting">Marcar stories como vistos após a visualização</string>
<string name="mark_as_seen_setting_summary">O autor do story saberá que você viu</string>
<string name="dm_mark_as_seen_setting">Marcar DM como vista após a visualização</string>

View File

@ -23,6 +23,7 @@
<string name="update_check">Проверять наличие обновлений при запуске</string>
<string name="flag_secure">Block screenshots &amp; app preview</string>
<string name="download_user_folder">Скачать публикации в папки с именем пользователя</string>
<string name="download_prepend_username">Prepend Username to Filename</string>
<string name="mark_as_seen_setting">Отметить истории как увиденные после просмотра</string>
<string name="mark_as_seen_setting_summary">Автор истории узнает, что вы просмотрели её</string>
<string name="dm_mark_as_seen_setting">Отметить ЛС как увиденные после просмотра</string>

View File

@ -23,6 +23,7 @@
<string name="update_check">Kontrolovať aktualizácie pri štarte</string>
<string name="flag_secure">Block screenshots &amp; app preview</string>
<string name="download_user_folder">Ukľadať do priečinkov podľa mena</string>
<string name="download_prepend_username">Prepend Username to Filename</string>
<string name="mark_as_seen_setting">Označiť príbehy po videní ako videné</string>
<string name="mark_as_seen_setting_summary">Autor príbehu bude vedieť že ste ho videli</string>
<string name="dm_mark_as_seen_setting">Po prečítaní, označiť správu ako prečítanú</string>

View File

@ -23,6 +23,7 @@
<string name="update_check">Güncellemeleri başlangıçta kontrol et</string>
<string name="flag_secure">Block screenshots &amp; app preview</string>
<string name="download_user_folder">İndirmeleri kullanıcı adından oluşan bir alt klasörün içine yap</string>
<string name="download_prepend_username">Prepend Username to Filename</string>
<string name="mark_as_seen_setting">Hikayeleri gördükten sonra görüldü olarak işaretle</string>
<string name="mark_as_seen_setting_summary">Hikayeyi paylaşan gördüğünüzü bilecek</string>
<string name="dm_mark_as_seen_setting">DM\'leri gördükten sonra görüldü olarak işaretle</string>

View File

@ -23,6 +23,7 @@
<string name="update_check">Kiểm tra cập nhật khi khởi động</string>
<string name="flag_secure">Block screenshots &amp; app preview</string>
<string name="download_user_folder">Tải bài viết xuống theo thư mục tên người dùng trong Downloads</string>
<string name="download_prepend_username">Prepend Username to Filename</string>
<string name="mark_as_seen_setting">Đánh dấu story là đã xem sau khi xem</string>
<string name="mark_as_seen_setting_summary">Người đăng story sẽ biết bạn đã xem nó</string>
<string name="dm_mark_as_seen_setting">Đánh dấu DM là đã xem sau khi xem</string>

View File

@ -23,6 +23,7 @@
<string name="update_check">启动时检查更新</string>
<string name="flag_secure">屏蔽截图及应用预览</string>
<string name="download_user_folder">下载帖子到用户名文件夹</string>
<string name="download_prepend_username">Prepend Username to Filename</string>
<string name="mark_as_seen_setting">查看快拍后将其标记为已读</string>
<string name="mark_as_seen_setting_summary">快拍作者会知道您已看过</string>
<string name="dm_mark_as_seen_setting">查看私信后将其标记为已读</string>

View File

@ -23,6 +23,7 @@
<string name="update_check">啟動時檢查更新</string>
<string name="flag_secure">Block screenshots &amp; app preview</string>
<string name="download_user_folder">將貼文下載到用戶名資料夾</string>
<string name="download_prepend_username">Prepend Username to Filename</string>
<string name="mark_as_seen_setting">檢視完限時動態後標記為已讀</string>
<string name="mark_as_seen_setting_summary">限時動態的作者會知道您已查看了此限時動態</string>
<string name="dm_mark_as_seen_setting">檢視完訊息後標記為已讀</string>

View File

@ -26,6 +26,7 @@
<string name="update_check">Check for updates at startup</string>
<string name="flag_secure">Block screenshots &amp; app preview</string>
<string name="download_user_folder">Download posts to username folders</string>
<string name="download_prepend_username">Prepend Username to Filename</string>
<string name="mark_as_seen_setting">Mark stories as seen after viewing</string>
<string name="mark_as_seen_setting_summary">Story author will know you viewed it</string>
<string name="dm_mark_as_seen_setting">Mark DM as seen after viewing</string>