Skip to content

Commit

Permalink
Merge pull request #2320 from Neamar/api-35
Browse files Browse the repository at this point in the history
Migrate to API34
  • Loading branch information
Neamar authored Sep 24, 2024
2 parents 3f31eb0 + 35ad2f4 commit 95ff215
Show file tree
Hide file tree
Showing 7 changed files with 34 additions and 14 deletions.
13 changes: 9 additions & 4 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,18 @@ plugins {
}

android {
compileSdkVersion 33
defaultConfig {
compileSdk 34
}
buildFeatures {
buildConfig = true
}
defaultConfig {
applicationId 'fr.neamar.kiss'
minSdkVersion 15
targetSdkVersion 33
versionCode 209
versionName "3.21.1"
targetSdkVersion 34
versionCode 210
versionName "3.21.2"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}
buildTypes {
Expand Down
10 changes: 8 additions & 2 deletions app/src/main/java/fr/neamar/kiss/DataHandler.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package fr.neamar.kiss;

import android.annotation.SuppressLint;
import android.app.KeyguardManager;
import android.content.BroadcastReceiver;
import android.content.ComponentName;
Expand Down Expand Up @@ -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
Expand All @@ -93,7 +95,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);
Expand Down Expand Up @@ -189,7 +196,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) {
Expand Down
18 changes: 15 additions & 3 deletions app/src/main/java/fr/neamar/kiss/MainActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -219,9 +220,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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,6 @@ public void loadOver(List<T> 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;
Expand Down
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -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'
}
}

Expand Down
2 changes: 0 additions & 2 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
Expand Up @@ -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

0 comments on commit 95ff215

Please sign in to comment.