Bladeren bron

harmonize text sizes, make active tab easier to discover

Signed-off-by: Andy Scherzinger <info@andy-scherzinger.de>
Andy Scherzinger 4 jaren geleden
bovenliggende
commit
99e5694ece

+ 5 - 5
src/main/java/com/owncloud/android/ui/fragment/FileDetailFragment.java

@@ -26,7 +26,9 @@
 package com.owncloud.android.ui.fragment;
 
 import android.content.Context;
+import android.content.res.ColorStateList;
 import android.graphics.Bitmap;
+import android.graphics.Color;
 import android.os.Bundle;
 import android.view.LayoutInflater;
 import android.view.Menu;
@@ -227,12 +229,10 @@ public class FileDetailFragment extends FileFragment implements OnClickListener,
     private void setupViewPager() {
         binding.tabLayout.removeAllTabs();
 
-        binding.tabLayout.addTab(binding.tabLayout.newTab().setText(R.string.drawer_item_activities));
-        binding.tabLayout.addTab(binding.tabLayout.newTab().setText(R.string.share_dialog_title));
+        binding.tabLayout.addTab(binding.tabLayout.newTab().setText(R.string.drawer_item_activities).setIcon(R.drawable.ic_activity));
+        binding.tabLayout.addTab(binding.tabLayout.newTab().setText(R.string.share_dialog_title).setIcon(R.drawable.shared_via_users));
 
-        binding.tabLayout.setTabGravity(TabLayout.GRAVITY_FILL);
-        binding.tabLayout.setSelectedTabIndicatorColor(ThemeUtils.primaryColor(getContext()));
-        binding.tabLayout.setTabTextColors(getResources().getColor(R.color.text_color), ThemeUtils.primaryColor(getContext()));
+        ThemeUtils.colorTabLayout(getContext(), binding.tabLayout);
 
         final FileDetailTabAdapter adapter = new FileDetailTabAdapter(getFragmentManager(), getFile(), user);
         binding.pager.setAdapter(adapter);

+ 21 - 0
src/main/java/com/owncloud/android/utils/ThemeUtils.java

@@ -48,6 +48,7 @@ import android.widget.SeekBar;
 import com.google.android.material.button.MaterialButton;
 import com.google.android.material.floatingactionbutton.FloatingActionButton;
 import com.google.android.material.snackbar.Snackbar;
+import com.google.android.material.tabs.TabLayout;
 import com.google.android.material.textfield.TextInputEditText;
 import com.google.android.material.textfield.TextInputLayout;
 import com.nextcloud.client.account.User;
@@ -517,6 +518,26 @@ public final class ThemeUtils {
         colorStatusBar(fragmentActivity, primaryAppbarColor(fragmentActivity));
     }
 
+    public static void colorTabLayout(Context context, TabLayout tabLayout) {
+        int primaryColor = primaryColor(context);
+        int textColor = context.getResources().getColor(R.color.text_color);
+        tabLayout.setTabGravity(TabLayout.GRAVITY_FILL);
+        tabLayout.setSelectedTabIndicatorColor(primaryColor);
+        tabLayout.setTabTextColors(textColor, primaryColor);
+        tabLayout.setTabIconTint(new ColorStateList(
+            new int[][]{
+                new int[]{android.R.attr.state_selected},
+                new int[]{android.R.attr.state_enabled},
+                new int[]{-android.R.attr.state_enabled}
+            },
+            new int[]{
+                primaryColor,
+                textColor,
+                Color.GRAY
+            }
+        ));
+    }
+
     /**
      * Sets the color of the (containerized) text input TextInputLayout to {@code color} for hint text, box stroke and
      * highlight color.

+ 2 - 1
src/main/res/layout/file_details_fragment.xml

@@ -179,7 +179,8 @@
         app:tabGravity="center"
         app:tabMode="fixed"
         app:tabTextAppearance="@style/AppTabTextAppearance"
-        app:tabTextColor="@color/text_color" />
+        app:tabTextColor="@color/text_color"
+        app:tabInlineLabel="true" />
 
     <androidx.viewpager.widget.ViewPager
         android:id="@+id/pager"