Merge pull request #1 from Fox2CodeCoProcessor/master

Fix and improve previous commit & Update libraries
pull/192/head
Androidacy Service Account 2 years ago committed by GitHub
commit e181fd1c93
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -12,7 +12,7 @@ android {
minSdk 21
targetSdk 33
versionCode 54
versionName "0.7.0-dev"
versionName "0.6.2"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}
@ -35,6 +35,7 @@ android {
"default" {
dimension "type"
buildConfigField "boolean", "ENABLE_AUTO_UPDATER", "true"
buildConfigField "boolean", "DEFAULT_ENABLE_CRASH_REPORTING", "true"
buildConfigField(
"java.util.List<String>",
"ENABLED_REPOS",
@ -51,6 +52,9 @@ android {
// with our keys, so the APK wouldn't install anyways).
buildConfigField "boolean", "ENABLE_AUTO_UPDATER", "false"
// Respect privacy paranoiac nature of F-Droid builds
buildConfigField "boolean", "DEFAULT_ENABLE_CRASH_REPORTING", "false"
// Repo with ads or tracking feature are disabled by default for the
// F-Droid flavor.
buildConfigField(
@ -88,9 +92,10 @@ dependencies {
implementation 'androidx.constraintlayout:constraintlayout:2.1.4'
implementation 'androidx.recyclerview:recyclerview:1.2.1'
implementation 'androidx.swiperefreshlayout:swiperefreshlayout:1.1.0'
implementation 'androidx.webkit:webkit:1.4.0'
implementation 'androidx.webkit:webkit:1.5.0'
implementation 'com.google.android.material:material:1.6.1'
implementation 'com.mikepenz:aboutlibraries:10.4.1-a01'
// Update root build.gradle instead.
implementation "com.mikepenz:aboutlibraries:${latestAboutLibsRelease}"
implementation "dev.rikka.rikkax.layoutinflater:layoutinflater:1.2.0"
implementation "dev.rikka.rikkax.insets:insets:1.3.0"
implementation 'com.github.Dimezis:BlurView:version-1.6.6'

@ -74,19 +74,6 @@ public class MainActivity extends FoxActivity implements SwipeRefreshLayout.OnRe
@Override
protected void onCreate(Bundle savedInstanceState) {
SentryAndroid.init(this, options -> {
// Add a callback that will be used before the event is sent to Sentry.
// With this callback, you can modify the event or, when returning null, also discard the event.
options.setBeforeSend((event, hint) -> {
// Check saved preferences to see if the user has opted out of crash reporting.
// If the user has opted out, return null.
if (SettingsActivity.getCrashReporting(this)) {
return event;
} else {
return null;
}
});
});
this.initMode = true;
BackgroundUpdateChecker.onMainActivityCreate(this);
super.onCreate(savedInstanceState);

@ -27,6 +27,8 @@ import com.fox2code.mmm.utils.Http;
import com.fox2code.rosettax.LanguageSwitcher;
import com.topjohnwu.superuser.Shell;
import java.io.IOException;
import java.io.Writer;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.Locale;
@ -42,6 +44,9 @@ import io.noties.markwon.syntax.Prism4jThemeDefault;
import io.noties.markwon.syntax.SyntaxHighlightPlugin;
import io.noties.prism4j.Prism4j;
import io.noties.prism4j.annotations.PrismBundle;
import io.sentry.JsonObjectWriter;
import io.sentry.NoOpLogger;
import io.sentry.android.core.SentryAndroid;
@PrismBundle(
includeAll = true,
@ -49,6 +54,7 @@ import io.noties.prism4j.annotations.PrismBundle;
)
public class MainApplication extends FoxApplication
implements androidx.work.Configuration.Provider {
private static final String TAG = "MainApplication";
private static final String timeFormatString = "dd MMM yyyy"; // Example: 13 july 2001
private static Locale timeFormatLocale =
Resources.getSystem().getConfiguration().locale;
@ -168,6 +174,11 @@ public class MainApplication extends FoxApplication
getSharedPreferences().edit().putBoolean("has_root_access", bool).apply();
}
public static boolean isCrashReportingEnabled() {
return getSharedPreferences().getBoolean(
"crash_reporting", BuildConfig.DEFAULT_ENABLE_CRASH_REPORTING);
}
public static SharedPreferences getBootSharedPreferences() {
return bootSharedPreferences;
}
@ -341,6 +352,57 @@ public class MainApplication extends FoxApplication
Log.d("MainApplication", "Emoji compat loaded!");
}, "Emoji compat init.").start();
}
SentryAndroid.init(this, options -> {
// Note: Sentry library only take a screenshot of Fox Magisk Module Manager.
// The screen shot doesn't and cannot contain other applications (if in multi windows)
// status bar and notifications (even if notification shade is pulled down)
// In the possibility you find this library sending anything listed above,
// it's a serious bug and a security issue you should report to Google
// Google bug bounties on Android are huge, so you can also get rich by doing that.
options.setAttachScreenshot(true);
// Add a callback that will be used before the event is sent to Sentry.
// With this callback, you can modify the event or, when returning null, also discard the event.
options.setBeforeSend((event, hint) -> {
if (BuildConfig.DEBUG) { // Debug sentry events for debug.
StringBuilder stringBuilder = new StringBuilder("Sentry report debug: ");
try {
event.serialize(new JsonObjectWriter(new Writer() {
@Override
public void write(char[] cbuf) {
stringBuilder.append(cbuf);
}
@Override
public void write(char[] chars, int i, int i1) {
stringBuilder.append(chars, i, i1);
}
@Override
public void write(String str, int off, int len) {
stringBuilder.append(str, off, len);
}
@Override
public void flush() {}
@Override
public void close() {}
}, 4), NoOpLogger.getInstance());
} catch (IOException ignored) {}
Log.i(TAG, stringBuilder.toString());
}
// Check saved preferences to see if the user has opted out of crash reporting.
// If the user has opted out, return null.
if (isCrashReportingEnabled()) {
Log.i(TAG, "Relayed sentry report according to user preference");
return event;
} else {
Log.i(TAG, "Blocked sentry report according to user preference");
return null;
}
});
});
}
@Override

@ -62,11 +62,6 @@ public class SettingsActivity extends FoxActivity implements LanguageActivity {
private static final String TAG = "SettingsActivity";
private static int devModeStep = 0;
public static boolean getCrashReporting(MainActivity mainActivity) {
return mainActivity.getPreferences(Context.MODE_PRIVATE)
.getBoolean("crash_reporting", true);
}
@Override
protected void onCreate(Bundle savedInstanceState) {
devModeStep = 0;
@ -132,8 +127,7 @@ public class SettingsActivity extends FoxActivity implements LanguageActivity {
});
// Crash reporting
TwoStatePreference crashReportingPreference = findPreference("pref_crash_reporting");
crashReportingPreference.setChecked(getCrashReporting(
(MainActivity) requireActivity()));
crashReportingPreference.setChecked(MainApplication.isCrashReportingEnabled());
crashReportingPreference.setOnPreferenceChangeListener((preference, newValue) -> {
devModeStep = 0;
getCrashReportingEditor(requireActivity()).putBoolean("crash_reporting",

@ -8,7 +8,7 @@ buildscript {
project.ext.latestAboutLibsRelease = "10.4.1-a01"
dependencies {
classpath 'com.android.tools.build:gradle:7.2.2'
classpath "com.mikepenz.aboutlibraries.plugin:aboutlibraries-plugin:10.4.1-a01"
classpath "com.mikepenz.aboutlibraries.plugin:aboutlibraries-plugin:${latestAboutLibsRelease}"
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files

Loading…
Cancel
Save