# HG changeset patch # User David Barts # Date 1614374670 28800 # Node ID 0023e6013dd9ea17157a2c9d39ce72fb54d6e1f2 # Parent aacf7a856b5f63394e018db1c0be25d8d39b62e9 Complete the deception that is my dummy main activity (hopefully). diff -r aacf7a856b5f -r 0023e6013dd9 app/src/main/java/com/bartsent/simpleresizer/MainActivity.kt --- a/app/src/main/java/com/bartsent/simpleresizer/MainActivity.kt Wed Feb 24 19:14:50 2021 -0800 +++ b/app/src/main/java/com/bartsent/simpleresizer/MainActivity.kt Fri Feb 26 13:24:30 2021 -0800 @@ -23,17 +23,14 @@ override fun onResume() { super.onResume() - if (showChooser) - doShowChooser() - else + if (showChooser) { + Intent(Intent.ACTION_GET_CONTENT).run { + type = "image/*" + addCategory(Intent.CATEGORY_OPENABLE) + startActivityForResult(this, GET_IMAGE) + } + } else { showChooser = true - } - - fun doShowChooser(): Unit { - Intent(Intent.ACTION_GET_CONTENT).run { - type = "image/*" - addCategory(Intent.CATEGORY_OPENABLE) - startActivityForResult(this, GET_IMAGE) } } @@ -46,10 +43,13 @@ Intent(Intent.ACTION_SEND, imageUri, this, EditImage::class.java).run { startActivity(this) } - } else { - Toast.makeText(applicationContext, "Unable to get image!", Toast.LENGTH_LONG).show() - doShowChooser() + return } } + // If we get here, it means that the user backed out of the file chooser. + // This should be interpreted as a desire to back out of editing an image + // altogether. So… goodbye! + showChooser = true // reset flag (paranoid) + finish() } -} \ No newline at end of file +}