correctly emojify account name in AccountActivity (#1297)

main
Konrad Pozniak 6 years ago committed by GitHub
parent c0d95209a8
commit c1dcc4dda4
  1. 19
      app/src/main/java/com/keylesspalace/tusky/AccountActivity.kt

@ -91,10 +91,6 @@ class AccountActivity : BottomSheetActivity(), ActionButtonActivity, HasSupportF
private var statusBarColorTransparent: Int = 0 private var statusBarColorTransparent: Int = 0
@ColorInt @ColorInt
private var statusBarColorOpaque: Int = 0 private var statusBarColorOpaque: Int = 0
@ColorInt
private var textColorPrimary: Int = 0
@ColorInt
private var textColorSecondary: Int = 0
private var avatarSize: Float = 0f private var avatarSize: Float = 0f
@Px @Px
@ -142,8 +138,6 @@ class AccountActivity : BottomSheetActivity(), ActionButtonActivity, HasSupportF
backgroundColor = ThemeUtils.getColor(this, android.R.attr.colorBackground) backgroundColor = ThemeUtils.getColor(this, android.R.attr.colorBackground)
statusBarColorTransparent = ContextCompat.getColor(this, R.color.header_background_filter) statusBarColorTransparent = ContextCompat.getColor(this, R.color.header_background_filter)
statusBarColorOpaque = ThemeUtils.getColor(this, R.attr.colorPrimaryDark) statusBarColorOpaque = ThemeUtils.getColor(this, R.attr.colorPrimaryDark)
textColorPrimary = ThemeUtils.getColor(this, android.R.attr.textColorPrimary)
textColorSecondary = ThemeUtils.getColor(this, android.R.attr.textColorSecondary)
avatarSize = resources.getDimension(R.dimen.account_activity_avatar_size) avatarSize = resources.getDimension(R.dimen.account_activity_avatar_size)
titleVisibleHeight = resources.getDimensionPixelSize(R.dimen.account_activity_scroll_title_visible_height) titleVisibleHeight = resources.getDimensionPixelSize(R.dimen.account_activity_scroll_title_visible_height)
} }
@ -247,13 +241,11 @@ class AccountActivity : BottomSheetActivity(), ActionButtonActivity, HasSupportF
override fun onOffsetChanged(appBarLayout: AppBarLayout, verticalOffset: Int) { override fun onOffsetChanged(appBarLayout: AppBarLayout, verticalOffset: Int) {
@AttrRes val attribute = if (titleVisibleHeight + verticalOffset < 0) { @AttrRes val attribute = if (titleVisibleHeight + verticalOffset < 0) {
accountToolbar.setTitleTextColor(textColorPrimary) supportActionBar?.setDisplayShowTitleEnabled(true)
accountToolbar.setSubtitleTextColor(textColorSecondary)
R.attr.account_toolbar_icon_tint_collapsed R.attr.account_toolbar_icon_tint_collapsed
} else { } else {
accountToolbar.setTitleTextColor(Color.TRANSPARENT) supportActionBar?.setDisplayShowTitleEnabled(false)
accountToolbar.setSubtitleTextColor(Color.TRANSPARENT)
R.attr.account_toolbar_icon_tint_uncollapsed R.attr.account_toolbar_icon_tint_uncollapsed
} }
@ -414,10 +406,13 @@ class AccountActivity : BottomSheetActivity(), ActionButtonActivity, HasSupportF
*/ */
private fun updateToolbar() { private fun updateToolbar() {
loadedAccount?.let { account -> loadedAccount?.let { account ->
val emojifiedName = CustomEmojiHelper.emojifyString(account.name, account.emojis, accountToolbar)
try { try {
supportActionBar?.title = EmojiCompat.get().process(account.name) supportActionBar?.title = EmojiCompat.get().process(emojifiedName)
} catch (e: IllegalStateException) { } catch (e: IllegalStateException) {
supportActionBar?.title = account.name supportActionBar?.title = emojifiedName
} }
supportActionBar?.subtitle = String.format(getString(R.string.status_username_format), account.username) supportActionBar?.subtitle = String.format(getString(R.string.status_username_format), account.username)
} }

Loading…
Cancel
Save