2015-09-20 21:33:42 +00:00
|
|
|
package eu.siacs.conversations.ui;
|
|
|
|
|
2016-02-23 22:58:42 +00:00
|
|
|
import android.Manifest;
|
2015-09-20 21:33:42 +00:00
|
|
|
import android.content.Context;
|
|
|
|
import android.content.Intent;
|
2016-02-23 22:58:42 +00:00
|
|
|
import android.content.pm.PackageManager;
|
|
|
|
import android.os.Build;
|
2015-09-20 21:33:42 +00:00
|
|
|
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() {
|
2016-02-23 22:58:42 +00:00
|
|
|
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M
|
|
|
|
&& getContext().checkSelfPermission(Manifest.permission.WRITE_EXTERNAL_STORAGE) != PackageManager.PERMISSION_GRANTED) {
|
|
|
|
return;
|
|
|
|
}
|
2015-09-20 21:33:42 +00:00
|
|
|
final Intent startIntent = new Intent(getContext(), ExportLogsService.class);
|
|
|
|
getContext().startService(startIntent);
|
|
|
|
super.onClick();
|
|
|
|
}
|
|
|
|
}
|