Integrate crash reporting (#418)
Disable minify to get proper logs Enable it by default Integrate crash reporting Reviewed-on: https://gitea.com/gitnex/GitNex/pulls/418 Reviewed-by: 6543 <6543@noreply.gitea.io>
This commit is contained in:
@@ -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();
|
||||
|
||||
@@ -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 -> {
|
||||
|
||||
|
||||
Reference in New Issue
Block a user