From 5b2d04e09d6126d9610cc6aee8a217ec5c17c4af Mon Sep 17 00:00:00 2001 From: sk Date: Fri, 21 Jul 2023 01:45:08 +0200 Subject: [PATCH] add navigation bar tab labels - with option to hide them --- .../android/GlobalUserPreferences.java | 3 + .../android/fragments/HomeFragment.java | 9 +- .../settings/SettingsDisplayFragment.java | 9 +- .../main/res/color/m3_on_surface_selector.xml | 6 + mastodon/src/main/res/layout/tab_bar.xml | 218 ++++++++++++------ mastodon/src/main/res/values/strings_sk.xml | 5 + 6 files changed, 173 insertions(+), 77 deletions(-) create mode 100644 mastodon/src/main/res/color/m3_on_surface_selector.xml diff --git a/mastodon/src/main/java/org/joinmastodon/android/GlobalUserPreferences.java b/mastodon/src/main/java/org/joinmastodon/android/GlobalUserPreferences.java index 2d91b09f0..22bf062a9 100644 --- a/mastodon/src/main/java/org/joinmastodon/android/GlobalUserPreferences.java +++ b/mastodon/src/main/java/org/joinmastodon/android/GlobalUserPreferences.java @@ -57,6 +57,7 @@ public class GlobalUserPreferences{ public static AutoRevealMode autoRevealEqualSpoilers; public static ColorPreference color; public static boolean disableM3PillActiveIndicator; + public static boolean showNavigationLabels; public static boolean displayPronounsInTimelines, displayPronounsInThreads, displayPronounsInUserListings; private static SharedPreferences getPrefs(){ @@ -112,6 +113,7 @@ public class GlobalUserPreferences{ autoRevealEqualSpoilers=AutoRevealMode.valueOf(prefs.getString("autoRevealEqualSpoilers", AutoRevealMode.THREADS.name())); forwardReportDefault=prefs.getBoolean("forwardReportDefault", true); disableM3PillActiveIndicator=prefs.getBoolean("disableM3PillActiveIndicator", false); + showNavigationLabels=prefs.getBoolean("showNavigationLabels", true); displayPronounsInTimelines=prefs.getBoolean("displayPronounsInTimelines", true); displayPronounsInThreads=prefs.getBoolean("displayPronounsInThreads", true); displayPronounsInUserListings=prefs.getBoolean("displayPronounsInUserListings", true); @@ -168,6 +170,7 @@ public class GlobalUserPreferences{ .putString("autoRevealEqualSpoilers", autoRevealEqualSpoilers.name()) .putBoolean("forwardReportDefault", forwardReportDefault) .putBoolean("disableM3PillActiveIndicator", disableM3PillActiveIndicator) + .putBoolean("showNavigationLabels", showNavigationLabels) .putBoolean("displayPronounsInTimelines", displayPronounsInTimelines) .putBoolean("displayPronounsInThreads", displayPronounsInThreads) .putBoolean("displayPronounsInUserListings", displayPronounsInUserListings) diff --git a/mastodon/src/main/java/org/joinmastodon/android/fragments/HomeFragment.java b/mastodon/src/main/java/org/joinmastodon/android/fragments/HomeFragment.java index bf59b2bb1..94031053c 100644 --- a/mastodon/src/main/java/org/joinmastodon/android/fragments/HomeFragment.java +++ b/mastodon/src/main/java/org/joinmastodon/android/fragments/HomeFragment.java @@ -126,7 +126,7 @@ public class HomeFragment extends AppKitFragment implements OnBackPressedListene tabBarWrap=content.findViewById(R.id.tabbar_wrap); // this one's for the pill haters (https://m3.material.io/components/navigation-bar/overview) - if (GlobalUserPreferences.disableM3PillActiveIndicator) { + if (GlobalUserPreferences.disableM3PillActiveIndicator){ for(int i=0; i{ private CheckableListItem revealCWsItem, hideSensitiveMediaItem, interactionCountsItem, emojiInNamesItem; // MEGALODON - private CheckableListItem trueBlackModeItem, marqueeItem, disableSwipeItem, reduceMotionItem, altIndicatorItem, noAltIndicatorItem, collapsePostsItem, spectatorModeItem, hideFabItem, translateOpenedItem, disablePillItem; + private CheckableListItem trueBlackModeItem, marqueeItem, disableSwipeItem, reduceMotionItem, altIndicatorItem, noAltIndicatorItem, collapsePostsItem, spectatorModeItem, hideFabItem, translateOpenedItem, disablePillItem, showNavigationLabelsItem; private ListItem colorItem, publishTextItem, autoRevealCWsItem; private CheckableListItem pronounsInUserListingsItem, pronounsInTimelinesItem, pronounsInThreadsItem; @@ -68,7 +68,8 @@ public class SettingsDisplayFragment extends BaseSettingsFragment{ spectatorModeItem=new CheckableListItem<>(R.string.sk_settings_hide_interaction, 0, CheckableListItem.Style.SWITCH, GlobalUserPreferences.spectatorMode, R.drawable.ic_fluent_star_off_24_regular, ()->toggleCheckableItem(spectatorModeItem)), hideFabItem=new CheckableListItem<>(R.string.sk_settings_hide_fab, 0, CheckableListItem.Style.SWITCH, GlobalUserPreferences.autoHideFab, R.drawable.ic_fluent_edit_24_regular, ()->toggleCheckableItem(hideFabItem)), translateOpenedItem=new CheckableListItem<>(R.string.sk_settings_translate_only_opened, 0, CheckableListItem.Style.SWITCH, GlobalUserPreferences.translateButtonOpenedOnly, R.drawable.ic_fluent_translate_24_regular, ()->toggleCheckableItem(translateOpenedItem)), - disablePillItem=new CheckableListItem<>(R.string.sk_disable_pill_shaped_active_indicator, 0, CheckableListItem.Style.SWITCH, GlobalUserPreferences.disableM3PillActiveIndicator, R.drawable.ic_fluent_pill_24_regular, ()->toggleCheckableItem(disablePillItem), true), + disablePillItem=new CheckableListItem<>(R.string.sk_disable_pill_shaped_active_indicator, 0, CheckableListItem.Style.SWITCH, GlobalUserPreferences.disableM3PillActiveIndicator, R.drawable.ic_fluent_pill_24_regular, ()->toggleCheckableItem(disablePillItem)), + showNavigationLabelsItem=new CheckableListItem<>(R.string.sk_settings_show_labels_in_navigation_bar, 0, CheckableListItem.Style.SWITCH, GlobalUserPreferences.showNavigationLabels, R.drawable.ic_fluent_tag_24_regular, ()->toggleCheckableItem(showNavigationLabelsItem), true), pronounsInTimelinesItem=new CheckableListItem<>(R.string.sk_settings_display_pronouns_in_timelines, 0, CheckableListItem.Style.CHECKBOX, GlobalUserPreferences.displayPronounsInTimelines, 0, ()->toggleCheckableItem(pronounsInTimelinesItem)), pronounsInThreadsItem=new CheckableListItem<>(R.string.sk_settings_display_pronouns_in_threads, 0, CheckableListItem.Style.CHECKBOX, GlobalUserPreferences.displayPronounsInThreads, 0, ()->toggleCheckableItem(pronounsInThreadsItem)), pronounsInUserListingsItem=new CheckableListItem<>(R.string.sk_settings_display_pronouns_in_user_listings, 0, CheckableListItem.Style.CHECKBOX, GlobalUserPreferences.displayPronounsInUserListings, 0, ()->toggleCheckableItem(pronounsInUserListingsItem)) @@ -94,7 +95,8 @@ public class SettingsDisplayFragment extends BaseSettingsFragment{ super.onHidden(); boolean restartPlease= - GlobalUserPreferences.disableM3PillActiveIndicator!=disablePillItem.checked; + GlobalUserPreferences.disableM3PillActiveIndicator!=disablePillItem.checked || + GlobalUserPreferences.showNavigationLabels!=showNavigationLabelsItem.checked; lp.revealCWs=revealCWsItem.checked; lp.hideSensitiveMedia=hideSensitiveMediaItem.checked; @@ -111,6 +113,7 @@ public class SettingsDisplayFragment extends BaseSettingsFragment{ GlobalUserPreferences.autoHideFab=hideFabItem.checked; GlobalUserPreferences.translateButtonOpenedOnly=translateOpenedItem.checked; GlobalUserPreferences.disableM3PillActiveIndicator=disablePillItem.checked; + GlobalUserPreferences.showNavigationLabels=showNavigationLabelsItem.checked; GlobalUserPreferences.displayPronounsInTimelines=pronounsInTimelinesItem.checked; GlobalUserPreferences.displayPronounsInThreads=pronounsInThreadsItem.checked; GlobalUserPreferences.displayPronounsInUserListings=pronounsInUserListingsItem.checked; diff --git a/mastodon/src/main/res/color/m3_on_surface_selector.xml b/mastodon/src/main/res/color/m3_on_surface_selector.xml new file mode 100644 index 000000000..f1c42d07c --- /dev/null +++ b/mastodon/src/main/res/color/m3_on_surface_selector.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/mastodon/src/main/res/layout/tab_bar.xml b/mastodon/src/main/res/layout/tab_bar.xml index c89a30864..395cae074 100644 --- a/mastodon/src/main/res/layout/tab_bar.xml +++ b/mastodon/src/main/res/layout/tab_bar.xml @@ -12,111 +12,183 @@ - + android:orientation="vertical"> - + - + - + + + + + + + android:orientation="vertical"> - + - + - + + + + + + + android:orientation="vertical"> + + + + + + + + - - + android:layout_height="wrap_content" + android:layout_gravity="center_horizontal" + android:layout_marginTop="4dp" + android:textColor="@color/m3_on_surface_selector" + android:text="@string/sk_tab_notifications" /> - + - - - - + android:layout_marginEnd="8dp" + android:orientation="vertical"> + + + + + + + + + + \ No newline at end of file diff --git a/mastodon/src/main/res/values/strings_sk.xml b/mastodon/src/main/res/values/strings_sk.xml index e5ec374e4..5c1b7eb47 100644 --- a/mastodon/src/main/res/values/strings_sk.xml +++ b/mastodon/src/main/res/values/strings_sk.xml @@ -339,4 +339,9 @@ Display pronouns in timelines Display pronouns in threads Display pronouns in user listings + Home + Search + Notifications + Profile + Show tab labels in the navigation bar \ No newline at end of file