Skip to content

Commit 9e8a311

Browse files
committed
improvement in permission handling
1 parent c6c7b40 commit 9e8a311

3 files changed

Lines changed: 8 additions & 3 deletions

File tree

quickedit/src/main/java/com/abizer_r/quickedit/ui/mainScreen/MainScreen.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ fun MainScreen(
5959
isGranted = perms[permission] == true
6060
)
6161
}
62-
if (perms.values.all { true }) {
62+
if (perms.values.all { granted -> granted }) {
6363
viewModel.permissionsGranted.value = true
6464
}
6565
}

quickedit/src/main/java/com/abizer_r/quickedit/utils/FileUtils.kt

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import android.os.Environment
99
import android.provider.MediaStore
1010
import androidx.annotation.RequiresApi
1111
import androidx.core.content.FileProvider
12+
import com.abizer_r.quickedit.R
1213
import java.io.File
1314
import java.io.FileInputStream
1415

@@ -65,7 +66,8 @@ object FileUtils {
6566
copyFileToUri(context.contentResolver, file, uri)
6667
onSuccess()
6768
} else {
68-
onFailure(null)
69+
onFailure(context.getString(R.string.fail_to_insert_uri_in_content_resolver))
70+
return
6971
}
7072
}
7173

@@ -89,6 +91,7 @@ object FileUtils {
8991
copyFile(file, externalStorageDir)
9092
} catch (e: Exception) {
9193
onFailure(e.message)
94+
return
9295
}
9396

9497
// Make the file visible in the gallery
@@ -103,7 +106,8 @@ object FileUtils {
103106
copyFileToUri(context.contentResolver, file, uri)
104107
onSuccess()
105108
} else {
106-
onFailure(null)
109+
onFailure(context.getString(R.string.fail_to_insert_uri_in_content_resolver))
110+
return
107111
}
108112
}
109113

quickedit/src/main/res/values/strings.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,4 +34,5 @@
3434
<string name="following_permissions_are_required">Following permissions are required to perform this action:\n</string>
3535
<string name="perm_item_storage">- Storage\n</string>
3636
<string name="app_not_found">App not found</string>
37+
<string name="fail_to_insert_uri_in_content_resolver">Couldn\'t insert uri in content resolver</string>
3738
</resources>

0 commit comments

Comments
 (0)