Migrate to MaterialAlertDialog everywhere
Signed-off-by: Aayush Gupta <aayushgupta219@gmail.com>
This commit is contained in:
parent
033498aa17
commit
cdcb862d9d
7 changed files with 18 additions and 17 deletions
|
@ -14,12 +14,12 @@ import android.view.WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON
|
||||||
import android.widget.Button
|
import android.widget.Button
|
||||||
import android.widget.ProgressBar
|
import android.widget.ProgressBar
|
||||||
import android.widget.TextView
|
import android.widget.TextView
|
||||||
import androidx.appcompat.app.AlertDialog
|
|
||||||
import androidx.core.content.ContextCompat.getColor
|
import androidx.core.content.ContextCompat.getColor
|
||||||
import androidx.fragment.app.Fragment
|
import androidx.fragment.app.Fragment
|
||||||
import androidx.lifecycle.lifecycleScope
|
import androidx.lifecycle.lifecycleScope
|
||||||
import androidx.recyclerview.widget.LinearLayoutManager
|
import androidx.recyclerview.widget.LinearLayoutManager
|
||||||
import androidx.recyclerview.widget.RecyclerView
|
import androidx.recyclerview.widget.RecyclerView
|
||||||
|
import com.google.android.material.dialog.MaterialAlertDialogBuilder
|
||||||
import com.stevesoltys.seedvault.R
|
import com.stevesoltys.seedvault.R
|
||||||
import com.stevesoltys.seedvault.ui.AppBackupState.FAILED_NOT_INSTALLED
|
import com.stevesoltys.seedvault.ui.AppBackupState.FAILED_NOT_INSTALLED
|
||||||
import org.koin.androidx.viewmodel.ext.android.sharedViewModel
|
import org.koin.androidx.viewmodel.ext.android.sharedViewModel
|
||||||
|
@ -99,7 +99,7 @@ class RestoreProgressFragment : Fragment() {
|
||||||
// check if any restore failed, because the app is not installed
|
// check if any restore failed, because the app is not installed
|
||||||
val failed = viewModel.restoreProgress.value?.any { it.state == FAILED_NOT_INSTALLED }
|
val failed = viewModel.restoreProgress.value?.any { it.state == FAILED_NOT_INSTALLED }
|
||||||
if (failed != true) return // nothing left to do if there's no failures due to not installed
|
if (failed != true) return // nothing left to do if there's no failures due to not installed
|
||||||
AlertDialog.Builder(requireContext())
|
MaterialAlertDialogBuilder(requireContext())
|
||||||
.setTitle(R.string.restore_restoring_error_title)
|
.setTitle(R.string.restore_restoring_error_title)
|
||||||
.setMessage(R.string.restore_restoring_error_message)
|
.setMessage(R.string.restore_restoring_error_message)
|
||||||
.setPositiveButton(android.R.string.ok) { dialog, _ ->
|
.setPositiveButton(android.R.string.ok) { dialog, _ ->
|
||||||
|
|
|
@ -19,11 +19,11 @@ import android.widget.TextView
|
||||||
import android.widget.Toast
|
import android.widget.Toast
|
||||||
import android.widget.Toast.LENGTH_LONG
|
import android.widget.Toast.LENGTH_LONG
|
||||||
import androidx.activity.result.contract.ActivityResultContract
|
import androidx.activity.result.contract.ActivityResultContract
|
||||||
import androidx.appcompat.app.AlertDialog
|
|
||||||
import androidx.fragment.app.Fragment
|
import androidx.fragment.app.Fragment
|
||||||
import androidx.lifecycle.lifecycleScope
|
import androidx.lifecycle.lifecycleScope
|
||||||
import androidx.recyclerview.widget.LinearLayoutManager
|
import androidx.recyclerview.widget.LinearLayoutManager
|
||||||
import androidx.recyclerview.widget.RecyclerView
|
import androidx.recyclerview.widget.RecyclerView
|
||||||
|
import com.google.android.material.dialog.MaterialAlertDialogBuilder
|
||||||
import com.stevesoltys.seedvault.R
|
import com.stevesoltys.seedvault.R
|
||||||
import com.stevesoltys.seedvault.restore.RestoreViewModel
|
import com.stevesoltys.seedvault.restore.RestoreViewModel
|
||||||
import org.koin.androidx.viewmodel.ext.android.sharedViewModel
|
import org.koin.androidx.viewmodel.ext.android.sharedViewModel
|
||||||
|
@ -96,7 +96,7 @@ class InstallProgressFragment : Fragment(), InstallItemListener {
|
||||||
adapter.setFinished()
|
adapter.setFinished()
|
||||||
button.isEnabled = true
|
button.isEnabled = true
|
||||||
if (!hasShownFailDialog && installResult.hasFailed) {
|
if (!hasShownFailDialog && installResult.hasFailed) {
|
||||||
AlertDialog.Builder(requireContext())
|
MaterialAlertDialogBuilder(requireContext())
|
||||||
.setIcon(R.drawable.ic_warning)
|
.setIcon(R.drawable.ic_warning)
|
||||||
.setTitle(R.string.restore_installing_error_title)
|
.setTitle(R.string.restore_installing_error_title)
|
||||||
.setMessage(R.string.restore_installing_error_message)
|
.setMessage(R.string.restore_installing_error_message)
|
||||||
|
|
|
@ -19,12 +19,12 @@ import android.view.MenuItem
|
||||||
import android.view.View
|
import android.view.View
|
||||||
import android.widget.Toast
|
import android.widget.Toast
|
||||||
import android.widget.Toast.LENGTH_LONG
|
import android.widget.Toast.LENGTH_LONG
|
||||||
import androidx.appcompat.app.AlertDialog
|
|
||||||
import androidx.preference.Preference
|
import androidx.preference.Preference
|
||||||
import androidx.preference.Preference.OnPreferenceChangeListener
|
import androidx.preference.Preference.OnPreferenceChangeListener
|
||||||
import androidx.preference.PreferenceFragmentCompat
|
import androidx.preference.PreferenceFragmentCompat
|
||||||
import androidx.preference.TwoStatePreference
|
import androidx.preference.TwoStatePreference
|
||||||
import androidx.work.WorkInfo
|
import androidx.work.WorkInfo
|
||||||
|
import com.google.android.material.dialog.MaterialAlertDialogBuilder
|
||||||
import com.stevesoltys.seedvault.R
|
import com.stevesoltys.seedvault.R
|
||||||
import com.stevesoltys.seedvault.permitDiskReads
|
import com.stevesoltys.seedvault.permitDiskReads
|
||||||
import com.stevesoltys.seedvault.plugins.StoragePluginManager
|
import com.stevesoltys.seedvault.plugins.StoragePluginManager
|
||||||
|
@ -77,7 +77,7 @@ class SettingsFragment : PreferenceFragmentCompat() {
|
||||||
when (enabled) {
|
when (enabled) {
|
||||||
true -> return@OnPreferenceChangeListener trySetBackupEnabled(true)
|
true -> return@OnPreferenceChangeListener trySetBackupEnabled(true)
|
||||||
false -> {
|
false -> {
|
||||||
AlertDialog.Builder(requireContext())
|
MaterialAlertDialogBuilder(requireContext())
|
||||||
.setIcon(R.drawable.ic_warning)
|
.setIcon(R.drawable.ic_warning)
|
||||||
.setTitle(R.string.settings_backup_dialog_title)
|
.setTitle(R.string.settings_backup_dialog_title)
|
||||||
.setMessage(R.string.settings_backup_dialog_message)
|
.setMessage(R.string.settings_backup_dialog_message)
|
||||||
|
@ -123,7 +123,7 @@ class SettingsFragment : PreferenceFragmentCompat() {
|
||||||
apkBackup.onPreferenceChangeListener = OnPreferenceChangeListener { _, newValue ->
|
apkBackup.onPreferenceChangeListener = OnPreferenceChangeListener { _, newValue ->
|
||||||
val enable = newValue as Boolean
|
val enable = newValue as Boolean
|
||||||
if (enable) return@OnPreferenceChangeListener true
|
if (enable) return@OnPreferenceChangeListener true
|
||||||
AlertDialog.Builder(requireContext())
|
MaterialAlertDialogBuilder(requireContext())
|
||||||
.setIcon(R.drawable.ic_warning)
|
.setIcon(R.drawable.ic_warning)
|
||||||
.setTitle(R.string.settings_backup_apk_dialog_title)
|
.setTitle(R.string.settings_backup_apk_dialog_title)
|
||||||
.setMessage(R.string.settings_backup_apk_dialog_message)
|
.setMessage(R.string.settings_backup_apk_dialog_message)
|
||||||
|
@ -313,7 +313,7 @@ class SettingsFragment : PreferenceFragmentCompat() {
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun onEnablingStorageBackup() {
|
private fun onEnablingStorageBackup() {
|
||||||
AlertDialog.Builder(requireContext())
|
MaterialAlertDialogBuilder(requireContext())
|
||||||
.setIcon(R.drawable.ic_warning)
|
.setIcon(R.drawable.ic_warning)
|
||||||
.setTitle(R.string.settings_backup_storage_dialog_title)
|
.setTitle(R.string.settings_backup_storage_dialog_title)
|
||||||
.setMessage(R.string.settings_backup_storage_dialog_message)
|
.setMessage(R.string.settings_backup_storage_dialog_message)
|
||||||
|
@ -341,7 +341,7 @@ class SettingsFragment : PreferenceFragmentCompat() {
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun showCodeRegenerationNeededDialog() {
|
private fun showCodeRegenerationNeededDialog() {
|
||||||
AlertDialog.Builder(requireContext())
|
MaterialAlertDialogBuilder(requireContext())
|
||||||
.setIcon(R.drawable.ic_vpn_key)
|
.setIcon(R.drawable.ic_vpn_key)
|
||||||
.setTitle(R.string.settings_backup_new_code_dialog_title)
|
.setTitle(R.string.settings_backup_new_code_dialog_title)
|
||||||
.setMessage(R.string.settings_backup_new_code_dialog_message)
|
.setMessage(R.string.settings_backup_new_code_dialog_message)
|
||||||
|
|
|
@ -27,13 +27,13 @@ import android.widget.TextView
|
||||||
import android.widget.Toast
|
import android.widget.Toast
|
||||||
import android.widget.Toast.LENGTH_LONG
|
import android.widget.Toast.LENGTH_LONG
|
||||||
import androidx.activity.result.contract.ActivityResultContracts.StartActivityForResult
|
import androidx.activity.result.contract.ActivityResultContracts.StartActivityForResult
|
||||||
import androidx.appcompat.app.AlertDialog
|
|
||||||
import androidx.constraintlayout.widget.ConstraintLayout
|
import androidx.constraintlayout.widget.ConstraintLayout
|
||||||
import androidx.core.content.ContextCompat.getMainExecutor
|
import androidx.core.content.ContextCompat.getMainExecutor
|
||||||
import androidx.fragment.app.Fragment
|
import androidx.fragment.app.Fragment
|
||||||
import cash.z.ecc.android.bip39.Mnemonics
|
import cash.z.ecc.android.bip39.Mnemonics
|
||||||
import cash.z.ecc.android.bip39.Mnemonics.ChecksumException
|
import cash.z.ecc.android.bip39.Mnemonics.ChecksumException
|
||||||
import cash.z.ecc.android.bip39.Mnemonics.InvalidWordException
|
import cash.z.ecc.android.bip39.Mnemonics.InvalidWordException
|
||||||
|
import com.google.android.material.dialog.MaterialAlertDialogBuilder
|
||||||
import com.google.android.material.snackbar.Snackbar
|
import com.google.android.material.snackbar.Snackbar
|
||||||
import com.google.android.material.textfield.TextInputLayout
|
import com.google.android.material.textfield.TextInputLayout
|
||||||
import com.stevesoltys.seedvault.R
|
import com.stevesoltys.seedvault.R
|
||||||
|
@ -207,7 +207,7 @@ class RecoveryCodeInputFragment : Fragment() {
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun onExistingCodeChecked(verified: Boolean) {
|
private fun onExistingCodeChecked(verified: Boolean) {
|
||||||
AlertDialog.Builder(requireContext()).apply {
|
MaterialAlertDialogBuilder(requireContext()).apply {
|
||||||
if (verified) {
|
if (verified) {
|
||||||
setTitle(R.string.recovery_code_verification_ok_title)
|
setTitle(R.string.recovery_code_verification_ok_title)
|
||||||
setMessage(R.string.recovery_code_verification_ok_message)
|
setMessage(R.string.recovery_code_verification_ok_message)
|
||||||
|
@ -237,7 +237,7 @@ class RecoveryCodeInputFragment : Fragment() {
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun generateNewCode() {
|
private fun generateNewCode() {
|
||||||
AlertDialog.Builder(requireContext())
|
MaterialAlertDialogBuilder(requireContext())
|
||||||
.setIcon(R.drawable.ic_warning)
|
.setIcon(R.drawable.ic_warning)
|
||||||
.setTitle(R.string.recovery_code_verification_new_dialog_title)
|
.setTitle(R.string.recovery_code_verification_new_dialog_title)
|
||||||
.setMessage(R.string.recovery_code_verification_new_dialog_message)
|
.setMessage(R.string.recovery_code_verification_new_dialog_message)
|
||||||
|
|
|
@ -16,7 +16,7 @@ import android.net.Uri
|
||||||
import android.os.Bundle
|
import android.os.Bundle
|
||||||
import androidx.activity.result.contract.ActivityResultContracts.OpenDocumentTree
|
import androidx.activity.result.contract.ActivityResultContracts.OpenDocumentTree
|
||||||
import androidx.annotation.CallSuper
|
import androidx.annotation.CallSuper
|
||||||
import androidx.appcompat.app.AlertDialog
|
import com.google.android.material.dialog.MaterialAlertDialogBuilder
|
||||||
import com.stevesoltys.seedvault.R
|
import com.stevesoltys.seedvault.R
|
||||||
import com.stevesoltys.seedvault.plugins.saf.StorageRootResolver
|
import com.stevesoltys.seedvault.plugins.saf.StorageRootResolver
|
||||||
import com.stevesoltys.seedvault.ui.BackupActivity
|
import com.stevesoltys.seedvault.ui.BackupActivity
|
||||||
|
@ -89,7 +89,7 @@ class StorageActivity : BackupActivity() {
|
||||||
|
|
||||||
private fun onInvalidLocation(errorMsg: String) {
|
private fun onInvalidLocation(errorMsg: String) {
|
||||||
if (viewModel.isRestoreOperation) {
|
if (viewModel.isRestoreOperation) {
|
||||||
val dialog = AlertDialog.Builder(this)
|
val dialog = MaterialAlertDialogBuilder(this)
|
||||||
.setTitle(getString(R.string.restore_invalid_location_title))
|
.setTitle(getString(R.string.restore_invalid_location_title))
|
||||||
.setMessage(errorMsg)
|
.setMessage(errorMsg)
|
||||||
.setPositiveButton(android.R.string.ok) { dialog, _ -> dialog.dismiss() }
|
.setPositiveButton(android.R.string.ok) { dialog, _ -> dialog.dismiss() }
|
||||||
|
|
|
@ -15,9 +15,9 @@ import android.view.View.VISIBLE
|
||||||
import android.view.ViewGroup
|
import android.view.ViewGroup
|
||||||
import android.widget.ImageView
|
import android.widget.ImageView
|
||||||
import android.widget.TextView
|
import android.widget.TextView
|
||||||
import androidx.appcompat.app.AlertDialog
|
|
||||||
import androidx.recyclerview.widget.RecyclerView.Adapter
|
import androidx.recyclerview.widget.RecyclerView.Adapter
|
||||||
import androidx.recyclerview.widget.RecyclerView.ViewHolder
|
import androidx.recyclerview.widget.RecyclerView.ViewHolder
|
||||||
|
import com.google.android.material.dialog.MaterialAlertDialogBuilder
|
||||||
import com.stevesoltys.seedvault.R
|
import com.stevesoltys.seedvault.R
|
||||||
import com.stevesoltys.seedvault.ui.storage.StorageOption.SafOption
|
import com.stevesoltys.seedvault.ui.storage.StorageOption.SafOption
|
||||||
import com.stevesoltys.seedvault.ui.storage.StorageOptionAdapter.StorageOptionViewHolder
|
import com.stevesoltys.seedvault.ui.storage.StorageOptionAdapter.StorageOptionViewHolder
|
||||||
|
@ -91,7 +91,7 @@ internal class StorageOptionAdapter(
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun showWarningDialog(context: Context, item: StorageOption) {
|
private fun showWarningDialog(context: Context, item: StorageOption) {
|
||||||
AlertDialog.Builder(context)
|
MaterialAlertDialogBuilder(context)
|
||||||
.setTitle(R.string.storage_internal_warning_title)
|
.setTitle(R.string.storage_internal_warning_title)
|
||||||
.setMessage(R.string.storage_internal_warning_message)
|
.setMessage(R.string.storage_internal_warning_message)
|
||||||
.setPositiveButton(R.string.storage_internal_warning_choose_other) { dialog, _ ->
|
.setPositiveButton(R.string.storage_internal_warning_choose_other) { dialog, _ ->
|
||||||
|
|
|
@ -19,6 +19,7 @@ import android.widget.Toast
|
||||||
import android.widget.Toast.LENGTH_SHORT
|
import android.widget.Toast.LENGTH_SHORT
|
||||||
import androidx.appcompat.app.AlertDialog
|
import androidx.appcompat.app.AlertDialog
|
||||||
import androidx.fragment.app.activityViewModels
|
import androidx.fragment.app.activityViewModels
|
||||||
|
import com.google.android.material.dialog.MaterialAlertDialogBuilder
|
||||||
import de.grobox.storagebackuptester.MainViewModel
|
import de.grobox.storagebackuptester.MainViewModel
|
||||||
import de.grobox.storagebackuptester.R
|
import de.grobox.storagebackuptester.R
|
||||||
import de.grobox.storagebackuptester.restore.DemoSnapshotFragment
|
import de.grobox.storagebackuptester.restore.DemoSnapshotFragment
|
||||||
|
@ -133,7 +134,7 @@ class SettingsFragment : BackupContentFragment() {
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun onRestoreClicked() {
|
private fun onRestoreClicked() {
|
||||||
AlertDialog.Builder(requireContext())
|
MaterialAlertDialogBuilder(requireContext())
|
||||||
.setIcon(android.R.drawable.stat_sys_warning)
|
.setIcon(android.R.drawable.stat_sys_warning)
|
||||||
.setTitle("Warning")
|
.setTitle("Warning")
|
||||||
.setMessage("This will override data and should only be used on a clean phone. Not the one you just made the backup on.")
|
.setMessage("This will override data and should only be used on a clean phone. Not the one you just made the backup on.")
|
||||||
|
|
Loading…
Reference in a new issue