From c67feaac9a981f064ca4bbd18c8939049894178c Mon Sep 17 00:00:00 2001 From: LucasGGamerM Date: Wed, 23 Aug 2023 14:30:09 -0300 Subject: [PATCH] refactor: removing legacy settings fragments --- .../fragments/settings/AboutFragment.java | 137 --- .../fragments/settings/AccountFragment.java | 181 ---- .../settings/AppearanceFragment.java | 98 -- .../fragments/settings/BehaviourFragment.java | 199 ---- .../settings/NotificationsFragment.java | 47 - .../settings/SettingsBaseFragment.java | 981 ------------------ .../fragments/settings/TimeLineFragment.java | 125 --- 7 files changed, 1768 deletions(-) delete mode 100644 mastodon/src/main/java/org/joinmastodon/android/fragments/settings/AboutFragment.java delete mode 100644 mastodon/src/main/java/org/joinmastodon/android/fragments/settings/AccountFragment.java delete mode 100644 mastodon/src/main/java/org/joinmastodon/android/fragments/settings/AppearanceFragment.java delete mode 100644 mastodon/src/main/java/org/joinmastodon/android/fragments/settings/BehaviourFragment.java delete mode 100644 mastodon/src/main/java/org/joinmastodon/android/fragments/settings/NotificationsFragment.java delete mode 100644 mastodon/src/main/java/org/joinmastodon/android/fragments/settings/SettingsBaseFragment.java delete mode 100644 mastodon/src/main/java/org/joinmastodon/android/fragments/settings/TimeLineFragment.java diff --git a/mastodon/src/main/java/org/joinmastodon/android/fragments/settings/AboutFragment.java b/mastodon/src/main/java/org/joinmastodon/android/fragments/settings/AboutFragment.java deleted file mode 100644 index 54d9a2793..000000000 --- a/mastodon/src/main/java/org/joinmastodon/android/fragments/settings/AboutFragment.java +++ /dev/null @@ -1,137 +0,0 @@ -package org.joinmastodon.android.fragments.settings; - -import android.app.Activity; -import android.content.Intent; -import android.net.Uri; -import android.os.Bundle; -import android.provider.Settings; -import android.text.TextUtils; -import android.util.LruCache; -import android.view.View; -import android.widget.Toast; - -import com.squareup.otto.Subscribe; - -import org.joinmastodon.android.BuildConfig; -import org.joinmastodon.android.E; -import org.joinmastodon.android.GlobalUserPreferences; -import org.joinmastodon.android.MainActivity; -import org.joinmastodon.android.R; -import org.joinmastodon.android.api.MastodonAPIController; -import org.joinmastodon.android.api.requests.oauth.RevokeOauthToken; -import org.joinmastodon.android.api.session.AccountActivationInfo; -import org.joinmastodon.android.api.session.AccountSession; -import org.joinmastodon.android.api.session.AccountSessionManager; -import org.joinmastodon.android.events.SelfUpdateStateChangedEvent; -import org.joinmastodon.android.fragments.onboarding.AccountActivationFragment; -import org.joinmastodon.android.fragments.onboarding.InstanceRulesFragment; -import org.joinmastodon.android.ui.M3AlertDialogBuilder; -import org.joinmastodon.android.ui.utils.UiUtils; -import org.joinmastodon.android.updater.GithubSelfUpdater; -import org.parceler.Parcels; - -import java.util.ArrayList; - -import me.grishka.appkit.Nav; -import me.grishka.appkit.api.Callback; -import me.grishka.appkit.api.ErrorResponse; -import me.grishka.appkit.imageloader.ImageCache; - -public class AboutFragment extends SettingsBaseFragment{ - - private TextItem clearImageCacheItem; - private ImageCache imageCache; - - private TextItem checkForUpdateItem; - - @Override - public void addItems(ArrayList items) { - - imageCache = ImageCache.getInstance(getActivity()); - - items.add(new TextItem(R.string.mo_settings_contribute, ()->UiUtils.launchWebBrowser(getActivity(), "https://github.com/LucasGGamerM/moshidon"), R.drawable.ic_fluent_open_24_regular)); - items.add(new TextItem(R.string.sk_settings_donate, ()->UiUtils.launchWebBrowser(getActivity(), "https://github.com/sponsors/LucasGGamerM"), R.drawable.ic_fluent_heart_24_regular)); - - if (GithubSelfUpdater.needSelfUpdating()) { - checkForUpdateItem = new TextItem(R.string.sk_check_for_update, GithubSelfUpdater.getInstance()::checkForUpdates); - items.add(checkForUpdateItem); - items.add(new SwitchItem(R.string.sk_updater_enable_pre_releases, 0, GlobalUserPreferences.enablePreReleases, i->{ - GlobalUserPreferences.enablePreReleases=i.checked; - GlobalUserPreferences.save(); - })); - } - - LruCache cache = imageCache == null ? null : imageCache.getLruCache(); - clearImageCacheItem = new TextItem(R.string.settings_clear_cache, UiUtils.formatFileSize(getContext(), cache != null ? cache.size() : 0, true), this::clearImageCache, 0); - items.add(clearImageCacheItem); - items.add(new TextItem(R.string.sk_clear_recent_languages, ()->UiUtils.showConfirmationAlert(getActivity(), R.string.sk_clear_recent_languages, R.string.sk_confirm_clear_recent_languages, R.string.clear, ()->{ - GlobalUserPreferences.recentLanguages.remove(accountID); - GlobalUserPreferences.save(); - }))); - - items.add(new TextItem(R.string.mo_clear_recent_emoji, ()-> { - GlobalUserPreferences.recentEmojis.clear(); - GlobalUserPreferences.save(); - })); - - if(BuildConfig.DEBUG){ - items.add(new RedHeaderItem("Debug options")); - - items.add(new TextItem("Test E-Mail confirmation flow", ()->{ - AccountSession sess=AccountSessionManager.getInstance().getAccount(accountID); - sess.activated=false; - sess.activationInfo=new AccountActivationInfo("test@email", System.currentTimeMillis()); - Bundle args=new Bundle(); - args.putString("account", accountID); - args.putBoolean("debug", true); - Nav.goClearingStack(getActivity(), AccountActivationFragment.class, args); - })); - - items.add(new TextItem("Copy preferences", ()->{ - StringBuilder prefBuilder = new StringBuilder(); - GlobalUserPreferences.load(); - GlobalUserPreferences.getPrefs().getAll().forEach((key, value) -> prefBuilder.append(key).append(": ").append(value).append('\n')); - UiUtils.copyText(view, prefBuilder.toString()); - })); - - items.add(new TextItem("Reset preferences", ()->{ - GlobalUserPreferences.load(); - GlobalUserPreferences.getPrefs().edit().clear().commit(); - UiUtils.restartApp(); - }, R.drawable.ic_fluent_warning_24_regular)); - - items.add(new TextItem("Open App Info", () -> - getContext().startActivity(new Intent(Settings.ACTION_APPLICATION_DETAILS_SETTINGS) - .setData(Uri.fromParts("package", getContext().getPackageName(), null))), - R.drawable.ic_fluent_open_24_regular - ) - ); - - items.add(new TextItem("Open developer settings", - ()-> getContext().startActivity(new Intent(Settings.ACTION_APPLICATION_DEVELOPMENT_SETTINGS)), - R.drawable.ic_fluent_open_24_regular) - ); - } - - String version = getContext().getString(R.string.mo_settings_app_version, BuildConfig.VERSION_NAME, BuildConfig.VERSION_CODE); - items.add(new FooterItem(version, () -> UiUtils.copyText(view, version))); - } - - @Subscribe - public void onSelfUpdateStateChanged(SelfUpdateStateChangedEvent ev){ - checkForUpdateItem.loading = ev.state == GithubSelfUpdater.UpdateState.CHECKING; - if (list.findViewHolderForAdapterPosition(items.indexOf(checkForUpdateItem)) instanceof TextViewHolder tvh) tvh.rebind(); - } - - private void clearImageCache(){ - MastodonAPIController.runInBackground(()->{ - Activity activity=getActivity(); - imageCache.clear(); - Toast.makeText(activity, R.string.media_cache_cleared, Toast.LENGTH_SHORT).show(); - }); - if (list.findViewHolderForAdapterPosition(items.indexOf(clearImageCacheItem)) instanceof TextViewHolder tvh) { - clearImageCacheItem.secondaryText = UiUtils.formatFileSize(getContext(), 0, true); - tvh.rebind(); - } - } -} diff --git a/mastodon/src/main/java/org/joinmastodon/android/fragments/settings/AccountFragment.java b/mastodon/src/main/java/org/joinmastodon/android/fragments/settings/AccountFragment.java deleted file mode 100644 index 98fe71255..000000000 --- a/mastodon/src/main/java/org/joinmastodon/android/fragments/settings/AccountFragment.java +++ /dev/null @@ -1,181 +0,0 @@ -package org.joinmastodon.android.fragments.settings; - -import android.content.Intent; -import android.os.Bundle; -import android.text.TextUtils; -import android.view.Gravity; -import android.view.Menu; -import android.view.MenuItem; -import android.widget.Button; -import android.widget.PopupMenu; - -import androidx.annotation.Nullable; -import androidx.annotation.StringRes; - -import org.joinmastodon.android.GlobalUserPreferences; -import org.joinmastodon.android.MainActivity; -import org.joinmastodon.android.R; -import org.joinmastodon.android.api.requests.oauth.RevokeOauthToken; -import org.joinmastodon.android.api.session.AccountSession; -import org.joinmastodon.android.api.session.AccountSessionManager; -import org.joinmastodon.android.fragments.onboarding.InstanceRulesFragment; -import org.joinmastodon.android.model.ContentType; -import org.joinmastodon.android.ui.M3AlertDialogBuilder; -import org.joinmastodon.android.ui.utils.UiUtils; -import org.parceler.Parcels; - -import java.util.ArrayList; - -import me.grishka.appkit.Nav; -import me.grishka.appkit.api.Callback; -import me.grishka.appkit.api.ErrorResponse; - -public class AccountFragment extends SettingsBaseFragment{ - - - private SwitchItem glitchModeItem; - private ButtonItem defaultContentTypeButtonItem; - private Menu contentTypeMenu; - @Override - public void addItems(ArrayList items) { - items.add(new HeaderItem(R.string.settings_account)); - items.add(new TextItem(R.string.sk_settings_profile, ()-> UiUtils.launchWebBrowser(getActivity(), "https://"+session.domain+"/settings/profile"), R.drawable.ic_fluent_open_24_regular)); - items.add(new TextItem(R.string.sk_settings_posting, ()->UiUtils.launchWebBrowser(getActivity(), "https://"+session.domain+"/settings/preferences/other"), R.drawable.ic_fluent_open_24_regular)); - items.add(new TextItem(R.string.sk_settings_filters, ()->UiUtils.launchWebBrowser(getActivity(), "https://"+session.domain+"/filters"), R.drawable.ic_fluent_open_24_regular)); - items.add(new TextItem(R.string.sk_settings_auth, ()->UiUtils.launchWebBrowser(getActivity(), "https://"+session.domain+"/auth/edit"), R.drawable.ic_fluent_open_24_regular)); - - items.add(new HeaderItem(getInstanceName())); - items.add(new TextItem(R.string.sk_settings_rules, ()->{ - Bundle args=new Bundle(); - args.putParcelable("instance", Parcels.wrap(getInstance())); - Nav.go(getActivity(), InstanceRulesFragment.class, args); - }, R.drawable.ic_fluent_task_list_ltr_24_regular)); - items.add(new TextItem(R.string.sk_settings_about_instance , ()->UiUtils.launchWebBrowser(getActivity(), "https://"+session.domain+"/about"), R.drawable.ic_fluent_info_24_regular)); - items.add(new TextItem(R.string.settings_tos, ()->UiUtils.launchWebBrowser(getActivity(), "https://"+session.domain+"/terms"), R.drawable.ic_fluent_open_24_regular)); - items.add(new TextItem(R.string.settings_privacy_policy, ()->UiUtils.launchWebBrowser(getActivity(), "https://"+session.domain+"/terms"), R.drawable.ic_fluent_open_24_regular)); - items.add(new TextItem(R.string.log_out, this::confirmLogOut, R.drawable.ic_fluent_sign_out_24_regular)); - if (!TextUtils.isEmpty(getInstance().version)) items.add(new SmallTextItem(getString(R.string.sk_settings_server_version, getInstance().version))); - - items.add(new HeaderItem(R.string.sk_instance_features)); - items.add(new SwitchItem(R.string.sk_settings_content_types, R.string.sk_settings_content_types_explanation, 0, GlobalUserPreferences.accountsWithContentTypesEnabled.contains(accountID), (i)->{ - if (i.checked) { - GlobalUserPreferences.accountsWithContentTypesEnabled.add(accountID); - if (GlobalUserPreferences.accountsDefaultContentTypes.get(accountID) == null) { - GlobalUserPreferences.accountsDefaultContentTypes.put(accountID, ContentType.PLAIN); - } - } else { - GlobalUserPreferences.accountsWithContentTypesEnabled.remove(accountID); - GlobalUserPreferences.accountsDefaultContentTypes.remove(accountID); - } - if (list.findViewHolderForAdapterPosition(items.indexOf(defaultContentTypeButtonItem)) - instanceof ButtonViewHolder bvh) bvh.rebind(); - GlobalUserPreferences.save(); - })); - items.add(defaultContentTypeButtonItem = new ButtonItem(R.string.sk_settings_default_content_type, R.string.sk_settings_default_content_type_explanation, 0, b->{ - PopupMenu popupMenu=new PopupMenu(getActivity(), b, Gravity.CENTER_HORIZONTAL); - popupMenu.inflate(R.menu.compose_content_type); - popupMenu.setOnMenuItemClickListener(item -> this.onContentTypeChanged(item, b)); - b.setOnTouchListener(popupMenu.getDragToOpenListener()); - b.setOnClickListener(v->popupMenu.show()); - ContentType contentType = GlobalUserPreferences.accountsDefaultContentTypes.get(accountID); - b.setText(getContentTypeString(contentType)); - contentTypeMenu = popupMenu.getMenu(); - contentTypeMenu.findItem(ContentType.getContentTypeRes(contentType)).setChecked(true); - ContentType.adaptMenuToInstance(contentTypeMenu, getInstance()); - contentTypeMenu.findItem(R.id.content_type_null).setVisible( - !GlobalUserPreferences.accountsWithContentTypesEnabled.contains(accountID)); - })); - items.add(new SwitchItem(R.string.sk_settings_support_local_only, R.string.sk_settings_local_only_explanation, 0, GlobalUserPreferences.accountsWithLocalOnlySupport.contains(accountID), i->{ - glitchModeItem.enabled = i.checked; - if (i.checked) { - GlobalUserPreferences.accountsWithLocalOnlySupport.add(accountID); - if (getInstance().pleroma == null) GlobalUserPreferences.accountsInGlitchMode.add(accountID); - } else { - GlobalUserPreferences.accountsWithLocalOnlySupport.remove(accountID); - GlobalUserPreferences.accountsInGlitchMode.remove(accountID); - } - glitchModeItem.checked = GlobalUserPreferences.accountsInGlitchMode.contains(accountID); - if (list.findViewHolderForAdapterPosition(items.indexOf(glitchModeItem)) instanceof SwitchViewHolder svh) svh.rebind(); - GlobalUserPreferences.save(); - })); - items.add(glitchModeItem = new SwitchItem(R.string.sk_settings_glitch_instance, R.string.sk_settings_glitch_mode_explanation, 0, GlobalUserPreferences.accountsInGlitchMode.contains(accountID), i->{ - if (i.checked) { - GlobalUserPreferences.accountsInGlitchMode.add(accountID); - } else { - GlobalUserPreferences.accountsInGlitchMode.remove(accountID); - } - GlobalUserPreferences.save(); - })); - glitchModeItem.enabled = GlobalUserPreferences.accountsWithLocalOnlySupport.contains(accountID); - - - boolean translationAvailable = getInstance().v2 != null && getInstance().v2.configuration.translation != null && getInstance().v2.configuration.translation.enabled; - items.add(new SmallTextItem(getString(translationAvailable ? - R.string.sk_settings_translation_availability_note_available : - R.string.sk_settings_translation_availability_note_unavailable, getInstance().title))); - - } - - private void confirmLogOut(){ - new M3AlertDialogBuilder(getActivity()) - .setTitle(R.string.log_out) - .setMessage(R.string.confirm_log_out) - .setPositiveButton(R.string.log_out, (dialog, which) -> logOut()) - .setNegativeButton(R.string.cancel, null) - .show(); - } - - private void logOut(){ - AccountSession session= AccountSessionManager.getInstance().getAccount(accountID); - new RevokeOauthToken(session.app.clientId, session.app.clientSecret, session.token.accessToken) - .setCallback(new Callback<>(){ - @Override - public void onSuccess(Object result){ - onLoggedOut(); - } - - @Override - public void onError(ErrorResponse error){ - onLoggedOut(); - } - }) - .wrapProgress(getActivity(), R.string.loading, false) - .exec(accountID); - } - - private void onLoggedOut(){ - if (getActivity() == null) return; - AccountSessionManager.getInstance().removeAccount(accountID); - getActivity().finish(); - Intent intent=new Intent(getActivity(), MainActivity.class); - startActivity(intent); - } - - private @StringRes int getContentTypeString(@Nullable ContentType contentType) { - if (contentType == null) return R.string.sk_content_type_unspecified; - return switch (contentType) { - case PLAIN -> R.string.sk_content_type_plain; - case HTML -> R.string.sk_content_type_html; - case MARKDOWN -> R.string.sk_content_type_markdown; - case BBCODE -> R.string.sk_content_type_bbcode; - case MISSKEY_MARKDOWN -> R.string.sk_content_type_mfm; - }; - } - - private boolean onContentTypeChanged(MenuItem item, Button btn){ - int id = item.getItemId(); - ContentType contentType = switch (id) { - case R.id.content_type_plain -> ContentType.PLAIN; - case R.id.content_type_html -> ContentType.HTML; - case R.id.content_type_markdown -> ContentType.MARKDOWN; - case R.id.content_type_bbcode -> ContentType.BBCODE; - case R.id.content_type_misskey_markdown -> ContentType.MISSKEY_MARKDOWN; - default -> null; - }; - GlobalUserPreferences.accountsDefaultContentTypes.put(accountID, contentType); - GlobalUserPreferences.save(); - btn.setText(getContentTypeString(contentType)); - item.setChecked(true); - return true; - } -} diff --git a/mastodon/src/main/java/org/joinmastodon/android/fragments/settings/AppearanceFragment.java b/mastodon/src/main/java/org/joinmastodon/android/fragments/settings/AppearanceFragment.java deleted file mode 100644 index 891af1a9b..000000000 --- a/mastodon/src/main/java/org/joinmastodon/android/fragments/settings/AppearanceFragment.java +++ /dev/null @@ -1,98 +0,0 @@ -package org.joinmastodon.android.fragments.settings; - -import android.os.Build; -import android.view.Gravity; -import android.view.Menu; -import android.view.MenuItem; -import android.widget.PopupMenu; - -import androidx.annotation.Nullable; - -import org.joinmastodon.android.GlobalUserPreferences; -import org.joinmastodon.android.R; -import org.joinmastodon.android.model.ContentType; - -import java.util.ArrayList; - -public class AppearanceFragment extends SettingsBaseFragment { - - @Override - public void addItems(ArrayList items) { - themeItem = new ThemeItem(); - items.add(themeItem); - items.add(new ButtonItem(R.string.sk_settings_color_palette, R.drawable.ic_fluent_color_24_regular, b -> { - PopupMenu popupMenu = new PopupMenu(getActivity(), b, Gravity.CENTER_HORIZONTAL); - popupMenu.inflate(R.menu.color_palettes); - popupMenu.getMenu().findItem(R.id.m3_color).setVisible(Build.VERSION.SDK_INT >= Build.VERSION_CODES.S); - popupMenu.setOnMenuItemClickListener(this::onColorPreferenceClick); - - Menu colorTheme = popupMenu.getMenu(); - colorTheme.findItem(getColorThemeRes(GlobalUserPreferences.color)).setChecked(true); - - b.setOnTouchListener(popupMenu.getDragToOpenListener()); - b.setOnClickListener(v -> popupMenu.show()); - b.setText(switch (GlobalUserPreferences.color) { - case MATERIAL3 -> R.string.sk_color_palette_material3; - case PINK -> R.string.sk_color_palette_pink; - case PURPLE -> R.string.sk_color_palette_purple; - case GREEN -> R.string.sk_color_palette_green; - case BLUE -> R.string.sk_color_palette_blue; - case BROWN -> R.string.sk_color_palette_brown; - case RED -> R.string.sk_color_palette_red; - case YELLOW -> R.string.sk_color_palette_yellow; - case NORD -> R.string.mo_color_palette_nord; - case WHITE -> R.string.mo_color_palette_black_and_white; - }); - })); - items.add(new SwitchItem(R.string.theme_true_black, R.string.mo_setting_true_black_summary, R.drawable.ic_fluent_dark_theme_24_regular, GlobalUserPreferences.trueBlackTheme, this::onTrueBlackThemeChanged)); - items.add(new SwitchItem(R.string.sk_disable_marquee, R.drawable.ic_fluent_text_more_24_regular, GlobalUserPreferences.disableMarquee, i -> { - GlobalUserPreferences.disableMarquee = i.checked; - GlobalUserPreferences.save(); - needAppRestart = true; - })); - items.add(new SwitchItem(R.string.sk_settings_reduce_motion, R.string.mo_setting_reduced_motion_summary, R.drawable.ic_fluent_star_emphasis_24_regular, GlobalUserPreferences.reduceMotion, i -> { - GlobalUserPreferences.reduceMotion = i.checked; - GlobalUserPreferences.save(); - needAppRestart = true; - })); - } - - public static int getColorThemeRes(@Nullable GlobalUserPreferences.ColorPreference colorPreference) { - return colorPreference == null ? R.id.content_type_null : switch(colorPreference) { - case MATERIAL3 -> R.id.m3_color; - case PINK -> R.id.pink_color; - case PURPLE -> R.id.purple_color; - case GREEN -> R.id.green_color; - case BLUE -> R.id.blue_color; - case BROWN -> R.id.brown_color; - case RED -> R.id.red_color; - case YELLOW -> R.id.yellow_color; - case NORD -> R.id.nord_color; - case WHITE -> R.id.black_and_white_color; - }; - } - - private boolean onColorPreferenceClick(MenuItem item) { - GlobalUserPreferences.ColorPreference pref = null; - int id = item.getItemId(); - - if (id == R.id.m3_color) pref = GlobalUserPreferences.ColorPreference.MATERIAL3; - else if (id == R.id.pink_color) pref = GlobalUserPreferences.ColorPreference.PINK; - else if (id == R.id.purple_color) pref = GlobalUserPreferences.ColorPreference.PURPLE; - else if (id == R.id.green_color) pref = GlobalUserPreferences.ColorPreference.GREEN; - else if (id == R.id.blue_color) pref = GlobalUserPreferences.ColorPreference.BLUE; - else if (id == R.id.brown_color) pref = GlobalUserPreferences.ColorPreference.BROWN; - else if (id == R.id.red_color) pref = GlobalUserPreferences.ColorPreference.RED; - else if (id == R.id.yellow_color) pref = GlobalUserPreferences.ColorPreference.YELLOW; - else if (id == R.id.nord_color) pref = GlobalUserPreferences.ColorPreference.NORD; - else if (id == R.id.black_and_white_color) pref = GlobalUserPreferences.ColorPreference.WHITE; - - if (pref == null) return false; - - GlobalUserPreferences.color=pref; - GlobalUserPreferences.save(); - restartActivityToApplyNewTheme(); - return true; - } -} - diff --git a/mastodon/src/main/java/org/joinmastodon/android/fragments/settings/BehaviourFragment.java b/mastodon/src/main/java/org/joinmastodon/android/fragments/settings/BehaviourFragment.java deleted file mode 100644 index 22353b974..000000000 --- a/mastodon/src/main/java/org/joinmastodon/android/fragments/settings/BehaviourFragment.java +++ /dev/null @@ -1,199 +0,0 @@ -package org.joinmastodon.android.fragments.settings; - -import android.os.Build; -import android.view.Gravity; -import android.view.MenuItem; -import android.view.ViewGroup; -import android.widget.Button; -import android.widget.EditText; -import android.widget.FrameLayout; -import android.widget.PopupMenu; -import android.widget.Toast; - -import org.joinmastodon.android.GlobalUserPreferences; -import org.joinmastodon.android.R; -//import org.joinmastodon.android.fragments.SettingsFragment; -import org.joinmastodon.android.ui.M3AlertDialogBuilder; - -import java.util.ArrayList; - -import me.grishka.appkit.utils.V; - -public class BehaviourFragment extends SettingsBaseFragment{ - - SwitchItem alwaysRevealSpoilersItem; - ButtonItem autoRevealSpoilersItem; - ButtonItem publishButtonTextSetting; - SwitchItem relocatePublishButtonSetting; - @Override - public void addItems(ArrayList items) { - items.add(new HeaderItem(R.string.settings_behavior)); - items.add(new SwitchItem(R.string.settings_gif, R.string.mo_setting_play_gif_summary, R.drawable.ic_fluent_gif_24_regular, GlobalUserPreferences.playGifs, i->{ - GlobalUserPreferences.playGifs=i.checked; - GlobalUserPreferences.save(); - })); - items.add(new SwitchItem(R.string.settings_custom_tabs, R.drawable.ic_fluent_link_24_regular, GlobalUserPreferences.useCustomTabs, i->{ - GlobalUserPreferences.useCustomTabs=i.checked; - GlobalUserPreferences.save(); - })); - items.add(new SettingsBaseFragment.SwitchItem(R.string.sk_settings_allow_remote_loading, R.string.sk_settings_allow_remote_loading_explanation, R.drawable.ic_fluent_communication_24_regular, GlobalUserPreferences.allowRemoteLoading, i->{ - GlobalUserPreferences.allowRemoteLoading=i.checked; - GlobalUserPreferences.save(); - })); - items.add(alwaysRevealSpoilersItem = new SettingsBaseFragment.SwitchItem(R.string.sk_settings_always_reveal_content_warnings, R.drawable.ic_fluent_chat_warning_24_regular, GlobalUserPreferences.alwaysExpandContentWarnings, i->{ - GlobalUserPreferences.alwaysExpandContentWarnings=i.checked; - GlobalUserPreferences.save(); - if (list.findViewHolderForAdapterPosition(items.indexOf(autoRevealSpoilersItem)) instanceof SettingsBaseFragment.ButtonViewHolder bvh) bvh.rebind(); - })); - items.add(autoRevealSpoilersItem = new SettingsBaseFragment.ButtonItem(R.string.sk_settings_auto_reveal_equal_spoilers, R.drawable.ic_fluent_eye_24_regular, b->{ - PopupMenu popupMenu=new PopupMenu(getActivity(), b, Gravity.CENTER_HORIZONTAL); - popupMenu.inflate(R.menu.settings_auto_reveal_spoiler); - popupMenu.setOnMenuItemClickListener(i -> onAutoRevealSpoilerClick(i, b)); - b.setOnTouchListener(popupMenu.getDragToOpenListener()); - b.setOnClickListener(v->popupMenu.show()); - onAutoRevealSpoilerChanged(b); - })); - - items.add(new SwitchItem(R.string.sk_tabs_disable_swipe, R.string.mo_setting_disable_swipe_summary, R.drawable.ic_fluent_swipe_right_24_regular, GlobalUserPreferences.disableSwipe, i->{ - GlobalUserPreferences.disableSwipe=i.checked; - GlobalUserPreferences.save(); - needAppRestart=true; - })); - items.add(new SwitchItem(R.string.mo_double_tap_to_swipe_between_tabs, R.drawable.ic_fluent_double_tap_swipe_right_24_regular, GlobalUserPreferences.doubleTapToSwipe, i->{ - GlobalUserPreferences.doubleTapToSwipe=i.checked; - GlobalUserPreferences.save(); - needAppRestart=true; - })); - items.add(new SwitchItem(R.string.mo_haptic_feedback, R.string.mo_setting_haptic_feedback_summary, R.drawable.ic_fluent_phone_vibrate_24_filled, GlobalUserPreferences.hapticFeedback, i -> { - GlobalUserPreferences.hapticFeedback = i.checked; - GlobalUserPreferences.save(); - })); - items.add(new SwitchItem(R.string.sk_settings_confirm_before_reblog, R.drawable.ic_fluent_checkmark_circle_24_regular, GlobalUserPreferences.confirmBeforeReblog, i->{ - GlobalUserPreferences.confirmBeforeReblog=i.checked; - GlobalUserPreferences.save(); - })); - items.add(new SettingsBaseFragment.SwitchItem(R.string.sk_settings_forward_report_default, R.drawable.ic_fluent_arrow_forward_24_regular, GlobalUserPreferences.forwardReportDefault, i->{ - GlobalUserPreferences.forwardReportDefault=i.checked; - GlobalUserPreferences.save(); - })); - - items.add(new HeaderItem(R.string.mo_composer_behavior)); - items.add(publishButtonTextSetting = new ButtonItem(R.string.sk_settings_publish_button_text, R.drawable.ic_fluent_send_24_regular, b-> { - updatePublishText(b); - b.setOnClickListener(l -> { - if(!GlobalUserPreferences.relocatePublishButton) { - FrameLayout inputWrap = new FrameLayout(getContext()); - EditText input = new EditText(getContext()); - input.setHint(R.string.publish); - input.setText(GlobalUserPreferences.publishButtonText.trim()); - FrameLayout.LayoutParams params = new FrameLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT); - params.setMargins(V.dp(16), V.dp(4), V.dp(16), V.dp(16)); - input.setLayoutParams(params); - inputWrap.addView(input); - new M3AlertDialogBuilder(getContext()).setTitle(R.string.sk_settings_publish_button_text_title).setView(inputWrap) - .setPositiveButton(R.string.save, (d, which) -> { - GlobalUserPreferences.publishButtonText = input.getText().toString().trim(); - GlobalUserPreferences.save(); - updatePublishText(b); - }) - .setNeutralButton(R.string.clear, (d, which) -> { - GlobalUserPreferences.publishButtonText = ""; - GlobalUserPreferences.save(); - updatePublishText(b); - }) - .setNegativeButton(R.string.cancel, (d, which) -> { - }) - .show(); - - } else { - Toast.makeText(getActivity(), R.string.mo_disable_relocate_publish_button_to_enable_customization, - Toast.LENGTH_LONG).show(); - } - }); - - b.setAlpha(relocatePublishButtonSetting.checked ? 0.7f : 1f); - })); - items.add(relocatePublishButtonSetting = new SwitchItem(R.string.mo_relocate_publish_button, R.string.mo_setting_relocate_publish_summary, R.drawable.ic_fluent_arrow_autofit_down_24_regular, GlobalUserPreferences.relocatePublishButton, i->{ - if (list.findViewHolderForAdapterPosition(items.indexOf(publishButtonTextSetting)) instanceof SettingsBaseFragment.ButtonViewHolder bvh) bvh.rebind(); - GlobalUserPreferences.relocatePublishButton=i.checked; - GlobalUserPreferences.save(); - })); - items.add(new SwitchItem(R.string.mo_change_default_reply_visibility_to_unlisted, R.string.mo_setting_default_reply_privacy_summary, R.drawable.ic_fluent_lock_open_24_regular, GlobalUserPreferences.defaultToUnlistedReplies, i->{ - GlobalUserPreferences.defaultToUnlistedReplies=i.checked; - GlobalUserPreferences.save(); - })); - items.add(new SwitchItem(R.string.mo_mention_reblogger_automatically, R.drawable.ic_fluent_comment_mention_24_regular, GlobalUserPreferences.mentionRebloggerAutomatically, i -> { - GlobalUserPreferences.mentionRebloggerAutomatically=i.checked; - GlobalUserPreferences.save(); - })); - items.add(new SwitchItem(R.string.mo_disable_reminder_to_add_alt_text, R.drawable.ic_fluent_image_alt_text_24_regular, GlobalUserPreferences.disableAltTextReminder, i->{ - GlobalUserPreferences.disableAltTextReminder=i.checked; - GlobalUserPreferences.save(); - needAppRestart=true; - })); - items.add(new SettingsBaseFragment.ButtonItem(R.string.sk_settings_prefix_reply_cw_with_re, R.drawable.ic_fluent_arrow_reply_24_regular, b->{ - PopupMenu popupMenu=new PopupMenu(getActivity(), b, Gravity.CENTER_HORIZONTAL); - popupMenu.inflate(R.menu.settings_prefix_reply_mode); - popupMenu.setOnMenuItemClickListener(i -> onPrefixRepliesClick(i, b)); - b.setOnTouchListener(popupMenu.getDragToOpenListener()); - b.setOnClickListener(v->popupMenu.show()); - b.setText(switch(GlobalUserPreferences.prefixReplies){ - case TO_OTHERS -> R.string.sk_settings_prefix_replies_to_others; - case ALWAYS -> R.string.sk_settings_prefix_replies_always; - default -> R.string.sk_settings_prefix_replies_never; - }); - GlobalUserPreferences.save(); - })); - } - - private boolean onPrefixRepliesClick(MenuItem item, Button btn) { - int id = item.getItemId(); - GlobalUserPreferences.PrefixRepliesMode mode = GlobalUserPreferences.PrefixRepliesMode.NEVER; - if (id == R.id.prefix_replies_always) mode = GlobalUserPreferences.PrefixRepliesMode.ALWAYS; - else if (id == R.id.prefix_replies_to_others) mode = GlobalUserPreferences.PrefixRepliesMode.TO_OTHERS; - GlobalUserPreferences.prefixReplies = mode; - - btn.setText(switch(GlobalUserPreferences.prefixReplies){ - case TO_OTHERS -> R.string.sk_settings_prefix_replies_to_others; - case ALWAYS -> R.string.sk_settings_prefix_replies_always; - default -> R.string.sk_settings_prefix_replies_never; - }); - - return true; - } - - private boolean onAutoRevealSpoilerClick(MenuItem item, Button btn) { - int id = item.getItemId(); - - GlobalUserPreferences.AutoRevealMode mode = GlobalUserPreferences.AutoRevealMode.NEVER; - if (id == R.id.auto_reveal_threads) mode = GlobalUserPreferences.AutoRevealMode.THREADS; - else if (id == R.id.auto_reveal_discussions) mode = GlobalUserPreferences.AutoRevealMode.DISCUSSIONS; - - GlobalUserPreferences.alwaysExpandContentWarnings = false; - GlobalUserPreferences.autoRevealEqualSpoilers = mode; - GlobalUserPreferences.save(); - onAutoRevealSpoilerChanged(btn); - return true; - } - - private void onAutoRevealSpoilerChanged(Button b) { - if (GlobalUserPreferences.alwaysExpandContentWarnings) { - b.setText(R.string.sk_settings_auto_reveal_anyone); - } else { - b.setText(switch(GlobalUserPreferences.autoRevealEqualSpoilers){ - case THREADS -> R.string.sk_settings_auto_reveal_author; - case DISCUSSIONS -> R.string.sk_settings_auto_reveal_anyone; - default -> R.string.sk_settings_auto_reveal_nobody; - }); - if (alwaysRevealSpoilersItem.checked != GlobalUserPreferences.alwaysExpandContentWarnings) { - alwaysRevealSpoilersItem.checked = GlobalUserPreferences.alwaysExpandContentWarnings; - if (list.findViewHolderForAdapterPosition(items.indexOf(alwaysRevealSpoilersItem)) instanceof SettingsBaseFragment.SwitchViewHolder svh) svh.rebind(); - } - } - } - - private void updatePublishText(Button btn) { - if (GlobalUserPreferences.publishButtonText.isBlank()) btn.setText(R.string.publish); - else btn.setText(GlobalUserPreferences.publishButtonText); - } -} diff --git a/mastodon/src/main/java/org/joinmastodon/android/fragments/settings/NotificationsFragment.java b/mastodon/src/main/java/org/joinmastodon/android/fragments/settings/NotificationsFragment.java deleted file mode 100644 index 265a4be75..000000000 --- a/mastodon/src/main/java/org/joinmastodon/android/fragments/settings/NotificationsFragment.java +++ /dev/null @@ -1,47 +0,0 @@ -package org.joinmastodon.android.fragments.settings; - -import org.joinmastodon.android.GlobalUserPreferences; -import org.joinmastodon.android.R; -import org.joinmastodon.android.model.PushNotification; -import org.joinmastodon.android.model.PushSubscription; - -import java.util.ArrayList; - -public class NotificationsFragment extends SettingsBaseFragment { - @Override - public void addItems(ArrayList items) { - items.add(new HeaderItem(R.string.mo_notification_audience_settings)); - items.add(notificationPolicyItem = new NotificationPolicyItem()); - PushSubscription pushSubscription = getPushSubscription(); - boolean switchEnabled = pushSubscription.policy != PushSubscription.Policy.NONE; - - items.add(new SwitchItem(R.string.notify_favorites, R.drawable.ic_fluent_star_24_regular, pushSubscription.alerts.favourite, i -> onNotificationsChanged(PushNotification.Type.FAVORITE, i.checked), switchEnabled)); - items.add(new SwitchItem(R.string.notify_follow, R.drawable.ic_fluent_person_add_24_regular, pushSubscription.alerts.follow, i -> onNotificationsChanged(PushNotification.Type.FOLLOW, i.checked), switchEnabled)); - items.add(new SwitchItem(R.string.notify_reblog, R.drawable.ic_fluent_arrow_repeat_all_24_regular, pushSubscription.alerts.reblog, i -> onNotificationsChanged(PushNotification.Type.REBLOG, i.checked), switchEnabled)); - items.add(new SwitchItem(R.string.notify_mention, R.drawable.ic_fluent_mention_24_regular, pushSubscription.alerts.mention, i -> onNotificationsChanged(PushNotification.Type.MENTION, i.checked), switchEnabled)); - items.add(new SwitchItem(R.string.sk_notify_posts, R.drawable.ic_fluent_chat_24_regular, pushSubscription.alerts.status, i -> onNotificationsChanged(PushNotification.Type.STATUS, i.checked), switchEnabled)); - items.add(new SwitchItem(R.string.sk_notify_update, R.drawable.ic_fluent_history_24_regular, pushSubscription.alerts.update, i -> onNotificationsChanged(PushNotification.Type.UPDATE, i.checked), switchEnabled)); - items.add(new SwitchItem(R.string.sk_notify_poll_results, R.drawable.ic_fluent_poll_24_regular, pushSubscription.alerts.poll, i -> onNotificationsChanged(PushNotification.Type.POLL, i.checked), switchEnabled)); - - items.add(new HeaderItem(R.string.mo_notification_management_settings)); - items.add(new SwitchItem(R.string.sk_enable_delete_notifications, R.drawable.ic_fluent_mail_inbox_dismiss_24_regular, GlobalUserPreferences.enableDeleteNotifications, i->{ - GlobalUserPreferences.enableDeleteNotifications=i.checked; - GlobalUserPreferences.save(); - needAppRestart=true; - })); - items.add(new SwitchItem(R.string.sk_settings_single_notification, R.drawable.ic_fluent_convert_range_24_regular, GlobalUserPreferences.keepOnlyLatestNotification, i->{ - GlobalUserPreferences.keepOnlyLatestNotification=i.checked; - GlobalUserPreferences.save(); - })); - items.add(new SwitchItem(R.string.sk_settings_uniform_icon_for_notifications, R.string.mo_setting_uniform_summary, R.drawable.ic_ntf_logo, GlobalUserPreferences.uniformNotificationIcon, i -> { - GlobalUserPreferences.uniformNotificationIcon = i.checked; - GlobalUserPreferences.save(); - })); - items.add(new SwitchItem(R.string.mo_swap_bookmark_with_reblog, R.string.mo_swap_bookmark_with_reblog_summary, R.drawable.ic_boost, GlobalUserPreferences.swapBookmarkWithBoostAction, i -> { - GlobalUserPreferences.swapBookmarkWithBoostAction=i.checked; - GlobalUserPreferences.save(); - })); - - - } -} diff --git a/mastodon/src/main/java/org/joinmastodon/android/fragments/settings/SettingsBaseFragment.java b/mastodon/src/main/java/org/joinmastodon/android/fragments/settings/SettingsBaseFragment.java deleted file mode 100644 index 77731be34..000000000 --- a/mastodon/src/main/java/org/joinmastodon/android/fragments/settings/SettingsBaseFragment.java +++ /dev/null @@ -1,981 +0,0 @@ -package org.joinmastodon.android.fragments.settings; - -import android.animation.ObjectAnimator; -import android.annotation.SuppressLint; -import android.app.Fragment; -import android.graphics.Rect; -import android.os.Build; -import android.os.Bundle; -import android.util.TypedValue; -import android.view.Gravity; -import android.view.LayoutInflater; -import android.view.View; -import android.view.ViewGroup; -import android.view.WindowInsets; -import android.view.animation.AlphaAnimation; -import android.view.animation.LinearInterpolator; -import android.widget.Button; -import android.widget.ImageButton; -import android.widget.ImageView; -import android.widget.LinearLayout; -import android.widget.PopupMenu; -import android.widget.ProgressBar; -import android.widget.RadioButton; -import android.widget.Switch; -import android.widget.TextView; - -import androidx.annotation.DrawableRes; -import androidx.annotation.NonNull; -import androidx.annotation.StringRes; -import androidx.recyclerview.widget.LinearLayoutManager; -import androidx.recyclerview.widget.RecyclerView; - -import org.joinmastodon.android.E; -import org.joinmastodon.android.GlobalUserPreferences; -import org.joinmastodon.android.R; -import org.joinmastodon.android.api.PushSubscriptionManager; -import org.joinmastodon.android.api.session.AccountSession; -import org.joinmastodon.android.api.session.AccountSessionManager; -import org.joinmastodon.android.fragments.DomainDisplay; -//import org.joinmastodon.android.fragments.InstanceInfoFragment; -import org.joinmastodon.android.fragments.MastodonToolbarFragment; -import org.joinmastodon.android.model.Instance; -import org.joinmastodon.android.model.PushNotification; -import org.joinmastodon.android.model.PushSubscription; -import org.joinmastodon.android.ui.OutlineProviders; -import org.joinmastodon.android.ui.utils.UiUtils; -import org.joinmastodon.android.updater.GithubSelfUpdater; - -import java.util.ArrayList; -import java.util.function.Consumer; - -import me.grishka.appkit.Nav; -import me.grishka.appkit.utils.BindableViewHolder; -import me.grishka.appkit.utils.V; -import me.grishka.appkit.views.UsableRecyclerView; - -public abstract class SettingsBaseFragment extends MastodonToolbarFragment implements DomainDisplay { - protected View view; - protected UsableRecyclerView list; - - protected ImageView themeTransitionWindowView; - - protected ThemeItem themeItem; - - protected boolean needAppRestart; - - private Instance instance; - private String instanceName; - protected String title; - - protected NotificationPolicyItem notificationPolicyItem; - - protected PushSubscription pushSubscription; - protected ArrayList items=new ArrayList<>(); - protected String accountID; - protected AccountSession session; - - protected boolean needUpdateNotificationSettings; - - public abstract void addItems(ArrayList items); - - @Override - public void onCreate(Bundle savedInstanceState){ - super.onCreate(savedInstanceState); - if(Build.VERSION.SDK_INT>=Build.VERSION_CODES.N) - setRetainInstance(true); - setTitle(R.string.settings); - - accountID=getArguments().getString("account"); - session = AccountSessionManager.getInstance().getAccount(accountID); - instance = AccountSessionManager.getInstance().getInstanceInfo(session.domain); - instanceName = UiUtils.getInstanceName(accountID); - - if (GithubSelfUpdater.needSelfUpdating()) - E.register(this); - - - - addItems(items); - title = getArguments().getString("title", getTitle().toString()); - items.add(0, new GiantHeaderItem(title)); - } - - @Override - public View onCreateContentView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { - list = new UsableRecyclerView(getActivity()); - list.setLayoutManager(new LinearLayoutManager(getActivity())); - list.setAdapter(new SettingsAdapter()); - list.setBackgroundColor(UiUtils.getThemeColor(getActivity(), android.R.attr.windowBackground)); - list.setPadding(0, V.dp(16), 0, V.dp(12)); - list.setClipToPadding(false); - list.addItemDecoration(new RecyclerView.ItemDecoration() { - @Override - public void getItemOffsets(@NonNull Rect outRect, @NonNull View view, @NonNull RecyclerView parent, @NonNull RecyclerView.State state) { - // Add 32dp gaps between sections - RecyclerView.ViewHolder holder = parent.getChildViewHolder(view); - if ((holder instanceof HeaderViewHolder || holder instanceof FooterViewHolder) && holder.getAbsoluteAdapterPosition() > 1) - outRect.top = V.dp(32); - } - }); - - setTitle(title); - - list.addOnScrollListener(new RecyclerView.OnScrollListener() { - @Override - public void onScrolled(@NonNull RecyclerView recyclerView, int dx, int dy) { - LinearLayoutManager linearLayoutManager = (LinearLayoutManager) list.getLayoutManager(); - if (linearLayoutManager != null && linearLayoutManager.findFirstVisibleItemPosition() > 0) { - showToolbarAnimated(); - } else { - hideToolbarAnimated(); - } - } - }); - - return list; - } - - @Override - public void onApplyWindowInsets(WindowInsets insets){ - if(Build.VERSION.SDK_INT>=29 && insets.getTappableElementInsets().bottom==0){ - list.setPadding(0, V.dp(16), 0, V.dp(12)+insets.getSystemWindowInsetBottom()); - insets=insets.inset(0, 0, 0, insets.getSystemWindowInsetBottom()); - } - super.onApplyWindowInsets(insets); - } - - @Override - public void onViewCreated(View view, Bundle savedInstanceState){ - super.onViewCreated(view, savedInstanceState); - this.view = view; - hideToolbar(); - toolbarTitleView.setVisibility(View.INVISIBLE); - setStatusBarColor(UiUtils.getThemeColor(getContext(), R.attr.colorWindowBackground)); - } - - protected void hideToolbar() { - getToolbar().setElevation(0f); - toolbarTitleView.setVisibility(View.INVISIBLE); - TypedValue typedValue = new TypedValue(); - if (getActivity().getTheme().resolveAttribute(android.R.attr.windowBackground, typedValue, true)) { - getToolbar().setBackgroundColor(typedValue.data); - } - } - - protected void showToolbarAnimated(){ - AlphaAnimation fadeIn = new AlphaAnimation(0.0f , 1.0f ) ; - fadeIn.setDuration(100); - if(toolbarTitleView.getVisibility() != View.VISIBLE){ - getToolbar().setElevation(8.625f); - toolbarTitleView.startAnimation(fadeIn); - toolbarTitleView.setVisibility(View.VISIBLE); - } - getToolbar().setBackgroundColor(UiUtils.getThemeColor(getContext(), R.attr.colorBackgroundLight)); - setStatusBarColor(UiUtils.getThemeColor(getContext(), R.attr.colorBackgroundLight)); - } - - protected void hideToolbarAnimated(){ - AlphaAnimation fadeOut = new AlphaAnimation( 1.0f , 0.0f ) ; - fadeOut.setDuration(100); - if(toolbarTitleView.getVisibility() != View.INVISIBLE){ - getToolbar().setElevation(0f); - toolbarTitleView.startAnimation(fadeOut); - toolbarTitleView.setVisibility(View.INVISIBLE); - } - getToolbar().setBackgroundColor(UiUtils.getThemeColor(getContext(), R.attr.colorWindowBackground)); - setStatusBarColor(UiUtils.getThemeColor(getContext(), R.attr.colorWindowBackground)); - - } - - protected Instance getInstance() { - return instance; - } - - protected String getInstanceName() { - return instanceName; - } - - - static abstract class Item{ - public abstract int getViewType(); - } - - protected class HeaderItem extends Item{ - private String text; - - public HeaderItem(@StringRes int text){ - this.text=getString(text); - } - - public HeaderItem(String text){ - this.text=text; - } - - @Override - public int getViewType(){ - return Type.HEADER.ordinal(); - } - } - - protected class RedHeaderItem extends HeaderItem { - - public RedHeaderItem(int text){ - super(text); - } - - public RedHeaderItem(String text){ - super(text); - } - - @Override - public int getViewType(){ - return Type.RED_HEADER.ordinal(); - } - } - - - protected class SwitchItem extends Item{ - private String title; - private String summary; - private int icon; - boolean checked; - private Consumer onChanged; - protected boolean enabled=true; - - public SwitchItem(@StringRes int title, @DrawableRes int icon, boolean checked, Consumer onChanged){ - this.title=getString(title); - this.icon=icon; - this.checked=checked; - this.onChanged=onChanged; - } - - public SwitchItem(@StringRes int title, @StringRes int summary, @DrawableRes int icon, boolean checked, Consumer onChanged){ - this.title=getString(title); - this.summary=getString(summary); - this.icon=icon; - this.checked=checked; - this.onChanged=onChanged; - } - - public SwitchItem(@StringRes int title, @DrawableRes int icon, boolean checked, Consumer onChanged, boolean enabled){ - this.title=getString(title); - this.icon=icon; - this.checked=checked; - this.onChanged=onChanged; - this.enabled=enabled; - } - - @Override - public int getViewType(){ - return Type.SWITCH.ordinal(); - } - } - - protected class UpdateItem extends Item { - - @Override - public int getViewType(){ - return Type.UPDATER.ordinal(); - } - } - - protected static class ThemeItem extends Item { - - @Override - public int getViewType(){ - return Type.THEME.ordinal(); - } - } - - protected static class NotificationPolicyItem extends Item { - - @Override - public int getViewType(){ - return Type.NOTIFICATION_POLICY.ordinal(); - } - } - - - protected class ButtonItem extends Item{ - private int title; - private int summary; - private int icon; - private Consumer