Add Android Pie bug warning dialog

This commit is contained in:
Davide Depau 2018-09-30 22:51:48 +02:00
parent 23eec4ceb1
commit 474dbad1a8
Signed by: depau
GPG key ID: C7D999B6A55EFE86
3 changed files with 39 additions and 2 deletions

View file

@ -4,12 +4,14 @@ import android.Manifest
import android.content.Intent import android.content.Intent
import android.content.pm.PackageManager import android.content.pm.PackageManager
import android.net.Uri import android.net.Uri
import android.os.Build
import android.os.Bundle import android.os.Bundle
import android.os.Environment import android.os.Environment
import android.view.View import android.view.View
import androidx.appcompat.app.AppCompatActivity import androidx.appcompat.app.AppCompatActivity
import androidx.core.app.ActivityCompat import androidx.core.app.ActivityCompat
import androidx.core.content.ContextCompat import androidx.core.content.ContextCompat
import com.codekidlabs.storagechooser.StorageChooser
import eu.depau.etchdroid.R import eu.depau.etchdroid.R
import eu.depau.etchdroid.StateKeeper import eu.depau.etchdroid.StateKeeper
import eu.depau.etchdroid.enums.FlashMethod import eu.depau.etchdroid.enums.FlashMethod
@ -38,6 +40,19 @@ class StartActivity : ActivityBase() {
editor.apply() editor.apply()
} }
var shouldShowAndroidPieAlertDialog: Boolean
get() {
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.P)
return false
val settings = getSharedPreferences(DISMISSED_DIALOGS_PREFS, 0)
return !settings.getBoolean("Android_Pie_alert", false)
}
set(value) {
val settings = getSharedPreferences(DISMISSED_DIALOGS_PREFS, 0)
val editor = settings.edit()
editor.putBoolean("Android_Pie_alert", !value)
editor.apply()
}
override fun onCreate(savedInstanceState: Bundle?) { override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState) super.onCreate(savedInstanceState)
@ -75,7 +90,26 @@ class StartActivity : ActivityBase() {
dialogFragment.show(supportFragmentManager, "DMGBetaAlertDialogFragment") dialogFragment.show(supportFragmentManager, "DMGBetaAlertDialogFragment")
} }
fun showFilePicker() { fun showAndroidPieAlertDialog() {
val dialogFragment = DoNotShowAgainDialogFragment(nightModeHelper.nightMode)
dialogFragment.title = getString(R.string.android_pie_bug)
dialogFragment.message = getString(R.string.android_pie_bug_dialog_text)
dialogFragment.positiveButton = getString(R.string.i_understand)
dialogFragment.listener = object : DoNotShowAgainDialogFragment.DialogListener {
override fun onDialogNegative(dialog: DoNotShowAgainDialogFragment, showAgain: Boolean) {}
override fun onDialogPositive(dialog: DoNotShowAgainDialogFragment, showAgain: Boolean) {
shouldShowAndroidPieAlertDialog = showAgain
showFilePicker(false)
}
}
dialogFragment.show(supportFragmentManager, "DMGBetaAlertDialogFragment")
}
fun showFilePicker(showDialog: Boolean = true) {
if (showDialog && shouldShowAndroidPieAlertDialog) {
showAndroidPieAlertDialog()
return
}
when (StateKeeper.flashMethod) { when (StateKeeper.flashMethod) {
FlashMethod.FLASH_API -> { FlashMethod.FLASH_API -> {
val intent = Intent(Intent.ACTION_OPEN_DOCUMENT) val intent = Intent(Intent.ACTION_OPEN_DOCUMENT)
@ -159,7 +193,6 @@ class StartActivity : ActivityBase() {
} }
} }
fun nextStep() { fun nextStep() {
val intent = Intent(this, UsbDrivePickerActivity::class.java) val intent = Intent(this, UsbDrivePickerActivity::class.java)
startActivity(intent) startActivity(intent)

View file

@ -104,4 +104,6 @@
<string name="unknown_error">Errore sconosciuto. Prova a ricollegare il dispositivo USB o a riavviare il dispositivo. Per favore, segnala il problema su GitHub.</string> <string name="unknown_error">Errore sconosciuto. Prova a ricollegare il dispositivo USB o a riavviare il dispositivo. Per favore, segnala il problema su GitHub.</string>
<string name="uncompressed">(decompresso)</string> <string name="uncompressed">(decompresso)</string>
<string name="nightmode">Attiva modalità notturna</string> <string name="nightmode">Attiva modalità notturna</string>
<string name="android_pie_bug">Bug di Android Pie</string>
<string name="android_pie_bug_dialog_text">A causa di un bug di Android 9, alcune scritture potrebbero fallire.\nSe appare un messaggio di errore \"Scrittura fallita\", riavvia il dispositivo e prova di nuovo.</string>
</resources> </resources>

View file

@ -103,4 +103,6 @@
<string name="unknown_error">Unknown error. Try to reattach the USB drive or reboot the device. Please file an issue on GitHub.</string> <string name="unknown_error">Unknown error. Try to reattach the USB drive or reboot the device. Please file an issue on GitHub.</string>
<string name="uncompressed">(uncompressed)</string> <string name="uncompressed">(uncompressed)</string>
<string name="nightmode">Enable night mode</string> <string name="nightmode">Enable night mode</string>
<string name="android_pie_bug">Android Pie bug</string>
<string name="android_pie_bug_dialog_text">There is a bug on Android 9 which causes some writes to fail.\nIf it says \"Write failed\", reboot your device and try again.</string>
</resources> </resources>