improved user fragment ui

This commit is contained in:
Mariotaku Lee 2017-10-29 00:13:36 +08:00
parent 763452e335
commit 97a8df5f99
No known key found for this signature in database
GPG Key ID: 15C10F89D7C33535
2 changed files with 14 additions and 10 deletions

View File

@ -164,8 +164,6 @@ class UserFragment : BaseFragment(), OnClickListener, OnLinkClickListener,
private var uiColor: Int = 0
private var primaryColor: Int = 0
private var nameFirst: Boolean = false
private var previousTabItemIsDark: Int = 0
private var previousActionBarItemIsDark: Int = 0
private var hideBirthdayView: Boolean = false
private val friendshipLoaderCallbacks = object : LoaderCallbacks<SingleResponse<ParcelableRelationship>> {
@ -1250,9 +1248,6 @@ class UserFragment : BaseFragment(), OnClickListener, OnLinkClickListener,
private fun setUiColor(color: Int) {
val theme = Chameleon.getOverrideTheme(activity, activity)
uiColor = if (color != 0) color else theme.colorPrimary
previousActionBarItemIsDark = 0
previousTabItemIsDark = 0
setupViewStyle()
val activity = activity as BaseActivity
primaryColor = if (theme.isToolbarColored) {
color
@ -1291,11 +1286,9 @@ class UserFragment : BaseFragment(), OnClickListener, OnLinkClickListener,
val actionBarElevation = ThemeUtils.getSupportActionBarElevation(activity)
ViewCompat.setElevation(toolbar, actionBarElevation)
// ViewCompat.setElevation(profileHeader, actionBarElevation)
ViewCompat.setElevation(statusBarBackground, actionBarElevation * 2)
ViewSupport.setOutlineProvider(toolbar, ViewOutlineProviderCompat.BACKGROUND)
// ViewSupport.setOutlineProvider(profileHeader, ViewOutlineProviderCompat.BOUNDS)
ViewSupport.setOutlineProvider(statusBarBackground, null)
}

View File

@ -41,9 +41,20 @@ internal class ToolbarBehavior(context: Context?, attrs: AttributeSet? = null) :
return dependency.id == R.id.profileHeader
}
@SuppressLint("RestrictedApi")
override fun onLayoutChild(parent: CoordinatorLayout, child: Toolbar, layoutDirection: Int): Boolean {
val ret = super.onLayoutChild(parent, child, layoutDirection)
updateToolbarFactor(parent, child, parent.getDependencies(child).first())
return ret
}
override fun onDependentViewChanged(parent: CoordinatorLayout, child: Toolbar, dependency: View): Boolean {
val actionBarBackground = child.background as? ActionBarDrawable ?: return false
if (updateToolbarFactor(parent, child, dependency)) return false
return true
}
@SuppressLint("RestrictedApi")
private fun updateToolbarFactor(parent: CoordinatorLayout, child: Toolbar, dependency: View): Boolean {
val actionBarBackground = child.background as? ActionBarDrawable ?: return true
val bannerContainer = parent.profileBannerContainer
val detailsBackground = parent.profileHeaderBackground
val bannerBottom = dependency.top + bannerContainer.bottom
@ -69,7 +80,7 @@ internal class ToolbarBehavior(context: Context?, attrs: AttributeSet? = null) :
ThemeUtils.applyToolbarItemColor(parent.context, child, currentActionBarColor)
}
this.actionItemIsDark = actionItemIsDark
return true
return false
}
}