From 0e9d3623514a8234ed148a9648f9227dbb52967f Mon Sep 17 00:00:00 2001 From: moddedBear <57692663+moddedBear@users.noreply.github.com> Date: Wed, 27 Apr 2022 11:58:39 -0600 Subject: [PATCH] Remove Identity Proof Support (#2456) * Remove IdentityProof.kt and refactor * Remove accountFieldData from viewmodel * Remove unused imports --- .../components/account/AccountActivity.kt | 8 +---- .../components/account/AccountFieldAdapter.kt | 32 +++++-------------- .../components/account/AccountViewModel.kt | 28 ---------------- .../tusky/entity/IdentityProof.kt | 9 ------ .../tusky/network/MastodonApi.kt | 6 ---- 5 files changed, 9 insertions(+), 74 deletions(-) delete mode 100644 app/src/main/java/com/keylesspalace/tusky/entity/IdentityProof.kt diff --git a/app/src/main/java/com/keylesspalace/tusky/components/account/AccountActivity.kt b/app/src/main/java/com/keylesspalace/tusky/components/account/AccountActivity.kt index 7a7d5ecc..cc8719bb 100644 --- a/app/src/main/java/com/keylesspalace/tusky/components/account/AccountActivity.kt +++ b/app/src/main/java/com/keylesspalace/tusky/components/account/AccountActivity.kt @@ -372,12 +372,6 @@ class AccountActivity : BottomSheetActivity(), ActionButtonActivity, HasAndroidI .show() } } - viewModel.accountFieldData.observe( - this - ) { - accountFieldAdapter.fields = it - accountFieldAdapter.notifyDataSetChanged() - } viewModel.noteSaved.observe(this) { binding.saveNoteInfo.visible(it, View.INVISIBLE) } @@ -409,7 +403,7 @@ class AccountActivity : BottomSheetActivity(), ActionButtonActivity, HasAndroidI val emojifiedNote = account.note.parseAsMastodonHtml().emojify(account.emojis, binding.accountNoteTextView, animateEmojis) setClickableText(binding.accountNoteTextView, emojifiedNote, emptyList(), null, this) - // accountFieldAdapter.fields = account.fields ?: emptyList() + accountFieldAdapter.fields = account.fields ?: emptyList() accountFieldAdapter.emojis = account.emojis ?: emptyList() accountFieldAdapter.notifyDataSetChanged() diff --git a/app/src/main/java/com/keylesspalace/tusky/components/account/AccountFieldAdapter.kt b/app/src/main/java/com/keylesspalace/tusky/components/account/AccountFieldAdapter.kt index d51bb145..86acb813 100644 --- a/app/src/main/java/com/keylesspalace/tusky/components/account/AccountFieldAdapter.kt +++ b/app/src/main/java/com/keylesspalace/tusky/components/account/AccountFieldAdapter.kt @@ -15,7 +15,6 @@ package com.keylesspalace.tusky.components.account -import android.text.method.LinkMovementMethod import android.view.LayoutInflater import android.view.ViewGroup import androidx.recyclerview.widget.RecyclerView @@ -23,11 +22,8 @@ import com.keylesspalace.tusky.R import com.keylesspalace.tusky.databinding.ItemAccountFieldBinding import com.keylesspalace.tusky.entity.Emoji import com.keylesspalace.tusky.entity.Field -import com.keylesspalace.tusky.entity.IdentityProof import com.keylesspalace.tusky.interfaces.LinkListener import com.keylesspalace.tusky.util.BindingHolder -import com.keylesspalace.tusky.util.Either -import com.keylesspalace.tusky.util.createClickableText import com.keylesspalace.tusky.util.emojify import com.keylesspalace.tusky.util.parseAsMastodonHtml import com.keylesspalace.tusky.util.setClickableText @@ -38,7 +34,7 @@ class AccountFieldAdapter( ) : RecyclerView.Adapter>() { var emojis: List = emptyList() - var fields: List> = emptyList() + var fields: List = emptyList() override fun getItemCount() = fields.size @@ -48,32 +44,20 @@ class AccountFieldAdapter( } override fun onBindViewHolder(holder: BindingHolder, position: Int) { - val proofOrField = fields[position] + val field = fields[position] val nameTextView = holder.binding.accountFieldName val valueTextView = holder.binding.accountFieldValue - if (proofOrField.isLeft()) { - val identityProof = proofOrField.asLeft() + val emojifiedName = field.name.emojify(emojis, nameTextView, animateEmojis) + nameTextView.text = emojifiedName - nameTextView.text = identityProof.provider - valueTextView.text = createClickableText(identityProof.username, identityProof.profileUrl) - - valueTextView.movementMethod = LinkMovementMethod.getInstance() + val emojifiedValue = field.value.parseAsMastodonHtml().emojify(emojis, valueTextView, animateEmojis) + setClickableText(valueTextView, emojifiedValue, emptyList(), null, linkListener) + if (field.verifiedAt != null) { valueTextView.setCompoundDrawablesRelativeWithIntrinsicBounds(0, 0, R.drawable.ic_check_circle, 0) } else { - val field = proofOrField.asRight() - val emojifiedName = field.name.emojify(emojis, nameTextView, animateEmojis) - nameTextView.text = emojifiedName - - val emojifiedValue = field.value.parseAsMastodonHtml().emojify(emojis, valueTextView, animateEmojis) - setClickableText(valueTextView, emojifiedValue, emptyList(), null, linkListener) - - if (field.verifiedAt != null) { - valueTextView.setCompoundDrawablesRelativeWithIntrinsicBounds(0, 0, R.drawable.ic_check_circle, 0) - } else { - valueTextView.setCompoundDrawablesRelativeWithIntrinsicBounds(0, 0, 0, 0) - } + valueTextView.setCompoundDrawablesRelativeWithIntrinsicBounds(0, 0, 0, 0) } } } diff --git a/app/src/main/java/com/keylesspalace/tusky/components/account/AccountViewModel.kt b/app/src/main/java/com/keylesspalace/tusky/components/account/AccountViewModel.kt index 6fa988ac..664651eb 100644 --- a/app/src/main/java/com/keylesspalace/tusky/components/account/AccountViewModel.kt +++ b/app/src/main/java/com/keylesspalace/tusky/components/account/AccountViewModel.kt @@ -10,17 +10,13 @@ import com.keylesspalace.tusky.appstore.ProfileEditedEvent import com.keylesspalace.tusky.appstore.UnfollowEvent import com.keylesspalace.tusky.db.AccountManager import com.keylesspalace.tusky.entity.Account -import com.keylesspalace.tusky.entity.Field -import com.keylesspalace.tusky.entity.IdentityProof import com.keylesspalace.tusky.entity.Relationship import com.keylesspalace.tusky.network.MastodonApi -import com.keylesspalace.tusky.util.Either import com.keylesspalace.tusky.util.Error import com.keylesspalace.tusky.util.Loading import com.keylesspalace.tusky.util.Resource import com.keylesspalace.tusky.util.RxAwareViewModel import com.keylesspalace.tusky.util.Success -import com.keylesspalace.tusky.util.combineOptionalLiveData import io.reactivex.rxjava3.core.Single import io.reactivex.rxjava3.disposables.Disposable import retrofit2.Call @@ -40,13 +36,6 @@ class AccountViewModel @Inject constructor( val noteSaved = MutableLiveData() - private val identityProofData = MutableLiveData>() - - val accountFieldData = combineOptionalLiveData(accountData, identityProofData) { accountRes, identityProofs -> - identityProofs.orEmpty().map { Either.Left(it) } - .plus(accountRes?.data?.fields.orEmpty().map { Either.Right(it) }) - } - val isRefreshing = MutableLiveData().apply { value = false } private var isDataLoading = false @@ -106,22 +95,6 @@ class AccountViewModel @Inject constructor( } } - private fun obtainIdentityProof(reload: Boolean = false) { - if (identityProofData.value == null || reload) { - - mastodonApi.identityProofs(accountId) - .subscribe( - { proofs -> - identityProofData.postValue(proofs) - }, - { t -> - Log.w(TAG, "failed obtaining identity proofs", t) - } - ) - .autoDispose() - } - } - fun changeFollowState() { val relationship = relationshipData.value?.data if (relationship?.following == true || relationship?.requested == true) { @@ -314,7 +287,6 @@ class AccountViewModel @Inject constructor( return accountId.let { obtainAccount(isReload) - obtainIdentityProof() if (!isSelf) obtainRelationship(isReload) } diff --git a/app/src/main/java/com/keylesspalace/tusky/entity/IdentityProof.kt b/app/src/main/java/com/keylesspalace/tusky/entity/IdentityProof.kt deleted file mode 100644 index 98af734b..00000000 --- a/app/src/main/java/com/keylesspalace/tusky/entity/IdentityProof.kt +++ /dev/null @@ -1,9 +0,0 @@ -package com.keylesspalace.tusky.entity - -import com.google.gson.annotations.SerializedName - -data class IdentityProof( - val provider: String, - @SerializedName("provider_username") val username: String, - @SerializedName("profile_url") val profileUrl: String -) diff --git a/app/src/main/java/com/keylesspalace/tusky/network/MastodonApi.kt b/app/src/main/java/com/keylesspalace/tusky/network/MastodonApi.kt index 2340c5dd..02af5caa 100644 --- a/app/src/main/java/com/keylesspalace/tusky/network/MastodonApi.kt +++ b/app/src/main/java/com/keylesspalace/tusky/network/MastodonApi.kt @@ -24,7 +24,6 @@ import com.keylesspalace.tusky.entity.Conversation import com.keylesspalace.tusky.entity.DeletedStatus import com.keylesspalace.tusky.entity.Emoji import com.keylesspalace.tusky.entity.Filter -import com.keylesspalace.tusky.entity.IdentityProof import com.keylesspalace.tusky.entity.Instance import com.keylesspalace.tusky.entity.Marker import com.keylesspalace.tusky.entity.MastoList @@ -367,11 +366,6 @@ interface MastodonApi { @Query("id[]") accountIds: List ): Single> - @GET("api/v1/accounts/{id}/identity_proofs") - fun identityProofs( - @Path("id") accountId: String - ): Single> - @POST("api/v1/pleroma/accounts/{id}/subscribe") fun subscribeAccount( @Path("id") accountId: String