diff options
Diffstat (limited to 'src/main/java/de/thedevstack/conversationsplus/ui/ExportLogsPreference.java')
-rw-r--r-- | src/main/java/de/thedevstack/conversationsplus/ui/ExportLogsPreference.java | 36 |
1 files changed, 36 insertions, 0 deletions
diff --git a/src/main/java/de/thedevstack/conversationsplus/ui/ExportLogsPreference.java b/src/main/java/de/thedevstack/conversationsplus/ui/ExportLogsPreference.java new file mode 100644 index 00000000..54fe3910 --- /dev/null +++ b/src/main/java/de/thedevstack/conversationsplus/ui/ExportLogsPreference.java @@ -0,0 +1,36 @@ +package de.thedevstack.conversationsplus.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.thedevstack.conversationsplus.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 |