Skip to content

Commit

Permalink
update Gradle and dependencies; target API level 34 (Android 14) and …
Browse files Browse the repository at this point in the history
…make some adjustments for that
  • Loading branch information
mathisdt committed Oct 31, 2023
1 parent b59db29 commit c1d0a43
Show file tree
Hide file tree
Showing 8 changed files with 32 additions and 16 deletions.
14 changes: 6 additions & 8 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -43,11 +43,10 @@ android {
testInstrumentationRunner 'androidx.test.runner.AndroidJUnitRunner'

minSdkVersion 21
targetSdkVersion 33
targetSdkVersion 34
compileSdk 34
}

compileSdkVersion 33

buildTypes {
release {
postprocessing {
Expand All @@ -59,8 +58,8 @@ android {
}

// rename final APK files
android.applicationVariants.all { variant ->
variant.outputs.all {
android.applicationVariants.configureEach { variant ->
variant.outputs.configureEach {
outputFileName = "TrackWorkTime_${variant.versionName}_${buildTime()}_${variant.buildType.name}${variant.signingReady ? "" : "-unsigned"}.apk"
}
}
Expand All @@ -75,12 +74,11 @@ dependencies {
implementation 'androidx.asynclayoutinflater:asynclayoutinflater:1.0.0'
implementation 'androidx.constraintlayout:constraintlayout:2.1.4'
implementation 'androidx.preference:preference:1.2.1'
implementation 'androidx.recyclerview:recyclerview:1.3.1'
implementation 'androidx.recyclerview:recyclerview:1.3.2'
implementation 'androidx.recyclerview:recyclerview-selection:1.1.0'
implementation 'androidx.lifecycle:lifecycle-extensions:2.2.0'
implementation 'androidx.viewpager2:viewpager2:1.0.0'
// material:1.10.0 forces API level 34
implementation 'com.google.android.material:material:1.9.0'
implementation 'com.google.android.material:material:1.10.0'
implementation "ch.acra:acra-http:$acraVersion"
implementation "ch.acra:acra-dialog:$acraVersion"
implementation 'org.apache.commons:commons-lang3:3.13.0'
Expand Down
1 change: 1 addition & 0 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
<uses-permission android:name="android.permission.FOREGROUND_SERVICE" />
<uses-permission android:name="android.permission.FOREGROUND_SERVICE_LOCATION" />
<uses-permission android:name="android.permission.REQUEST_IGNORE_BATTERY_OPTIMIZATIONS" />
<uses-permission android:name="android.permission.POST_NOTIFICATIONS" />

Expand Down
6 changes: 5 additions & 1 deletion app/src/main/java/org/zephyrsoft/trackworktime/Basics.java
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,11 @@ private void registerThirdPartyReceiver() {
intentFilter.addAction(Constants.CLOCK_IN_ACTION);
intentFilter.addAction(Constants.CLOCK_OUT_ACTION);
intentFilter.addAction(Constants.STATUS_REQUEST_ACTION);
context.registerReceiver(thirdPartyReceiver, intentFilter);
if (android.os.Build.VERSION.SDK_INT >= Build.VERSION_CODES.TIRAMISU) {
context.registerReceiver(thirdPartyReceiver, intentFilter, Context.RECEIVER_EXPORTED);
} else {
context.registerReceiver(thirdPartyReceiver, intentFilter);
}
Logger.debug("Registered {}", ThirdPartyReceiver.class.getSimpleName());
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
import android.app.Service;
import android.content.Context;
import android.content.Intent;
import android.content.pm.ServiceInfo;
import android.location.LocationManager;
import android.media.AudioManager;
import android.os.Build;
Expand Down Expand Up @@ -46,7 +47,10 @@ public class LocationTrackerService extends Service {
public void onCreate() {
Logger.info("creating LocationTrackerService");
basics = Basics.get(getApplicationContext());
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q) {
startForeground(Constants.PERSISTENT_TRACKING_ID, basics.createNotificationTracking(),
ServiceInfo.FOREGROUND_SERVICE_TYPE_LOCATION);
} else if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
startForeground(Constants.PERSISTENT_TRACKING_ID, basics.createNotificationTracking());
}
locationTracker = new LocationTracker((LocationManager) getSystemService(Context.LOCATION_SERVICE), basics
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
import android.content.IntentFilter;
import android.net.wifi.ScanResult;
import android.net.wifi.WifiManager;
import android.os.Build;

import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
Expand Down Expand Up @@ -130,7 +131,11 @@ public void register(@NonNull Context context) {
IntentFilter intentFilter = new IntentFilter();
intentFilter.addAction(WifiManager.SCAN_RESULTS_AVAILABLE_ACTION);
// Note: Android API only allows registering broadcast receivers to application context!
context.getApplicationContext().registerReceiver(this, intentFilter);
if (android.os.Build.VERSION.SDK_INT >= Build.VERSION_CODES.TIRAMISU) {
context.getApplicationContext().registerReceiver(this, intentFilter, Context.RECEIVER_EXPORTED);
} else {
context.getApplicationContext().registerReceiver(this, intentFilter);
}
this.context = context;
setRegistered(true);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
import android.app.Service;
import android.content.Context;
import android.content.Intent;
import android.content.pm.ServiceInfo;
import android.media.AudioManager;
import android.net.wifi.WifiManager;
import android.os.Build;
Expand Down Expand Up @@ -49,7 +50,10 @@ public class WifiTrackerService extends Service {
public void onCreate() {
Logger.info("creating WifiTrackerService");
basics = Basics.get(getApplicationContext());
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q) {
startForeground(Constants.PERSISTENT_TRACKING_ID, basics.createNotificationTracking(),
ServiceInfo.FOREGROUND_SERVICE_TYPE_LOCATION);
} else if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
startForeground(Constants.PERSISTENT_TRACKING_ID, basics.createNotificationTracking());
}

Expand Down
4 changes: 2 additions & 2 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ app_suffix=

# use appropriate AndroidX library instead of a Support Library
android.useAndroidX=true
# automatic migrating of third-party libraries to AndroidX
android.enableJetifier=true
# automatic migrating of third-party libraries to AndroidX not needed
android.enableJetifier=false
# Github Actions don't reserve enough memory without this:
org.gradle.jvmargs=-XX:MaxMetaspaceSize=512m
# generate the BuildConfig class
Expand Down
4 changes: 2 additions & 2 deletions gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
distributionBase=GRADLE_USER_HOME
distributionUrl=https\://services.gradle.org/distributions/gradle-8.2-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-8.4-bin.zip
distributionPath=wrapper/dists
zipStorePath=wrapper/dists
distributionSha256Sum=38f66cd6eef217b4c35855bb11ea4e9fbc53594ccccb5fb82dfd317ef8c2c5a3
distributionSha256Sum=3e1af3ae886920c3ac87f7a91f816c0c7c436f276a6eefdb3da152100fef72ae
zipStoreBase=GRADLE_USER_HOME

0 comments on commit c1d0a43

Please sign in to comment.