diff --git a/app/src/main/java/gr/thmmy/mthmmy/activities/main/MainActivity.java b/app/src/main/java/gr/thmmy/mthmmy/activities/main/MainActivity.java index 58a3b8db..bd5abffb 100644 --- a/app/src/main/java/gr/thmmy/mthmmy/activities/main/MainActivity.java +++ b/app/src/main/java/gr/thmmy/mthmmy/activities/main/MainActivity.java @@ -55,6 +55,7 @@ public class MainActivity extends BaseActivity implements RecentFragment.RecentF private SectionsPagerAdapter sectionsPagerAdapter; private ViewPager viewPager; private TabLayout tabLayout; + private boolean displayCompactTabs; //Fix for vector drawables on android <21 static { @@ -82,9 +83,13 @@ public class MainActivity extends BaseActivity implements RecentFragment.RecentF return; //Avoid executing the code below } - toolbar = findViewById(R.id.toolbar); - toolbar.setTitle(""); - setSupportActionBar(toolbar); + displayCompactTabs = BaseApplication.getInstance().isDisplayCompactTabsEnabled(); + + if(displayCompactTabs) { + toolbar = findViewById(R.id.toolbar); + toolbar.setTitle(""); + setSupportActionBar(toolbar); + } //Initialize drawer createDrawer(); @@ -108,8 +113,8 @@ public class MainActivity extends BaseActivity implements RecentFragment.RecentF if ((preferredTab != 3 && preferredTab != 4) || sessionManager.isLoggedIn()) tabLayout.getTabAt(preferredTab).select(); - for (int i = 0; i < tabLayout.getTabCount(); i++) - updateTabIcon(i); + if(!displayCompactTabs) + updateTabIcons(); setMainActivity(this); } @@ -189,7 +194,8 @@ public class MainActivity extends BaseActivity implements RecentFragment.RecentF fragmentList.add(fragment); fragmentTitleList.add(title); notifyDataSetChanged(); - updateTabIcon(fragmentList.size() - 1); + if(!displayCompactTabs) + updateTabIcon(fragmentList.size() - 1); } void removeFragment(int position) { @@ -234,6 +240,10 @@ public class MainActivity extends BaseActivity implements RecentFragment.RecentF tabLayout.getTabAt(2).setIcon(getResources().getDrawable(R.drawable.ic_fiber_new_white_24dp)); } + private void updateTabIcons (){ + for (int i = 0; i < tabLayout.getTabCount(); i++) + updateTabIcon(i); + } public void updateTabs() { if (!sessionManager.isLoggedIn() && sectionsPagerAdapter.getCount() == 3) @@ -241,8 +251,8 @@ public class MainActivity extends BaseActivity implements RecentFragment.RecentF else if (sessionManager.isLoggedIn() && sectionsPagerAdapter.getCount() == 2) sectionsPagerAdapter.addFragment(UnreadFragment.newInstance(3), "UNREAD"); - for (int i = 0; i < tabLayout.getTabCount(); i++) - updateTabIcon(i); + if(!displayCompactTabs) + updateTabIcons(); } //-------------------------------FragmentPagerAdapter END------------------------------------------- diff --git a/app/src/main/java/gr/thmmy/mthmmy/activities/settings/SettingsActivity.java b/app/src/main/java/gr/thmmy/mthmmy/activities/settings/SettingsActivity.java index e9cc61f6..40fab7a7 100644 --- a/app/src/main/java/gr/thmmy/mthmmy/activities/settings/SettingsActivity.java +++ b/app/src/main/java/gr/thmmy/mthmmy/activities/settings/SettingsActivity.java @@ -9,6 +9,7 @@ import gr.thmmy.mthmmy.base.BaseActivity; public class SettingsActivity extends BaseActivity { public static final String DEFAULT_HOME_TAB = "pref_app_main_default_tab_key"; + public static final String DISPLAY_COMPACT_TABS = "pref_app_display_compact_tabs_key"; public static final String DISPLAY_RELATIVE_TIME = "pref_app_display_relative_time_key"; public static final String NOTIFICATION_LED_KEY = "pref_notification_led_enable_key"; public static final String NOTIFICATION_VIBRATION_KEY = "pref_notification_vibration_enable_key"; diff --git a/app/src/main/java/gr/thmmy/mthmmy/activities/settings/SettingsFragment.java b/app/src/main/java/gr/thmmy/mthmmy/activities/settings/SettingsFragment.java index 983c542a..a639c199 100644 --- a/app/src/main/java/gr/thmmy/mthmmy/activities/settings/SettingsFragment.java +++ b/app/src/main/java/gr/thmmy/mthmmy/activities/settings/SettingsFragment.java @@ -224,6 +224,10 @@ public class SettingsFragment extends PreferenceFragmentCompat implements Shared && BaseApplication.getInstance().isDisplayRelativeTimeEnabled() != sharedPreferences.getBoolean(key, false)) { displayRestartAppToTakeEffectToast(); } + else if (key.equals(getString(R.string.pref_app_display_compact_tabs_key)) + && BaseApplication.getInstance().isDisplayCompactTabsEnabled() != sharedPreferences.getBoolean(key, false)) { + displayRestartAppToTakeEffectToast(); + } } private void displayRestartAppToTakeEffectToast() { diff --git a/app/src/main/java/gr/thmmy/mthmmy/base/BaseApplication.java b/app/src/main/java/gr/thmmy/mthmmy/base/BaseApplication.java index 61c32078..71ebc4ae 100644 --- a/app/src/main/java/gr/thmmy/mthmmy/base/BaseApplication.java +++ b/app/src/main/java/gr/thmmy/mthmmy/base/BaseApplication.java @@ -47,6 +47,7 @@ import okhttp3.Request; import timber.log.Timber; import static gr.thmmy.mthmmy.activities.settings.SettingsActivity.DISPLAY_RELATIVE_TIME; +import static gr.thmmy.mthmmy.activities.settings.SettingsActivity.DISPLAY_COMPACT_TABS; // TODO: Replace MultiDexApplication with Application after KitKat support is dropped public class BaseApplication extends MultiDexApplication { @@ -63,6 +64,7 @@ public class BaseApplication extends MultiDexApplication { private SessionManager sessionManager; private boolean displayRelativeTime; + private boolean displayCompactTabs; //Display Metrics private static float widthDp; @@ -105,6 +107,7 @@ public class BaseApplication extends MultiDexApplication { setDisplayMetrics(); displayRelativeTime = settingsSharedPrefs.getBoolean(DISPLAY_RELATIVE_TIME, true); + displayCompactTabs = settingsSharedPrefs.getBoolean(DISPLAY_COMPACT_TABS, true); } private void initFirebase(SharedPreferences settingsSharedPrefs) { @@ -233,6 +236,10 @@ public class BaseApplication extends MultiDexApplication { return displayRelativeTime; } + public boolean isDisplayCompactTabsEnabled() { + return displayCompactTabs; + } + //-------------------- Firebase -------------------- public void logFirebaseAnalyticsEvent(String event, Bundle params) { diff --git a/app/src/main/res/layout/activity_main.xml b/app/src/main/res/layout/activity_main.xml index 79069193..1fd17ba9 100644 --- a/app/src/main/res/layout/activity_main.xml +++ b/app/src/main/res/layout/activity_main.xml @@ -33,6 +33,7 @@ android:layout_height="wrap_content" android:layout_width="0dp" android:layout_weight="1.0" + android:paddingBottom="2dp" app:tabMaxWidth="0dp" app:tabGravity="fill" app:tabMode="fixed" diff --git a/app/src/main/res/layout/fragment_forum.xml b/app/src/main/res/layout/fragment_forum.xml index 8b65bca9..29e311be 100644 --- a/app/src/main/res/layout/fragment_forum.xml +++ b/app/src/main/res/layout/fragment_forum.xml @@ -17,7 +17,6 @@ android:layout_height="match_parent" android:background="@color/background" android:paddingBottom="4dp" - android:paddingTop="4dp" app:layoutManager="LinearLayoutManager" tools:context=".activities.main.forum.ForumFragment" /> @@ -26,11 +25,12 @@ android:id="@+id/progressBar" style="@style/Widget.MaterialProgressBar.ProgressBar.Horizontal.NoPadding" android:layout_width="match_parent" - android:layout_height="@dimen/progress_bar_height" + android:layout_height="@dimen/progress_bar_unpadded_height" android:layout_alignParentTop="true" android:indeterminate="true" android:visibility="invisible" app:mpb_indeterminateTint="@color/accent" + app:mpb_useIntrinsicPadding = "false" app:mpb_progressStyle="horizontal" /> \ No newline at end of file diff --git a/app/src/main/res/layout/fragment_recent.xml b/app/src/main/res/layout/fragment_recent.xml index 421b6fd9..790d8b87 100644 --- a/app/src/main/res/layout/fragment_recent.xml +++ b/app/src/main/res/layout/fragment_recent.xml @@ -17,7 +17,6 @@ android:layout_height="match_parent" android:background="@color/background" android:paddingBottom="4dp" - android:paddingTop="4dp" app:layoutManager="LinearLayoutManager" tools:context=".activities.main.recent.RecentFragment" tools:listitem="@layout/fragment_recent_row" /> @@ -27,10 +26,11 @@ android:id="@+id/progressBar" style="@style/Widget.MaterialProgressBar.ProgressBar.Horizontal.NoPadding" android:layout_width="match_parent" - android:layout_height="@dimen/progress_bar_height" + android:layout_height="@dimen/progress_bar_unpadded_height" android:layout_alignParentTop="true" android:indeterminate="true" android:visibility="invisible" app:mpb_indeterminateTint="@color/accent" + app:mpb_useIntrinsicPadding = "false" app:mpb_progressStyle="horizontal" /> \ No newline at end of file diff --git a/app/src/main/res/layout/fragment_unread.xml b/app/src/main/res/layout/fragment_unread.xml index 7e7238ca..44780490 100644 --- a/app/src/main/res/layout/fragment_unread.xml +++ b/app/src/main/res/layout/fragment_unread.xml @@ -23,7 +23,6 @@ android:layout_width="match_parent" android:layout_height="match_parent" android:background="@color/background" - android:paddingTop="4dp" android:paddingBottom="4dp" app:layoutManager="LinearLayoutManager" tools:context=".activities.main.unread.UnreadFragment" @@ -47,11 +46,12 @@ android:id="@+id/progressBar" style="@style/Widget.MaterialProgressBar.ProgressBar.Horizontal.NoPadding" android:layout_width="match_parent" - android:layout_height="@dimen/progress_bar_height" + android:layout_height="@dimen/progress_bar_unpadded_height" android:layout_alignParentTop="true" android:indeterminate="true" android:visibility="invisible" app:mpb_indeterminateTint="@color/accent" + app:mpb_useIntrinsicPadding = "false" app:mpb_progressStyle="horizontal" /> 36dp 16dp 10dp + 3dp 16sp 24sp 24dp diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 43af28b3..f203b8cf 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -175,6 +175,9 @@ pref_app_display_relative_time_key Display relative time Considering that you haven\'t set some weird custom time format + pref_app_display_compact_tabs_key + Display compact tabs + Home screen tabs will occupy less space Notifications pref_notification_vibration_enable_key diff --git a/app/src/main/res/xml-v26/app_preferences_guest.xml b/app/src/main/res/xml-v26/app_preferences_guest.xml index 1e04ec41..f366c6e0 100644 --- a/app/src/main/res/xml-v26/app_preferences_guest.xml +++ b/app/src/main/res/xml-v26/app_preferences_guest.xml @@ -20,6 +20,12 @@ android:title="@string/pref_title_display_relative_time" android:summary="@string/pref_summary_display_relative_time" app:iconSpaceReserved="false" /> + + + +