From 5d844e0911d3fb705062d88f7daf368d79ee2c92 Mon Sep 17 00:00:00 2001 From: androidacy-user Date: Tue, 3 Jan 2023 15:11:33 -0500 Subject: [PATCH] recreate setup activity Signed-off-by: androidacy-user --- app/build.gradle | 3 + app/src/main/AndroidManifest.xml | 76 +++---- .../java/com/fox2code/mmm/MainActivity.java | 130 +----------- .../com/fox2code/mmm/MainApplication.java | 29 +++ .../mmm/settings/SettingsActivity.java | 31 +-- app/src/main/res/layout/setup_box.xml | 190 +----------------- app/src/main/res/values/dimens.xml | 3 + app/src/main/res/values/strings.xml | 93 ++++++++- app/src/main/res/values/themes.xml | 16 +- 9 files changed, 188 insertions(+), 383 deletions(-) diff --git a/app/build.gradle b/app/build.gradle index 317f76c..8449ad4 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -316,6 +316,9 @@ android { includeInApk false includeInBundle false } + buildFeatures { + viewBinding true + } } // Safeguard (Do not remove) diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index dfa3971..313460d 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -1,5 +1,6 @@ - @@ -10,23 +11,15 @@ - - - + - - - - - - - - - - - - + android:name="android.hardware.wifi" + android:required="false" /> + + + + + + + @@ -69,6 +68,7 @@ android:launchMode="singleTask"> + @@ -79,18 +79,22 @@ android:parentActivityName=".MainActivity" android:screenOrientation="portrait" tools:ignore="LockedOrientationActivity"> - - - + + --> + + + @@ -106,9 +110,12 @@ android:exported="false" android:parentActivityName=".MainActivity" android:theme="@style/Theme.MagiskModuleManager"> - + + --> - - - - + android:value="https://198c68516cb0412b9832204631a3fac8@o993586.ingest.sentry.io/4504069942804480" /> - + android:value="0.5" /> - + android:value="true" /> - + android:value="true" /> - + android:value="true" /> @@ -169,4 +168,5 @@ android:name="io.sentry.traces.profiling.sample-rate" android:value="0.25" /> + \ No newline at end of file diff --git a/app/src/main/java/com/fox2code/mmm/MainActivity.java b/app/src/main/java/com/fox2code/mmm/MainActivity.java index 9e51a73..0fc7138 100644 --- a/app/src/main/java/com/fox2code/mmm/MainActivity.java +++ b/app/src/main/java/com/fox2code/mmm/MainActivity.java @@ -26,7 +26,6 @@ import android.widget.TextView; import android.widget.Toast; import androidx.annotation.NonNull; -import androidx.appcompat.app.ActionBar; import androidx.appcompat.widget.SearchView; import androidx.cardview.widget.CardView; import androidx.core.app.ActivityCompat; @@ -52,11 +51,8 @@ import com.fox2code.mmm.utils.BlurUtils; import com.fox2code.mmm.utils.ExternalHelper; import com.fox2code.mmm.utils.Http; import com.fox2code.mmm.utils.IntentHelper; -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; @@ -66,7 +62,6 @@ import org.json.JSONObject; import java.io.IOException; import java.net.HttpURLConnection; import java.net.URL; -import java.util.Objects; import eightbitlab.com.blurview.BlurView; @@ -90,7 +85,7 @@ public class MainActivity extends FoxActivity implements SwipeRefreshLayout.OnRe private CardView searchCard; private SearchView searchView; private boolean initMode; - private boolean doSetupRestarting = false; + public static boolean doSetupRestarting = false; private boolean urlFactoryInstalled = false; public MainActivity() { @@ -747,122 +742,13 @@ public class MainActivity extends FoxActivity implements SwipeRefreshLayout.OnRe Log.i("SetupWizard", "First launch: " + firstLaunch); if (firstLaunch) { doSetupNowRunning = true; - // Show setup box. Put the setup_box in the main activity layout - View view = getLayoutInflater().inflate(R.layout.setup_box, null); - // Make the setup_box linear layout the sole child of the root_container constraint layout - setContentView(view); - updateScreenInsets(); - // Handle action bar. Set it to setup_title and make it visible - ActionBar actionBar = getSupportActionBar(); - if (actionBar != null) { - actionBar.setTitle(R.string.app_name); - // Set solid color background - actionBar.show(); - } - ((MaterialSwitch) Objects.requireNonNull(view.findViewById(R.id.setup_background_update_check))).setChecked(BuildConfig.ENABLE_AUTO_UPDATER); - ((MaterialSwitch) Objects.requireNonNull(view.findViewById(R.id.setup_crash_reporting))).setChecked(BuildConfig.DEFAULT_ENABLE_CRASH_REPORTING); - // Repos are a little harder, as the enabled_repos build config is an arraylist - ((MaterialSwitch) Objects.requireNonNull(view.findViewById(R.id.setup_androidacy_repo))).setChecked(BuildConfig.ENABLED_REPOS.contains("androidacy_repo")); - ((MaterialSwitch) Objects.requireNonNull(view.findViewById(R.id.setup_magisk_alt_repo))).setChecked(BuildConfig.ENABLED_REPOS.contains("magisk_alt_repo")); - // On debug builds, log when a switch is toggled - if (BuildConfig.DEBUG) { - ((MaterialSwitch) Objects.requireNonNull(view.findViewById(R.id.setup_background_update_check))).setOnCheckedChangeListener((buttonView, isChecked) -> Log.i("SetupWizard", "Background Update Check: " + isChecked)); - ((MaterialSwitch) Objects.requireNonNull(view.findViewById(R.id.setup_crash_reporting))).setOnCheckedChangeListener((buttonView, isChecked) -> Log.i("SetupWizard", "Crash Reporting: " + isChecked)); - ((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 dialog for the theme picker - MaterialAlertDialogBuilder builder = new MaterialAlertDialogBuilder(this); - builder.setTitle(R.string.setup_theme_title); - // Create a new array of theme names (system, light, dark, black, transparent light) - String[] themeNames = new String[]{getString(R.string.theme_system), getString(R.string.theme_light), getString(R.string.theme_dark), getString(R.string.theme_black), getString(R.string.theme_transparent_light)}; - // Create a new array of theme values (system, light, dark, black, transparent_light) - String[] themeValues = new String[]{"system", "light", "dark", "black", "transparent_light"}; - // if pref_theme is set, check the relevant theme_* menu item, otherwise check the default (theme_system) - String prefTheme = prefs.getString("pref_theme", "system"); - int checkedItem = 0; - switch (prefTheme) { - case "system": - break; - case "light": - checkedItem = 1; - break; - case "dark": - checkedItem = 2; - break; - case "black": - checkedItem = 3; - break; - case "transparent_light": - checkedItem = 4; - break; - } - builder.setCancelable(true); - // Create the dialog - builder.setSingleChoiceItems(themeNames, checkedItem, (dialog, which) -> { - // Set the theme - prefs.edit().putString("pref_theme", themeValues[which]).commit(); - // Set the theme button text to the selected theme - themeButton.setText(themeNames[which]); - // Dismiss the dialog - dialog.dismiss(); - // Set the theme - UiThreadHandler.handler.postDelayed(() -> { - MainApplication.getINSTANCE().updateTheme(); - FoxActivity.getFoxActivity(this).setThemeRecreate(MainApplication.getINSTANCE().getManagerThemeResId()); - }, 1); - }); - builder.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 restart the activity - prefs.edit().putBoolean("first_time_user", false).commit(); - finish(); - startActivity(getIntent()); - }); - // Setup button - MaterialButton setupButton = view.findViewById(R.id.setup_continue); - setupButton.setOnClickListener(v -> { - // Set first launch to false - // get instance of editor - SharedPreferences.Editor editor = prefs.edit(); - editor.putBoolean("first_time_user", false); - // Set the background update check pref - editor.putBoolean("pref_background_update_check", ((MaterialSwitch) Objects.requireNonNull(view.findViewById(R.id.setup_background_update_check))).isChecked()); - // Set the crash reporting pref - editor.putBoolean("pref_crash_reporting", ((MaterialSwitch) Objects.requireNonNull(view.findViewById(R.id.setup_crash_reporting))).isChecked()); - // Set the repos - // 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()); - // Commit the changes - editor.commit(); - // Sleep for 1 second to allow the user to see the changes - try { - Thread.sleep(500); - } catch ( - InterruptedException e) { - e.printStackTrace(); - } - // Log the changes if debug - if (BuildConfig.DEBUG) { - Log.d("SetupWizard", "Background update check: " + prefs.getBoolean("pref_background_update_check", false)); - Log.i("SetupWizard", "Crash reporting: " + prefs.getBoolean("pref_crash_reporting", false)); - Log.i("SetupWizard", "Magisk Alt Repo: " + prefs.getBoolean("pref_magisk_alt_repo_enabled", false)); - Log.i("SetupWizard", "Androidacy Repo: " + prefs.getBoolean("pref_androidacy_repo_enabled", false)); - } - // Restart the activity - doSetupRestarting = true; - finish(); - startActivity(getIntent()); - }); + // Launch setup wizard + if (BuildConfig.DEBUG) + Log.i("SetupWizard", "Launching setup wizard"); + // Show setup activity + Intent intent = new Intent(this, SetupActivity.class); + finish(); + startActivity(intent); } else { ensurePermissions(); } diff --git a/app/src/main/java/com/fox2code/mmm/MainApplication.java b/app/src/main/java/com/fox2code/mmm/MainApplication.java index 7ca9e64..7303923 100644 --- a/app/src/main/java/com/fox2code/mmm/MainApplication.java +++ b/app/src/main/java/com/fox2code/mmm/MainApplication.java @@ -37,6 +37,7 @@ import com.topjohnwu.superuser.Shell; import java.io.File; import java.text.SimpleDateFormat; import java.util.Date; +import java.util.HashSet; import java.util.Locale; import java.util.Objects; import java.util.Random; @@ -79,6 +80,10 @@ public class MainApplication extends FoxApplication implements androidx.work.Con private FoxThemeWrapper markwonThemeContext; private Markwon markwon; + // Warning! Locales that are't exist will crash the app + // Anything that is commented out is supported but the translation is not complete to at least 60% + public static HashSet supportedLocales = new HashSet<>(); + public MainApplication() { if (INSTANCE != null && INSTANCE != this) throw new IllegalStateException("Duplicate application instance!"); @@ -280,6 +285,30 @@ public class MainApplication extends FoxApplication implements androidx.work.Con @Override public void onCreate() { + // supportedLocales.add("ar"); + // supportedLocales.add("ar_SA"); + supportedLocales.add("cs"); + supportedLocales.add("de"); + // supportedLocales.add("el"); + supportedLocales.add("es"); + supportedLocales.add("es-rMX"); + // supportedLocales.add("et"); + supportedLocales.add("fr"); + supportedLocales.add("id"); + supportedLocales.add("it"); + // supportedLocales.add("ja"); + // supportedLocales.add("nb-rNO"); + supportedLocales.add("pl"); + supportedLocales.add("pt-rBR"); + supportedLocales.add("ro"); + supportedLocales.add("ru"); + supportedLocales.add("sk"); + supportedLocales.add("tr"); + supportedLocales.add("uk"); + // supportedLocales.add("vi"); + supportedLocales.add("zh-rCH"); + // supportedLocales.add("zh-rTW"); + supportedLocales.add("en"); if (INSTANCE == null) INSTANCE = this; relPackageName = this.getPackageName(); 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 f792370..ae931fe 100644 --- a/app/src/main/java/com/fox2code/mmm/settings/SettingsActivity.java +++ b/app/src/main/java/com/fox2code/mmm/settings/SettingsActivity.java @@ -76,7 +76,6 @@ import org.json.JSONException; import java.io.IOException; import java.io.RandomAccessFile; import java.security.NoSuchAlgorithmException; -import java.util.HashSet; import java.util.Locale; import java.util.Objects; import java.util.Random; @@ -329,38 +328,10 @@ public class SettingsActivity extends FoxActivity implements LanguageActivity { return true; }); - // Warning! Locales that are't exist will crash the app - // Anything that is commented out is supported but the translation is not complete to at least 60% - HashSet supportedLocales = new HashSet<>(); - // supportedLocales.add("ar"); - // supportedLocales.add("ar_SA"); - supportedLocales.add("cs"); - supportedLocales.add("de"); - // supportedLocales.add("el"); - supportedLocales.add("es"); - supportedLocales.add("es-rMX"); - // supportedLocales.add("et"); - supportedLocales.add("fr"); - supportedLocales.add("id"); - supportedLocales.add("it"); - // supportedLocales.add("ja"); - // supportedLocales.add("nb-rNO"); - supportedLocales.add("pl"); - supportedLocales.add("pt-rBR"); - supportedLocales.add("ro"); - supportedLocales.add("ru"); - supportedLocales.add("sk"); - supportedLocales.add("tr"); - supportedLocales.add("uk"); - // supportedLocales.add("vi"); - supportedLocales.add("zh-rCH"); - // supportedLocales.add("zh-rTW"); - supportedLocales.add("en"); - Preference languageSelector = findPreference("pref_language_selector"); languageSelector.setOnPreferenceClickListener(preference -> { LanguageSwitcher ls = new LanguageSwitcher(getActivity()); - ls.setSupportedStringLocales(supportedLocales); + ls.setSupportedStringLocales(MainApplication.supportedLocales); ls.showChangeLanguageDialog(getActivity()); return true; }); diff --git a/app/src/main/res/layout/setup_box.xml b/app/src/main/res/layout/setup_box.xml index b77f4bf..62f8644 100644 --- a/app/src/main/res/layout/setup_box.xml +++ b/app/src/main/res/layout/setup_box.xml @@ -1,194 +1,10 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + android:layout_height="wrap_content" android:orientation="vertical"> - - - - - - - - - \ No newline at end of file + \ No newline at end of file diff --git a/app/src/main/res/values/dimens.xml b/app/src/main/res/values/dimens.xml index 52e003c..1b91ae3 100644 --- a/app/src/main/res/values/dimens.xml +++ b/app/src/main/res/values/dimens.xml @@ -5,4 +5,7 @@ 0dp 32dp 8dp + 180dp + 16dp + 16dp \ No newline at end of file diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 24444df..aba6f1a 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -278,5 +278,96 @@ And of course, thanks to all of our contributors, whether it\'s translations, code, or just being fun to hang out with! We love you all. Inspecting module… Warning! This module has indicators it may have been installed without your knowledge, or may be attempting to hide itself. Uninstall is strongly recommended. - I understandChoose theme + I understandChoose themeChoose language + SetupActivity + +"Material is the metaphor.\n\n" + +"A material metaphor is the unifying theory of a rationalized space and a system of motion." +"The material is grounded in tactile reality, inspired by the study of paper and ink, yet " +"technologically advanced and open to imagination and magic.\n" +"Surfaces and edges of the material provide visual cues that are grounded in reality. The " +"use of familiar tactile attributes helps users quickly understand affordances. Yet the " +"flexibility of the material creates new affordances that supercede those in the physical " +"world, without breaking the rules of physics.\n" +"The fundamentals of light, surface, and movement are key to conveying how objects move, " +"interact, and exist in space and in relation to each other. Realistic lighting shows " +"seams, divides space, and indicates moving parts.\n\n" + +"Bold, graphic, intentional.\n\n" + +"The foundational elements of print based design typography, grids, space, scale, color, " +"and use of imagery guide visual treatments. These elements do far more than please the " +"eye. They create hierarchy, meaning, and focus. Deliberate color choices, edge to edge " +"imagery, large scale typography, and intentional white space create a bold and graphic " +"interface that immerse the user in the experience.\n" +"An emphasis on user actions makes core functionality immediately apparent and provides " +"waypoints for the user.\n\n" + +"Motion provides meaning.\n\n" + +"Motion respects and reinforces the user as the prime mover. Primary user actions are " +"inflection points that initiate motion, transforming the whole design.\n" +"All action takes place in a single environment. Objects are presented to the user without " +"breaking the continuity of experience even as they transform and reorganize.\n" +"Motion is meaningful and appropriate, serving to focus attention and maintain continuity. " +"Feedback is subtle yet clear. Transitions are efficient yet coherent.\n\n" + +"3D world.\n\n" + +"The material environment is a 3D space, which means all objects have x, y, and z " +"dimensions. The z-axis is perpendicularly aligned to the plane of the display, with the " +"positive z-axis extending towards the viewer. Every sheet of material occupies a single " +"position along the z-axis and has a standard 1dp thickness.\n" +"On the web, the z-axis is used for layering and not for perspective. The 3D world is " +"emulated by manipulating the y-axis.\n\n" + +"Light and shadow.\n\n" + +"Within the material environment, virtual lights illuminate the scene. Key lights create " +"directional shadows, while ambient light creates soft shadows from all angles.\n" +"Shadows in the material environment are cast by these two light sources. In Android " +"development, shadows occur when light sources are blocked by sheets of material at " +"various positions along the z-axis. On the web, shadows are depicted by manipulating the " +"y-axis only. The following example shows the card with a height of 6dp.\n\n" + +"Resting elevation.\n\n" + +"All material objects, regardless of size, have a resting elevation, or default elevation " +"that does not change. If an object changes elevation, it should return to its resting " +"elevation as soon as possible.\n\n" + +"Component elevations.\n\n" + +"The resting elevation for a component type is consistent across apps (e.g., FAB elevation " +"does not vary from 6dp in one app to 16dp in another app).\n" +"Components may have different resting elevations across platforms, depending on the depth " +"of the environment (e.g., TV has a greater depth than mobile or desktop).\n\n" + +"Responsive elevation and dynamic elevation offsets.\n\n" + +"Some component types have responsive elevation, meaning they change elevation in response " +"to user input (e.g., normal, focused, and pressed) or system events. These elevation " +"changes are consistently implemented using dynamic elevation offsets.\n" +"Dynamic elevation offsets are the goal elevation that a component moves towards, relative " +"to the component’s resting state. They ensure that elevation changes are consistent " +"across actions and component types. For example, all components that lift on press have " +"the same elevation change relative to their resting elevation.\n" +"Once the input event is completed or cancelled, the component will return to its resting " +"elevation.\n\n" + +"Avoiding elevation interference.\n\n" + +"Components with responsive elevations may encounter other components as they move between " +"their resting elevations and dynamic elevation offsets. Because material cannot pass " +"through other material, components avoid interfering with one another any number of ways, " +"whether on a per component basis or using the entire app layout.\n" +"On a component level, components can move or be removed before they cause interference. " +"For example, a floating action button (FAB) can disappear or move off screen before a " +"user picks up a card, or it can move if a snackbar appears.\n" +"On the layout level, design your app layout to minimize opportunities for interference. " +"For example, position the FAB to one side of stream of a cards so the FAB won’t interfere " +"when a user tries to pick up one of cards.\n\n" + + Settings diff --git a/app/src/main/res/values/themes.xml b/app/src/main/res/values/themes.xml index d39e9c2..c6c3c8e 100644 --- a/app/src/main/res/values/themes.xml +++ b/app/src/main/res/values/themes.xml @@ -1,7 +1,7 @@ +