From f176fe2915a7850f11b8d6f9ff471fd10882bb2b Mon Sep 17 00:00:00 2001 From: Naveen Singh Date: Sat, 28 Sep 2024 01:35:27 +0530 Subject: [PATCH] Bump minimum target version to Android 8 (API Level 26) See https://github.com/orgs/FossifyOrg/discussions/241 --- .../gallery/activities/EditActivity.kt | 18 +-- .../gallery/activities/MainActivity.kt | 129 ++++++++++++++++-- .../activities/SetWallpaperActivity.kt | 25 ++-- .../gallery/activities/ViewPagerActivity.kt | 8 +- .../gallery/adapters/DirectoryAdapter.kt | 95 ++++++++++--- .../fossify/gallery/adapters/MediaAdapter.kt | 88 ++++++++++-- .../fossify/gallery/extensions/Activity.kt | 18 +-- .../fossify/gallery/jobs/NewPhotoFetcher.kt | 3 - gradle/libs.versions.toml | 2 +- 9 files changed, 293 insertions(+), 93 deletions(-) diff --git a/app/src/main/kotlin/org/fossify/gallery/activities/EditActivity.kt b/app/src/main/kotlin/org/fossify/gallery/activities/EditActivity.kt index 17fdb78e1..21bff6bc8 100644 --- a/app/src/main/kotlin/org/fossify/gallery/activities/EditActivity.kt +++ b/app/src/main/kotlin/org/fossify/gallery/activities/EditActivity.kt @@ -1,6 +1,5 @@ package org.fossify.gallery.activities -import android.annotation.TargetApi import android.app.Activity import android.content.Intent import android.graphics.Bitmap @@ -8,7 +7,6 @@ import android.graphics.Bitmap.CompressFormat import android.graphics.Color import android.graphics.Point import android.net.Uri -import android.os.Build import android.os.Bundle import android.os.Handler import android.provider.MediaStore @@ -32,7 +30,6 @@ import org.fossify.commons.extensions.* import org.fossify.commons.helpers.NavigationIcon import org.fossify.commons.helpers.REAL_FILE_PATH import org.fossify.commons.helpers.ensureBackgroundThread -import org.fossify.commons.helpers.isNougatPlus import org.fossify.commons.models.FileDirItem import org.fossify.gallery.BuildConfig import org.fossify.gallery.R @@ -312,7 +309,6 @@ class EditActivity : SimpleActivity(), CropImageView.OnCropImageCompleteListener } } - @TargetApi(Build.VERSION_CODES.N) private fun saveImage() { setOldExif() @@ -355,14 +351,11 @@ class EditActivity : SimpleActivity(), CropImageView.OnCropImageCompleteListener } } - @TargetApi(Build.VERSION_CODES.N) private fun setOldExif() { var inputStream: InputStream? = null try { - if (isNougatPlus()) { - inputStream = contentResolver.openInputStream(uri!!) - oldExif = ExifInterface(inputStream!!) - } + inputStream = contentResolver.openInputStream(uri!!) + oldExif = ExifInterface(inputStream!!) } catch (e: Exception) { } finally { inputStream?.close() @@ -904,7 +897,6 @@ class EditActivity : SimpleActivity(), CropImageView.OnCropImageCompleteListener } } - @TargetApi(Build.VERSION_CODES.N) private fun saveBitmap(file: File, bitmap: Bitmap, out: OutputStream, showSavingToast: Boolean) { if (showSavingToast) { toast(org.fossify.commons.R.string.saving) @@ -918,10 +910,8 @@ class EditActivity : SimpleActivity(), CropImageView.OnCropImageCompleteListener } try { - if (isNougatPlus()) { - val newExif = ExifInterface(file.absolutePath) - oldExif?.copyNonDimensionAttributesTo(newExif) - } + val newExif = ExifInterface(file.absolutePath) + oldExif?.copyNonDimensionAttributesTo(newExif) } catch (e: Exception) { } diff --git a/app/src/main/kotlin/org/fossify/gallery/activities/MainActivity.kt b/app/src/main/kotlin/org/fossify/gallery/activities/MainActivity.kt index cce6e5d80..f9b1fda01 100644 --- a/app/src/main/kotlin/org/fossify/gallery/activities/MainActivity.kt +++ b/app/src/main/kotlin/org/fossify/gallery/activities/MainActivity.kt @@ -16,8 +16,62 @@ import androidx.recyclerview.widget.RecyclerView import org.fossify.commons.dialogs.CreateNewFolderDialog import org.fossify.commons.dialogs.FilePickerDialog import org.fossify.commons.dialogs.RadioGroupDialog -import org.fossify.commons.extensions.* -import org.fossify.commons.helpers.* +import org.fossify.commons.extensions.appLaunched +import org.fossify.commons.extensions.appLockManager +import org.fossify.commons.extensions.areSystemAnimationsEnabled +import org.fossify.commons.extensions.beGone +import org.fossify.commons.extensions.beVisible +import org.fossify.commons.extensions.beVisibleIf +import org.fossify.commons.extensions.checkWhatsNew +import org.fossify.commons.extensions.deleteFiles +import org.fossify.commons.extensions.getDoesFilePathExist +import org.fossify.commons.extensions.getFileCount +import org.fossify.commons.extensions.getFilePublicUri +import org.fossify.commons.extensions.getFilenameFromPath +import org.fossify.commons.extensions.getLatestMediaByDateId +import org.fossify.commons.extensions.getLatestMediaId +import org.fossify.commons.extensions.getMimeType +import org.fossify.commons.extensions.getProperBackgroundColor +import org.fossify.commons.extensions.getProperPrimaryColor +import org.fossify.commons.extensions.getProperSize +import org.fossify.commons.extensions.getProperTextColor +import org.fossify.commons.extensions.getStorageDirectories +import org.fossify.commons.extensions.getTimeFormat +import org.fossify.commons.extensions.handleHiddenFolderPasswordProtection +import org.fossify.commons.extensions.handleLockedFolderOpening +import org.fossify.commons.extensions.hasAllPermissions +import org.fossify.commons.extensions.hasOTGConnected +import org.fossify.commons.extensions.hasPermission +import org.fossify.commons.extensions.hideKeyboard +import org.fossify.commons.extensions.internalStoragePath +import org.fossify.commons.extensions.isExternalStorageManager +import org.fossify.commons.extensions.isGif +import org.fossify.commons.extensions.isGone +import org.fossify.commons.extensions.isImageFast +import org.fossify.commons.extensions.isMediaFile +import org.fossify.commons.extensions.isPathOnOTG +import org.fossify.commons.extensions.isRawFast +import org.fossify.commons.extensions.isSvg +import org.fossify.commons.extensions.isVideoFast +import org.fossify.commons.extensions.launchMoreAppsFromUsIntent +import org.fossify.commons.extensions.recycleBinPath +import org.fossify.commons.extensions.sdCardPath +import org.fossify.commons.extensions.showErrorToast +import org.fossify.commons.extensions.toFileDirItem +import org.fossify.commons.extensions.toast +import org.fossify.commons.extensions.underlineText +import org.fossify.commons.extensions.viewBinding +import org.fossify.commons.helpers.DAY_SECONDS +import org.fossify.commons.helpers.FAVORITES +import org.fossify.commons.helpers.PERMISSION_READ_STORAGE +import org.fossify.commons.helpers.SORT_BY_DATE_MODIFIED +import org.fossify.commons.helpers.SORT_BY_DATE_TAKEN +import org.fossify.commons.helpers.SORT_BY_SIZE +import org.fossify.commons.helpers.SORT_USE_NUMERIC_VALUE +import org.fossify.commons.helpers.VIEW_TYPE_GRID +import org.fossify.commons.helpers.VIEW_TYPE_LIST +import org.fossify.commons.helpers.ensureBackgroundThread +import org.fossify.commons.helpers.isRPlus import org.fossify.commons.models.FileDirItem import org.fossify.commons.models.RadioItem import org.fossify.commons.models.Release @@ -32,13 +86,70 @@ import org.fossify.gallery.dialogs.ChangeSortingDialog import org.fossify.gallery.dialogs.ChangeViewTypeDialog import org.fossify.gallery.dialogs.FilterMediaDialog import org.fossify.gallery.dialogs.GrantAllFilesDialog -import org.fossify.gallery.extensions.* -import org.fossify.gallery.helpers.* +import org.fossify.gallery.extensions.addTempFolderIfNeeded +import org.fossify.gallery.extensions.config +import org.fossify.gallery.extensions.createDirectoryFromMedia +import org.fossify.gallery.extensions.directoryDB +import org.fossify.gallery.extensions.getCachedDirectories +import org.fossify.gallery.extensions.getCachedMedia +import org.fossify.gallery.extensions.getDirectorySortingValue +import org.fossify.gallery.extensions.getDirsToShow +import org.fossify.gallery.extensions.getDistinctPath +import org.fossify.gallery.extensions.getFavoritePaths +import org.fossify.gallery.extensions.getNoMediaFoldersSync +import org.fossify.gallery.extensions.getOTGFolderChildrenNames +import org.fossify.gallery.extensions.getSortedDirectories +import org.fossify.gallery.extensions.handleExcludedFolderPasswordProtection +import org.fossify.gallery.extensions.handleMediaManagementPrompt +import org.fossify.gallery.extensions.isDownloadsFolder +import org.fossify.gallery.extensions.launchAbout +import org.fossify.gallery.extensions.launchCamera +import org.fossify.gallery.extensions.launchSettings +import org.fossify.gallery.extensions.mediaDB +import org.fossify.gallery.extensions.movePathsInRecycleBin +import org.fossify.gallery.extensions.movePinnedDirectoriesToFront +import org.fossify.gallery.extensions.openRecycleBin +import org.fossify.gallery.extensions.removeInvalidDBDirectories +import org.fossify.gallery.extensions.storeDirectoryItems +import org.fossify.gallery.extensions.tryDeleteFileDirItem +import org.fossify.gallery.extensions.updateDBDirectory +import org.fossify.gallery.extensions.updateWidgets +import org.fossify.gallery.helpers.DIRECTORY +import org.fossify.gallery.helpers.GET_ANY_INTENT +import org.fossify.gallery.helpers.GET_IMAGE_INTENT +import org.fossify.gallery.helpers.GET_VIDEO_INTENT +import org.fossify.gallery.helpers.GROUP_BY_DATE_TAKEN_DAILY +import org.fossify.gallery.helpers.GROUP_BY_DATE_TAKEN_MONTHLY +import org.fossify.gallery.helpers.GROUP_BY_LAST_MODIFIED_DAILY +import org.fossify.gallery.helpers.GROUP_BY_LAST_MODIFIED_MONTHLY +import org.fossify.gallery.helpers.GROUP_DESCENDING +import org.fossify.gallery.helpers.LOCATION_INTERNAL +import org.fossify.gallery.helpers.MAX_COLUMN_COUNT +import org.fossify.gallery.helpers.MONTH_MILLISECONDS +import org.fossify.gallery.helpers.MediaFetcher +import org.fossify.gallery.helpers.PICKED_PATHS +import org.fossify.gallery.helpers.RECYCLE_BIN +import org.fossify.gallery.helpers.SET_WALLPAPER_INTENT +import org.fossify.gallery.helpers.SHOW_ALL +import org.fossify.gallery.helpers.SHOW_TEMP_HIDDEN_DURATION +import org.fossify.gallery.helpers.SKIP_AUTHENTICATION +import org.fossify.gallery.helpers.TYPE_GIFS +import org.fossify.gallery.helpers.TYPE_IMAGES +import org.fossify.gallery.helpers.TYPE_RAWS +import org.fossify.gallery.helpers.TYPE_SVGS +import org.fossify.gallery.helpers.TYPE_VIDEOS +import org.fossify.gallery.helpers.getDefaultFileFilter +import org.fossify.gallery.helpers.getPermissionToRequest +import org.fossify.gallery.helpers.getPermissionsToRequest import org.fossify.gallery.interfaces.DirectoryOperationsListener import org.fossify.gallery.jobs.NewPhotoFetcher import org.fossify.gallery.models.Directory import org.fossify.gallery.models.Medium -import java.io.* +import java.io.File +import java.io.FileInputStream +import java.io.FileNotFoundException +import java.io.InputStream +import java.io.OutputStream class MainActivity : SimpleActivity(), DirectoryOperationsListener { companion object { @@ -407,11 +518,9 @@ class MainActivity : SimpleActivity(), DirectoryOperationsListener { } private fun startNewPhotoFetcher() { - if (isNougatPlus()) { - val photoFetcher = NewPhotoFetcher() - if (!photoFetcher.isScheduled(applicationContext)) { - photoFetcher.scheduleJob(applicationContext) - } + val photoFetcher = NewPhotoFetcher() + if (!photoFetcher.isScheduled(applicationContext)) { + photoFetcher.scheduleJob(applicationContext) } } diff --git a/app/src/main/kotlin/org/fossify/gallery/activities/SetWallpaperActivity.kt b/app/src/main/kotlin/org/fossify/gallery/activities/SetWallpaperActivity.kt index 102d9c2a6..4bea8d56a 100644 --- a/app/src/main/kotlin/org/fossify/gallery/activities/SetWallpaperActivity.kt +++ b/app/src/main/kotlin/org/fossify/gallery/activities/SetWallpaperActivity.kt @@ -13,7 +13,6 @@ import org.fossify.commons.extensions.toast import org.fossify.commons.extensions.viewBinding import org.fossify.commons.helpers.NavigationIcon import org.fossify.commons.helpers.ensureBackgroundThread -import org.fossify.commons.helpers.isNougatPlus import org.fossify.commons.models.RadioItem import org.fossify.gallery.R import org.fossify.gallery.databinding.ActivitySetWallpaperBinding @@ -127,18 +126,14 @@ class SetWallpaperActivity : SimpleActivity(), CropImageView.OnCropImageComplete } private fun confirmWallpaper() { - if (isNougatPlus()) { - val items = arrayListOf( - RadioItem(WallpaperManager.FLAG_SYSTEM, getString(R.string.home_screen)), - RadioItem(WallpaperManager.FLAG_LOCK, getString(R.string.lock_screen)), - RadioItem(WallpaperManager.FLAG_SYSTEM or WallpaperManager.FLAG_LOCK, getString(R.string.home_and_lock_screen)) - ) + val items = arrayListOf( + RadioItem(WallpaperManager.FLAG_SYSTEM, getString(R.string.home_screen)), + RadioItem(WallpaperManager.FLAG_LOCK, getString(R.string.lock_screen)), + RadioItem(WallpaperManager.FLAG_SYSTEM or WallpaperManager.FLAG_LOCK, getString(R.string.home_and_lock_screen)) + ) - RadioGroupDialog(this, items) { - wallpaperFlag = it as Int - binding.cropImageView.croppedImageAsync() - } - } else { + RadioGroupDialog(this, items) { + wallpaperFlag = it as Int binding.cropImageView.croppedImageAsync() } } @@ -156,11 +151,7 @@ class SetWallpaperActivity : SimpleActivity(), CropImageView.OnCropImageComplete val wantedWidth = (bitmap.width * ratio).toInt() try { val scaledBitmap = Bitmap.createScaledBitmap(bitmap, wantedWidth, wantedHeight, true) - if (isNougatPlus()) { - wallpaperManager.setBitmap(scaledBitmap, null, true, wallpaperFlag) - } else { - wallpaperManager.setBitmap(scaledBitmap) - } + wallpaperManager.setBitmap(scaledBitmap, null, true, wallpaperFlag) setResult(Activity.RESULT_OK) } catch (e: OutOfMemoryError) { toast(org.fossify.commons.R.string.out_of_memory_error) diff --git a/app/src/main/kotlin/org/fossify/gallery/activities/ViewPagerActivity.kt b/app/src/main/kotlin/org/fossify/gallery/activities/ViewPagerActivity.kt index b5f4a5572..fda8b9f00 100644 --- a/app/src/main/kotlin/org/fossify/gallery/activities/ViewPagerActivity.kt +++ b/app/src/main/kotlin/org/fossify/gallery/activities/ViewPagerActivity.kt @@ -189,7 +189,7 @@ class ViewPagerActivity : SimpleActivity(), ViewPager.OnPageChangeListener, View currentMedium.isFavorite && visibleBottomActions and BOTTOM_ACTION_TOGGLE_FAVORITE == 0 && !currentMedium.getIsInRecycleBin() findItem(R.id.menu_restore_file).isVisible = currentMedium.path.startsWith(recycleBinPath) - findItem(R.id.menu_create_shortcut).isVisible = isOreoPlus() + findItem(R.id.menu_create_shortcut).isVisible = true findItem(R.id.menu_change_orientation).isVisible = rotationDegrees == 0 && visibleBottomActions and BOTTOM_ACTION_CHANGE_ORIENTATION == 0 findItem(R.id.menu_change_orientation).icon = resources.getDrawable(getChangeOrientationIcon()) findItem(R.id.menu_rotate).setShowAsAction( @@ -402,7 +402,7 @@ class ViewPagerActivity : SimpleActivity(), ViewPager.OnPageChangeListener, View window.decorView.setOnSystemUiVisibilityChangeListener { visibility -> mIsFullScreen = if (isUpsideDownCakePlus()) { visibility and View.SYSTEM_UI_FLAG_LOW_PROFILE != 0 - } else if (isNougatPlus() && isInMultiWindowMode) { + } else if (isInMultiWindowMode) { visibility and View.SYSTEM_UI_FLAG_LOW_PROFILE != 0 } else if (visibility and View.SYSTEM_UI_FLAG_LOW_PROFILE == 0) { false @@ -756,10 +756,6 @@ class ViewPagerActivity : SimpleActivity(), ViewPager.OnPageChangeListener, View } 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/org/fossify/gallery/adapters/DirectoryAdapter.kt b/app/src/main/kotlin/org/fossify/gallery/adapters/DirectoryAdapter.kt index 4feca5b69..7fb85fae4 100644 --- a/app/src/main/kotlin/org/fossify/gallery/adapters/DirectoryAdapter.kt +++ b/app/src/main/kotlin/org/fossify/gallery/adapters/DirectoryAdapter.kt @@ -5,7 +5,6 @@ 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 @@ -13,7 +12,6 @@ import android.view.View import android.view.ViewGroup import android.widget.ImageView import android.widget.RelativeLayout -import androidx.annotation.RequiresApi import androidx.appcompat.content.res.AppCompatResources import androidx.recyclerview.widget.ItemTouchHelper import androidx.recyclerview.widget.RecyclerView @@ -23,9 +21,43 @@ import com.google.gson.Gson import com.qtalk.recyclerviewfastscroller.RecyclerViewFastScroller import org.fossify.commons.activities.BaseSimpleActivity import org.fossify.commons.adapters.MyRecyclerViewAdapter -import org.fossify.commons.dialogs.* -import org.fossify.commons.extensions.* -import org.fossify.commons.helpers.* +import org.fossify.commons.dialogs.ConfirmationDialog +import org.fossify.commons.dialogs.FolderLockingNoticeDialog +import org.fossify.commons.dialogs.PropertiesDialog +import org.fossify.commons.dialogs.RenameItemDialog +import org.fossify.commons.dialogs.RenameItemsDialog +import org.fossify.commons.dialogs.SecurityDialog +import org.fossify.commons.extensions.applyColorFilter +import org.fossify.commons.extensions.beGone +import org.fossify.commons.extensions.beVisible +import org.fossify.commons.extensions.beVisibleIf +import org.fossify.commons.extensions.containsNoMedia +import org.fossify.commons.extensions.convertToBitmap +import org.fossify.commons.extensions.doesThisOrParentHaveNoMedia +import org.fossify.commons.extensions.getContrastColor +import org.fossify.commons.extensions.getFilenameFromPath +import org.fossify.commons.extensions.getProperBackgroundColor +import org.fossify.commons.extensions.getTimeFormat +import org.fossify.commons.extensions.handleDeletePasswordProtection +import org.fossify.commons.extensions.handleLockedFolderOpening +import org.fossify.commons.extensions.isAStorageRootFolder +import org.fossify.commons.extensions.isExternalStorageManager +import org.fossify.commons.extensions.isGif +import org.fossify.commons.extensions.isImageFast +import org.fossify.commons.extensions.isMediaFile +import org.fossify.commons.extensions.isRawFast +import org.fossify.commons.extensions.isSvg +import org.fossify.commons.extensions.isVideoFast +import org.fossify.commons.extensions.isVisible +import org.fossify.commons.extensions.rescanPaths +import org.fossify.commons.extensions.showErrorToast +import org.fossify.commons.extensions.toast +import org.fossify.commons.helpers.FAVORITES +import org.fossify.commons.helpers.SHOW_ALL_TABS +import org.fossify.commons.helpers.SORT_BY_CUSTOM +import org.fossify.commons.helpers.VIEW_TYPE_LIST +import org.fossify.commons.helpers.ensureBackgroundThread +import org.fossify.commons.helpers.isRPlus import org.fossify.commons.interfaces.ItemMoveCallback import org.fossify.commons.interfaces.ItemTouchHelperContract import org.fossify.commons.interfaces.StartReorderDragListener @@ -39,8 +71,38 @@ import org.fossify.gallery.databinding.DirectoryItemListBinding import org.fossify.gallery.dialogs.ConfirmDeleteFolderDialog import org.fossify.gallery.dialogs.ExcludeFolderDialog import org.fossify.gallery.dialogs.PickMediumDialog -import org.fossify.gallery.extensions.* -import org.fossify.gallery.helpers.* +import org.fossify.gallery.extensions.addNoMedia +import org.fossify.gallery.extensions.checkAppendingHidden +import org.fossify.gallery.extensions.config +import org.fossify.gallery.extensions.directoryDB +import org.fossify.gallery.extensions.emptyAndDisableTheRecycleBin +import org.fossify.gallery.extensions.emptyTheRecycleBin +import org.fossify.gallery.extensions.favoritesDB +import org.fossify.gallery.extensions.fixDateTaken +import org.fossify.gallery.extensions.getShortcutImage +import org.fossify.gallery.extensions.isThisOrParentFolderHidden +import org.fossify.gallery.extensions.loadImage +import org.fossify.gallery.extensions.mediaDB +import org.fossify.gallery.extensions.removeNoMedia +import org.fossify.gallery.extensions.showRecycleBinEmptyingDialog +import org.fossify.gallery.extensions.tryCopyMoveFilesTo +import org.fossify.gallery.helpers.DIRECTORY +import org.fossify.gallery.helpers.FOLDER_MEDIA_CNT_BRACKETS +import org.fossify.gallery.helpers.FOLDER_MEDIA_CNT_LINE +import org.fossify.gallery.helpers.FOLDER_STYLE_ROUNDED_CORNERS +import org.fossify.gallery.helpers.FOLDER_STYLE_SQUARE +import org.fossify.gallery.helpers.LOCATION_INTERNAL +import org.fossify.gallery.helpers.LOCATION_SD +import org.fossify.gallery.helpers.PATH +import org.fossify.gallery.helpers.RECYCLE_BIN +import org.fossify.gallery.helpers.ROUNDED_CORNERS_BIG +import org.fossify.gallery.helpers.ROUNDED_CORNERS_NONE +import org.fossify.gallery.helpers.ROUNDED_CORNERS_SMALL +import org.fossify.gallery.helpers.TYPE_GIFS +import org.fossify.gallery.helpers.TYPE_IMAGES +import org.fossify.gallery.helpers.TYPE_RAWS +import org.fossify.gallery.helpers.TYPE_SVGS +import org.fossify.gallery.helpers.TYPE_VIDEOS import org.fossify.gallery.interfaces.DirectoryOperationsListener import org.fossify.gallery.models.AlbumCover import org.fossify.gallery.models.Directory @@ -48,10 +110,16 @@ import java.io.File import java.util.Collections class DirectoryAdapter( - activity: BaseSimpleActivity, var dirs: ArrayList, val listener: DirectoryOperationsListener?, recyclerView: MyRecyclerView, - val isPickIntent: Boolean, val swipeRefreshLayout: SwipeRefreshLayout? = null, itemClick: (Any) -> Unit + activity: BaseSimpleActivity, + var dirs: ArrayList, + val listener: DirectoryOperationsListener?, + recyclerView: MyRecyclerView, + val isPickIntent: Boolean, + val swipeRefreshLayout: SwipeRefreshLayout? = null, + itemClick: (Any) -> Unit ) : - MyRecyclerViewAdapter(activity, recyclerView, itemClick), ItemTouchHelperContract, RecyclerViewFastScroller.OnPopupTextUpdate { + MyRecyclerViewAdapter(activity, recyclerView, itemClick), ItemTouchHelperContract, + RecyclerViewFastScroller.OnPopupTextUpdate { private val config = activity.config private val isListViewType = config.viewTypeFolders == VIEW_TYPE_LIST @@ -119,7 +187,7 @@ class DirectoryAdapter( findItem(R.id.cab_empty_recycle_bin).isVisible = isOneItemSelected && selectedPaths.first() == RECYCLE_BIN findItem(R.id.cab_empty_disable_recycle_bin).isVisible = isOneItemSelected && selectedPaths.first() == RECYCLE_BIN - findItem(R.id.cab_create_shortcut).isVisible = isOreoPlus() && isOneItemSelected + findItem(R.id.cab_create_shortcut).isVisible = isOneItemSelected checkHideBtnVisibility(this, selectedPaths) checkPinBtnVisibility(this, selectedPaths) @@ -549,10 +617,6 @@ class DirectoryAdapter( } private fun tryCreateShortcut() { - if (!isOreoPlus()) { - return - } - activity.handleLockedFolderOpening(getFirstSelectedItemPath() ?: "") { success -> if (success) { createShortcut() @@ -560,7 +624,6 @@ class DirectoryAdapter( } } - @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/org/fossify/gallery/adapters/MediaAdapter.kt b/app/src/main/kotlin/org/fossify/gallery/adapters/MediaAdapter.kt index 068fca05f..85a3e116f 100644 --- a/app/src/main/kotlin/org/fossify/gallery/adapters/MediaAdapter.kt +++ b/app/src/main/kotlin/org/fossify/gallery/adapters/MediaAdapter.kt @@ -18,25 +18,91 @@ import org.fossify.commons.adapters.MyRecyclerViewAdapter import org.fossify.commons.dialogs.PropertiesDialog import org.fossify.commons.dialogs.RenameDialog import org.fossify.commons.dialogs.RenameItemDialog -import org.fossify.commons.extensions.* -import org.fossify.commons.helpers.* +import org.fossify.commons.extensions.applyColorFilter +import org.fossify.commons.extensions.beGone +import org.fossify.commons.extensions.beVisible +import org.fossify.commons.extensions.beVisibleIf +import org.fossify.commons.extensions.convertToBitmap +import org.fossify.commons.extensions.formatSize +import org.fossify.commons.extensions.getFilenameFromPath +import org.fossify.commons.extensions.getFormattedDuration +import org.fossify.commons.extensions.getOTGPublicPath +import org.fossify.commons.extensions.getParentPath +import org.fossify.commons.extensions.getTimeFormat +import org.fossify.commons.extensions.handleDeletePasswordProtection +import org.fossify.commons.extensions.hasOTGConnected +import org.fossify.commons.extensions.internalStoragePath +import org.fossify.commons.extensions.isAStorageRootFolder +import org.fossify.commons.extensions.isAccessibleWithSAFSdk30 +import org.fossify.commons.extensions.isExternalStorageManager +import org.fossify.commons.extensions.isImageFast +import org.fossify.commons.extensions.isPathOnOTG +import org.fossify.commons.extensions.isRestrictedWithSAFSdk30 +import org.fossify.commons.extensions.needsStupidWritePermissions +import org.fossify.commons.extensions.recycleBinPath +import org.fossify.commons.extensions.rescanPaths +import org.fossify.commons.extensions.toast +import org.fossify.commons.helpers.FAVORITES +import org.fossify.commons.helpers.VIEW_TYPE_LIST +import org.fossify.commons.helpers.ensureBackgroundThread +import org.fossify.commons.helpers.isRPlus +import org.fossify.commons.helpers.sumByLong import org.fossify.commons.models.FileDirItem import org.fossify.commons.views.MyRecyclerView import org.fossify.gallery.R import org.fossify.gallery.activities.ViewPagerActivity -import org.fossify.gallery.databinding.* +import org.fossify.gallery.databinding.PhotoItemGridBinding +import org.fossify.gallery.databinding.PhotoItemListBinding +import org.fossify.gallery.databinding.ThumbnailSectionBinding +import org.fossify.gallery.databinding.VideoItemGridBinding +import org.fossify.gallery.databinding.VideoItemListBinding import org.fossify.gallery.dialogs.DeleteWithRememberDialog -import org.fossify.gallery.extensions.* -import org.fossify.gallery.helpers.* +import org.fossify.gallery.extensions.config +import org.fossify.gallery.extensions.fixDateTaken +import org.fossify.gallery.extensions.getShortcutImage +import org.fossify.gallery.extensions.handleMediaManagementPrompt +import org.fossify.gallery.extensions.launchResizeImageDialog +import org.fossify.gallery.extensions.launchResizeMultipleImagesDialog +import org.fossify.gallery.extensions.loadImage +import org.fossify.gallery.extensions.openEditor +import org.fossify.gallery.extensions.openPath +import org.fossify.gallery.extensions.rescanFolderMedia +import org.fossify.gallery.extensions.restoreRecycleBinPaths +import org.fossify.gallery.extensions.saveRotatedImageToFile +import org.fossify.gallery.extensions.setAs +import org.fossify.gallery.extensions.shareMediaPaths +import org.fossify.gallery.extensions.shareMediumPath +import org.fossify.gallery.extensions.toggleFileVisibility +import org.fossify.gallery.extensions.tryCopyMoveFilesTo +import org.fossify.gallery.extensions.updateDBMediaPath +import org.fossify.gallery.extensions.updateFavorite +import org.fossify.gallery.extensions.updateFavoritePaths +import org.fossify.gallery.helpers.PATH +import org.fossify.gallery.helpers.RECYCLE_BIN +import org.fossify.gallery.helpers.ROUNDED_CORNERS_BIG +import org.fossify.gallery.helpers.ROUNDED_CORNERS_NONE +import org.fossify.gallery.helpers.ROUNDED_CORNERS_SMALL +import org.fossify.gallery.helpers.SHOW_ALL +import org.fossify.gallery.helpers.SHOW_FAVORITES +import org.fossify.gallery.helpers.SHOW_RECYCLE_BIN +import org.fossify.gallery.helpers.TYPE_GIFS +import org.fossify.gallery.helpers.TYPE_RAWS import org.fossify.gallery.interfaces.MediaOperationsListener import org.fossify.gallery.models.Medium import org.fossify.gallery.models.ThumbnailItem import org.fossify.gallery.models.ThumbnailSection class MediaAdapter( - activity: BaseSimpleActivity, var media: ArrayList, val listener: MediaOperationsListener?, val isAGetIntent: Boolean, - val allowMultiplePicks: Boolean, val path: String, recyclerView: MyRecyclerView, itemClick: (Any) -> Unit -) : MyRecyclerViewAdapter(activity, recyclerView, itemClick), RecyclerViewFastScroller.OnPopupTextUpdate { + activity: BaseSimpleActivity, + var media: ArrayList, + val listener: MediaOperationsListener?, + val isAGetIntent: Boolean, + val allowMultiplePicks: Boolean, + val path: String, + recyclerView: MyRecyclerView, + itemClick: (Any) -> Unit +) : MyRecyclerViewAdapter(activity, recyclerView, itemClick), + RecyclerViewFastScroller.OnPopupTextUpdate { private val ITEM_SECTION = 0 private val ITEM_MEDIUM_VIDEO_PORTRAIT = 1 @@ -130,7 +196,7 @@ class MediaAdapter( findItem(R.id.cab_resize).isVisible = canResize(selectedItems) findItem(R.id.cab_confirm_selection).isVisible = isAGetIntent && allowMultiplePicks && selectedKeys.isNotEmpty() findItem(R.id.cab_restore_recycle_bin_files).isVisible = selectedPaths.all { it.startsWith(activity.recycleBinPath) } - findItem(R.id.cab_create_shortcut).isVisible = isOreoPlus() && isOneItemSelected + findItem(R.id.cab_create_shortcut).isVisible = isOneItemSelected checkHideBtnVisibility(this, selectedItems) checkFavoriteBtnVisibility(this, selectedItems) @@ -417,10 +483,6 @@ class MediaAdapter( } private fun createShortcut() { - if (!isOreoPlus()) { - return - } - val manager = activity.getSystemService(ShortcutManager::class.java) if (manager.isRequestPinShortcutSupported) { val path = getSelectedPaths().first() diff --git a/app/src/main/kotlin/org/fossify/gallery/extensions/Activity.kt b/app/src/main/kotlin/org/fossify/gallery/extensions/Activity.kt index 88bbd2fee..973e54772 100644 --- a/app/src/main/kotlin/org/fossify/gallery/extensions/Activity.kt +++ b/app/src/main/kotlin/org/fossify/gallery/extensions/Activity.kt @@ -1,6 +1,5 @@ package org.fossify.gallery.extensions -import android.annotation.TargetApi import android.app.Activity import android.content.ContentProviderOperation import android.content.ContentValues @@ -12,7 +11,6 @@ import android.graphics.Point import android.graphics.drawable.Drawable import android.graphics.drawable.LayerDrawable import android.net.Uri -import android.os.Build import android.os.Environment import android.provider.MediaStore import android.provider.MediaStore.Files @@ -689,7 +687,6 @@ fun BaseSimpleActivity.saveRotatedImageToFile(oldPath: String, newPath: String, } } -@TargetApi(Build.VERSION_CODES.N) fun Activity.tryRotateByExif(path: String, degrees: Int, showToasts: Boolean, callback: () -> Unit): Boolean { return try { val file = File(path) @@ -830,10 +827,8 @@ fun BaseSimpleActivity.launchResizeImageDialog(path: String, callback: (() -> Un fun BaseSimpleActivity.resizeImage(oldPath: String, newPath: String, size: Point, callback: (success: Boolean) -> Unit) { var oldExif: ExifInterface? = null - if (isNougatPlus()) { - val inputStream = contentResolver.openInputStream(Uri.fromFile(File(oldPath))) - oldExif = ExifInterface(inputStream!!) - } + val inputStream = contentResolver.openInputStream(Uri.fromFile(File(oldPath))) + oldExif = ExifInterface(inputStream!!) val newBitmap = Glide.with(applicationContext).asBitmap().load(oldPath).submit(size.x, size.y).get() @@ -845,10 +840,8 @@ fun BaseSimpleActivity.resizeImage(oldPath: String, newPath: String, size: Point try { newBitmap.compress(newFile.absolutePath.getCompressionFormat(), 90, out) - if (isNougatPlus()) { - val newExif = ExifInterface(newFile.absolutePath) - oldExif?.copyNonDimensionAttributesTo(newExif) - } + val newExif = ExifInterface(newFile.absolutePath) + oldExif.copyNonDimensionAttributesTo(newExif) } catch (ignored: Exception) { } @@ -907,10 +900,9 @@ fun Activity.getShortcutImage(tmb: String, drawable: Drawable, callback: () -> U } } -@TargetApi(Build.VERSION_CODES.N) fun Activity.showFileOnMap(path: String) { val exif = try { - if (path.startsWith("content://") && isNougatPlus()) { + if (path.startsWith("content://")) { ExifInterface(contentResolver.openInputStream(Uri.parse(path))!!) } else { ExifInterface(path) diff --git a/app/src/main/kotlin/org/fossify/gallery/jobs/NewPhotoFetcher.kt b/app/src/main/kotlin/org/fossify/gallery/jobs/NewPhotoFetcher.kt index db311d036..5cdee7970 100644 --- a/app/src/main/kotlin/org/fossify/gallery/jobs/NewPhotoFetcher.kt +++ b/app/src/main/kotlin/org/fossify/gallery/jobs/NewPhotoFetcher.kt @@ -1,6 +1,5 @@ package org.fossify.gallery.jobs -import android.annotation.TargetApi import android.app.job.JobInfo import android.app.job.JobInfo.TriggerContentUri import android.app.job.JobParameters @@ -10,7 +9,6 @@ import android.content.ComponentName import android.content.Context import android.database.Cursor import android.net.Uri -import android.os.Build import android.os.Handler import android.provider.MediaStore import android.provider.MediaStore.Images @@ -22,7 +20,6 @@ import org.fossify.gallery.extensions.addPathToDB import org.fossify.gallery.extensions.updateDirectoryPath // based on https://developer.android.com/reference/android/app/job/JobInfo.Builder.html#addTriggerContentUri(android.app.job.JobInfo.TriggerContentUri) -@TargetApi(Build.VERSION_CODES.N) class NewPhotoFetcher : JobService() { companion object { const val PHOTO_VIDEO_CONTENT_JOB = 1 diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index 674dc4dff..634b06e18 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -36,7 +36,7 @@ subsamplingScaleImageView = "d705c3c4ad" #build app-build-compileSDKVersion = "34" app-build-targetSDK = "34" -app-build-minimumSDK = "23" +app-build-minimumSDK = "26" app-build-javaVersion = "VERSION_17" app-build-kotlinJVMTarget = "17" #versioning