From 55499815c316e5ed5c19a8f8d96612200e71751c Mon Sep 17 00:00:00 2001 From: Ebrahim Byagowi Date: Mon, 6 Dec 2021 01:14:23 +0330 Subject: [PATCH 1/6] Remove now obsolete suppress lint annotations They are no longer needed as the update in Simple-Common project. --- .../gallery/pro/activities/SetWallpaperActivity.kt | 3 --- .../gallery/pro/activities/SimpleActivity.kt | 2 -- .../gallery/pro/activities/ViewPagerActivity.kt | 6 +++--- .../gallery/pro/adapters/DirectoryAdapter.kt | 8 +++++--- .../gallery/pro/adapters/MediaAdapter.kt | 9 +++++---- .../gallery/pro/helpers/MediaFetcher.kt | 3 --- 6 files changed, 13 insertions(+), 18 deletions(-) diff --git a/app/src/main/kotlin/com/simplemobiletools/gallery/pro/activities/SetWallpaperActivity.kt b/app/src/main/kotlin/com/simplemobiletools/gallery/pro/activities/SetWallpaperActivity.kt index 46e609400..a56ca076a 100644 --- a/app/src/main/kotlin/com/simplemobiletools/gallery/pro/activities/SetWallpaperActivity.kt +++ b/app/src/main/kotlin/com/simplemobiletools/gallery/pro/activities/SetWallpaperActivity.kt @@ -1,6 +1,5 @@ package com.simplemobiletools.gallery.pro.activities -import android.annotation.SuppressLint import android.app.Activity import android.app.WallpaperManager import android.content.Intent @@ -100,7 +99,6 @@ class SetWallpaperActivity : SimpleActivity(), CropImageView.OnCropImageComplete setupAspectRatio() } - @SuppressLint("InlinedApi") private fun confirmWallpaper() { if (isNougatPlus()) { val items = arrayListOf( @@ -118,7 +116,6 @@ class SetWallpaperActivity : SimpleActivity(), CropImageView.OnCropImageComplete } } - @SuppressLint("NewApi") override fun onCropImageComplete(view: CropImageView?, result: CropImageView.CropResult) { if (isDestroyed) return diff --git a/app/src/main/kotlin/com/simplemobiletools/gallery/pro/activities/SimpleActivity.kt b/app/src/main/kotlin/com/simplemobiletools/gallery/pro/activities/SimpleActivity.kt index 95b9f5841..6d02ad838 100644 --- a/app/src/main/kotlin/com/simplemobiletools/gallery/pro/activities/SimpleActivity.kt +++ b/app/src/main/kotlin/com/simplemobiletools/gallery/pro/activities/SimpleActivity.kt @@ -1,6 +1,5 @@ package com.simplemobiletools.gallery.pro.activities -import android.annotation.SuppressLint import android.database.ContentObserver import android.net.Uri import android.provider.MediaStore.Images @@ -56,7 +55,6 @@ open class SimpleActivity : BaseSimpleActivity() { override fun getAppLauncherName() = getString(R.string.app_launcher_name) - @SuppressLint("InlinedApi") protected fun checkNotchSupport() { if (isPiePlus()) { val cutoutMode = when { diff --git a/app/src/main/kotlin/com/simplemobiletools/gallery/pro/activities/ViewPagerActivity.kt b/app/src/main/kotlin/com/simplemobiletools/gallery/pro/activities/ViewPagerActivity.kt index 8a4bf4e63..f3668fec5 100644 --- a/app/src/main/kotlin/com/simplemobiletools/gallery/pro/activities/ViewPagerActivity.kt +++ b/app/src/main/kotlin/com/simplemobiletools/gallery/pro/activities/ViewPagerActivity.kt @@ -27,6 +27,7 @@ import android.view.View import android.view.WindowManager import android.view.animation.DecelerateInterpolator import android.widget.Toast +import androidx.annotation.RequiresApi import androidx.exifinterface.media.ExifInterface import androidx.print.PrintHelper import androidx.viewpager.widget.ViewPager @@ -238,7 +239,7 @@ class ViewPagerActivity : SimpleActivity(), ViewPager.OnPageChangeListener, View R.id.menu_force_landscape -> toggleOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE) R.id.menu_default_orientation -> toggleOrientation(ActivityInfo.SCREEN_ORIENTATION_UNSPECIFIED) R.id.menu_save_as -> saveImageAs() - R.id.menu_create_shortcut -> createShortcut() + R.id.menu_create_shortcut -> if (isOreoPlus()) createShortcut() R.id.menu_resize -> resizeImage() R.id.menu_settings -> launchSettings() else -> return super.onOptionsItemSelected(item) @@ -333,7 +334,6 @@ class ViewPagerActivity : SimpleActivity(), ViewPager.OnPageChangeListener, View } } - @SuppressLint("NewApi") private fun initContinue() { if (intent.extras?.containsKey(IS_VIEW_INTENT) == true) { if (isShowHiddenFlagNeeded()) { @@ -716,7 +716,7 @@ class ViewPagerActivity : SimpleActivity(), ViewPager.OnPageChangeListener, View } } - @SuppressLint("NewApi") + @RequiresApi(Build.VERSION_CODES.O) private fun createShortcut() { val manager = getSystemService(ShortcutManager::class.java) if (manager.isRequestPinShortcutSupported) { diff --git a/app/src/main/kotlin/com/simplemobiletools/gallery/pro/adapters/DirectoryAdapter.kt b/app/src/main/kotlin/com/simplemobiletools/gallery/pro/adapters/DirectoryAdapter.kt index ed6a021cd..59d404929 100644 --- a/app/src/main/kotlin/com/simplemobiletools/gallery/pro/adapters/DirectoryAdapter.kt +++ b/app/src/main/kotlin/com/simplemobiletools/gallery/pro/adapters/DirectoryAdapter.kt @@ -1,17 +1,18 @@ package com.simplemobiletools.gallery.pro.adapters -import android.annotation.SuppressLint import android.content.Intent import android.content.pm.ShortcutInfo import android.content.pm.ShortcutManager import android.graphics.drawable.ColorDrawable import android.graphics.drawable.Icon +import android.os.Build import android.text.TextUtils import android.view.Menu import android.view.MotionEvent import android.view.View import android.view.ViewGroup import android.widget.RelativeLayout +import androidx.annotation.RequiresApi import androidx.recyclerview.widget.ItemTouchHelper import androidx.recyclerview.widget.RecyclerView import androidx.swiperefreshlayout.widget.SwipeRefreshLayout @@ -156,7 +157,7 @@ class DirectoryAdapter( R.id.cab_copy_to -> copyMoveTo(true) R.id.cab_move_to -> moveFilesTo() R.id.cab_select_all -> selectAll() - R.id.cab_create_shortcut -> tryCreateShortcut() + R.id.cab_create_shortcut -> if (isOreoPlus()) tryCreateShortcut() R.id.cab_delete -> askConfirmDelete() R.id.cab_select_photo -> tryChangeAlbumCover(false) R.id.cab_use_default -> tryChangeAlbumCover(true) @@ -539,6 +540,7 @@ class DirectoryAdapter( } } + @RequiresApi(Build.VERSION_CODES.O) private fun tryCreateShortcut() { activity.handleLockedFolderOpening(getFirstSelectedItemPath() ?: "") { success -> if (success) { @@ -547,7 +549,7 @@ class DirectoryAdapter( } } - @SuppressLint("NewApi") + @RequiresApi(Build.VERSION_CODES.O) private fun createShortcut() { val manager = activity.getSystemService(ShortcutManager::class.java) if (manager.isRequestPinShortcutSupported) { diff --git a/app/src/main/kotlin/com/simplemobiletools/gallery/pro/adapters/MediaAdapter.kt b/app/src/main/kotlin/com/simplemobiletools/gallery/pro/adapters/MediaAdapter.kt index f9a0bd45d..b21143179 100644 --- a/app/src/main/kotlin/com/simplemobiletools/gallery/pro/adapters/MediaAdapter.kt +++ b/app/src/main/kotlin/com/simplemobiletools/gallery/pro/adapters/MediaAdapter.kt @@ -1,16 +1,17 @@ package com.simplemobiletools.gallery.pro.adapters -import android.annotation.SuppressLint import android.content.Intent import android.content.pm.ShortcutInfo import android.content.pm.ShortcutManager import android.graphics.drawable.Icon +import android.os.Build import android.os.Handler import android.os.Looper import android.view.Menu import android.view.View import android.view.ViewGroup import android.widget.Toast +import androidx.annotation.RequiresApi import com.bumptech.glide.Glide import com.qtalk.recyclerviewfastscroller.RecyclerViewFastScroller import com.simplemobiletools.commons.activities.BaseSimpleActivity @@ -34,8 +35,8 @@ import com.simplemobiletools.gallery.pro.models.ThumbnailSection import kotlinx.android.synthetic.main.photo_item_grid.view.* import kotlinx.android.synthetic.main.thumbnail_section.view.* import kotlinx.android.synthetic.main.video_item_grid.view.* -import kotlinx.android.synthetic.main.video_item_grid.view.media_item_holder import kotlinx.android.synthetic.main.video_item_grid.view.favorite +import kotlinx.android.synthetic.main.video_item_grid.view.media_item_holder import kotlinx.android.synthetic.main.video_item_grid.view.medium_check import kotlinx.android.synthetic.main.video_item_grid.view.medium_name import kotlinx.android.synthetic.main.video_item_grid.view.medium_thumbnail @@ -174,7 +175,7 @@ class MediaAdapter( R.id.cab_rotate_one_eighty -> rotateSelection(180) R.id.cab_copy_to -> copyMoveTo(true) R.id.cab_move_to -> moveFilesTo() - R.id.cab_create_shortcut -> createShortcut() + R.id.cab_create_shortcut -> if (isOreoPlus()) createShortcut() R.id.cab_select_all -> selectAll() R.id.cab_open_with -> openPath() R.id.cab_fix_date_taken -> fixDateTaken() @@ -386,7 +387,7 @@ class MediaAdapter( } } - @SuppressLint("NewApi") + @RequiresApi(Build.VERSION_CODES.O) private fun createShortcut() { val manager = activity.getSystemService(ShortcutManager::class.java) if (manager.isRequestPinShortcutSupported) { diff --git a/app/src/main/kotlin/com/simplemobiletools/gallery/pro/helpers/MediaFetcher.kt b/app/src/main/kotlin/com/simplemobiletools/gallery/pro/helpers/MediaFetcher.kt index a1cc62167..b0796a4ad 100644 --- a/app/src/main/kotlin/com/simplemobiletools/gallery/pro/helpers/MediaFetcher.kt +++ b/app/src/main/kotlin/com/simplemobiletools/gallery/pro/helpers/MediaFetcher.kt @@ -1,6 +1,5 @@ package com.simplemobiletools.gallery.pro.helpers -import android.annotation.SuppressLint import android.content.ContentResolver import android.content.Context import android.database.Cursor @@ -119,7 +118,6 @@ class MediaFetcher(val context: Context) { } } - @SuppressLint("NewApi") private fun getLatestFileFolders(): LinkedHashSet { val uri = Files.getContentUri("external") val projection = arrayOf(Images.ImageColumns.DATA) @@ -408,7 +406,6 @@ class MediaFetcher(val context: Context) { return media } - @SuppressLint("InlinedApi") fun getAndroid11FolderMedia( isPickImage: Boolean, isPickVideo: Boolean, favoritePaths: ArrayList ): HashMap> { From 0e1a1cfb90acd875cdbc9a9046156a677ba96cd6 Mon Sep 17 00:00:00 2001 From: Ebrahim Byagowi Date: Mon, 6 Dec 2021 01:28:38 +0330 Subject: [PATCH 2/6] Check for api version at the target instead marking with RequiresApi --- .../gallery/pro/activities/ViewPagerActivity.kt | 5 ++--- .../gallery/pro/adapters/DirectoryAdapter.kt | 5 ++--- .../simplemobiletools/gallery/pro/adapters/MediaAdapter.kt | 6 ++---- 3 files changed, 6 insertions(+), 10 deletions(-) diff --git a/app/src/main/kotlin/com/simplemobiletools/gallery/pro/activities/ViewPagerActivity.kt b/app/src/main/kotlin/com/simplemobiletools/gallery/pro/activities/ViewPagerActivity.kt index f3668fec5..31c46723f 100644 --- a/app/src/main/kotlin/com/simplemobiletools/gallery/pro/activities/ViewPagerActivity.kt +++ b/app/src/main/kotlin/com/simplemobiletools/gallery/pro/activities/ViewPagerActivity.kt @@ -27,7 +27,6 @@ import android.view.View import android.view.WindowManager import android.view.animation.DecelerateInterpolator import android.widget.Toast -import androidx.annotation.RequiresApi import androidx.exifinterface.media.ExifInterface import androidx.print.PrintHelper import androidx.viewpager.widget.ViewPager @@ -239,7 +238,7 @@ class ViewPagerActivity : SimpleActivity(), ViewPager.OnPageChangeListener, View R.id.menu_force_landscape -> toggleOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE) R.id.menu_default_orientation -> toggleOrientation(ActivityInfo.SCREEN_ORIENTATION_UNSPECIFIED) R.id.menu_save_as -> saveImageAs() - R.id.menu_create_shortcut -> if (isOreoPlus()) createShortcut() + R.id.menu_create_shortcut -> createShortcut() R.id.menu_resize -> resizeImage() R.id.menu_settings -> launchSettings() else -> return super.onOptionsItemSelected(item) @@ -716,8 +715,8 @@ class ViewPagerActivity : SimpleActivity(), ViewPager.OnPageChangeListener, View } } - @RequiresApi(Build.VERSION_CODES.O) private fun createShortcut() { + if (!isOreoPlus()) return val manager = getSystemService(ShortcutManager::class.java) if (manager.isRequestPinShortcutSupported) { val medium = getCurrentMedium() ?: return diff --git a/app/src/main/kotlin/com/simplemobiletools/gallery/pro/adapters/DirectoryAdapter.kt b/app/src/main/kotlin/com/simplemobiletools/gallery/pro/adapters/DirectoryAdapter.kt index 59d404929..b54c3c2bd 100644 --- a/app/src/main/kotlin/com/simplemobiletools/gallery/pro/adapters/DirectoryAdapter.kt +++ b/app/src/main/kotlin/com/simplemobiletools/gallery/pro/adapters/DirectoryAdapter.kt @@ -157,7 +157,7 @@ class DirectoryAdapter( R.id.cab_copy_to -> copyMoveTo(true) R.id.cab_move_to -> moveFilesTo() R.id.cab_select_all -> selectAll() - R.id.cab_create_shortcut -> if (isOreoPlus()) tryCreateShortcut() + R.id.cab_create_shortcut -> tryCreateShortcut() R.id.cab_delete -> askConfirmDelete() R.id.cab_select_photo -> tryChangeAlbumCover(false) R.id.cab_use_default -> tryChangeAlbumCover(true) @@ -540,7 +540,6 @@ class DirectoryAdapter( } } - @RequiresApi(Build.VERSION_CODES.O) private fun tryCreateShortcut() { activity.handleLockedFolderOpening(getFirstSelectedItemPath() ?: "") { success -> if (success) { @@ -549,8 +548,8 @@ class DirectoryAdapter( } } - @RequiresApi(Build.VERSION_CODES.O) private fun createShortcut() { + if (!isOreoPlus()) return val manager = activity.getSystemService(ShortcutManager::class.java) if (manager.isRequestPinShortcutSupported) { val dir = getFirstSelectedItem() ?: return diff --git a/app/src/main/kotlin/com/simplemobiletools/gallery/pro/adapters/MediaAdapter.kt b/app/src/main/kotlin/com/simplemobiletools/gallery/pro/adapters/MediaAdapter.kt index b21143179..65e409dca 100644 --- a/app/src/main/kotlin/com/simplemobiletools/gallery/pro/adapters/MediaAdapter.kt +++ b/app/src/main/kotlin/com/simplemobiletools/gallery/pro/adapters/MediaAdapter.kt @@ -4,14 +4,12 @@ import android.content.Intent import android.content.pm.ShortcutInfo import android.content.pm.ShortcutManager import android.graphics.drawable.Icon -import android.os.Build import android.os.Handler import android.os.Looper import android.view.Menu import android.view.View import android.view.ViewGroup import android.widget.Toast -import androidx.annotation.RequiresApi import com.bumptech.glide.Glide import com.qtalk.recyclerviewfastscroller.RecyclerViewFastScroller import com.simplemobiletools.commons.activities.BaseSimpleActivity @@ -175,7 +173,7 @@ class MediaAdapter( R.id.cab_rotate_one_eighty -> rotateSelection(180) R.id.cab_copy_to -> copyMoveTo(true) R.id.cab_move_to -> moveFilesTo() - R.id.cab_create_shortcut -> if (isOreoPlus()) createShortcut() + R.id.cab_create_shortcut -> createShortcut() R.id.cab_select_all -> selectAll() R.id.cab_open_with -> openPath() R.id.cab_fix_date_taken -> fixDateTaken() @@ -387,8 +385,8 @@ class MediaAdapter( } } - @RequiresApi(Build.VERSION_CODES.O) private fun createShortcut() { + if (!isOreoPlus()) return val manager = activity.getSystemService(ShortcutManager::class.java) if (manager.isRequestPinShortcutSupported) { val path = getSelectedPaths().first() From dd8cd61450f5dc8c146fbc8aad021c8cc308013d Mon Sep 17 00:00:00 2001 From: Ebrahim Byagowi Date: Mon, 6 Dec 2021 01:32:45 +0330 Subject: [PATCH 3/6] Apply project's code style to api version checks --- .../gallery/pro/activities/ViewPagerActivity.kt | 4 +++- .../gallery/pro/adapters/DirectoryAdapter.kt | 4 +++- .../simplemobiletools/gallery/pro/adapters/MediaAdapter.kt | 4 +++- 3 files changed, 9 insertions(+), 3 deletions(-) diff --git a/app/src/main/kotlin/com/simplemobiletools/gallery/pro/activities/ViewPagerActivity.kt b/app/src/main/kotlin/com/simplemobiletools/gallery/pro/activities/ViewPagerActivity.kt index 31c46723f..94e62b028 100644 --- a/app/src/main/kotlin/com/simplemobiletools/gallery/pro/activities/ViewPagerActivity.kt +++ b/app/src/main/kotlin/com/simplemobiletools/gallery/pro/activities/ViewPagerActivity.kt @@ -716,7 +716,9 @@ class ViewPagerActivity : SimpleActivity(), ViewPager.OnPageChangeListener, View } private fun createShortcut() { - if (!isOreoPlus()) return + if (!isOreoPlus()) { + return + } val manager = getSystemService(ShortcutManager::class.java) if (manager.isRequestPinShortcutSupported) { val medium = getCurrentMedium() ?: return diff --git a/app/src/main/kotlin/com/simplemobiletools/gallery/pro/adapters/DirectoryAdapter.kt b/app/src/main/kotlin/com/simplemobiletools/gallery/pro/adapters/DirectoryAdapter.kt index b54c3c2bd..914150121 100644 --- a/app/src/main/kotlin/com/simplemobiletools/gallery/pro/adapters/DirectoryAdapter.kt +++ b/app/src/main/kotlin/com/simplemobiletools/gallery/pro/adapters/DirectoryAdapter.kt @@ -549,7 +549,9 @@ class DirectoryAdapter( } private fun createShortcut() { - if (!isOreoPlus()) return + if (!isOreoPlus()) { + return + } val manager = activity.getSystemService(ShortcutManager::class.java) if (manager.isRequestPinShortcutSupported) { val dir = getFirstSelectedItem() ?: return diff --git a/app/src/main/kotlin/com/simplemobiletools/gallery/pro/adapters/MediaAdapter.kt b/app/src/main/kotlin/com/simplemobiletools/gallery/pro/adapters/MediaAdapter.kt index 65e409dca..059cfcf23 100644 --- a/app/src/main/kotlin/com/simplemobiletools/gallery/pro/adapters/MediaAdapter.kt +++ b/app/src/main/kotlin/com/simplemobiletools/gallery/pro/adapters/MediaAdapter.kt @@ -386,7 +386,9 @@ class MediaAdapter( } private fun createShortcut() { - if (!isOreoPlus()) return + if (!isOreoPlus()) { + return + } val manager = activity.getSystemService(ShortcutManager::class.java) if (manager.isRequestPinShortcutSupported) { val path = getSelectedPaths().first() From a83765705d01bd739f4143e45337aa5db39b08ac Mon Sep 17 00:00:00 2001 From: Tibor Kaputa Date: Sun, 5 Dec 2021 23:28:01 +0100 Subject: [PATCH 4/6] adding an empty line --- .../gallery/pro/activities/ViewPagerActivity.kt | 1 + 1 file changed, 1 insertion(+) diff --git a/app/src/main/kotlin/com/simplemobiletools/gallery/pro/activities/ViewPagerActivity.kt b/app/src/main/kotlin/com/simplemobiletools/gallery/pro/activities/ViewPagerActivity.kt index 94e62b028..04a2ac467 100644 --- a/app/src/main/kotlin/com/simplemobiletools/gallery/pro/activities/ViewPagerActivity.kt +++ b/app/src/main/kotlin/com/simplemobiletools/gallery/pro/activities/ViewPagerActivity.kt @@ -719,6 +719,7 @@ class ViewPagerActivity : SimpleActivity(), ViewPager.OnPageChangeListener, View if (!isOreoPlus()) { return } + val manager = getSystemService(ShortcutManager::class.java) if (manager.isRequestPinShortcutSupported) { val medium = getCurrentMedium() ?: return From 8c0f04780937b66da8afe20a6a576bfa99bcc295 Mon Sep 17 00:00:00 2001 From: Tibor Kaputa Date: Sun, 5 Dec 2021 23:29:28 +0100 Subject: [PATCH 5/6] Update DirectoryAdapter.kt --- .../gallery/pro/adapters/DirectoryAdapter.kt | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/app/src/main/kotlin/com/simplemobiletools/gallery/pro/adapters/DirectoryAdapter.kt b/app/src/main/kotlin/com/simplemobiletools/gallery/pro/adapters/DirectoryAdapter.kt index 914150121..84e92b726 100644 --- a/app/src/main/kotlin/com/simplemobiletools/gallery/pro/adapters/DirectoryAdapter.kt +++ b/app/src/main/kotlin/com/simplemobiletools/gallery/pro/adapters/DirectoryAdapter.kt @@ -541,6 +541,10 @@ class DirectoryAdapter( } private fun tryCreateShortcut() { + if (!isOreoPlus()) { + return + } + activity.handleLockedFolderOpening(getFirstSelectedItemPath() ?: "") { success -> if (success) { createShortcut() @@ -549,9 +553,6 @@ class DirectoryAdapter( } private fun createShortcut() { - if (!isOreoPlus()) { - return - } val manager = activity.getSystemService(ShortcutManager::class.java) if (manager.isRequestPinShortcutSupported) { val dir = getFirstSelectedItem() ?: return From 05fa21a08591ea3fd990c58dae753f7fd884b712 Mon Sep 17 00:00:00 2001 From: Tibor Kaputa Date: Sun, 5 Dec 2021 23:30:02 +0100 Subject: [PATCH 6/6] Update MediaAdapter.kt --- .../com/simplemobiletools/gallery/pro/adapters/MediaAdapter.kt | 1 + 1 file changed, 1 insertion(+) diff --git a/app/src/main/kotlin/com/simplemobiletools/gallery/pro/adapters/MediaAdapter.kt b/app/src/main/kotlin/com/simplemobiletools/gallery/pro/adapters/MediaAdapter.kt index 059cfcf23..6e3e0438f 100644 --- a/app/src/main/kotlin/com/simplemobiletools/gallery/pro/adapters/MediaAdapter.kt +++ b/app/src/main/kotlin/com/simplemobiletools/gallery/pro/adapters/MediaAdapter.kt @@ -389,6 +389,7 @@ class MediaAdapter( if (!isOreoPlus()) { return } + val manager = activity.getSystemService(ShortcutManager::class.java) if (manager.isRequestPinShortcutSupported) { val path = getSelectedPaths().first()