diff --git a/app/build.gradle b/app/build.gradle index 44bafc62..472d6a4e 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -3,11 +3,11 @@ apply plugin: 'com.android.application' def lifecycleVersion = '2.2.0' android { - compileSdkVersion 29 + compileSdkVersion 32 defaultConfig { applicationId "cz.martykan.forecastie" minSdkVersion 15 - targetSdkVersion 29 + targetSdkVersion 32 versionCode 74 versionName "1.22.1" } diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index 6c4a2411..978b9cc7 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -18,6 +18,7 @@ android:supportsRtl="true"> @@ -54,7 +55,7 @@ - + @@ -64,7 +65,7 @@ android:resource="@xml/extensive_widget" /> - + @@ -74,7 +75,7 @@ android:resource="@xml/time_widget" /> - + @@ -84,7 +85,7 @@ android:resource="@xml/simple_widget" /> - + @@ -94,7 +95,7 @@ android:resource="@xml/time_widget_classic" /> - + diff --git a/app/src/main/java/cz/martykan/forecastie/AlarmReceiver.java b/app/src/main/java/cz/martykan/forecastie/AlarmReceiver.java index 36917368..90d468d5 100644 --- a/app/src/main/java/cz/martykan/forecastie/AlarmReceiver.java +++ b/app/src/main/java/cz/martykan/forecastie/AlarmReceiver.java @@ -374,8 +374,9 @@ public static void setRecurringAlarm(Context context) { String intervalPref = PreferenceManager.getDefaultSharedPreferences(context) .getString("refreshInterval", "1"); Intent refresh = new Intent(context, AlarmReceiver.class); - PendingIntent recurringRefresh = PendingIntent.getBroadcast(context, - 0, refresh, PendingIntent.FLAG_CANCEL_CURRENT); + PendingIntent recurringRefresh = android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.M + ? PendingIntent.getBroadcast(context, 0, refresh, PendingIntent.FLAG_CANCEL_CURRENT | PendingIntent.FLAG_IMMUTABLE) + : PendingIntent.getBroadcast(context, 0, refresh, PendingIntent.FLAG_CANCEL_CURRENT); AlarmManager alarms = (AlarmManager) context.getSystemService( Context.ALARM_SERVICE); long intervalMillis = intervalMillisForRecurringAlarm(intervalPref); diff --git a/app/src/main/java/cz/martykan/forecastie/widgets/AbstractWidgetProvider.java b/app/src/main/java/cz/martykan/forecastie/widgets/AbstractWidgetProvider.java index f8cd0d13..80f6a41d 100644 --- a/app/src/main/java/cz/martykan/forecastie/widgets/AbstractWidgetProvider.java +++ b/app/src/main/java/cz/martykan/forecastie/widgets/AbstractWidgetProvider.java @@ -148,7 +148,9 @@ protected void cancelUpdate(Context context) { protected PendingIntent getTimeIntent(Context context) { Intent intent = new Intent(context, this.getClass()); intent.setAction(ACTION_UPDATE_TIME); - return PendingIntent.getBroadcast(context, 0, intent, PendingIntent.FLAG_CANCEL_CURRENT); + return android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.M + ? PendingIntent.getBroadcast(context, 0, intent, PendingIntent.FLAG_CANCEL_CURRENT | PendingIntent.FLAG_IMMUTABLE) + : PendingIntent.getBroadcast(context, 0, intent, PendingIntent.FLAG_CANCEL_CURRENT); } protected String getFormattedTemperature(Weather weather, Context context, SharedPreferences sp) { diff --git a/app/src/main/java/cz/martykan/forecastie/widgets/ClassicTimeWidgetProvider.java b/app/src/main/java/cz/martykan/forecastie/widgets/ClassicTimeWidgetProvider.java index 431df5f8..df53881e 100644 --- a/app/src/main/java/cz/martykan/forecastie/widgets/ClassicTimeWidgetProvider.java +++ b/app/src/main/java/cz/martykan/forecastie/widgets/ClassicTimeWidgetProvider.java @@ -35,8 +35,10 @@ public void onUpdate(Context context, AppWidgetManager appWidgetManager, int[] a setTheme(context, remoteViews); Intent intent = new Intent(context, AlarmReceiver.class); - PendingIntent pendingIntent = PendingIntent.getBroadcast(context, - 0, intent, PendingIntent.FLAG_UPDATE_CURRENT); + PendingIntent pendingIntent = android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.M + ? PendingIntent.getBroadcast(context, 0, intent, PendingIntent.FLAG_UPDATE_CURRENT | PendingIntent.FLAG_IMMUTABLE) + : PendingIntent.getBroadcast(context, 0, intent, PendingIntent.FLAG_UPDATE_CURRENT); + remoteViews.setOnClickPendingIntent(R.id.widgetButtonRefresh, pendingIntent); SharedPreferences sp = PreferenceManager.getDefaultSharedPreferences(context); diff --git a/app/src/main/java/cz/martykan/forecastie/widgets/ExtensiveWidgetProvider.java b/app/src/main/java/cz/martykan/forecastie/widgets/ExtensiveWidgetProvider.java index 0cfb301d..bfc6dd0e 100644 --- a/app/src/main/java/cz/martykan/forecastie/widgets/ExtensiveWidgetProvider.java +++ b/app/src/main/java/cz/martykan/forecastie/widgets/ExtensiveWidgetProvider.java @@ -26,8 +26,9 @@ public void onUpdate(Context context, AppWidgetManager appWidgetManager, int[] a setTheme(context, remoteViews); Intent intent = new Intent(context, AlarmReceiver.class); - PendingIntent pendingIntent = PendingIntent.getBroadcast(context, - 0, intent, PendingIntent.FLAG_UPDATE_CURRENT); + PendingIntent pendingIntent = android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.M + ? PendingIntent.getBroadcast(context, 0, intent, PendingIntent.FLAG_UPDATE_CURRENT | PendingIntent.FLAG_IMMUTABLE) + : PendingIntent.getBroadcast(context, 0, intent, PendingIntent.FLAG_UPDATE_CURRENT); remoteViews.setOnClickPendingIntent(R.id.widgetButtonRefresh, pendingIntent); SharedPreferences sp = PreferenceManager.getDefaultSharedPreferences(context); diff --git a/app/src/main/java/cz/martykan/forecastie/widgets/SimpleWidgetProvider.java b/app/src/main/java/cz/martykan/forecastie/widgets/SimpleWidgetProvider.java index 3b7cf9f5..81b4f2b9 100644 --- a/app/src/main/java/cz/martykan/forecastie/widgets/SimpleWidgetProvider.java +++ b/app/src/main/java/cz/martykan/forecastie/widgets/SimpleWidgetProvider.java @@ -22,8 +22,9 @@ public void onUpdate(Context context, AppWidgetManager appWidgetManager, int[] a setTheme(context, remoteViews); Intent intent = new Intent(context, AlarmReceiver.class); - PendingIntent pendingIntent = PendingIntent.getBroadcast(context, - 0, intent, PendingIntent.FLAG_UPDATE_CURRENT); + PendingIntent pendingIntent = android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.M + ? PendingIntent.getBroadcast(context, 0, intent, PendingIntent.FLAG_UPDATE_CURRENT | PendingIntent.FLAG_IMMUTABLE) + : PendingIntent.getBroadcast(context, 0, intent, PendingIntent.FLAG_UPDATE_CURRENT); remoteViews.setOnClickPendingIntent(R.id.widgetButtonRefresh, pendingIntent); SharedPreferences sp = PreferenceManager.getDefaultSharedPreferences(context); diff --git a/app/src/main/java/cz/martykan/forecastie/widgets/TimeWidgetProvider.java b/app/src/main/java/cz/martykan/forecastie/widgets/TimeWidgetProvider.java index 31ddd813..295dcf8b 100644 --- a/app/src/main/java/cz/martykan/forecastie/widgets/TimeWidgetProvider.java +++ b/app/src/main/java/cz/martykan/forecastie/widgets/TimeWidgetProvider.java @@ -27,8 +27,9 @@ public void onUpdate(Context context, AppWidgetManager appWidgetManager, int[] a setTheme(context, remoteViews); Intent intent = new Intent(context, AlarmReceiver.class); - PendingIntent pendingIntent = PendingIntent.getBroadcast(context, - 0, intent, PendingIntent.FLAG_UPDATE_CURRENT); + PendingIntent pendingIntent = android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.M + ? PendingIntent.getBroadcast(context, 0, intent, PendingIntent.FLAG_UPDATE_CURRENT | PendingIntent.FLAG_IMMUTABLE) + : PendingIntent.getBroadcast(context, 0, intent, PendingIntent.FLAG_UPDATE_CURRENT); remoteViews.setOnClickPendingIntent(R.id.widgetButtonRefresh, pendingIntent); SharedPreferences sp = PreferenceManager.getDefaultSharedPreferences(context); diff --git a/build.gradle b/build.gradle index 22161cb1..10d315ba 100644 --- a/build.gradle +++ b/build.gradle @@ -1,17 +1,17 @@ buildscript { repositories { google() - jcenter() + mavenCentral() } dependencies { - classpath 'com.android.tools.build:gradle:4.0.1' + classpath 'com.android.tools.build:gradle:7.1.2' } } allprojects { repositories { google() - jcenter() + mavenCentral() } gradle.projectsEvaluated { tasks.withType(JavaCompile) { diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index 7b868e0f..ffd72b7b 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -3,4 +3,4 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-6.1.1-all.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-7.2-all.zip