diff --git a/app/src/main/kotlin/com/simplemobiletools/gallery/activities/EditActivity.kt b/app/src/main/kotlin/com/simplemobiletools/gallery/activities/EditActivity.kt index f4d587aaf..b1477989c 100644 --- a/app/src/main/kotlin/com/simplemobiletools/gallery/activities/EditActivity.kt +++ b/app/src/main/kotlin/com/simplemobiletools/gallery/activities/EditActivity.kt @@ -60,21 +60,13 @@ class EditActivity : SimpleActivity(), CropImageView.OnCropImageCompleteListener } override fun onOptionsItemSelected(item: MenuItem): Boolean { - return when (item.itemId) { - R.id.save_as -> { - crop_image_view.getCroppedImageAsync() - true - } - R.id.rotate -> { - crop_image_view.rotateImage(90) - true - } - R.id.resize -> { - resizeImage() - true - } - else -> super.onOptionsItemSelected(item) + when (item.itemId) { + R.id.save_as -> crop_image_view.getCroppedImageAsync() + R.id.rotate -> crop_image_view.rotateImage(90) + R.id.resize -> resizeImage() + else -> return super.onOptionsItemSelected(item) } + return true } private fun resizeImage() { 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 c95b4a952..e32600722 100644 --- a/app/src/main/kotlin/com/simplemobiletools/gallery/activities/MainActivity.kt +++ b/app/src/main/kotlin/com/simplemobiletools/gallery/activities/MainActivity.kt @@ -76,29 +76,15 @@ class MainActivity : SimpleActivity(), DirectoryAdapter.DirOperationsListener { } override fun onOptionsItemSelected(item: MenuItem): Boolean { - return when (item.itemId) { - R.id.sort -> { - showSortingDialog() - true - } - R.id.open_camera -> { - launchCamera() - true - } - R.id.show_all -> { - showAllMedia() - true - } - R.id.settings -> { - launchSettings() - true - } - R.id.about -> { - launchAbout() - true - } - else -> super.onOptionsItemSelected(item) + when (item.itemId) { + R.id.sort -> showSortingDialog() + R.id.open_camera -> launchCamera() + R.id.show_all -> showAllMedia() + R.id.settings -> launchSettings() + R.id.about -> launchAbout() + else -> return super.onOptionsItemSelected(item) } + return true } override fun onResume() { diff --git a/app/src/main/kotlin/com/simplemobiletools/gallery/activities/MediaActivity.kt b/app/src/main/kotlin/com/simplemobiletools/gallery/activities/MediaActivity.kt index 982a75c75..2d89192f7 100644 --- a/app/src/main/kotlin/com/simplemobiletools/gallery/activities/MediaActivity.kt +++ b/app/src/main/kotlin/com/simplemobiletools/gallery/activities/MediaActivity.kt @@ -111,41 +111,18 @@ class MediaActivity : SimpleActivity(), MediaAdapter.MediaOperationsListener { } override fun onOptionsItemSelected(item: MenuItem): Boolean { - return when (item.itemId) { - R.id.sort -> { - showSortingDialog() - true - } - R.id.toggle_filename -> { - toggleFilenameVisibility() - true - } - R.id.open_camera -> { - launchCamera() - true - } - R.id.folder_view -> { - switchToFolderView() - true - } - R.id.hide_folder -> { - hideFolder() - true - } - R.id.unhide_folder -> { - unhideFolder() - true - } - R.id.settings -> { - launchSettings() - true - } - R.id.about -> { - launchAbout() - true - } - else -> super.onOptionsItemSelected(item) + when (item.itemId) { + R.id.sort -> showSortingDialog() + R.id.toggle_filename -> toggleFilenameVisibility() + R.id.open_camera -> launchCamera() + R.id.folder_view -> switchToFolderView() + R.id.hide_folder -> hideFolder() + R.id.unhide_folder -> unhideFolder() + R.id.settings -> launchSettings() + R.id.about -> launchAbout() + else -> return super.onOptionsItemSelected(item) } + return true } private fun toggleFilenameVisibility() { diff --git a/app/src/main/kotlin/com/simplemobiletools/gallery/activities/PhotoVideoActivity.kt b/app/src/main/kotlin/com/simplemobiletools/gallery/activities/PhotoVideoActivity.kt index 44e2908b5..41ea0357a 100644 --- a/app/src/main/kotlin/com/simplemobiletools/gallery/activities/PhotoVideoActivity.kt +++ b/app/src/main/kotlin/com/simplemobiletools/gallery/activities/PhotoVideoActivity.kt @@ -95,25 +95,14 @@ open class PhotoVideoActivity : SimpleActivity(), ViewPagerFragment.FragmentClic } override fun onOptionsItemSelected(item: MenuItem): Boolean { - return when (item.itemId) { - R.id.menu_set_as_wallpaper -> { - setAsWallpaper(File(mMedium!!.path)) - true - } - R.id.menu_open_with -> { - openWith(File(mMedium!!.path)) - true - } - R.id.menu_share -> { - shareMedium(mMedium!!) - true - } - R.id.menu_edit -> { - openEditor(File(mMedium!!.path)) - true - } - else -> super.onOptionsItemSelected(item) + when (item.itemId) { + R.id.menu_set_as_wallpaper -> setAsWallpaper(File(mMedium!!.path)) + R.id.menu_open_with -> openWith(File(mMedium!!.path)) + R.id.menu_share -> shareMedium(mMedium!!) + R.id.menu_edit -> openEditor(File(mMedium!!.path)) + else -> return super.onOptionsItemSelected(item) } + return true } override fun fragmentClicked() { diff --git a/app/src/main/kotlin/com/simplemobiletools/gallery/activities/SetWallpaperActivity.kt b/app/src/main/kotlin/com/simplemobiletools/gallery/activities/SetWallpaperActivity.kt index 3eb0e3fc7..b2446e9e8 100644 --- a/app/src/main/kotlin/com/simplemobiletools/gallery/activities/SetWallpaperActivity.kt +++ b/app/src/main/kotlin/com/simplemobiletools/gallery/activities/SetWallpaperActivity.kt @@ -58,16 +58,11 @@ class SetWallpaperActivity : SimpleActivity(), CropImageView.OnCropImageComplete override fun onOptionsItemSelected(item: MenuItem): Boolean { when (item.itemId) { - R.id.save -> { - crop_image_view.getCroppedImageAsync() - return true - } - R.id.rotate -> { - crop_image_view.rotateImage(90) - return true - } + R.id.save -> crop_image_view.getCroppedImageAsync() + R.id.rotate -> crop_image_view.rotateImage(90) + else -> return super.onOptionsItemSelected(item) } - return super.onOptionsItemSelected(item) + return true } override fun onCropImageComplete(view: CropImageView?, result: CropImageView.CropResult) { diff --git a/app/src/main/kotlin/com/simplemobiletools/gallery/activities/ViewPagerActivity.kt b/app/src/main/kotlin/com/simplemobiletools/gallery/activities/ViewPagerActivity.kt index 65a890851..cd7ed53b2 100644 --- a/app/src/main/kotlin/com/simplemobiletools/gallery/activities/ViewPagerActivity.kt +++ b/app/src/main/kotlin/com/simplemobiletools/gallery/activities/ViewPagerActivity.kt @@ -100,41 +100,18 @@ class ViewPagerActivity : SimpleActivity(), ViewPager.OnPageChangeListener, View } override fun onOptionsItemSelected(item: MenuItem): Boolean { - return when (item.itemId) { - R.id.menu_set_as_wallpaper -> { - setAsWallpaper(getCurrentFile()) - true - } - R.id.menu_copy_move -> { - displayCopyDialog() - true - } - R.id.menu_open_with -> { - openWith(getCurrentFile()) - true - } - R.id.menu_share -> { - shareMedium(getCurrentMedium()!!) - true - } - R.id.menu_delete -> { - askConfirmDelete() - true - } - R.id.menu_rename -> { - renameFile() - true - } - R.id.menu_edit -> { - openEditor(getCurrentFile()) - true - } - R.id.menu_properties -> { - showProperties() - true - } - else -> super.onOptionsItemSelected(item) + when (item.itemId) { + R.id.menu_set_as_wallpaper -> setAsWallpaper(getCurrentFile()) + R.id.menu_copy_move -> displayCopyDialog() + R.id.menu_open_with -> openWith(getCurrentFile()) + R.id.menu_share -> shareMedium(getCurrentMedium()!!) + R.id.menu_delete -> askConfirmDelete() + R.id.menu_rename -> renameFile() + R.id.menu_edit -> openEditor(getCurrentFile()) + R.id.menu_properties -> showProperties() + else -> return super.onOptionsItemSelected(item) } + return true } override fun onConfigurationChanged(newConfig: Configuration) { diff --git a/app/src/main/kotlin/com/simplemobiletools/gallery/adapters/DirectoryAdapter.kt b/app/src/main/kotlin/com/simplemobiletools/gallery/adapters/DirectoryAdapter.kt index 2a18ec457..ab7c770fb 100644 --- a/app/src/main/kotlin/com/simplemobiletools/gallery/adapters/DirectoryAdapter.kt +++ b/app/src/main/kotlin/com/simplemobiletools/gallery/adapters/DirectoryAdapter.kt @@ -59,45 +59,18 @@ class DirectoryAdapter(val activity: SimpleActivity, val dirs: MutableList { - showProperties() - true - } - R.id.cab_rename -> { - renameDir() - true - } - R.id.cab_pin -> { - pinFolder() - mode.finish() - true - } - R.id.cab_unpin -> { - unpinFolder() - mode.finish() - true - } - R.id.cab_hide -> { - hideFolders() - mode.finish() - true - } - R.id.cab_unhide -> { - unhideFolders() - mode.finish() - true - } - R.id.cab_copy_move -> { - displayCopyDialog() - true - } - R.id.cab_delete -> { - askConfirmDelete() - true - } - else -> false + when (item.itemId) { + R.id.cab_properties -> showProperties() + R.id.cab_rename -> renameDir() + R.id.cab_pin -> pinFolders(true) + R.id.cab_unpin -> pinFolders(false) + R.id.cab_hide -> toggleFoldersVisibility(true) + R.id.cab_unhide -> toggleFoldersVisibility(false) + R.id.cab_copy_move -> displayCopyDialog() + R.id.cab_delete -> askConfirmDelete() + else -> return false } + return true } override fun onCreateActionMode(actionMode: ActionMode?, menu: Menu?): Boolean { @@ -183,28 +156,26 @@ class DirectoryAdapter(val activity: SimpleActivity, val dirs: MutableList, val multiSelectorMode = object : ModalMultiSelectorCallback(multiSelector) { override fun onActionItemClicked(mode: ActionMode, item: MenuItem): Boolean { - return when (item.itemId) { - R.id.cab_properties -> { - showProperties() - true - } - R.id.cab_rename -> { - renameFile() - true - } - R.id.cab_edit -> { - editFile() - true - } - R.id.cab_share -> { - shareMedia() - true - } - R.id.cab_copy_move -> { - displayCopyDialog() - true - } - R.id.cab_select_all -> { - selectAll() - true - } - R.id.cab_delete -> { - askConfirmDelete() - true - } - else -> false + when (item.itemId) { + R.id.cab_properties -> showProperties() + R.id.cab_rename -> renameFile() + R.id.cab_edit -> editFile() + R.id.cab_share -> shareMedia() + R.id.cab_copy_move -> displayCopyDialog() + R.id.cab_select_all -> selectAll() + R.id.cab_delete -> askConfirmDelete() + else -> return false } + return true } override fun onCreateActionMode(actionMode: ActionMode?, menu: Menu?): Boolean {