make human readable logs export optional and false as default

This commit is contained in:
Christian Schneppe 2016-08-13 21:56:52 +02:00
parent 44bf3cfb2d
commit f382943d69
4 changed files with 24 additions and 8 deletions

View file

@ -4,7 +4,9 @@ import android.app.NotificationManager;
import android.app.Service;
import android.content.Context;
import android.content.Intent;
import android.content.SharedPreferences;
import android.os.IBinder;
import android.preference.PreferenceManager;
import android.support.v4.app.NotificationCompat;
import android.util.Log;
@ -42,11 +44,14 @@ public class ExportLogsService extends Service {
private static AtomicBoolean running = new AtomicBoolean(false);
private DatabaseBackend mDatabaseBackend;
private List<Account> mAccounts;
boolean ReadableLogsEnabled = false;
@Override
public void onCreate() {
mDatabaseBackend = DatabaseBackend.getInstance(getBaseContext());
mAccounts = mDatabaseBackend.getAccounts();
final SharedPreferences ReadableLogs = PreferenceManager.getDefaultSharedPreferences(this);
ReadableLogsEnabled = ReadableLogs.getBoolean("export_plain_text_logs", false);
}
@Override
@ -76,9 +81,10 @@ public class ExportLogsService extends Service {
.setProgress(0, 0, true);
startForeground(NOTIFICATION_ID, mBuilder.build());
mNotifyManager.notify(NOTIFICATION_ID, mBuilder.build());
for (Conversation conversation : conversations) {
writeToFile(conversation);
if (ReadableLogsEnabled) {
for (Conversation conversation : conversations) {
writeToFile(conversation);
}
}
if (mAccounts.size() == 1) {
try {

View file

@ -638,5 +638,7 @@
<string name="import_canceled">Import abgebrochen</string>
<string name="databaseimport_started">Backup wird importiert, dies wird eine Weile dauern.</string>
<string name="please_wait">Bitte warten…</string>
<string name="pref_export_plain_text_logs">Exportiere Chats als lesbare Text-Dateien</string>
<string name="pref_export_plain_text_logs_summary">Aktiviere den Export von Chats als lesbare Text-Dateien</string>
</resources>

View file

@ -683,4 +683,6 @@
<string name="enter_account_password">Please enter your account password to import your backup.</string>
<string name="please_wait">Please wait…</string>
<string name="databaseimport_started">Backup will be imported, this may take awhile.</string>
<string name="pref_export_plain_text_logs_summary">Enable an export of chat logs as human readable text files</string>
<string name="pref_export_plain_text_logs">Export human readable chat logs</string>
</resources>

View file

@ -172,7 +172,17 @@
android:key="crashreport"
android:summary="@string/pref_send_crash_summary"
android:title="@string/pref_send_crash" />
<PreferenceCategory android:title="@string/pref_export_logs">
<de.pixart.messenger.ui.ExportLogsPreference
android:key="export_logs"
android:summary="@string/pref_export_logs_summary"
android:title="@string/pref_export_logs" />
<CheckBoxPreference
android:defaultValue="false"
android:key="export_plain_text_logs"
android:summary="@string/pref_export_plain_text_logs_summary"
android:title="@string/pref_export_plain_text_logs" />
</PreferenceCategory>
</PreferenceScreen>
<!--Expert-->
<PreferenceScreen
@ -229,10 +239,6 @@
android:key="autojoin"
android:summary="@string/pref_autojoin_summary"
android:title="@string/pref_autojoin" />
<de.pixart.messenger.ui.ExportLogsPreference
android:key="export_logs"
android:summary="@string/pref_export_logs_summary"
android:title="@string/pref_export_logs" />
</PreferenceCategory>
</PreferenceScreen>
<!--About-->