From 0d2486a7eb2322c3fb7192e8ccca11332cd10ce9 Mon Sep 17 00:00:00 2001 From: tibbi Date: Sat, 31 Dec 2022 11:49:55 +0100 Subject: [PATCH] updating the main screens ui --- app/build.gradle | 2 +- .../pro/activities/MainActivity.kt | 21 +++++++++++++-- .../pro/fragments/ItemsFragment.kt | 2 ++ .../pro/fragments/MyViewPagerFragment.kt | 3 +++ .../pro/fragments/RecentsFragment.kt | 2 ++ .../pro/fragments/StorageFragment.kt | 2 ++ app/src/main/res/layout/activity_main.xml | 26 +++++++------------ app/src/main/res/layout/storage_fragment.xml | 6 ++--- 8 files changed, 42 insertions(+), 22 deletions(-) diff --git a/app/build.gradle b/app/build.gradle index e1a72bde..0ba1b247 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -64,7 +64,7 @@ android { } dependencies { - implementation 'com.github.SimpleMobileTools:Simple-Commons:7e489f7121' + implementation 'com.github.SimpleMobileTools:Simple-Commons:7408174438' implementation 'com.github.tibbi:PdfViewPager:d2af24208d' implementation 'com.github.Stericson:RootTools:df729dcb13' implementation 'com.github.Stericson:RootShell:1.6' diff --git a/app/src/main/kotlin/com/simplemobiletools/filemanager/pro/activities/MainActivity.kt b/app/src/main/kotlin/com/simplemobiletools/filemanager/pro/activities/MainActivity.kt index 57be24b4..2fa6f091 100644 --- a/app/src/main/kotlin/com/simplemobiletools/filemanager/pro/activities/MainActivity.kt +++ b/app/src/main/kotlin/com/simplemobiletools/filemanager/pro/activities/MainActivity.kt @@ -67,11 +67,13 @@ class MainActivity : SimpleActivity() { private var mStoredShowTabs = 0 override fun onCreate(savedInstanceState: Bundle?) { + isMaterialActivity = true super.onCreate(savedInstanceState) setContentView(R.layout.activity_main) appLaunched(BuildConfig.APPLICATION_ID) setupOptionsMenu() refreshMenuItems() + updateMaterialActivityViews(main_coordinator, main_holder, false) mTabsToShow = getTabsList() if (!config.wasStorageAnalysisTabAdded && isOreoPlus()) { @@ -110,9 +112,15 @@ class MainActivity : SimpleActivity() { return } - setupTabColors() - setupToolbar(main_toolbar, searchMenuItem = mSearchMenuItem) + val statusBarColor = if (getCurrentFragment()?.getScrollingView() == null) { + getProperBackgroundColor() + } else { + window.statusBarColor + } + + setupToolbar(main_toolbar, statusBarColor = statusBarColor, searchMenuItem = mSearchMenuItem) refreshMenuItems() + setupTabColors() getAllFragments().forEach { it?.onResume(getProperTextColor()) @@ -416,6 +424,7 @@ class MainActivity : SimpleActivity() { (it as? ItemOperationsListener)?.finishActMode() } refreshMenuItems() + updateStatusBarChanger() } }) main_view_pager.currentItem = config.lastUsedViewPagerPage @@ -466,6 +475,14 @@ class MainActivity : SimpleActivity() { ) main_tabs_holder.beGoneIf(main_tabs_holder.tabCount == 1) + main_tabs_holder.onGlobalLayout { + updateStatusBarChanger() + } + } + + private fun updateStatusBarChanger() { + setupMaterialScrollListener(getCurrentFragment()?.getScrollingView(), main_toolbar) + updateStatusBarOnPageChange() } private fun setupTabColors() { diff --git a/app/src/main/kotlin/com/simplemobiletools/filemanager/pro/fragments/ItemsFragment.kt b/app/src/main/kotlin/com/simplemobiletools/filemanager/pro/fragments/ItemsFragment.kt index 1da7e61d..2e28cbe7 100644 --- a/app/src/main/kotlin/com/simplemobiletools/filemanager/pro/fragments/ItemsFragment.kt +++ b/app/src/main/kotlin/com/simplemobiletools/filemanager/pro/fragments/ItemsFragment.kt @@ -557,4 +557,6 @@ class ItemsFragment(context: Context, attributeSet: AttributeSet) : MyViewPagerF override fun selectedPaths(paths: ArrayList) { (activity as MainActivity).pickedPaths(paths) } + + override fun getScrollingView() = items_list } diff --git a/app/src/main/kotlin/com/simplemobiletools/filemanager/pro/fragments/MyViewPagerFragment.kt b/app/src/main/kotlin/com/simplemobiletools/filemanager/pro/fragments/MyViewPagerFragment.kt index 70095ab0..9b816250 100644 --- a/app/src/main/kotlin/com/simplemobiletools/filemanager/pro/fragments/MyViewPagerFragment.kt +++ b/app/src/main/kotlin/com/simplemobiletools/filemanager/pro/fragments/MyViewPagerFragment.kt @@ -3,6 +3,7 @@ package com.simplemobiletools.filemanager.pro.fragments import android.content.Context import android.util.AttributeSet import android.widget.RelativeLayout +import androidx.core.view.ScrollingView import com.simplemobiletools.commons.extensions.* import com.simplemobiletools.commons.helpers.VIEW_TYPE_LIST import com.simplemobiletools.filemanager.pro.R @@ -66,4 +67,6 @@ abstract class MyViewPagerFragment(context: Context, attributeSet: AttributeSet) abstract fun onResume(textColor: Int) abstract fun refreshFragment() + + abstract fun getScrollingView(): ScrollingView? } diff --git a/app/src/main/kotlin/com/simplemobiletools/filemanager/pro/fragments/RecentsFragment.kt b/app/src/main/kotlin/com/simplemobiletools/filemanager/pro/fragments/RecentsFragment.kt index 5f6ab818..ed3395d2 100644 --- a/app/src/main/kotlin/com/simplemobiletools/filemanager/pro/fragments/RecentsFragment.kt +++ b/app/src/main/kotlin/com/simplemobiletools/filemanager/pro/fragments/RecentsFragment.kt @@ -230,4 +230,6 @@ class RecentsFragment(context: Context, attributeSet: AttributeSet) : MyViewPage override fun finishActMode() { getRecyclerAdapter()?.finishActMode() } + + override fun getScrollingView() = recents_list } diff --git a/app/src/main/kotlin/com/simplemobiletools/filemanager/pro/fragments/StorageFragment.kt b/app/src/main/kotlin/com/simplemobiletools/filemanager/pro/fragments/StorageFragment.kt index eb835a57..ad45350e 100644 --- a/app/src/main/kotlin/com/simplemobiletools/filemanager/pro/fragments/StorageFragment.kt +++ b/app/src/main/kotlin/com/simplemobiletools/filemanager/pro/fragments/StorageFragment.kt @@ -221,4 +221,6 @@ class StorageFragment(context: Context, attributeSet: AttributeSet) : MyViewPage } } } + + override fun getScrollingView() = storage_nested_scrollview } diff --git a/app/src/main/res/layout/activity_main.xml b/app/src/main/res/layout/activity_main.xml index f4b679ad..00508d81 100644 --- a/app/src/main/res/layout/activity_main.xml +++ b/app/src/main/res/layout/activity_main.xml @@ -5,27 +5,21 @@ android:layout_width="match_parent" android:layout_height="match_parent"> - - - - - + android:layout_height="?attr/actionBarSize" + android:background="@color/color_primary" + app:menu="@menu/menu" + app:titleTextAppearance="@style/AppTheme.ActionBar.TitleTextStyle" /> + android:layout_marginTop="?attr/actionBarSize" + android:fillViewport="true" + android:scrollbars="none"> - @@ -301,5 +301,5 @@ app:trackThickness="2dp" /> - +