From 816d94aee4af2fd1fd3a6d9cbabb39651eb2ab25 Mon Sep 17 00:00:00 2001 From: androidacy-user Date: Sat, 10 Dec 2022 15:39:43 -0500 Subject: [PATCH] Add crash dialog Signed-off-by: androidacy-user --- app/src/main/res/values/strings.xml | 6 +++ .../com/fox2code/mmm/sentry/SentryMain.java | 51 ++++++++++++++++--- docs/add-repo.md | 47 +++++++++++++++++ 3 files changed, 96 insertions(+), 8 deletions(-) create mode 100644 docs/add-repo.md diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 95c9762..06ac217 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -204,4 +204,10 @@ You are setting a transparent theme Transparent themes may have some inconsistencies and may not work on all ROMs. In additon, monet and blur will be disabled. You can change back at any time. Custom repos are always on until you remove them. + We encountered an error, please help us improve the app by adding some information about the error. + Sentry report + Name + Email + Tell us what happened + Submit diff --git a/app/src/sentry/java/com/fox2code/mmm/sentry/SentryMain.java b/app/src/sentry/java/com/fox2code/mmm/sentry/SentryMain.java index d5d0cb9..5d91070 100644 --- a/app/src/sentry/java/com/fox2code/mmm/sentry/SentryMain.java +++ b/app/src/sentry/java/com/fox2code/mmm/sentry/SentryMain.java @@ -3,12 +3,18 @@ package com.fox2code.mmm.sentry; import static io.sentry.TypeCheckHint.SENTRY_TYPE_CHECK_HINT; import android.annotation.SuppressLint; +import android.app.Activity; import android.net.Uri; +import android.os.Handler; +import android.os.Looper; import android.util.Log; +import android.widget.EditText; import com.fox2code.mmm.BuildConfig; import com.fox2code.mmm.MainApplication; +import com.fox2code.mmm.R; import com.fox2code.mmm.androidacy.AndroidacyUtil; +import com.google.android.material.dialog.MaterialAlertDialogBuilder; import java.io.IOException; import java.io.Writer; @@ -94,16 +100,46 @@ public class SentryMain { SentryId sentryId = event.getEventId(); if (sentryId != null) { UserFeedback userFeedback = new UserFeedback(sentryId); - userFeedback.setName("Anonymous"); - userFeedback.setEmail("test@test.com"); - userFeedback.setComments("No comments"); - Sentry.captureUserFeedback(userFeedback); + // Get the current activity + Activity context = MainApplication.getINSTANCE().getLastCompatActivity(); + // Create a material dialog + new Handler(Looper.getMainLooper()).post(() -> { + if (context != null) { + // Show fields for name, email, and comment, and two buttons: "Submit" and "Cancel" + MaterialAlertDialogBuilder builder = new MaterialAlertDialogBuilder(context); + builder.setTitle(R.string.sentry_dialogue_title); + builder.setMessage(R.string.sentry_dialogue_message); + // Add the text fields, set the text to the previously entered values + EditText name = new EditText(context); + name.setHint(R.string.name); + builder.setView(name); + EditText email = new EditText(context); + email.setHint(R.string.email); + builder.setView(email); + EditText comment = new EditText(context); + comment.setHint(R.string.additional_info); + builder.setView(comment); + // Add the buttons + builder.setPositiveButton(R.string.submit, (dialog, id) -> { + // User clicked "Submit" + userFeedback.setName(name.getText().toString()); + userFeedback.setEmail(email.getText().toString()); + userFeedback.setComments(comment.getText().toString()); + // Send the feedback + Sentry.captureUserFeedback(userFeedback); + }); + builder.setNegativeButton(R.string.cancel, (dialog, id) -> { + // User cancelled the dialog + }); + // Create and show the AlertDialog + builder.create().show(); + } + }); } return event; } else { // We need to do this to avoid crash delay on crash when the event is dropped - DiskFlushNotification diskFlushNotification = hint.getAs( - SENTRY_TYPE_CHECK_HINT, DiskFlushNotification.class); + DiskFlushNotification diskFlushNotification = hint.getAs(SENTRY_TYPE_CHECK_HINT, DiskFlushNotification.class); if (diskFlushNotification != null) diskFlushNotification.markFlushed(); return null; } @@ -112,8 +148,7 @@ public class SentryMain { options.setBeforeBreadcrumb((breadcrumb, hint) -> { String url = (String) breadcrumb.getData("url"); if (url == null || url.isEmpty()) return breadcrumb; - if ("cloudflare-dns.com".equals(Uri.parse(url).getHost())) - return null; + if ("cloudflare-dns.com".equals(Uri.parse(url).getHost())) return null; if (AndroidacyUtil.isAndroidacyLink(url)) { breadcrumb.setData("url", AndroidacyUtil.hideToken(url)); } diff --git a/docs/add-repo.md b/docs/add-repo.md new file mode 100644 index 0000000..9d5e316 --- /dev/null +++ b/docs/add-repo.md @@ -0,0 +1,47 @@ +## Adding custom repositories + +You have two options: + +### Option 1: Add your repo to the app for yourself: + +1. You need the modules.json link of your repo, if you don't have one please contact the repo owner. +2. Open the app and go to the settings. +3. Go to repos at the top. +4. Scroll to the bottom and click on the "Add repo" button. +5. Paste the modules.json link and click on the "Add" button. +6. You can now download modules from your repo. + +### Option 2: Add your repo to the app for everyone: + +To add you own repo to Fox's mmm it need to follow theses conditions: + +- The module repo or at least one of it's owners must be known. +- Modules in the repo must be monitored, and malicious modules must be removed. +- Module repo must have a valid, working, automatically or frequently updated `modules.json` + ([Example](https://github.com/Magisk-Modules-Alt-Repo/json/blob/main/modules.json)) + +These guidelines are not mandatory, but not following them may result in your repo being removed or +not being added in the first place. +
+Click to see the guidelines + +- Repos must process and take-down off their repo module where it's removal was provably + requested by + their + original author +- Repos may not collect and/or distribute any personally identifiable data (including IP + addresses) without + informing + users + that they do so and offering a way to opt out +- Modules owners must be aware that their modules are being hosted on the repository and/or have a + way to remove their modules from the repository +- Modules owners must be aware of any change made of the distributed version of their modules. +- Repos should make an effort to keep users safe, via a review process, or by using a + whitelist/blacklist + +
+ +In all scenarios, insofar that their policies are not in conflict with the above, the repo owner's +poloicies take precedence over the above guidelines. We encourage users to check the guidelines of +the repo they are using. \ No newline at end of file