(misc) fix settings bugs

known issue is custom repo can't be added

Signed-off-by: androidacy-user <opensource@androidacy.com>
pull/299/head
androidacy-user 1 year ago
parent a96cee7e2e
commit 8ba2d2d98e

@ -318,7 +318,6 @@ dependencies {
implementation 'com.google.android.material:material:1.8.0'
implementation 'dev.rikka.rikkax.layoutinflater:layoutinflater:1.3.0'
implementation "dev.rikka.rikkax.insets:insets:1.3.0"
implementation 'com.github.Dimezis:BlurView:version-2.0.2'
implementation 'com.github.KieronQuinn:MonetCompat:0.4.1'
implementation 'com.github.Fox2Code:FoxCompat:0.2.0'
// Update the version code in the root build.gradle

@ -1,7 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
xmlns:app="http://schemas.android.com/apk/res-auto"
tools:ignore="QueryAllPackagesPermission"
tools:targetApi="tiramisu">
@ -19,7 +18,7 @@
<!-- uses webview -->
<uses-feature
android:name="android.software.webview"
android:required="false" />
android:required="true" />
<!-- uses opengl 1.2 -->
<uses-feature
android:name="android.hardware.opengles.aep"
@ -65,6 +64,7 @@
android:memtagMode="async"
android:theme="@style/Theme.MagiskModuleManager"
android:usesCleartextTraffic="false"
android:forceDarkAllowed="false"
android:extractNativeLibs="true"
tools:ignore="ManifestResource"
tools:replace="android:supportsRtl"

@ -12,7 +12,6 @@ import android.content.pm.PackageManager;
import android.content.res.Configuration;
import android.content.res.Resources;
import android.graphics.Color;
import android.graphics.drawable.ColorDrawable;
import android.net.Uri;
import android.os.Build;
import android.os.Bundle;
@ -29,7 +28,6 @@ import androidx.appcompat.widget.SearchView;
import androidx.cardview.widget.CardView;
import androidx.core.app.NotificationManagerCompat;
import androidx.core.content.ContextCompat;
import androidx.core.graphics.ColorUtils;
import androidx.preference.PreferenceManager;
import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;
@ -74,7 +72,6 @@ public class MainActivity extends FoxActivity implements SwipeRefreshLayout.OnRe
private long swipeRefreshBlocker = 0;
private int overScrollInsetTop;
private int overScrollInsetBottom;
private ColorDrawable actionBarBackground;
private RecyclerView moduleList;
private RecyclerView moduleListOnline;
private CardView searchCard;
@ -129,7 +126,6 @@ public class MainActivity extends FoxActivity implements SwipeRefreshLayout.OnRe
WindowManager.LayoutParams.LAYOUT_IN_DISPLAY_CUTOUT_MODE_SHORT_EDGES;
this.getWindow().setAttributes(layoutParams);
}
this.actionBarBackground = new ColorDrawable(Color.TRANSPARENT);
this.progressIndicator = findViewById(R.id.progress_bar);
this.swipeRefreshLayout = findViewById(R.id.swipe_refresh);
this.swipeRefreshLayoutOrigStartOffset = this.swipeRefreshLayout.getProgressViewStartOffset();
@ -148,6 +144,8 @@ public class MainActivity extends FoxActivity implements SwipeRefreshLayout.OnRe
this.moduleListOnline.setLayoutManager(new LinearLayoutManager(this));
this.moduleList.setItemViewCacheSize(4); // Default is 2
this.swipeRefreshLayout.setOnRefreshListener(this);
// add background blur if enabled
this.updateBlurState();
hideActionBar();
this.updateBlurState();
checkShowInitialSetup();
@ -397,18 +395,13 @@ public class MainActivity extends FoxActivity implements SwipeRefreshLayout.OnRe
}
private void updateBlurState() {
boolean isLightMode = this.isLightTheme();
int colorBackground;
try {
colorBackground = this.getColorCompat(android.R.attr.windowBackground);
} catch (Resources.NotFoundException e) {
colorBackground = this.getColorCompat(isLightMode ? R.color.white : R.color.black);
}
if (MainApplication.isBlurEnabled()) {
this.actionBarBackground.setColor(ColorUtils.setAlphaComponent(colorBackground, 0x02));
this.actionBarBackground.setColor(Color.TRANSPARENT);
} else {
this.actionBarBackground.setColor(colorBackground);
// set bottom navigation bar color to transparent blur
BottomNavigationView bottomNavigationView = findViewById(R.id.bottom_navigation);
bottomNavigationView.setBackgroundColor(Color.TRANSPARENT);
bottomNavigationView.setAlpha(0.8F);
// set dialogs to have transparent blur
getWindow().addFlags(WindowManager.LayoutParams.FLAG_BLUR_BEHIND);
}
}

@ -3,9 +3,7 @@ package com.fox2code.mmm.markdown;
import android.content.Intent;
import android.content.pm.PackageManager;
import android.content.res.Configuration;
import android.content.res.Resources;
import android.graphics.Color;
import android.graphics.drawable.ColorDrawable;
import android.os.Build;
import android.os.Bundle;
import android.view.View;
@ -15,16 +13,15 @@ import android.widget.TextView;
import android.widget.Toast;
import androidx.annotation.Nullable;
import androidx.core.graphics.ColorUtils;
import com.fox2code.foxcompat.app.FoxActivity;
import com.fox2code.mmm.Constants;
import com.fox2code.mmm.MainApplication;
import com.fox2code.mmm.R;
import com.fox2code.mmm.XHooks;
import com.fox2code.mmm.utils.BlurUtils;
import com.fox2code.mmm.utils.IntentHelper;
import com.fox2code.mmm.utils.io.net.Http;
import com.google.android.material.bottomnavigation.BottomNavigationView;
import com.google.android.material.chip.Chip;
import com.google.android.material.chip.ChipGroup;
import com.google.android.material.dialog.MaterialAlertDialogBuilder;
@ -34,17 +31,11 @@ import java.io.IOException;
import java.nio.charset.StandardCharsets;
import java.util.HashMap;
import eightbitlab.com.blurview.BlurView;
import timber.log.Timber;
public class MarkdownActivity extends FoxActivity {
private static final HashMap<String, String> redirects = new HashMap<>(4);
private static final String[] variants = new String[]{
"readme.md", "README.MD", ".github/README.md"
};
private TextView actionBarPadding;
private ColorDrawable actionBarBackground;
private BlurView actionBarBlur;
private static final String[] variants = new String[]{"readme.md", "README.MD", ".github/README.md"};
private TextView header;
private TextView footer;
@ -57,8 +48,7 @@ public class MarkdownActivity extends FoxActivity {
return Http.doHttpGet(url, true);
} catch (IOException e) {
// Workaround GitHub README.md case sensitivity issue
if (url.startsWith("https://raw.githubusercontent.com/") &&
url.endsWith("/README.md")) {
if (url.startsWith("https://raw.githubusercontent.com/") && url.endsWith("/README.md")) {
String prefix = url.substring(0, url.length() - 9);
for (String suffix : variants) {
newUrl = prefix + suffix;
@ -84,28 +74,19 @@ public class MarkdownActivity extends FoxActivity {
this.forceBackPressed();
return;
}
String url = intent.getExtras()
.getString(Constants.EXTRA_MARKDOWN_URL);
String title = intent.getExtras()
.getString(Constants.EXTRA_MARKDOWN_TITLE);
String config = intent.getExtras()
.getString(Constants.EXTRA_MARKDOWN_CONFIG);
boolean change_boot = intent.getExtras()
.getBoolean(Constants.EXTRA_MARKDOWN_CHANGE_BOOT);
boolean needs_ramdisk = intent.getExtras()
.getBoolean(Constants.EXTRA_MARKDOWN_NEEDS_RAMDISK);
int min_magisk = intent.getExtras()
.getInt(Constants.EXTRA_MARKDOWN_MIN_MAGISK);
int min_api = intent.getExtras()
.getInt(Constants.EXTRA_MARKDOWN_MIN_API);
int max_api = intent.getExtras()
.getInt(Constants.EXTRA_MARKDOWN_MAX_API);
String url = intent.getExtras().getString(Constants.EXTRA_MARKDOWN_URL);
String title = intent.getExtras().getString(Constants.EXTRA_MARKDOWN_TITLE);
String config = intent.getExtras().getString(Constants.EXTRA_MARKDOWN_CONFIG);
boolean change_boot = intent.getExtras().getBoolean(Constants.EXTRA_MARKDOWN_CHANGE_BOOT);
boolean needs_ramdisk = intent.getExtras().getBoolean(Constants.EXTRA_MARKDOWN_NEEDS_RAMDISK);
int min_magisk = intent.getExtras().getInt(Constants.EXTRA_MARKDOWN_MIN_MAGISK);
int min_api = intent.getExtras().getInt(Constants.EXTRA_MARKDOWN_MIN_API);
int max_api = intent.getExtras().getInt(Constants.EXTRA_MARKDOWN_MAX_API);
if (title != null && !title.isEmpty()) {
this.setTitle(title);
}
setActionBarBackground(null);
this.getWindow().setFlags(
WindowManager.LayoutParams.FLAG_TRANSLUCENT_NAVIGATION, 0);
this.getWindow().setFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_NAVIGATION, 0);
if (config != null && !config.isEmpty()) {
String configPkg = IntentHelper.getPackageOfConfig(config);
try {
@ -115,8 +96,7 @@ public class MarkdownActivity extends FoxActivity {
return true;
});
} catch (PackageManager.NameNotFoundException e) {
Timber.w("Config package \"" +
configPkg + "\" missing for markdown view");
Timber.w("Config package \"" + configPkg + "\" missing for markdown view");
}
}
// validate the url won't crash the app
@ -130,13 +110,8 @@ public class MarkdownActivity extends FoxActivity {
setContentView(R.layout.markdown_view);
final ViewGroup markdownBackground = findViewById(R.id.markdownBackground);
final TextView textView = findViewById(R.id.markdownView);
this.actionBarPadding = findViewById(R.id.markdown_action_bar_padding);
this.actionBarBackground = new ColorDrawable(Color.TRANSPARENT);
this.actionBarBlur = findViewById(R.id.markdown_action_bar_blur);
this.header = findViewById(R.id.markdownHeader);
this.footer = findViewById(R.id.markdownFooter);
this.actionBarBlur.setBackground(this.actionBarBackground);
BlurUtils.setupBlur(this.actionBarBlur, this, markdownBackground);
this.updateBlurState();
UiThreadHandler.handler.post(() -> // Fix header/footer height
this.updateScreenInsets(this.getResources().getConfiguration()));
@ -157,57 +132,40 @@ public class MarkdownActivity extends FoxActivity {
String markdown = new String(rawMarkdown, StandardCharsets.UTF_8);
Timber.i("Done!");
runOnUiThread(() -> {
findViewById(R.id.markdownFooter)
.setMinimumHeight(this.getNavigationBarHeight());
MainApplication.getINSTANCE().getMarkwon().setMarkdown(
textView, MarkdownUrlLinker.urlLinkify(markdown));
findViewById(R.id.markdownFooter).setMinimumHeight(this.getNavigationBarHeight());
MainApplication.getINSTANCE().getMarkwon().setMarkdown(textView, MarkdownUrlLinker.urlLinkify(markdown));
if (markdownBackground != null) {
markdownBackground.setClickable(true);
}
});
} catch (Exception e) {
Timber.e(e);
runOnUiThread(() -> Toast.makeText(this, R.string.failed_download,
Toast.LENGTH_SHORT).show());
runOnUiThread(() -> Toast.makeText(this, R.string.failed_download, Toast.LENGTH_SHORT).show());
}
}, "Markdown load thread").start();
}
private void updateBlurState() {
boolean isLightMode = this.isLightTheme();
int colorBackground;
try {
colorBackground = this.getColorCompat(
android.R.attr.windowBackground);
} catch (Resources.NotFoundException e) {
colorBackground = this.getColorCompat(isLightMode ?
R.color.white : R.color.black);
}
if (MainApplication.isBlurEnabled()) {
this.actionBarBlur.setBlurEnabled(true);
this.actionBarBackground.setColor(ColorUtils
.setAlphaComponent(colorBackground, 0x02));
this.actionBarBackground.setColor(Color.TRANSPARENT);
} else {
this.actionBarBlur.setBlurEnabled(false);
this.actionBarBlur.setOverlayColor(Color.TRANSPARENT);
this.actionBarBackground.setColor(colorBackground);
// set bottom navigation bar color to transparent blur
BottomNavigationView bottomNavigationView = findViewById(R.id.bottom_navigation);
bottomNavigationView.setBackgroundColor(Color.TRANSPARENT);
bottomNavigationView.setAlpha(0.8F);
// set dialogs to have transparent blur
getWindow().addFlags(WindowManager.LayoutParams.FLAG_BLUR_BEHIND);
}
}
private void updateScreenInsets() {
this.runOnUiThread(() -> this.updateScreenInsets(
this.getResources().getConfiguration()));
this.runOnUiThread(() -> this.updateScreenInsets(this.getResources().getConfiguration()));
}
private void updateScreenInsets(Configuration configuration) {
boolean landscape = configuration.orientation ==
Configuration.ORIENTATION_LANDSCAPE;
boolean landscape = configuration.orientation == Configuration.ORIENTATION_LANDSCAPE;
int bottomInset = (landscape ? 0 : this.getNavigationBarHeight());
int statusBarHeight = getStatusBarHeight();
int actionBarHeight = getActionBarHeight();
int combinedBarsHeight = statusBarHeight + actionBarHeight;
this.actionBarPadding.setMinHeight(combinedBarsHeight);
this.header.setMinHeight(combinedBarsHeight);
this.footer.setMinHeight(bottomInset);
//this.actionBarBlur.invalidate();
@ -226,8 +184,7 @@ public class MarkdownActivity extends FoxActivity {
}
private void addChip(MarkdownChip markdownChip) {
this.makeChip(this.getString(markdownChip.title),
markdownChip.desc == 0 ? null : this.getString(markdownChip.desc));
this.makeChip(this.getString(markdownChip.title), markdownChip.desc == 0 ? null : this.getString(markdownChip.desc));
}
private void addChip(MarkdownChip markdownChip, String extra) {
@ -237,8 +194,7 @@ public class MarkdownActivity extends FoxActivity {
} else {
title = title + " " + extra;
}
this.makeChip(title, markdownChip.desc == 0 ?
null : this.getString(markdownChip.desc));
this.makeChip(title, markdownChip.desc == 0 ? null : this.getString(markdownChip.desc));
}
private void makeChip(String title, String message) {
@ -248,14 +204,9 @@ public class MarkdownActivity extends FoxActivity {
chip.setVisibility(View.VISIBLE);
if (message != null) {
chip.setOnClickListener(_view -> {
MaterialAlertDialogBuilder builder =
new MaterialAlertDialogBuilder(this);
MaterialAlertDialogBuilder builder = new MaterialAlertDialogBuilder(this);
builder
.setTitle(title)
.setMessage(message)
.setCancelable(true)
.setPositiveButton(R.string.ok, (x, y) -> x.dismiss()).show();
builder.setTitle(title).setMessage(message).setCancelable(true).setPositiveButton(R.string.ok, (x, y) -> x.dismiss()).show();
});
}

@ -109,7 +109,6 @@ public class ModuleViewListBuilder {
Timber.i("A2: %s", repoManager.getModules().size());
boolean no32bitSupport = Build.SUPPORTED_32_BIT_ABIS.length == 0;
for (RepoModule repoModule : repoManager.getModules().values()) {
Timber.i("Module id %s from repo %s", repoModule.id, (repoModule.repoData == null ? "null" : repoModule.repoData.id));
// if repoData is null, something is wrong
if (repoModule.repoData == null) {
Timber.w("RepoData is null for module %s", repoModule.id);

@ -14,7 +14,6 @@ import java.util.Collection;
import java.util.Collections;
import java.util.HashSet;
import java.util.List;
import java.util.Objects;
import java.util.concurrent.atomic.AtomicBoolean;
import io.realm.Realm;
@ -327,7 +326,6 @@ public class RepoUpdater {
moduleListCache.setStats(downloads);
realm.copyToRealmOrUpdate(moduleListCache);
realm.commitTransaction();
Timber.d("Inserted module %s to realm. New record is %s", id, Objects.requireNonNull(realm.where(ModuleListCache.class).equalTo("codename", id).findFirst()).toString());
} catch (
Exception e) {
Timber.w("Failed to get module info from module " + module + " in repo " + this.repoData.id + " with error " + e.getMessage());

@ -20,12 +20,10 @@ import android.os.Handler;
import android.os.Looper;
import android.provider.Settings;
import android.text.Html;
import android.text.method.LinkMovementMethod;
import android.view.View;
import android.view.inputmethod.EditorInfo;
import android.widget.AutoCompleteTextView;
import android.widget.Button;
import android.widget.TextView;
import android.widget.Toast;
import androidx.annotation.StringRes;
@ -41,6 +39,8 @@ import androidx.preference.PreferenceGroup;
import androidx.preference.PreferenceManager;
import androidx.preference.SwitchPreferenceCompat;
import androidx.preference.TwoStatePreference;
import androidx.security.crypto.EncryptedSharedPreferences;
import androidx.security.crypto.MasterKey;
import com.fox2code.foxcompat.app.FoxActivity;
import com.fox2code.foxcompat.view.FoxDisplay;
@ -193,9 +193,23 @@ public class SettingsActivity extends FoxActivity implements LanguageActivity {
@Override
@SuppressWarnings("ConstantConditions")
public void onCreatePreferences(Bundle savedInstanceState, String rootKey) {
String name = "mmm";
Context context = requireContext();
MasterKey masterKey;
PreferenceManager preferenceManager = getPreferenceManager();
preferenceManager.setPreferenceDataStore(new EncryptedPreferenceDataStore(this.getContext()));
preferenceManager.setSharedPreferencesName("mmm");
SharedPreferenceDataStore dataStore;
SharedPreferences.Editor editor;
try {
masterKey = new MasterKey.Builder(context).setKeyScheme(MasterKey.KeyScheme.AES256_GCM).build();
dataStore = new SharedPreferenceDataStore(EncryptedSharedPreferences.create(context, name, masterKey, EncryptedSharedPreferences.PrefKeyEncryptionScheme.AES256_SIV, EncryptedSharedPreferences.PrefValueEncryptionScheme.AES256_GCM));
preferenceManager.setPreferenceDataStore(dataStore);
preferenceManager.setSharedPreferencesName("mmm");
editor = dataStore.getSharedPreferences().edit();
} catch (Exception e) {
Timber.e(e, "Failed to create encrypted shared preferences");
throw new RuntimeException(getString(R.string.error_encrypted_shared_preferences));
}
assert preferenceManager != null;
setPreferencesFromResource(R.xml.root_preferences, rootKey);
applyMaterial3(getPreferenceScreen());
// add bottom navigation bar to the settings
@ -216,7 +230,6 @@ public class SettingsActivity extends FoxActivity implements LanguageActivity {
findPreference("pref_enable_monet").setEnabled(false);
// Toggle monet off
((TwoStatePreference) findPreference("pref_enable_monet")).setChecked(false);
SharedPreferences.Editor editor = getPreferenceManager().getSharedPreferences().edit();
editor.putBoolean("pref_enable_monet", false).apply();
// Set summary
findPreference("pref_enable_monet").setSummary(R.string.monet_disabled_summary);
@ -231,8 +244,6 @@ public class SettingsActivity extends FoxActivity implements LanguageActivity {
// You need to reboot your device at least once to be able to access dev-mode
if (devModeStepFirstBootIgnore || !MainApplication.isFirstBoot()) devModeStep = 1;
Timber.d("refreshing activity. New value: %s", newValue);
// Immediately save
SharedPreferences.Editor editor = getPreferenceManager().getSharedPreferences().edit();
editor.putString("pref_theme", (String) newValue).apply();
// If theme contains "transparent" then disable monet
if (newValue.toString().contains("transparent")) {
@ -317,14 +328,12 @@ public class SettingsActivity extends FoxActivity implements LanguageActivity {
new MaterialAlertDialogBuilder(requireContext()).setTitle(R.string.low_performance_device_dialogue_title).setMessage(R.string.low_performance_device_dialogue_message).setPositiveButton(R.string.ok, (dialog, which) -> {
// Toggle blur on
((TwoStatePreference) findPreference("pref_enable_blur")).setChecked(true);
SharedPreferences.Editor editor = getPreferenceManager().getSharedPreferences().edit();
editor.putBoolean("pref_enable_blur", true).apply();
// Set summary
findPreference("pref_enable_blur").setSummary(R.string.blur_disabled_summary);
}).setNegativeButton(R.string.cancel, (dialog, which) -> {
// Revert to blur on
((TwoStatePreference) findPreference("pref_enable_blur")).setChecked(false);
SharedPreferences.Editor editor = getPreferenceManager().getSharedPreferences().edit();
editor.putBoolean("pref_enable_blur", false).apply();
// Set summary
findPreference("pref_enable_blur").setSummary(null);
@ -1160,33 +1169,42 @@ public class SettingsActivity extends FoxActivity implements LanguageActivity {
startActivity(intent);
});
AlertDialog alertDialog = builder.show();
//make message clickable
((TextView) Objects.requireNonNull(alertDialog.findViewById(android.R.id.message))).setMovementMethod(LinkMovementMethod.getInstance());
final Button positiveButton = alertDialog.getButton(DialogInterface.BUTTON_POSITIVE);
input.setValidator(new AutoCompleteTextView.Validator() {
@Override
public boolean isValid(CharSequence charSequence) {
Timber.i("checking repo url validity");
// show error if string is empty, does not start with https://, or contains spaces
if (charSequence.toString().isEmpty()) {
input.setError(getString(R.string.empty_field));
Timber.d("No input for repo");
positiveButton.setEnabled(false);
return false;
} else if (!charSequence.toString().matches("^https://.*")) {
input.setError(getString(R.string.invalid_repo_url));
Timber.d("Non https link for repo");
return false;
} else if (charSequence.toString().contains(" ")) {
input.setError(getString(R.string.invalid_repo_url));
Timber.d("Repo url has space");
positiveButton.setEnabled(false);
return false;
} else if (!customRepoManager.canAddRepo(charSequence.toString())) {
input.setError(getString(R.string.repo_already_added));
Timber.d("Could not add repo for misc reason");
positiveButton.setEnabled(false);
return false;
} else {
// enable ok button
Timber.d("Repo URL is ok");
positiveButton.setEnabled(true);
return true;
}
}
@Override
public CharSequence fixText(CharSequence invalidText) {
return null;
return invalidText;
}
});
positiveButton.setEnabled(false);

@ -1,47 +1,28 @@
package com.fox2code.mmm.settings;
import android.annotation.SuppressLint;
import android.content.Context;
import android.content.SharedPreferences;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.preference.PreferenceDataStore;
import androidx.security.crypto.EncryptedSharedPreferences;
import androidx.security.crypto.MasterKey;
import com.fox2code.mmm.MainApplication;
import java.io.IOException;
import java.security.GeneralSecurityException;
import java.util.Set;
public class EncryptedPreferenceDataStore extends PreferenceDataStore {
private static final String CONFIG_FILE_NAME = "mmm";
@SuppressLint("StaticFieldLeak")
private static EncryptedPreferenceDataStore mInstance;
private SharedPreferences mSharedPreferences;
EncryptedPreferenceDataStore(Context context) {
try {
MasterKey mainKeyAlias;
try {
mainKeyAlias = new MasterKey.Builder(MainApplication.getINSTANCE().getApplicationContext()).setKeyScheme(MasterKey.KeyScheme.AES256_GCM).build();
} catch (GeneralSecurityException | IOException e) {
throw new RuntimeException(e);
}
mSharedPreferences = EncryptedSharedPreferences.create(MainApplication.getINSTANCE().getApplicationContext(), "mmm", mainKeyAlias, EncryptedSharedPreferences.PrefKeyEncryptionScheme.AES256_SIV, EncryptedSharedPreferences.PrefValueEncryptionScheme.AES256_GCM);
} catch (Exception e) {
// Fallback
mSharedPreferences = context.getSharedPreferences(CONFIG_FILE_NAME, Context.MODE_PRIVATE);
}
import timber.log.Timber;
public class SharedPreferenceDataStore extends PreferenceDataStore {
private final SharedPreferences mSharedPreferences;
public SharedPreferenceDataStore(@NonNull SharedPreferences sharedPreferences) {
Timber.d("SharedPreferenceDataStore: %s", sharedPreferences);
mSharedPreferences = sharedPreferences;
}
public static PreferenceDataStore getInstance() {
if (mInstance == null) {
mInstance = new EncryptedPreferenceDataStore(MainApplication.getINSTANCE().getApplicationContext());
}
return mInstance;
@NonNull
public SharedPreferences getSharedPreferences() {
Timber.d("getSharedPreferences: %s", mSharedPreferences);
return mSharedPreferences;
}
@Override
@ -105,4 +86,4 @@ public class EncryptedPreferenceDataStore extends PreferenceDataStore {
public boolean getBoolean(String key, boolean defValue) {
return mSharedPreferences.getBoolean(key, defValue);
}
}
}

@ -1,72 +0,0 @@
package com.fox2code.mmm.utils;
import android.app.Activity;
import android.graphics.Bitmap;
import android.graphics.Canvas;
import android.os.Build;
import android.view.ViewGroup;
import androidx.annotation.IdRes;
import androidx.annotation.NonNull;
import eightbitlab.com.blurview.BlurAlgorithm;
import eightbitlab.com.blurview.BlurView;
import eightbitlab.com.blurview.RenderEffectBlur;
import eightbitlab.com.blurview.RenderScriptBlur;
public enum BlurUtils {
;
public static void setupBlur(BlurView blurView, Activity activity, @IdRes int viewId) {
setupBlur(blurView, activity, activity.findViewById(viewId));
}
@SuppressWarnings("deprecation")
public static void setupBlur(BlurView blurView, Activity activity, ViewGroup rootView) {
blurView.setupWith(rootView, new BlurAlgorithmWrapper(
Build.VERSION.SDK_INT < Build.VERSION_CODES.S ?
new RenderScriptBlur(blurView.getContext()) : new RenderEffectBlur()))
.setFrameClearDrawable(activity.getWindow().getDecorView().getBackground())
.setBlurRadius(4F).setBlurAutoUpdate(true);
}
// Allow to have fancy blur, use more performance.
private static final class BlurAlgorithmWrapper implements BlurAlgorithm {
private final BlurAlgorithm algorithm;
private BlurAlgorithmWrapper(BlurAlgorithm algorithm) {
this.algorithm = algorithm;
}
@Override
public Bitmap blur(Bitmap bitmap, float blurRadius) {
return this.algorithm.blur(bitmap, blurRadius * 6f);
}
@Override
public void destroy() {
this.algorithm.destroy();
}
@Override
public boolean canModifyBitmap() {
return this.algorithm.canModifyBitmap();
}
@NonNull
@Override
public Bitmap.Config getSupportedBitmapConfig() {
return this.algorithm.getSupportedBitmapConfig();
}
@Override
public float scaleFactor() {
return 1f;
}
@Override
public void render(@NonNull Canvas canvas, @NonNull Bitmap bitmap) {
this.algorithm.render(canvas, bitmap);
}
}
}

@ -5,7 +5,7 @@
android:id="@+id/root_container"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:padding="0dp"
android:padding="4dp"
app:fitsSystemWindowsInsets="start|end|bottom|top"
tools:context=".MainActivity">
@ -24,16 +24,16 @@
android:layout_height="match_parent"
android:paddingBottom="84dp">
<androidx.recyclerview.widget.RecyclerView
android:id="@+id/module_list"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
<!-- online modules -->
<androidx.recyclerview.widget.RecyclerView
android:id="@+id/module_list_online"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:visibility="gone" />
<androidx.recyclerview.widget.RecyclerView
android:id="@+id/module_list"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
<!-- online modules -->
<androidx.recyclerview.widget.RecyclerView
android:id="@+id/module_list_online"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:visibility="gone" />
</FrameLayout>
</androidx.swiperefreshlayout.widget.SwipeRefreshLayout>
@ -83,8 +83,8 @@
android:id="@+id/search_bar"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:padding="2dp"
android:background="@null"
android:padding="2dp"
android:visibility="visible"
app:iconifiedByDefault="true"
app:useDrawerArrowDrawable="true" />

@ -57,18 +57,4 @@
</LinearLayout>
</androidx.core.widget.NestedScrollView>
<eightbitlab.com.blurview.BlurView
android:id="@+id/markdown_action_bar_blur"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent">
<TextView
android:id="@+id/markdown_action_bar_padding"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
</eightbitlab.com.blurview.BlurView>
</androidx.constraintlayout.widget.ConstraintLayout>

@ -397,4 +397,6 @@
<string name="empty_field">URL is required</string>
<string name="repo_already_added">Repo already exists.</string>
<string name="language_not_available">Language %s has not been translated. Help translate it?</string>
<string name="blur_desc">Creates a blur effect behind some dialogs and elements. Note that blur may not perform well on some devices and may not work for everyone.</string>
<string name="error_encrypted_shared_preferences">An error occurred reading shared preferences. Please reset the app.</string>
</resources>

@ -1,7 +1,7 @@
<resources xmlns:tools="http://schemas.android.com/tools">
<style name="Theme.MagiskModuleManager.Light" parent="Theme.Material3.Light">
<item name="android:isLightTheme"
tools:targetApi="q">true</item>
<item name="android:isLightTheme" tools:targetApi="q">true</item>
<item name="isLightTheme">true</item>
<!-- Primary brand color. -->
<item name="colorPrimary">@color/orange_200</item>
@ -31,6 +31,7 @@
<item name="chipStyle">@style/Widget.Material3.Chip.Choice.Light</item>
<!-- fonts -->
<item name="android:fontFamily">@font/inter</item>
<item name="windowActionBar">false</item>
</style>
<style name="Widget.Material3.Chip.Choice.Light" parent="Widget.Material3.Chip.Assist">
@ -59,10 +60,11 @@
<item name="chipStyle">@style/Widget.Material3.Chip.Choice.Light</item>
<!-- fonts -->
<item name="android:fontFamily">@font/inter</item>
<item name="windowActionBar">false</item>
</style>
<style name="Theme.MagiskModuleManager.Dark" parent="Theme.Material3.Dark">
<item name="android:isLightTheme"
tools:targetApi="q">false</item>
<item name="android:isLightTheme" tools:targetApi="q">false</item>
<item name="isLightTheme">false</item>
<!-- Primary brand color. -->
<item name="colorPrimary">@color/orange_200</item>
@ -91,6 +93,7 @@
<item name="backgroundColor">@color/dark_backgroundColor</item>
<!-- fonts -->
<item name="android:fontFamily">@font/inter</item>
<item name="windowActionBar">false</item>
</style>
<!-- Black theme, which is just a dark theme with a black background -->
@ -113,6 +116,7 @@
<item name="android:colorBackgroundCacheHint">@null</item>
<!-- chips should be dark, not black -->
<item name="chipStyle">@style/Widget.Material.Chip.Choice.Dark</item>
<item name="windowActionBar">false</item>
</style>
<style name="Widget.Material.Chip.Choice.Dark" parent="Widget.MaterialComponents.Chip.Action">
@ -134,14 +138,17 @@
<item name="android:windowTranslucentStatus">false</item>
<item name="android:statusBarColor">@android:color/transparent</item>
<item name="windowNoTitle">true</item>
<item name="windowActionBar">false</item>
</style>
<style name="Theme.MagiskModuleManager"
parent="Theme.MagiskModuleManager.Light" />
<style name="Theme.MagiskModuleManager.NoActionBar">
<item name="windowActionBar">false</item>
<item name="windowNoTitle">true</item>
</style>
<style name="Theme.MagiskModuleManager.AppBarOverlay" parent="ThemeOverlay.AppCompat.Dark.ActionBar" />
<style name="Theme.MagiskModuleManager.PopupOverlay" parent="ThemeOverlay.AppCompat.Light" />
<style name="Theme.MagiskModuleManager" parent="Theme.MagiskModuleManager.Light" />
<style name="Theme.MagiskModuleManager.NoActionBar">
<item name="windowActionBar">false</item>
<item name="windowNoTitle">true</item>
</style>
<style name="Theme.MagiskModuleManager.AppBarOverlay" parent="ThemeOverlay.AppCompat.Dark.ActionBar" />
<style name="Theme.MagiskModuleManager.PopupOverlay" parent="ThemeOverlay.AppCompat.Light" />
</resources>

@ -122,6 +122,7 @@
app:icon="@drawable/ic_baseline_blur_on_24"
app:key="pref_enable_blur"
app:singleLineTitle="false"
app:summary="@string/blur_desc"
app:title="@string/enable_blur_pref" />
<SwitchPreferenceCompat

Loading…
Cancel
Save