flip 'never send crash reports' to positive
This commit is contained in:
parent
dc0a139392
commit
e84d66874c
|
@ -40,6 +40,8 @@ public class AppSettings {
|
|||
public static final String USE_TOR = "use_tor";
|
||||
public static final String CHANNEL_DISCOVERY_METHOD = "channel_discovery_method";
|
||||
|
||||
public static final String SEND_CRASH_REPORTS = "send_crash_reports";
|
||||
|
||||
private final Context context;
|
||||
|
||||
public AppSettings(final Context context) {
|
||||
|
@ -73,7 +75,10 @@ public class AppSettings {
|
|||
public void setNotificationTone(final Uri uri) {
|
||||
final SharedPreferences sharedPreferences =
|
||||
PreferenceManager.getDefaultSharedPreferences(context);
|
||||
sharedPreferences.edit().putString(NOTIFICATION_RINGTONE, uri == null ? null : uri.toString()).apply();
|
||||
sharedPreferences
|
||||
.edit()
|
||||
.putString(NOTIFICATION_RINGTONE, uri == null ? null : uri.toString())
|
||||
.apply();
|
||||
}
|
||||
|
||||
public boolean isBTBVEnabled() {
|
||||
|
@ -101,6 +106,17 @@ public class AppSettings {
|
|||
public String getOmemo() {
|
||||
final SharedPreferences sharedPreferences =
|
||||
PreferenceManager.getDefaultSharedPreferences(context);
|
||||
return sharedPreferences.getString(OMEMO, context.getString(R.string.omemo_setting_default));
|
||||
return sharedPreferences.getString(
|
||||
OMEMO, context.getString(R.string.omemo_setting_default));
|
||||
}
|
||||
|
||||
public boolean isSendCrashReports() {
|
||||
return getBooleanPreference(SEND_CRASH_REPORTS, R.bool.send_crash_reports);
|
||||
}
|
||||
|
||||
public void setSendCrashReports(boolean value) {
|
||||
final SharedPreferences sharedPreferences =
|
||||
PreferenceManager.getDefaultSharedPreferences(context);
|
||||
sharedPreferences.edit().putBoolean(SEND_CRASH_REPORTS, value).apply();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -10,11 +10,14 @@ import androidx.appcompat.app.AppCompatDelegate;
|
|||
import com.google.android.material.color.DynamicColors;
|
||||
import com.google.android.material.color.DynamicColorsOptions;
|
||||
|
||||
import eu.siacs.conversations.utils.ExceptionHelper;
|
||||
|
||||
public class Conversations extends Application {
|
||||
|
||||
@Override
|
||||
public void onCreate() {
|
||||
super.onCreate();
|
||||
ExceptionHelper.init(getApplicationContext());
|
||||
applyThemeSettings();
|
||||
}
|
||||
|
||||
|
|
|
@ -485,7 +485,6 @@ public abstract class XmppActivity extends ActionBarActivity {
|
|||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
metrics = getResources().getDisplayMetrics();
|
||||
ExceptionHelper.init(getApplicationContext());
|
||||
EmojiInitializationService.execute(this);
|
||||
this.isCameraFeatureAvailable = getPackageManager().hasSystemFeature(PackageManager.FEATURE_CAMERA_ANY);
|
||||
}
|
||||
|
|
|
@ -1,17 +1,22 @@
|
|||
package eu.siacs.conversations.utils;
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.SharedPreferences;
|
||||
import android.content.pm.PackageInfo;
|
||||
import android.content.pm.PackageManager;
|
||||
import android.content.pm.Signature;
|
||||
import android.preference.PreferenceManager;
|
||||
import android.util.Log;
|
||||
|
||||
import androidx.appcompat.app.AlertDialog;
|
||||
|
||||
import com.google.android.material.dialog.MaterialAlertDialogBuilder;
|
||||
|
||||
import eu.siacs.conversations.AppSettings;
|
||||
import eu.siacs.conversations.Config;
|
||||
import eu.siacs.conversations.R;
|
||||
import eu.siacs.conversations.entities.Account;
|
||||
import eu.siacs.conversations.entities.Conversation;
|
||||
import eu.siacs.conversations.entities.Message;
|
||||
import eu.siacs.conversations.services.XmppConnectionService;
|
||||
import eu.siacs.conversations.ui.XmppActivity;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
import java.io.FileInputStream;
|
||||
import java.io.IOException;
|
||||
|
@ -21,47 +26,38 @@ import java.text.SimpleDateFormat;
|
|||
import java.util.Date;
|
||||
import java.util.Locale;
|
||||
|
||||
import eu.siacs.conversations.Config;
|
||||
import eu.siacs.conversations.R;
|
||||
import eu.siacs.conversations.entities.Account;
|
||||
import eu.siacs.conversations.entities.Conversation;
|
||||
import eu.siacs.conversations.entities.Message;
|
||||
import eu.siacs.conversations.services.XmppConnectionService;
|
||||
import eu.siacs.conversations.ui.XmppActivity;
|
||||
|
||||
public class ExceptionHelper {
|
||||
|
||||
private static final String FILENAME = "stacktrace.txt";
|
||||
private static final SimpleDateFormat DATE_FORMAT = new SimpleDateFormat("yyyy-MM-dd", Locale.ENGLISH);
|
||||
|
||||
public static void init(Context context) {
|
||||
public static void init(final Context context) {
|
||||
if (Thread.getDefaultUncaughtExceptionHandler() instanceof ExceptionHandler) {
|
||||
return;
|
||||
}
|
||||
Thread.setDefaultUncaughtExceptionHandler(new ExceptionHandler(context));
|
||||
}
|
||||
|
||||
public static boolean checkForCrash(XmppActivity activity) {
|
||||
public static boolean checkForCrash(final XmppActivity activity) {
|
||||
try {
|
||||
final XmppConnectionService service = activity == null ? null : activity.xmppConnectionService;
|
||||
if (service == null) {
|
||||
return false;
|
||||
}
|
||||
final SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(activity);
|
||||
boolean neverSend = preferences.getBoolean("never_send", false);
|
||||
if (neverSend || Config.BUG_REPORTS == null) {
|
||||
final AppSettings appSettings = new AppSettings(activity);
|
||||
if (!appSettings.isSendCrashReports() || Config.BUG_REPORTS == null) {
|
||||
return false;
|
||||
}
|
||||
final Account account = AccountUtils.getFirstEnabled(service);
|
||||
if (account == null) {
|
||||
return false;
|
||||
}
|
||||
FileInputStream file = activity.openFileInput(FILENAME);
|
||||
InputStreamReader inputStreamReader = new InputStreamReader(file);
|
||||
BufferedReader stacktrace = new BufferedReader(inputStreamReader);
|
||||
final FileInputStream file = activity.openFileInput(FILENAME);
|
||||
final InputStreamReader inputStreamReader = new InputStreamReader(file);
|
||||
final BufferedReader stacktrace = new BufferedReader(inputStreamReader);
|
||||
final StringBuilder report = new StringBuilder();
|
||||
PackageManager pm = activity.getPackageManager();
|
||||
PackageInfo packageInfo;
|
||||
final PackageManager pm = activity.getPackageManager();
|
||||
final PackageInfo packageInfo;
|
||||
try {
|
||||
packageInfo = pm.getPackageInfo(activity.getPackageName(), PackageManager.GET_SIGNATURES);
|
||||
final String versionName = packageInfo.versionName;
|
||||
|
@ -94,7 +90,7 @@ public class ExceptionHelper {
|
|||
Message message = new Message(conversation, report.toString(), Message.ENCRYPTION_NONE);
|
||||
service.sendMessage(message);
|
||||
});
|
||||
builder.setNegativeButton(activity.getText(R.string.send_never), (dialog, which) -> preferences.edit().putBoolean("never_send", true).apply());
|
||||
builder.setNegativeButton(activity.getText(R.string.send_never), (dialog, which) -> appSettings.setSendCrashReports(false));
|
||||
builder.create().show();
|
||||
return true;
|
||||
} catch (final IOException ignored) {
|
||||
|
|
|
@ -33,7 +33,7 @@
|
|||
<bool name="away_when_screen_off">false</bool>
|
||||
<bool name="autojoin">true</bool>
|
||||
<bool name="enable_foreground_service">true</bool>
|
||||
<bool name="never_send">false</bool>
|
||||
<bool name="send_crash_reports">true</bool>
|
||||
<bool name="validate_hostname">false</bool>
|
||||
<bool name="show_qr_code_scan">true</bool>
|
||||
<bool name="show_individual_search_options">true</bool>
|
||||
|
|
|
@ -125,7 +125,7 @@
|
|||
<string name="pref_notification_grace_period">Grace Period</string>
|
||||
<string name="pref_notification_grace_period_summary">The length of time notifications are silenced after detecting activity on one of your other devices.</string>
|
||||
<string name="pref_advanced_options">Advanced</string>
|
||||
<string name="pref_never_send_crash">Never send crash reports</string>
|
||||
<string name="pref_send_crash_reports">Send crash reports</string>
|
||||
<string name="pref_never_send_crash_summary">By sending in stack traces you are helping the development</string>
|
||||
<string name="pref_confirm_messages">Confirm Messages</string>
|
||||
<string name="pref_confirm_messages_summary">Let your contacts know when you have received and read their messages</string>
|
||||
|
|
|
@ -62,11 +62,11 @@
|
|||
</PreferenceCategory>
|
||||
<PreferenceCategory android:title="@string/pref_category_application">
|
||||
<SwitchPreferenceCompat
|
||||
android:defaultValue="@bool/never_send"
|
||||
android:defaultValue="@bool/send_crash_reports"
|
||||
android:icon="@drawable/ic_report_24dp"
|
||||
android:key="never_send"
|
||||
android:key="send_crash_reports"
|
||||
android:summary="@string/pref_never_send_crash_summary"
|
||||
android:title="@string/pref_never_send_crash" />
|
||||
android:title="@string/pref_send_crash_reports" />
|
||||
|
||||
</PreferenceCategory>
|
||||
|
||||
|
|
Loading…
Reference in a new issue