From 3e779c0a98bd874d1da90c338cbce0fac946306b Mon Sep 17 00:00:00 2001 From: tibbi Date: Tue, 6 Dec 2016 18:03:27 +0100 Subject: [PATCH] move some activity intent actions to SimpleActivity --- .../gallery/activities/MainActivity.kt | 6 +++--- .../gallery/activities/SimpleActivity.kt | 15 ++++++++++++++- 2 files changed, 17 insertions(+), 4 deletions(-) diff --git a/app/src/main/kotlin/com/simplemobiletools/gallery/activities/MainActivity.kt b/app/src/main/kotlin/com/simplemobiletools/gallery/activities/MainActivity.kt index e83983b23..7bd7bac29 100644 --- a/app/src/main/kotlin/com/simplemobiletools/gallery/activities/MainActivity.kt +++ b/app/src/main/kotlin/com/simplemobiletools/gallery/activities/MainActivity.kt @@ -78,7 +78,7 @@ class MainActivity : SimpleActivity(), DirectoryAdapter.DirOperationsListener { true } R.id.camera -> { - startActivity(Intent(MediaStore.INTENT_ACTION_STILL_IMAGE_CAMERA)) + launchCamera() true } R.id.show_all -> { @@ -86,11 +86,11 @@ class MainActivity : SimpleActivity(), DirectoryAdapter.DirOperationsListener { true } R.id.settings -> { - startActivity(Intent(applicationContext, SettingsActivity::class.java)) + launchSettings() true } R.id.about -> { - startActivity(Intent(applicationContext, AboutActivity::class.java)) + launchAbout() true } else -> super.onOptionsItemSelected(item) diff --git a/app/src/main/kotlin/com/simplemobiletools/gallery/activities/SimpleActivity.kt b/app/src/main/kotlin/com/simplemobiletools/gallery/activities/SimpleActivity.kt index 37c43bb4c..c7585dd98 100644 --- a/app/src/main/kotlin/com/simplemobiletools/gallery/activities/SimpleActivity.kt +++ b/app/src/main/kotlin/com/simplemobiletools/gallery/activities/SimpleActivity.kt @@ -5,13 +5,14 @@ import android.app.Activity import android.content.Intent import android.os.Build import android.os.Bundle +import android.provider.MediaStore import android.support.v7.app.AppCompatActivity import android.view.MenuItem import android.view.View import com.simplemobiletools.filepicker.extensions.isShowingWritePermissions +import com.simplemobiletools.gallery.R import com.simplemobiletools.gallery.helpers.Config import com.simplemobiletools.gallery.helpers.OPEN_DOCUMENT_TREE -import com.simplemobiletools.gallery.R import java.io.File open class SimpleActivity : AppCompatActivity() { @@ -53,6 +54,18 @@ open class SimpleActivity : AppCompatActivity() { contentResolver.takePersistableUriPermission(treeUri, takeFlags) } + fun launchCamera() { + startActivity(Intent(MediaStore.INTENT_ACTION_STILL_IMAGE_CAMERA)) + } + + fun launchSettings() { + startActivity(Intent(applicationContext, SettingsActivity::class.java)) + } + + fun launchAbout() { + startActivity(Intent(applicationContext, AboutActivity::class.java)) + } + fun isShowingPermDialog(file: File) = isShowingWritePermissions(file, mConfig.treeUri, OPEN_DOCUMENT_TREE) fun showSystemUI() {