1
0
mirror of https://codeberg.org/Freeyourgadget/Gadgetbridge synced 2024-10-02 03:07:09 +02:00

Add alert to Log Sharing if logging has not been enabled yet

This commit is contained in:
vanous 2022-07-30 21:40:31 +02:00
parent c2f5fd3215
commit 8f3ef9cd7f
2 changed files with 21 additions and 2 deletions

View File

@ -36,6 +36,7 @@ import android.content.SharedPreferences;
import android.net.Uri;
import android.os.Bundle;
import android.os.Handler;
import android.preference.PreferenceManager;
import android.text.Editable;
import android.text.TextUtils;
import android.text.TextWatcher;
@ -102,6 +103,7 @@ import nodomain.freeyourgadget.gadgetbridge.model.RecordedDataTypes;
import nodomain.freeyourgadget.gadgetbridge.service.serial.GBDeviceProtocol;
import nodomain.freeyourgadget.gadgetbridge.util.DeviceHelper;
import nodomain.freeyourgadget.gadgetbridge.util.GB;
import nodomain.freeyourgadget.gadgetbridge.util.Prefs;
import nodomain.freeyourgadget.gadgetbridge.util.WidgetPreferenceStorage;
public class DebugActivity extends AbstractGBActivity {
@ -372,7 +374,14 @@ public class DebugActivity extends AbstractGBActivity {
shareLogButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
showWarning();
SharedPreferences sharedPrefs = PreferenceManager.getDefaultSharedPreferences(DebugActivity.this);
Prefs prefs = new Prefs(sharedPrefs);
boolean logging_enabled = prefs.getBoolean("log_to_file", false);
if (logging_enabled) {
showLogSharingWarning();
} else {
showLogSharingNotEnabledAlert();
}
}
});
@ -652,7 +661,15 @@ public class DebugActivity extends AbstractGBActivity {
}
}
private void showWarning() {
private void showLogSharingNotEnabledAlert() {
new AlertDialog.Builder(this)
.setTitle(R.string.note)
.setPositiveButton(R.string.ok, null)
.setMessage(R.string.share_log_not_enabled_message)
.show();
}
private void showLogSharingWarning() {
new AlertDialog.Builder(this)
.setCancelable(true)
.setTitle(R.string.warning)

View File

@ -1133,7 +1133,9 @@
<string name="preferences_rtl_settings">Right To Left Support</string>
<string name="share_log">Share log</string>
<string name="share_log_warning">Please keep in mind Gadgetbridge logs files that may contain lots of personal info, including but not limited to health data, unique identifiers (such as a device\'s MAC address), music preferences, etc. Consider editing the file and removing this info before sending the file to a public issue report.</string>
<string name="share_log_not_enabled_message">You must first enable logging in the Settings - Write log files</string>
<string name="warning">Warning!</string>
<string name="note">Note</string>
<string name="no_data">No data</string>
<!-- LED Color -->
<string name="preferences_led_color">LED Color</string>