From cdac40f01c6689796e86226d6b807afb3f6d53e2 Mon Sep 17 00:00:00 2001 From: Neamar Date: Wed, 18 Sep 2024 10:45:34 +0200 Subject: [PATCH 1/3] Compile for API35 --- app/build.gradle | 9 +++++++-- .../main/java/fr/neamar/kiss/DataHandler.java | 8 ++++++-- .../main/java/fr/neamar/kiss/MainActivity.java | 17 ++++++++++++++--- .../fr/neamar/kiss/dataprovider/Provider.java | 1 - build.gradle | 2 +- gradle.properties | 2 -- gradle/wrapper/gradle-wrapper.properties | 2 +- 7 files changed, 29 insertions(+), 12 deletions(-) diff --git a/app/build.gradle b/app/build.gradle index bfbf359e5..36a6d2b57 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -13,11 +13,16 @@ plugins { } android { - compileSdkVersion 33 + defaultConfig { + compileSdk 35 + } + buildFeatures { + buildConfig = true + } defaultConfig { applicationId 'fr.neamar.kiss' minSdkVersion 15 - targetSdkVersion 33 + targetSdkVersion 35 versionCode 209 versionName "3.21.1" testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" diff --git a/app/src/main/java/fr/neamar/kiss/DataHandler.java b/app/src/main/java/fr/neamar/kiss/DataHandler.java index 68d4a9c48..2503cf53c 100644 --- a/app/src/main/java/fr/neamar/kiss/DataHandler.java +++ b/app/src/main/java/fr/neamar/kiss/DataHandler.java @@ -93,7 +93,12 @@ public DataHandler(Context context) { start = System.currentTimeMillis(); IntentFilter intentFilter = new IntentFilter(MainActivity.LOAD_OVER); - this.context.getApplicationContext().registerReceiver(this, intentFilter); + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) { + this.context.getApplicationContext().registerReceiver(this, intentFilter, Context.RECEIVER_EXPORTED); + } + else { + this.context.getApplicationContext().registerReceiver(this, intentFilter); + } Intent i = new Intent(MainActivity.START_LOAD); this.context.sendBroadcast(i); @@ -189,7 +194,6 @@ private void connectToProvider(final String name, final int counter) { Log.v(TAG, "Connecting to " + name); - // Find provider class for the given service name final Intent intent = this.providerName2Intent(name); if (intent == null) { diff --git a/app/src/main/java/fr/neamar/kiss/MainActivity.java b/app/src/main/java/fr/neamar/kiss/MainActivity.java index 70a2f5755..8e55857e4 100644 --- a/app/src/main/java/fr/neamar/kiss/MainActivity.java +++ b/app/src/main/java/fr/neamar/kiss/MainActivity.java @@ -219,9 +219,20 @@ public void onReceive(Context context, Intent intent) { } }; - this.registerReceiver(mReceiver, intentFilterLoad); - this.registerReceiver(mReceiver, intentFilterLoadOver); - this.registerReceiver(mReceiver, intentFilterFullLoadOver); + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) { + // Since Android 33, we need to specify is the receiver is available from other applications + // For some reasons, in our case, using RECEIVER_NOT_EXPORTED means we do not get the updates from our own services?! + // So we export the receiver. + // In practice, this means other apps can trigger a refresh of search results if they want by sending a broadcast. + this.registerReceiver(mReceiver, intentFilterLoad, Context.RECEIVER_EXPORTED); + this.registerReceiver(mReceiver, intentFilterLoadOver, Context.RECEIVER_EXPORTED); + this.registerReceiver(mReceiver, intentFilterFullLoadOver, Context.RECEIVER_EXPORTED); + } + else { + this.registerReceiver(mReceiver, intentFilterLoad); + this.registerReceiver(mReceiver, intentFilterLoadOver); + this.registerReceiver(mReceiver, intentFilterFullLoadOver); + } /* * Set the view and store all useful components diff --git a/app/src/main/java/fr/neamar/kiss/dataprovider/Provider.java b/app/src/main/java/fr/neamar/kiss/dataprovider/Provider.java index 9905a55ef..6d0ae8043 100644 --- a/app/src/main/java/fr/neamar/kiss/dataprovider/Provider.java +++ b/app/src/main/java/fr/neamar/kiss/dataprovider/Provider.java @@ -84,7 +84,6 @@ public void loadOver(List results) { long time = System.currentTimeMillis() - start; Log.i(TAG, "Time to load " + this.getClass().getSimpleName() + ": " + time + "ms"); - // Store results this.loader = null; this.loaded = true; diff --git a/build.gradle b/build.gradle index 25afd1a51..143be512c 100644 --- a/build.gradle +++ b/build.gradle @@ -5,7 +5,7 @@ buildscript { google() } dependencies { - classpath 'com.android.tools.build:gradle:8.3.2' + classpath 'com.android.tools.build:gradle:8.6.0' } } diff --git a/gradle.properties b/gradle.properties index 4ad340e95..4b514fa07 100644 --- a/gradle.properties +++ b/gradle.properties @@ -9,8 +9,6 @@ # Specifies the JVM arguments used for the daemon process. # The setting is particularly useful for tweaking memory settings. -android.defaults.buildfeatures.buildconfig=true -android.enableJetifier=true android.nonFinalResIds=false android.nonTransitiveRClass=false android.useAndroidX=true diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index 8b47d7186..e6bc16036 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-8.4-all.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-8.7-all.zip From 0a380e962a0454764b7835de2ee60dee347407bc Mon Sep 17 00:00:00 2001 From: Neamar Date: Wed, 18 Sep 2024 10:56:52 +0200 Subject: [PATCH 2/3] BAck to v34 v35 seems to have an issue with SettingsActivity (top bar displays above settings) --- app/build.gradle | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/build.gradle b/app/build.gradle index 36a6d2b57..83b893f1a 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -14,7 +14,7 @@ plugins { android { defaultConfig { - compileSdk 35 + compileSdk 34 } buildFeatures { buildConfig = true @@ -22,7 +22,7 @@ android { defaultConfig { applicationId 'fr.neamar.kiss' minSdkVersion 15 - targetSdkVersion 35 + targetSdkVersion 34 versionCode 209 versionName "3.21.1" testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" From 35ad2f4860fecdb407cebb767c183e6154411675 Mon Sep 17 00:00:00 2001 From: Neamar Date: Wed, 18 Sep 2024 11:21:37 +0200 Subject: [PATCH 3/3] Lint --- app/build.gradle | 4 ++-- app/src/main/java/fr/neamar/kiss/DataHandler.java | 2 ++ app/src/main/java/fr/neamar/kiss/MainActivity.java | 1 + 3 files changed, 5 insertions(+), 2 deletions(-) diff --git a/app/build.gradle b/app/build.gradle index 83b893f1a..c5fd970e9 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -23,8 +23,8 @@ android { applicationId 'fr.neamar.kiss' minSdkVersion 15 targetSdkVersion 34 - versionCode 209 - versionName "3.21.1" + versionCode 210 + versionName "3.21.2" testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" } buildTypes { diff --git a/app/src/main/java/fr/neamar/kiss/DataHandler.java b/app/src/main/java/fr/neamar/kiss/DataHandler.java index 2503cf53c..82e3f74df 100644 --- a/app/src/main/java/fr/neamar/kiss/DataHandler.java +++ b/app/src/main/java/fr/neamar/kiss/DataHandler.java @@ -1,5 +1,6 @@ package fr.neamar.kiss; +import android.annotation.SuppressLint; import android.app.KeyguardManager; import android.content.BroadcastReceiver; import android.content.ComponentName; @@ -84,6 +85,7 @@ public class DataHandler extends BroadcastReceiver /** * Initialize all providers */ + @SuppressLint("UnspecifiedRegisterReceiverFlag") public DataHandler(Context context) { // Make sure we are in the context of the main application // (otherwise we might receive an exception about broadcast listeners not being able diff --git a/app/src/main/java/fr/neamar/kiss/MainActivity.java b/app/src/main/java/fr/neamar/kiss/MainActivity.java index 8e55857e4..01cac3ed5 100644 --- a/app/src/main/java/fr/neamar/kiss/MainActivity.java +++ b/app/src/main/java/fr/neamar/kiss/MainActivity.java @@ -174,6 +174,7 @@ public class MainActivity extends Activity implements QueryInterface, KeyboardSc /** * Called when the activity is first created. */ + @SuppressLint("UnspecifiedRegisterReceiverFlag") @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState);