From 1e10cbafa3cfb7a9de13e3743c939bdec6602d6d Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=C4=B0lhan=20Atahan?=
<80551220+ilhan-athn7@users.noreply.github.com>
Date: Wed, 5 Jul 2023 13:04:10 +0300
Subject: [PATCH 1/2] Request notification permission for API 33
---
app/src/main/AndroidManifest.xml | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml
index e511c510..b5fdf45d 100644
--- a/app/src/main/AndroidManifest.xml
+++ b/app/src/main/AndroidManifest.xml
@@ -5,6 +5,7 @@
+
@@ -50,4 +51,4 @@
android:enabled="true" />
-
\ No newline at end of file
+
From 6e982606e677dfc88b368a7d5a945be5ef588d65 Mon Sep 17 00:00:00 2001
From: Xtr126
Date: Fri, 7 Jul 2023 22:48:10 +0530
Subject: [PATCH 2/2] Request for notification permission in MainActivity
---
.../xtr/keymapper/activity/MainActivity.java | 17 ++++++++++++++---
1 file changed, 14 insertions(+), 3 deletions(-)
diff --git a/app/src/main/java/xtr/keymapper/activity/MainActivity.java b/app/src/main/java/xtr/keymapper/activity/MainActivity.java
index 4555aa76..6f04ded1 100644
--- a/app/src/main/java/xtr/keymapper/activity/MainActivity.java
+++ b/app/src/main/java/xtr/keymapper/activity/MainActivity.java
@@ -1,25 +1,28 @@
package xtr.keymapper.activity;
+import static android.Manifest.permission.POST_NOTIFICATIONS;
+import static android.content.pm.PackageManager.PERMISSION_GRANTED;
+
import android.content.ComponentName;
import android.content.Context;
import android.content.Intent;
import android.content.ServiceConnection;
import android.content.res.ColorStateList;
+import android.os.Build;
import android.os.Bundle;
import android.os.IBinder;
import android.provider.Settings;
import android.widget.Button;
-import androidx.appcompat.app.AlertDialog;
import androidx.appcompat.app.AppCompatActivity;
import com.google.android.material.dialog.MaterialAlertDialogBuilder;
-import xtr.keymapper.editor.EditorService;
import xtr.keymapper.R;
import xtr.keymapper.Server;
import xtr.keymapper.TouchPointer;
import xtr.keymapper.databinding.ActivityMainBinding;
+import xtr.keymapper.editor.EditorService;
import xtr.keymapper.fragment.SettingsFragment;
import xtr.keymapper.server.InputService;
@@ -71,6 +74,7 @@ public void startPointer(){
setButtonActive(binding.controls.startPointer);
binding.controls.startPointer.setText(R.string.stop);
binding.controls.startPointer.setOnClickListener(v -> stopPointer());
+ requestNotificationPermission();
}
}
@@ -114,6 +118,13 @@ private void checkOverlayPermission(){
}
}
+ private void requestNotificationPermission(){
+ if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.TIRAMISU) {
+ if (!(checkSelfPermission(POST_NOTIFICATIONS) ==
+ PERMISSION_GRANTED)) requestPermissions(new String[]{POST_NOTIFICATIONS}, 0);
+ }
+ }
+
@Override
protected void onDestroy() {
if (pointerOverlay != null)
@@ -191,4 +202,4 @@ public void onServiceConnected(ComponentName className,
public void onServiceDisconnected(ComponentName arg0) {
}
};
-}
\ No newline at end of file
+}