From e13bb9488a5e5fb8395e85eec238145abd39f6ae Mon Sep 17 00:00:00 2001 From: bjoern Date: Wed, 21 Sep 2022 22:49:49 +0200 Subject: [PATCH] add 'Audio' tab to profile (#2387) --- src/org/thoughtcrime/securesms/ProfileActivity.java | 12 ++++++++++++ .../securesms/ProfileDocumentsFragment.java | 13 ++++++++++--- 2 files changed, 22 insertions(+), 3 deletions(-) diff --git a/src/org/thoughtcrime/securesms/ProfileActivity.java b/src/org/thoughtcrime/securesms/ProfileActivity.java index 50a8da50e..d4af63976 100644 --- a/src/org/thoughtcrime/securesms/ProfileActivity.java +++ b/src/org/thoughtcrime/securesms/ProfileActivity.java @@ -56,6 +56,7 @@ public class ProfileActivity extends PassphraseRequiredActionBarActivity public static final int TAB_SETTINGS = 10; public static final int TAB_GALLERY = 20; + public static final int TAB_AUDIO = 25; public static final int TAB_DOCS = 30; public static final int TAB_WEBXDC = 35; public static final int TAB_LINKS = 40; @@ -243,6 +244,7 @@ public class ProfileActivity extends PassphraseRequiredActionBarActivity tabs.add(TAB_SETTINGS); } tabs.add(TAB_GALLERY); + tabs.add(TAB_AUDIO); tabs.add(TAB_DOCS); tabs.add(TAB_WEBXDC); //tabs.add(TAB_LINKS); @@ -325,6 +327,13 @@ public class ProfileActivity extends PassphraseRequiredActionBarActivity args.putSerializable(ProfileGalleryFragment.LOCALE_EXTRA, dynamicLanguage.getCurrentLocale()); break; + case TAB_AUDIO: + fragment = new ProfileDocumentsFragment(); + args.putInt(ProfileDocumentsFragment.CHAT_ID_EXTRA, (chatId==0&&!isGlobalProfile())? -1 : chatId); + args.putBoolean(ProfileDocumentsFragment.SHOW_AUDIO_EXTRA, true); + args.putSerializable(ProfileDocumentsFragment.LOCALE_EXTRA, dynamicLanguage.getCurrentLocale()); + break; + case TAB_WEBXDC: fragment = new ProfileDocumentsFragment(); args.putInt(ProfileDocumentsFragment.CHAT_ID_EXTRA, (chatId==0&&!isGlobalProfile())? -1 : chatId); @@ -370,6 +379,9 @@ public class ProfileActivity extends PassphraseRequiredActionBarActivity case TAB_GALLERY: return getString(R.string.tab_gallery); + case TAB_AUDIO: + return getString(R.string.audio); + case TAB_DOCS: return getString(R.string.files); diff --git a/src/org/thoughtcrime/securesms/ProfileDocumentsFragment.java b/src/org/thoughtcrime/securesms/ProfileDocumentsFragment.java index 42354b025..746328fd5 100644 --- a/src/org/thoughtcrime/securesms/ProfileDocumentsFragment.java +++ b/src/org/thoughtcrime/securesms/ProfileDocumentsFragment.java @@ -39,12 +39,14 @@ public class ProfileDocumentsFragment { public static final String LOCALE_EXTRA = "locale_extra"; public static final String CHAT_ID_EXTRA = "chat_id"; + public static final String SHOW_AUDIO_EXTRA = "show_audio"; public static final String SHOW_WEBXDC_EXTRA = "show_webxdc"; protected TextView noMedia; protected RecyclerView recyclerView; private StickyHeaderGridLayoutManager gridManager; private ActionModeCallback actionModeCallback = new ActionModeCallback(); + private boolean showAudio; private boolean showWebxdc; protected int chatId; @@ -56,6 +58,7 @@ public class ProfileDocumentsFragment dcContext = DcHelper.getContext(getContext()); chatId = getArguments().getInt(CHAT_ID_EXTRA, -1); + showAudio = getArguments().getBoolean(SHOW_AUDIO_EXTRA, false); showWebxdc = getArguments().getBoolean(SHOW_WEBXDC_EXTRA, false); locale = (Locale)getArguments().getSerializable(LOCALE_EXTRA); if (locale == null) throw new AssertionError(); @@ -106,10 +109,12 @@ public class ProfileDocumentsFragment @Override public Loader onCreateLoader(int i, Bundle bundle) { - if (showWebxdc) { + if (showAudio) { + return new BucketedThreadMediaLoader(getContext(), chatId, DcMsg.DC_MSG_AUDIO, DcMsg.DC_MSG_VOICE, 0); + } else if (showWebxdc) { return new BucketedThreadMediaLoader(getContext(), chatId, DcMsg.DC_MSG_WEBXDC, 0, 0); } else { - return new BucketedThreadMediaLoader(getContext(), chatId, DcMsg.DC_MSG_FILE, DcMsg.DC_MSG_AUDIO, 0); + return new BucketedThreadMediaLoader(getContext(), chatId, DcMsg.DC_MSG_FILE, 0, 0); } } @@ -119,7 +124,9 @@ public class ProfileDocumentsFragment ((ProfileDocumentsAdapter) recyclerView.getAdapter()).notifyAllSectionsDataSetChanged(); noMedia.setVisibility(recyclerView.getAdapter().getItemCount() > 0 ? View.GONE : View.VISIBLE); - if (showWebxdc) { + if (showAudio) { + noMedia.setText(R.string.tab_audio_empty_hint); + } else if (showWebxdc) { noMedia.setText(R.string.tab_webxdc_empty_hint); } getActivity().invalidateOptionsMenu();