From f49b77bfce9dd18f703699ba230fce60edd9b9fa Mon Sep 17 00:00:00 2001 From: Tlaster Date: Fri, 15 May 2020 16:16:02 +0800 Subject: [PATCH] Add account type display support --- .../fragment/AccountsDashboardFragment.kt | 8 +++++++ .../layout/header_drawer_account_selector.xml | 21 +++++++++++++++++-- 2 files changed, 27 insertions(+), 2 deletions(-) diff --git a/twidere/src/main/kotlin/org/mariotaku/twidere/fragment/AccountsDashboardFragment.kt b/twidere/src/main/kotlin/org/mariotaku/twidere/fragment/AccountsDashboardFragment.kt index 2a127bc3a..5de2bb4ef 100644 --- a/twidere/src/main/kotlin/org/mariotaku/twidere/fragment/AccountsDashboardFragment.kt +++ b/twidere/src/main/kotlin/org/mariotaku/twidere/fragment/AccountsDashboardFragment.kt @@ -51,6 +51,7 @@ import android.view.* import android.view.View.OnClickListener import android.view.animation.DecelerateInterpolator import android.widget.ImageView +import androidx.core.view.isVisible import kotlinx.android.synthetic.main.header_drawer_account_selector.view.* import org.mariotaku.chameleon.Chameleon import org.mariotaku.kpreferences.get @@ -108,6 +109,7 @@ class AccountsDashboardFragment : BaseFragment(), LoaderCallbacks, private val floatingProfileImageSnapshot by lazy { accountsHeader.floatingProfileImageSnapshot } private val accountProfileImageView by lazy { accountsHeader.profileImage } private val accountProfileNameView by lazy { accountsHeader.name } + private val accountUserTypeView by lazy { accountsHeader.user_type } private val accountProfileScreenNameView by lazy { accountsHeader.screenName } private val accountDashboardMenu by lazy { accountsHeader.accountDashboardMenu } private val profileContainer by lazy { accountsHeader.profileContainer } @@ -548,6 +550,12 @@ class AccountsDashboardFragment : BaseFragment(), LoaderCallbacks, if (context == null || isDetached || (activity?.isFinishing != false)) return val account = accountsAdapter.selectedAccount ?: return accountProfileNameView.spannable = account.user.name + accountsAdapter.accounts?.groupBy { it.type }?.count()?.let { + it > 1 + }?.let { + accountUserTypeView.isVisible = it + } + accountUserTypeView.spannable = account.type accountProfileScreenNameView.spannable = "@${account.user.screen_name}" requestManager.loadProfileImage(context!!, account, preferences[profileImageStyleKey], accountProfileImageView.cornerRadius, accountProfileImageView.cornerRadiusRatio, diff --git a/twidere/src/main/res/layout/header_drawer_account_selector.xml b/twidere/src/main/res/layout/header_drawer_account_selector.xml index 4fc3aeeb8..5cac902f2 100644 --- a/twidere/src/main/res/layout/header_drawer_account_selector.xml +++ b/twidere/src/main/res/layout/header_drawer_account_selector.xml @@ -125,7 +125,7 @@ android:gravity="center_vertical" android:orientation="horizontal"> - - + + +