1
0
mirror of https://gitlab.com/comunic/comunicmobile synced 2024-10-22 14:34:20 +00:00

Update Gradle & Target sdk 32

This commit is contained in:
Pierre HUBERT 2021-12-28 18:35:32 +01:00
parent 04114dede1
commit c849ee0bac
5 changed files with 29 additions and 21 deletions

2
.gitignore vendored
View File

@ -74,3 +74,5 @@ lib/*private*.dart
.flutter-plugins-dependencies
local.properties
.gradle

View File

@ -33,7 +33,7 @@ if (keystorePropertiesFile.exists()) {
}
android {
compileSdkVersion 30
compileSdkVersion 31
compileOptions {
@ -50,7 +50,7 @@ android {
defaultConfig {
applicationId "org.communiquons.comunic"
minSdkVersion 21
targetSdkVersion 30
targetSdkVersion 31
versionCode flutterVersionCode.toInteger()
versionName flutterVersionName
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"

View File

@ -59,7 +59,8 @@
android:hardwareAccelerated="true"
android:launchMode="singleTop"
android:theme="@style/LaunchTheme"
android:windowSoftInputMode="adjustResize">
android:windowSoftInputMode="adjustResize"
android:exported="true">
<!-- This keeps the window background of the activity showing
until Flutter renders its first frame. It can be removed if
there is no splash screen (such as the default splash screen

View File

@ -100,7 +100,10 @@ public class NotificationsService extends Service implements Runnable {
Intent notificationIntent = new Intent(this, MainActivity.class);
PendingIntent pendingIntent = PendingIntent.getActivity(this,
0, notificationIntent, 0);
0,
notificationIntent,
android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.M ? PendingIntent.FLAG_IMMUTABLE : 0);
Notification notification = new NotificationCompat.Builder(this, SVC_CHANNEL_ID)
.setContentTitle("Comunic")
.setContentText(getText(R.string.independent_push_notification_notification_text))
@ -197,12 +200,12 @@ public class NotificationsService extends Service implements Runnable {
ws.setPingInterval(PING_INTERVAL);
ws.addListener(new WebSocketAdapter() {
@Override
public void onConnected(WebSocket websocket, Map<String, List<String>> headers) throws Exception {
public void onConnected(WebSocket websocket, Map<String, List<String>> headers) {
Log.v(TAG, "Connected to independent push notifications service!");
}
@Override
public void onDisconnected(WebSocket websocket, WebSocketFrame serverCloseFrame, WebSocketFrame clientCloseFrame, boolean closedByServer) throws Exception {
public void onDisconnected(WebSocket websocket, WebSocketFrame serverCloseFrame, WebSocketFrame clientCloseFrame, boolean closedByServer) {
Log.v(TAG, "Disconnected from independent push notifications websocket!");
synchronized (lock) {
lock.notify();
@ -210,12 +213,12 @@ public class NotificationsService extends Service implements Runnable {
}
@Override
public void onTextFrame(WebSocket websocket, WebSocketFrame frame) throws Exception {
public void onTextFrame(WebSocket websocket, WebSocketFrame frame) {
handleTextFrame(frame);
}
@Override
public void onError(WebSocket websocket, WebSocketException cause) throws Exception {
public void onError(WebSocket websocket, WebSocketException cause) {
Log.e(TAG, "An error occured, closing WebSocket!");
cause.printStackTrace();
websocket.disconnect();
@ -254,17 +257,14 @@ public class NotificationsService extends Service implements Runnable {
}
}
private void dropNotification(String id) throws Exception {
new Handler(Looper.getMainLooper()).post(new Runnable() {
@Override
public void run() {
NotificationManagerCompat notifManager = NotificationManagerCompat.from(NotificationsService.this);
notifManager.cancel(id, NOTIFS_ID);
}
private void dropNotification(String id) {
new Handler(Looper.getMainLooper()).post(() -> {
NotificationManagerCompat notifManager = NotificationManagerCompat.from(NotificationsService.this);
notifManager.cancel(id, NOTIFS_ID);
});
}
private void sendNotification(PushNotification n) throws Exception {
private void sendNotification(PushNotification n) {
new Handler(Looper.getMainLooper()).post(() -> postNotification(n));
}
@ -273,7 +273,12 @@ public class NotificationsService extends Service implements Runnable {
createPushNotificationChannel();
Intent intent = new Intent(this, MainActivity.class);
PendingIntent pendingIntent = PendingIntent.getActivity(this, 0, intent, 0);
PendingIntent pendingIntent = PendingIntent.getActivity(
this,
0,
intent,
android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.M ? PendingIntent.FLAG_IMMUTABLE : 0
);
NotificationCompat.Builder builder = new NotificationCompat.Builder(this, NOTIFS_CHANNEL_ID)
.setSmallIcon(R.drawable.ic_notifications)

View File

@ -1,21 +1,21 @@
buildscript {
repositories {
google()
jcenter()
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.5.4'
classpath 'com.android.tools.build:gradle:4.1.3'
// Firebase
classpath 'com.google.gms:google-services:4.3.5'
classpath 'com.google.gms:google-services:4.3.10'
}
}
allprojects {
repositories {
google()
jcenter()
mavenCentral()
}
}