diff --git a/app/src/main/java/com/fox2code/mmm/MainActivity.java b/app/src/main/java/com/fox2code/mmm/MainActivity.java index 0c7e31c..71bec1c 100644 --- a/app/src/main/java/com/fox2code/mmm/MainActivity.java +++ b/app/src/main/java/com/fox2code/mmm/MainActivity.java @@ -124,7 +124,7 @@ public class MainActivity extends FoxActivity implements SwipeRefreshLayout.OnRe // Show a toast to warn the user Toast.makeText(this, R.string.not_official_build, Toast.LENGTH_LONG).show(); } - if (!MainApplication.getSharedPreferences().getBoolean("first_time_user", true)) { + if (!MainApplication.getSharedPreferences().getBoolean("first_time_setup_done", true)) { this.setActionBarExtraMenuButton(R.drawable.ic_baseline_settings_24, v -> { IntentHelper.startActivity(this, SettingsActivity.class); return true; @@ -648,7 +648,7 @@ public class MainActivity extends FoxActivity implements SwipeRefreshLayout.OnRe Timber.i("Checking if we need to run setup"); // Check if this is the first launch SharedPreferences prefs = MainApplication.getSharedPreferences(); - boolean firstLaunch = prefs.getBoolean("first_time_user", true); + boolean firstLaunch = prefs.getBoolean("first_time_setup_done", true); if (BuildConfig.DEBUG) Timber.i("First launch: %s", firstLaunch); if (firstLaunch) { diff --git a/app/src/main/java/com/fox2code/mmm/SetupActivity.java b/app/src/main/java/com/fox2code/mmm/SetupActivity.java index 295a647..7f8e6cf 100644 --- a/app/src/main/java/com/fox2code/mmm/SetupActivity.java +++ b/app/src/main/java/com/fox2code/mmm/SetupActivity.java @@ -178,7 +178,7 @@ public class SetupActivity extends FoxActivity implements LanguageActivity { // Set first launch to false // get instance of editor SharedPreferences.Editor editor = prefs.edit(); - editor.putBoolean("first_time_user", false); + editor.putBoolean("first_time_setup_done", 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 @@ -232,7 +232,7 @@ public class SetupActivity extends FoxActivity implements LanguageActivity { 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(); + prefs.edit().putBoolean("first_time_setup_done", false).commit(); MainActivity.doSetupRestarting = true; Intent intent = new Intent(this, MainActivity.class); startActivity(intent); @@ -339,7 +339,8 @@ public class SetupActivity extends FoxActivity implements LanguageActivity { }); try { String cookieFileName = "cookies"; - String initialCookie = "is_foxmmm=true; expires=Fri, 31 Dec 9999 23:59:59 GMT; path=/; domain=\" + chain.request().url().host() + \"; SameSite=None; Secure;|foxmmm_version=" + BuildConfig.VERSION_CODE + "; expires=Fri, 31 Dec 9999 23:59:59 GMT; path=/; domain=\" + chain.request().url().host() + \"; SameSite=None; Secure;"; + // initial set of cookies, only really used to create the keypair and encrypted file + String initialCookie = "is_foxmmm=true; expires=Fri, 31 Dec 9999 23:59:59 GMT; path=/; domain=production-api.androidacy.com; SameSite=None; Secure;|foxmmm_version=" + BuildConfig.VERSION_CODE + "; expires=Fri, 31 Dec 9999 23:59:59 GMT; path=/; domain=production-api.androidacy.com; SameSite=None; Secure;"; Context context = getApplicationContext(); MasterKey mainKeyAlias; mainKeyAlias = new MasterKey.Builder(context).setKeyScheme(MasterKey.KeyScheme.AES256_GCM).build(); diff --git a/app/src/main/java/com/fox2code/mmm/background/BackgroundUpdateChecker.java b/app/src/main/java/com/fox2code/mmm/background/BackgroundUpdateChecker.java index 12dcf0f..b0c6cd1 100644 --- a/app/src/main/java/com/fox2code/mmm/background/BackgroundUpdateChecker.java +++ b/app/src/main/java/com/fox2code/mmm/background/BackgroundUpdateChecker.java @@ -81,7 +81,7 @@ public class BackgroundUpdateChecker extends Worker { public static void onMainActivityCreate(Context context) { // Refuse to run if first_launch pref is not false - if (MainApplication.getSharedPreferences().getBoolean("first_time_user", true)) + if (MainApplication.getSharedPreferences().getBoolean("first_time_setup_done", true)) return; NotificationManagerCompat notificationManagerCompat = NotificationManagerCompat.from(context); notificationManagerCompat.createNotificationChannel(new NotificationChannelCompat.Builder(NOTIFICATION_CHANNEL_ID, NotificationManagerCompat.IMPORTANCE_HIGH).setShowBadge(true).setName(context.getString(R.string.notification_update_pref)).build()); 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 518ce03..e5055bc 100644 --- a/app/src/main/java/com/fox2code/mmm/settings/SettingsActivity.java +++ b/app/src/main/java/com/fox2code/mmm/settings/SettingsActivity.java @@ -426,15 +426,30 @@ public class SettingsActivity extends FoxActivity implements LanguageActivity { }); backgroundUpdateCheck.setSummary(R.string.background_update_check_permission_required); } + + EditTextPreference updateCheckExcludes = findPreference("pref_background_update_check_excludes"); backgroundUpdateCheck.setOnPreferenceChangeListener((preference, newValue) -> { boolean enabled = Boolean.parseBoolean(String.valueOf(newValue)); debugNotification.setEnabled(enabled); + updateCheckExcludes.setEnabled(enabled); if (!enabled) { BackgroundUpdateChecker.onMainActivityResume(this.requireContext()); } return true; }); - + // updateCheckExcludes is an EditTextPreference. on change, validate it contains only alphanumerical and , - _ characters + updateCheckExcludes.setOnPreferenceChangeListener((preference, newValue) -> { + String value = String.valueOf(newValue); + // strip whitespace + value = value.replaceAll("\\s", ""); + if (value.matches("^[a-zA-Z0-9,\\-_]*$")) { + return true; + } else { + new MaterialAlertDialogBuilder(this.requireContext()).setTitle(R.string.invalid_excludes).setMessage(R.string.invalid_characters_message).setPositiveButton(R.string.ok, (dialog, which) -> { + }).show(); + return false; + } + }); final LibsBuilder libsBuilder = new LibsBuilder().withShowLoadingProgress(false).withLicenseShown(true).withAboutMinimalDesign(false); ClipboardManager clipboard = (ClipboardManager) requireContext().getSystemService(Context.CLIPBOARD_SERVICE); LongClickablePreference linkClickable = findPreference("pref_update"); @@ -662,10 +677,9 @@ public class SettingsActivity extends FoxActivity implements LanguageActivity { } public static class RepoFragment extends PreferenceFragmentCompat { - private static final int CUSTOM_REPO_ENTRIES = 5; /** - * proudly I stole it + * says proudly: I stole it *

* namely, from neo wellbeing */ @@ -764,7 +778,7 @@ public class SettingsActivity extends FoxActivity implements LanguageActivity { androidacyRepoEnabled.setOnPreferenceClickListener(preference -> { new MaterialAlertDialogBuilder(this.requireContext()).setTitle(R.string.androidacy_repo_disabled).setCancelable(false).setMessage(R.string.androidacy_repo_disabled_message).setPositiveButton(R.string.download_full_app, (dialog, which) -> { // User clicked OK button. Open GitHub releases page - Intent browserIntent = new Intent(Intent.ACTION_VIEW, Uri.parse("https://github.com/Fox2Code/FoxMagiskModuleManager/releases")); + Intent browserIntent = new Intent(Intent.ACTION_VIEW, Uri.parse("https://www.androidacy.com/downloads/?view=FoxMMM&utm_source=FoxMMM&utm_medium=app&utm_campaign=FoxMMM")); startActivity(browserIntent); }).show(); // Revert the switch to off @@ -793,9 +807,6 @@ public class SettingsActivity extends FoxActivity implements LanguageActivity { if (reposListRealmResults.isEmpty()) { throw new IllegalStateException("Realm db is empty"); } - for (ReposList reposList2 : reposListRealmResults) { - Timber.d("Realm db entry: %s %s %s", reposList2.getId(), reposList2.getName(), reposList2.isEnabled()); - } throw new IllegalStateException("Androidacy repo not found in realm db"); } boolean androidacyRepoEnabledPref = repoRealmResults.isEnabled(); @@ -843,6 +854,7 @@ public class SettingsActivity extends FoxActivity implements LanguageActivity { Snackbar.make(requireView(), R.string.api_key_mismatch, Snackbar.LENGTH_LONG).show(); // Restore the original api key prefAndroidacyRepoApiKey.setText(originalApiKeyRef[0]); + prefAndroidacyRepoApiKey.performClick(); return false; } // Make sure originalApiKeyRef is not null @@ -1006,12 +1018,8 @@ public class SettingsActivity extends FoxActivity implements LanguageActivity { Exception e) { Timber.e(e); // show new dialog - new Handler(Looper.getMainLooper()).post(() -> new MaterialAlertDialogBuilder(context) - .setTitle(R.string.error_adding) - .setMessage(e.getMessage()) - .setPositiveButton(android.R.string.ok, (dialog1, which1) -> { - }) - .show()); + new Handler(Looper.getMainLooper()).post(() -> new MaterialAlertDialogBuilder(context).setTitle(R.string.error_adding).setMessage(e.getMessage()).setPositiveButton(android.R.string.ok, (dialog1, which1) -> { + }).show()); } } }.start(); diff --git a/app/src/main/java/com/fox2code/mmm/utils/io/AddCookiesInterceptor.java b/app/src/main/java/com/fox2code/mmm/utils/io/AddCookiesInterceptor.java index 0dfc1b2..fa224f7 100644 --- a/app/src/main/java/com/fox2code/mmm/utils/io/AddCookiesInterceptor.java +++ b/app/src/main/java/com/fox2code/mmm/utils/io/AddCookiesInterceptor.java @@ -11,6 +11,7 @@ import com.fox2code.mmm.MainApplication; import java.io.File; import java.io.IOException; import java.io.InputStream; +import java.util.regex.Pattern; import okhttp3.Interceptor; import okhttp3.Request; @@ -58,7 +59,18 @@ public class AddCookiesInterceptor implements Interceptor { } for (String cookie : cookies) { - builder.addHeader("Cookie", cookie); + // ensure the cookie applies to the current domain + if (cookie.contains("domain=")) { + // match from the start of the string to the first semicolon + Pattern pattern = Pattern.compile("domain=([^;]+)"); + String domain = pattern.matcher(cookie).group(1); + if (domain != null && !chain.request().url().host().contains(domain)) { + //noinspection UnnecessaryContinue + continue; + } else { + builder.addHeader("Cookie", cookie); + } + } } return chain.proceed(builder.build()); diff --git a/app/src/main/java/com/fox2code/mmm/utils/sentry/SentryMain.java b/app/src/main/java/com/fox2code/mmm/utils/sentry/SentryMain.java index 1d1d7c3..0aeed73 100644 --- a/app/src/main/java/com/fox2code/mmm/utils/sentry/SentryMain.java +++ b/app/src/main/java/com/fox2code/mmm/utils/sentry/SentryMain.java @@ -19,7 +19,6 @@ import io.sentry.android.timber.SentryTimberIntegration; public class SentryMain { public static final boolean IS_SENTRY_INSTALLED = true; - private static final String TAG = "SentryMain"; private static boolean sentryEnabled = false; /** @@ -30,7 +29,7 @@ public class SentryMain { public static void initialize(final MainApplication mainApplication) { // If first_launch pref is not false, refuse to initialize Sentry SharedPreferences sharedPreferences = MainApplication.getSharedPreferences(); - if (sharedPreferences.getBoolean("first_time_user", true)) { + if (sharedPreferences.getBoolean("first_time_setup_done", true)) { return; } Thread.setDefaultUncaughtExceptionHandler((thread, throwable) -> { @@ -110,6 +109,7 @@ public class SentryMain { } } + @SuppressWarnings("unused") public static boolean isSentryEnabled() { return sentryEnabled; } diff --git a/app/src/main/res/drawable/baseline_notification_important_24.xml b/app/src/main/res/drawable/baseline_notification_important_24.xml new file mode 100644 index 0000000..041386e --- /dev/null +++ b/app/src/main/res/drawable/baseline_notification_important_24.xml @@ -0,0 +1,5 @@ + + + diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 2c453d4..1ca8d85 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -15,7 +15,7 @@ Could not open system WebView SettingsActivity A new version of the app is available - Upgrade + Update app No description found. Download module Install module @@ -316,5 +316,14 @@ Reset the app You\'re pretty awesome! Looks like you\'ve already upgraded your subscription and are supporting Androidacy. Premium active - If you keep seeing this screen, resetting the app might help. This will clear app data but will not effect installed modules.This will completely remove all app data and close the app. Modules will not be uninstalled.ResetThis is going to completely wipe app data, but will not effect modules.Failed to add custom repoAPI key is in an invalid format + If you keep seeing this screen, resetting the app might help. This will clear app data but will not effect installed modules. + This will completely remove all app data and close the app. Modules will not be uninstalled. + Reset + This is going to completely wipe app data, but will not effect modules. + Failed to add custom repo + API key is in an invalid format + Comma separated list of modules to exclude from update checks + Exclude modules + UpdatesInvalid input + The list of modules you input is invalid. Please only input valid module id\'s separated by commas diff --git a/app/src/main/res/xml/root_preferences.xml b/app/src/main/res/xml/root_preferences.xml index 5d16dd9..7544f91 100644 --- a/app/src/main/res/xml/root_preferences.xml +++ b/app/src/main/res/xml/root_preferences.xml @@ -31,6 +31,9 @@ app:singleLineTitle="false" app:summary="@string/use_magisk_install_command_desc" app:title="@string/use_magisk_install_command_pref" /> + + + + + + + + + @@ -149,11 +169,6 @@ -