|
|
@ -4,10 +4,14 @@ import android.app.ActivityManager |
|
|
|
import android.app.Dialog |
|
|
|
import android.content.Context |
|
|
|
import android.text.Html |
|
|
|
import android.util.Log |
|
|
|
import androidx.annotation.StringRes |
|
|
|
import androidx.core.content.getSystemService |
|
|
|
import cash.z.ecc.android.R |
|
|
|
import cash.z.ecc.android.feedback.Report |
|
|
|
import cash.z.ecc.android.ui.scan.ScanFragment |
|
|
|
import com.google.android.material.dialog.MaterialAlertDialogBuilder |
|
|
|
import kotlin.system.exitProcess |
|
|
|
|
|
|
|
fun Context.showClearDataConfirmation(onDismiss: () -> Unit = {}, onCancel: () -> Unit = {}): Dialog { |
|
|
|
return MaterialAlertDialogBuilder(this) |
|
|
@ -88,6 +92,24 @@ fun Context.showCriticalMessage(@StringRes titleResId: Int, @StringRes messageRe |
|
|
|
} |
|
|
|
|
|
|
|
fun Context.showCriticalMessage(title: String, message: String, onDismiss: () -> Unit = {}): Dialog { |
|
|
|
Log.d("SilentDragon", "showCriticalMessage called: $message") |
|
|
|
|
|
|
|
var delimiter = ":" |
|
|
|
val splitError = message.split(delimiter) |
|
|
|
var pluckedError = splitError[0] |
|
|
|
|
|
|
|
if(pluckedError == "UNAVAILABLE"){ |
|
|
|
return MaterialAlertDialogBuilder(this) |
|
|
|
.setTitle("Server Unavailable") |
|
|
|
.setMessage("Please close and restart the app to try another random server.") |
|
|
|
.setCancelable(false) |
|
|
|
.setNegativeButton("Exit") { dialog, _ -> |
|
|
|
dialog.dismiss() |
|
|
|
exitProcess(0) |
|
|
|
} |
|
|
|
.show() |
|
|
|
} |
|
|
|
|
|
|
|
return MaterialAlertDialogBuilder(this) |
|
|
|
.setTitle(title) |
|
|
|
.setMessage(message) |
|
|
|