add navigation bar tab labels - with option to hide them

This commit is contained in:
sk 2023-07-21 01:45:08 +02:00
parent 6bd13f99d2
commit 5b2d04e09d
6 changed files with 173 additions and 77 deletions

View File

@ -57,6 +57,7 @@ public class GlobalUserPreferences{
public static AutoRevealMode autoRevealEqualSpoilers; public static AutoRevealMode autoRevealEqualSpoilers;
public static ColorPreference color; public static ColorPreference color;
public static boolean disableM3PillActiveIndicator; public static boolean disableM3PillActiveIndicator;
public static boolean showNavigationLabels;
public static boolean displayPronounsInTimelines, displayPronounsInThreads, displayPronounsInUserListings; public static boolean displayPronounsInTimelines, displayPronounsInThreads, displayPronounsInUserListings;
private static SharedPreferences getPrefs(){ private static SharedPreferences getPrefs(){
@ -112,6 +113,7 @@ public class GlobalUserPreferences{
autoRevealEqualSpoilers=AutoRevealMode.valueOf(prefs.getString("autoRevealEqualSpoilers", AutoRevealMode.THREADS.name())); autoRevealEqualSpoilers=AutoRevealMode.valueOf(prefs.getString("autoRevealEqualSpoilers", AutoRevealMode.THREADS.name()));
forwardReportDefault=prefs.getBoolean("forwardReportDefault", true); forwardReportDefault=prefs.getBoolean("forwardReportDefault", true);
disableM3PillActiveIndicator=prefs.getBoolean("disableM3PillActiveIndicator", false); disableM3PillActiveIndicator=prefs.getBoolean("disableM3PillActiveIndicator", false);
showNavigationLabels=prefs.getBoolean("showNavigationLabels", true);
displayPronounsInTimelines=prefs.getBoolean("displayPronounsInTimelines", true); displayPronounsInTimelines=prefs.getBoolean("displayPronounsInTimelines", true);
displayPronounsInThreads=prefs.getBoolean("displayPronounsInThreads", true); displayPronounsInThreads=prefs.getBoolean("displayPronounsInThreads", true);
displayPronounsInUserListings=prefs.getBoolean("displayPronounsInUserListings", true); displayPronounsInUserListings=prefs.getBoolean("displayPronounsInUserListings", true);
@ -168,6 +170,7 @@ public class GlobalUserPreferences{
.putString("autoRevealEqualSpoilers", autoRevealEqualSpoilers.name()) .putString("autoRevealEqualSpoilers", autoRevealEqualSpoilers.name())
.putBoolean("forwardReportDefault", forwardReportDefault) .putBoolean("forwardReportDefault", forwardReportDefault)
.putBoolean("disableM3PillActiveIndicator", disableM3PillActiveIndicator) .putBoolean("disableM3PillActiveIndicator", disableM3PillActiveIndicator)
.putBoolean("showNavigationLabels", showNavigationLabels)
.putBoolean("displayPronounsInTimelines", displayPronounsInTimelines) .putBoolean("displayPronounsInTimelines", displayPronounsInTimelines)
.putBoolean("displayPronounsInThreads", displayPronounsInThreads) .putBoolean("displayPronounsInThreads", displayPronounsInThreads)
.putBoolean("displayPronounsInUserListings", displayPronounsInUserListings) .putBoolean("displayPronounsInUserListings", displayPronounsInUserListings)

View File

@ -126,7 +126,7 @@ public class HomeFragment extends AppKitFragment implements OnBackPressedListene
tabBarWrap=content.findViewById(R.id.tabbar_wrap); tabBarWrap=content.findViewById(R.id.tabbar_wrap);
// this one's for the pill haters (https://m3.material.io/components/navigation-bar/overview) // 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<tabBar.getChildCount(); i++){ for(int i=0; i<tabBar.getChildCount(); i++){
ViewGroup f=(ViewGroup) tabBar.getChildAt(i); ViewGroup f=(ViewGroup) tabBar.getChildAt(i);
f.setBackgroundResource(R.drawable.bg_tabbar_tab_ripple); f.setBackgroundResource(R.drawable.bg_tabbar_tab_ripple);
@ -134,6 +134,13 @@ public class HomeFragment extends AppKitFragment implements OnBackPressedListene
tabBar.findViewById(R.id.tab_profile).setBackgroundResource(R.drawable.bg_tab_profile); tabBar.findViewById(R.id.tab_profile).setBackgroundResource(R.drawable.bg_tab_profile);
} }
if (!GlobalUserPreferences.showNavigationLabels){
tabBar.findViewById(R.id.tab_home_label).setVisibility(View.GONE);
tabBar.findViewById(R.id.tab_search_label).setVisibility(View.GONE);
tabBar.findViewById(R.id.tab_notifications_label).setVisibility(View.GONE);
tabBar.findViewById(R.id.tab_profile_label).setVisibility(View.GONE);
}
tabBarAvatar=tabBar.findViewById(R.id.tab_profile_ava); tabBarAvatar=tabBar.findViewById(R.id.tab_profile_ava);
tabBarAvatar.setOutlineProvider(OutlineProviders.OVAL); tabBarAvatar.setOutlineProvider(OutlineProviders.OVAL);
tabBarAvatar.setClipToOutline(true); tabBarAvatar.setClipToOutline(true);

View File

@ -37,7 +37,7 @@ public class SettingsDisplayFragment extends BaseSettingsFragment<Void>{
private CheckableListItem<Void> revealCWsItem, hideSensitiveMediaItem, interactionCountsItem, emojiInNamesItem; private CheckableListItem<Void> revealCWsItem, hideSensitiveMediaItem, interactionCountsItem, emojiInNamesItem;
// MEGALODON // MEGALODON
private CheckableListItem<Void> trueBlackModeItem, marqueeItem, disableSwipeItem, reduceMotionItem, altIndicatorItem, noAltIndicatorItem, collapsePostsItem, spectatorModeItem, hideFabItem, translateOpenedItem, disablePillItem; private CheckableListItem<Void> trueBlackModeItem, marqueeItem, disableSwipeItem, reduceMotionItem, altIndicatorItem, noAltIndicatorItem, collapsePostsItem, spectatorModeItem, hideFabItem, translateOpenedItem, disablePillItem, showNavigationLabelsItem;
private ListItem<Void> colorItem, publishTextItem, autoRevealCWsItem; private ListItem<Void> colorItem, publishTextItem, autoRevealCWsItem;
private CheckableListItem<Void> pronounsInUserListingsItem, pronounsInTimelinesItem, pronounsInThreadsItem; private CheckableListItem<Void> pronounsInUserListingsItem, pronounsInTimelinesItem, pronounsInThreadsItem;
@ -68,7 +68,8 @@ public class SettingsDisplayFragment extends BaseSettingsFragment<Void>{
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)), 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)), 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)), 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)), 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)), 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)) 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<Void>{
super.onHidden(); super.onHidden();
boolean restartPlease= boolean restartPlease=
GlobalUserPreferences.disableM3PillActiveIndicator!=disablePillItem.checked; GlobalUserPreferences.disableM3PillActiveIndicator!=disablePillItem.checked ||
GlobalUserPreferences.showNavigationLabels!=showNavigationLabelsItem.checked;
lp.revealCWs=revealCWsItem.checked; lp.revealCWs=revealCWsItem.checked;
lp.hideSensitiveMedia=hideSensitiveMediaItem.checked; lp.hideSensitiveMedia=hideSensitiveMediaItem.checked;
@ -111,6 +113,7 @@ public class SettingsDisplayFragment extends BaseSettingsFragment<Void>{
GlobalUserPreferences.autoHideFab=hideFabItem.checked; GlobalUserPreferences.autoHideFab=hideFabItem.checked;
GlobalUserPreferences.translateButtonOpenedOnly=translateOpenedItem.checked; GlobalUserPreferences.translateButtonOpenedOnly=translateOpenedItem.checked;
GlobalUserPreferences.disableM3PillActiveIndicator=disablePillItem.checked; GlobalUserPreferences.disableM3PillActiveIndicator=disablePillItem.checked;
GlobalUserPreferences.showNavigationLabels=showNavigationLabelsItem.checked;
GlobalUserPreferences.displayPronounsInTimelines=pronounsInTimelinesItem.checked; GlobalUserPreferences.displayPronounsInTimelines=pronounsInTimelinesItem.checked;
GlobalUserPreferences.displayPronounsInThreads=pronounsInThreadsItem.checked; GlobalUserPreferences.displayPronounsInThreads=pronounsInThreadsItem.checked;
GlobalUserPreferences.displayPronounsInUserListings=pronounsInUserListingsItem.checked; GlobalUserPreferences.displayPronounsInUserListings=pronounsInUserListingsItem.checked;

View File

@ -0,0 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:color="?colorM3OnSurfaceVariant" android:state_enabled="false" />
<item android:color="?colorM3OnSurfaceVariant" android:state_selected="false" />
<item android:color="?colorM3OnSurface" />
</selector>

View File

@ -12,111 +12,183 @@
<org.joinmastodon.android.ui.views.TabBar <org.joinmastodon.android.ui.views.TabBar
android:id="@+id/tabbar" android:id="@+id/tabbar"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="56dp" android:layout_height="wrap_content"
android:paddingTop="12dp"
android:paddingBottom="16dp"
android:paddingHorizontal="8dp"> android:paddingHorizontal="8dp">
<FrameLayout <LinearLayout
android:id="@+id/tab_home" android:id="@+id/tab_home"
android:layout_width="0dp" android:layout_width="0dp"
android:layout_height="match_parent" android:layout_height="match_parent"
android:layout_weight="1" android:layout_weight="1"
android:layout_marginEnd="8dp" android:layout_marginEnd="8dp"
android:background="@drawable/bg_tabbar_tab" android:orientation="vertical">
android:contentDescription="@string/home_timeline">
<ImageView <FrameLayout
android:layout_width="24dp" android:layout_width="match_parent"
android:layout_height="24dp" android:layout_height="32dp"
android:layout_gravity="center" android:background="@drawable/bg_tabbar_tab"
android:scaleType="center" android:contentDescription="@string/home_timeline">
android:importantForAccessibility="no"
android:tint="@color/tab_bar_icon"
android:src="@drawable/ic_fluent_home_24_selector"/>
</FrameLayout> <ImageView
android:layout_width="24dp"
android:layout_height="24dp"
android:layout_gravity="center"
android:scaleType="center"
android:importantForAccessibility="no"
android:tint="@color/tab_bar_icon"
android:src="@drawable/ic_fluent_home_24_selector"/>
<FrameLayout </FrameLayout>
<TextView
android:id="@+id/tab_home_label"
style="@style/m3_label_medium"
android:layout_width="wrap_content"
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_home" />
</LinearLayout>
<LinearLayout
android:id="@+id/tab_search" android:id="@+id/tab_search"
android:layout_width="0dp" android:layout_width="0dp"
android:layout_height="match_parent" android:layout_height="match_parent"
android:layout_weight="1" android:layout_weight="1"
android:layout_marginEnd="8dp" android:layout_marginEnd="8dp"
android:background="@drawable/bg_tabbar_tab" android:orientation="vertical">
android:contentDescription="@string/search_hint">
<ImageView <FrameLayout
android:layout_width="24dp" android:layout_width="match_parent"
android:layout_height="24dp" android:layout_height="32dp"
android:layout_gravity="center" android:background="@drawable/bg_tabbar_tab"
android:scaleType="center" android:contentDescription="@string/search_hint">
android:importantForAccessibility="no"
android:tint="@color/tab_bar_icon"
android:src="@drawable/ic_fluent_search_24_selector"/>
</FrameLayout> <ImageView
android:layout_width="24dp"
android:layout_height="24dp"
android:layout_gravity="center"
android:scaleType="center"
android:importantForAccessibility="no"
android:tint="@color/tab_bar_icon"
android:src="@drawable/ic_fluent_search_24_selector"/>
<RelativeLayout </FrameLayout>
<TextView
android:id="@+id/tab_search_label"
style="@style/m3_label_medium"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textColor="@color/m3_on_surface_selector"
android:layout_gravity="center_horizontal"
android:layout_marginTop="4dp"
android:text="@string/sk_tab_search" />
</LinearLayout>
<LinearLayout
android:id="@+id/tab_notifications" android:id="@+id/tab_notifications"
android:layout_width="0dp" android:layout_width="0dp"
android:layout_height="match_parent" android:layout_height="match_parent"
android:layout_weight="1" android:layout_weight="1"
android:layout_marginEnd="8dp" android:layout_marginEnd="8dp"
android:background="@drawable/bg_tabbar_tab" android:orientation="vertical">
android:contentDescription="@string/notifications">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="32dp"
android:background="@drawable/bg_tabbar_tab"
android:contentDescription="@string/notifications">
<ImageView
android:id="@+id/notifications_icon"
android:layout_width="24dp"
android:layout_height="24dp"
android:layout_centerInParent="true"
android:scaleType="center"
android:importantForAccessibility="no"
android:tint="@color/tab_bar_icon"
android:src="@drawable/ic_fluent_alert_24_selector"/>
<TextView
android:id="@+id/notifications_badge"
android:layout_width="wrap_content"
android:layout_height="16dp"
android:layout_gravity="center"
android:layout_alignTop="@id/notifications_icon"
android:layout_toEndOf="@id/notifications_icon"
android:layout_marginTop="-4dp"
android:layout_marginStart="-12dp"
android:background="@drawable/bg_tabbar_badge"
android:textColor="?colorM3OnPrimary"
android:gravity="center"
android:includeFontPadding="false"
android:textAppearance="@style/m3_label_small"
android:minWidth="16dp"
tools:text="222"/>
</RelativeLayout>
<ImageView
android:id="@+id/notifications_icon"
android:layout_width="24dp"
android:layout_height="24dp"
android:layout_centerInParent="true"
android:scaleType="center"
android:importantForAccessibility="no"
android:tint="@color/tab_bar_icon"
android:src="@drawable/ic_fluent_alert_24_selector"/>
<TextView <TextView
android:id="@+id/notifications_badge" android:id="@+id/tab_notifications_label"
style="@style/m3_label_medium"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="16dp" android:layout_height="wrap_content"
android:layout_gravity="center" android:layout_gravity="center_horizontal"
android:layout_alignTop="@id/notifications_icon" android:layout_marginTop="4dp"
android:layout_toEndOf="@id/notifications_icon" android:textColor="@color/m3_on_surface_selector"
android:layout_marginTop="-4dp" android:text="@string/sk_tab_notifications" />
android:layout_marginStart="-12dp"
android:background="@drawable/bg_tabbar_badge"
android:textColor="?colorM3OnPrimary"
android:gravity="center"
android:includeFontPadding="false"
android:textAppearance="@style/m3_label_small"
android:minWidth="16dp"
tools:text="222"/>
</RelativeLayout> </LinearLayout>
<FrameLayout <LinearLayout
android:id="@+id/tab_profile" android:id="@+id/tab_profile"
android:layout_width="0dp" android:layout_width="0dp"
android:layout_height="match_parent" android:layout_height="match_parent"
android:layout_weight="1" android:layout_weight="1"
android:background="@drawable/bg_tabbar_tab" android:layout_marginEnd="8dp"
android:contentDescription="@string/my_profile"> android:orientation="vertical">
<ImageView
android:id="@+id/tab_profile_ava" <FrameLayout
android:layout_width="24dp" android:layout_width="match_parent"
android:layout_height="24dp" android:layout_height="32dp"
android:layout_gravity="center" android:background="@drawable/bg_tabbar_tab"
android:scaleType="centerCrop" android:contentDescription="@string/my_profile">
android:src="@null"/> <ImageView
<ImageView android:id="@+id/tab_profile_ava"
android:layout_width="8dp" android:layout_width="24dp"
android:layout_height="24dp" android:layout_height="24dp"
android:layout_gravity="center" android:layout_gravity="center"
android:layout_marginStart="22dp" android:scaleType="centerCrop"
android:importantForAccessibility="no" android:src="@null"/>
android:scaleType="center" <ImageView
android:tint="@color/tab_bar_icon" android:layout_width="8dp"
android:src="@drawable/ic_fluent_chevron_up_down_16_regular"/> android:layout_height="24dp"
</FrameLayout> android:layout_gravity="center"
android:layout_marginStart="22dp"
android:importantForAccessibility="no"
android:scaleType="center"
android:tint="@color/tab_bar_icon"
android:src="@drawable/ic_fluent_chevron_up_down_16_regular"/>
</FrameLayout>
<TextView
android:id="@+id/tab_profile_label"
style="@style/m3_label_medium"
android:layout_width="wrap_content"
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_profile" />
</LinearLayout>
</org.joinmastodon.android.ui.views.TabBar> </org.joinmastodon.android.ui.views.TabBar>
</FrameLayout> </FrameLayout>

View File

@ -339,4 +339,9 @@
<string name="sk_settings_display_pronouns_in_timelines">Display pronouns in timelines</string> <string name="sk_settings_display_pronouns_in_timelines">Display pronouns in timelines</string>
<string name="sk_settings_display_pronouns_in_threads">Display pronouns in threads</string> <string name="sk_settings_display_pronouns_in_threads">Display pronouns in threads</string>
<string name="sk_settings_display_pronouns_in_user_listings">Display pronouns in user listings</string> <string name="sk_settings_display_pronouns_in_user_listings">Display pronouns in user listings</string>
<string name="sk_tab_home">Home</string>
<string name="sk_tab_search">Search</string>
<string name="sk_tab_notifications">Notifications</string>
<string name="sk_tab_profile">Profile</string>
<string name="sk_settings_show_labels_in_navigation_bar">Show tab labels in the navigation bar</string>
</resources> </resources>