diff --git a/app/src/main/java/be/scri/activities/BaseSimpleActivity.kt b/app/src/main/java/be/scri/activities/BaseSimpleActivity.kt index c61f4fc2..7bd6a514 100644 --- a/app/src/main/java/be/scri/activities/BaseSimpleActivity.kt +++ b/app/src/main/java/be/scri/activities/BaseSimpleActivity.kt @@ -336,7 +336,7 @@ abstract class BaseSimpleActivity : AppCompatActivity() { } else if (requestCode == OPEN_DOCUMENT_TREE_FOR_ANDROID_DATA_OR_OBB) { if (resultCode == Activity.RESULT_OK && resultData != null && resultData.data != null) { if (isProperAndroidRoot(checkedDocumentPath, resultData.data!!)) { - if (resultData.dataString == baseConfig.OTGTreeUri || resultData.dataString == baseConfig.sdTreeUri) { + if (resultData.dataString == baseConfig.otgTreeUri || resultData.dataString == baseConfig.sdTreeUri) { val pathToSelect = createAndroidDataOrObbPath(checkedDocumentPath) toast(getString(R.string.wrong_folder_selected, pathToSelect)) return @@ -378,7 +378,7 @@ abstract class BaseSimpleActivity : AppCompatActivity() { resultData.dataString!!.contains(partition) ) if (isProperSDRootFolder(resultData.data!!) && isProperPartition) { - if (resultData.dataString == baseConfig.OTGTreeUri) { + if (resultData.dataString == baseConfig.otgTreeUri) { toast(R.string.sd_card_usb_same) return } @@ -416,9 +416,9 @@ abstract class BaseSimpleActivity : AppCompatActivity() { toast(R.string.sd_card_usb_same) return } - baseConfig.OTGTreeUri = resultData.dataString!! - baseConfig.OTGPartition = - baseConfig.OTGTreeUri + baseConfig.otgTreeUri = resultData.dataString!! + baseConfig.otgPartition = + baseConfig.otgTreeUri .removeSuffix("%3A") .substringAfterLast('/') .trimEnd('/') @@ -589,7 +589,7 @@ abstract class BaseSimpleActivity : AppCompatActivity() { fun handleOTGPermission(callback: (success: Boolean) -> Unit) { hideKeyboard() - if (baseConfig.OTGTreeUri.isNotEmpty()) { + if (baseConfig.otgTreeUri.isNotEmpty()) { callback(true) return } diff --git a/app/src/main/java/be/scri/helpers/ViewPagerAdapter.kt b/app/src/main/java/be/scri/adapters/ViewPagerAdapter.kt similarity index 100% rename from app/src/main/java/be/scri/helpers/ViewPagerAdapter.kt rename to app/src/main/java/be/scri/adapters/ViewPagerAdapter.kt diff --git a/app/src/main/java/be/scri/extensions/Activity.kt b/app/src/main/java/be/scri/extensions/Activity.kt index ea5a011c..e47d5db1 100644 --- a/app/src/main/java/be/scri/extensions/Activity.kt +++ b/app/src/main/java/be/scri/extensions/Activity.kt @@ -67,6 +67,7 @@ import be.scri.helpers.REQUEST_SET_AS import be.scri.helpers.SIDELOADING_FALSE import be.scri.helpers.SIDELOADING_TRUE import be.scri.helpers.SILENT +import be.scri.helpers.STORE_URL import be.scri.helpers.ensureBackgroundThread import be.scri.helpers.isMarshmallowPlus import be.scri.helpers.isOnMainThread @@ -302,7 +303,7 @@ fun BaseSimpleActivity.isShowingAndroidSAFDialog(path: String): Boolean { } fun BaseSimpleActivity.isShowingOTGDialog(path: String): Boolean = - if (!isRPlus() && isPathOnOTG(path) && (baseConfig.OTGTreeUri.isEmpty() || !hasProperStoredTreeUri(true))) { + if (!isRPlus() && isPathOnOTG(path) && (baseConfig.otgTreeUri.isEmpty() || !hasProperStoredTreeUri(true))) { showOTGPermissionDialog(path) true } else { @@ -348,7 +349,7 @@ fun Activity.launchUpgradeToProIntent() { try { launchViewIntent("market://details?id=${baseConfig.appId.removeSuffix(".debug")}.pro") } catch (ignored: Exception) { - launchViewIntent(getStoreUrl()) + launchViewIntent(STORE_URL) } } @@ -366,7 +367,7 @@ fun Activity.redirectToRateUs() { try { launchViewIntent("market://details?id=${packageName.removeSuffix(".debug")}") } catch (ignored: ActivityNotFoundException) { - launchViewIntent(getStoreUrl()) + launchViewIntent(STORE_URL) } } diff --git a/app/src/main/java/be/scri/extensions/CommonsContext.kt b/app/src/main/java/be/scri/extensions/CommonsContext.kt index b96107be..aae91d7b 100644 --- a/app/src/main/java/be/scri/extensions/CommonsContext.kt +++ b/app/src/main/java/be/scri/extensions/CommonsContext.kt @@ -162,7 +162,7 @@ fun Context.showErrorToast( val Context.baseConfig: BaseConfig get() = BaseConfig.newInstance(this) val Context.sdCardPath: String get() = baseConfig.sdCardPath val Context.internalStoragePath: String get() = baseConfig.internalStoragePath -val Context.otgPath: String get() = baseConfig.OTGPath +val Context.otgPath: String get() = baseConfig.otgPath val Context.targetSdkVersion: Int get() = applicationInfo.targetSdkVersion @@ -722,8 +722,6 @@ fun Context.getCanAppBeUpgraded() = proPackages.contains(baseConfig.appId.remove fun Context.getProUrl() = "https://play.google.com/store/apps/details?id=${baseConfig.appId.removeSuffix(".debug")}.pro" -fun Context.getStoreUrl() = "https://play.google.com/store/apps/" - fun Context.getTimeFormat() = if (baseConfig.use24HourFormat) TIME_FORMAT_24 else TIME_FORMAT_12 fun Context.getResolution(path: String): Point? = diff --git a/app/src/main/java/be/scri/extensions/ContextStorage.kt b/app/src/main/java/be/scri/extensions/ContextStorage.kt index 44b409a6..ef81be90 100644 --- a/app/src/main/java/be/scri/extensions/ContextStorage.kt +++ b/app/src/main/java/be/scri/extensions/ContextStorage.kt @@ -56,7 +56,7 @@ fun Context.getSDCardPath(): String { "/storage/emulated/0", true, ) && - (baseConfig.OTGPartition.isEmpty() || !it.endsWith(baseConfig.OTGPartition)) + (baseConfig.otgPartition.isEmpty() || !it.endsWith(baseConfig.otgPartition)) } val fullSDpattern = Pattern.compile(SD_OTG_PATTERN) @@ -186,11 +186,11 @@ fun Context.needsStupidWritePermissions(path: String) = !isRPlus() && (isPathOnS fun Context.isSDCardSetAsDefaultStorage() = sdCardPath.isNotEmpty() && Environment.getExternalStorageDirectory().absolutePath.equals(sdCardPath, true) fun Context.hasProperStoredTreeUri(isOTG: Boolean): Boolean { - val uri = if (isOTG) baseConfig.OTGTreeUri else baseConfig.sdTreeUri + val uri = if (isOTG) baseConfig.otgTreeUri else baseConfig.sdTreeUri val hasProperUri = contentResolver.persistedUriPermissions.any { it.uri.toString() == uri } if (!hasProperUri) { if (isOTG) { - baseConfig.OTGTreeUri = "" + baseConfig.otgTreeUri = "" } else { baseConfig.sdTreeUri = "" } @@ -318,14 +318,14 @@ fun Context.getOTGFastDocumentFile( path: String, otgPathToUse: String? = null, ): DocumentFile? { - if (baseConfig.OTGTreeUri.isEmpty()) { + if (baseConfig.otgTreeUri.isEmpty()) { return null } - val otgPath = otgPathToUse ?: baseConfig.OTGPath - if (baseConfig.OTGPartition.isEmpty()) { - baseConfig.OTGPartition = - baseConfig.OTGTreeUri + val otgPath = otgPathToUse ?: baseConfig.otgPath + if (baseConfig.otgPartition.isEmpty()) { + baseConfig.otgPartition = + baseConfig.otgTreeUri .removeSuffix("%3A") .substringAfterLast('/') .trimEnd('/') @@ -333,7 +333,7 @@ fun Context.getOTGFastDocumentFile( } val relativePath = Uri.encode(path.substring(otgPath.length).trim('/')) - val fullUri = "${baseConfig.OTGTreeUri}/document/${baseConfig.OTGPartition}%3A$relativePath" + val fullUri = "${baseConfig.otgTreeUri}/document/${baseConfig.otgPartition}%3A$relativePath" return DocumentFile.fromSingleUri(this, Uri.parse(fullUri)) } @@ -345,7 +345,7 @@ fun Context.getDocumentFile(path: String): DocumentFile? { } return try { - val treeUri = Uri.parse(if (isOTG) baseConfig.OTGTreeUri else baseConfig.sdTreeUri) + val treeUri = Uri.parse(if (isOTG) baseConfig.otgTreeUri else baseConfig.sdTreeUri) var document = DocumentFile.fromTreeUri(applicationContext, treeUri) val parts = relativePath.split("/").filter { it.isNotEmpty() } for (part in parts) { @@ -537,15 +537,15 @@ fun Context.getOTGItems( callback: (ArrayList) -> Unit, ) { val items = ArrayList() - val otgTreeUri = baseConfig.OTGTreeUri + val otgTreeUri = baseConfig.otgTreeUri var rootUri = try { DocumentFile.fromTreeUri(applicationContext, Uri.parse(otgTreeUri)) } catch (e: Exception) { showErrorToast(e) - baseConfig.OTGPath = "" - baseConfig.OTGTreeUri = "" - baseConfig.OTGPartition = "" + baseConfig.otgPath = "" + baseConfig.otgTreeUri = "" + baseConfig.otgPartition = "" null } @@ -572,7 +572,7 @@ fun Context.getOTGItems( val files = rootUri!!.listFiles().filter { it.exists() } - val basePath = "${baseConfig.OTGTreeUri}/document/${baseConfig.OTGPartition}%3A" + val basePath = "${baseConfig.otgTreeUri}/document/${baseConfig.otgPartition}%3A" for (file in files) { val name = file.name ?: continue if (!shouldShowHidden && name.startsWith(".")) { @@ -960,12 +960,12 @@ fun Context.getFileInputStreamSync(path: String): InputStream? = } fun Context.updateOTGPathFromPartition() { - val otgPath = "/storage/${baseConfig.OTGPartition}" - baseConfig.OTGPath = + val otgPath = "/storage/${baseConfig.otgPartition}" + baseConfig.otgPath = if (getOTGFastDocumentFile(otgPath, otgPath)?.exists() == true) { - "/storage/${baseConfig.OTGPartition}" + "/storage/${baseConfig.otgPartition}" } else { - "/mnt/media_rw/${baseConfig.OTGPartition}" + "/mnt/media_rw/${baseConfig.otgPartition}" } } @@ -973,7 +973,7 @@ fun Context.getDoesFilePathExist( path: String, otgPathToUse: String? = null, ): Boolean { - val otgPath = otgPathToUse ?: baseConfig.OTGPath + val otgPath = otgPathToUse ?: baseConfig.otgPath return when { isRestrictedSAFOnlyRoot(path) -> getFastAndroidSAFDocument(path)?.exists() ?: false otgPath.isNotEmpty() && path.startsWith(otgPath) -> getOTGFastDocumentFile(path)?.exists() ?: false diff --git a/app/src/main/java/be/scri/extensions/String.kt b/app/src/main/java/be/scri/extensions/String.kt index e53f41ec..366de2d5 100644 --- a/app/src/main/java/be/scri/extensions/String.kt +++ b/app/src/main/java/be/scri/extensions/String.kt @@ -93,7 +93,7 @@ fun String.isAValidFilename(): Boolean { } fun String.getOTGPublicPath(context: Context) = - "${context.baseConfig.OTGTreeUri}/document/${context.baseConfig.OTGPartition}%3A${substring(context.baseConfig.OTGPath.length).replace("/", "%2F")}" + "${context.baseConfig.otgTreeUri}/document/${context.baseConfig.otgPartition}%3A${substring(context.baseConfig.otgPath.length).replace("/", "%2F")}" fun String.isMediaFile() = isImageFast() || isVideoFast() || isGif() || isRawFast() || isSvg() || isPortrait() diff --git a/app/src/main/java/be/scri/helpers/BaseConfig.kt b/app/src/main/java/be/scri/helpers/BaseConfig.kt index 2bec0a87..c9b9f909 100644 --- a/app/src/main/java/be/scri/helpers/BaseConfig.kt +++ b/app/src/main/java/be/scri/helpers/BaseConfig.kt @@ -56,15 +56,15 @@ open class BaseConfig( get() = prefs.getString(SD_TREE_URI, "")!! set(uri) = prefs.edit().putString(SD_TREE_URI, uri).apply() - var OTGTreeUri: String + var otgTreeUri: String get() = prefs.getString(OTG_TREE_URI, "")!! set(OTGTreeUri) = prefs.edit().putString(OTG_TREE_URI, OTGTreeUri).apply() - var OTGPartition: String + var otgPartition: String get() = prefs.getString(OTG_PARTITION, "")!! set(OTGPartition) = prefs.edit().putString(OTG_PARTITION, OTGPartition).apply() - var OTGPath: String + var otgPath: String get() = prefs.getString(OTG_REAL_PATH, "")!! set(OTGPath) = prefs.edit().putString(OTG_REAL_PATH, OTGPath).apply() diff --git a/app/src/main/java/be/scri/helpers/CommonsConstants.kt b/app/src/main/java/be/scri/helpers/CommonsConstants.kt index 75f7f15b..2c2a593f 100644 --- a/app/src/main/java/be/scri/helpers/CommonsConstants.kt +++ b/app/src/main/java/be/scri/helpers/CommonsConstants.kt @@ -295,6 +295,8 @@ const val TAB_FILES = 16 const val TAB_RECENT_FILES = 32 const val TAB_STORAGE_ANALYSIS = 64 +internal const val STORE_URL = "https://play.google.com/store/apps/" + val photoExtensions: Array get() = arrayOf(".jpg", ".png", ".jpeg", ".bmp", ".webp", ".heic", ".heif", ".apng") val videoExtensions: Array get() = arrayOf(".mp4", ".mkv", ".webm", ".avi", ".3gp", ".mov", ".m4v", ".3gpp") val audioExtensions: Array get() = arrayOf(".mp3", ".wav", ".wma", ".ogg", ".m4a", ".opus", ".flac", ".aac") diff --git a/detekt.yml b/detekt.yml index e28ea878..a5b37117 100644 --- a/detekt.yml +++ b/detekt.yml @@ -13,8 +13,6 @@ style: active: true UnusedParameter: active: true - FunctionOnlyReturningConstant: - active: false UtilityClassWithPublicConstructor: active: false @@ -34,12 +32,6 @@ complexity: LargeClass: active: false -naming: - VariableNaming: - active: false - InvalidPackageDeclaration: - active: false - potential-bugs: ImplicitDefaultLocale: active: false