mirror of https://github.com/readrops/Readrops.git
Request storage permission only with APIs <= 28
This commit is contained in:
parent
76d5e29589
commit
e370abbb43
|
@ -6,7 +6,9 @@
|
|||
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
|
||||
<uses-permission android:name="android.permission.INTERNET" />
|
||||
<uses-permission android:name="android.permission.FOREGROUND_SERVICE" />
|
||||
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
|
||||
<uses-permission
|
||||
android:name="android.permission.WRITE_EXTERNAL_STORAGE"
|
||||
android:maxSdkVersion="28" />
|
||||
|
||||
<application
|
||||
android:name=".ReadropsApp"
|
||||
|
|
|
@ -7,9 +7,9 @@ import android.app.PendingIntent;
|
|||
import android.content.Intent;
|
||||
import android.content.pm.PackageManager;
|
||||
import android.net.Uri;
|
||||
import android.os.Build;
|
||||
import android.os.Bundle;
|
||||
import android.provider.Settings;
|
||||
import android.util.Log;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
|
@ -73,6 +73,7 @@ public class AccountSettingsFragment extends PreferenceFragmentCompat {
|
|||
return fragment;
|
||||
}
|
||||
|
||||
@SuppressWarnings("ConstantConditions")
|
||||
@Override
|
||||
public void onCreatePreferences(Bundle savedInstanceState, String rootKey) {
|
||||
addPreferencesFromResource(R.xml.acount_preferences);
|
||||
|
@ -117,16 +118,7 @@ public class AccountSettingsFragment extends PreferenceFragmentCompat {
|
|||
opmlPref.setOnPreferenceClickListener(preference -> {
|
||||
new MaterialDialog.Builder(getActivity())
|
||||
.items(R.array.opml_import_export)
|
||||
.itemsCallback(((dialog, itemView, position, text) -> {
|
||||
if (position == 0) {
|
||||
OPMLHelper.openFileIntent(this);
|
||||
} else {
|
||||
if (PermissionManager.isPermissionGranted(getContext(), Manifest.permission.WRITE_EXTERNAL_STORAGE))
|
||||
exportAsOPMLFile();
|
||||
else
|
||||
requestExternalStoragePermission();
|
||||
}
|
||||
}))
|
||||
.itemsCallback(((dialog, itemView, position, text) -> openOPMLMode(position)))
|
||||
.show();
|
||||
return true;
|
||||
});
|
||||
|
@ -175,6 +167,22 @@ public class AccountSettingsFragment extends PreferenceFragmentCompat {
|
|||
.show();
|
||||
}
|
||||
|
||||
private void openOPMLMode(int position) {
|
||||
if (position == 0) {
|
||||
OPMLHelper.openFileIntent(this);
|
||||
} else {
|
||||
if (Build.VERSION.SDK_INT <= Build.VERSION_CODES.P) {
|
||||
if (PermissionManager.isPermissionGranted(getContext(), Manifest.permission.WRITE_EXTERNAL_STORAGE)) {
|
||||
exportAsOPMLFile();
|
||||
} else {
|
||||
requestExternalStoragePermission();
|
||||
}
|
||||
} else {
|
||||
exportAsOPMLFile();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// region opml import
|
||||
|
||||
@Override
|
||||
|
@ -243,8 +251,7 @@ public class AccountSettingsFragment extends PreferenceFragmentCompat {
|
|||
|
||||
displayNotification(fileName, path);
|
||||
} catch (Exception e) {
|
||||
Log.e(TAG, e.getMessage());
|
||||
Utils.showSnackbar(getView(), e.getMessage());
|
||||
displayErrorMessage();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue