@ -9,13 +9,11 @@ import android.graphics.Bitmap
import android.graphics.Canvas
import android.graphics.Color
import android.net.Uri
import android.text.SpannableStringBuilder
import android.util.TypedValue
import android.view.View
import android.view.inputmethod.InputMethodManager
import android.widget.ImageView
import android.widget.LinearLayout
import android.widget.TextView
import android.widget.Toast
import android.widget.*
import androidx.appcompat.app.AlertDialog
import androidx.appcompat.widget.SearchView
import androidx.core.content.ContextCompat
@ -84,7 +82,11 @@ fun BaseActivity.openContactMail(subjectStringRes: Int, filePath: String? = null
filePath ?. let {
val databaseFile = File ( it )
val contentUri = FileProvider . getUriForFile ( this , " net.pokeranalytics.android.fileprovider " , databaseFile )
val contentUri = FileProvider . getUriForFile (
this ,
" net.pokeranalytics.android.fileprovider " ,
databaseFile
)
if ( contentUri != null ) {
emailIntent . addFlags ( Intent . FLAG _GRANT _READ _URI _PERMISSION )
emailIntent . setDataAndType ( contentUri , contentResolver . getType ( contentUri ) )
@ -107,7 +109,12 @@ fun Context.openUrl(url: String) {
}
// Open custom tab
fun Context . areYouSure ( title : Int ? = null , message : Int ? = null , positiveTitle : Int ? = null , proceed : ( ) -> Unit ) {
fun Context . areYouSure (
title : Int ? = null ,
message : Int ? = null ,
positiveTitle : Int ? = null ,
proceed : ( ) -> Unit
) {
val builder : android . app . AlertDialog . Builder = android . app . AlertDialog . Builder ( this )
@ -123,22 +130,7 @@ fun Context.areYouSure(title: Int? = null, message: Int? = null, positiveTitle:
builder . setNegativeButton ( R . string . cancel ) { _ , _ ->
// nothing
}
// builder.setItems(
// arrayOf<CharSequence>(
// getString(R.string.yes),
// getString(R.string.cancel)
// )
// ) { _, index ->
// // The 'which' argument contains the index position
// // of the selected item
// when (index) {
// 0 -> proceed()
// 1 -> {} // nothing
// }
// }
builder . create ( ) . show ( )
}
// Display Alert Dialog
@ -146,17 +138,52 @@ fun Activity.showAlertDialog(title: Int? = null, message: Int? = null) {
showAlertDialog ( this , title , message )
}
fun Fragment . showAlertDialog ( title : Int ? = null , messageResId : Int ? = null , message : String ? = null ) {
fun Fragment . showAlertDialog (
title : Int ? = null ,
messageResId : Int ? = null ,
message : String ? = null
) {
context ?. let {
showAlertDialog ( it , title , messageResId , message )
}
}
fun showEditTextAlertDialog (
context : Context , inputType : Int , title : Int ? = null , messageResId : Int ? = null , message : String ? = null ,
editTextText : String ? = null , positiveAction : ( ( String ) -> Unit ) ? = null
) {
val builder = AlertDialog . Builder ( context )
title ?. let {
builder . setTitle ( title )
}
messageResId ?. let {
builder . setMessage ( messageResId )
}
message ?. let {
builder . setMessage ( it )
}
val editText = EditText ( context )
editTextText ?. let {
editText . text = SpannableStringBuilder ( it )
}
editText . setTextColor ( ContextCompat . getColor ( context , R . color . white ) )
editText . inputType = inputType
builder . setView ( editText )
builder . setPositiveButton ( net . pokeranalytics . android . R . string . ok ) { _ , _ ->
positiveAction ?. invoke ( editText . text . toString ( ) )
}
builder . show ( )
}
/ * *
* Create and show an alert dialog
* /
fun showAlertDialog (
context : Context , title : Int ? = null , messageResId : Int ? = null , message : String ? = null , cancelButtonTitle : Int ? = null , showCancelButton : Boolean = false ,
context : Context , title : Int ? = null , messageResId : Int ? = null , message : String ? = null ,
cancelButtonTitle : Int ? = null , showCancelButton : Boolean = false ,
positiveAction : ( ( ) -> Unit ) ? = null , negativeAction : ( ( ) -> Unit ) ? = null
) {
val builder = AlertDialog . Builder ( context )