From fc9ffc9aeffbdf0b9d2a93b96f383060e3965f69 Mon Sep 17 00:00:00 2001 From: LucasGGamerM Date: Sat, 22 Apr 2023 22:35:39 -0300 Subject: [PATCH] feat: add settings category view holder Also adds a small proof of concept --- .../android/fragments/HomeTabFragment.java | 3 +- .../settings/SettingsBaseFragment.java | 88 ++++++++++++++++--- .../settings/SettingsMainFragment.java | 14 +++ .../res/layout/item_settings_category.xml | 32 +++++++ 4 files changed, 125 insertions(+), 12 deletions(-) create mode 100644 mastodon/src/main/java/org/joinmastodon/android/fragments/settings/SettingsMainFragment.java create mode 100644 mastodon/src/main/res/layout/item_settings_category.xml diff --git a/mastodon/src/main/java/org/joinmastodon/android/fragments/HomeTabFragment.java b/mastodon/src/main/java/org/joinmastodon/android/fragments/HomeTabFragment.java index a2a121bd6..9affb3ba7 100644 --- a/mastodon/src/main/java/org/joinmastodon/android/fragments/HomeTabFragment.java +++ b/mastodon/src/main/java/org/joinmastodon/android/fragments/HomeTabFragment.java @@ -47,6 +47,7 @@ import org.joinmastodon.android.events.ListDeletedEvent; import org.joinmastodon.android.events.ListUpdatedCreatedEvent; import org.joinmastodon.android.events.SelfUpdateStateChangedEvent; import org.joinmastodon.android.fragments.settings.SettingsFragment; +import org.joinmastodon.android.fragments.settings.SettingsMainFragment; import org.joinmastodon.android.model.Announcement; import org.joinmastodon.android.model.Hashtag; import org.joinmastodon.android.model.HeaderPaginationList; @@ -462,7 +463,7 @@ public class HomeTabFragment extends MastodonToolbarFragment implements Scrollab getToolbar().post(() -> overflowPopup.show()); return true; } else if (id == R.id.settings || id == R.id.settings_action) { - Nav.go(getActivity(), SettingsFragment.class, args); + Nav.go(getActivity(), SettingsMainFragment.class, args); } else if (id == R.id.announcements || id == R.id.announcements_action) { Nav.goForResult(getActivity(), AnnouncementsFragment.class, args, ANNOUNCEMENTS_RESULT, this); } else if (id == R.id.edit_timelines) { 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 index be246163f..93f7429b7 100644 --- a/mastodon/src/main/java/org/joinmastodon/android/fragments/settings/SettingsBaseFragment.java +++ b/mastodon/src/main/java/org/joinmastodon/android/fragments/settings/SettingsBaseFragment.java @@ -118,11 +118,11 @@ public abstract class SettingsBaseFragment extends MastodonToolbarFragment imple } - private static abstract class Item{ + static abstract class Item{ public abstract int getViewType(); } - private class HeaderItem extends Item{ + protected class HeaderItem extends Item{ private String text; public HeaderItem(@StringRes int text){ @@ -139,7 +139,7 @@ public abstract class SettingsBaseFragment extends MastodonToolbarFragment imple } } - private class SwitchItem extends Item{ + protected class SwitchItem extends Item{ private String text; private int icon; private boolean checked; @@ -167,7 +167,7 @@ public abstract class SettingsBaseFragment extends MastodonToolbarFragment imple } } - private class UpdateItem extends SettingsBaseFragment.Item { + protected class UpdateItem extends SettingsBaseFragment.Item { @Override public int getViewType(){ @@ -175,7 +175,7 @@ public abstract class SettingsBaseFragment extends MastodonToolbarFragment imple } } - private static class ThemeItem extends SettingsBaseFragment.Item { + protected static class ThemeItem extends SettingsBaseFragment.Item { @Override public int getViewType(){ @@ -183,7 +183,7 @@ public abstract class SettingsBaseFragment extends MastodonToolbarFragment imple } } - private static class NotificationPolicyItem extends SettingsBaseFragment.Item { + protected static class NotificationPolicyItem extends SettingsBaseFragment.Item { @Override public int getViewType(){ @@ -192,7 +192,7 @@ public abstract class SettingsBaseFragment extends MastodonToolbarFragment imple } - public class ButtonItem extends Item{ + protected class ButtonItem extends Item{ private int text; private int icon; private Consumer