Skip to content

Commit 22f9f51

Browse files
committed
upgrading notifications exmaple app
1 parent a422435 commit 22f9f51

File tree

12 files changed

+60
-40
lines changed

12 files changed

+60
-40
lines changed

packages/notifications/CHANGELOG.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,10 @@
1+
## 3.1.0
2+
3+
- Upgrading gradle version
4+
- Upgrading agp version
5+
- Upgrading kotlin version
6+
7+
18
## 3.0.0
29

310
- Updated Android AGP

packages/notifications/android/build.gradle

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,8 @@ version '1.0'
44
buildscript {
55
repositories {
66
google()
7-
jcenter()
7+
mavenCentral()
8+
gradlePluginPortal()
89
}
910

1011
dependencies {
@@ -15,14 +16,15 @@ buildscript {
1516
rootProject.allprojects {
1617
repositories {
1718
google()
18-
jcenter()
19+
mavenCentral()
20+
gradlePluginPortal()
1921
}
2022
}
2123

2224
apply plugin: 'com.android.library'
2325

2426
android {
25-
compileSdkVersion 30
27+
compileSdkVersion 35
2628

2729
defaultConfig {
2830
minSdkVersion 16
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#Tue Feb 11 14:46:23 CET 2025
22
distributionBase=GRADLE_USER_HOME
33
distributionPath=wrapper/dists
4-
distributionUrl=https\://services.gradle.org/distributions/gradle-8.9-bin.zip
4+
distributionUrl=https\://services.gradle.org/distributions/gradle-8.13-bin.zip
55
zipStoreBase=GRADLE_USER_HOME
66
zipStorePath=wrapper/dists

packages/notifications/android/src/main/java/dk/cachet/notifications/NotificationsPlugin.java

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
import android.content.Intent;
77
import android.content.IntentFilter;
88
import android.os.Build.VERSION_CODES;
9+
import android.os.Build.VERSION;
910
import android.provider.Settings;
1011
import android.text.TextUtils;
1112
import android.util.Log;
@@ -81,7 +82,11 @@ public void onListen(Object arguments, EventSink events) {
8182
intentFilter.addAction(NotificationListener.NOTIFICATION_INTENT);
8283

8384
NotificationReceiver receiver = new NotificationReceiver(events);
84-
context.registerReceiver(receiver, intentFilter);
85+
if (VERSION.SDK_INT >= VERSION_CODES.TIRAMISU) {
86+
context.registerReceiver(receiver, intentFilter, Context.RECEIVER_EXPORTED);
87+
} else {
88+
context.registerReceiver(receiver, intentFilter);
89+
}
8590

8691
/// Set up listener intent
8792
Intent listenerIntent = new Intent(context, NotificationListener.class);

packages/notifications/example/android/app/build.gradle

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
1+
plugins {
2+
id "com.android.application"
3+
id "kotlin-android"
4+
id "dev.flutter.flutter-gradle-plugin"
5+
}
6+
17
def localProperties = new Properties()
28
def localPropertiesFile = rootProject.file('local.properties')
39
if (localPropertiesFile.exists()) {
@@ -6,11 +12,6 @@ if (localPropertiesFile.exists()) {
612
}
713
}
814

9-
def flutterRoot = localProperties.getProperty('flutter.sdk')
10-
if (flutterRoot == null) {
11-
throw new GradleException("Flutter SDK not found. Define location with flutter.sdk in the local.properties file.")
12-
}
13-
1415
def flutterVersionCode = localProperties.getProperty('flutter.versionCode')
1516
if (flutterVersionCode == null) {
1617
flutterVersionCode = '1'
@@ -21,11 +22,9 @@ if (flutterVersionName == null) {
2122
flutterVersionName = '1.0'
2223
}
2324

24-
apply plugin: 'com.android.application'
25-
apply from: "$flutterRoot/packages/flutter_tools/gradle/flutter.gradle"
26-
2725
android {
28-
compileSdkVersion 33
26+
compileSdkVersion 35
27+
namespace "dk.cachet.notifications_example"
2928

3029
defaultConfig {
3130
// TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html).

packages/notifications/example/android/app/src/main/AndroidManifest.xml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,14 @@
3737
<meta-data
3838
android:name="flutterEmbedding"
3939
android:value="2" />
40+
<receiver
41+
android:name="dk.cachet.notifications.NotificationReceiver"
42+
android:exported="true">
43+
<intent-filter>
44+
<action android:name="dk.cachet.notifications.NOTIFICATION_EVENT" />
45+
</intent-filter>
46+
</receiver>
47+
4048
<!-- Don't delete the meta-data below.
4149
This is used by the Flutter tool to generate GeneratedPluginRegistrant.java -->
4250
<service

packages/notifications/example/android/build.gradle

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,3 @@
1-
buildscript {
2-
repositories {
3-
google()
4-
mavenCentral()
5-
}
6-
7-
dependencies {
8-
classpath 'com.android.tools.build:gradle:7.3.0'
9-
}
10-
}
11-
121
allprojects {
132
repositories {
143
google()

packages/notifications/example/android/gradle/wrapper/gradle-wrapper.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,4 @@ distributionBase=GRADLE_USER_HOME
33
distributionPath=wrapper/dists
44
zipStoreBase=GRADLE_USER_HOME
55
zipStorePath=wrapper/dists
6-
distributionUrl=https\://services.gradle.org/distributions/gradle-7.6.1-all.zip
6+
distributionUrl=https\://services.gradle.org/distributions/gradle-8.13-all.zip
Lines changed: 22 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,25 @@
1-
include ':app'
1+
pluginManagement {
2+
def flutterSdkPath = {
3+
def properties = new Properties()
4+
file("local.properties").withInputStream { properties.load(it) }
5+
def flutterSdkPath = properties.getProperty("flutter.sdk")
6+
assert flutterSdkPath != null, "flutter.sdk not set in local.properties"
7+
return flutterSdkPath
8+
}()
29

3-
def localPropertiesFile = new File(rootProject.projectDir, "local.properties")
4-
def properties = new Properties()
10+
includeBuild("$flutterSdkPath/packages/flutter_tools/gradle")
511

6-
assert localPropertiesFile.exists()
7-
localPropertiesFile.withReader("UTF-8") { reader -> properties.load(reader) }
12+
repositories {
13+
google()
14+
mavenCentral()
15+
gradlePluginPortal()
16+
}
17+
}
818

9-
def flutterSdkPath = properties.getProperty("flutter.sdk")
10-
assert flutterSdkPath != null, "flutter.sdk not set in local.properties"
11-
apply from: "$flutterSdkPath/packages/flutter_tools/gradle/app_plugin_loader.gradle"
19+
plugins {
20+
id "dev.flutter.flutter-plugin-loader" version "1.0.2"
21+
id "com.android.application" version "8.1.0" apply false
22+
id "org.jetbrains.kotlin.android" version "1.9.20" apply false
23+
}
24+
25+
include ":app"

packages/notifications/example/lib/main.dart

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -33,10 +33,6 @@ class _MyAppState extends State<MyApp> {
3333
print(event.toString());
3434
}
3535

36-
void example() {
37-
Notifications().notificationStream!.listen((event) => print(event));
38-
}
39-
4036
void startListening() {
4137
_notifications = Notifications();
4238
try {

0 commit comments

Comments
 (0)