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

Commit 6df9b92

Browse files
committed
SettingsAutoDetect: Add permission request
Signed-off-by: Fung <fython@163.com>
1 parent 285fd9d commit 6df9b92

2 files changed

Lines changed: 12 additions & 2 deletions

File tree

gradle.properties

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
org.gradle.jvmargs=-Xmx1536m
22
BUILD_TOOLS_VERSION=26.0.0
3-
VERSION_NAME=2.6.1
3+
VERSION_NAME=2.7.0
44
TARGET_SDK_VERSION=26
5-
VERSION_CODE=36
5+
VERSION_CODE=37
66
MIN_SDK_VERSION=21

mobile/src/main/java/info/papdt/express/helper/ui/fragment/settings/SettingsAutoDetect.java

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
package info.papdt.express.helper.ui.fragment.settings;
22

33
import android.content.Intent;
4+
import android.net.Uri;
5+
import android.os.Build;
46
import android.os.Bundle;
57
import info.papdt.express.helper.R;
68
import info.papdt.express.helper.services.ClipboardDetectService;
@@ -34,6 +36,14 @@ public void onCreatePreferences(Bundle bundle, String s) {
3436
public boolean onPreferenceChange(Preference pref, Object o) {
3537
if (pref == mPrefFromClipboard) {
3638
Boolean b = (Boolean) o;
39+
if (b && Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
40+
if (!android.provider.Settings.canDrawOverlays(getActivity())) {
41+
Intent intent = new Intent(android.provider.Settings.ACTION_MANAGE_OVERLAY_PERMISSION,
42+
Uri.parse("package:" + getActivity().getPackageName()));
43+
startActivity(intent);
44+
return false;
45+
}
46+
}
3747
getSettings().putBoolean(Settings.KEY_DETECT_FROM_CLIPBOARD, b);
3848
Intent intent = new Intent(getActivity().getApplicationContext(), ClipboardDetectService.class);
3949
if (!b) {

0 commit comments

Comments
 (0)