Skip to content
This repository has been archived by the owner on Aug 6, 2021. It is now read-only.

Commit

Permalink
Consolidate changes once more
Browse files Browse the repository at this point in the history
Signed-off-by: Sam Therapy <sam@samtherapy.net>
  • Loading branch information
SamTherapy committed Aug 5, 2021
1 parent 488e003 commit 07e89ad
Show file tree
Hide file tree
Showing 8 changed files with 51 additions and 20 deletions.
13 changes: 11 additions & 2 deletions app/src/main/java/com/keylesspalace/tusky/AccountActivity.kt
Original file line number Diff line number Diff line change
Expand Up @@ -389,17 +389,26 @@ class AccountActivity : BottomSheetActivity(), ActionButtonActivity, HasAndroidI

val usernameFormatted = getString(R.string.status_username_format, account.username)
accountUsernameTextView.text = usernameFormatted
accountDisplayNameTextView.text = account.name.emojify(account.emojis, accountDisplayNameTextView)
accountDisplayNameTextView.text =
account.name.emojify(account.emojis, accountDisplayNameTextView)

val emojifiedNote = account.note.emojify(account.emojis, accountNoteTextView)
LinkHelper.setClickableText(accountNoteTextView, emojifiedNote, null, this)

// accountFieldAdapter.fields = account.fields ?: emptyList()
// accountFieldAdapter.fields = account.fields ?: emptyList()
accountFieldAdapter.emojis = account.emojis ?: emptyList()
accountFieldAdapter.notifyDataSetChanged()
val verified = account.pleroma?.verified
var isVerified = false
verified!!.forEach {
if (it.matches(Regex("verified")))
isVerified = true
}

accountLockedImageView.visible(account.locked)
accountBadgeTextView.visible(account.bot)
account_verified.visible(isVerified)

// API can return user is both admin and mod
// but admin rights already implies moderator, so just ignore it
val isAdmin = account.pleroma?.isAdmin ?: false
Expand Down
3 changes: 2 additions & 1 deletion app/src/main/java/com/keylesspalace/tusky/entity/Account.kt
Original file line number Diff line number Diff line change
Expand Up @@ -101,5 +101,6 @@ data class PleromaAccount(
@SerializedName("ap_id") val apId: String? = null,
@SerializedName("accepts_chat_messages") val acceptsChatMessages: Boolean? = null,
@SerializedName("is_moderator") val isModerator: Boolean? = null,
@SerializedName("is_admin") val isAdmin: Boolean? = null
@SerializedName("is_admin") val isAdmin: Boolean? = null,
@SerializedName("tags") val verified: Array<String>? = null
)
Original file line number Diff line number Diff line change
Expand Up @@ -631,7 +631,7 @@ interface MastodonApi {
@Path("message_id") messageId: String
): Single<ChatMessage>

@GET("api/v1/pleroma/chats")
@GET("api/v2/pleroma/chats")
fun getChats(
@Query("max_id") maxId: String?,
@Query("min_id") minId: String?,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,24 +59,24 @@ class ChatRepositoryImpl(
getChatMessagesFromNetwork(chatId, maxId, sinceId, sincedIdMinusOne, limit, accountId, requestMode)
}*/

return getChatMessagesFromNetwork(chatId, maxId, sinceId, sincedIdMinusOne, limit, accountId, requestMode)
return getChatMessagesFromNetwork(chatId, maxId, null, null, limit, accountId, requestMode)
}

private fun getChatsFromNetwork(maxId: String?, sinceId: String?,
sinceIdMinusOne: String?, limit: Int,
accountId: Long, requestMode: TimelineRequestMode
): Single<out List<ChatStatus>> {
return mastodonApi.getChats(maxId, null, sinceIdMinusOne, 0, limit + 1)
.map { chats ->
this.saveChatsToDb(accountId, chats, maxId, sinceId)
}
.flatMap { chats ->
this.addFromDbIfNeeded(accountId, chats, maxId, sinceId, limit, requestMode)
}
.onErrorResumeNext { error ->
if (error is IOException && requestMode != NETWORK) {
this.getChatsFromDb(accountId, maxId, sinceId, limit)
} else {
return mastodonApi.getChats(null, null, sinceIdMinusOne, 0, limit + 1)
.map { chats ->
this.saveChatsToDb(accountId, chats, maxId, sinceId)
}
.flatMap { chats ->
this.addFromDbIfNeeded(accountId, chats, maxId, sinceId, limit, requestMode)
}
.onErrorResumeNext { error ->
if (error is IOException && requestMode != NETWORK) {
this.getChatsFromDb(accountId, maxId, sinceId, limit)
} else {
Single.error(error)
}
}
Expand Down
10 changes: 10 additions & 0 deletions app/src/main/res/drawable/verified_badge.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:tint="#838383"
android:viewportWidth="24"
android:viewportHeight="24">
<path
android:fillColor="@android:color/white"
android:pathData="M23,12l-2.44,-2.79l0.34,-3.69l-3.61,-0.82L15.4,1.5L12,2.96L8.6,1.5L6.71,4.69L3.1,5.5L3.44,9.2L1,12l2.44,2.79l-0.34,3.7l3.61,0.82L8.6,22.5l3.4,-1.47l3.4,1.46l1.89,-3.19l3.61,-0.82l-0.34,-3.69L23,12zM10.09,16.72l-3.8,-3.81l1.48,-1.48l2.32,2.33l5.85,-5.87l1.48,1.48L10.09,16.72z" />
</vector>
14 changes: 13 additions & 1 deletion app/src/main/res/layout/activity_account.xml
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,19 @@
app:srcCompat="@drawable/ic_reblog_private_24dp"
app:tint="?android:textColorSecondary"
tools:visibility="visible" />


<ImageView
android:id="@+id/account_verified"
android:layout_width="24sp"
android:layout_height="24sp"
android:contentDescription="@string/description_account_verified"
app:layout_constraintBottom_toBottomOf="@+id/accountDisplayNameTextView"
app:layout_constraintStart_toEndOf="@+id/accountDisplayNameTextView"
app:layout_constraintTop_toTopOf="@+id/accountDisplayNameTextView"
app:srcCompat="@drawable/verified_badge"
tools:layout_editor_absoluteX="230dp"
tools:layout_editor_absoluteY="62dp" />

<TextView
android:id="@+id/accountAdminTextView"
android:layout_width="wrap_content"
Expand Down
4 changes: 1 addition & 3 deletions app/src/main/res/values/donottranslate.xml
Original file line number Diff line number Diff line change
Expand Up @@ -136,9 +136,7 @@
</string>

<string-array name="rick_roll_domains" translatable="false">
<item>gab.com</item>
<item>gab.ai</item>
<item>spinster.xyz</item>
<item></item>
</string-array>

<string name="rick_roll_url">https://www.youtube.com/watch?v=dQw4w9WgXcQ</string>
Expand Down
1 change: 1 addition & 0 deletions app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -298,6 +298,7 @@
<string name="notification_summary_small">%1$s and %2$s</string>
<string name="notification_title_summary">%d new interactions</string>

<string name="description_account_verified">Verified Account</string>
<string name="description_account_locked">Locked Account</string>

<string name="about_title_activity">About</string>
Expand Down

0 comments on commit 07e89ad

Please sign in to comment.