diff options
Diffstat (limited to 'app/src/main/java/app/fedilab/android/mastodon/ui/fragment')
18 files changed, 546 insertions, 319 deletions
diff --git a/app/src/main/java/app/fedilab/android/mastodon/ui/fragment/media/FragmentMedia.java b/app/src/main/java/app/fedilab/android/mastodon/ui/fragment/media/FragmentMedia.java index b1649b326..6740a6d8e 100644 --- a/app/src/main/java/app/fedilab/android/mastodon/ui/fragment/media/FragmentMedia.java +++ b/app/src/main/java/app/fedilab/android/mastodon/ui/fragment/media/FragmentMedia.java @@ -110,9 +110,17 @@ public class FragmentMedia extends Fragment { enableSliding(true); } }); - binding.mediaPicture.setOnClickListener(v -> ((MediaActivity) requireActivity()).toogleFullScreen()); + binding.mediaPicture.setOnClickListener(v -> { + if (isAdded()) { + ((MediaActivity) requireActivity()).toogleFullScreen(); + } + }); - binding.mediaVideo.setOnClickListener(v -> ((MediaActivity) requireActivity()).toogleFullScreen()); + binding.mediaVideo.setOnClickListener(v -> { + if (isAdded()) { + ((MediaActivity) requireActivity()).toogleFullScreen(); + } + }); String type = attachment.type; String preview_url = attachment.preview_url; @@ -363,7 +371,8 @@ public class FragmentMedia extends Fragment { binding.videoLayout.setVisibility(View.GONE); try { ActivityCompat.finishAfterTransition(requireActivity()); - }catch (Exception ignored){} + } catch (Exception ignored) { + } } } @@ -386,7 +395,9 @@ public class FragmentMedia extends Fragment { @Override public boolean onPreDraw() { imageView.getViewTreeObserver().removeOnPreDrawListener(this); - ActivityCompat.startPostponedEnterTransition(requireActivity()); + if (isAdded()) { + ActivityCompat.startPostponedEnterTransition(requireActivity()); + } return true; } }); diff --git a/app/src/main/java/app/fedilab/android/mastodon/ui/fragment/media/FragmentMediaProfile.java b/app/src/main/java/app/fedilab/android/mastodon/ui/fragment/media/FragmentMediaProfile.java index 8d8daca7d..bea3e7b61 100644 --- a/app/src/main/java/app/fedilab/android/mastodon/ui/fragment/media/FragmentMediaProfile.java +++ b/app/src/main/java/app/fedilab/android/mastodon/ui/fragment/media/FragmentMediaProfile.java @@ -14,6 +14,8 @@ package app.fedilab.android.mastodon.ui.fragment.media; * You should have received a copy of the GNU General Public License along with Fedilab; if not, * see <http://www.gnu.org/licenses>. */ +import static app.fedilab.android.BaseMainActivity.currentAccount; + import android.content.SharedPreferences; import android.os.Bundle; import android.view.LayoutInflater; @@ -38,6 +40,8 @@ import app.fedilab.android.mastodon.client.entities.api.Account; import app.fedilab.android.mastodon.client.entities.api.Attachment; import app.fedilab.android.mastodon.client.entities.api.Status; import app.fedilab.android.mastodon.client.entities.api.Statuses; +import app.fedilab.android.mastodon.client.entities.app.CachedBundle; +import app.fedilab.android.mastodon.exception.DBException; import app.fedilab.android.mastodon.helper.CrossActionHelper; import app.fedilab.android.mastodon.helper.Helper; import app.fedilab.android.mastodon.helper.MastodonHelper; @@ -68,17 +72,37 @@ public class FragmentMediaProfile extends Fragment { SharedPreferences sharedpreferences = PreferenceManager.getDefaultSharedPreferences(requireActivity()); boolean displayScrollBar = sharedpreferences.getBoolean(getString(R.string.SET_TIMELINE_SCROLLBAR), false); binding.recyclerView.setVerticalScrollBarEnabled(displayScrollBar); - Bundle bundle = this.getArguments(); - if (bundle != null) { - accountTimeline = (Account) getArguments().getSerializable(Helper.ARG_ACCOUNT); - checkRemotely = getArguments().getBoolean(Helper.ARG_CHECK_REMOTELY, false); + + if (getArguments() != null) { + long bundleId = getArguments().getLong(Helper.ARG_INTENT_ID, -1); + if (bundleId != -1) { + new CachedBundle(requireActivity()).getBundle(bundleId, currentAccount, this::initializeAfterBundle); + } else { + if (getArguments().containsKey(Helper.ARG_CACHED_ACCOUNT_ID)) { + try { + accountTimeline = new CachedBundle(requireActivity()).getCachedAccount(currentAccount, getArguments().getString(Helper.ARG_CACHED_ACCOUNT_ID)); + } catch (DBException e) { + e.printStackTrace(); + } + } + initializeAfterBundle(getArguments()); + + } + } else { + initializeAfterBundle(null); } return binding.getRoot(); } - @Override - public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) { - super.onViewCreated(view, savedInstanceState); + private void initializeAfterBundle(Bundle bundle) { + + if (bundle != null) { + if (bundle.containsKey(Helper.ARG_ACCOUNT)) { + accountTimeline = (Account) bundle.getSerializable(Helper.ARG_ACCOUNT); + } + checkRemotely = bundle.getBoolean(Helper.ARG_CHECK_REMOTELY, false); + } + flagLoading = false; accountsVM = new ViewModelProvider(requireActivity()).get(AccountsVM.class); mediaStatuses = new ArrayList<>(); @@ -114,7 +138,12 @@ public class FragmentMediaProfile extends Fragment { accountsVM.getAccountStatuses(BaseMainActivity.currentInstance, BaseMainActivity.currentToken, accountTimeline.id, null, null, null, null, null, true, false, MastodonHelper.statusesPerCall(requireActivity())) .observe(getViewLifecycleOwner(), this::initializeStatusesCommonView); } + } + + @Override + public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) { + super.onViewCreated(view, savedInstanceState); } /** diff --git a/app/src/main/java/app/fedilab/android/mastodon/ui/fragment/settings/FragmentComposeSettings.java b/app/src/main/java/app/fedilab/android/mastodon/ui/fragment/settings/FragmentComposeSettings.java index afe46342e..2b27992e4 100644 --- a/app/src/main/java/app/fedilab/android/mastodon/ui/fragment/settings/FragmentComposeSettings.java +++ b/app/src/main/java/app/fedilab/android/mastodon/ui/fragment/settings/FragmentComposeSettings.java @@ -19,6 +19,7 @@ import android.content.SharedPreferences; import android.os.Bundle; import androidx.preference.EditTextPreference; +import androidx.preference.ListPreference; import androidx.preference.MultiSelectListPreference; import androidx.preference.PreferenceFragmentCompat; import androidx.preference.PreferenceManager; @@ -30,6 +31,7 @@ import java.util.Set; import app.fedilab.android.BaseMainActivity; import app.fedilab.android.R; import app.fedilab.android.mastodon.client.entities.app.Languages; +import app.fedilab.android.mastodon.helper.Helper; public class FragmentComposeSettings extends PreferenceFragmentCompat implements SharedPreferences.OnSharedPreferenceChangeListener { @@ -43,12 +45,21 @@ public class FragmentComposeSettings extends PreferenceFragmentCompat implements private void createPref() { SharedPreferences sharedPreferences = PreferenceManager.getDefaultSharedPreferences(requireActivity()); + + //Theme for dialogs + ListPreference SET_THREAD_MESSAGE = findPreference(getString(R.string.SET_THREAD_MESSAGE)); + if (SET_THREAD_MESSAGE != null) { + SET_THREAD_MESSAGE.getContext().setTheme(Helper.dialogStyle()); + } + //--------- + EditTextPreference SET_WATERMARK_TEXT = findPreference(getString(R.string.SET_WATERMARK_TEXT)); if (SET_WATERMARK_TEXT != null) { String val = sharedPreferences.getString(getString(R.string.SET_WATERMARK_TEXT) + BaseMainActivity.currentUserID + BaseMainActivity.currentInstance, sharedPreferences.getString(getString(R.string.SET_WATERMARK_TEXT), null)); SET_WATERMARK_TEXT.setText(val); } + MultiSelectListPreference SET_SELECTED_LANGUAGE = findPreference(getString(R.string.SET_SELECTED_LANGUAGE)); if (SET_SELECTED_LANGUAGE != null) { diff --git a/app/src/main/java/app/fedilab/android/mastodon/ui/fragment/settings/FragmentExtraFeaturesSettings.java b/app/src/main/java/app/fedilab/android/mastodon/ui/fragment/settings/FragmentExtraFeaturesSettings.java index 8ba49507e..4212c66e1 100644 --- a/app/src/main/java/app/fedilab/android/mastodon/ui/fragment/settings/FragmentExtraFeaturesSettings.java +++ b/app/src/main/java/app/fedilab/android/mastodon/ui/fragment/settings/FragmentExtraFeaturesSettings.java @@ -25,6 +25,7 @@ import androidx.preference.SwitchPreferenceCompat; import app.fedilab.android.R; import app.fedilab.android.activities.MainActivity; +import app.fedilab.android.mastodon.helper.Helper; public class FragmentExtraFeaturesSettings extends PreferenceFragmentCompat implements SharedPreferences.OnSharedPreferenceChangeListener { @@ -41,6 +42,18 @@ public class FragmentExtraFeaturesSettings extends PreferenceFragmentCompat impl addPreferencesFromResource(R.xml.pref_extra_features); PreferenceScreen preferenceScreen = getPreferenceScreen(); SharedPreferences sharedpreferences = PreferenceManager.getDefaultSharedPreferences(requireActivity()); + + //Theme for dialogs + ListPreference SET_POST_FORMAT = findPreference(getString(R.string.SET_POST_FORMAT)); + if (SET_POST_FORMAT != null) { + SET_POST_FORMAT.getContext().setTheme(Helper.dialogStyle()); + } + ListPreference SET_COMPOSE_LOCAL_ONLY = findPreference(getString(R.string.SET_DEFAULT_LOCALE_NEW)); + if (SET_COMPOSE_LOCAL_ONLY != null) { + SET_COMPOSE_LOCAL_ONLY.getContext().setTheme(Helper.dialogStyle()); + } + //--------- + SwitchPreferenceCompat SET_EXTAND_EXTRA_FEATURES = findPreference(getString(R.string.SET_EXTAND_EXTRA_FEATURES)); if (SET_EXTAND_EXTRA_FEATURES != null) { boolean checked = sharedpreferences.getBoolean(getString(R.string.SET_EXTAND_EXTRA_FEATURES) + MainActivity.currentUserID + MainActivity.currentInstance, false); @@ -69,13 +82,11 @@ public class FragmentExtraFeaturesSettings extends PreferenceFragmentCompat impl SET_DISPLAY_REACTIONS.setChecked(checked); } - ListPreference SET_POST_FORMAT = findPreference(getString(R.string.SET_POST_FORMAT)); if (SET_POST_FORMAT != null) { String format = sharedpreferences.getString(getString(R.string.SET_POST_FORMAT) + MainActivity.currentUserID + MainActivity.currentInstance, "text/plain"); SET_POST_FORMAT.setValue(format); } - ListPreference SET_COMPOSE_LOCAL_ONLY = findPreference(getString(R.string.SET_COMPOSE_LOCAL_ONLY)); if (SET_COMPOSE_LOCAL_ONLY != null) { int localOnly = sharedpreferences.getInt(getString(R.string.SET_COMPOSE_LOCAL_ONLY) + MainActivity.currentUserID + MainActivity.currentInstance, 0); SET_COMPOSE_LOCAL_ONLY.setValue(String.valueOf(localOnly)); diff --git a/app/src/main/java/app/fedilab/android/mastodon/ui/fragment/settings/FragmentHomeCacheSettings.java b/app/src/main/java/app/fedilab/android/mastodon/ui/fragment/settings/FragmentHomeCacheSettings.java index 8fe1f1dea..ed98dea41 100644 --- a/app/src/main/java/app/fedilab/android/mastodon/ui/fragment/settings/FragmentHomeCacheSettings.java +++ b/app/src/main/java/app/fedilab/android/mastodon/ui/fragment/settings/FragmentHomeCacheSettings.java @@ -63,13 +63,21 @@ public class FragmentHomeCacheSettings extends PreferenceFragmentCompat implemen return; } SharedPreferences sharedpreferences = PreferenceManager.getDefaultSharedPreferences(requireActivity()); + + //Theme for dialogs + ListPreference SET_FETCH_HOME_DELAY_VALUE = findPreference(getString(R.string.SET_FETCH_HOME_DELAY_VALUE)); + if (SET_FETCH_HOME_DELAY_VALUE != null) { + SET_FETCH_HOME_DELAY_VALUE.getContext().setTheme(Helper.dialogStyle()); + } + //--------- + + SwitchPreference SET_FETCH_HOME = findPreference(getString(R.string.SET_FETCH_HOME)); if (SET_FETCH_HOME != null) { boolean checked = sharedpreferences.getBoolean(getString(R.string.SET_FETCH_HOME) + MainActivity.currentUserID + MainActivity.currentInstance, false); SET_FETCH_HOME.setChecked(checked); } - ListPreference SET_FETCH_HOME_DELAY_VALUE = findPreference(getString(R.string.SET_FETCH_HOME_DELAY_VALUE)); if (SET_FETCH_HOME_DELAY_VALUE != null) { String timeRefresh = sharedpreferences.getString(getString(R.string.SET_FETCH_HOME_DELAY_VALUE) + MainActivity.currentUserID + MainActivity.currentInstance, "60"); SET_FETCH_HOME_DELAY_VALUE.setValue(timeRefresh); diff --git a/app/src/main/java/app/fedilab/android/mastodon/ui/fragment/settings/FragmentInterfaceSettings.java b/app/src/main/java/app/fedilab/android/mastodon/ui/fragment/settings/FragmentInterfaceSettings.java index c18a0c8f4..3019cccba 100644 --- a/app/src/main/java/app/fedilab/android/mastodon/ui/fragment/settings/FragmentInterfaceSettings.java +++ b/app/src/main/java/app/fedilab/android/mastodon/ui/fragment/settings/FragmentInterfaceSettings.java @@ -33,6 +33,7 @@ import app.fedilab.android.BuildConfig; import app.fedilab.android.R; import app.fedilab.android.activities.MainActivity; import app.fedilab.android.mastodon.helper.Helper; +import app.fedilab.android.mastodon.helper.ImageListPreference; import app.fedilab.android.mastodon.helper.LogoHelper; import es.dmoral.toasty.Toasty; @@ -54,6 +55,13 @@ public class FragmentInterfaceSettings extends PreferenceFragmentCompat implemen Toasty.error(requireActivity(), getString(R.string.toast_error), Toasty.LENGTH_SHORT).show(); return; } + + //Theme for dialogs + ImageListPreference SET_LOGO_LAUNCHER = findPreference(getString(R.string.SET_LOGO_LAUNCHER)); + if (SET_LOGO_LAUNCHER != null) { + SET_LOGO_LAUNCHER.getContext().setTheme(Helper.dialogStyle()); + } + //--------- SeekBarPreference SET_FONT_SCALE = findPreference(getString(R.string.SET_FONT_SCALE_INT)); if (SET_FONT_SCALE != null) { SET_FONT_SCALE.setMax(180); @@ -64,7 +72,6 @@ public class FragmentInterfaceSettings extends PreferenceFragmentCompat implemen SET_FONT_SCALE_ICON.setMax(180); SET_FONT_SCALE_ICON.setMin(80); } - ListPreference SET_LOGO_LAUNCHER = findPreference(getString(R.string.SET_LOGO_LAUNCHER)); if (SET_LOGO_LAUNCHER != null) { SET_LOGO_LAUNCHER.setIcon(LogoHelper.getDrawable(SET_LOGO_LAUNCHER.getValue())); } @@ -120,6 +127,9 @@ public class FragmentInterfaceSettings extends PreferenceFragmentCompat implemen editor.putString(getString(R.string.SET_LOGO_LAUNCHER), newLauncher); } } + if (key.compareToIgnoreCase(getString(R.string.SET_DISABLE_TOPBAR_SCROLLING)) == 0) { + recreate = true; + } editor.apply(); } } diff --git a/app/src/main/java/app/fedilab/android/mastodon/ui/fragment/settings/FragmentLanguageSettings.java b/app/src/main/java/app/fedilab/android/mastodon/ui/fragment/settings/FragmentLanguageSettings.java index 6ba2d9446..40f057356 100644 --- a/app/src/main/java/app/fedilab/android/mastodon/ui/fragment/settings/FragmentLanguageSettings.java +++ b/app/src/main/java/app/fedilab/android/mastodon/ui/fragment/settings/FragmentLanguageSettings.java @@ -18,6 +18,7 @@ import android.annotation.SuppressLint; import android.content.SharedPreferences; import android.os.Bundle; +import androidx.preference.ListPreference; import androidx.preference.Preference; import androidx.preference.PreferenceFragmentCompat; import androidx.preference.PreferenceManager; @@ -37,6 +38,14 @@ public class FragmentLanguageSettings extends PreferenceFragmentCompat implement private void createPref() { Preference SET_TRANSLATE_VALUES_RESET = findPreference(getString(R.string.SET_TRANSLATE_VALUES_RESET)); SharedPreferences sharedPreferences = PreferenceManager.getDefaultSharedPreferences(requireActivity()); + + //Theme for dialogs + ListPreference SET_DEFAULT_LOCALE_NEW = findPreference(getString(R.string.SET_DEFAULT_LOCALE_NEW)); + if (SET_DEFAULT_LOCALE_NEW != null) { + SET_DEFAULT_LOCALE_NEW.getContext().setTheme(Helper.dialogStyle()); + } + //--------- + if (SET_TRANSLATE_VALUES_RESET != null) { SET_TRANSLATE_VALUES_RESET.setOnPreferenceClickListener(preference -> { SharedPreferences.Editor editor = sharedPreferences.edit(); diff --git a/app/src/main/java/app/fedilab/android/mastodon/ui/fragment/settings/FragmentNotificationsSettings.java b/app/src/main/java/app/fedilab/android/mastodon/ui/fragment/settings/FragmentNotificationsSettings.java index a665adc93..7a834ccbd 100644 --- a/app/src/main/java/app/fedilab/android/mastodon/ui/fragment/settings/FragmentNotificationsSettings.java +++ b/app/src/main/java/app/fedilab/android/mastodon/ui/fragment/settings/FragmentNotificationsSettings.java @@ -40,6 +40,7 @@ import java.util.ArrayList; import java.util.List; import app.fedilab.android.R; +import app.fedilab.android.mastodon.helper.Helper; import app.fedilab.android.mastodon.helper.PushHelper; import app.fedilab.android.mastodon.helper.settings.TimePreference; import app.fedilab.android.mastodon.helper.settings.TimePreferenceDialogFragment; @@ -76,13 +77,37 @@ public class FragmentNotificationsSettings extends PreferenceFragmentCompat impl getPreferenceScreen().removeAll(); addPreferencesFromResource(R.xml.pref_notifications); PreferenceScreen preferenceScreen = getPreferenceScreen(); + + //Theme for dialogs + ListPreference SET_NOTIFICATION_TYPE = findPreference(getString(R.string.SET_NOTIFICATION_TYPE)); + if (SET_NOTIFICATION_TYPE != null) { + SET_NOTIFICATION_TYPE.getContext().setTheme(Helper.dialogStyle()); + } + ListPreference SET_NOTIFICATION_DELAY_VALUE = findPreference(getString(R.string.SET_NOTIFICATION_DELAY_VALUE)); + if (SET_NOTIFICATION_DELAY_VALUE != null) { + SET_NOTIFICATION_DELAY_VALUE.getContext().setTheme(Helper.dialogStyle()); + } + ListPreference SET_PUSH_DISTRIBUTOR = findPreference(getString(R.string.SET_PUSH_DISTRIBUTOR)); + if (SET_PUSH_DISTRIBUTOR != null) { + SET_PUSH_DISTRIBUTOR.getContext().setTheme(Helper.dialogStyle()); + } + ListPreference SET_LED_COLOUR_VAL_N = findPreference(getString(R.string.SET_LED_COLOUR_VAL_N)); + if (SET_LED_COLOUR_VAL_N != null) { + SET_LED_COLOUR_VAL_N.getContext().setTheme(Helper.dialogStyle()); + } + ListPreference SET_NOTIFICATION_ACTION = findPreference(getString(R.string.SET_NOTIFICATION_ACTION)); + if (SET_NOTIFICATION_ACTION != null) { + SET_NOTIFICATION_ACTION.getContext().setTheme(Helper.dialogStyle()); + } + //--------- + + if (preferenceScreen == null) { Toasty.error(requireActivity(), getString(R.string.toast_error), Toasty.LENGTH_SHORT).show(); return; } - ListPreference SET_NOTIFICATION_TYPE = findPreference(getString(R.string.SET_NOTIFICATION_TYPE)); String[] notificationValues = getResources().getStringArray(R.array.SET_NOTIFICATION_TYPE_VALUE); if (SET_NOTIFICATION_TYPE != null && SET_NOTIFICATION_TYPE.getValue().equals(notificationValues[2])) { PreferenceCategory notification_sounds = findPreference("notification_sounds"); @@ -97,26 +122,21 @@ public class FragmentNotificationsSettings extends PreferenceFragmentCompat impl if (notification_time_slot != null) { preferenceScreen.removePreference(notification_time_slot); } - ListPreference SET_NOTIFICATION_DELAY_VALUE = findPreference("SET_NOTIFICATION_DELAY_VALUE"); if (SET_NOTIFICATION_DELAY_VALUE != null) { preferenceScreen.removePreferenceRecursively("SET_NOTIFICATION_DELAY_VALUE"); } - ListPreference SET_PUSH_DISTRIBUTOR = findPreference("SET_PUSH_DISTRIBUTOR"); if (SET_PUSH_DISTRIBUTOR != null) { preferenceScreen.removePreferenceRecursively("SET_PUSH_DISTRIBUTOR"); } return; } else if (SET_NOTIFICATION_TYPE != null && SET_NOTIFICATION_TYPE.getValue().equals(notificationValues[1])) { - ListPreference SET_PUSH_DISTRIBUTOR = findPreference("SET_PUSH_DISTRIBUTOR"); if (SET_PUSH_DISTRIBUTOR != null) { preferenceScreen.removePreferenceRecursively("SET_PUSH_DISTRIBUTOR"); } } else { - ListPreference SET_NOTIFICATION_DELAY_VALUE = findPreference("SET_NOTIFICATION_DELAY_VALUE"); if (SET_NOTIFICATION_DELAY_VALUE != null) { preferenceScreen.removePreferenceRecursively("SET_NOTIFICATION_DELAY_VALUE"); } - ListPreference SET_PUSH_DISTRIBUTOR = findPreference(getString(R.string.SET_PUSH_DISTRIBUTOR)); if (SET_PUSH_DISTRIBUTOR != null) { List<String> distributors = UnifiedPush.getDistributors(requireActivity(), new ArrayList<>()); SET_PUSH_DISTRIBUTOR.setValue(UnifiedPush.getDistributor(requireActivity())); diff --git a/app/src/main/java/app/fedilab/android/mastodon/ui/fragment/settings/FragmentThemingSettings.java b/app/src/main/java/app/fedilab/android/mastodon/ui/fragment/settings/FragmentThemingSettings.java index f9e77b55b..e6e42cbb9 100644 --- a/app/src/main/java/app/fedilab/android/mastodon/ui/fragment/settings/FragmentThemingSettings.java +++ b/app/src/main/java/app/fedilab/android/mastodon/ui/fragment/settings/FragmentThemingSettings.java @@ -114,6 +114,22 @@ public class FragmentThemingSettings extends PreferenceFragmentCompat implements Toasty.error(requireActivity(), getString(R.string.toast_error), Toasty.LENGTH_SHORT).show(); } SharedPreferences sharedpreferences = PreferenceManager.getDefaultSharedPreferences(requireActivity()); + + //Theme for dialogs + ListPreference SET_THEME_BASE = findPreference(getString(R.string.SET_THEME_BASE)); + if (SET_THEME_BASE != null) { + SET_THEME_BASE.getContext().setTheme(Helper.dialogStyle()); + } + ListPreference SET_THEME_DEFAULT_LIGHT = findPreference(getString(R.string.SET_THEME_DEFAULT_LIGHT)); + if (SET_THEME_DEFAULT_LIGHT != null) { + SET_THEME_DEFAULT_LIGHT.getContext().setTheme(Helper.dialogStyle()); + } + ListPreference SET_THEME_DEFAULT_DARK = findPreference(getString(R.string.SET_THEME_DEFAULT_DARK)); + if (SET_THEME_DEFAULT_DARK != null) { + SET_THEME_DEFAULT_DARK.getContext().setTheme(Helper.dialogStyle()); + } + //--------- + SwitchPreferenceCompat SET_DYNAMIC_COLOR = findPreference(getString(R.string.SET_DYNAMICCOLOR)); SwitchPreferenceCompat SET_CUSTOM_ACCENT = findPreference(getString(R.string.SET_CUSTOM_ACCENT)); ColorPreferenceCompat SET_CUSTOM_ACCENT_DARK_VALUE = findPreference(getString(R.string.SET_CUSTOM_ACCENT_DARK_VALUE)); diff --git a/app/src/main/java/app/fedilab/android/mastodon/ui/fragment/settings/FragmentTimelinesSettings.java b/app/src/main/java/app/fedilab/android/mastodon/ui/fragment/settings/FragmentTimelinesSettings.java index 779460496..0383e1f85 100644 --- a/app/src/main/java/app/fedilab/android/mastodon/ui/fragment/settings/FragmentTimelinesSettings.java +++ b/app/src/main/java/app/fedilab/android/mastodon/ui/fragment/settings/FragmentTimelinesSettings.java @@ -31,6 +31,7 @@ import app.fedilab.android.mastodon.helper.Helper; public class FragmentTimelinesSettings extends PreferenceFragmentCompat implements SharedPreferences.OnSharedPreferenceChangeListener { boolean recreate; + @Override public void onCreatePreferences(Bundle savedInstanceState, String rootKey) { addPreferencesFromResource(R.xml.pref_timelines); @@ -47,7 +48,18 @@ public class FragmentTimelinesSettings extends PreferenceFragmentCompat implemen ListPreference SET_TRANSLATOR = findPreference(getString(R.string.SET_TRANSLATOR)); ListPreference SET_TRANSLATOR_VERSION = findPreference(getString(R.string.SET_TRANSLATOR_VERSION)); - + //Theme for dialogs + if (SET_TRANSLATOR_VERSION != null) { + SET_TRANSLATOR_VERSION.getContext().setTheme(Helper.dialogStyle()); + } + if (SET_TRANSLATOR != null) { + SET_TRANSLATOR.getContext().setTheme(Helper.dialogStyle()); + } + ListPreference SET_LOAD_MEDIA_TYPE = findPreference(getString(R.string.SET_LOAD_MEDIA_TYPE)); + if (SET_LOAD_MEDIA_TYPE != null) { + SET_LOAD_MEDIA_TYPE.getContext().setTheme(Helper.dialogStyle()); + } + //--------- EditTextPreference SET_TRANSLATOR_API_KEY = findPreference(getString(R.string.SET_TRANSLATOR_API_KEY)); EditTextPreference SET_TRANSLATOR_DOMAIN = findPreference(getString(R.string.SET_TRANSLATOR_DOMAIN)); if (SET_TRANSLATOR != null && !SET_TRANSLATOR.getValue().equals("DEEPL")) { diff --git a/app/src/main/java/app/fedilab/android/mastodon/ui/fragment/timeline/FragmentMastodonAccount.java b/app/src/main/java/app/fedilab/android/mastodon/ui/fragment/timeline/FragmentMastodonAccount.java index 4e26ec8ea..f55c74922 100644 --- a/app/src/main/java/app/fedilab/android/mastodon/ui/fragment/timeline/FragmentMastodonAccount.java +++ b/app/src/main/java/app/fedilab/android/mastodon/ui/fragment/timeline/FragmentMastodonAccount.java @@ -15,6 +15,7 @@ package app.fedilab.android.mastodon.ui.fragment.timeline; * see <http://www.gnu.org/licenses>. */ +import static app.fedilab.android.BaseMainActivity.currentAccount; import static app.fedilab.android.BaseMainActivity.currentInstance; import static app.fedilab.android.BaseMainActivity.currentToken; import static app.fedilab.android.mastodon.helper.MastodonHelper.ACCOUNTS_PER_CALL; @@ -38,14 +39,15 @@ import java.util.List; import app.fedilab.android.BaseMainActivity; import app.fedilab.android.R; -import app.fedilab.android.activities.MainActivity; import app.fedilab.android.databinding.FragmentPaginationBinding; import app.fedilab.android.mastodon.activities.SearchResultTabActivity; import app.fedilab.android.mastodon.client.entities.api.Account; import app.fedilab.android.mastodon.client.entities.api.Accounts; import app.fedilab.android.mastodon.client.entities.api.Pagination; import app.fedilab.android.mastodon.client.entities.api.RelationShip; +import app.fedilab.android.mastodon.client.entities.app.CachedBundle; import app.fedilab.android.mastodon.client.entities.app.Timeline; +import app.fedilab.android.mastodon.exception.DBException; import app.fedilab.android.mastodon.helper.Helper; import app.fedilab.android.mastodon.helper.MastodonHelper; import app.fedilab.android.mastodon.ui.drawer.AccountAdapter; @@ -77,19 +79,49 @@ public class FragmentMastodonAccount extends Fragment { public View onCreateView(@NonNull LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { - if (getArguments() != null) { - search = getArguments().getString(Helper.ARG_SEARCH_KEYWORD, null); - accountTimeline = (Account) getArguments().getSerializable(Helper.ARG_ACCOUNT); - followType = (FedilabProfileTLPageAdapter.follow_type) getArguments().getSerializable(Helper.ARG_FOLLOW_TYPE); - viewModelKey = getArguments().getString(Helper.ARG_VIEW_MODEL_KEY, ""); - timelineType = (Timeline.TimeLineEnum) getArguments().get(Helper.ARG_TIMELINE_TYPE); - order = getArguments().getString(Helper.ARG_DIRECTORY_ORDER, "active"); - local = getArguments().getBoolean(Helper.ARG_DIRECTORY_LOCAL, false); - checkRemotely = getArguments().getBoolean(Helper.ARG_CHECK_REMOTELY, false); - } + instance = currentInstance; token = currentToken; + flagLoading = false; + binding = FragmentPaginationBinding.inflate(inflater, container, false); + SharedPreferences sharedpreferences = PreferenceManager.getDefaultSharedPreferences(requireActivity()); + boolean displayScrollBar = sharedpreferences.getBoolean(getString(R.string.SET_TIMELINE_SCROLLBAR), false); + binding.recyclerView.setVerticalScrollBarEnabled(displayScrollBar); + if (getArguments() != null) { + long bundleId = getArguments().getLong(Helper.ARG_INTENT_ID, -1); + if (bundleId != -1) { + new CachedBundle(requireActivity()).getBundle(bundleId, currentAccount, this::initializeAfterBundle); + } else { + if (getArguments().containsKey(Helper.ARG_CACHED_ACCOUNT_ID)) { + try { + accountTimeline = new CachedBundle(requireActivity()).getCachedAccount(currentAccount, getArguments().getString(Helper.ARG_CACHED_ACCOUNT_ID)); + } catch (DBException e) { + e.printStackTrace(); + } + } + initializeAfterBundle(getArguments()); + } + } else { + initializeAfterBundle(null); + } + + return binding.getRoot(); + } + + private void initializeAfterBundle(Bundle bundle) { + if (bundle != null) { + search = bundle.getString(Helper.ARG_SEARCH_KEYWORD, null); + if (bundle.containsKey(Helper.ARG_ACCOUNT)) { + accountTimeline = (Account) bundle.getSerializable(Helper.ARG_ACCOUNT); + } + followType = (FedilabProfileTLPageAdapter.follow_type) bundle.getSerializable(Helper.ARG_FOLLOW_TYPE); + viewModelKey = bundle.getString(Helper.ARG_VIEW_MODEL_KEY, ""); + timelineType = (Timeline.TimeLineEnum) bundle.get(Helper.ARG_TIMELINE_TYPE); + order = bundle.getString(Helper.ARG_DIRECTORY_ORDER, "active"); + local = bundle.getBoolean(Helper.ARG_DIRECTORY_LOCAL, false); + checkRemotely = bundle.getBoolean(Helper.ARG_CHECK_REMOTELY, false); + } if (checkRemotely) { String[] acctArray = accountTimeline.acct.split("@"); if (acctArray.length > 1) { @@ -102,20 +134,6 @@ public class FragmentMastodonAccount extends Fragment { token = currentToken; } } - - flagLoading = false; - binding = FragmentPaginationBinding.inflate(inflater, container, false); - SharedPreferences sharedpreferences = PreferenceManager.getDefaultSharedPreferences(requireActivity()); - boolean displayScrollBar = sharedpreferences.getBoolean(getString(R.string.SET_TIMELINE_SCROLLBAR), false); - binding.recyclerView.setVerticalScrollBarEnabled(displayScrollBar); - return binding.getRoot(); - } - - @Override - public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) { - super.onViewCreated(view, savedInstanceState); - binding.loader.setVisibility(View.VISIBLE); - binding.recyclerView.setVisibility(View.GONE); accountsVM = new ViewModelProvider(FragmentMastodonAccount.this).get(viewModelKey, AccountsVM.class); max_id = null; offset = 0; @@ -126,6 +144,14 @@ public class FragmentMastodonAccount extends Fragment { router(true); } + @Override + public void onViewCreated(@NonNull View view, @Nullable Bundle s |