From 8ba2d2d98ec5efcf8559fa8dff02f3a0d06d477f Mon Sep 17 00:00:00 2001 From: androidacy-user Date: Tue, 11 Apr 2023 21:37:13 -0400 Subject: [PATCH] (misc) fix settings bugs known issue is custom repo can't be added Signed-off-by: androidacy-user --- app/build.gradle | 1 - app/src/main/AndroidManifest.xml | 4 +- .../java/com/fox2code/mmm/MainActivity.java | 23 ++-- .../mmm/markdown/MarkdownActivity.java | 105 +++++------------- .../mmm/module/ModuleViewListBuilder.java | 1 - .../com/fox2code/mmm/repo/RepoUpdater.java | 2 - .../mmm/settings/SettingsActivity.java | 42 +++++-- ...re.java => SharedPreferenceDataStore.java} | 49 +++----- .../com/fox2code/mmm/utils/BlurUtils.java | 72 ------------ app/src/main/res/layout/activity_main.xml | 24 ++-- app/src/main/res/layout/markdown_view.xml | 14 --- app/src/main/res/values/strings.xml | 2 + app/src/main/res/values/themes.xml | 31 ++++-- app/src/main/res/xml/root_preferences.xml | 1 + 14 files changed, 117 insertions(+), 254 deletions(-) rename app/src/main/java/com/fox2code/mmm/settings/{EncryptedPreferenceDataStore.java => SharedPreferenceDataStore.java} (54%) delete mode 100644 app/src/main/java/com/fox2code/mmm/utils/BlurUtils.java diff --git a/app/build.gradle b/app/build.gradle index 5769d5c..14f4c36 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -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 diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index ee80686..8fc8069 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -1,7 +1,6 @@ @@ -19,7 +18,7 @@ + android:required="true" /> 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(); }); } diff --git a/app/src/main/java/com/fox2code/mmm/module/ModuleViewListBuilder.java b/app/src/main/java/com/fox2code/mmm/module/ModuleViewListBuilder.java index 3b86af3..7fdd9e2 100644 --- a/app/src/main/java/com/fox2code/mmm/module/ModuleViewListBuilder.java +++ b/app/src/main/java/com/fox2code/mmm/module/ModuleViewListBuilder.java @@ -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); diff --git a/app/src/main/java/com/fox2code/mmm/repo/RepoUpdater.java b/app/src/main/java/com/fox2code/mmm/repo/RepoUpdater.java index 8ec84d3..a8c5862 100644 --- a/app/src/main/java/com/fox2code/mmm/repo/RepoUpdater.java +++ b/app/src/main/java/com/fox2code/mmm/repo/RepoUpdater.java @@ -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()); diff --git a/app/src/main/java/com/fox2code/mmm/settings/SettingsActivity.java b/app/src/main/java/com/fox2code/mmm/settings/SettingsActivity.java index 6b5771c..34fd4fb 100644 --- a/app/src/main/java/com/fox2code/mmm/settings/SettingsActivity.java +++ b/app/src/main/java/com/fox2code/mmm/settings/SettingsActivity.java @@ -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); diff --git a/app/src/main/java/com/fox2code/mmm/settings/EncryptedPreferenceDataStore.java b/app/src/main/java/com/fox2code/mmm/settings/SharedPreferenceDataStore.java similarity index 54% rename from app/src/main/java/com/fox2code/mmm/settings/EncryptedPreferenceDataStore.java rename to app/src/main/java/com/fox2code/mmm/settings/SharedPreferenceDataStore.java index cb38577..3270e2f 100644 --- a/app/src/main/java/com/fox2code/mmm/settings/EncryptedPreferenceDataStore.java +++ b/app/src/main/java/com/fox2code/mmm/settings/SharedPreferenceDataStore.java @@ -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); } -} +} \ No newline at end of file diff --git a/app/src/main/java/com/fox2code/mmm/utils/BlurUtils.java b/app/src/main/java/com/fox2code/mmm/utils/BlurUtils.java deleted file mode 100644 index 60957bd..0000000 --- a/app/src/main/java/com/fox2code/mmm/utils/BlurUtils.java +++ /dev/null @@ -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); - } - } -} diff --git a/app/src/main/res/layout/activity_main.xml b/app/src/main/res/layout/activity_main.xml index 5b4d781..d7a67c5 100644 --- a/app/src/main/res/layout/activity_main.xml +++ b/app/src/main/res/layout/activity_main.xml @@ -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"> - - - + + + @@ -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" /> diff --git a/app/src/main/res/layout/markdown_view.xml b/app/src/main/res/layout/markdown_view.xml index 2b30a39..ee4d594 100644 --- a/app/src/main/res/layout/markdown_view.xml +++ b/app/src/main/res/layout/markdown_view.xml @@ -57,18 +57,4 @@ - - - - - diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index acce799..0680c31 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -397,4 +397,6 @@ URL is required Repo already exists. Language %s has not been translated. Help translate it? + 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. + An error occurred reading shared preferences. Please reset the app. diff --git a/app/src/main/res/values/themes.xml b/app/src/main/res/values/themes.xml index 46ba63c..53531e1 100644 --- a/app/src/main/res/values/themes.xml +++ b/app/src/main/res/values/themes.xml @@ -1,7 +1,7 @@ + + @@ -113,6 +116,7 @@ @null @style/Widget.Material.Chip.Choice.Dark + false - - + +