handle OTG permissions dialog the same way as SD card permission

This commit is contained in:
tibbi 2019-02-16 09:38:27 +01:00
parent 0136b557da
commit c8e178f270
4 changed files with 5 additions and 4 deletions

View File

@ -61,7 +61,7 @@ android {
} }
dependencies { dependencies {
implementation 'com.simplemobiletools:commons:5.7.17' implementation 'com.simplemobiletools:commons:5.7.22'
implementation 'com.theartofdev.edmodo:android-image-cropper:2.8.0' implementation 'com.theartofdev.edmodo:android-image-cropper:2.8.0'
implementation 'androidx.multidex:multidex:2.0.1' implementation 'androidx.multidex:multidex:2.0.1'
implementation 'it.sephiroth.android.exif:library:1.0.1' implementation 'it.sephiroth.android.exif:library:1.0.1'

View File

@ -376,7 +376,7 @@ class MainActivity : SimpleActivity(), DirectoryOperationsListener {
if (hasOTGConnected()) { if (hasOTGConnected()) {
runOnUiThread { runOnUiThread {
ConfirmationDialog(this, getString(R.string.usb_detected), positive = R.string.ok, negative = 0) { ConfirmationDialog(this, getString(R.string.usb_detected), positive = R.string.ok, negative = 0) {
handleOTGPermission { handleSAFDialog(config.OTGPath) {
if (config.OTGPartition.isNotEmpty()) { if (config.OTGPartition.isNotEmpty()) {
config.addIncludedFolder(config.OTGPath) config.addIncludedFolder(config.OTGPath)
} }

View File

@ -584,11 +584,12 @@ class ViewPagerActivity : SimpleActivity(), ViewPager.OnPageChangeListener, View
private fun saveImageAs() { private fun saveImageAs() {
val currPath = getCurrentPath() val currPath = getCurrentPath()
SaveAsDialog(this, currPath, false) { SaveAsDialog(this, currPath, false) {
val newPath = it
handleSAFDialog(it) { handleSAFDialog(it) {
toast(R.string.saving) toast(R.string.saving)
Thread { Thread {
val photoFragment = getCurrentPhotoFragment() ?: return@Thread val photoFragment = getCurrentPhotoFragment() ?: return@Thread
saveRotatedImageToFile(currPath, it, photoFragment.mCurrentRotationDegrees, true) { saveRotatedImageToFile(currPath, newPath, photoFragment.mCurrentRotationDegrees, true) {
toast(R.string.file_saved) toast(R.string.file_saved)
getCurrentPhotoFragment()?.mCurrentRotationDegrees = 0 getCurrentPhotoFragment()?.mCurrentRotationDegrees = 0
invalidateOptionsMenu() invalidateOptionsMenu()

View File

@ -373,7 +373,7 @@ class MediaAdapter(activity: BaseSimpleActivity, var media: MutableList<Thumbnai
return return
} }
val SAFPath = getSelectedPaths().firstOrNull { activity.isPathOnSD(it) } ?: getFirstSelectedItemPath() ?: return val SAFPath = getSelectedPaths().firstOrNull { activity.needsStupidWritePermissions(it) } ?: getFirstSelectedItemPath() ?: return
activity.handleSAFDialog(SAFPath) { activity.handleSAFDialog(SAFPath) {
val fileDirItems = ArrayList<FileDirItem>(selectedKeys.size) val fileDirItems = ArrayList<FileDirItem>(selectedKeys.size)
val removeMedia = ArrayList<Medium>(selectedKeys.size) val removeMedia = ArrayList<Medium>(selectedKeys.size)