Please install a file manager (#1640)

This commit is contained in:
LoveSy 2022-02-08 00:41:14 +08:00 committed by GitHub
parent 2787d3e331
commit 20d5a0afd4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 40 additions and 12 deletions

View File

@ -24,6 +24,7 @@ import static android.provider.Settings.ACTION_APPLICATION_DETAILS_SETTINGS;
import android.annotation.SuppressLint;
import android.app.Activity;
import android.content.ActivityNotFoundException;
import android.content.Intent;
import android.content.SharedPreferences;
import android.content.pm.ApplicationInfo;
@ -254,12 +255,22 @@ public class ScopeAdapter extends EmptyStateRecyclerView.EmptyStateAdapter<Scope
preferences.edit().putBoolean("filter_denylist", item.isChecked()).apply();
} else if (itemId == R.id.backup) {
LocalDateTime now = LocalDateTime.now();
try {
fragment.backupLauncher.launch(String.format(LocaleDelegate.getDefaultLocale(),
"%s_%s.lsp", module.getAppName(), now.toString()));
return true;
} catch (ActivityNotFoundException e) {
fragment.showHint(R.string.enable_documentui, true);
return false;
}
} else if (itemId == R.id.restore) {
try {
fragment.restoreLauncher.launch(new String[]{"*/*"});
return true;
} catch (ActivityNotFoundException e) {
fragment.showHint(R.string.enable_documentui, true);
return false;
}
} else if (!AppHelper.onOptionsItemSelected(item, preferences)) {
return false;
}

View File

@ -20,6 +20,7 @@
package org.lsposed.manager.ui.fragment;
import android.annotation.SuppressLint;
import android.content.ActivityNotFoundException;
import android.os.Bundle;
import android.os.Handler;
import android.os.Looper;
@ -162,7 +163,11 @@ public class LogsFragment extends BaseFragment {
private void save() {
LocalDateTime now = LocalDateTime.now();
String filename = String.format(LocaleDelegate.getDefaultLocale(), "LSPosed_%s.zip", now.toString());
try {
saveLogsLauncher.launch(filename);
} catch (ActivityNotFoundException e) {
showHint(R.string.enable_documentui, true);
}
}
@Override

View File

@ -19,6 +19,7 @@
package org.lsposed.manager.ui.fragment;
import android.content.ActivityNotFoundException;
import android.content.Context;
import android.os.Build;
import android.os.Bundle;
@ -176,9 +177,14 @@ public class SettingsFragment extends BaseFragment {
backup.setEnabled(installed);
backup.setOnPreferenceClickListener(preference -> {
LocalDateTime now = LocalDateTime.now();
try {
backupLauncher.launch(String.format(LocaleDelegate.getDefaultLocale(),
"LSPosed_%s.lsp", now.toString()));
return true;
} catch (ActivityNotFoundException e) {
parentFragment.showHint(R.string.enable_documentui, true);
return false;
}
});
}
@ -186,8 +192,13 @@ public class SettingsFragment extends BaseFragment {
if (restore != null) {
restore.setEnabled(installed);
restore.setOnPreferenceClickListener(preference -> {
try {
restoreLauncher.launch(new String[]{"*/*"});
return true;
} catch (ActivityNotFoundException e) {
parentFragment.showHint(R.string.enable_documentui, true);
return false;
}
});
}

View File

@ -229,4 +229,5 @@
<string name="sort_upgradable_first">Upgradable first</string>
<string name="overview">Overview</string>
<string name="create_shortcut_summary">Manually create parasitic manager shortcut</string>
<string name="enable_documentui">Please enable DocumentUI</string>
</resources>