updating target SDK to 29, but use requestLegacyExternalStorage

This commit is contained in:
tibbi 2020-01-30 20:23:35 +01:00
parent f038da3b4f
commit 0eee2a7de5
4 changed files with 11 additions and 9 deletions

View File

@ -10,13 +10,13 @@ if (keystorePropertiesFile.exists()) {
} }
android { android {
compileSdkVersion 28 compileSdkVersion 29
buildToolsVersion "28.0.3" buildToolsVersion "29.0.2"
defaultConfig { defaultConfig {
applicationId "com.simplemobiletools.notes.pro" applicationId "com.simplemobiletools.notes.pro"
minSdkVersion 21 minSdkVersion 21
targetSdkVersion 28 targetSdkVersion 29
versionCode 68 versionCode 68
versionName "6.3.1" versionName "6.3.1"
setProperty("archivesBaseName", "notes") setProperty("archivesBaseName", "notes")

View File

@ -19,6 +19,7 @@
android:allowBackup="true" android:allowBackup="true"
android:icon="@mipmap/ic_launcher" android:icon="@mipmap/ic_launcher"
android:label="@string/app_launcher_name" android:label="@string/app_launcher_name"
android:requestLegacyExternalStorage="true"
android:roundIcon="@mipmap/ic_launcher" android:roundIcon="@mipmap/ic_launcher"
android:supportsRtl="true" android:supportsRtl="true"
android:theme="@style/AppTheme"> android:theme="@style/AppTheme">

View File

@ -203,7 +203,7 @@ class MainActivity : SimpleActivity() {
val file = File(realPath) val file = File(realPath)
handleUri(Uri.fromFile(file)) handleUri(Uri.fromFile(file))
} else { } else {
handleUri(data) handleUri(data!!)
} }
intent.removeCategory(Intent.CATEGORY_DEFAULT) intent.removeCategory(Intent.CATEGORY_DEFAULT)
intent.action = null intent.action = null
@ -239,7 +239,7 @@ class MainActivity : SimpleActivity() {
} }
private fun handleUri(uri: Uri) { private fun handleUri(uri: Uri) {
NotesHelper(this).getNoteIdWithPath(uri.path) { NotesHelper(this).getNoteIdWithPath(uri.path!!) {
if (it != null && it > 0L) { if (it != null && it > 0L) {
updateSelectedNote(it) updateSelectedNote(it)
return@getNoteIdWithPath return@getNoteIdWithPath
@ -397,7 +397,7 @@ class MainActivity : SimpleActivity() {
private fun importUri(uri: Uri) { private fun importUri(uri: Uri) {
when (uri.scheme) { when (uri.scheme) {
"file" -> openPath(uri.path) "file" -> openPath(uri.path!!)
"content" -> { "content" -> {
val realPath = getRealPathFromURI(uri) val realPath = getRealPathFromURI(uri)
if (realPath != null) { if (realPath != null) {
@ -578,12 +578,13 @@ class MainActivity : SimpleActivity() {
parent.createFile("", path.getFilenameFromPath())!! parent.createFile("", path.getFilenameFromPath())!!
} }
contentResolver.openOutputStream(document.uri).apply { contentResolver.openOutputStream(document.uri)!!.apply {
val byteArray = content.toByteArray(Charset.forName("UTF-8")) val byteArray = content.toByteArray(Charset.forName("UTF-8"))
write(byteArray, 0, byteArray.size) write(byteArray, 0, byteArray.size)
flush() flush()
close() close()
} }
if (showSuccessToasts) { if (showSuccessToasts) {
noteExportedSuccessfully(path.getFilenameFromPath()) noteExportedSuccessfully(path.getFilenameFromPath())
} }

View File

@ -64,11 +64,11 @@ class Config(context: Context) : BaseConfig(context) {
set(enableLineWrap) = prefs.edit().putBoolean(ENABLE_LINE_WRAP, enableLineWrap).apply() set(enableLineWrap) = prefs.edit().putBoolean(ENABLE_LINE_WRAP, enableLineWrap).apply()
var lastUsedExtension: String 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() set(lastUsedExtension) = prefs.edit().putString(LAST_USED_EXTENSION, lastUsedExtension).apply()
var lastUsedSavePath: String 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() set(lastUsedSavePath) = prefs.edit().putString(LAST_USED_SAVE_PATH, lastUsedSavePath).apply()
var useIncognitoMode: Boolean var useIncognitoMode: Boolean