aboutsummaryrefslogtreecommitdiffstats
path: root/src/main/java/de/pixart/messenger/ui/ExportLogsPreference.java
blob: e7c57a03312907f0462704498912cf6c88dca48c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
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();
    }
}