2024-01-31 18:32:43 +01:00
|
|
|
package helium314.keyboard.latin.utils
|
2023-10-31 12:06:44 +01:00
|
|
|
|
|
|
|
import android.content.Context
|
|
|
|
import androidx.appcompat.app.AlertDialog
|
2024-01-01 19:20:28 +01:00
|
|
|
import androidx.appcompat.view.ContextThemeWrapper
|
2024-01-31 18:32:43 +01:00
|
|
|
import helium314.keyboard.latin.R
|
2023-10-31 12:06:44 +01:00
|
|
|
|
2024-01-01 19:20:28 +01:00
|
|
|
fun getPlatformDialogThemeContext(context: Context): Context {
|
|
|
|
// Because {@link AlertDialog.Builder.create()} doesn't honor the specified theme with
|
|
|
|
// createThemeContextWrapper=false, the result dialog box has unneeded paddings around it.
|
|
|
|
return ContextThemeWrapper(context, R.style.platformActivityTheme)
|
|
|
|
}
|
2023-10-31 12:06:44 +01:00
|
|
|
|
|
|
|
fun confirmDialog(context: Context, message: String, confirmButton: String, onConfirmed: (() -> Unit)) {
|
|
|
|
AlertDialog.Builder(context)
|
|
|
|
.setMessage(message)
|
|
|
|
.setNegativeButton(android.R.string.cancel, null)
|
|
|
|
.setPositiveButton(confirmButton) { _, _ -> onConfirmed() }
|
|
|
|
.show()
|
|
|
|
}
|
|
|
|
|
|
|
|
fun infoDialog(context: Context, messageId: Int) {
|
|
|
|
AlertDialog.Builder(context)
|
|
|
|
.setMessage(messageId)
|
|
|
|
.setNegativeButton(android.R.string.ok, null)
|
|
|
|
.show()
|
|
|
|
}
|
2024-01-01 19:20:28 +01:00
|
|
|
|
2023-10-31 12:06:44 +01:00
|
|
|
fun infoDialog(context: Context, message: String) {
|
|
|
|
AlertDialog.Builder(context)
|
|
|
|
.setMessage(message)
|
|
|
|
.setNegativeButton(android.R.string.ok, null)
|
|
|
|
.show()
|
|
|
|
}
|