[app] Add prompt if the verbose log is not available (#219)

This commit is contained in:
tehcneko 2021-02-27 20:01:38 +08:00 committed by GitHub
parent 4643d4fbc2
commit d3d15a6b2e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 19 additions and 3 deletions

View File

@ -219,6 +219,12 @@ public class LogsActivity extends BaseActivity {
ParcelFileDescriptor parcelFileDescriptor = ConfigManager.getLogs(verbose);
if (parcelFileDescriptor != null) {
new LogsReader().execute(parcelFileDescriptor.getFileDescriptor());
} else {
binding.slidingTabs.selectTab(binding.slidingTabs.getTabAt(0));
new AlertDialog.Builder(this)
.setMessage(R.string.verbose_log_not_avaliable)
.setPositiveButton(android.R.string.ok, null)
.show();
}
}

View File

@ -204,7 +204,16 @@ public class SettingsActivity extends BaseActivity {
} else {
prefVerboseLogs.setEnabled(installed);
prefVerboseLogs.setChecked(!ConfigManager.isVerboseLogEnabled());
prefVerboseLogs.setOnPreferenceChangeListener((preference, newValue) -> ConfigManager.setVerboseLogEnabled(!(boolean) newValue));
prefVerboseLogs.setOnPreferenceChangeListener((preference, newValue) -> {
boolean result = ConfigManager.setVerboseLogEnabled(!(boolean) newValue);
SettingsActivity activity = (SettingsActivity) getActivity();
if (result && activity != null) {
Snackbar.make(activity.binding.snackbar, R.string.reboot_required, Snackbar.LENGTH_SHORT)
.setAction(R.string.reboot, v -> ConfigManager.reboot(false, null, false))
.show();
}
return result;
});
}
}

View File

@ -1,5 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
<?xml version="1.0" encoding="utf-8"?><!--
~ This file is part of LSPosed.
~
~ LSPosed is free software: you can redistribute it and/or modify
@ -182,4 +181,5 @@
<string name="reboot_required">需要重新启动才能应用此更改</string>
<string name="reboot">重新启动</string>
<string name="not_logcat_2">如果有人要求您提供一份 Android 系统日志,那么您来错了地方。在此处显示的是 LSPosed 的日志信息;如果您想抓取系统日志,可前往 XDA 寻求所需的答案。</string>
<string name="verbose_log_not_avaliable">详细日志不可用,如果您只是启用了它而没有重新启动,请在重新启动后再试一次。</string>
</resources>

View File

@ -166,4 +166,5 @@
<string name="app_destroyed">This application has been destroyed, please make sure you download it from the official source.</string>
<string name="outdated_manager">Version of LSPosed Manager and LSPosed Core are not consistent. Please re-install the corresponding version.</string>
<string name="lsposed_not_active">LSPosed is not currently installed or active.</string>
<string name="verbose_log_not_avaliable">Verbose log is not available, if you just enabled it without reboot, try again after reboot.</string>
</resources>