mirror of
https://github.com/FossifyOrg/Gallery.git
synced 2024-11-29 16:08:00 +01:00
prepare the app for having All files permission
This commit is contained in:
parent
b3ad40739f
commit
c5d9ac6fcc
14 changed files with 56 additions and 42 deletions
|
@ -7,6 +7,7 @@ import com.simplemobiletools.commons.dialogs.FilePickerDialog
|
||||||
import com.simplemobiletools.commons.extensions.beVisibleIf
|
import com.simplemobiletools.commons.extensions.beVisibleIf
|
||||||
import com.simplemobiletools.commons.extensions.getProperTextColor
|
import com.simplemobiletools.commons.extensions.getProperTextColor
|
||||||
import com.simplemobiletools.commons.extensions.internalStoragePath
|
import com.simplemobiletools.commons.extensions.internalStoragePath
|
||||||
|
import com.simplemobiletools.commons.extensions.isExternalStorageManager
|
||||||
import com.simplemobiletools.commons.helpers.isRPlus
|
import com.simplemobiletools.commons.helpers.isRPlus
|
||||||
import com.simplemobiletools.commons.interfaces.RefreshRecyclerViewListener
|
import com.simplemobiletools.commons.interfaces.RefreshRecyclerViewListener
|
||||||
import com.simplemobiletools.gallery.pro.R
|
import com.simplemobiletools.gallery.pro.R
|
||||||
|
@ -29,7 +30,7 @@ class ExcludedFoldersActivity : SimpleActivity(), RefreshRecyclerViewListener {
|
||||||
beVisibleIf(folders.isEmpty())
|
beVisibleIf(folders.isEmpty())
|
||||||
setTextColor(getProperTextColor())
|
setTextColor(getProperTextColor())
|
||||||
|
|
||||||
if (isRPlus()) {
|
if (isRPlus() && !isExternalStorageManager()) {
|
||||||
placeholderText = placeholderText.substringBefore("\n")
|
placeholderText = placeholderText.substringBefore("\n")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -299,13 +299,13 @@ class MainActivity : SimpleActivity(), DirectoryOperationsListener {
|
||||||
findItem(R.id.hide_the_recycle_bin).isVisible = useBin && config.showRecycleBinAtFolders
|
findItem(R.id.hide_the_recycle_bin).isVisible = useBin && config.showRecycleBinAtFolders
|
||||||
findItem(R.id.show_the_recycle_bin).isVisible = useBin && !config.showRecycleBinAtFolders
|
findItem(R.id.show_the_recycle_bin).isVisible = useBin && !config.showRecycleBinAtFolders
|
||||||
findItem(R.id.set_as_default_folder).isVisible = !config.defaultFolder.isEmpty()
|
findItem(R.id.set_as_default_folder).isVisible = !config.defaultFolder.isEmpty()
|
||||||
findItem(R.id.create_new_folder).isVisible = !isRPlus()
|
findItem(R.id.create_new_folder).isVisible = !isRPlus() || isExternalStorageManager()
|
||||||
setupSearch(this)
|
setupSearch(this)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
menu.findItem(R.id.temporarily_show_hidden).isVisible = !isRPlus() && !config.shouldShowHidden
|
menu.findItem(R.id.temporarily_show_hidden).isVisible = (!isRPlus() || isExternalStorageManager()) && !config.shouldShowHidden
|
||||||
menu.findItem(R.id.stop_showing_hidden).isVisible = !isRPlus() && config.temporarilyShowHidden
|
menu.findItem(R.id.stop_showing_hidden).isVisible = (!isRPlus() || isExternalStorageManager()) && config.temporarilyShowHidden
|
||||||
|
|
||||||
updateMenuItemColors(menu)
|
updateMenuItemColors(menu)
|
||||||
return true
|
return true
|
||||||
|
@ -932,6 +932,7 @@ class MainActivity : SimpleActivity(), DirectoryOperationsListener {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// fetch files from MediaStore only, unless the app has the MANAGE_EXTERNAL_STORAGE permission on Android 11+
|
||||||
val android11Files = mLastMediaFetcher?.getAndroid11FolderMedia(getImagesOnly, getVideosOnly, favoritePaths, false, true, dateTakens)
|
val android11Files = mLastMediaFetcher?.getAndroid11FolderMedia(getImagesOnly, getVideosOnly, favoritePaths, false, true, dateTakens)
|
||||||
try {
|
try {
|
||||||
for (directory in dirs) {
|
for (directory in dirs) {
|
||||||
|
@ -1164,7 +1165,7 @@ class MainActivity : SimpleActivity(), DirectoryOperationsListener {
|
||||||
directories_empty_placeholder.text = getString(R.string.no_items_found)
|
directories_empty_placeholder.text = getString(R.string.no_items_found)
|
||||||
directories_empty_placeholder_2.beGone()
|
directories_empty_placeholder_2.beGone()
|
||||||
} else if (dirs.isEmpty() && config.filterMedia == getDefaultFileFilter()) {
|
} else if (dirs.isEmpty() && config.filterMedia == getDefaultFileFilter()) {
|
||||||
if (isRPlus()) {
|
if (isRPlus() && !isExternalStorageManager()) {
|
||||||
directories_empty_placeholder.text = getString(R.string.no_items_found)
|
directories_empty_placeholder.text = getString(R.string.no_items_found)
|
||||||
directories_empty_placeholder_2.beGone()
|
directories_empty_placeholder_2.beGone()
|
||||||
} else {
|
} else {
|
||||||
|
@ -1257,7 +1258,7 @@ class MainActivity : SimpleActivity(), DirectoryOperationsListener {
|
||||||
dirs.filter { !it.areFavorites() && !it.isRecycleBin() }.forEach {
|
dirs.filter { !it.areFavorites() && !it.isRecycleBin() }.forEach {
|
||||||
if (!getDoesFilePathExist(it.path, OTGPath)) {
|
if (!getDoesFilePathExist(it.path, OTGPath)) {
|
||||||
invalidDirs.add(it)
|
invalidDirs.add(it)
|
||||||
} else if (it.path != config.tempFolderPath && !isRPlus()) {
|
} else if (it.path != config.tempFolderPath && (!isRPlus() || isExternalStorageManager())) {
|
||||||
// avoid calling file.list() or listfiles() on Android 11+, it became way too slow
|
// avoid calling file.list() or listfiles() on Android 11+, it became way too slow
|
||||||
val children = if (isPathOnOTG(it.path)) {
|
val children = if (isPathOnOTG(it.path)) {
|
||||||
getOTGFolderChildrenNames(it.path)
|
getOTGFolderChildrenNames(it.path)
|
||||||
|
|
|
@ -240,8 +240,8 @@ class MediaActivity : SimpleActivity(), MediaOperationsListener {
|
||||||
findItem(R.id.about).isVisible = mShowAll
|
findItem(R.id.about).isVisible = mShowAll
|
||||||
findItem(R.id.create_new_folder).isVisible = !mShowAll && mPath != RECYCLE_BIN && mPath != FAVORITES
|
findItem(R.id.create_new_folder).isVisible = !mShowAll && mPath != RECYCLE_BIN && mPath != FAVORITES
|
||||||
|
|
||||||
findItem(R.id.temporarily_show_hidden).isVisible = !isRPlus() && !config.shouldShowHidden
|
findItem(R.id.temporarily_show_hidden).isVisible = (!isRPlus() || isExternalStorageManager()) && !config.shouldShowHidden
|
||||||
findItem(R.id.stop_showing_hidden).isVisible = !isRPlus() && config.temporarilyShowHidden
|
findItem(R.id.stop_showing_hidden).isVisible = (!isRPlus() || isExternalStorageManager()) && config.temporarilyShowHidden
|
||||||
|
|
||||||
findItem(R.id.set_as_default_folder).isVisible = !isDefaultFolder
|
findItem(R.id.set_as_default_folder).isVisible = !isDefaultFolder
|
||||||
findItem(R.id.unset_as_default_folder).isVisible = isDefaultFolder
|
findItem(R.id.unset_as_default_folder).isVisible = isDefaultFolder
|
||||||
|
|
|
@ -142,9 +142,9 @@ open class PhotoVideoActivity : SimpleActivity(), ViewPagerFragment.FragmentList
|
||||||
if (intent.extras?.containsKey(REAL_FILE_PATH) == true) {
|
if (intent.extras?.containsKey(REAL_FILE_PATH) == true) {
|
||||||
val realPath = intent.extras!!.getString(REAL_FILE_PATH)
|
val realPath = intent.extras!!.getString(REAL_FILE_PATH)
|
||||||
if (realPath != null && getDoesFilePathExist(realPath)) {
|
if (realPath != null && getDoesFilePathExist(realPath)) {
|
||||||
val avoidShowingHiddenFiles =
|
val isFileFolderHidden = (File(realPath).isHidden || File(realPath.getParentPath(), NOMEDIA).exists() || realPath.contains("/."))
|
||||||
isRPlus() && (File(realPath).isHidden || File(realPath.getParentPath(), NOMEDIA).exists() || realPath.contains("/."))
|
val preventShowingHiddenFile = (isRPlus() && !isExternalStorageManager()) && isFileFolderHidden
|
||||||
if (!avoidShowingHiddenFiles) {
|
if (!preventShowingHiddenFile) {
|
||||||
if (realPath.getFilenameFromPath().contains('.') || filename.contains('.')) {
|
if (realPath.getFilenameFromPath().contains('.') || filename.contains('.')) {
|
||||||
if (isFileTypeVisible(realPath)) {
|
if (isFileTypeVisible(realPath)) {
|
||||||
bottom_actions.beGone()
|
bottom_actions.beGone()
|
||||||
|
@ -168,14 +168,15 @@ open class PhotoVideoActivity : SimpleActivity(), ViewPagerFragment.FragmentList
|
||||||
}
|
}
|
||||||
return
|
return
|
||||||
} else {
|
} else {
|
||||||
val path = applicationContext.getRealPathFromURI(mUri!!) ?: ""
|
val realPath = applicationContext.getRealPathFromURI(mUri!!) ?: ""
|
||||||
val avoidShowingHiddenFiles = isRPlus() && File(path).isHidden
|
val isFileFolderHidden = (File(realPath).isHidden || File(realPath.getParentPath(), NOMEDIA).exists() || realPath.contains("/."))
|
||||||
if (!avoidShowingHiddenFiles) {
|
val preventShowingHiddenFile = (isRPlus() && !isExternalStorageManager()) && isFileFolderHidden
|
||||||
if (path != mUri.toString() && path.isNotEmpty() && mUri!!.authority != "mms" && filename.contains('.') && getDoesFilePathExist(path)) {
|
if (!preventShowingHiddenFile) {
|
||||||
if (isFileTypeVisible(path)) {
|
if (realPath != mUri.toString() && realPath.isNotEmpty() && mUri!!.authority != "mms" && filename.contains('.') && getDoesFilePathExist(realPath)) {
|
||||||
|
if (isFileTypeVisible(realPath)) {
|
||||||
bottom_actions.beGone()
|
bottom_actions.beGone()
|
||||||
rescanPaths(arrayListOf(mUri!!.path!!))
|
rescanPaths(arrayListOf(mUri!!.path!!))
|
||||||
sendViewPagerIntent(path)
|
sendViewPagerIntent(realPath)
|
||||||
finish()
|
finish()
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
|
@ -168,7 +168,7 @@ class SettingsActivity : SimpleActivity() {
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun setupFileLoadingPriority() {
|
private fun setupFileLoadingPriority() {
|
||||||
settings_file_loading_priority_holder.beGoneIf(isRPlus())
|
settings_file_loading_priority_holder.beGoneIf(isRPlus() && !isExternalStorageManager())
|
||||||
settings_file_loading_priority.text = getFileLoadingPriorityText()
|
settings_file_loading_priority.text = getFileLoadingPriorityText()
|
||||||
settings_file_loading_priority_holder.setOnClickListener {
|
settings_file_loading_priority_holder.setOnClickListener {
|
||||||
val items = arrayListOf(
|
val items = arrayListOf(
|
||||||
|
@ -193,7 +193,7 @@ class SettingsActivity : SimpleActivity() {
|
||||||
)
|
)
|
||||||
|
|
||||||
private fun setupManageIncludedFolders() {
|
private fun setupManageIncludedFolders() {
|
||||||
settings_manage_included_folders_holder.beGoneIf(isRPlus())
|
settings_manage_included_folders_holder.beGoneIf(isRPlus() && !isExternalStorageManager())
|
||||||
settings_manage_included_folders_holder.setOnClickListener {
|
settings_manage_included_folders_holder.setOnClickListener {
|
||||||
startActivity(Intent(this, IncludedFoldersActivity::class.java))
|
startActivity(Intent(this, IncludedFoldersActivity::class.java))
|
||||||
}
|
}
|
||||||
|
@ -215,7 +215,7 @@ class SettingsActivity : SimpleActivity() {
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun setupShowHiddenItems() {
|
private fun setupShowHiddenItems() {
|
||||||
if (isRPlus()) {
|
if (isRPlus() && !isExternalStorageManager()) {
|
||||||
settings_show_hidden_items_holder.beGone()
|
settings_show_hidden_items_holder.beGone()
|
||||||
settings_manage_excluded_folders_holder.background = resources.getDrawable(R.drawable.ripple_bottom_corners, theme)
|
settings_manage_excluded_folders_holder.background = resources.getDrawable(R.drawable.ripple_bottom_corners, theme)
|
||||||
}
|
}
|
||||||
|
@ -315,7 +315,7 @@ class SettingsActivity : SimpleActivity() {
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun setupHiddenItemPasswordProtection() {
|
private fun setupHiddenItemPasswordProtection() {
|
||||||
settings_hidden_item_password_protection_holder.beGoneIf(isRPlus())
|
settings_hidden_item_password_protection_holder.beGoneIf(isRPlus() && !isExternalStorageManager())
|
||||||
settings_hidden_item_password_protection.isChecked = config.isHiddenPasswordProtectionOn
|
settings_hidden_item_password_protection.isChecked = config.isHiddenPasswordProtectionOn
|
||||||
settings_hidden_item_password_protection_holder.setOnClickListener {
|
settings_hidden_item_password_protection_holder.setOnClickListener {
|
||||||
val tabToShow = if (config.isHiddenPasswordProtectionOn) config.hiddenProtectionType else SHOW_ALL_TABS
|
val tabToShow = if (config.isHiddenPasswordProtectionOn) config.hiddenProtectionType else SHOW_ALL_TABS
|
||||||
|
|
|
@ -203,13 +203,17 @@ class ViewPagerActivity : SimpleActivity(), ViewPager.OnPageChangeListener, View
|
||||||
findItem(R.id.menu_print).isVisible = currentMedium.isImage() || currentMedium.isRaw()
|
findItem(R.id.menu_print).isVisible = currentMedium.isImage() || currentMedium.isRaw()
|
||||||
findItem(R.id.menu_resize).isVisible = visibleBottomActions and BOTTOM_ACTION_RESIZE == 0 && currentMedium.isImage()
|
findItem(R.id.menu_resize).isVisible = visibleBottomActions and BOTTOM_ACTION_RESIZE == 0 && currentMedium.isImage()
|
||||||
findItem(R.id.menu_hide).isVisible =
|
findItem(R.id.menu_hide).isVisible =
|
||||||
!isRPlus() && !currentMedium.isHidden() && visibleBottomActions and BOTTOM_ACTION_TOGGLE_VISIBILITY == 0 && !currentMedium.getIsInRecycleBin()
|
(!isRPlus() || isExternalStorageManager()) && !currentMedium.isHidden() && visibleBottomActions and BOTTOM_ACTION_TOGGLE_VISIBILITY == 0 && !currentMedium.getIsInRecycleBin()
|
||||||
|
|
||||||
findItem(R.id.menu_unhide).isVisible =
|
findItem(R.id.menu_unhide).isVisible =
|
||||||
!isRPlus() && currentMedium.isHidden() && visibleBottomActions and BOTTOM_ACTION_TOGGLE_VISIBILITY == 0 && !currentMedium.getIsInRecycleBin()
|
(!isRPlus() || isExternalStorageManager()) && currentMedium.isHidden() && visibleBottomActions and BOTTOM_ACTION_TOGGLE_VISIBILITY == 0 && !currentMedium.getIsInRecycleBin()
|
||||||
|
|
||||||
findItem(R.id.menu_add_to_favorites).isVisible =
|
findItem(R.id.menu_add_to_favorites).isVisible =
|
||||||
!currentMedium.isFavorite && visibleBottomActions and BOTTOM_ACTION_TOGGLE_FAVORITE == 0 && !currentMedium.getIsInRecycleBin()
|
!currentMedium.isFavorite && visibleBottomActions and BOTTOM_ACTION_TOGGLE_FAVORITE == 0 && !currentMedium.getIsInRecycleBin()
|
||||||
|
|
||||||
findItem(R.id.menu_remove_from_favorites).isVisible =
|
findItem(R.id.menu_remove_from_favorites).isVisible =
|
||||||
currentMedium.isFavorite && visibleBottomActions and BOTTOM_ACTION_TOGGLE_FAVORITE == 0 && !currentMedium.getIsInRecycleBin()
|
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_restore_file).isVisible = currentMedium.path.startsWith(recycleBinPath)
|
||||||
findItem(R.id.menu_create_shortcut).isVisible = isOreoPlus()
|
findItem(R.id.menu_create_shortcut).isVisible = isOreoPlus()
|
||||||
findItem(R.id.menu_change_orientation).isVisible = rotationDegrees == 0 && visibleBottomActions and BOTTOM_ACTION_CHANGE_ORIENTATION == 0
|
findItem(R.id.menu_change_orientation).isVisible = rotationDegrees == 0 && visibleBottomActions and BOTTOM_ACTION_CHANGE_ORIENTATION == 0
|
||||||
|
@ -1188,7 +1192,7 @@ class ViewPagerActivity : SimpleActivity(), ViewPager.OnPageChangeListener, View
|
||||||
val oldPath = getCurrentPath()
|
val oldPath = getCurrentPath()
|
||||||
|
|
||||||
val isSDOrOtgRootFolder = isAStorageRootFolder(oldPath.getParentPath()) && !oldPath.startsWith(internalStoragePath)
|
val isSDOrOtgRootFolder = isAStorageRootFolder(oldPath.getParentPath()) && !oldPath.startsWith(internalStoragePath)
|
||||||
if (isRPlus() && isSDOrOtgRootFolder) {
|
if (isRPlus() && isSDOrOtgRootFolder && !isExternalStorageManager()) {
|
||||||
toast(R.string.rename_in_sd_card_system_restriction, Toast.LENGTH_LONG)
|
toast(R.string.rename_in_sd_card_system_restriction, Toast.LENGTH_LONG)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,12 +5,14 @@ import android.content.pm.ShortcutInfo
|
||||||
import android.content.pm.ShortcutManager
|
import android.content.pm.ShortcutManager
|
||||||
import android.graphics.drawable.ColorDrawable
|
import android.graphics.drawable.ColorDrawable
|
||||||
import android.graphics.drawable.Icon
|
import android.graphics.drawable.Icon
|
||||||
|
import android.os.Build
|
||||||
import android.text.TextUtils
|
import android.text.TextUtils
|
||||||
import android.view.Menu
|
import android.view.Menu
|
||||||
import android.view.MotionEvent
|
import android.view.MotionEvent
|
||||||
import android.view.View
|
import android.view.View
|
||||||
import android.view.ViewGroup
|
import android.view.ViewGroup
|
||||||
import android.widget.RelativeLayout
|
import android.widget.RelativeLayout
|
||||||
|
import androidx.annotation.RequiresApi
|
||||||
import androidx.recyclerview.widget.ItemTouchHelper
|
import androidx.recyclerview.widget.ItemTouchHelper
|
||||||
import androidx.recyclerview.widget.RecyclerView
|
import androidx.recyclerview.widget.RecyclerView
|
||||||
import androidx.swiperefreshlayout.widget.SwipeRefreshLayout
|
import androidx.swiperefreshlayout.widget.SwipeRefreshLayout
|
||||||
|
@ -190,8 +192,11 @@ class DirectoryAdapter(
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun checkHideBtnVisibility(menu: Menu, selectedPaths: ArrayList<String>) {
|
private fun checkHideBtnVisibility(menu: Menu, selectedPaths: ArrayList<String>) {
|
||||||
menu.findItem(R.id.cab_hide).isVisible = !isRPlus() && selectedPaths.any { !it.doesThisOrParentHaveNoMedia(HashMap(), null) }
|
menu.findItem(R.id.cab_hide).isVisible =
|
||||||
menu.findItem(R.id.cab_unhide).isVisible = !isRPlus() && selectedPaths.any { it.doesThisOrParentHaveNoMedia(HashMap(), null) }
|
(!isRPlus() || isExternalStorageManager()) && selectedPaths.any { !it.doesThisOrParentHaveNoMedia(HashMap(), null) }
|
||||||
|
|
||||||
|
menu.findItem(R.id.cab_unhide).isVisible =
|
||||||
|
(!isRPlus() || isExternalStorageManager()) && selectedPaths.any { it.doesThisOrParentHaveNoMedia(HashMap(), null) }
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun checkPinBtnVisibility(menu: Menu, selectedPaths: ArrayList<String>) {
|
private fun checkPinBtnVisibility(menu: Menu, selectedPaths: ArrayList<String>) {
|
||||||
|
@ -548,6 +553,7 @@ class DirectoryAdapter(
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@RequiresApi(Build.VERSION_CODES.O)
|
||||||
private fun createShortcut() {
|
private fun createShortcut() {
|
||||||
val manager = activity.getSystemService(ShortcutManager::class.java)
|
val manager = activity.getSystemService(ShortcutManager::class.java)
|
||||||
if (manager.isRequestPinShortcutSupported) {
|
if (manager.isRequestPinShortcutSupported) {
|
||||||
|
|
|
@ -211,8 +211,8 @@ class MediaAdapter(
|
||||||
|
|
||||||
private fun checkHideBtnVisibility(menu: Menu, selectedItems: ArrayList<Medium>) {
|
private fun checkHideBtnVisibility(menu: Menu, selectedItems: ArrayList<Medium>) {
|
||||||
val isInRecycleBin = selectedItems.firstOrNull()?.getIsInRecycleBin() == true
|
val isInRecycleBin = selectedItems.firstOrNull()?.getIsInRecycleBin() == true
|
||||||
menu.findItem(R.id.cab_hide).isVisible = !isRPlus() && !isInRecycleBin && selectedItems.any { !it.isHidden() }
|
menu.findItem(R.id.cab_hide).isVisible = (!isRPlus() || isExternalStorageManager()) && !isInRecycleBin && selectedItems.any { !it.isHidden() }
|
||||||
menu.findItem(R.id.cab_unhide).isVisible = !isRPlus() && !isInRecycleBin && selectedItems.any { it.isHidden() }
|
menu.findItem(R.id.cab_unhide).isVisible = (!isRPlus() || isExternalStorageManager()) && !isInRecycleBin && selectedItems.any { it.isHidden() }
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun checkFavoriteBtnVisibility(menu: Menu, selectedItems: ArrayList<Medium>) {
|
private fun checkFavoriteBtnVisibility(menu: Menu, selectedItems: ArrayList<Medium>) {
|
||||||
|
|
|
@ -82,7 +82,7 @@ class SaveAsDialog(
|
||||||
val newFile = File(newPath)
|
val newFile = File(newPath)
|
||||||
val isInDownloadDir = activity.isInDownloadDir(newPath)
|
val isInDownloadDir = activity.isInDownloadDir(newPath)
|
||||||
val isInSubFolderInDownloadDir = activity.isInSubFolderInDownloadDir(newPath)
|
val isInSubFolderInDownloadDir = activity.isInSubFolderInDownloadDir(newPath)
|
||||||
if (isRPlus() && isInDownloadDir && !isInSubFolderInDownloadDir && !newFile.canWrite()) {
|
if ((isRPlus() && !isExternalStorageManager()) && isInDownloadDir && !isInSubFolderInDownloadDir && !newFile.canWrite()) {
|
||||||
val fileDirItem = arrayListOf(File(newPath).toFileDirItem(activity))
|
val fileDirItem = arrayListOf(File(newPath).toFileDirItem(activity))
|
||||||
val fileUris = activity.getFileUrisFromFileDirItems(fileDirItem).second
|
val fileUris = activity.getFileUrisFromFileDirItems(fileDirItem).second
|
||||||
activity.updateSDK30Uris(fileUris) { success ->
|
activity.updateSDK30Uris(fileUris) { success ->
|
||||||
|
|
|
@ -117,7 +117,7 @@ fun SimpleActivity.launchAbout() {
|
||||||
faqItems.add(FAQItem(R.string.faq_10_title_commons, R.string.faq_10_text_commons))
|
faqItems.add(FAQItem(R.string.faq_10_title_commons, R.string.faq_10_text_commons))
|
||||||
}
|
}
|
||||||
|
|
||||||
if (isRPlus()) {
|
if (isRPlus() && !isExternalStorageManager()) {
|
||||||
faqItems.add(0, FAQItem(R.string.faq_16_title, R.string.faq_16_text))
|
faqItems.add(0, FAQItem(R.string.faq_16_title, R.string.faq_16_text))
|
||||||
faqItems.add(1, FAQItem(R.string.faq_17_title, R.string.faq_17_text))
|
faqItems.add(1, FAQItem(R.string.faq_17_title, R.string.faq_17_text))
|
||||||
faqItems.removeIf { it.text == R.string.faq_7_text }
|
faqItems.removeIf { it.text == R.string.faq_7_text }
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
package com.simplemobiletools.gallery.pro.extensions
|
package com.simplemobiletools.gallery.pro.extensions
|
||||||
|
|
||||||
import android.os.Environment
|
import android.os.Environment
|
||||||
|
import com.simplemobiletools.commons.extensions.isExternalStorageManager
|
||||||
import com.simplemobiletools.commons.helpers.NOMEDIA
|
import com.simplemobiletools.commons.helpers.NOMEDIA
|
||||||
import com.simplemobiletools.commons.helpers.isRPlus
|
import com.simplemobiletools.commons.helpers.isRPlus
|
||||||
import java.io.File
|
import java.io.File
|
||||||
|
@ -41,7 +42,7 @@ fun String.shouldFolderBeVisible(
|
||||||
val containsNoMedia = if (showHidden) {
|
val containsNoMedia = if (showHidden) {
|
||||||
false
|
false
|
||||||
} else {
|
} else {
|
||||||
folderNoMediaStatuses.getOrElse("$this/$NOMEDIA", { false }) || (!isRPlus() && File(this, NOMEDIA).exists())
|
folderNoMediaStatuses.getOrElse("$this/$NOMEDIA") { false } || ((!isRPlus() || isExternalStorageManager()) && File(this, NOMEDIA).exists())
|
||||||
}
|
}
|
||||||
|
|
||||||
return if (!showHidden && containsNoMedia) {
|
return if (!showHidden && containsNoMedia) {
|
||||||
|
|
|
@ -167,31 +167,31 @@ class PhotoFragment : ViewPagerFragment() {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (mMedium.path.startsWith("content://") && !mMedium.path.startsWith("content://mms/")) {
|
if (mMedium.path.startsWith("content://") && !mMedium.path.startsWith("content://mms/")) {
|
||||||
mMedium.path = context!!.getRealPathFromURI(Uri.parse(mOriginalPath)) ?: mMedium.path
|
mMedium.path = requireContext().getRealPathFromURI(Uri.parse(mOriginalPath)) ?: mMedium.path
|
||||||
if (isRPlus() && mMedium.path.startsWith("/storage/") && mMedium.isHidden()) {
|
if (isRPlus() && !isExternalStorageManager() && mMedium.path.startsWith("/storage/") && mMedium.isHidden()) {
|
||||||
mMedium.path = mOriginalPath
|
mMedium.path = mOriginalPath
|
||||||
}
|
}
|
||||||
|
|
||||||
if (mMedium.path.isEmpty()) {
|
if (mMedium.path.isEmpty()) {
|
||||||
var out: FileOutputStream? = null
|
var out: FileOutputStream? = null
|
||||||
try {
|
try {
|
||||||
var inputStream = context!!.contentResolver.openInputStream(Uri.parse(mOriginalPath))
|
var inputStream = requireContext().contentResolver.openInputStream(Uri.parse(mOriginalPath))
|
||||||
val exif = ExifInterface()
|
val exif = ExifInterface()
|
||||||
exif.readExif(inputStream, ExifInterface.Options.OPTION_ALL)
|
exif.readExif(inputStream, ExifInterface.Options.OPTION_ALL)
|
||||||
val tag = exif.getTag(ExifInterface.TAG_ORIENTATION)
|
val tag = exif.getTag(ExifInterface.TAG_ORIENTATION)
|
||||||
val orientation = tag?.getValueAsInt(-1) ?: -1
|
val orientation = tag?.getValueAsInt(-1) ?: -1
|
||||||
inputStream = context!!.contentResolver.openInputStream(Uri.parse(mOriginalPath))
|
inputStream = requireContext().contentResolver.openInputStream(Uri.parse(mOriginalPath))
|
||||||
val original = BitmapFactory.decodeStream(inputStream)
|
val original = BitmapFactory.decodeStream(inputStream)
|
||||||
val rotated = rotateViaMatrix(original, orientation)
|
val rotated = rotateViaMatrix(original, orientation)
|
||||||
exif.setTagValue(ExifInterface.TAG_ORIENTATION, 1)
|
exif.setTagValue(ExifInterface.TAG_ORIENTATION, 1)
|
||||||
exif.removeCompressedThumbnail()
|
exif.removeCompressedThumbnail()
|
||||||
|
|
||||||
val file = File(context!!.externalCacheDir, Uri.parse(mOriginalPath).lastPathSegment)
|
val file = File(requireContext().externalCacheDir, Uri.parse(mOriginalPath).lastPathSegment)
|
||||||
out = FileOutputStream(file)
|
out = FileOutputStream(file)
|
||||||
rotated.compress(Bitmap.CompressFormat.JPEG, 100, out)
|
rotated.compress(Bitmap.CompressFormat.JPEG, 100, out)
|
||||||
mMedium.path = file.absolutePath
|
mMedium.path = file.absolutePath
|
||||||
} catch (e: Exception) {
|
} catch (e: Exception) {
|
||||||
activity!!.toast(R.string.unknown_error_occurred)
|
requireActivity().toast(R.string.unknown_error_occurred)
|
||||||
return mView
|
return mView
|
||||||
} finally {
|
} finally {
|
||||||
out?.close()
|
out?.close()
|
||||||
|
@ -199,7 +199,7 @@ class PhotoFragment : ViewPagerFragment() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
mIsFullscreen = activity!!.window.decorView.systemUiVisibility and View.SYSTEM_UI_FLAG_FULLSCREEN == View.SYSTEM_UI_FLAG_FULLSCREEN
|
mIsFullscreen = requireActivity().window.decorView.systemUiVisibility and View.SYSTEM_UI_FLAG_FULLSCREEN == View.SYSTEM_UI_FLAG_FULLSCREEN
|
||||||
loadImage()
|
loadImage()
|
||||||
initExtendedDetails()
|
initExtendedDetails()
|
||||||
mWasInit = true
|
mWasInit = true
|
||||||
|
|
|
@ -42,7 +42,7 @@ class MediaFetcher(val context: Context) {
|
||||||
curMedia.addAll(newMedia)
|
curMedia.addAll(newMedia)
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (curPath != FAVORITES && curPath != RECYCLE_BIN && isRPlus()) {
|
if (curPath != FAVORITES && curPath != RECYCLE_BIN && isRPlus() && !isExternalStorageManager()) {
|
||||||
if (android11Files?.containsKey(curPath.toLowerCase()) == true) {
|
if (android11Files?.containsKey(curPath.toLowerCase()) == true) {
|
||||||
curMedia.addAll(android11Files[curPath.toLowerCase()]!!)
|
curMedia.addAll(android11Files[curPath.toLowerCase()]!!)
|
||||||
} else if (android11Files == null) {
|
} else if (android11Files == null) {
|
||||||
|
@ -59,7 +59,7 @@ class MediaFetcher(val context: Context) {
|
||||||
favoritePaths, getVideoDurations, lastModifieds.clone() as HashMap<String, Long>, dateTakens.clone() as HashMap<String, Long>
|
favoritePaths, getVideoDurations, lastModifieds.clone() as HashMap<String, Long>, dateTakens.clone() as HashMap<String, Long>
|
||||||
)
|
)
|
||||||
|
|
||||||
if (curPath == FAVORITES && isRPlus()) {
|
if (curPath == FAVORITES && isRPlus() && !isExternalStorageManager()) {
|
||||||
val files =
|
val files =
|
||||||
getAndroid11FolderMedia(isPickImage, isPickVideo, favoritePaths, true, getProperDateTaken, dateTakens.clone() as HashMap<String, Long>)
|
getAndroid11FolderMedia(isPickImage, isPickVideo, favoritePaths, true, getProperDateTaken, dateTakens.clone() as HashMap<String, Long>)
|
||||||
newMedia.forEach { newMedium ->
|
newMedia.forEach { newMedium ->
|
||||||
|
@ -429,7 +429,7 @@ class MediaFetcher(val context: Context) {
|
||||||
dateTakens: HashMap<String, Long>
|
dateTakens: HashMap<String, Long>
|
||||||
): HashMap<String, ArrayList<Medium>> {
|
): HashMap<String, ArrayList<Medium>> {
|
||||||
val media = HashMap<String, ArrayList<Medium>>()
|
val media = HashMap<String, ArrayList<Medium>>()
|
||||||
if (!isRPlus()) {
|
if (!isRPlus() || Environment.isExternalStorageManager()) {
|
||||||
return media
|
return media
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -208,7 +208,7 @@ class NewPhotoEditActivity : SimpleActivity() {
|
||||||
|
|
||||||
// In case the user wants to overwrite the original file and it is on an SD card, delete it manually first. Else the system just appends (1)
|
// In case the user wants to overwrite the original file and it is on an SD card, delete it manually first. Else the system just appends (1)
|
||||||
private fun handleFileOverwriting(path: String, callback: () -> Unit) {
|
private fun handleFileOverwriting(path: String, callback: () -> Unit) {
|
||||||
if (!isRPlus() && getDoesFilePathExist(path) && isPathOnSD(path)) {
|
if ((!isRPlus() || isExternalStorageManager()) && getDoesFilePathExist(path) && isPathOnSD(path)) {
|
||||||
val fileDirItem = FileDirItem(path, path.getFilenameFromPath())
|
val fileDirItem = FileDirItem(path, path.getFilenameFromPath())
|
||||||
tryDeleteFileDirItem(fileDirItem, false, true) { success ->
|
tryDeleteFileDirItem(fileDirItem, false, true) { success ->
|
||||||
if (success) {
|
if (success) {
|
||||||
|
|
Loading…
Reference in a new issue