aboutsummaryrefslogtreecommitdiffstats
path: root/src/main
diff options
context:
space:
mode:
authorDaniel Gultsch <daniel@gultsch.de>2016-09-28 12:35:52 +0200
committerDaniel Gultsch <daniel@gultsch.de>2016-09-28 12:35:52 +0200
commit43f5dfe1746a9986d0c4ffa9a0c193aa3cf509a1 (patch)
tree0f66f6ef0a77b406ba201bca8efe06383b9536a7 /src/main
parentf0dbcce58fecd294efdc2d049f85b8bd794aad3e (diff)
simplified code that invokes the export logs service
Diffstat (limited to '')
-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"/>