Display mastodon account domain
This commit is contained in:
parent
f49b77bfce
commit
9ae74b04f7
|
@ -20,10 +20,10 @@
|
||||||
package org.mariotaku.twidere.adapter
|
package org.mariotaku.twidere.adapter
|
||||||
|
|
||||||
import android.content.Context
|
import android.content.Context
|
||||||
import androidx.recyclerview.widget.RecyclerViewAccessor
|
|
||||||
import android.view.View
|
import android.view.View
|
||||||
import android.view.ViewGroup
|
import android.view.ViewGroup
|
||||||
import android.widget.CompoundButton
|
import android.widget.CompoundButton
|
||||||
|
import androidx.recyclerview.widget.RecyclerViewAccessor
|
||||||
import com.bumptech.glide.RequestManager
|
import com.bumptech.glide.RequestManager
|
||||||
import org.mariotaku.twidere.R
|
import org.mariotaku.twidere.R
|
||||||
import org.mariotaku.twidere.model.AccountDetails
|
import org.mariotaku.twidere.model.AccountDetails
|
||||||
|
@ -59,8 +59,9 @@ class AccountDetailsAdapter(
|
||||||
|
|
||||||
override fun getView(position: Int, convertView: View?, parent: ViewGroup?): View {
|
override fun getView(position: Int, convertView: View?, parent: ViewGroup?): View {
|
||||||
val view = super.getView(position, convertView, parent)
|
val view = super.getView(position, convertView, parent)
|
||||||
|
val showType = objects.groupBy { it.type }.count().let { it > 1 }
|
||||||
val holder = view.tag as? AccountViewHolder ?: run {
|
val holder = view.tag as? AccountViewHolder ?: run {
|
||||||
val h = AccountViewHolder(this, view)
|
val h = AccountViewHolder(this, view, showType)
|
||||||
view.tag = h
|
view.tag = h
|
||||||
return@run h
|
return@run h
|
||||||
}
|
}
|
||||||
|
|
|
@ -26,6 +26,7 @@ import com.bumptech.glide.RequestManager
|
||||||
import kotlinx.android.synthetic.main.list_item_simple_user.view.*
|
import kotlinx.android.synthetic.main.list_item_simple_user.view.*
|
||||||
import org.mariotaku.ktextension.spannable
|
import org.mariotaku.ktextension.spannable
|
||||||
import org.mariotaku.twidere.R
|
import org.mariotaku.twidere.R
|
||||||
|
import org.mariotaku.twidere.annotation.AccountType
|
||||||
import org.mariotaku.twidere.extension.loadProfileImage
|
import org.mariotaku.twidere.extension.loadProfileImage
|
||||||
import org.mariotaku.twidere.model.AccountDetails
|
import org.mariotaku.twidere.model.AccountDetails
|
||||||
import org.mariotaku.twidere.model.UserKey
|
import org.mariotaku.twidere.model.UserKey
|
||||||
|
@ -63,7 +64,12 @@ class AccountsSpinnerAdapter(
|
||||||
text1?.visibility = View.VISIBLE
|
text1?.visibility = View.VISIBLE
|
||||||
text1?.spannable = item.user.name
|
text1?.spannable = item.user.name
|
||||||
text2?.visibility = View.VISIBLE
|
text2?.visibility = View.VISIBLE
|
||||||
text2?.spannable = "@${item.user.screen_name}"
|
val showType = objects.filter { it.type != null }.groupBy { it.type }.count().let { it > 1 }
|
||||||
|
text2?.spannable = if (item.type == AccountType.MASTODON) {
|
||||||
|
item.account.name
|
||||||
|
} else {
|
||||||
|
"${if (showType) item.type else ""}@${item.user.screen_name}"
|
||||||
|
}
|
||||||
if (icon != null) {
|
if (icon != null) {
|
||||||
if (profileImageEnabled) {
|
if (profileImageEnabled) {
|
||||||
icon.visibility = View.VISIBLE
|
icon.visibility = View.VISIBLE
|
||||||
|
|
|
@ -38,20 +38,20 @@ import android.graphics.drawable.ColorDrawable
|
||||||
import android.graphics.drawable.Drawable
|
import android.graphics.drawable.Drawable
|
||||||
import android.net.Uri
|
import android.net.Uri
|
||||||
import android.os.Bundle
|
import android.os.Bundle
|
||||||
import com.google.android.material.navigation.NavigationView
|
|
||||||
import androidx.loader.app.LoaderManager.LoaderCallbacks
|
|
||||||
import androidx.core.content.ContextCompat
|
|
||||||
import androidx.loader.content.FixedAsyncTaskLoader
|
|
||||||
import androidx.loader.content.Loader
|
|
||||||
import androidx.core.view.MenuItemCompat
|
|
||||||
import androidx.viewpager.widget.ViewPager
|
|
||||||
import androidx.appcompat.view.SupportMenuInflater
|
|
||||||
import androidx.appcompat.widget.ActionMenuView.OnMenuItemClickListener
|
|
||||||
import android.view.*
|
import android.view.*
|
||||||
import android.view.View.OnClickListener
|
import android.view.View.OnClickListener
|
||||||
import android.view.animation.DecelerateInterpolator
|
import android.view.animation.DecelerateInterpolator
|
||||||
import android.widget.ImageView
|
import android.widget.ImageView
|
||||||
|
import androidx.appcompat.view.SupportMenuInflater
|
||||||
|
import androidx.appcompat.widget.ActionMenuView.OnMenuItemClickListener
|
||||||
|
import androidx.core.content.ContextCompat
|
||||||
|
import androidx.core.view.MenuItemCompat
|
||||||
import androidx.core.view.isVisible
|
import androidx.core.view.isVisible
|
||||||
|
import androidx.loader.app.LoaderManager.LoaderCallbacks
|
||||||
|
import androidx.loader.content.FixedAsyncTaskLoader
|
||||||
|
import androidx.loader.content.Loader
|
||||||
|
import androidx.viewpager.widget.ViewPager
|
||||||
|
import com.google.android.material.navigation.NavigationView
|
||||||
import kotlinx.android.synthetic.main.header_drawer_account_selector.view.*
|
import kotlinx.android.synthetic.main.header_drawer_account_selector.view.*
|
||||||
import org.mariotaku.chameleon.Chameleon
|
import org.mariotaku.chameleon.Chameleon
|
||||||
import org.mariotaku.kpreferences.get
|
import org.mariotaku.kpreferences.get
|
||||||
|
@ -109,7 +109,6 @@ class AccountsDashboardFragment : BaseFragment(), LoaderCallbacks<AccountsInfo>,
|
||||||
private val floatingProfileImageSnapshot by lazy { accountsHeader.floatingProfileImageSnapshot }
|
private val floatingProfileImageSnapshot by lazy { accountsHeader.floatingProfileImageSnapshot }
|
||||||
private val accountProfileImageView by lazy { accountsHeader.profileImage }
|
private val accountProfileImageView by lazy { accountsHeader.profileImage }
|
||||||
private val accountProfileNameView by lazy { accountsHeader.name }
|
private val accountProfileNameView by lazy { accountsHeader.name }
|
||||||
private val accountUserTypeView by lazy { accountsHeader.user_type }
|
|
||||||
private val accountProfileScreenNameView by lazy { accountsHeader.screenName }
|
private val accountProfileScreenNameView by lazy { accountsHeader.screenName }
|
||||||
private val accountDashboardMenu by lazy { accountsHeader.accountDashboardMenu }
|
private val accountDashboardMenu by lazy { accountsHeader.accountDashboardMenu }
|
||||||
private val profileContainer by lazy { accountsHeader.profileContainer }
|
private val profileContainer by lazy { accountsHeader.profileContainer }
|
||||||
|
@ -550,13 +549,14 @@ class AccountsDashboardFragment : BaseFragment(), LoaderCallbacks<AccountsInfo>,
|
||||||
if (context == null || isDetached || (activity?.isFinishing != false)) return
|
if (context == null || isDetached || (activity?.isFinishing != false)) return
|
||||||
val account = accountsAdapter.selectedAccount ?: return
|
val account = accountsAdapter.selectedAccount ?: return
|
||||||
accountProfileNameView.spannable = account.user.name
|
accountProfileNameView.spannable = account.user.name
|
||||||
accountsAdapter.accounts?.groupBy { it.type }?.count()?.let {
|
val showType = accountsAdapter.accounts?.groupBy { it.type }?.count()?.let {
|
||||||
it > 1
|
it > 1
|
||||||
}?.let {
|
} ?: false
|
||||||
accountUserTypeView.isVisible = it
|
accountProfileScreenNameView.spannable = if (account.type == AccountType.MASTODON) {
|
||||||
|
account.account.name
|
||||||
|
} else {
|
||||||
|
"${if (showType) account.type else ""}@${account.user.screen_name}"
|
||||||
}
|
}
|
||||||
accountUserTypeView.spannable = account.type
|
|
||||||
accountProfileScreenNameView.spannable = "@${account.user.screen_name}"
|
|
||||||
requestManager.loadProfileImage(context!!, account, preferences[profileImageStyleKey],
|
requestManager.loadProfileImage(context!!, account, preferences[profileImageStyleKey],
|
||||||
accountProfileImageView.cornerRadius, accountProfileImageView.cornerRadiusRatio,
|
accountProfileImageView.cornerRadius, accountProfileImageView.cornerRadiusRatio,
|
||||||
ProfileImageSize.REASONABLY_SMALL).placeholder(profileImageSnapshot).into(accountProfileImageView)
|
ProfileImageSize.REASONABLY_SMALL).placeholder(profileImageSnapshot).into(accountProfileImageView)
|
||||||
|
|
|
@ -19,14 +19,15 @@
|
||||||
|
|
||||||
package org.mariotaku.twidere.view.holder
|
package org.mariotaku.twidere.view.holder
|
||||||
|
|
||||||
import androidx.recyclerview.widget.RecyclerView
|
|
||||||
import android.view.View
|
import android.view.View
|
||||||
import android.widget.CompoundButton
|
import android.widget.CompoundButton
|
||||||
import android.widget.ImageView
|
import android.widget.ImageView
|
||||||
import android.widget.TextView
|
import android.widget.TextView
|
||||||
|
import androidx.recyclerview.widget.RecyclerView
|
||||||
import org.mariotaku.ktextension.spannable
|
import org.mariotaku.ktextension.spannable
|
||||||
import org.mariotaku.twidere.R
|
import org.mariotaku.twidere.R
|
||||||
import org.mariotaku.twidere.adapter.AccountDetailsAdapter
|
import org.mariotaku.twidere.adapter.AccountDetailsAdapter
|
||||||
|
import org.mariotaku.twidere.annotation.AccountType
|
||||||
import org.mariotaku.twidere.extension.loadProfileImage
|
import org.mariotaku.twidere.extension.loadProfileImage
|
||||||
import org.mariotaku.twidere.model.AccountDetails
|
import org.mariotaku.twidere.model.AccountDetails
|
||||||
import org.mariotaku.twidere.model.util.AccountUtils
|
import org.mariotaku.twidere.model.util.AccountUtils
|
||||||
|
@ -35,7 +36,8 @@ import org.mariotaku.twidere.view.iface.IColorLabelView
|
||||||
|
|
||||||
class AccountViewHolder(
|
class AccountViewHolder(
|
||||||
val adapter: AccountDetailsAdapter,
|
val adapter: AccountDetailsAdapter,
|
||||||
itemView: View
|
itemView: View,
|
||||||
|
val showType: Boolean
|
||||||
) : RecyclerView.ViewHolder(itemView) {
|
) : RecyclerView.ViewHolder(itemView) {
|
||||||
|
|
||||||
private val content = itemView as IColorLabelView
|
private val content = itemView as IColorLabelView
|
||||||
|
@ -61,7 +63,11 @@ class AccountViewHolder(
|
||||||
|
|
||||||
fun display(details: AccountDetails) {
|
fun display(details: AccountDetails) {
|
||||||
name.spannable = details.user.name
|
name.spannable = details.user.name
|
||||||
screenName.spannable = "@${details.user.screen_name}"
|
screenName.spannable = if (details.type == AccountType.MASTODON) {
|
||||||
|
details.account.name
|
||||||
|
} else {
|
||||||
|
"${if (showType) details.type else ""}@${details.user.screen_name}"
|
||||||
|
}
|
||||||
setAccountColor(details.color)
|
setAccountColor(details.color)
|
||||||
profileImage.visibility = View.VISIBLE
|
profileImage.visibility = View.VISIBLE
|
||||||
adapter.requestManager.loadProfileImage(adapter.context, details, adapter.profileImageStyle,
|
adapter.requestManager.loadProfileImage(adapter.context, details, adapter.profileImageStyle,
|
||||||
|
|
|
@ -125,7 +125,7 @@
|
||||||
android:gravity="center_vertical"
|
android:gravity="center_vertical"
|
||||||
android:orientation="horizontal">
|
android:orientation="horizontal">
|
||||||
|
|
||||||
<RelativeLayout
|
<LinearLayout
|
||||||
android:layout_width="0dp"
|
android:layout_width="0dp"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_weight="1"
|
android:layout_weight="1"
|
||||||
|
@ -133,8 +133,6 @@
|
||||||
android:orientation="vertical">
|
android:orientation="vertical">
|
||||||
|
|
||||||
<org.mariotaku.twidere.view.FixedTextView
|
<org.mariotaku.twidere.view.FixedTextView
|
||||||
android:layout_alignParentTop="true"
|
|
||||||
android:layout_alignParentStart="true"
|
|
||||||
android:id="@+id/name"
|
android:id="@+id/name"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
|
@ -147,8 +145,6 @@
|
||||||
tools:text="Name"/>
|
tools:text="Name"/>
|
||||||
|
|
||||||
<org.mariotaku.twidere.view.FixedTextView
|
<org.mariotaku.twidere.view.FixedTextView
|
||||||
android:layout_below="@id/name"
|
|
||||||
android:layout_toEndOf="@id/user_type"
|
|
||||||
android:id="@+id/screenName"
|
android:id="@+id/screenName"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
|
@ -159,20 +155,7 @@
|
||||||
android:textColor="@color/material_grey"
|
android:textColor="@color/material_grey"
|
||||||
tools:text="\@username"/>
|
tools:text="\@username"/>
|
||||||
|
|
||||||
<org.mariotaku.twidere.view.FixedTextView
|
</LinearLayout>
|
||||||
android:layout_alignParentStart="true"
|
|
||||||
android:layout_below="@id/name"
|
|
||||||
android:id="@+id/user_type"
|
|
||||||
android:layout_width="wrap_content"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:ellipsize="end"
|
|
||||||
android:focusable="false"
|
|
||||||
android:maxLines="1"
|
|
||||||
android:textAppearance="?android:textAppearanceSmall"
|
|
||||||
android:textColor="@color/material_grey"
|
|
||||||
tools:text="twidere"/>
|
|
||||||
|
|
||||||
</RelativeLayout>
|
|
||||||
|
|
||||||
<FrameLayout
|
<FrameLayout
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
|
|
Loading…
Reference in New Issue