mirror of
https://github.com/SchildiChat/SchildiChat-android.git
synced 2025-01-13 02:13:04 +01:00
Merge pull request #5649 from vector-im/hotfix/fre/rageshake_no_session
Replace "open settings" button by "disable" action in RageShake dialog if there is no session
This commit is contained in:
commit
45eb3bcbc5
1
changelog.d/4445.bugfix
Normal file
1
changelog.d/4445.bugfix
Normal file
@ -0,0 +1 @@
|
||||
Replace "open settings" button by "disable" action in RageShake dialog if there is no session
|
@ -24,6 +24,7 @@ import androidx.fragment.app.FragmentActivity
|
||||
import com.google.android.material.dialog.MaterialAlertDialogBuilder
|
||||
import com.squareup.seismic.ShakeDetector
|
||||
import im.vector.app.R
|
||||
import im.vector.app.core.di.ActiveSessionHolder
|
||||
import im.vector.app.core.hardware.vibrate
|
||||
import im.vector.app.features.navigation.Navigator
|
||||
import im.vector.app.features.settings.VectorPreferences
|
||||
@ -33,6 +34,7 @@ import javax.inject.Inject
|
||||
class RageShake @Inject constructor(private val activity: FragmentActivity,
|
||||
private val bugReporter: BugReporter,
|
||||
private val navigator: Navigator,
|
||||
private val sessionHolder: ActiveSessionHolder,
|
||||
private val vectorPreferences: VectorPreferences) : ShakeDetector.Listener {
|
||||
|
||||
private var shakeDetector: ShakeDetector? = null
|
||||
@ -75,7 +77,13 @@ class RageShake @Inject constructor(private val activity: FragmentActivity,
|
||||
MaterialAlertDialogBuilder(activity)
|
||||
.setMessage(R.string.send_bug_report_alert_message)
|
||||
.setPositiveButton(R.string.yes) { _, _ -> openBugReportScreen() }
|
||||
.setNeutralButton(R.string.settings) { _, _ -> openSettings() }
|
||||
.also {
|
||||
if (sessionHolder.hasActiveSession()) {
|
||||
it.setNeutralButton(R.string.settings) { _, _ -> openSettings() }
|
||||
} else {
|
||||
it.setNeutralButton(R.string.action_disable) { _, _ -> disableRageShake() }
|
||||
}
|
||||
}
|
||||
.setOnDismissListener { dialogDisplayed = false }
|
||||
.setNegativeButton(R.string.no, null)
|
||||
.show()
|
||||
@ -90,6 +98,11 @@ class RageShake @Inject constructor(private val activity: FragmentActivity,
|
||||
navigator.openSettings(activity, VectorSettingsActivity.EXTRA_DIRECT_ACCESS_ADVANCED_SETTINGS)
|
||||
}
|
||||
|
||||
private fun disableRageShake() {
|
||||
vectorPreferences.setRageshakeEnabled(false)
|
||||
stop()
|
||||
}
|
||||
|
||||
companion object {
|
||||
/**
|
||||
* Check if the feature is available
|
||||
|
@ -865,6 +865,17 @@ class VectorPreferences @Inject constructor(private val context: Context) {
|
||||
return defaultPrefs.getBoolean(SETTINGS_INTERFACE_BUBBLE_KEY, getDefault(R.bool.settings_interface_bubble_default))
|
||||
}
|
||||
|
||||
/**
|
||||
* Update the rage shake enabled status.
|
||||
*
|
||||
* @param isEnabled true to enable rage shake.
|
||||
*/
|
||||
fun setRageshakeEnabled(isEnabled: Boolean) {
|
||||
defaultPrefs.edit {
|
||||
putBoolean(SETTINGS_USE_RAGE_SHAKE_KEY, isEnabled)
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Tells if the rage shake is used.
|
||||
*
|
||||
|
@ -358,6 +358,7 @@
|
||||
<string name="action_switch">Switch</string>
|
||||
<string name="action_unpublish">Unpublish</string>
|
||||
<string name="action_enable">Enable</string>
|
||||
<string name="action_disable">Disable</string>
|
||||
<string name="action_not_now">Not now</string>
|
||||
<string name="action_agree">Agree</string>
|
||||
<string name="action_change">"Change"</string>
|
||||
|
Loading…
Reference in New Issue
Block a user