diff options
author | Christian Schneppe <christian@pix-art.de> | 2016-09-28 21:43:54 +0200 |
---|---|---|
committer | Christian Schneppe <christian@pix-art.de> | 2016-09-28 21:43:54 +0200 |
commit | 577c507052620c0f726e39a9c2e67fd172d65d2e (patch) | |
tree | 115d71f9a54a25612b8125f615c985344e64bb88 /src/main/java/de/pixart | |
parent | 314bc117bff752d98f51be8cd2f82285d32393f1 (diff) |
simplified code that invokes the export logs service
Diffstat (limited to 'src/main/java/de/pixart')
-rw-r--r-- | src/main/java/de/pixart/messenger/ui/ExportLogsPreference.java | 36 | ||||
-rw-r--r-- | src/main/java/de/pixart/messenger/ui/SettingsActivity.java | 12 |
2 files changed, 9 insertions, 39 deletions
diff --git a/src/main/java/de/pixart/messenger/ui/ExportLogsPreference.java b/src/main/java/de/pixart/messenger/ui/ExportLogsPreference.java deleted file mode 100644 index e7c57a033..000000000 --- a/src/main/java/de/pixart/messenger/ui/ExportLogsPreference.java +++ /dev/null @@ -1,36 +0,0 @@ -package de.pixart.messenger.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 de.pixart.messenger.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/de/pixart/messenger/ui/SettingsActivity.java b/src/main/java/de/pixart/messenger/ui/SettingsActivity.java index 737f10c86..05b14d215 100644 --- a/src/main/java/de/pixart/messenger/ui/SettingsActivity.java +++ b/src/main/java/de/pixart/messenger/ui/SettingsActivity.java @@ -142,7 +142,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; } }); @@ -264,14 +266,18 @@ 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 displayToast(final String msg) { + private void startExport() { + startService(new Intent(getApplicationContext(), ExportLogsService.class)); + } + + private void displayToast(final String msg) { runOnUiThread(new Runnable() { @Override public void run() { |