1package eu.siacs.conversations.ui;
2
3import android.Manifest;
4import android.content.Context;
5import android.content.Intent;
6import android.content.pm.PackageManager;
7import android.os.Build;
8import android.preference.Preference;
9import android.util.AttributeSet;
10
11import eu.siacs.conversations.services.ExportLogsService;
12
13public class ExportLogsPreference extends Preference {
14
15 public ExportLogsPreference(Context context, AttributeSet attrs, int defStyleAttr) {
16 super(context, attrs, defStyleAttr);
17 }
18
19 public ExportLogsPreference(Context context, AttributeSet attrs) {
20 super(context, attrs);
21 }
22
23 public ExportLogsPreference(Context context) {
24 super(context);
25 }
26
27 protected void onClick() {
28 if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M
29 && getContext().checkSelfPermission(Manifest.permission.WRITE_EXTERNAL_STORAGE) != PackageManager.PERMISSION_GRANTED) {
30 return;
31 }
32 final Intent startIntent = new Intent(getContext(), ExportLogsService.class);
33 getContext().startService(startIntent);
34 super.onClick();
35 }
36}