|
|
|
@ -18,6 +18,7 @@ package com.keylesspalace.tusky |
|
|
|
|
import android.animation.ArgbEvaluator |
|
|
|
|
import android.content.Context |
|
|
|
|
import android.content.Intent |
|
|
|
|
import android.content.res.ColorStateList |
|
|
|
|
import android.graphics.Color |
|
|
|
|
import android.graphics.PorterDuff |
|
|
|
|
import android.os.Bundle |
|
|
|
@ -40,6 +41,8 @@ import com.bumptech.glide.Glide |
|
|
|
|
import com.google.android.material.appbar.AppBarLayout |
|
|
|
|
import com.google.android.material.appbar.CollapsingToolbarLayout |
|
|
|
|
import com.google.android.material.floatingactionbutton.FloatingActionButton |
|
|
|
|
import com.google.android.material.shape.MaterialShapeDrawable |
|
|
|
|
import com.google.android.material.shape.ShapeAppearanceModel |
|
|
|
|
import com.google.android.material.snackbar.Snackbar |
|
|
|
|
import com.google.android.material.tabs.TabLayout |
|
|
|
|
import com.keylesspalace.tusky.adapter.AccountFieldAdapter |
|
|
|
@ -86,8 +89,6 @@ class AccountActivity : BottomSheetActivity(), ActionButtonActivity, HasAndroidI |
|
|
|
|
@ColorInt |
|
|
|
|
private var toolbarColor: Int = 0 |
|
|
|
|
@ColorInt |
|
|
|
|
private var backgroundColor: Int = 0 |
|
|
|
|
@ColorInt |
|
|
|
|
private var statusBarColorTransparent: Int = 0 |
|
|
|
|
@ColorInt |
|
|
|
|
private var statusBarColorOpaque: Int = 0 |
|
|
|
@ -107,6 +108,7 @@ class AccountActivity : BottomSheetActivity(), ActionButtonActivity, HasAndroidI |
|
|
|
|
|
|
|
|
|
override fun onCreate(savedInstanceState: Bundle?) { |
|
|
|
|
super.onCreate(savedInstanceState) |
|
|
|
|
loadResources() |
|
|
|
|
makeNotificationBarTransparent() |
|
|
|
|
setContentView(R.layout.activity_account) |
|
|
|
|
|
|
|
|
@ -119,7 +121,6 @@ class AccountActivity : BottomSheetActivity(), ActionButtonActivity, HasAndroidI |
|
|
|
|
animateAvatar = sharedPrefs.getBoolean("animateGifAvatars", false) |
|
|
|
|
hideFab = sharedPrefs.getBoolean("fabHide", false) |
|
|
|
|
|
|
|
|
|
loadResources() |
|
|
|
|
setupToolbar() |
|
|
|
|
setupTabs() |
|
|
|
|
setupAccountViews() |
|
|
|
@ -135,8 +136,7 @@ class AccountActivity : BottomSheetActivity(), ActionButtonActivity, HasAndroidI |
|
|
|
|
* Load colors and dimensions from resources |
|
|
|
|
*/ |
|
|
|
|
private fun loadResources() { |
|
|
|
|
toolbarColor = ThemeUtils.getColor(this, R.attr.toolbar_background_color) |
|
|
|
|
backgroundColor = ThemeUtils.getColor(this, android.R.attr.colorBackground) |
|
|
|
|
toolbarColor = ThemeUtils.getColor(this, R.attr.colorSurface) |
|
|
|
|
statusBarColorTransparent = ContextCompat.getColor(this, R.color.header_background_filter) |
|
|
|
|
statusBarColorOpaque = ThemeUtils.getColor(this, R.attr.colorPrimaryDark) |
|
|
|
|
avatarSize = resources.getDimension(R.dimen.account_activity_avatar_size) |
|
|
|
@ -211,9 +211,6 @@ class AccountActivity : BottomSheetActivity(), ActionButtonActivity, HasAndroidI |
|
|
|
|
}) |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* Setup toolbar |
|
|
|
|
*/ |
|
|
|
|
private fun setupToolbar() { |
|
|
|
|
// set toolbar top margin according to system window insets |
|
|
|
|
accountCoordinatorLayout.setOnApplyWindowInsetsListener { _, insets -> |
|
|
|
@ -236,6 +233,23 @@ class AccountActivity : BottomSheetActivity(), ActionButtonActivity, HasAndroidI |
|
|
|
|
ThemeUtils.setDrawableTint(this, accountToolbar.navigationIcon, R.attr.account_toolbar_icon_tint_uncollapsed) |
|
|
|
|
ThemeUtils.setDrawableTint(this, accountToolbar.overflowIcon, R.attr.account_toolbar_icon_tint_uncollapsed) |
|
|
|
|
|
|
|
|
|
val appBarElevation = resources.getDimension(R.dimen.actionbar_elevation) |
|
|
|
|
|
|
|
|
|
val toolbarBackground = MaterialShapeDrawable.createWithElevationOverlay(this, appBarElevation) |
|
|
|
|
toolbarBackground.fillColor = ColorStateList.valueOf(Color.TRANSPARENT) |
|
|
|
|
accountToolbar.background = toolbarBackground |
|
|
|
|
|
|
|
|
|
accountHeaderInfoContainer.background = MaterialShapeDrawable.createWithElevationOverlay(this, appBarElevation) |
|
|
|
|
|
|
|
|
|
val avatarBackground = MaterialShapeDrawable.createWithElevationOverlay(this, appBarElevation).apply { |
|
|
|
|
fillColor = ColorStateList.valueOf(toolbarColor) |
|
|
|
|
elevation = appBarElevation |
|
|
|
|
shapeAppearanceModel = ShapeAppearanceModel.builder() |
|
|
|
|
.setAllCornerSizes(resources.getDimension(R.dimen.account_avatar_background_radius)) |
|
|
|
|
.build() |
|
|
|
|
} |
|
|
|
|
accountAvatarImageView.background = avatarBackground |
|
|
|
|
|
|
|
|
|
// Add a listener to change the toolbar icon color when it enters/exits its collapsed state. |
|
|
|
|
accountAppBarLayout.addOnOffsetChangedListener(object : AppBarLayout.OnOffsetChangedListener { |
|
|
|
|
|
|
|
|
@ -281,16 +295,14 @@ class AccountActivity : BottomSheetActivity(), ActionButtonActivity, HasAndroidI |
|
|
|
|
|
|
|
|
|
accountAvatarImageView.visible(scaledAvatarSize > 0) |
|
|
|
|
|
|
|
|
|
var transparencyPercent = abs(verticalOffset) / titleVisibleHeight.toFloat() |
|
|
|
|
if (transparencyPercent > 1) transparencyPercent = 1f |
|
|
|
|
val transparencyPercent = (abs(verticalOffset) / titleVisibleHeight.toFloat()).coerceAtMost(1f) |
|
|
|
|
|
|
|
|
|
window.statusBarColor = argbEvaluator.evaluate(transparencyPercent, statusBarColorTransparent, statusBarColorOpaque) as Int |
|
|
|
|
|
|
|
|
|
val evaluatedToolbarColor = argbEvaluator.evaluate(transparencyPercent, Color.TRANSPARENT, toolbarColor) as Int |
|
|
|
|
val evaluatedTabBarColor = argbEvaluator.evaluate(transparencyPercent, backgroundColor, toolbarColor) as Int |
|
|
|
|
accountToolbar.setBackgroundColor(evaluatedToolbarColor) |
|
|
|
|
accountHeaderInfoContainer.setBackgroundColor(evaluatedTabBarColor) |
|
|
|
|
accountTabLayout.setBackgroundColor(evaluatedTabBarColor) |
|
|
|
|
|
|
|
|
|
toolbarBackground.fillColor = ColorStateList.valueOf(evaluatedToolbarColor) |
|
|
|
|
|
|
|
|
|
swipeToRefreshLayout.isEnabled = verticalOffset == 0 |
|
|
|
|
} |
|
|
|
|
}) |
|
|
|
@ -300,7 +312,7 @@ class AccountActivity : BottomSheetActivity(), ActionButtonActivity, HasAndroidI |
|
|
|
|
private fun makeNotificationBarTransparent() { |
|
|
|
|
val decorView = window.decorView |
|
|
|
|
decorView.systemUiVisibility = decorView.systemUiVisibility or View.SYSTEM_UI_FLAG_LAYOUT_STABLE or View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN |
|
|
|
|
window.statusBarColor = Color.TRANSPARENT |
|
|
|
|
window.statusBarColor = statusBarColorTransparent |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|