Skip to content
This repository has been archived by the owner on Jun 8, 2024. It is now read-only.

Commit

Permalink
SettingsAutoDetect: Add permission request
Browse files Browse the repository at this point in the history
Signed-off-by: Fung <[email protected]>
  • Loading branch information
fython committed Jun 26, 2017
1 parent 285fd9d commit 6df9b92
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
4 changes: 2 additions & 2 deletions gradle.properties
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
org.gradle.jvmargs=-Xmx1536m
BUILD_TOOLS_VERSION=26.0.0
VERSION_NAME=2.6.1
VERSION_NAME=2.7.0
TARGET_SDK_VERSION=26
VERSION_CODE=36
VERSION_CODE=37
MIN_SDK_VERSION=21
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
package info.papdt.express.helper.ui.fragment.settings;

import android.content.Intent;
import android.net.Uri;
import android.os.Build;
import android.os.Bundle;
import info.papdt.express.helper.R;
import info.papdt.express.helper.services.ClipboardDetectService;
Expand Down Expand Up @@ -34,6 +36,14 @@ public void onCreatePreferences(Bundle bundle, String s) {
public boolean onPreferenceChange(Preference pref, Object o) {
if (pref == mPrefFromClipboard) {
Boolean b = (Boolean) o;
if (b && Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
if (!android.provider.Settings.canDrawOverlays(getActivity())) {
Intent intent = new Intent(android.provider.Settings.ACTION_MANAGE_OVERLAY_PERMISSION,
Uri.parse("package:" + getActivity().getPackageName()));
startActivity(intent);
return false;
}
}
getSettings().putBoolean(Settings.KEY_DETECT_FROM_CLIPBOARD, b);
Intent intent = new Intent(getActivity().getApplicationContext(), ClipboardDetectService.class);
if (!b) {
Expand Down

0 comments on commit 6df9b92

Please sign in to comment.