Add a feature and preference to confirm follows. (#4445)

This means a popup will appear if you have that option enabled in the
preferences which will have a popup similar to the unfollow dialog
asking you if you want to follow the user.
This commit is contained in:
fries1234 2024-05-13 10:02:21 -07:00 committed by GitHub
commit a690b537c2
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 25 additions and 1 deletions

View file

@ -675,6 +675,8 @@ class AccountActivity : BottomSheetActivity(), ActionButtonActivity, MenuProvide
binding.accountFloatingActionButton.setOnClickListener { mention() }
binding.accountFollowButton.setOnClickListener {
val preferences = PreferenceManager.getDefaultSharedPreferences(this)
val confirmFollows = preferences.getBoolean(PrefKeys.CONFIRM_FOLLOWS, false)
if (viewModel.isSelf) {
val intent = Intent(this@AccountActivity, EditProfileActivity::class.java)
startActivity(intent)
@ -688,7 +690,11 @@ class AccountActivity : BottomSheetActivity(), ActionButtonActivity, MenuProvide
when (followState) {
FollowState.NOT_FOLLOWING -> {
viewModel.changeFollowState()
if (confirmFollows) {
showFollowWarningDialog()
} else {
viewModel.changeFollowState()
}
}
FollowState.REQUESTED -> {
showFollowRequestPendingDialog()
@ -908,6 +914,14 @@ class AccountActivity : BottomSheetActivity(), ActionButtonActivity, MenuProvide
.show()
}
private fun showFollowWarningDialog() {
AlertDialog.Builder(this)
.setMessage(R.string.dialog_follow_warning)
.setPositiveButton(android.R.string.ok) { _, _ -> viewModel.changeFollowState() }
.setNegativeButton(android.R.string.cancel, null)
.show()
}
private fun toggleBlockDomain(instance: String) {
if (blockingDomain) {
viewModel.unblockDomain(instance)

View file

@ -241,6 +241,13 @@ class PreferencesFragment : PreferenceFragmentCompat() {
isSingleLineTitle = false
}
switchPreference {
setDefaultValue(false)
key = PrefKeys.CONFIRM_FOLLOWS
setTitle(R.string.pref_title_confirm_follows)
isSingleLineTitle = false
}
switchPreference {
setDefaultValue(true)
key = PrefKeys.ENABLE_SWIPE_FOR_TABS

View file

@ -71,6 +71,7 @@ object PrefKeys {
const val SHOW_CARDS_IN_TIMELINES = "showCardsInTimelines"
const val CONFIRM_REBLOGS = "confirmReblogs"
const val CONFIRM_FAVOURITES = "confirmFavourites"
const val CONFIRM_FOLLOWS = "confirmFollows"
const val ENABLE_SWIPE_FOR_TABS = "enableSwipeForTabs"
const val ANIMATE_CUSTOM_EMOJIS = "animateCustomEmojis"
const val SHOW_STATS_INLINE = "showStatsInline"