aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/main/java/eu/siacs/conversations/ui/ExportLogsPreference.java36
-rw-r--r--src/main/java/eu/siacs/conversations/ui/SettingsActivity.java10
-rw-r--r--src/main/res/xml/preferences.xml2
3 files changed, 9 insertions, 39 deletions
diff --git a/src/main/java/eu/siacs/conversations/ui/ExportLogsPreference.java b/src/main/java/eu/siacs/conversations/ui/ExportLogsPreference.java
deleted file mode 100644
index bedb4172..00000000
--- a/src/main/java/eu/siacs/conversations/ui/ExportLogsPreference.java
+++ /dev/null
@@ -1,36 +0,0 @@
-package eu.siacs.conversations.ui;
-
-import android.Manifest;
-import android.content.Context;
-import android.content.Intent;
-import android.content.pm.PackageManager;
-import android.os.Build;
-import android.preference.Preference;
-import android.util.AttributeSet;
-
-import eu.siacs.conversations.services.ExportLogsService;
-
-public class ExportLogsPreference extends Preference {
-
- public ExportLogsPreference(Context context, AttributeSet attrs, int defStyleAttr) {
- super(context, attrs, defStyleAttr);
- }
-
- public ExportLogsPreference(Context context, AttributeSet attrs) {
- super(context, attrs);
- }
-
- public ExportLogsPreference(Context context) {
- super(context);
- }
-
- protected void onClick() {
- if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M
- && getContext().checkSelfPermission(Manifest.permission.WRITE_EXTERNAL_STORAGE) != PackageManager.PERMISSION_GRANTED) {
- return;
- }
- final Intent startIntent = new Intent(getContext(), ExportLogsService.class);
- getContext().startService(startIntent);
- super.onClick();
- }
-} \ No newline at end of file
diff --git a/src/main/java/eu/siacs/conversations/ui/SettingsActivity.java b/src/main/java/eu/siacs/conversations/ui/SettingsActivity.java
index fd81c621..c2bf20ac 100644
--- a/src/main/java/eu/siacs/conversations/ui/SettingsActivity.java
+++ b/src/main/java/eu/siacs/conversations/ui/SettingsActivity.java
@@ -149,7 +149,9 @@ public class SettingsActivity extends XmppActivity implements
exportLogsPreference.setOnPreferenceClickListener(new Preference.OnPreferenceClickListener() {
@Override
public boolean onPreferenceClick(Preference preference) {
- hasStoragePermission(REQUEST_WRITE_LOGS);
+ if (hasStoragePermission(REQUEST_WRITE_LOGS)) {
+ startExport();
+ }
return true;
}
});
@@ -273,13 +275,17 @@ public class SettingsActivity extends XmppActivity implements
if (grantResults.length > 0)
if (grantResults[0] == PackageManager.PERMISSION_GRANTED) {
if (requestCode == REQUEST_WRITE_LOGS) {
- getApplicationContext().startService(new Intent(getApplicationContext(), ExportLogsService.class));
+ startExport();
}
} else {
Toast.makeText(this, R.string.no_storage_permission, Toast.LENGTH_SHORT).show();
}
}
+ private void startExport() {
+ startService(new Intent(getApplicationContext(), ExportLogsService.class));
+ }
+
private void displayToast(final String msg) {
runOnUiThread(new Runnable() {
@Override
diff --git a/src/main/res/xml/preferences.xml b/src/main/res/xml/preferences.xml
index b01faa6b..cee43491 100644
--- a/src/main/res/xml/preferences.xml
+++ b/src/main/res/xml/preferences.xml
@@ -257,7 +257,7 @@
android:key="keep_foreground_service"
android:summary="@string/pref_keep_foreground_service_summary"
android:title="@string/pref_keep_foreground_service"/>
- <eu.siacs.conversations.ui.ExportLogsPreference
+ <Preference
android:key="export_logs"
android:summary="@string/pref_export_logs_summary"
android:title="@string/pref_export_logs"/>