Work on setup and enhance themes

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

@ -22,12 +22,12 @@ import android.view.inputmethod.EditorInfo;
import android.widget.CheckBox;
import android.widget.EditText;
import android.widget.LinearLayout;
import android.widget.RadioGroup;
import android.widget.TextView;
import android.widget.Toast;
import androidx.annotation.NonNull;
import androidx.appcompat.app.ActionBar;
import androidx.appcompat.widget.PopupMenu;
import androidx.appcompat.widget.SearchView;
import androidx.cardview.widget.CardView;
import androidx.core.app.ActivityCompat;
@ -57,6 +57,7 @@ import com.google.android.material.button.MaterialButton;
import com.google.android.material.dialog.MaterialAlertDialogBuilder;
import com.google.android.material.materialswitch.MaterialSwitch;
import com.google.android.material.progressindicator.LinearProgressIndicator;
import com.topjohnwu.superuser.internal.UiThreadHandler;
import org.chromium.net.ExperimentalCronetEngine;
import org.chromium.net.urlconnection.CronetURLStreamHandlerFactory;
@ -767,12 +768,66 @@ public class MainActivity extends FoxActivity implements SwipeRefreshLayout.OnRe
((MaterialSwitch) Objects.requireNonNull(view.findViewById(R.id.setup_androidacy_repo))).setOnCheckedChangeListener((buttonView, isChecked) -> Log.i("SetupWizard", "Androidacy Repo: " + isChecked));
((MaterialSwitch) Objects.requireNonNull(view.findViewById(R.id.setup_magisk_alt_repo))).setOnCheckedChangeListener((buttonView, isChecked) -> Log.i("SetupWizard", "Magisk Alt Repo: " + isChecked));
}
// Setup popup dialogue for the setup_theme_button
MaterialButton themeButton = view.findViewById(R.id.setup_theme_button);
themeButton.setOnClickListener(v -> {
// Create a new popup menu
PopupMenu popupMenu = new PopupMenu(this, themeButton);
// Inflate the menu
popupMenu.getMenuInflater().inflate(R.menu.theme_menu, popupMenu.getMenu());
// if pref_theme is set, check the relevant theme_* menu item, otherwise check the default (theme_system)
String prefTheme = prefs.getString("pref_theme", "system");
if (BuildConfig.DEBUG)
Log.i("SetupWizard", "pref_theme: " + prefTheme);
switch (prefTheme) {
case "light":
popupMenu.getMenu().findItem(R.id.theme_light).setChecked(true);
break;
case "dark":
popupMenu.getMenu().findItem(R.id.theme_dark).setChecked(true);
break;
case "system":
popupMenu.getMenu().findItem(R.id.theme_system).setChecked(true);
break;
// Black and transparent_light
case "black":
popupMenu.getMenu().findItem(R.id.theme_black).setChecked(true);
break;
case "transparent_light":
popupMenu.getMenu().findItem(R.id.theme_transparent_light).setChecked(true);
break;
}
// Set the on click listener
popupMenu.setOnMenuItemClickListener(item -> {
if (item == null) {
return false;
}
// Make sure it.s an actual item, not the overflow menu. Actual items have an id of theme_* (see theme_menu.xml)
// Check if item id contains theme_ and return false if it doesn't
String itemId = getResources().getResourceEntryName(item.getItemId());
if (!itemId.contains("theme_")) {
return false;
}
// Save the theme. ID is theme_* so we need to remove the first 6 characters
// Possible values are light, dark, system, transparent_light, and black
prefs.edit().putString("pref_theme", item.getItemId() == R.id.theme_light ? "light" : item.getItemId() == R.id.theme_dark ? "dark" : item.getItemId() == R.id.theme_system ? "system" : item.getItemId() == R.id.theme_transparent_light ? "transparent_light" : "black").commit();
// Set the theme
UiThreadHandler.handler.postDelayed(() -> {
MainApplication.getINSTANCE().updateTheme();
FoxActivity.getFoxActivity(this).setThemeRecreate(
MainApplication.getINSTANCE().getManagerThemeResId());
}, 1);
return true;
});
// Show the popup menu
popupMenu.show();
});
// Set up the buttons
// Cancel button
MaterialButton cancelButton = view.findViewById(R.id.setup_cancel);
cancelButton.setText(R.string.cancel);
cancelButton.setOnClickListener(v -> {
// Set first launch to false and finish the activity
// Set first launch to false and restart the activity
prefs.edit().putBoolean("first_time_user", false).commit();
finish();
startActivity(getIntent());
@ -792,21 +847,6 @@ public class MainActivity extends FoxActivity implements SwipeRefreshLayout.OnRe
// first pref_magisk_alt_repo_enabled then pref_androidacy_repo_enabled
editor.putBoolean("pref_magisk_alt_repo_enabled", ((MaterialSwitch) Objects.requireNonNull(view.findViewById(R.id.setup_magisk_alt_repo))).isChecked());
editor.putBoolean("pref_androidacy_repo_enabled", ((MaterialSwitch) Objects.requireNonNull(view.findViewById(R.id.setup_androidacy_repo))).isChecked());
// Loop through the setup_theme radio group and set the theme pref
RadioGroup themeRadioGroup = view.findViewById(R.id.setup_theme);
int selectedTheme = themeRadioGroup.getCheckedRadioButtonId();
// system, light, dark, black, and transparent_light
if (selectedTheme == R.id.setup_theme_light) {
editor.putString("pref_theme", "light");
} else if (selectedTheme == R.id.setup_theme_dark) {
editor.putString("pref_theme", "dark");
} else if (selectedTheme == R.id.setup_theme_system) {
editor.putString("pref_theme", "system");
} else if (selectedTheme == R.id.setup_theme_black) {
editor.putString("pref_theme", "black");
} else if (selectedTheme == R.id.setup_theme_transparent_light) {
editor.putString("pref_theme", "transparent_light");
}
// Commit the changes
editor.commit();
// Sleep for 1 second to allow the user to see the changes

@ -368,7 +368,11 @@ public final class ModuleViewAdapter extends RecyclerView.Adapter<ModuleViewAdap
if (bgColor == Color.WHITE) {
bgColor = 0xFFF8F8F8;
}
if (theme.getResources().getBoolean(R.bool.force_transparency)) {
// if force_transparency is true or theme is transparent_light, set diff bgColor
// get string value of Theme
String themeName = theme.toString();
if (theme.getResources().getBoolean(R.bool.force_transparency) ||
themeName.contains("transparent")) {
bgColor = ColorUtils.setAlphaComponent(bgColor, 0x80);
}
this.titleText.setTextColor(fgColor);

@ -53,6 +53,9 @@ public class SentryMain {
options.setEnableNdk(true);
// Intercept okhttp requests to add sentry headers
options.addInAppInclude("com.fox2code.mmm");
options.addInAppInclude("com.fox2code.mmm.debug");
options.addInAppInclude("com.fox2code.mmm.fdroid");
options.addInAppExclude("com.fox2code.mmm.utils.SentryMain");
// Sentry sends ABSOLUTELY NO Personally Identifiable Information (PII) by default.
// Already set to false by default, just set it again to make peoples feel safer.
options.setSendDefaultPii(false);

@ -48,43 +48,25 @@
android:text="@string/setup_theme_header"
android:textAppearance="@style/TextAppearance.Material3.HeadlineSmall" />
<RadioGroup
android:id="@+id/setup_theme"
<!-- Button to trigger theme selection -->
<com.google.android.material.button.MaterialButton
android:id="@+id/setup_theme_button"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<com.google.android.material.radiobutton.MaterialRadioButton
android:id="@+id/setup_theme_system"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:checked="true"
android:text="@string/setup_theme_system" />
<com.google.android.material.radiobutton.MaterialRadioButton
android:id="@+id/setup_theme_light"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@string/setup_theme_light" />
<com.google.android.material.radiobutton.MaterialRadioButton
android:id="@+id/setup_theme_dark"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@string/setup_theme_dark" />
<com.google.android.material.radiobutton.MaterialRadioButton
android:id="@+id/setup_theme_black"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@string/setup_theme_black" />
<com.google.android.material.radiobutton.MaterialRadioButton
android:id="@+id/setup_theme_transparent_light"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@string/setup_theme_transparent_light" />
</RadioGroup>
android:layout_height="wrap_content"
android:layout_marginTop="4dp"
android:backgroundTint="@color/gray_900"
android:foreground="?attr/selectableItemBackground"
android:padding="8dp"
android:text="@string/setup_theme_button"
android:textColor="@color/white"
android:textSize="16sp"
app:cornerRadius="8dp"
app:icon="@drawable/ic_baseline_palette_24"
app:iconGravity="textStart"
app:iconPadding="8dp"
app:iconTint="@color/white"
app:iconTintMode="src_in"
app:rippleColor="@color/gray_800" />
<com.google.android.material.textview.MaterialTextView
android:layout_width="match_parent"

@ -0,0 +1,38 @@
<?xml version="1.0" encoding="utf-8"?>
<menu xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.android.com/apk/res-auto">
<!-- Options for system, dark, light, black, transparent_light -->
<!-- Only one of these can be selected at a time -->
<!-- Radio buttons -->
<!-- Themes are taken from theme_values_names string array -->
<item
android:id="@+id/theme"
android:icon="@drawable/ic_baseline_design_services_24"
android:title="@string/theme"
app:showAsAction="never">
<menu>
<group android:checkableBehavior="single">
<!-- System is default selected -->
<item
android:id="@+id/theme_system"
android:title="@string/theme_system"
app:showAsAction="never" />
<item
android:id="@+id/theme_dark"
android:title="@string/theme_dark"
app:showAsAction="never" />
<item
android:id="@+id/theme_black"
android:title="@string/theme_black"
app:showAsAction="never" />
<item
android:id="@+id/theme_transparent_light"
android:title="@string/theme_transparent_light"
app:showAsAction="never" />
<item
android:id="@+id/theme_light"
android:title="@string/theme_light"
app:showAsAction="never" />
</group>
</menu>
</item>
</menu>

@ -248,5 +248,5 @@
<string name="debug_build">This is a debug build. Expect some bugs and worse performance.</string>
<string name="androidacy_repo_name">Androidacy Repo</string>
<string name="magisk_alt_repo_name">Magisk Alt Repo</string>
<string name="repo_enabled_changed">You\'ve enabled or disabled a repo. Please refresh the module list or restart the app.</string><string name="finish">Finish</string><string name="setup_theme">Choose a theme</string><string name="setup_theme_header">Choose a theme</string><string name="setup_theme_system">System theme</string><string name="setup_theme_light">Light theme</string><string name="setup_theme_dark">Dark theme</string><string name="setup_theme_black">AMOLED Black theme</string><string name="setup_theme_transparent_light">Transparent light theme - will disable monet and blur!</string>
<string name="repo_enabled_changed">You\'ve enabled or disabled a repo. Please refresh the module list or restart the app.</string><string name="finish">Finish</string><string name="setup_theme">Choose a theme</string><string name="setup_theme_header">Choose a theme</string><string name="setup_theme_system">System theme</string><string name="setup_theme_light">Light theme</string><string name="setup_theme_dark">Dark theme</string><string name="setup_theme_black">AMOLED Black theme</string><string name="setup_theme_transparent_light">Transparent light theme - will disable monet and blur!</string><string name="setup_theme_button">Choose a theme</string><string name="theme">Theme</string><string name="theme_system">System</string><string name="theme_dark">Dark</string><string name="theme_black">AMOLED Black</string><string name="theme_transparent_light">Light (transparency)</string><string name="theme_light">Light</string>
</resources>

Loading…
Cancel
Save