From 0eee2a7de5923ceec85524efdad2a414f8c7ac0b Mon Sep 17 00:00:00 2001 From: tibbi Date: Thu, 30 Jan 2020 20:23:35 +0100 Subject: [PATCH] updating target SDK to 29, but use requestLegacyExternalStorage --- app/build.gradle | 6 +++--- app/src/main/AndroidManifest.xml | 1 + .../notes/pro/activities/MainActivity.kt | 9 +++++---- .../com/simplemobiletools/notes/pro/helpers/Config.kt | 4 ++-- 4 files changed, 11 insertions(+), 9 deletions(-) diff --git a/app/build.gradle b/app/build.gradle index 462b04d7..d1124a47 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -10,13 +10,13 @@ if (keystorePropertiesFile.exists()) { } android { - compileSdkVersion 28 - buildToolsVersion "28.0.3" + compileSdkVersion 29 + buildToolsVersion "29.0.2" defaultConfig { applicationId "com.simplemobiletools.notes.pro" minSdkVersion 21 - targetSdkVersion 28 + targetSdkVersion 29 versionCode 68 versionName "6.3.1" setProperty("archivesBaseName", "notes") diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index 855cbdb2..beee67c7 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -19,6 +19,7 @@ android:allowBackup="true" android:icon="@mipmap/ic_launcher" android:label="@string/app_launcher_name" + android:requestLegacyExternalStorage="true" android:roundIcon="@mipmap/ic_launcher" android:supportsRtl="true" android:theme="@style/AppTheme"> diff --git a/app/src/main/kotlin/com/simplemobiletools/notes/pro/activities/MainActivity.kt b/app/src/main/kotlin/com/simplemobiletools/notes/pro/activities/MainActivity.kt index 3df8b7d4..93d5aed7 100644 --- a/app/src/main/kotlin/com/simplemobiletools/notes/pro/activities/MainActivity.kt +++ b/app/src/main/kotlin/com/simplemobiletools/notes/pro/activities/MainActivity.kt @@ -203,7 +203,7 @@ class MainActivity : SimpleActivity() { val file = File(realPath) handleUri(Uri.fromFile(file)) } else { - handleUri(data) + handleUri(data!!) } intent.removeCategory(Intent.CATEGORY_DEFAULT) intent.action = null @@ -239,7 +239,7 @@ class MainActivity : SimpleActivity() { } private fun handleUri(uri: Uri) { - NotesHelper(this).getNoteIdWithPath(uri.path) { + NotesHelper(this).getNoteIdWithPath(uri.path!!) { if (it != null && it > 0L) { updateSelectedNote(it) return@getNoteIdWithPath @@ -397,7 +397,7 @@ class MainActivity : SimpleActivity() { private fun importUri(uri: Uri) { when (uri.scheme) { - "file" -> openPath(uri.path) + "file" -> openPath(uri.path!!) "content" -> { val realPath = getRealPathFromURI(uri) if (realPath != null) { @@ -578,12 +578,13 @@ class MainActivity : SimpleActivity() { parent.createFile("", path.getFilenameFromPath())!! } - contentResolver.openOutputStream(document.uri).apply { + contentResolver.openOutputStream(document.uri)!!.apply { val byteArray = content.toByteArray(Charset.forName("UTF-8")) write(byteArray, 0, byteArray.size) flush() close() } + if (showSuccessToasts) { noteExportedSuccessfully(path.getFilenameFromPath()) } diff --git a/app/src/main/kotlin/com/simplemobiletools/notes/pro/helpers/Config.kt b/app/src/main/kotlin/com/simplemobiletools/notes/pro/helpers/Config.kt index b2aaaa07..a333fa2a 100644 --- a/app/src/main/kotlin/com/simplemobiletools/notes/pro/helpers/Config.kt +++ b/app/src/main/kotlin/com/simplemobiletools/notes/pro/helpers/Config.kt @@ -64,11 +64,11 @@ class Config(context: Context) : BaseConfig(context) { set(enableLineWrap) = prefs.edit().putBoolean(ENABLE_LINE_WRAP, enableLineWrap).apply() var lastUsedExtension: String - get() = prefs.getString(LAST_USED_EXTENSION, "txt") + get() = prefs.getString(LAST_USED_EXTENSION, "txt")!! set(lastUsedExtension) = prefs.edit().putString(LAST_USED_EXTENSION, lastUsedExtension).apply() var lastUsedSavePath: String - get() = prefs.getString(LAST_USED_SAVE_PATH, Environment.getExternalStorageDirectory().toString()) + get() = prefs.getString(LAST_USED_SAVE_PATH, Environment.getExternalStorageDirectory().toString())!! set(lastUsedSavePath) = prefs.edit().putString(LAST_USED_SAVE_PATH, lastUsedSavePath).apply() var useIncognitoMode: Boolean