mirror of
https://github.com/SimpleMobileTools/Simple-Dialer.git
synced 2025-06-05 21:49:23 +02:00
add handling for status bar color changing
This commit is contained in:
@@ -62,7 +62,7 @@ android {
|
|||||||
}
|
}
|
||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
implementation 'com.github.SimpleMobileTools:Simple-Commons:4da0ee0cf4'
|
implementation 'com.github.SimpleMobileTools:Simple-Commons:d82297ad77'
|
||||||
implementation 'com.github.tibbi:IndicatorFastScroll:4524cd0b61'
|
implementation 'com.github.tibbi:IndicatorFastScroll:4524cd0b61'
|
||||||
implementation 'me.grantland:autofittextview:0.2.1'
|
implementation 'me.grantland:autofittextview:0.2.1'
|
||||||
}
|
}
|
||||||
|
@@ -53,11 +53,13 @@ class MainActivity : SimpleActivity() {
|
|||||||
var cachedContacts = ArrayList<SimpleContact>()
|
var cachedContacts = ArrayList<SimpleContact>()
|
||||||
|
|
||||||
override fun onCreate(savedInstanceState: Bundle?) {
|
override fun onCreate(savedInstanceState: Bundle?) {
|
||||||
|
isMaterialActivity = true
|
||||||
super.onCreate(savedInstanceState)
|
super.onCreate(savedInstanceState)
|
||||||
setContentView(R.layout.activity_main)
|
setContentView(R.layout.activity_main)
|
||||||
appLaunched(BuildConfig.APPLICATION_ID)
|
appLaunched(BuildConfig.APPLICATION_ID)
|
||||||
setupOptionsMenu()
|
setupOptionsMenu()
|
||||||
refreshMenuItems()
|
refreshMenuItems()
|
||||||
|
updateMaterialActivityViews(main_coordinator, main_holder, false)
|
||||||
|
|
||||||
launchedDialer = savedInstanceState?.getBoolean(OPEN_DIAL_PAD_AT_LAUNCH) ?: false
|
launchedDialer = savedInstanceState?.getBoolean(OPEN_DIAL_PAD_AT_LAUNCH) ?: false
|
||||||
|
|
||||||
@@ -95,13 +97,19 @@ class MainActivity : SimpleActivity() {
|
|||||||
|
|
||||||
override fun onResume() {
|
override fun onResume() {
|
||||||
super.onResume()
|
super.onResume()
|
||||||
|
val statusBarColor = if (getCurrentFragment()?.getScrollingView() == null) {
|
||||||
|
getProperBackgroundColor()
|
||||||
|
} else {
|
||||||
|
window.statusBarColor
|
||||||
|
}
|
||||||
|
|
||||||
val properPrimaryColor = getProperPrimaryColor()
|
val properPrimaryColor = getProperPrimaryColor()
|
||||||
val dialpadIcon = resources.getColoredDrawableWithColor(R.drawable.ic_dialpad_vector, properPrimaryColor.getContrastColor())
|
val dialpadIcon = resources.getColoredDrawableWithColor(R.drawable.ic_dialpad_vector, properPrimaryColor.getContrastColor())
|
||||||
main_dialpad_button.setImageDrawable(dialpadIcon)
|
main_dialpad_button.setImageDrawable(dialpadIcon)
|
||||||
|
|
||||||
setupTabColors()
|
setupToolbar(main_toolbar, statusBarColor = statusBarColor, searchMenuItem = mSearchMenuItem)
|
||||||
setupToolbar(main_toolbar, searchMenuItem = mSearchMenuItem)
|
|
||||||
updateTextColors(main_holder)
|
updateTextColors(main_holder)
|
||||||
|
setupTabColors()
|
||||||
|
|
||||||
getAllFragments().forEach {
|
getAllFragments().forEach {
|
||||||
it?.setupColors(getProperTextColor(), getProperPrimaryColor(), getProperPrimaryColor())
|
it?.setupColors(getProperTextColor(), getProperPrimaryColor(), getProperPrimaryColor())
|
||||||
@@ -268,6 +276,11 @@ class MainActivity : SimpleActivity() {
|
|||||||
.build()
|
.build()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private fun updateStatusBarChanger() {
|
||||||
|
setupMaterialScrollListener(getCurrentFragment()?.getScrollingView(), main_toolbar)
|
||||||
|
updateStatusBarOnPageChange()
|
||||||
|
}
|
||||||
|
|
||||||
private fun setupTabColors() {
|
private fun setupTabColors() {
|
||||||
val activeView = main_tabs_holder.getTabAt(view_pager.currentItem)?.customView
|
val activeView = main_tabs_holder.getTabAt(view_pager.currentItem)?.customView
|
||||||
updateBottomTabItemColors(activeView, true)
|
updateBottomTabItemColors(activeView, true)
|
||||||
@@ -297,6 +310,7 @@ class MainActivity : SimpleActivity() {
|
|||||||
it?.finishActMode()
|
it?.finishActMode()
|
||||||
}
|
}
|
||||||
refreshMenuItems()
|
refreshMenuItems()
|
||||||
|
updateStatusBarChanger()
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
@@ -359,6 +373,9 @@ class MainActivity : SimpleActivity() {
|
|||||||
)
|
)
|
||||||
|
|
||||||
main_tabs_holder.beGoneIf(main_tabs_holder.tabCount == 1)
|
main_tabs_holder.beGoneIf(main_tabs_holder.tabCount == 1)
|
||||||
|
main_tabs_holder.onGlobalLayout {
|
||||||
|
updateStatusBarChanger()
|
||||||
|
}
|
||||||
storedShowTabs = config.showTabs
|
storedShowTabs = config.showTabs
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -157,4 +157,6 @@ class ContactsFragment(context: Context, attributeSet: AttributeSet) : MyViewPag
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
override fun getScrollingView() = fragment_list
|
||||||
}
|
}
|
||||||
|
@@ -190,4 +190,6 @@ class FavoritesFragment(context: Context, attributeSet: AttributeSet) : MyViewPa
|
|||||||
(fragment_list.adapter as? ContactsAdapter)?.updateItems(contacts, text)
|
(fragment_list.adapter as? ContactsAdapter)?.updateItems(contacts, text)
|
||||||
setupLetterFastscroller(contacts)
|
setupLetterFastscroller(contacts)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
override fun getScrollingView() = fragment_list
|
||||||
}
|
}
|
||||||
|
@@ -3,6 +3,7 @@ package com.simplemobiletools.dialer.fragments
|
|||||||
import android.content.Context
|
import android.content.Context
|
||||||
import android.util.AttributeSet
|
import android.util.AttributeSet
|
||||||
import android.widget.RelativeLayout
|
import android.widget.RelativeLayout
|
||||||
|
import androidx.core.view.ScrollingView
|
||||||
import com.simplemobiletools.commons.adapters.MyRecyclerViewAdapter
|
import com.simplemobiletools.commons.adapters.MyRecyclerViewAdapter
|
||||||
import com.simplemobiletools.commons.extensions.getProperPrimaryColor
|
import com.simplemobiletools.commons.extensions.getProperPrimaryColor
|
||||||
import com.simplemobiletools.commons.extensions.getProperTextColor
|
import com.simplemobiletools.commons.extensions.getProperTextColor
|
||||||
@@ -39,4 +40,6 @@ abstract class MyViewPagerFragment(context: Context, attributeSet: AttributeSet)
|
|||||||
abstract fun onSearchClosed()
|
abstract fun onSearchClosed()
|
||||||
|
|
||||||
abstract fun onSearchQueryChanged(text: String)
|
abstract fun onSearchQueryChanged(text: String)
|
||||||
|
|
||||||
|
abstract fun getScrollingView(): ScrollingView?
|
||||||
}
|
}
|
||||||
|
@@ -143,4 +143,6 @@ class RecentsFragment(context: Context, attributeSet: AttributeSet) : MyViewPage
|
|||||||
recents_placeholder.beVisibleIf(recentCalls.isEmpty())
|
recents_placeholder.beVisibleIf(recentCalls.isEmpty())
|
||||||
(recents_list.adapter as? RecentCallsAdapter)?.updateItems(recentCalls, text)
|
(recents_list.adapter as? RecentCallsAdapter)?.updateItems(recentCalls, text)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
override fun getScrollingView() = recents_list
|
||||||
}
|
}
|
||||||
|
@@ -5,27 +5,21 @@
|
|||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="match_parent">
|
android:layout_height="match_parent">
|
||||||
|
|
||||||
<com.google.android.material.appbar.AppBarLayout
|
<com.google.android.material.appbar.MaterialToolbar
|
||||||
android:id="@+id/main_app_bar_layout"
|
android:id="@+id/main_toolbar"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content">
|
android:layout_height="?attr/actionBarSize"
|
||||||
|
android:background="@color/color_primary"
|
||||||
<com.google.android.material.appbar.MaterialToolbar
|
app:menu="@menu/menu"
|
||||||
android:id="@+id/main_toolbar"
|
app:titleTextAppearance="@style/AppTheme.ActionBar.TitleTextStyle" />
|
||||||
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>
|
|
||||||
|
|
||||||
<androidx.constraintlayout.widget.ConstraintLayout
|
<androidx.constraintlayout.widget.ConstraintLayout
|
||||||
android:id="@+id/main_holder"
|
android:id="@+id/main_holder"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="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
|
<com.simplemobiletools.commons.views.MyViewPager
|
||||||
android:id="@+id/view_pager"
|
android:id="@+id/view_pager"
|
||||||
|
Reference in New Issue
Block a user