mirror of
https://github.com/oliexdev/openScale.git
synced 2025-08-13 20:24:14 +02:00
change the get external storage directory to match the storage updates in Android 11
This commit is contained in:
@@ -7,7 +7,7 @@
|
||||
<uses-permission android:name="android.permission.BLUETOOTH_ADMIN" android:maxSdkVersion="30" />
|
||||
<uses-permission android:name="android.permission.BLUETOOTH_SCAN" />
|
||||
<uses-permission android:name="android.permission.BLUETOOTH_CONNECT" />
|
||||
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
|
||||
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" android:maxSdkVersion="29"/>
|
||||
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE"/>
|
||||
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED"/>
|
||||
|
||||
|
@@ -91,8 +91,7 @@ public class AlarmBackupHandler
|
||||
|
||||
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context);
|
||||
|
||||
// TODO to disable in the AndroidManfiest the requestLegacyExternalStorage on SDK >= 29 we need store the files on shared storages
|
||||
File exportDir = new File(Environment.getExternalStorageDirectory(),
|
||||
File exportDir = new File(context.getExternalFilesDir(null).getPath(),
|
||||
prefs.getString("exportDir", "openScale Backup"));
|
||||
if (!Environment.getExternalStorageState().equals(Environment.MEDIA_MOUNTED)) {
|
||||
return;
|
||||
|
@@ -15,11 +15,14 @@
|
||||
*/
|
||||
package com.health.openscale.gui.preferences;
|
||||
|
||||
import static android.app.Activity.RESULT_OK;
|
||||
|
||||
import android.content.ComponentName;
|
||||
import android.content.Intent;
|
||||
import android.content.SharedPreferences;
|
||||
import android.content.pm.PackageManager;
|
||||
import android.net.Uri;
|
||||
import android.os.Build;
|
||||
import android.os.Bundle;
|
||||
import android.view.Menu;
|
||||
import android.view.MenuInflater;
|
||||
@@ -38,8 +41,6 @@ import com.health.openscale.gui.utils.PermissionHelper;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import static android.app.Activity.RESULT_OK;
|
||||
|
||||
public class BackupPreferences extends PreferenceFragmentCompat implements SharedPreferences.OnSharedPreferenceChangeListener {
|
||||
private static final String PREFERENCE_KEY_IMPORT_BACKUP = "importBackup";
|
||||
private static final String PREFERENCE_KEY_EXPORT_BACKUP = "exportBackup";
|
||||
@@ -146,7 +147,9 @@ public class BackupPreferences extends PreferenceFragmentCompat implements Share
|
||||
private class onClickListenerExportBackup implements Preference.OnPreferenceClickListener {
|
||||
@Override
|
||||
public boolean onPreferenceClick(Preference preference) {
|
||||
if (PermissionHelper.requestWritePermission(fragment)) {
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q) {
|
||||
exportBackup();
|
||||
} else if (PermissionHelper.requestWritePermission(fragment)) {
|
||||
exportBackup();
|
||||
}
|
||||
|
||||
@@ -208,6 +211,7 @@ public class BackupPreferences extends PreferenceFragmentCompat implements Share
|
||||
Intent intent = new Intent(Intent.ACTION_CREATE_DOCUMENT);
|
||||
intent.addCategory(Intent.CATEGORY_OPENABLE);
|
||||
intent.addFlags(Intent.FLAG_GRANT_WRITE_URI_PERMISSION);
|
||||
intent.putExtra(Intent.EXTRA_TITLE, "openScale.db");
|
||||
intent.setType("*/*");
|
||||
|
||||
startActivityForResult(intent, EXPORT_DATA_REQUEST);
|
||||
|
Reference in New Issue
Block a user