begin work on excluding modules from update checks

Signed-off-by: androidacy-user <opensource@androidacy.com>
pull/284/head
androidacy-user 1 year ago
parent a75e68a27c
commit d9ebb2a2c4

@ -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) {

@ -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();

@ -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());

@ -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;
/**
* <i>proudly</i> I stole it
* <i>says proudly</i>: I stole it
* <p>
* namely, from <a href="https://github.com/NeoApplications/Neo-Wellbeing/blob/9fca4136263780c022f9ec6433c0b43d159166db/app/src/main/java/org/eu/droid_ng/wellbeing/prefs/SettingsActivity.java#L101">neo wellbeing</a>
*/
@ -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();

@ -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());

@ -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;
}

@ -0,0 +1,5 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android" android:width="24dp"
android:height="24dp" android:autoMirrored="true"
android:tint="?attr/colorControlNormal" android:viewportWidth="24" android:viewportHeight="24">
<path android:fillColor="@android:color/white" android:pathData="M18,16v-5c0,-3.1 -1.6,-5.6 -4.5,-6.3L13.5,4c0,-0.8 -0.7,-1.5 -1.5,-1.5s-1.5,0.7 -1.5,1.5v0.7C7.6,5.4 6,7.9 6,11v5l-2,2v1h16v-1l-2,-2zM13,16h-2v-2h2v2zM13,12h-2L11,8h2v4zM12,22c1.1,0 2,-0.9 2,-2h-4c0,1.1 0.9,2 2,2z"/>
</vector>

@ -15,7 +15,7 @@
<string name="no_web_view">Could not open system WebView</string>
<string name="title_activity_settings">SettingsActivity</string>
<string name="app_update_available">A new version of the app is available</string>
<string name="app_update">Upgrade</string>
<string name="app_update">Update app</string>
<string name="no_desc_found">No description found.</string>
<string name="download_module">Download module</string>
<string name="install_module">Install module</string>
@ -316,5 +316,14 @@
<string name="reset_app">Reset the app</string>
<string name="upgraded_summary">You\'re pretty awesome! Looks like you\'ve already upgraded your subscription and are supporting Androidacy.</string>
<string name="upgraded">Premium active</string>
<string name="reset_warning">If you keep seeing this screen, resetting the app might help. This will clear app data but will not effect installed modules.</string><string name="reset_app_message">This will completely remove all app data and close the app. Modules will not be uninstalled.</string><string name="reset">Reset</string><string name="reset_app_confirmation">This is going to completely wipe app data, but will not effect modules.</string><string name="error_adding">Failed to add custom repo</string><string name="api_key_mismatch">API key is in an invalid format</string>
<string name="reset_warning">If you keep seeing this screen, resetting the app might help. This will clear app data but will not effect installed modules.</string>
<string name="reset_app_message">This will completely remove all app data and close the app. Modules will not be uninstalled.</string>
<string name="reset">Reset</string>
<string name="reset_app_confirmation">This is going to completely wipe app data, but will not effect modules.</string>
<string name="error_adding">Failed to add custom repo</string>
<string name="api_key_mismatch">API key is in an invalid format</string>
<string name="notification_update_ignore_desc">Comma separated list of modules to exclude from update checks</string>
<string name="notification_update_ignore_pref">Exclude modules</string>
<string name="pref_category_updates">Updates</string><string name="invalid_excludes">Invalid input</string>
<string name="invalid_characters_message">The list of modules you input is invalid. Please only input valid module id\'s separated by commas</string>
</resources>

@ -31,6 +31,9 @@
app:singleLineTitle="false"
app:summary="@string/use_magisk_install_command_desc"
app:title="@string/use_magisk_install_command_pref" />
</PreferenceCategory>
<PreferenceCategory app:title="@string/pref_category_updates">
<SwitchPreferenceCompat
app:defaultValue="true"
@ -40,10 +43,27 @@
app:summary="@string/notification_update_desc"
app:title="@string/notification_update_pref" />
<!-- Ignore updates for preference. Used to ignore updates for specific modules -->
<EditTextPreference
app:defaultValue=""
app:icon="@drawable/ic_baseline_notifications_24"
app:key="pref_background_update_check_excludes"
app:singleLineTitle="false"
app:summary="@string/notification_update_ignore_desc"
app:title="@string/notification_update_ignore_pref" />
<Preference
app:key="pref_background_update_check_debug"
app:singleLineTitle="false"
app:icon="@drawable/baseline_notification_important_24"
app:title="@string/notification_update_debug_pref" />
<com.fox2code.mmm.settings.LongClickablePreference
app:icon="@drawable/ic_baseline_system_update_24"
app:key="pref_update"
app:singleLineTitle="false"
app:title="@string/app_update" />
</PreferenceCategory>
<PreferenceCategory app:title="@string/pref_category_appearance">
@ -149,11 +169,6 @@
</PreferenceCategory>
<PreferenceCategory app:title="@string/pref_category_info">
<com.fox2code.mmm.settings.LongClickablePreference
app:icon="@drawable/ic_baseline_system_update_24"
app:key="pref_update"
app:singleLineTitle="false"
app:title="@string/app_update" />
<!-- Save logs -->
<Preference
app:icon="@drawable/baseline_save_24"

Loading…
Cancel
Save