Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add a feature and preference to confirm follows. #4445

Merged
merged 2 commits into from
May 13, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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()
Expand Down Expand Up @@ -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)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
2 changes: 2 additions & 0 deletions app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -265,6 +265,7 @@
<string name="dialog_download_image">Download</string>
<string name="dialog_message_cancel_follow_request">Revoke the follow request?</string>
<string name="dialog_unfollow_warning">Unfollow this account?</string>
<string name="dialog_follow_warning">Follow this account?</string>
<string name="dialog_delete_post_warning">Delete this post?</string>
<string name="dialog_redraft_post_warning">Delete and re-draft this post?</string>
<string name="dialog_delete_conversation_warning">Delete this conversation?</string>
Expand Down Expand Up @@ -720,6 +721,7 @@
<string name="pref_title_show_cards_in_timelines">Show link previews in timelines</string>
<string name="pref_title_confirm_reblogs">Show confirmation before boosting</string>
<string name="pref_title_confirm_favourites">Show confirmation before favoriting</string>
<string name="pref_title_confirm_follows">Show confirmation before following</string>
<string name="pref_title_hide_top_toolbar">Hide the title of the top toolbar</string>
<string name="pref_title_wellbeing_mode">Wellbeing</string>
<string name="account_note_hint">Your private note about this account</string>
Expand Down
Loading