AccountActivity: show admin/moderator badge
This commit is contained in:
parent
f5aa20577e
commit
ad4b559f8f
@ -152,6 +152,8 @@ class AccountActivity : BottomSheetActivity(), ActionButtonActivity, HasAndroidI
|
||||
*/
|
||||
private fun setupAccountViews() {
|
||||
// Initialise the default UI states.
|
||||
accountAdminTextView.hide()
|
||||
accountModeratorTextView.hide()
|
||||
accountFloatingActionButton.hide()
|
||||
accountFollowButton.hide()
|
||||
accountMuteButton.hide()
|
||||
@ -391,6 +393,8 @@ class AccountActivity : BottomSheetActivity(), ActionButtonActivity, HasAndroidI
|
||||
|
||||
accountLockedImageView.visible(account.locked)
|
||||
accountBadgeTextView.visible(account.bot)
|
||||
accountAdminTextView.visible(account.pleroma?.isAdmin ?: false)
|
||||
accountModeratorTextView.visible(account.pleroma?.isModerator ?: false)
|
||||
|
||||
updateAccountAvatar()
|
||||
updateToolbar()
|
||||
|
@ -44,8 +44,8 @@ data class Account(
|
||||
val bot: Boolean = false,
|
||||
val emojis: List<Emoji>? = emptyList(), // nullable for backward compatibility
|
||||
val fields: List<Field>? = emptyList(), //nullable for backward compatibility
|
||||
val moved: Account? = null
|
||||
|
||||
val moved: Account? = null,
|
||||
val pleroma: PleromaAccount? = null
|
||||
) : Parcelable {
|
||||
|
||||
val name: String
|
||||
@ -81,6 +81,7 @@ data class Account(
|
||||
&& emojis == other.emojis
|
||||
&& fields == other.fields
|
||||
&& moved == other.moved
|
||||
&& pleroma == other.pleroma
|
||||
}
|
||||
|
||||
fun isRemote(): Boolean = this.username != this.localUsername
|
||||
@ -107,10 +108,16 @@ data class StringField (
|
||||
val value: String
|
||||
): Parcelable
|
||||
|
||||
@Parcelize
|
||||
data class PleromaAccount(
|
||||
@SerializedName("is_moderator") val isModerator: Boolean? = null,
|
||||
@SerializedName("is_admin") val isAdmin: Boolean? = null
|
||||
): Parcelable
|
||||
|
||||
object SpannedParceler : Parceler<Spanned> {
|
||||
override fun create(parcel: Parcel): Spanned = HtmlUtils.fromHtml(parcel.readString())
|
||||
|
||||
override fun Spanned.write(parcel: Parcel, flags: Int) {
|
||||
parcel.writeString(HtmlUtils.toHtml(this))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -132,18 +132,48 @@
|
||||
app:layout_constraintTop_toTopOf="@+id/accountUsernameTextView"
|
||||
app:srcCompat="@drawable/reblog_private_light"
|
||||
tools:visibility="visible" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/accountAdminTextView"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="6dp"
|
||||
android:background="@drawable/profile_badge_background"
|
||||
android:text="@string/admin"
|
||||
android:textSize="?attr/status_text_small"
|
||||
android:visibility="gone"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@id/accountUsernameTextView"
|
||||
tools:visibility="visible" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/accountModeratorTextView"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginStart="8dp"
|
||||
android:layout_marginTop="6dp"
|
||||
android:background="@drawable/profile_badge_background"
|
||||
android:text="@string/moderator"
|
||||
android:textSize="?attr/status_text_small"
|
||||
android:visibility="gone"
|
||||
app:layout_constraintStart_toEndOf="@id/accountAdminTextView"
|
||||
app:layout_constraintTop_toBottomOf="@id/accountUsernameTextView"
|
||||
app:layout_goneMarginStart="0dp"
|
||||
tools:visibility="visible" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/accountFollowsYouTextView"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginStart="8dp"
|
||||
android:layout_marginTop="6dp"
|
||||
android:background="@drawable/profile_badge_background"
|
||||
android:text="@string/follows_you"
|
||||
android:textSize="?attr/status_text_small"
|
||||
android:visibility="gone"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintStart_toEndOf="@id/accountModeratorTextView"
|
||||
app:layout_constraintTop_toBottomOf="@id/accountUsernameTextView"
|
||||
app:layout_goneMarginStart="0dp"
|
||||
tools:visibility="visible" />
|
||||
|
||||
<TextView
|
||||
@ -160,13 +190,13 @@
|
||||
app:layout_constraintTop_toBottomOf="@id/accountUsernameTextView"
|
||||
app:layout_goneMarginStart="0dp"
|
||||
tools:visibility="visible" />
|
||||
|
||||
|
||||
<androidx.constraintlayout.widget.Barrier
|
||||
android:id="@+id/labelBarrier"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
app:barrierDirection="bottom"
|
||||
app:constraint_referenced_ids="accountFollowsYouTextView,accountBadgeTextView" />
|
||||
app:constraint_referenced_ids="accountAdminTextView,accountModeratorTextView,accountFollowsYouTextView,accountBadgeTextView" />
|
||||
|
||||
<androidx.emoji.widget.EmojiTextView
|
||||
android:id="@+id/accountNoteTextView"
|
||||
|
@ -6,5 +6,8 @@
|
||||
<string name="hint_appname">Application name</string>
|
||||
<string name="hint_website">Application website</string>
|
||||
|
||||
<string name="admin">Admin</string>
|
||||
<string name="moderator">Moderator</string>
|
||||
|
||||
</resources>
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user