Cleanup custom API key support

Also allow devs to purposely crash the app, because it's fun

Signed-off-by: androidacy-user <opensource@androidacy.com>
pull/27/head
androidacy-user 3 years ago
parent aad605cbd0
commit 8c6f75c7bf

@ -3,7 +3,6 @@ package com.fox2code.mmm.settings;
import android.annotation.SuppressLint;
import android.app.AlarmManager;
import android.app.PendingIntent;
import android.app.ProgressDialog;
import android.content.Context;
import android.content.Intent;
import android.content.SharedPreferences;
@ -27,6 +26,7 @@ import androidx.preference.EditTextPreference;
import androidx.preference.ListPreference;
import androidx.preference.Preference;
import androidx.preference.PreferenceFragmentCompat;
import androidx.preference.SwitchPreferenceCompat;
import androidx.preference.TwoStatePreference;
import com.fox2code.foxcompat.FoxActivity;
@ -52,6 +52,7 @@ import com.fox2code.rosettax.LanguageActivity;
import com.fox2code.rosettax.LanguageSwitcher;
import com.google.android.material.dialog.MaterialAlertDialogBuilder;
import com.google.android.material.internal.TextWatcherAdapter;
import com.google.android.material.snackbar.Snackbar;
import com.google.android.material.textfield.MaterialAutoCompleteTextView;
import com.mikepenz.aboutlibraries.LibsBuilder;
import com.topjohnwu.superuser.internal.UiThreadHandler;
@ -77,10 +78,7 @@ public class SettingsActivity extends FoxActivity implements LanguageActivity {
setTitle(R.string.app_name);
setActionBarBackground(null);
if (savedInstanceState == null) {
getSupportFragmentManager()
.beginTransaction()
.replace(R.id.settings, new SettingsFragment())
.commit();
getSupportFragmentManager().beginTransaction().replace(R.id.settings, new SettingsFragment()).commit();
}
}
@ -90,8 +88,7 @@ public class SettingsActivity extends FoxActivity implements LanguageActivity {
Intent mStartActivity = new Intent(this, MainActivity.class);
mStartActivity.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_NEW_TASK);
int mPendingIntentId = 123456;
PendingIntent mPendingIntent = PendingIntent.getActivity(this, mPendingIntentId,
mStartActivity, PendingIntent.FLAG_CANCEL_CURRENT | PendingIntent.FLAG_IMMUTABLE);
PendingIntent mPendingIntent = PendingIntent.getActivity(this, mPendingIntentId, mStartActivity, PendingIntent.FLAG_CANCEL_CURRENT | PendingIntent.FLAG_IMMUTABLE);
AlarmManager mgr = (AlarmManager) this.getSystemService(Context.ALARM_SERVICE);
mgr.set(AlarmManager.RTC, System.currentTimeMillis() + 100, mPendingIntent);
System.exit(0); // Exit app process
@ -103,8 +100,7 @@ public class SettingsActivity extends FoxActivity implements LanguageActivity {
super.onPause();
}
public static class SettingsFragment extends PreferenceFragmentCompat
implements FoxActivity.OnBackPressedCallback {
public static class SettingsFragment extends PreferenceFragmentCompat implements FoxActivity.OnBackPressedCallback {
@Override
@SuppressWarnings("ConstantConditions")
public void onCreatePreferences(Bundle savedInstanceState, String rootKey) {
@ -126,8 +122,7 @@ public class SettingsActivity extends FoxActivity implements LanguageActivity {
devModeStep = 0;
UiThreadHandler.handler.postDelayed(() -> {
MainApplication.getINSTANCE().updateTheme();
FoxActivity.getFoxActivity(this).setThemeRecreate(
MainApplication.getINSTANCE().getManagerThemeResId());
FoxActivity.getFoxActivity(this).setThemeRecreate(MainApplication.getINSTANCE().getManagerThemeResId());
}, 1);
return true;
});
@ -136,8 +131,7 @@ public class SettingsActivity extends FoxActivity implements LanguageActivity {
crashReportingPreference.setChecked(MainApplication.isCrashReportingEnabled());
crashReportingPreference.setOnPreferenceChangeListener((preference, newValue) -> {
devModeStep = 0;
getCrashReportingEditor(requireActivity()).putBoolean("crash_reporting",
(boolean) newValue).apply();
getCrashReportingEditor(requireActivity()).putBoolean("crash_reporting", (boolean) newValue).apply();
return true;
});
Preference enableBlur = findPreference("pref_enable_blur");
@ -154,8 +148,7 @@ public class SettingsActivity extends FoxActivity implements LanguageActivity {
disableMonet.setOnPreferenceClickListener(preference -> {
UiThreadHandler.handler.postDelayed(() -> {
MainApplication.getINSTANCE().updateTheme();
((FoxActivity) this.requireActivity()).setThemeRecreate(
MainApplication.getINSTANCE().getManagerThemeResId());
((FoxActivity) this.requireActivity()).setThemeRecreate(MainApplication.getINSTANCE().getManagerThemeResId());
}, 1);
return true;
});
@ -198,8 +191,7 @@ public class SettingsActivity extends FoxActivity implements LanguageActivity {
int level = this.currentLanguageLevel();
if (level != LANGUAGE_SUPPORT_LEVEL) {
Log.e(TAG, "Detected language level " + level +
", latest is " + LANGUAGE_SUPPORT_LEVEL);
Log.e(TAG, "Detected language level " + level + ", latest is " + LANGUAGE_SUPPORT_LEVEL);
languageSelector.setSummary(R.string.language_support_outdated);
} else {
if (!"Translated by Fox2Code".equals( // I don't "translate" english
@ -212,45 +204,45 @@ public class SettingsActivity extends FoxActivity implements LanguageActivity {
if (!MainApplication.isDeveloper()) {
findPreference("pref_disable_low_quality_module_filter").setVisible(false);
// Hide the pref_crash option if not in debug mode - stop users from purposely crashing the app
Objects.requireNonNull((Preference) findPreference("pref_crash")).setVisible(false);
} else {
findPreference("pref_crash").setOnPreferenceClickListener(preference -> {
// Hard crash the app
throw new RuntimeException("This is a test crash");
});
}
if (InstallerInitializer.peekMagiskVersion() < Constants.MAGISK_VER_CODE_INSTALL_COMMAND
|| !MainApplication.isDeveloper()) {
if (InstallerInitializer.peekMagiskVersion() < Constants.MAGISK_VER_CODE_INSTALL_COMMAND || !MainApplication.isDeveloper()) {
findPreference("pref_use_magisk_install_command").setVisible(false);
}
Preference debugNotification = findPreference("pref_background_update_check_debug");
debugNotification.setEnabled(MainApplication.isBackgroundUpdateCheckEnabled());
debugNotification.setVisible(MainApplication.isDeveloper());
debugNotification.setOnPreferenceClickListener(preference -> {
BackgroundUpdateChecker.postNotification(
this.requireContext(), new Random().nextInt(4) + 2);
BackgroundUpdateChecker.postNotification(this.requireContext(), new Random().nextInt(4) + 2);
return true;
});
findPreference("pref_background_update_check").setOnPreferenceChangeListener((preference, newValue) -> {
boolean enabled = Boolean.parseBoolean(String.valueOf(newValue));
debugNotification.setEnabled(enabled);
if (!enabled) {
BackgroundUpdateChecker.onMainActivityResume(
this.requireContext());
BackgroundUpdateChecker.onMainActivityResume(this.requireContext());
}
return true;
});
final LibsBuilder libsBuilder = new LibsBuilder().withShowLoadingProgress(false)
.withLicenseShown(true).withAboutMinimalDesign(false);
final LibsBuilder libsBuilder = new LibsBuilder().withShowLoadingProgress(false).withLicenseShown(true).withAboutMinimalDesign(false);
Preference update = findPreference("pref_update");
update.setVisible(BuildConfig.ENABLE_AUTO_UPDATER && (BuildConfig.DEBUG ||
AppUpdateManager.getAppUpdateManager().peekHasUpdate()));
update.setVisible(BuildConfig.ENABLE_AUTO_UPDATER && (BuildConfig.DEBUG || AppUpdateManager.getAppUpdateManager().peekHasUpdate()));
update.setOnPreferenceClickListener(p -> {
devModeStep = 0;
IntentHelper.openUrl(p.getContext(),
"https://github.com/Fox2Code/FoxMagiskModuleManager/releases");
IntentHelper.openUrl(p.getContext(), "https://github.com/Fox2Code/FoxMagiskModuleManager/releases");
return true;
});
if (BuildConfig.DEBUG || BuildConfig.ENABLE_AUTO_UPDATER) {
findPreference("pref_report_bug").setOnPreferenceClickListener(p -> {
devModeStep = 0;
IntentHelper.openUrl(p.getContext(),
"https://github.com/Fox2Code/FoxMagiskModuleManager/issues");
IntentHelper.openUrl(p.getContext(), "https://github.com/Fox2Code/FoxMagiskModuleManager/issues");
return true;
});
} else {
@ -260,20 +252,17 @@ public class SettingsActivity extends FoxActivity implements LanguageActivity {
if (devModeStep == 2) {
devModeStep = 0;
if (MainApplication.isDeveloper() && !BuildConfig.DEBUG) {
MainApplication.getSharedPreferences().edit()
.putBoolean("developer", false).apply();
MainApplication.getSharedPreferences().edit().putBoolean("developer", false).apply();
Toast.makeText(getContext(), // Tell the user something changed
R.string.dev_mode_disabled, Toast.LENGTH_SHORT).show();
} else {
MainApplication.getSharedPreferences().edit()
.putBoolean("developer", true).apply();
MainApplication.getSharedPreferences().edit().putBoolean("developer", true).apply();
Toast.makeText(getContext(), // Tell the user something changed
R.string.dev_mode_enabled, Toast.LENGTH_SHORT).show();
}
return true;
}
IntentHelper.openUrl(p.getContext(),
"https://github.com/Fox2Code/FoxMagiskModuleManager");
IntentHelper.openUrl(p.getContext(), "https://github.com/Fox2Code/FoxMagiskModuleManager");
return true;
});
findPreference("pref_support").setOnPreferenceClickListener(p -> {
@ -287,14 +276,10 @@ public class SettingsActivity extends FoxActivity implements LanguageActivity {
openFragment(libsBuilder.supportFragment(), R.string.licenses);
return true;
});
findPreference("pref_pkg_info").setSummary(
BuildConfig.APPLICATION_ID + " v" +
BuildConfig.VERSION_NAME + " (" +
BuildConfig.VERSION_CODE + ")");
findPreference("pref_pkg_info").setSummary(BuildConfig.APPLICATION_ID + " v" + BuildConfig.VERSION_NAME + " (" + BuildConfig.VERSION_CODE + ")");
}
private SharedPreferences.Editor getCrashReportingEditor(FragmentActivity
requireActivity) {
private SharedPreferences.Editor getCrashReportingEditor(FragmentActivity requireActivity) {
return requireActivity.getSharedPreferences("crash_reporting", Context.MODE_PRIVATE).edit();
}
@ -302,33 +287,20 @@ public class SettingsActivity extends FoxActivity implements LanguageActivity {
FoxActivity compatActivity = getFoxActivity(this);
compatActivity.setOnBackPressedCallback(this);
compatActivity.setTitle(title);
compatActivity.getSupportFragmentManager()
.beginTransaction()
.replace(R.id.settings, fragment)
.setTransition(FragmentTransaction.TRANSIT_FRAGMENT_FADE)
.commit();
compatActivity.getSupportFragmentManager().beginTransaction().replace(R.id.settings, fragment).setTransition(FragmentTransaction.TRANSIT_FRAGMENT_FADE).commit();
}
@Override
public boolean onBackPressed(FoxActivity compatActivity) {
compatActivity.setTitle(R.string.app_name);
compatActivity.getSupportFragmentManager()
.beginTransaction().replace(R.id.settings, this)
.setTransition(FragmentTransaction.TRANSIT_FRAGMENT_FADE)
.commit();
compatActivity.getSupportFragmentManager().beginTransaction().replace(R.id.settings, this).setTransition(FragmentTransaction.TRANSIT_FRAGMENT_FADE).commit();
return true;
}
private int currentLanguageLevel() {
int declaredLanguageLevel =
this.getResources().getInteger(R.integer.language_support_level);
if (declaredLanguageLevel != LANGUAGE_SUPPORT_LEVEL)
return declaredLanguageLevel;
if (!this.getResources().getConfiguration().locale.getLanguage().equals("en") &&
this.getResources().getString(R.string.notification_update_pref)
.equals("Background modules update check") &&
this.getResources().getString(R.string.notification_update_desc)
.equals("May increase battery usage")) {
int declaredLanguageLevel = this.getResources().getInteger(R.integer.language_support_level);
if (declaredLanguageLevel != LANGUAGE_SUPPORT_LEVEL) return declaredLanguageLevel;
if (!this.getResources().getConfiguration().locale.getLanguage().equals("en") && this.getResources().getString(R.string.notification_update_pref).equals("Background modules update check") && this.getResources().getString(R.string.notification_update_desc).equals("May increase battery usage")) {
return 0;
}
return LANGUAGE_SUPPORT_LEVEL;
@ -348,13 +320,26 @@ public class SettingsActivity extends FoxActivity implements LanguageActivity {
setRepoData(RepoManager.DG_MAGISK_REPO_GITHUB);
updateCustomRepoList(true);
if (!MainApplication.isDeveloper()) {
Objects.requireNonNull((Preference) findPreference(
"pref_androidacy_test_mode")).setVisible(false);
Objects.requireNonNull((Preference) findPreference("pref_androidacy_test_mode")).setVisible(false);
} else {
// Show a warning if user tries to enable test mode
Objects.requireNonNull((SwitchPreferenceCompat) findPreference("pref_androidacy_test_mode")).setOnPreferenceChangeListener((preference, newValue) -> {
if (Boolean.parseBoolean(String.valueOf(newValue))) {
new AlertDialog.Builder(this.requireContext())
.setTitle(R.string.warning)
.setMessage(R.string.androidacy_test_mode_warning)
.setPositiveButton(android.R.string.ok, (dialog, which) -> {
// Do nothing
})
.show();
}
return true;
});
}
String originalApiKey = MainApplication.getSharedPreferences()
.getString("pref_androidacy_api_token", "");
String originalApiKey = MainApplication.getSharedPreferences().getString("pref_androidacy_api_token", "");
// Create the pref_androidacy_repo_api_key text input with validation
EditTextPreference prefAndroidacyRepoApiKey = findPreference("pref_androidacy_repo_api_key");
assert prefAndroidacyRepoApiKey != null;
prefAndroidacyRepoApiKey.setOnBindEditTextListener(editText -> {
editText.setSingleLine();
// Make the single line wrap
@ -370,61 +355,48 @@ public class SettingsActivity extends FoxActivity implements LanguageActivity {
// throw new RuntimeException("This is a test crash");
// get original api key
String apiKey = String.valueOf(newValue);
// Show progress dialog
ProgressDialog progressDialog = new ProgressDialog(getContext());
progressDialog.setMessage(getString(R.string.checking_api_key));
progressDialog.setCancelable(false);
progressDialog.show();
// Show snack bar with indeterminate progress
Snackbar.make(requireView(), R.string.checking_api_key, Snackbar.LENGTH_INDEFINITE).setAction(R.string.cancel, v -> {
// Restore the original api key
prefAndroidacyRepoApiKey.setText(originalApiKey);
}).show();
// Check the API key on a background thread
new Thread(() -> {
// If key is empty, just remove it and show a toast
// If key is empty, just remove it and change the text of the snack bar
if (apiKey.isEmpty()) {
MainApplication.getSharedPreferences().edit()
.remove("pref_androidacy_repo_api_key").apply();
new Handler(Looper.getMainLooper()).post(() -> {
progressDialog.dismiss();
Toast.makeText(getContext(), R.string.api_key_removed, Toast.LENGTH_SHORT).show();
});
return;
MainApplication.getSharedPreferences().edit().remove("pref_androidacy_repo_api_key").apply();
new Handler(Looper.getMainLooper()).post(() -> Snackbar.make(requireView(), R.string.api_key_removed, Snackbar.LENGTH_SHORT).show());
} else {
// If key < 64 chars, it's not valid
if (apiKey.length() < 64) {
new Handler(Looper.getMainLooper()).post(() -> {
progressDialog.dismiss();
Snackbar.make(requireView(), R.string.api_key_invalid, Snackbar.LENGTH_SHORT).show();
// Save the original key
MainApplication.getSharedPreferences().edit()
.putString("pref_androidacy_api_token", originalApiKey).apply();
MainApplication.getSharedPreferences().edit().putString("pref_androidacy_api_token", originalApiKey).apply();
// Re-show the dialog with an error
prefAndroidacyRepoApiKey.performClick();
// Show error
prefAndroidacyRepoApiKey.setDialogMessage(getString(R.string.api_key_invalid));
// Set the error color
Toast.makeText(getContext(), R.string.api_key_invalid, Toast.LENGTH_SHORT).show();
});
return;
}
}
// Check the API key
boolean valid = AndroidacyRepoData.getInstance().isValidToken(apiKey);
// Update the UI on the main thread
new Handler(Looper.getMainLooper()).post(() -> {
progressDialog.dismiss();
if (valid) {
// Show a success message
Toast.makeText(getContext(), R.string.api_key_valid,
Toast.LENGTH_SHORT).show();
// Save the API key
MainApplication.getSharedPreferences().edit()
.putString("pref_androidacy_api_token", apiKey).apply();
} else {
// Show an error message
Toast.makeText(getContext(), R.string.api_key_invalid,
Toast.LENGTH_SHORT).show();
// Restore the original API key
MainApplication.getSharedPreferences().edit()
.putString("pref_androidacy_api_token", originalApiKey).apply();
boolean valid = AndroidacyRepoData.getInstance().isValidToken(apiKey);
// If the key is valid, save it
if (valid) {
MainApplication.getSharedPreferences().edit().putString("pref_androidacy_repo_api_key", apiKey).apply();
new Handler(Looper.getMainLooper()).post(() -> Snackbar.make(requireView(), R.string.api_key_valid, Snackbar.LENGTH_SHORT).show());
} else {
new Handler(Looper.getMainLooper()).post(() -> {
Snackbar.make(requireView(), R.string.api_key_invalid, Snackbar.LENGTH_SHORT).show();
// Save the original key
MainApplication.getSharedPreferences().edit().putString("pref_androidacy_api_token", originalApiKey).apply();
// Re-show the dialog with an error
prefAndroidacyRepoApiKey.performClick();
// Show error
prefAndroidacyRepoApiKey.setDialogMessage(getString(R.string.api_key_invalid));
});
}
}
});
}
}).start();
return true;
});
@ -432,21 +404,17 @@ public class SettingsActivity extends FoxActivity implements LanguageActivity {
@SuppressLint("RestrictedApi")
public void updateCustomRepoList(boolean initial) {
final SharedPreferences sharedPreferences = Objects.requireNonNull(
this.getPreferenceManager().getSharedPreferences());
final CustomRepoManager customRepoManager =
RepoManager.getINSTANCE().getCustomRepoManager();
final SharedPreferences sharedPreferences = Objects.requireNonNull(this.getPreferenceManager().getSharedPreferences());
final CustomRepoManager customRepoManager = RepoManager.getINSTANCE().getCustomRepoManager();
for (int i = 0; i < CUSTOM_REPO_ENTRIES; i++) {
CustomRepoData repoData = customRepoManager.getRepo(i);
setRepoData(repoData, "pref_custom_repo_" + i);
if (initial) {
Preference preference =
findPreference("pref_custom_repo_" + i + "_delete");
Preference preference = findPreference("pref_custom_repo_" + i + "_delete");
if (preference == null) continue;
final int index = i;
preference.setOnPreferenceClickListener(preference1 -> {
sharedPreferences.edit().putBoolean(
"pref_custom_repo_" + index + "_enabled", false).apply();
sharedPreferences.edit().putBoolean("pref_custom_repo_" + index + "_enabled", false).apply();
customRepoManager.removeRepo(index);
updateCustomRepoList(false);
return true;
@ -455,16 +423,14 @@ public class SettingsActivity extends FoxActivity implements LanguageActivity {
}
Preference preference = findPreference("pref_custom_add_repo");
if (preference == null) return;
preference.setVisible(customRepoManager.canAddRepo() &&
customRepoManager.getRepoCount() < CUSTOM_REPO_ENTRIES);
preference.setVisible(customRepoManager.canAddRepo() && customRepoManager.getRepoCount() < CUSTOM_REPO_ENTRIES);
if (initial) { // Custom repo add button part.
preference = findPreference("pref_custom_add_repo_button");
if (preference == null) return;
preference.setOnPreferenceClickListener(preference1 -> {
final Context context = this.requireContext();
MaterialAlertDialogBuilder builder = new MaterialAlertDialogBuilder(context);
final MaterialAutoCompleteTextView input =
new MaterialAutoCompleteTextView(context);
final MaterialAutoCompleteTextView input = new MaterialAutoCompleteTextView(context);
input.setHint(R.string.custom_url);
builder.setIcon(R.drawable.ic_baseline_add_box_24);
builder.setTitle(R.string.add_repo);
@ -472,8 +438,7 @@ public class SettingsActivity extends FoxActivity implements LanguageActivity {
builder.setPositiveButton("OK", (dialog, which) -> {
String text = String.valueOf(input.getText());
if (customRepoManager.canAddRepo(text)) {
final CustomRepoData customRepoData =
customRepoManager.addRepo(text);
final CustomRepoData customRepoData = customRepoManager.addRepo(text);
customRepoData.setEnabled(true);
new Thread("Add Custom Repo Thread") {
@Override
@ -490,8 +455,7 @@ public class SettingsActivity extends FoxActivity implements LanguageActivity {
});
builder.setNegativeButton("Cancel", (dialog, which) -> dialog.cancel());
AlertDialog alertDialog = builder.show();
final Button positiveButton =
alertDialog.getButton(AlertDialog.BUTTON_POSITIVE);
final Button positiveButton = alertDialog.getButton(AlertDialog.BUTTON_POSITIVE);
input.setValidator(new AutoCompleteTextView.Validator() {
@Override
public boolean isValid(CharSequence charSequence) {
@ -505,16 +469,12 @@ public class SettingsActivity extends FoxActivity implements LanguageActivity {
});
input.addTextChangedListener(new TextWatcherAdapter() {
@Override
public void onTextChanged(
@NonNull CharSequence charSequence, int i, int i1, int i2) {
positiveButton.setEnabled(customRepoManager
.canAddRepo(charSequence.toString()) &&
customRepoManager.getRepoCount() < CUSTOM_REPO_ENTRIES);
public void onTextChanged(@NonNull CharSequence charSequence, int i, int i1, int i2) {
positiveButton.setEnabled(customRepoManager.canAddRepo(charSequence.toString()) && customRepoManager.getRepoCount() < CUSTOM_REPO_ENTRIES);
}
});
positiveButton.setEnabled(false);
int dp10 = FoxDisplay.dpToPixel(10),
dp20 = FoxDisplay.dpToPixel(20);
int dp10 = FoxDisplay.dpToPixel(10), dp20 = FoxDisplay.dpToPixel(20);
FoxViewCompat.setMargin(input, dp20, dp10, dp20, dp10);
return true;
});
@ -523,8 +483,7 @@ public class SettingsActivity extends FoxActivity implements LanguageActivity {
private void setRepoData(String url) {
final RepoData repoData = RepoManager.getINSTANCE().get(url);
setRepoData(repoData, "pref_" + (repoData == null ?
RepoManager.internalIdOfUrl(url) : repoData.getPreferenceId()));
setRepoData(repoData, "pref_" + (repoData == null ? RepoManager.internalIdOfUrl(url) : repoData.getPreferenceId()));
}
private void setRepoData(final RepoData repoData, String preferenceName) {
@ -539,11 +498,9 @@ public class SettingsActivity extends FoxActivity implements LanguageActivity {
preference = findPreference(preferenceName + "_enabled");
if (preference != null) {
((TwoStatePreference) preference).setChecked(repoData.isEnabled());
preference.setTitle(repoData.isEnabled() ?
R.string.repo_enabled : R.string.repo_disabled);
preference.setTitle(repoData.isEnabled() ? R.string.repo_enabled : R.string.repo_disabled);
preference.setOnPreferenceChangeListener((p, newValue) -> {
p.setTitle(((Boolean) newValue) ?
R.string.repo_enabled : R.string.repo_disabled);
p.setTitle(((Boolean) newValue) ? R.string.repo_enabled : R.string.repo_disabled);
return true;
});
}
@ -554,8 +511,7 @@ public class SettingsActivity extends FoxActivity implements LanguageActivity {
preference.setVisible(true);
preference.setOnPreferenceClickListener(p -> {
if (homepage.startsWith("https://www.androidacy.com/")) {
IntentHelper.openUrlAndroidacy(
getFoxActivity(this), homepage, true);
IntentHelper.openUrlAndroidacy(getFoxActivity(this), homepage, true);
} else {
IntentHelper.openUrl(getFoxActivity(this), homepage);
}
@ -600,8 +556,7 @@ public class SettingsActivity extends FoxActivity implements LanguageActivity {
preference.setVisible(true);
preference.setOnPreferenceClickListener(p -> {
if (submissionUrl.startsWith("https://www.androidacy.com/")) {
IntentHelper.openUrlAndroidacy(
getFoxActivity(this), submissionUrl, true);
IntentHelper.openUrlAndroidacy(getFoxActivity(this), submissionUrl, true);
} else {
IntentHelper.openUrl(getFoxActivity(this), submissionUrl);
}

@ -24,4 +24,5 @@
<color name="light_colorBackgroundFloating">#FFFFFFFF</color>
<color name="light_backgroundColor">#FFFFFFFF</color>
<color name="light_chipBackgroundColor">#FFDADADA</color>
<color name="gray_900">#3A3A3A</color>
</resources>

@ -165,4 +165,7 @@
<string name="please_wait">Please wait</string>
<string name="api_key_removed">Successfully reset API key</string>
<string name="save_api_key">Validate</string>
<string name="warning">Warning!</string>
<string name="androidacy_test_mode_warning">You are setting the app to use a non-production endpoint for Androidacy. This may result in app instability and failure to load the online repo. Do NOT report bugs if you have this switch on. Change will take effect on app restart.</string>
<string name="crash">Crash the app for testing</string>
</resources>

@ -3,161 +3,165 @@
<!-- Custom repos has been announced, check https://github.com/Fox2Code/FoxMagiskModuleManager/issues/131 -->
<PreferenceCategory app:title="@string/pref_category_repos">
<Preference
app:key="pref_manage_repos"
app:icon="@drawable/ic_baseline_extension_24"
app:title="@string/manage_repos_pref"
app:singleLineTitle="false" />
app:key="pref_manage_repos"
app:singleLineTitle="false"
app:title="@string/manage_repos_pref" />
<SwitchPreferenceCompat
app:defaultValue="false"
app:key="pref_show_incompatible"
app:icon="@drawable/ic_baseline_hide_source_24"
app:title="@string/show_incompatible_pref"
app:key="pref_show_incompatible"
app:singleLineTitle="false"
app:summary="@string/show_incompatible_desc"
app:singleLineTitle="false" />
app:title="@string/show_incompatible_pref" />
<SwitchPreferenceCompat
app:defaultValue="false"
app:key="pref_disable_low_quality_module_filter"
app:icon="@drawable/ic_baseline_warning_24"
app:title="@string/disable_low_quality_module_filter_pref"
app:key="pref_disable_low_quality_module_filter"
app:singleLineTitle="false"
app:summary="@string/disable_low_quality_module_filter_desc"
app:singleLineTitle="false" />
app:title="@string/disable_low_quality_module_filter_pref" />
<SwitchPreferenceCompat
app:defaultValue="false"
app:key="pref_use_magisk_install_command"
app:icon="@drawable/ic_baseline_numbers_24"
app:title="@string/use_magisk_install_command_pref"
app:key="pref_use_magisk_install_command"
app:singleLineTitle="false"
app:summary="@string/use_magisk_install_command_desc"
app:singleLineTitle="false" />
app:title="@string/use_magisk_install_command_pref" />
<SwitchPreferenceCompat
app:defaultValue="true"
app:key="pref_background_update_check"
app:icon="@drawable/ic_baseline_notifications_24"
app:title="@string/notification_update_pref"
app:key="pref_background_update_check"
app:singleLineTitle="false"
app:summary="@string/notification_update_desc"
app:singleLineTitle="false" />
app:title="@string/notification_update_pref" />
<Preference
app:key="pref_background_update_check_debug"
app:title="@string/notification_update_debug_pref"
app:singleLineTitle="false" />
app:singleLineTitle="false"
app:title="@string/notification_update_debug_pref" />
</PreferenceCategory>
<PreferenceCategory app:title="@string/pref_category_appearance">
<ListPreference
app:key="pref_theme"
app:icon="@drawable/ic_baseline_palette_24"
app:title="@string/theme_pref"
app:defaultValue="system"
app:entries="@array/theme_values_names"
app:entryValues="@array/theme_values"
app:singleLineTitle="false" />
app:icon="@drawable/ic_baseline_palette_24"
app:key="pref_theme"
app:singleLineTitle="false"
app:title="@string/theme_pref" />
<Preference
app:key="pref_language_selector"
app:icon="@drawable/ic_baseline_language_24"
app:title="@string/language" />
app:key="pref_language_selector"
app:title="@string/language" />
<SwitchPreferenceCompat
app:defaultValue="false"
app:key="pref_enable_blur"
app:icon="@drawable/ic_baseline_blur_on_24"
app:title="@string/enable_blur_pref"
app:singleLineTitle="false" />
app:key="pref_enable_blur"
app:singleLineTitle="false"
app:title="@string/enable_blur_pref" />
<SwitchPreferenceCompat
app:defaultValue="false"
app:key="pref_force_dark_terminal"
app:icon="@drawable/ic_baseline_list_24"
app:title="@string/force_dark_terminal_title"
app:singleLineTitle="false" />
app:key="pref_force_dark_terminal"
app:singleLineTitle="false"
app:title="@string/force_dark_terminal_title" />
<SwitchPreferenceCompat
app:defaultValue="@bool/monet_enabled_by_default"
app:key="pref_enable_monet"
app:icon="@drawable/ic_baseline_design_services_24"
app:title="@string/enable_monet"
app:singleLineTitle="false" />
app:key="pref_enable_monet"
app:singleLineTitle="false"
app:title="@string/enable_monet" />
<SwitchPreferenceCompat
app:defaultValue="false"
app:key="pref_wrap_text"
app:icon="@drawable/ic_baseline_keyboard_return_24"
app:title="@string/wrap_text_pref"
app:key="pref_wrap_text"
app:singleLineTitle="false"
app:summary="@string/wrap_text_desc"
app:singleLineTitle="false" />
app:title="@string/wrap_text_pref" />
</PreferenceCategory>
<PreferenceCategory app:title="@string/pref_category_security">
<SwitchPreferenceCompat
app:defaultValue="true"
app:key="pref_dns_over_https"
app:icon="@drawable/ic_baseline_security_24"
app:title="@string/dns_over_https_pref"
app:key="pref_dns_over_https"
app:singleLineTitle="false"
app:summary="@string/dns_over_https_desc"
app:singleLineTitle="false" />
app:title="@string/dns_over_https_pref" />
<!-- Note: Lockdown mode used to be called showcase mode -->
<SwitchPreferenceCompat
app:defaultValue="false"
app:key="pref_showcase_mode"
app:icon="@drawable/ic_baseline_lock_24"
app:title="@string/showcase_mode_pref"
app:key="pref_showcase_mode"
app:singleLineTitle="false"
app:summary="@string/showcase_mode_desc"
app:singleLineTitle="false" />
app:title="@string/showcase_mode_pref" />
<SwitchPreferenceCompat
app:defaultValue="true"
app:key="pref_prevent_reboot"
app:icon="@drawable/ic_reboot_24"
app:title="@string/prevent_reboot_pref"
app:key="pref_prevent_reboot"
app:singleLineTitle="false"
app:summary="@string/prevent_reboot_desc"
app:singleLineTitle="false" />
app:title="@string/prevent_reboot_pref" />
<!-- Crash reporting -->
<SwitchPreferenceCompat
app:defaultValue="true"
app:key="pref_crash_reporting"
app:icon="@drawable/ic_baseline_bug_report_24"
app:title="@string/crash_reporting"
app:key="pref_crash_reporting"
app:singleLineTitle="false"
app:summary="@string/crash_reporting_desc"
app:singleLineTitle="false" />
app:title="@string/crash_reporting" />
<!-- Purposely crash the app -->
<Preference
app:icon="@drawable/ic_baseline_bug_report_24"
app:key="pref_crash"
app:singleLineTitle="false"
app:title="@string/crash" />
</PreferenceCategory>
<PreferenceCategory
app:title="@string/pref_category_info">
<PreferenceCategory app:title="@string/pref_category_info">
<Preference
app:key="pref_update"
app:icon="@drawable/ic_baseline_system_update_24"
app:title="@string/app_update"
app:singleLineTitle="false" />
app:key="pref_update"
app:singleLineTitle="false"
app:title="@string/app_update" />
<Preference
app:key="pref_report_bug"
app:icon="@drawable/ic_baseline_bug_report_24"
app:title="@string/report_bugs"
app:singleLineTitle="false" />
app:key="pref_report_bug"
app:singleLineTitle="false"
app:title="@string/report_bugs" />
<Preference
app:key="pref_source_code"
app:icon="@drawable/ic_github"
app:title="@string/source_code"
app:singleLineTitle="false" />
app:key="pref_source_code"
app:singleLineTitle="false"
app:title="@string/source_code" />
<Preference
app:key="pref_support"
app:icon="@drawable/ic_baseline_telegram_24"
app:title="@string/support"
app:singleLineTitle="false" />
app:key="pref_support"
app:singleLineTitle="false"
app:title="@string/support" />
<Preference
app:key="pref_show_licenses"
app:icon="@drawable/ic_baseline_info_24"
app:title="@string/show_licenses"
app:singleLineTitle="false" />
app:key="pref_show_licenses"
app:singleLineTitle="false"
app:title="@string/show_licenses" />
<Preference
app:key="pref_pkg_info"
app:enabled="false"
app:summary="@string/loading"
app:iconSpaceReserved="false"
app:key="pref_pkg_info"
app:singleLineTitle="false"
app:iconSpaceReserved="false" />
app:summary="@string/loading" />
</PreferenceCategory>
</PreferenceScreen>
Loading…
Cancel
Save