Skip to content

Commit 66f56cf

Browse files
committed
Pull Request g123k#92: added support for newer version of the android gradle plugins and other fixes
2 parents 7fdabb6 + 0cc96b6 commit 66f56cf

File tree

13 files changed

+67
-64
lines changed

13 files changed

+67
-64
lines changed

CHANGELOG.md

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,15 @@
1+
## [1.5.2] - 15th Mart 2024
2+
3+
* Removed unnecessary requestAuthorizationWithOptions for iOS, this plugin doesn't need it to show badges. This should be used only for remote push notification.
4+
5+
## [1.5.1] - 2nd January 2024
6+
7+
* Fixed an issue with missing Gradle namespace and other related issues.
8+
* Resolved an issue with the Java target SDK.
9+
* Adjusted Dart SDK constraint to exclusively support Dart null-safety and Flutter null-safety versions.
10+
* Corrected the usage of old Flutter embedding in the example app.
11+
* Updated the wrapper to support the new Gradle version.
12+
113
## [1.5.0] - 16th September 2022
214

315
* PR #52 (Don't overwrite categories on iOS)

android/build.gradle

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ buildscript {
88
}
99

1010
dependencies {
11-
classpath 'com.android.tools.build:gradle:4.1.0'
11+
classpath 'com.android.tools.build:gradle:7.3.1'
1212
}
1313
}
1414

@@ -22,18 +22,24 @@ rootProject.allprojects {
2222
apply plugin: 'com.android.library'
2323

2424
android {
25-
compileSdkVersion 29
25+
compileSdkVersion 33
2626

2727
defaultConfig {
28-
minSdkVersion 16
28+
minSdkVersion 19
2929
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
3030
}
3131
lintOptions {
3232
disable 'InvalidPackage'
3333
}
34+
3435
if (project.android.hasProperty('namespace')) {
3536
namespace 'fr.g123k.flutterappbadge.flutterappbadger'
3637
}
38+
39+
compileOptions {
40+
sourceCompatibility JavaVersion.VERSION_1_8
41+
targetCompatibility JavaVersion.VERSION_1_8
42+
}
3743
}
3844

3945
dependencies {
Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1 @@
1-
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
2-
package="fr.g123k.flutterappbadge.flutterappbadger">
3-
</manifest>
1+
<manifest xmlns:android="http://schemas.android.com/apk/res/android" />

android/src/main/java/fr/g123k/flutterappbadger/FlutterAppBadgerPlugin.java

Lines changed: 19 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22

33
import android.content.Context;
44

5+
import androidx.annotation.NonNull;
6+
57
import io.flutter.embedding.engine.plugins.FlutterPlugin;
68
import io.flutter.plugin.common.MethodChannel;
79
import io.flutter.plugin.common.MethodChannel.MethodCallHandler;
@@ -30,23 +32,28 @@ public void onAttachedToEngine(FlutterPluginBinding flutterPluginBinding) {
3032
}
3133

3234
@Override
33-
public void onDetachedFromEngine(FlutterPluginBinding flutterPluginBinding) {
35+
public void onDetachedFromEngine(@NonNull FlutterPluginBinding flutterPluginBinding) {
3436
channel.setMethodCallHandler(null);
3537
applicationContext = null;
3638
}
3739

3840
@Override
39-
public void onMethodCall(MethodCall call, Result result) {
40-
if (call.method.equals("updateBadgeCount")) {
41-
ShortcutBadger.applyCount(applicationContext, Integer.valueOf(call.argument("count").toString()));
42-
result.success(null);
43-
} else if (call.method.equals("removeBadge")) {
44-
ShortcutBadger.removeCount(applicationContext);
45-
result.success(null);
46-
} else if (call.method.equals("isAppBadgeSupported")) {
47-
result.success(ShortcutBadger.isBadgeCounterSupported(applicationContext));
48-
} else {
49-
result.notImplemented();
41+
public void onMethodCall(MethodCall call, @NonNull Result result) {
42+
switch (call.method) {
43+
case "updateBadgeCount":
44+
ShortcutBadger.applyCount(applicationContext, Integer.valueOf(call.argument("count").toString()));
45+
result.success(null);
46+
break;
47+
case "removeBadge":
48+
ShortcutBadger.removeCount(applicationContext);
49+
result.success(null);
50+
break;
51+
case "isAppBadgeSupported":
52+
result.success(ShortcutBadger.isBadgeCounterSupported(applicationContext));
53+
break;
54+
default:
55+
result.notImplemented();
56+
break;
5057
}
5158
}
5259
}

example/android/app/build.gradle

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ apply plugin: 'com.android.application'
1515
apply from: "$flutterRoot/packages/flutter_tools/gradle/flutter.gradle"
1616

1717
android {
18-
compileSdkVersion 29
18+
compileSdk = 33
1919

2020
lintOptions {
2121
disable 'InvalidPackage'
@@ -24,8 +24,8 @@ android {
2424
defaultConfig {
2525
// TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html).
2626
applicationId "fr.g123k.flutterappbadger.flutterappbadgerexample"
27-
minSdkVersion 16
28-
targetSdkVersion 29
27+
minSdkVersion flutter.minSdkVersion
28+
targetSdkVersion 33
2929
versionCode 1
3030
versionName "1.0"
3131
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
@@ -38,6 +38,11 @@ android {
3838
signingConfig signingConfigs.debug
3939
}
4040
}
41+
42+
compileOptions {
43+
sourceCompatibility JavaVersion.VERSION_1_8
44+
targetCompatibility JavaVersion.VERSION_1_8
45+
}
4146
}
4247

4348
flutter {

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,8 @@
2222
android:theme="@style/LaunchTheme"
2323
android:configChanges="orientation|keyboardHidden|keyboard|screenSize|locale|layoutDirection|fontScale|screenLayout|density"
2424
android:hardwareAccelerated="true"
25-
android:windowSoftInputMode="adjustResize">
25+
android:windowSoftInputMode="adjustResize"
26+
android:exported="true">
2627
<!-- This keeps the window background of the activity showing
2728
until Flutter renders its first frame. It can be removed if
2829
there is no splash screen (such as the default splash screen
Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,6 @@
11
package fr.g123k.flutterappbadge.flutterappbadgerexample;
22

3-
import android.os.Bundle;
4-
5-
import io.flutter.app.FlutterActivity;
6-
import io.flutter.plugins.GeneratedPluginRegistrant;
3+
import io.flutter.embedding.android.FlutterActivity;
74

85
public class MainActivity extends FlutterActivity {
9-
@Override
10-
protected void onCreate(Bundle savedInstanceState) {
11-
super.onCreate(savedInstanceState);
12-
GeneratedPluginRegistrant.registerWith(this);
13-
}
146
}

example/android/build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ buildscript {
55
}
66

77
dependencies {
8-
classpath 'com.android.tools.build:gradle:3.5.2'
8+
classpath 'com.android.tools.build:gradle:7.3.0'
99
}
1010
}
1111

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
1+
#Tue Jan 02 14:47:09 CET 2024
12
distributionBase=GRADLE_USER_HOME
23
distributionPath=wrapper/dists
3-
distributionUrl=https\://services.gradle.org/distributions/gradle-6.5-bin.zip
4+
distributionUrl=https\://services.gradle.org/distributions/gradle-7.4-bin.zip
45
zipStoreBase=GRADLE_USER_HOME
56
zipStorePath=wrapper/dists

example/lib/main.dart

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -54,17 +54,13 @@ class _MyAppState extends State<MyApp> {
5454
crossAxisAlignment: CrossAxisAlignment.center,
5555
children: <Widget>[
5656
new Text('Badge supported: $_appBadgeSupported\n'),
57-
new RaisedButton(
57+
new ElevatedButton(
5858
child: new Text('Add badge'),
59-
onPressed: () {
60-
_addBadge();
61-
},
59+
onPressed: () => _addBadge(),
6260
),
63-
new RaisedButton(
61+
new ElevatedButton(
6462
child: new Text('Remove badge'),
65-
onPressed: () {
66-
_removeBadge();
67-
}),
63+
onPressed: () => _removeBadge()),
6864
],
6965
),
7066
),

0 commit comments

Comments
 (0)