updating the main screens ui

This commit is contained in:
tibbi 2022-12-31 11:49:55 +01:00
parent f232f577e4
commit 0d2486a7eb
8 changed files with 42 additions and 22 deletions

View File

@ -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'

View File

@ -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() {

View File

@ -557,4 +557,6 @@ class ItemsFragment(context: Context, attributeSet: AttributeSet) : MyViewPagerF
override fun selectedPaths(paths: ArrayList<String>) {
(activity as MainActivity).pickedPaths(paths)
}
override fun getScrollingView() = items_list
}

View File

@ -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?
}

View File

@ -230,4 +230,6 @@ class RecentsFragment(context: Context, attributeSet: AttributeSet) : MyViewPage
override fun finishActMode() {
getRecyclerAdapter()?.finishActMode()
}
override fun getScrollingView() = recents_list
}

View File

@ -221,4 +221,6 @@ class StorageFragment(context: Context, attributeSet: AttributeSet) : MyViewPage
}
}
}
override fun getScrollingView() = storage_nested_scrollview
}

View File

@ -5,27 +5,21 @@
android:layout_width="match_parent"
android:layout_height="match_parent">
<com.google.android.material.appbar.AppBarLayout
android:id="@+id/main_app_bar_layout"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<com.google.android.material.appbar.MaterialToolbar
android:id="@+id/main_toolbar"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
android:background="@color/color_primary"
app:menu="@menu/menu"
app:title="@string/app_launcher_name"
app:titleTextAppearance="@style/AppTheme.ActionBar.TitleTextStyle" />
</com.google.android.material.appbar.AppBarLayout>
<RelativeLayout
android:id="@+id/main_screen"
android:id="@+id/main_holder"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:layout_behavior="@string/appbar_scrolling_view_behavior">
android:layout_marginTop="?attr/actionBarSize"
android:fillViewport="true"
android:scrollbars="none">
<com.simplemobiletools.commons.views.MyViewPager
android:id="@+id/main_view_pager"

View File

@ -6,8 +6,8 @@
android:layout_width="match_parent"
android:layout_height="match_parent">
<ScrollView
android:id="@+id/storage_scrollview"
<androidx.core.widget.NestedScrollView
android:id="@+id/storage_nested_scrollview"
android:layout_width="wrap_content"
android:layout_height="wrap_content">
@ -301,5 +301,5 @@
app:trackThickness="2dp" />
</RelativeLayout>
</RelativeLayout>
</ScrollView>
</androidx.core.widget.NestedScrollView>
</com.simplemobiletools.filemanager.pro.fragments.StorageFragment>