Prevent crash

This commit is contained in:
M66B 2022-02-23 10:43:32 +01:00
parent 3b1ff558db
commit 625bb0dfa8
1 changed files with 4 additions and 2 deletions

View File

@ -785,6 +785,7 @@ public class FragmentOptionsMisc extends FragmentBase implements SharedPreferenc
} }
}); });
swExternalStorage.setEnabled(getContext().getExternalFilesDir(null) != null);
swExternalStorage.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() { swExternalStorage.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
@Override @Override
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) { public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
@ -1311,8 +1312,9 @@ public class FragmentOptionsMisc extends FragmentBase implements SharedPreferenc
setLastCleanup(prefs.getLong("last_cleanup", -1)); setLastCleanup(prefs.getLong("last_cleanup", -1));
File external = getContext().getExternalFilesDir(null); File external = getContext().getExternalFilesDir(null);
boolean emulated = Environment.isExternalStorageEmulated(external); boolean emulated = (external != null && Environment.isExternalStorageEmulated(external));
tvExternalStorageFolder.setText(external.getAbsolutePath() + (emulated ? " emulated" : "")); tvExternalStorageFolder.setText(
(external == null ? null : external.getAbsolutePath()) + (emulated ? " emulated" : ""));
swExactAlarms.setEnabled(AlarmManagerCompatEx.canScheduleExactAlarms(getContext())); swExactAlarms.setEnabled(AlarmManagerCompatEx.canScheduleExactAlarms(getContext()));
swTestIab.setVisibility(BuildConfig.TEST_RELEASE ? View.VISIBLE : View.GONE); swTestIab.setVisibility(BuildConfig.TEST_RELEASE ? View.VISIBLE : View.GONE);