diff --git a/app/build.gradle b/app/build.gradle
index c18681d9..548b44d0 100644
--- a/app/build.gradle
+++ b/app/build.gradle
@@ -36,6 +36,7 @@ dependencies {
def lifecycle_version = "2.2.0"
def markwon_version = '4.3.1'
def fastadapter = "3.3.1"
+ def acra = "5.5.0"
implementation fileTree(include: ['*.jar'], dir: 'libs')
implementation "androidx.appcompat:appcompat:1.1.0"
@@ -85,4 +86,8 @@ dependencies {
implementation "com.mikepenz:fastadapter:$fastadapter"
implementation "com.mikepenz:fastadapter-commons:$fastadapter"
implementation "com.mikepenz:fastadapter-extensions:$fastadapter"
+ implementation "ch.acra:acra-mail:$acra"
+ implementation "ch.acra:acra-limiter:$acra"
+ implementation "ch.acra:acra-notification:$acra"
+
}
diff --git a/app/src/main/java/org/mian/gitnex/activities/BaseActivity.java b/app/src/main/java/org/mian/gitnex/activities/BaseActivity.java
index d6d5544a..2ce8b221 100644
--- a/app/src/main/java/org/mian/gitnex/activities/BaseActivity.java
+++ b/app/src/main/java/org/mian/gitnex/activities/BaseActivity.java
@@ -2,15 +2,28 @@ package org.mian.gitnex.activities;
import android.os.Bundle;
import androidx.appcompat.app.AppCompatActivity;
+import org.acra.ACRA;
+import org.acra.BuildConfig;
+import org.acra.annotation.AcraNotification;
+import org.acra.config.CoreConfigurationBuilder;
+import org.acra.config.LimiterConfigurationBuilder;
+import org.acra.config.MailSenderConfigurationBuilder;
+import org.acra.data.StringFormat;
import org.mian.gitnex.R;
import org.mian.gitnex.helpers.FontsOverride;
import org.mian.gitnex.helpers.TimeHelper;
+import org.mian.gitnex.util.AppUtil;
import org.mian.gitnex.util.TinyDB;
/**
* Author M M Arif
*/
+@AcraNotification(resIcon = R.mipmap.app_logo,
+ resTitle = R.string.crashTitle,
+ resChannelName = R.string.setCrashReports,
+ resText = R.string.crashMessage)
+
public abstract class BaseActivity extends AppCompatActivity {
@Override
@@ -71,6 +84,22 @@ public abstract class BaseActivity extends AppCompatActivity {
tinyDb.putString("enableCounterBadgesInit", "yes");
}
+ // enable crash reports by default
+ if(tinyDb.getString("crashReportingEnabledInit").isEmpty()) {
+ tinyDb.putBoolean("crashReportingEnabled", true);
+ tinyDb.putString("crashReportingEnabledInit", "yes");
+ }
+
+ if (tinyDb.getBoolean("crashReportingEnabled")) {
+
+ CoreConfigurationBuilder ACRABuilder = new CoreConfigurationBuilder(this);
+ ACRABuilder.setBuildConfigClass(BuildConfig.class).setReportFormat(StringFormat.KEY_VALUE_LIST);
+ ACRABuilder.getPluginConfigurationBuilder(MailSenderConfigurationBuilder.class).setReportAsFile(true).setMailTo(getResources().getString(R.string.appEmail)).setSubject(getResources().getString(R.string.crashReportEmailSubject, AppUtil.getAppBuildNo(getApplicationContext()))).setEnabled(true);
+ ACRABuilder.getPluginConfigurationBuilder(LimiterConfigurationBuilder.class).setEnabled(true);
+ ACRA.init(getApplication(), ACRABuilder);
+
+ }
+
}
protected abstract int getLayoutResourceId();
diff --git a/app/src/main/java/org/mian/gitnex/fragments/SettingsFragment.java b/app/src/main/java/org/mian/gitnex/fragments/SettingsFragment.java
index fa5a3d37..db62d81e 100644
--- a/app/src/main/java/org/mian/gitnex/fragments/SettingsFragment.java
+++ b/app/src/main/java/org/mian/gitnex/fragments/SettingsFragment.java
@@ -76,6 +76,7 @@ public class SettingsFragment extends Fragment {
Switch counterBadgesSwitch = v.findViewById(R.id.switchCounterBadge);
Switch pdfModeSwitch = v.findViewById(R.id.switchPdfMode);
+ Switch crashReportsSwitch = v.findViewById(R.id.crashReportsSwitch);
TextView helpTranslate = v.findViewById(R.id.helpTranslate);
helpTranslate.setOnClickListener(v12 -> {
@@ -158,6 +159,13 @@ public class SettingsFragment extends Fragment {
pdfModeSwitch.setChecked(false);
}
+ if(tinyDb.getBoolean("crashReportingEnabled")) {
+ crashReportsSwitch.setChecked(true);
+ }
+ else {
+ crashReportsSwitch.setChecked(false);
+ }
+
// fileviewer srouce code theme selection dialog
sourceCodeThemeFrame.setOnClickListener(view -> {
@@ -239,6 +247,20 @@ public class SettingsFragment extends Fragment {
});
+ // crash reports switcher
+ crashReportsSwitch.setOnCheckedChangeListener((buttonView, isChecked) -> {
+
+ if(isChecked) {
+ tinyDb.putBoolean("crashReportingEnabled", true);
+ Toasty.info(getContext(), getResources().getString(R.string.settingsSave));
+ }
+ else {
+ tinyDb.putBoolean("crashReportingEnabled", false);
+ Toasty.info(getContext(), getResources().getString(R.string.settingsSave));
+ }
+
+ });
+
// theme selection dialog
themeFrame.setOnClickListener(view -> {
diff --git a/app/src/main/res/drawable/ic_bug_report.xml b/app/src/main/res/drawable/ic_bug_report.xml
new file mode 100644
index 00000000..a63dcc86
--- /dev/null
+++ b/app/src/main/res/drawable/ic_bug_report.xml
@@ -0,0 +1,5 @@
+
+
+
diff --git a/app/src/main/res/layout/fragment_settings.xml b/app/src/main/res/layout/fragment_settings.xml
index 4e272b2b..740fc21b 100644
--- a/app/src/main/res/layout/fragment_settings.xml
+++ b/app/src/main/res/layout/fragment_settings.xml
@@ -7,7 +7,7 @@
+ android:background="?attr/primaryBackgroundColor">
+
+
+
+
diff --git a/app/src/main/res/layout/settings_fileview.xml b/app/src/main/res/layout/settings_fileview.xml
index bee3c2ce..9884f719 100644
--- a/app/src/main/res/layout/settings_fileview.xml
+++ b/app/src/main/res/layout/settings_fileview.xml
@@ -23,15 +23,14 @@
android:id="@+id/pdfMode"
android:layout_width="match_parent"
android:layout_height="wrap_content"
- android:layout_marginTop="10dp"
- android:orientation="vertical">
+ android:layout_marginTop="20dp"
+ android:orientation="horizontal">
diff --git a/app/src/main/res/layout/settings_reporting.xml b/app/src/main/res/layout/settings_reporting.xml
new file mode 100644
index 00000000..80528dc3
--- /dev/null
+++ b/app/src/main/res/layout/settings_reporting.xml
@@ -0,0 +1,52 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml
index 8980e3a9..abc87fb4 100644
--- a/app/src/main/res/values/strings.xml
+++ b/app/src/main/res/values/strings.xml
@@ -2,7 +2,7 @@
GitNex
Developer : M M Arif
- gitnex@gitnex.com
+ gitnex@swatian.com
Source code
https://gitea.com/gitnex/GitNex
https://gitea.com/gitnex/GitNex/issues
@@ -15,6 +15,7 @@
%1$s / build %2$d
GitNex is a free, open-source Android client for Git repository management tool Gitea. GitNex is Licensed under GPLv3.\n\nThanks to all the contributors and donators for your generous work and donations.
https://crowdin.com/project/gitnex
+ [GitNex] - Crash Report #%1$d
Report issues at Gitea
Support the App on Liberapay
@@ -616,4 +617,10 @@
Open
Closed
+
+ Crash Reports
+ Enable Crash Reports
+ GitNex has stopped :(
+ Crash reports
+ You can tap the OK button to send the crash report by email. It will help to fix it :)\n\nYou can also add additional content in the email. Thank you!