AccountActivity: implement subscribing
This commit is contained in:
parent
d82ca3df9b
commit
f6a9c51b86
@ -83,6 +83,7 @@ class AccountActivity : BottomSheetActivity(), ActionButtonActivity, HasAndroidI
|
||||
private var blocking: Boolean = false
|
||||
private var muting: Boolean = false
|
||||
private var showingReblogs: Boolean = false
|
||||
private var subscribing: Boolean = false
|
||||
private var loadedAccount: Account? = null
|
||||
|
||||
private var animateAvatar: Boolean = false
|
||||
@ -185,7 +186,6 @@ class AccountActivity : BottomSheetActivity(), ActionButtonActivity, HasAndroidI
|
||||
poorTabView.isPressed = true
|
||||
accountTabLayout.postDelayed({ poorTabView.isPressed = false }, 300)
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
@ -390,7 +390,6 @@ class AccountActivity : BottomSheetActivity(), ActionButtonActivity, HasAndroidI
|
||||
accountFieldAdapter.emojis = account.emojis ?: emptyList()
|
||||
accountFieldAdapter.notifyDataSetChanged()
|
||||
|
||||
|
||||
accountLockedImageView.visible(account.locked)
|
||||
accountBadgeTextView.visible(account.bot)
|
||||
accountAdminTextView.visible(account.pleroma?.isAdmin ?: false)
|
||||
@ -554,6 +553,15 @@ class AccountActivity : BottomSheetActivity(), ActionButtonActivity, HasAndroidI
|
||||
showingReblogs = relation.showingReblogs
|
||||
|
||||
accountFollowsYouTextView.visible(relation.followedBy)
|
||||
|
||||
// because subscribing is Pleroma extension, enable it __only__ when we have non-null subscribing field
|
||||
if(!viewModel.isSelf && followState == FollowState.FOLLOWING && relation.subscribing != null) {
|
||||
accountSubscribeButton.show()
|
||||
accountSubscribeButton.setOnClickListener {
|
||||
viewModel.changeSubscribingState()
|
||||
}
|
||||
subscribing = relation.subscribing
|
||||
}
|
||||
|
||||
updateButtons()
|
||||
}
|
||||
@ -578,6 +586,7 @@ class AccountActivity : BottomSheetActivity(), ActionButtonActivity, HasAndroidI
|
||||
accountFollowButton.setText(R.string.action_unfollow)
|
||||
}
|
||||
}
|
||||
updateSubscribeButton()
|
||||
}
|
||||
|
||||
private fun updateMuteButton() {
|
||||
@ -587,7 +596,19 @@ class AccountActivity : BottomSheetActivity(), ActionButtonActivity, HasAndroidI
|
||||
accountMuteButton.hide()
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private fun updateSubscribeButton() {
|
||||
if(followState != FollowState.FOLLOWING) {
|
||||
accountSubscribeButton.hide()
|
||||
}
|
||||
|
||||
if(subscribing) {
|
||||
accountSubscribeButton.setIconResource(R.drawable.ic_notifications_active_24dp)
|
||||
} else {
|
||||
accountSubscribeButton.setIconResource(R.drawable.ic_notifications_24dp)
|
||||
}
|
||||
}
|
||||
|
||||
private fun updateButtons() {
|
||||
invalidateOptionsMenu()
|
||||
|
||||
@ -599,6 +620,7 @@ class AccountActivity : BottomSheetActivity(), ActionButtonActivity, HasAndroidI
|
||||
if (blocking || viewModel.isSelf) {
|
||||
accountFloatingActionButton.hide()
|
||||
accountMuteButton.hide()
|
||||
accountSubscribeButton.hide()
|
||||
} else {
|
||||
accountFloatingActionButton.show()
|
||||
if (muting)
|
||||
@ -612,6 +634,7 @@ class AccountActivity : BottomSheetActivity(), ActionButtonActivity, HasAndroidI
|
||||
accountFloatingActionButton.hide()
|
||||
accountFollowButton.hide()
|
||||
accountMuteButton.hide()
|
||||
accountSubscribeButton.hide()
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -18,4 +18,4 @@ data class ProfileEditedEvent(val newProfileData: Account) : Dispatchable
|
||||
data class PreferenceChangedEvent(val preferenceKey: String) : Dispatchable
|
||||
data class MainTabsChangedEvent(val newTabs: List<TabData>) : Dispatchable
|
||||
data class PollVoteEvent(val statusId: String, val poll: Poll) : Dispatchable
|
||||
data class DomainMuteEvent(val instance: String): Dispatchable
|
||||
data class DomainMuteEvent(val instance: String): Dispatchable
|
||||
|
@ -155,6 +155,14 @@ class AccountViewModel @Inject constructor(
|
||||
changeRelationship(RelationShipAction.MUTE)
|
||||
}
|
||||
}
|
||||
|
||||
fun changeSubscribingState() {
|
||||
if (relationshipData.value?.data?.subscribing == true) {
|
||||
changeRelationship(RelationShipAction.UNSUBSCRIBE)
|
||||
} else {
|
||||
changeRelationship(RelationShipAction.SUBSCRIBE)
|
||||
}
|
||||
}
|
||||
|
||||
fun muteDomain(instance: String) {
|
||||
mastodonApi.blockDomain(instance).enqueue(object: Callback<Any> {
|
||||
@ -200,6 +208,8 @@ class AccountViewModel @Inject constructor(
|
||||
RelationShipAction.UNBLOCK -> relation.copy(blocking = false)
|
||||
RelationShipAction.MUTE -> relation.copy(muting = true)
|
||||
RelationShipAction.UNMUTE -> relation.copy(muting = false)
|
||||
RelationShipAction.SUBSCRIBE -> relation.copy(subscribing = true)
|
||||
RelationShipAction.UNSUBSCRIBE -> relation.copy(subscribing = false)
|
||||
}
|
||||
relationshipData.postValue(Loading(newRelation))
|
||||
}
|
||||
@ -237,6 +247,8 @@ class AccountViewModel @Inject constructor(
|
||||
RelationShipAction.UNBLOCK -> mastodonApi.unblockAccount(accountId)
|
||||
RelationShipAction.MUTE -> mastodonApi.muteAccount(accountId)
|
||||
RelationShipAction.UNMUTE -> mastodonApi.unmuteAccount(accountId)
|
||||
RelationShipAction.SUBSCRIBE -> mastodonApi.subscribeAccount(accountId)
|
||||
RelationShipAction.UNSUBSCRIBE -> mastodonApi.unsubscribeAccount(accountId)
|
||||
}
|
||||
|
||||
call.enqueue(callback)
|
||||
@ -274,10 +286,10 @@ class AccountViewModel @Inject constructor(
|
||||
}
|
||||
|
||||
enum class RelationShipAction {
|
||||
FOLLOW, UNFOLLOW, BLOCK, UNBLOCK, MUTE, UNMUTE
|
||||
FOLLOW, UNFOLLOW, BLOCK, UNBLOCK, MUTE, UNMUTE, SUBSCRIBE, UNSUBSCRIBE
|
||||
}
|
||||
|
||||
companion object {
|
||||
const val TAG = "AccountViewModel"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
13
app/src/main/res/drawable/ic_notifications_active_24dp.xml
Normal file
13
app/src/main/res/drawable/ic_notifications_active_24dp.xml
Normal file
@ -0,0 +1,13 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:width="24dp"
|
||||
android:height="24dp"
|
||||
android:viewportWidth="24"
|
||||
android:viewportHeight="24">
|
||||
|
||||
<path
|
||||
android:pathData="M0 0h24v24H0V0z" />
|
||||
<path
|
||||
android:fillColor="#000000"
|
||||
android:pathData="M18 16v-5c0-3.07-1.64-5.64-4.5-6.32V4c0-0.83-0.68-1.5-1.51-1.5S10.5 3.17 10.5 4v0.68C7.63 5.36 6 7.92 6 11v5l-1.3 1.29c-0.63 0.63 -0.19 1.71 0.7 1.71h13.17c0.89 0 1.34-1.08 0.71 -1.71L18 16zm-6.01 6c1.1 0 2-0.9 2-2h-4c0 1.1 0.89 2 2 2zM6.77 4.73c0.42-0.38 0.43 -1.03 0.03 -1.43-0.38-0.38-1-0.39-1.39-0.02C3.7 4.84 2.52 6.96 2.14 9.34c-0.09 0.61 0.38 1.16 1 1.16 0.48 0 0.9-0.35 0.98 -0.83 0.3 -1.94 1.26-3.67 2.65-4.94zM18.6 3.28c-0.4-0.37-1.02-0.36-1.4 0.02 -0.4 0.4 -0.38 1.04 0.03 1.42 1.38 1.27 2.35 3 2.65 4.94 0.07 0.48 0.49 0.83 0.98 0.83 0.61 0 1.09-0.55 0.99 -1.16-0.38-2.37-1.55-4.48-3.25-6.05z" />
|
||||
</vector>
|
@ -71,6 +71,26 @@
|
||||
app:layout_constraintStart_toEndOf="@id/accountMuteButton"
|
||||
app:layout_constraintTop_toTopOf="parent"
|
||||
tools:text="Follow Requested" />
|
||||
|
||||
<com.google.android.material.button.MaterialButton
|
||||
android:id="@+id/accountSubscribeButton"
|
||||
style="@style/TuskyButton.Outlined"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="0dp"
|
||||
android:layout_marginStart="16dp"
|
||||
android:layout_marginEnd="6dp"
|
||||
android:minWidth="0dp"
|
||||
android:paddingStart="8dp"
|
||||
android:paddingEnd="4dp"
|
||||
android:scaleType="centerInside"
|
||||
app:icon="@drawable/ic_notifications_24dp"
|
||||
app:layout_constrainedHeight="true"
|
||||
app:layout_constraintBottom_toBottomOf="@+id/accountFollowButton"
|
||||
app:layout_constraintEnd_toStartOf="@id/accountFollowButton"
|
||||
app:layout_constraintHorizontal_bias="1"
|
||||
app:layout_constraintHorizontal_chainStyle="packed"
|
||||
app:layout_constraintStart_toStartOf="@id/accountMuteButton"
|
||||
app:layout_constraintTop_toTopOf="@+id/accountFollowButton" />
|
||||
|
||||
<com.google.android.material.button.MaterialButton
|
||||
android:id="@+id/accountMuteButton"
|
||||
@ -86,7 +106,7 @@
|
||||
app:icon="@drawable/ic_unmute_24dp"
|
||||
app:layout_constrainedHeight="true"
|
||||
app:layout_constraintBottom_toBottomOf="@+id/accountFollowButton"
|
||||
app:layout_constraintEnd_toStartOf="@id/accountFollowButton"
|
||||
app:layout_constraintEnd_toStartOf="@id/accountSubscribeButton"
|
||||
app:layout_constraintHorizontal_bias="1"
|
||||
app:layout_constraintHorizontal_chainStyle="packed"
|
||||
app:layout_constraintStart_toStartOf="@id/guideAvatar"
|
||||
|
Loading…
Reference in New Issue
Block a user