Changes after review

This commit is contained in:
MohitMali 2022-04-22 12:14:44 +05:30 committed by Emmanuel Engelhart
parent 62202448f9
commit 2ed2843540
No known key found for this signature in database
GPG Key ID: 120B30D020B553D3
5 changed files with 29 additions and 17 deletions

View File

@ -292,7 +292,11 @@ class OnlineLibraryFragment : BaseFragment(), FragmentActivityExtensions {
getPathFromUri(requireActivity(), data)?.let(sharedPreferenceUtil::putPrefStorage) getPathFromUri(requireActivity(), data)?.let(sharedPreferenceUtil::putPrefStorage)
sharedPreferenceUtil.putStoragePosition(EXTERNAL_SELECT_POSITION) sharedPreferenceUtil.putStoragePosition(EXTERNAL_SELECT_POSITION)
} ?: run { } ?: run {
activity.toast(resources.getString(R.string.error_occurred), Toast.LENGTH_SHORT) activity.toast(
resources
.getString(R.string.system_unable_to_grant_permission_message),
Toast.LENGTH_SHORT
)
} }
} }
} }

View File

@ -6,5 +6,4 @@
<string name="cannot_open_file">Failed to open file\nPlease try looking for this file in the Device Tab of your Library</string> <string name="cannot_open_file">Failed to open file\nPlease try looking for this file in the Device Tab of your Library</string>
<string name="send_files_title">Send Files</string> <string name="send_files_title">Send Files</string>
<string name="receive_files_title">Receive Files</string> <string name="receive_files_title">Receive Files</string>
<string name="error_occurred" translatable="false">System unable to grant permission!</string>
</resources> </resources>

View File

@ -45,7 +45,6 @@ dependencies {
// SquiDB // SquiDB
implementation(Libs.squidb) implementation(Libs.squidb)
implementation(Libs.squidb_annotations) implementation(Libs.squidb_annotations)
implementation("androidx.documentfile:documentfile:1.0.1")
add("kapt", Libs.squidb_processor) add("kapt", Libs.squidb_processor)
// Document File // Document File

View File

@ -242,25 +242,35 @@ object FileUtils {
or Intent.FLAG_GRANT_WRITE_URI_PERMISSION) or Intent.FLAG_GRANT_WRITE_URI_PERMISSION)
uri?.let { uri?.let {
activity.grantUriPermission( activity.grantUriPermission(
activity.packageName, uri, activity.packageName, it,
Intent.FLAG_GRANT_READ_URI_PERMISSION or Intent.FLAG_GRANT_WRITE_URI_PERMISSION Intent.FLAG_GRANT_READ_URI_PERMISSION or Intent.FLAG_GRANT_WRITE_URI_PERMISSION
) )
activity.contentResolver.takePersistableUriPermission(uri, takeFlags) activity.contentResolver.takePersistableUriPermission(it, takeFlags)
val dFile = DocumentFile.fromTreeUri(activity, uri) val dFile = DocumentFile.fromTreeUri(activity, it)
if (dFile != null) { if (dFile != null) {
val originalPath = dFile.uri.path!!.substring( dFile.uri.path?.let { file ->
dFile.uri.path!!.lastIndexOf(":") + 1 val originalPath = file.substring(
) file.lastIndexOf(":") + 1
val path = "${activity.getExternalFilesDirs("")[1]}" )
return@getPathFromUri path.substringBefore( val path = "${activity.getExternalFilesDirs("")[1]}"
activity.getString(R.string.android_directory_seperator) return@getPathFromUri path.substringBefore(
) activity.getString(R.string.android_directory_seperator)
.plus(File.separator).plus(originalPath) )
.plus(File.separator).plus(originalPath)
}
} }
activity.toast(activity.resources.getString(R.string.error_occurred), Toast.LENGTH_SHORT) activity.toast(
activity.resources
.getString(R.string.system_unable_to_grant_permission_message),
Toast.LENGTH_SHORT
)
} ?: run { } ?: run {
activity.toast(activity.resources.getString(R.string.error_occurred), Toast.LENGTH_SHORT) activity.toast(
activity.resources
.getString(R.string.system_unable_to_grant_permission_message),
Toast.LENGTH_SHORT
)
} }
return null return null
} }

View File

@ -297,7 +297,7 @@
<string name="not_allowed">Not allowed</string> <string name="not_allowed">Not allowed</string>
<string name="android_directory_seperator" translatable="false">/Android</string> <string name="android_directory_seperator" translatable="false">/Android</string>
<string name="select_folder" translatable="false">Please select a folder for external storage.</string> <string name="select_folder" translatable="false">Please select a folder for external storage.</string>
<string name="error_occurred" translatable="false">System unable to grant permission!</string> <string name="system_unable_to_grant_permission_message" translatable="false">System unable to grant permission!</string>
<string-array name="pref_night_modes_entries"> <string-array name="pref_night_modes_entries">
<item>@string/on</item> <item>@string/on</item>
<item>@string/off</item> <item>@string/off</item>