Work on setup experience

Signed-off-by: androidacy-user <opensource@androidacy.com>
This commit is contained in:
androidacy-user 2022-12-21 16:40:34 -05:00
parent 18d07d81b5
commit 9a79029cfc
8 changed files with 211 additions and 145 deletions

View File

@ -26,7 +26,7 @@ import android.widget.TextView;
import android.widget.Toast; import android.widget.Toast;
import androidx.annotation.NonNull; import androidx.annotation.NonNull;
import androidx.appcompat.app.AlertDialog; import androidx.appcompat.app.ActionBar;
import androidx.appcompat.widget.SearchView; import androidx.appcompat.widget.SearchView;
import androidx.cardview.widget.CardView; import androidx.cardview.widget.CardView;
import androidx.core.app.ActivityCompat; import androidx.core.app.ActivityCompat;
@ -52,6 +52,7 @@ import com.fox2code.mmm.utils.BlurUtils;
import com.fox2code.mmm.utils.ExternalHelper; import com.fox2code.mmm.utils.ExternalHelper;
import com.fox2code.mmm.utils.Http; import com.fox2code.mmm.utils.Http;
import com.fox2code.mmm.utils.IntentHelper; 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.dialog.MaterialAlertDialogBuilder;
import com.google.android.material.materialswitch.MaterialSwitch; import com.google.android.material.materialswitch.MaterialSwitch;
import com.google.android.material.progressindicator.LinearProgressIndicator; import com.google.android.material.progressindicator.LinearProgressIndicator;
@ -128,10 +129,12 @@ public class MainActivity extends FoxActivity implements SwipeRefreshLayout.OnRe
} }
BackgroundUpdateChecker.onMainActivityCreate(this); BackgroundUpdateChecker.onMainActivityCreate(this);
super.onCreate(savedInstanceState); super.onCreate(savedInstanceState);
this.setActionBarExtraMenuButton(R.drawable.ic_baseline_settings_24, v -> { if (!MainApplication.getSharedPreferences().getBoolean("first_run", true)) {
IntentHelper.startActivity(this, SettingsActivity.class); this.setActionBarExtraMenuButton(R.drawable.ic_baseline_settings_24, v -> {
return true; IntentHelper.startActivity(this, SettingsActivity.class);
}, R.string.pref_category_settings); return true;
}, R.string.pref_category_settings);
}
setContentView(R.layout.activity_main); setContentView(R.layout.activity_main);
this.setTitle(R.string.app_name); this.setTitle(R.string.app_name);
this.getWindow().setFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_NAVIGATION, WindowManager.LayoutParams.FLAG_TRANSLUCENT_NAVIGATION); this.getWindow().setFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_NAVIGATION, WindowManager.LayoutParams.FLAG_TRANSLUCENT_NAVIGATION);
@ -740,53 +743,47 @@ public class MainActivity extends FoxActivity implements SwipeRefreshLayout.OnRe
Log.i("SetupWizard", "First launch: " + firstLaunch); Log.i("SetupWizard", "First launch: " + firstLaunch);
if (firstLaunch) { if (firstLaunch) {
doSetupNowRunning = true; doSetupNowRunning = true;
// Show setup box // Show setup box. Put the setup_box in the main activity layout
runOnUiThread(() -> { View view = getLayoutInflater().inflate(R.layout.setup_box, null);
MaterialAlertDialogBuilder builder = new MaterialAlertDialogBuilder(this); // Make the setup_box linear layout the sole child of the root_container constraint layout
builder.setCancelable(false); setContentView(view);
builder.setTitle(R.string.setup_title); // Handle action bar. Set it to setup_title and make it visible
// Create a view from R.xml.setup_box ActionBar actionBar = getSupportActionBar();
View view = getLayoutInflater().inflate(R.layout.setup_box, null); if (actionBar != null) {
builder.setView(view); actionBar.setTitle(R.string.app_name);
// For sdk >= 31, use MaterialSwitch instead of MaterialSwitch // Set solid color background
// For now, we'll just have the positive button save the preferences and dismiss the dialog actionBar.show();
builder.setPositiveButton(R.string.setup_button, (dialog, which) -> { }
// Set the preferences and pref_first_launch to false ((MaterialSwitch) Objects.requireNonNull(view.findViewById(R.id.setup_background_update_check))).setChecked(BuildConfig.ENABLE_AUTO_UPDATER);
prefs.edit().putBoolean("first_launch", false).putBoolean("pref_background_update_check", ((MaterialSwitch) Objects.requireNonNull(((AlertDialog) dialog).findViewById(R.id.setup_background_update_check))).isChecked()).putBoolean("pref_crash_reporting", ((MaterialSwitch) Objects.requireNonNull(((AlertDialog) dialog).findViewById(R.id.setup_crash_reporting))).isChecked()).putBoolean("pref_androidacy_repo_enabled", ((MaterialSwitch) Objects.requireNonNull(((AlertDialog) dialog).findViewById(R.id.setup_androidacy_repo))).isChecked()).putBoolean("pref_magisk_alt_repo_enabled", ((MaterialSwitch) Objects.requireNonNull(((AlertDialog) dialog).findViewById(R.id.setup_magisk_alt_repo))).isChecked()).commit(); ((MaterialSwitch) Objects.requireNonNull(view.findViewById(R.id.setup_crash_reporting))).setChecked(BuildConfig.DEFAULT_ENABLE_CRASH_REPORTING);
// For debug builds, log the preferences // Repos are a little harder, as the enabled_repos build config is an arraylist
if (BuildConfig.DEBUG) { ((MaterialSwitch) Objects.requireNonNull(view.findViewById(R.id.setup_androidacy_repo))).setChecked(BuildConfig.ENABLED_REPOS.contains("androidacy_repo"));
Log.i("SetupWizard", "First launch: " + prefs.getBoolean("first_launch", true)); ((MaterialSwitch) Objects.requireNonNull(view.findViewById(R.id.setup_magisk_alt_repo))).setChecked(BuildConfig.ENABLED_REPOS.contains("magisk_alt_repo"));
Log.i("SetupWizard", "Background update check: " + prefs.getBoolean("pref_background_update_check", false)); // Set up the buttons
Log.i("SetupWizard", "Crash reporting: " + prefs.getBoolean("pref_crash_reporting", false)); // Cancel button
Log.i("SetupWizard", "Androidacy repo: " + prefs.getBoolean("pref_androidacy_repo_enabled", false)); MaterialButton cancelButton = view.findViewById(R.id.setup_cancel);
Log.i("SetupWizard", "Magisk alt repo: " + prefs.getBoolean("pref_magisk_alt_repo_enabled", false)); cancelButton.setText(R.string.cancel);
} cancelButton.setOnClickListener(v -> {
dialog.dismiss(); // Set first launch to false and finish the activity
// Sleep for 100ms. Who knows, it might fix it? prefs.edit().putBoolean("first_launch", false).commit();
try { finish();
Thread.sleep(750); });
} catch (InterruptedException e) { // Setup button
e.printStackTrace(); MaterialButton setupButton = view.findViewById(R.id.setup_continue);
} setupButton.setText(R.string.setup_button);
doSetupRestarting = true; setupButton.setOnClickListener(v -> {
// Restart the app // Set first launch to false
Intent intent = new Intent(this, MainActivity.class); prefs.edit().putBoolean("first_launch", false).commit();
intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP); // Set the background update check pref
finish(); prefs.edit().putBoolean("pref_background_update_check", ((MaterialSwitch) Objects.requireNonNull(view.findViewById(R.id.setup_background_update_check))).isChecked()).commit();
startActivity(intent); // Set the crash reporting pref
}); prefs.edit().putBoolean("pref_crash_reporting", ((MaterialSwitch) Objects.requireNonNull(view.findViewById(R.id.setup_crash_reporting))).isChecked()).commit();
builder.setNegativeButton(R.string.setup_button_skip, (dialog, which) -> { // Set the repos
MainApplication.getSharedPreferences().edit().putBoolean("first_launch", false).commit(); // first pref_magisk_alt_repo_enabled then pref_androidacy_repo_enabled
dialog.dismiss(); prefs.edit().putBoolean("pref_magisk_alt_repo_enabled", ((MaterialSwitch) Objects.requireNonNull(view.findViewById(R.id.setup_magisk_alt_repo))).isChecked()).commit();
ensurePermissions(); prefs.edit().putBoolean("pref_androidacy_repo_enabled", ((MaterialSwitch) Objects.requireNonNull(view.findViewById(R.id.setup_androidacy_repo))).isChecked()).commit();
}); // Finish the activity
builder.show(); finish();
// Set the switches appropriately
((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"));
}); });
} else { } else {
ensurePermissions(); ensurePermissions();

View File

@ -1,11 +1,13 @@
package com.fox2code.mmm.background; package com.fox2code.mmm.background;
import android.Manifest;
import android.app.PendingIntent; import android.app.PendingIntent;
import android.content.Context; import android.content.Context;
import android.content.Intent; import android.content.Intent;
import android.os.Build; import android.content.pm.PackageManager;
import androidx.annotation.NonNull; import androidx.annotation.NonNull;
import androidx.core.app.ActivityCompat;
import androidx.core.app.NotificationChannelCompat; import androidx.core.app.NotificationChannelCompat;
import androidx.core.app.NotificationCompat; import androidx.core.app.NotificationCompat;
import androidx.core.app.NotificationManagerCompat; import androidx.core.app.NotificationManagerCompat;
@ -31,46 +33,30 @@ import java.util.Random;
import java.util.concurrent.TimeUnit; import java.util.concurrent.TimeUnit;
public class BackgroundUpdateChecker extends Worker { public class BackgroundUpdateChecker extends Worker {
private static boolean easterEggActive = false;
static final Object lock = new Object(); // Avoid concurrency issues
public static final String NOTIFICATION_CHANNEL_ID = "background_update"; public static final String NOTIFICATION_CHANNEL_ID = "background_update";
public static final int NOTIFICATION_ID = 1; public static final int NOTIFICATION_ID = 1;
static final Object lock = new Object(); // Avoid concurrency issues
private static boolean easterEggActive = false;
public BackgroundUpdateChecker(@NonNull Context context, public BackgroundUpdateChecker(@NonNull Context context, @NonNull WorkerParameters workerParams) {
@NonNull WorkerParameters workerParams) {
super(context, workerParams); super(context, workerParams);
} }
@NonNull
@Override
public Result doWork() {
if (!NotificationManagerCompat.from(this.getApplicationContext()).areNotificationsEnabled()
|| !MainApplication.isBackgroundUpdateCheckEnabled()) return Result.success();
synchronized (lock) {
doCheck(this.getApplicationContext());
}
return Result.success();
}
static void doCheck(Context context) { static void doCheck(Context context) {
Thread.currentThread().setPriority(2); Thread.currentThread().setPriority(2);
ModuleManager.getINSTANCE().scanAsync(); ModuleManager.getINSTANCE().scanAsync();
RepoManager.getINSTANCE().update(null); RepoManager.getINSTANCE().update(null);
ModuleManager.getINSTANCE().runAfterScan(() -> { ModuleManager.getINSTANCE().runAfterScan(() -> {
int moduleUpdateCount = 0; int moduleUpdateCount = 0;
HashMap<String, RepoModule> repoModules = HashMap<String, RepoModule> repoModules = RepoManager.getINSTANCE().getModules();
RepoManager.getINSTANCE().getModules(); for (LocalModuleInfo localModuleInfo : ModuleManager.getINSTANCE().getModules().values()) {
for (LocalModuleInfo localModuleInfo : if ("twrp-keep".equals(localModuleInfo.id))
ModuleManager.getINSTANCE().getModules().values()) { continue;
if ("twrp-keep".equals(localModuleInfo.id)) continue;
RepoModule repoModule = repoModules.get(localModuleInfo.id); RepoModule repoModule = repoModules.get(localModuleInfo.id);
localModuleInfo.checkModuleUpdate(); localModuleInfo.checkModuleUpdate();
if (localModuleInfo.updateVersionCode > localModuleInfo.versionCode && if (localModuleInfo.updateVersionCode > localModuleInfo.versionCode && !PropUtils.isNullString(localModuleInfo.updateVersion)) {
!PropUtils.isNullString(localModuleInfo.updateVersion)) {
moduleUpdateCount++; moduleUpdateCount++;
} else if (repoModule != null && } else if (repoModule != null && repoModule.moduleInfo.versionCode > localModuleInfo.versionCode && !PropUtils.isNullString(repoModule.moduleInfo.version)) {
repoModule.moduleInfo.versionCode > localModuleInfo.versionCode &&
!PropUtils.isNullString(repoModule.moduleInfo.version)) {
moduleUpdateCount++; moduleUpdateCount++;
} }
} }
@ -81,43 +67,39 @@ public class BackgroundUpdateChecker extends Worker {
} }
public static void postNotification(Context context, int updateCount) { public static void postNotification(Context context, int updateCount) {
if (!easterEggActive) easterEggActive = new Random().nextInt(100) <= updateCount; if (!easterEggActive)
NotificationCompat.Builder builder = new NotificationCompat.Builder( easterEggActive = new Random().nextInt(100) <= updateCount;
context, NOTIFICATION_CHANNEL_ID) NotificationCompat.Builder builder = new NotificationCompat.Builder(context, NOTIFICATION_CHANNEL_ID).setContentTitle(context.getString(easterEggActive ? R.string.notification_update_title_easter_egg : R.string.notification_update_title).replace("%i", String.valueOf(updateCount))).setContentText(context.getString(R.string.notification_update_subtitle)).setSmallIcon(R.drawable.ic_baseline_extension_24).setPriority(NotificationCompat.PRIORITY_HIGH).setContentIntent(PendingIntent.getActivity(context, 0, new Intent(context, MainActivity.class).setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TASK), PendingIntent.FLAG_IMMUTABLE)).setAutoCancel(true);
.setContentTitle(context.getString(easterEggActive ? if (ActivityCompat.checkSelfPermission(MainApplication.getINSTANCE(), Manifest.permission.POST_NOTIFICATIONS) != PackageManager.PERMISSION_GRANTED) {
R.string.notification_update_title_easter_egg : return;
R.string.notification_update_title) }
.replace("%i", String.valueOf(updateCount)))
.setContentText(context.getString(R.string.notification_update_subtitle))
.setSmallIcon(R.drawable.ic_baseline_extension_24)
.setPriority(NotificationCompat.PRIORITY_HIGH)
.setContentIntent(PendingIntent.getActivity(context, 0,
new Intent(context, MainActivity.class).setFlags(
Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TASK),
Build.VERSION.SDK_INT >= Build.VERSION_CODES.M ?
PendingIntent.FLAG_IMMUTABLE : 0)).setAutoCancel(true);
NotificationManagerCompat.from(context).notify(NOTIFICATION_ID, builder.build()); NotificationManagerCompat.from(context).notify(NOTIFICATION_ID, builder.build());
} }
public static void onMainActivityCreate(Context context) { public static void onMainActivityCreate(Context context) {
NotificationManagerCompat notificationManagerCompat = // Refuse to run if first_launch pref is not false
NotificationManagerCompat.from(context); if (MainApplication.getSharedPreferences().getBoolean("first_launch", true))
notificationManagerCompat.createNotificationChannel( return;
new NotificationChannelCompat.Builder(NOTIFICATION_CHANNEL_ID, NotificationManagerCompat notificationManagerCompat = NotificationManagerCompat.from(context);
NotificationManagerCompat.IMPORTANCE_HIGH).setShowBadge(true) notificationManagerCompat.createNotificationChannel(new NotificationChannelCompat.Builder(NOTIFICATION_CHANNEL_ID, NotificationManagerCompat.IMPORTANCE_HIGH).setShowBadge(true).setName(context.getString(R.string.notification_update_pref)).build());
.setName(context.getString(R.string.notification_update_pref)).build());
notificationManagerCompat.cancel(BackgroundUpdateChecker.NOTIFICATION_ID); notificationManagerCompat.cancel(BackgroundUpdateChecker.NOTIFICATION_ID);
BackgroundUpdateChecker.easterEggActive = false; BackgroundUpdateChecker.easterEggActive = false;
WorkManager.getInstance(context).enqueueUniquePeriodicWork("background_checker", WorkManager.getInstance(context).enqueueUniquePeriodicWork("background_checker", ExistingPeriodicWorkPolicy.REPLACE, new PeriodicWorkRequest.Builder(BackgroundUpdateChecker.class, 6, TimeUnit.HOURS).setConstraints(new Constraints.Builder().setRequiresBatteryNotLow(true).setRequiredNetworkType(NetworkType.UNMETERED).build()).build());
ExistingPeriodicWorkPolicy.REPLACE, new PeriodicWorkRequest.Builder(
BackgroundUpdateChecker.class, 6, TimeUnit.HOURS)
.setConstraints(new Constraints.Builder().setRequiresBatteryNotLow(true)
.setRequiredNetworkType(NetworkType.UNMETERED).build()).build());
} }
public static void onMainActivityResume(Context context) { public static void onMainActivityResume(Context context) {
NotificationManagerCompat.from(context).cancel( NotificationManagerCompat.from(context).cancel(BackgroundUpdateChecker.NOTIFICATION_ID);
BackgroundUpdateChecker.NOTIFICATION_ID);
BackgroundUpdateChecker.easterEggActive = false; BackgroundUpdateChecker.easterEggActive = false;
} }
@NonNull
@Override
public Result doWork() {
if (!NotificationManagerCompat.from(this.getApplicationContext()).areNotificationsEnabled() || !MainApplication.isBackgroundUpdateCheckEnabled())
return Result.success();
synchronized (lock) {
doCheck(this.getApplicationContext());
}
return Result.success();
}
} }

View File

@ -30,7 +30,6 @@ import java.io.IOException;
import java.net.HttpURLConnection; import java.net.HttpURLConnection;
import java.net.URL; import java.net.URL;
import java.nio.charset.StandardCharsets; import java.nio.charset.StandardCharsets;
import java.security.NoSuchAlgorithmException;
import java.util.Collection; import java.util.Collection;
import java.util.HashMap; import java.util.HashMap;
import java.util.LinkedHashMap; import java.util.LinkedHashMap;
@ -245,13 +244,6 @@ public final class RepoManager extends SyncManager {
if (!repoUpdaters[i].repoData.isEnabled()) { if (!repoUpdaters[i].repoData.isEnabled()) {
if (BuildConfig.DEBUG) Log.i("RepoManager", if (BuildConfig.DEBUG) Log.i("RepoManager",
"Skipping disabled repo: " + repoUpdaters[i].repoData.getName()); "Skipping disabled repo: " + repoUpdaters[i].repoData.getName());
// Remove the repo from the list
try {
this.repoData.remove(repoUpdaters[i].repoData.getUrl());
} catch (
NoSuchAlgorithmException e) {
e.printStackTrace();
}
continue; continue;
} }
List<RepoModule> repoModules = repoUpdaters[i].toUpdate(); List<RepoModule> repoModules = repoUpdaters[i].toUpdate();

View File

@ -41,13 +41,6 @@ public class RepoUpdater {
return 0; return 0;
} }
this.indexRaw = Http.doHttpGet(this.repoData.getUrl(), false); this.indexRaw = Http.doHttpGet(this.repoData.getUrl(), false);
// Ensure it's a valid json and response code is 200
/*if (Arrays.hashCode(this.indexRaw) == 0) {
this.indexRaw = null;
this.toUpdate = Collections.emptyList();
this.toApply = this.repoData.moduleHashMap.values();
return 0;
}*/
this.toUpdate = this.repoData.populate(new JSONObject( this.toUpdate = this.repoData.populate(new JSONObject(
new String(this.indexRaw, StandardCharsets.UTF_8))); new String(this.indexRaw, StandardCharsets.UTF_8)));
// Since we reuse instances this should work // Since we reuse instances this should work

View File

@ -117,7 +117,7 @@ public class SettingsActivity extends FoxActivity implements LanguageActivity {
} }
int maxCpuFreq = freqResolved == 0 ? -1 : (int) Math.ceil(totalCpuFreq / (float) freqResolved); int maxCpuFreq = freqResolved == 0 ? -1 : (int) Math.ceil(totalCpuFreq / (float) freqResolved);
if (androidVersion < 21 || cpuCount <= 2 || memoryClass <= 100 || cpuCount <= 4 && maxCpuFreq != -1 && maxCpuFreq <= 1250 || cpuCount <= 4 && maxCpuFreq <= 1600 && memoryClass <= 128 && androidVersion <= 21 || cpuCount <= 4 && maxCpuFreq <= 1300 && memoryClass <= 128 && androidVersion <= 24) { if (androidVersion < 21 || cpuCount <= 2 || memoryClass <= 100 || cpuCount <= 4 && maxCpuFreq != -1 && maxCpuFreq <= 1250 || cpuCount <= 4 && maxCpuFreq <= 1600 && memoryClass <= 128 && androidVersion == 21 || cpuCount <= 4 && maxCpuFreq <= 1300 && memoryClass <= 128 && androidVersion <= 24) {
devicePerformanceClass = PERFORMANCE_CLASS_LOW; devicePerformanceClass = PERFORMANCE_CLASS_LOW;
} else if (cpuCount < 8 || memoryClass <= 160 || maxCpuFreq != -1 && maxCpuFreq <= 2050 || maxCpuFreq == -1 && cpuCount == 8 && androidVersion <= 23) { } else if (cpuCount < 8 || memoryClass <= 160 || maxCpuFreq != -1 && maxCpuFreq <= 2050 || maxCpuFreq == -1 && cpuCount == 8 && androidVersion <= 23) {
devicePerformanceClass = PERFORMANCE_CLASS_AVERAGE; devicePerformanceClass = PERFORMANCE_CLASS_AVERAGE;
@ -950,14 +950,19 @@ public class SettingsActivity extends FoxActivity implements LanguageActivity {
private void setRepoData(final RepoData repoData, String preferenceName) { private void setRepoData(final RepoData repoData, String preferenceName) {
ClipboardManager clipboard = (ClipboardManager) ClipboardManager clipboard = (ClipboardManager)
requireContext().getSystemService(Context.CLIPBOARD_SERVICE); requireContext().getSystemService(Context.CLIPBOARD_SERVICE);
if (repoData == null || repoData.isForceHide()) {
hideRepoData(preferenceName);
return;
}
Preference preference = findPreference(preferenceName); Preference preference = findPreference(preferenceName);
if (preference == null) return; if (preference == null) return;
preference.setVisible(true); if (!preferenceName.contains("androidacy") && !preferenceName.contains("magisk_alt_repo")) {
preference.setTitle(repoData.getName()); if (BuildConfig.DEBUG) {
Log.i(TAG, "Setting preference " + preferenceName + " because it is not the Androidacy repo or the Magisk Alt Repo");
}
if (repoData == null || repoData.isForceHide()) {
hideRepoData(preferenceName);
return;
}
preference.setTitle(repoData.getName());
preference.setVisible(true);
}
preference = findPreference(preferenceName + "_enabled"); preference = findPreference(preferenceName + "_enabled");
if (preference != null) { if (preference != null) {
// Handle custom repo separately // Handle custom repo separately
@ -971,6 +976,8 @@ public class SettingsActivity extends FoxActivity implements LanguageActivity {
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) -> { 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);
// Show snackbar telling the user to refresh the modules list or restart the app
Snackbar.make(requireView(), R.string.repo_enabled_changed, Snackbar.LENGTH_LONG).show();
return true; return true;
}); });
} }

View File

@ -1,24 +1,45 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="match_parent" android:gravity="fill" android:orientation="vertical" android:paddingLeft="20dp" android:paddingRight="20dp" android:scrollbars="vertical"> <LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="fill_vertical"
android:orientation="vertical"
android:padding="16dp"
android:scrollbars="vertical" >
<!-- Placeholder for the app bar -->
<View
android:layout_width="match_parent"
android:layout_height="64dp" />
<!-- App name as subheader -->
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@string/setup_title"
android:textAppearance="@style/TextAppearance.Material3.HeadlineSmall" />
<com.google.android.material.textview.MaterialTextView <com.google.android.material.textview.MaterialTextView
android:id="@+id/setup_summary"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_margin="4dp"
android:text="@string/setup_message" /> android:text="@string/setup_message" />
<ScrollView <ScrollView
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent" android:layout_height="match_parent"
app:layout_behavior="@string/appbar_scrolling_view_behavior"
android:fillViewport="true"> android:fillViewport="true">
<LinearLayout <LinearLayout
android:layout_width="wrap_content" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:orientation="vertical"> android:orientation="vertical">
<com.google.android.material.textview.MaterialTextView <com.google.android.material.textview.MaterialTextView
android:layout_width="wrap_content" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_margin="4dp" android:layout_margin="4dp"
android:text="@string/repos" android:text="@string/repos"
@ -26,22 +47,42 @@
<com.google.android.material.materialswitch.MaterialSwitch <com.google.android.material.materialswitch.MaterialSwitch
android:id="@+id/setup_androidacy_repo" android:id="@+id/setup_androidacy_repo"
android:layout_width="wrap_content" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_margin="4dp" android:layout_margin="4dp"
android:checked="false" android:checked="false"
android:key="pref_androidacy_repo_enabled" android:key="pref_androidacy_repo_enabled"
android:text="@string/setup_androidacy_repo" android:text="@string/setup_androidacy_repo"
android:textAppearance="@android:style/TextAppearance.Material.Subhead" />
<!-- Small summary for above switch -->
<com.google.android.material.textview.MaterialTextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="4dp"
android:drawableStart="@drawable/ic_baseline_info_24"
android:drawablePadding="8dp"
android:text="@string/setup_androidacy_repo_summary"
android:textAppearance="@android:style/TextAppearance.Material.Small" /> android:textAppearance="@android:style/TextAppearance.Material.Small" />
<com.google.android.material.materialswitch.MaterialSwitch <com.google.android.material.materialswitch.MaterialSwitch
android:id="@+id/setup_magisk_alt_repo" android:id="@+id/setup_magisk_alt_repo"
android:layout_width="wrap_content" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_margin="4dp" android:layout_margin="4dp"
android:text="@string/setup_magisk_alt_repo"
android:checked="false" android:checked="false"
android:key="pref_magisk_alt_repo_enabled" android:key="pref_magisk_alt_repo_enabled"
android:text="@string/setup_magisk_alt_repo"
android:textAppearance="@android:style/TextAppearance.Material.Subhead" />
<!-- Small summary for above switch -->
<com.google.android.material.textview.MaterialTextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="4dp"
android:drawableStart="@drawable/ic_baseline_info_24"
android:drawablePadding="8dp"
android:text="@string/setup_magisk_alt_repo_summary"
android:textAppearance="@android:style/TextAppearance.Material.Small" /> android:textAppearance="@android:style/TextAppearance.Material.Small" />
<com.google.android.material.textview.MaterialTextView <com.google.android.material.textview.MaterialTextView
@ -60,23 +101,42 @@
<com.google.android.material.materialswitch.MaterialSwitch <com.google.android.material.materialswitch.MaterialSwitch
android:id="@+id/setup_crash_reporting" android:id="@+id/setup_crash_reporting"
android:layout_width="wrap_content" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_margin="4dp" android:layout_margin="4dp"
android:checked="false" android:checked="false"
android:key="pref_crash_reporting_enabled" android:key="pref_crash_reporting_enabled"
android:text="@string/setup_crash_reporting" android:text="@string/setup_crash_reporting"
android:textAppearance="@android:style/TextAppearance.Material.Subhead" />
<com.google.android.material.textview.MaterialTextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="4dp"
android:drawableStart="@drawable/ic_baseline_info_24"
android:drawablePadding="8dp"
android:text="@string/setup_crash_reporting_summary"
android:textAppearance="@android:style/TextAppearance.Material.Small" /> android:textAppearance="@android:style/TextAppearance.Material.Small" />
<com.google.android.material.materialswitch.MaterialSwitch <com.google.android.material.materialswitch.MaterialSwitch
android:id="@+id/setup_background_update_check" android:id="@+id/setup_background_update_check"
android:layout_width="wrap_content" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_margin="4dp" android:layout_margin="4dp"
android:checked="false" android:checked="false"
android:key="pref_background_update_check" android:key="pref_background_update_check"
android:text="@string/setup_background_update_check" android:text="@string/setup_background_update_check"
android:textAppearance="@android:style/TextAppearance.Material.Small" /> android:textAppearance="@android:style/TextAppearance.Material.Subhead" />
<com.google.android.material.textview.MaterialTextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="4dp"
android:drawableStart="@drawable/ic_baseline_info_24"
android:drawablePadding="8dp"
android:text="@string/setup_background_update_check_summary"
android:textAppearance="@android:style/TextAppearance.Material.Small"
app:icon="@drawable/ic_baseline_info_24" />
<!-- Placeholder for future settings --> <!-- Placeholder for future settings -->
<!--<com.google.android.material.materialswitch.MaterialSwitch <!--<com.google.android.material.materialswitch.MaterialSwitch
@ -88,6 +148,29 @@
android:key="pref_app_analytics" android:key="pref_app_analytics"
android:textAppearance="@android:style/TextAppearance.Material.Small" android:textAppearance="@android:style/TextAppearance.Material.Small"
android:text="@string/setup_app_analytics" />--> android:text="@string/setup_app_analytics" />-->
<!-- setup_cancel and setup_continue side by side buttons, stuck to bottom right, with a small space in between -->
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="bottom|end"
android:layout_margin="4dp"
android:orientation="horizontal">
<com.google.android.material.button.MaterialButton
android:id="@+id/setup_cancel"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginEnd="2dp"
android:layout_weight="1"
android:text="@string/cancel" />
<com.google.android.material.button.MaterialButton
android:id="@+id/setup_continue"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="@string/finish" />
</LinearLayout>
</LinearLayout> </LinearLayout>
</ScrollView> </ScrollView>

View File

@ -224,17 +224,29 @@
<string name="setup_title">First time setup</string> <string name="setup_title">First time setup</string>
<string name="setup_message">Welcome! This app will help you install and manage Magisk modules. To get started, please select the options below. These and more can be configured from settings later.</string> <string name="setup_message">Welcome! This app will help you install and manage Magisk modules. To get started, please select the options below. These and more can be configured from settings later.</string>
<string name="setup_button">Finish setup</string> <string name="setup_button">Finish setup</string>
<string name="setup_background_update_check">Allow us to check for updates in the background.\nThis feature may use more battery.</string> <string name="setup_background_update_check">Background update check</string>
<string name="setup_androidacy_repo">Enable the Androidacy repo\nFeatures user reviews, automatic virus scans, fast updates, a wide selection, and is backed by Androidacy.</string> <string name="setup_background_update_check_summary">Allow us to check for module and app updates in the background. This feature may use more battery, and may use more data.</string>
<string name="setup_androidacy_repo">Enable the Androidacy repo</string>
<string name="setup_androidacy_repo_summary">Features user reviews, automatic virus scans, fast updates, a wide selection, and is backed by Androidacy.</string>
<!-- Maybe once alt repo fixes their shit and stops allowing crappy modules or outright <!-- Maybe once alt repo fixes their shit and stops allowing crappy modules or outright
kanged modules, we'll reword this. --> kanged modules, we'll reword this. -->
<string name="setup_magisk_alt_repo">Enable the Magisk Alt Repo\nMuch more lax than the original. Has a lot of modules at the cost of some safety.</string> <string name="setup_magisk_alt_repo">Enable the Magisk Alt Repo</string>
<string name="setup_crash_reporting">Enable Sentry crash reporting and performance monitoring.\nAll reports are striclty anonymous and confidential.</string> <string name="setup_magisk_alt_repo_summary">Much more lax than the original. Has a lot of modules at the cost of some safety.</string>
<string name="setup_crash_reporting">Enable Sentry</string>
<string name="setup_crash_reporting_summary">Crash reporting and performance monitoring. All reports are striclty anonymous and confidential.</string>
<string name="setup_custom_repos">You can add custom repos later in settings.</string> <string name="setup_custom_repos">You can add custom repos later in settings.</string>
<string name="repos">Repos</string> <string name="repos">Repos</string>
<string name="misc">Miscellaneous</string> <string name="misc">Miscellaneous</string>
<string name="setup_button_skip">Skip</string> <string name="setup_button_skip">Skip</string>
<string name="low_performance_device_dialogue_title">Enabling blur on lower-end device</string> <string name="low_performance_device_dialogue_title">Enabling blur on lower-end device</string>
<string name="low_performance_device_dialogue_message">You are trying to enable blur on a device that may not perform well with it.\nYou may enable it, but this may lead to a poor user experience and we recommend you don\'t.</string> <string name="low_performance_device_dialogue_message">You are trying to enable blur on a device that may not perform well with it.\nYou may enable it, but this may lead to a poor user experience and we recommend you don\'t.</string>
<string name="alt_repo_info">This repo has less restrictions and reviews, which may lead to lower quality modules. Pretty barebones but has a lot of modules.</string><string name="install_terminal_reboot_now_message">You are about to reboot your device. If you\'ve saved your work, hit ok to continue. Otherwise, hit cancel.</string><string name="install_terminal_config_missing">Package %s is missing for module config, so we cannot launch it.</string><string name="clear_app_data">Clear app data</string><string name="clear_data_dialogue_title">Clear app data?</string><string name="clear_data_dialogue_message">You\'re about to clear the app data. Please confirm this action.</string><string name="debug_build">This is a debug build. Expect some bugs and worse performance.</string> <string name="alt_repo_info">This repo has less restrictions and reviews, which may lead to lower quality modules. Pretty barebones but has a lot of modules.</string>
<string name="install_terminal_reboot_now_message">You are about to reboot your device. If you\'ve saved your work, hit OK to continue. Otherwise, hit cancel.</string>
<string name="install_terminal_config_missing">Package %s is missing for module config, so we cannot launch it.</string>
<string name="clear_app_data">Clear app data</string><string name="clear_data_dialogue_title">Clear app data?</string>
<string name="clear_data_dialogue_message">You\'re about to clear the app data. Please confirm this action.</string>
<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>
</resources> </resources>

View File

@ -2,7 +2,7 @@
<PreferenceScreen xmlns:app="http://schemas.android.com/apk/res-auto"> <PreferenceScreen xmlns:app="http://schemas.android.com/apk/res-auto">
<PreferenceCategory <PreferenceCategory
app:key="pref_androidacy_repo" app:key="pref_androidacy_repo"
app:title="@string/loading"> app:title="@string/androidacy_repo_name">
<SwitchPreferenceCompat <SwitchPreferenceCompat
app:icon="@drawable/ic_baseline_extension_24" app:icon="@drawable/ic_baseline_extension_24"
app:key="pref_androidacy_repo_enabled" app:key="pref_androidacy_repo_enabled"
@ -59,7 +59,7 @@
</PreferenceCategory> </PreferenceCategory>
<PreferenceCategory <PreferenceCategory
app:key="pref_magisk_alt_repo" app:key="pref_magisk_alt_repo"
app:title="@string/loading"> app:title="@string/magisk_alt_repo_name">
<SwitchPreferenceCompat <SwitchPreferenceCompat
app:icon="@drawable/ic_baseline_extension_24" app:icon="@drawable/ic_baseline_extension_24"
app:key="pref_magisk_alt_repo_enabled" app:key="pref_magisk_alt_repo_enabled"