Skip to content

Commit

Permalink
Fix floating notifications on pre-R
Browse files Browse the repository at this point in the history
  • Loading branch information
Xlythe committed Nov 24, 2022
1 parent 2168735 commit 6424184
Show file tree
Hide file tree
Showing 7 changed files with 8 additions and 9 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ Permissions
-----------------
The following permissions are required in your AndroidManfiest.xml
```xml
<uses-permission android:name="android.permission.POST_NOTIFICATIONS" />
<uses-permission android:name="android.permission.SYSTEM_ALERT_WINDOW" android:maxSdkVersion="29" />
<uses-permission android:name="android.permission.FOREGROUND_SERVICE" android:maxSdkVersion="29" />
<uses-permission android:name="android.permission.VIBRATE" android:maxSdkVersion="29" />
Expand Down
1 change: 1 addition & 0 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ android {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
namespace 'com.xlythe.view.floating.sample'
}

dependencies {
Expand Down
3 changes: 1 addition & 2 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
package="com.xlythe.view.floating.sample">
xmlns:tools="http://schemas.android.com/tools">

<application
android:allowBackup="true"
Expand Down
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ buildscript {
google()
}
dependencies {
classpath 'com.android.tools.build:gradle:7.2.2'
classpath 'com.android.tools.build:gradle:7.3.1'
classpath 'com.github.dcendents:android-maven-gradle-plugin:1.4.1'

// NOTE: Do not place your application dependencies here; they belong
Expand Down
3 changes: 1 addition & 2 deletions floating-view/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,6 @@ android {
defaultConfig {
minSdkVersion 14
targetSdkVersion 33
versionCode 1
versionName project.property("bintray.libraryVersion")
}
buildTypes {
release {
Expand All @@ -32,6 +30,7 @@ android {
withJavadocJar()
}
}
namespace 'com.xlythe.view.floating'
}

afterEvaluate {
Expand Down
3 changes: 1 addition & 2 deletions floating-view/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.xlythe.view.floating">
<manifest xmlns:android="http://schemas.android.com/apk/res/android">

<!-- For floating window -->
<uses-permission android:name="android.permission.POST_NOTIFICATIONS" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -116,10 +116,10 @@ protected void onActivityResult(int requestCode, int resultCode, Intent data) {
private boolean canDrawOverlays() {
if (Build.VERSION.SDK_INT < 23) {
// Before 23, just adding the permission to the manifest was enough.
return hasPermission(Manifest.permission.SYSTEM_ALERT_WINDOW);
return true;
}

return hasPermission(Manifest.permission.SYSTEM_ALERT_WINDOW) && Settings.canDrawOverlays(this);
return Settings.canDrawOverlays(this);
}

private boolean hasPermission(String permission) {
Expand Down

0 comments on commit 6424184

Please sign in to comment.