forked from upstream-mirrors/quik
Fix duplicate Matrix forwarding, contact names and bridge reset
Build and Release APK / Build APK (push) Successful in 12m11s
Build and Release APK / Build APK (push) Successful in 12m11s
This commit is contained in:
@@ -253,6 +253,7 @@ class SettingsController : QkController<SettingsControllerBinding, SettingsView,
|
||||
builder.setView(dialogView)
|
||||
builder.setPositiveButton("Log in", null) // Handled later to prevent auto-close
|
||||
builder.setNegativeButton("Cancel", null)
|
||||
builder.setNeutralButton(R.string.matrix_reset) { _, _ -> showMatrixResetDialog() }
|
||||
val dialog = builder.create()
|
||||
dialog.setOnShowListener {
|
||||
val loginBtn = dialog.getButton(androidx.appcompat.app.AlertDialog.BUTTON_POSITIVE)
|
||||
@@ -270,6 +271,15 @@ class SettingsController : QkController<SettingsControllerBinding, SettingsView,
|
||||
return@setOnClickListener
|
||||
}
|
||||
|
||||
fun setLoginBusy(busy: Boolean) {
|
||||
dialog.setCancelable(!busy)
|
||||
listOf(androidx.appcompat.app.AlertDialog.BUTTON_POSITIVE,
|
||||
androidx.appcompat.app.AlertDialog.BUTTON_NEGATIVE,
|
||||
androidx.appcompat.app.AlertDialog.BUTTON_NEUTRAL).forEach { button ->
|
||||
dialog.getButton(button).isEnabled = !busy
|
||||
}
|
||||
}
|
||||
setLoginBusy(true)
|
||||
ch.skew.remotrix.onLoginClick(
|
||||
context = activity!!,
|
||||
scope = kotlinx.coroutines.CoroutineScope(kotlinx.coroutines.Dispatchers.IO),
|
||||
@@ -282,6 +292,7 @@ class SettingsController : QkController<SettingsControllerBinding, SettingsView,
|
||||
abort = { errorMsg ->
|
||||
activity?.runOnUiThread {
|
||||
status.text = "Error: $errorMsg"
|
||||
setLoginBusy(false)
|
||||
}
|
||||
},
|
||||
onClickGoBack = {
|
||||
@@ -302,6 +313,38 @@ class SettingsController : QkController<SettingsControllerBinding, SettingsView,
|
||||
dialog.show()
|
||||
}
|
||||
|
||||
private fun showMatrixResetDialog() {
|
||||
val host = activity ?: return
|
||||
androidx.appcompat.app.AlertDialog.Builder(host)
|
||||
.setTitle(R.string.matrix_reset)
|
||||
.setMessage(R.string.matrix_reset_confirmation)
|
||||
.setNegativeButton(android.R.string.cancel, null)
|
||||
.setPositiveButton(R.string.matrix_reset) { _, _ ->
|
||||
val progress = androidx.appcompat.app.AlertDialog.Builder(host)
|
||||
.setMessage(R.string.matrix_reset_progress)
|
||||
.setCancelable(false)
|
||||
.show()
|
||||
val receiver = object : android.os.ResultReceiver(android.os.Handler(android.os.Looper.getMainLooper())) {
|
||||
override fun onReceiveResult(resultCode: Int, resultData: android.os.Bundle?) {
|
||||
progress.dismiss()
|
||||
val success = resultCode == ch.skew.remotrix.background.CommandService.RESET_SUCCESS
|
||||
if (success) prefs.matrixAccount.set("")
|
||||
android.widget.Toast.makeText(context, if (success) R.string.matrix_reset_success else R.string.matrix_reset_failure,
|
||||
android.widget.Toast.LENGTH_LONG).show()
|
||||
}
|
||||
}
|
||||
try {
|
||||
context.startService(android.content.Intent(context, ch.skew.remotrix.background.CommandService::class.java)
|
||||
.setAction(ch.skew.remotrix.background.CommandService.RESET_MATRIX)
|
||||
.putExtra(ch.skew.remotrix.background.CommandService.RESET_RESULT_RECEIVER, receiver))
|
||||
} catch (error: Exception) {
|
||||
progress.dismiss()
|
||||
android.widget.Toast.makeText(context, R.string.matrix_reset_failure, android.widget.Toast.LENGTH_LONG).show()
|
||||
}
|
||||
}
|
||||
.show()
|
||||
}
|
||||
|
||||
override fun showMmsSizePicker() = mmsSizeDialog.show(activity!!)
|
||||
|
||||
override fun showMessageLinkHandlingDialogPicker() = messageLinkHandlingDialog.show(activity!!)
|
||||
|
||||
@@ -509,4 +509,9 @@
|
||||
<string name="deduplicating_messages_failed">Deduplikacja wiadomości nie powiodła się. Spróbuj ponownie</string>
|
||||
<string name="about_developer">Zespół wspaniałych ludzi z całego świata!</string>
|
||||
<string name="notification_foreground_worker_channel_name">Powiadomienie dla modułu obsługującego odbiór wiadomości</string>
|
||||
<string name="matrix_reset">Resetuj Matrix</string>
|
||||
<string name="matrix_reset_confirmation">Odłączyć wszystkie konta Matrix i usunąć powiązania pokoi z tego telefonu? Wiadomości SMS i ustawienia Quik zostaną zachowane. Zaloguj się ponownie, aby utworzyć nowe pokoje i skopiować historię SMS. Pokoje na serwerze Matrix nie zostaną usunięte.</string>
|
||||
<string name="matrix_reset_progress">Resetowanie Matrixa…</string>
|
||||
<string name="matrix_reset_success">Matrix został zresetowany. Możesz zalogować się ponownie.</string>
|
||||
<string name="matrix_reset_failure">Nie udało się zresetować Matrixa. Spróbuj ponownie.</string>
|
||||
</resources>
|
||||
|
||||
@@ -564,4 +564,9 @@
|
||||
<string name="stt_toast_extra_prompt">Speak your message</string>
|
||||
|
||||
<string name="messages_text_share_file_error">Oops! Something went wrong while sharing</string>
|
||||
<string name="matrix_reset">Reset Matrix</string>
|
||||
<string name="matrix_reset_confirmation">Disconnect all Matrix accounts and forget their linked rooms on this phone? Your SMS messages and Quik settings will be kept. Sign in again to create new rooms and copy SMS history. This does not delete rooms on the Matrix server.</string>
|
||||
<string name="matrix_reset_progress">Resetting Matrix…</string>
|
||||
<string name="matrix_reset_success">Matrix reset. You can sign in again.</string>
|
||||
<string name="matrix_reset_failure">Could not reset Matrix. Please try again.</string>
|
||||
</resources>
|
||||
|
||||
Reference in New Issue
Block a user