Skip to content

Commit

Permalink
Migrating to sdk 34 (#38)
Browse files Browse the repository at this point in the history
* updating dependencies

* increase min sdk (21)

* fixed permissions request

* taxon: make unlisted taxon item available only if option is specified

* Release: Updated version number

---------

Co-authored-by: Stefano Ricci <[email protected]>
  • Loading branch information
SteRiccio and SteRiccio authored Feb 11, 2025
1 parent e0aecba commit fa3ccd3
Show file tree
Hide file tree
Showing 9 changed files with 76 additions and 54 deletions.
41 changes: 21 additions & 20 deletions android/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@ buildscript {
mavenCentral()
google()
jcenter()
maven { url "http://www.openforis.org/nexus/content/groups/public/" }
maven { url "https://www.openforis.org/nexus/content/groups/public/" }
}
dependencies {
classpath 'com.android.tools.build:gradle:4.1.3'
classpath 'com.android.tools.build:gradle:7.4.2'
}
}

Expand Down Expand Up @@ -47,9 +47,10 @@ dependencies {
implementation 'com.google.android.material:material:1.4.0'

// page indicator
implementation 'com.romandanylyk:pageindicatorview:1.0.3'
// implementation 'com.romandanylyk:pageindicatorview:1.0.3'
implementation 'com.github.romandanylyk:PageIndicatorView:master-SNAPSHOT'
// file chooser (survey import)
implementation 'com.nononsenseapps:filepicker:4.1.0'
implementation 'com.nononsenseapps:filepicker:4.2.1'

// storage chooser (working directory chooser)
// implementation 'com.github.codekidX:storage-chooser:2.0.4.4'
Expand Down Expand Up @@ -95,19 +96,18 @@ if (isRelease) {
}

android {
compileSdkVersion 33
buildToolsVersion '29.0.3'
compileSdkVersion 34
defaultConfig {
applicationId 'org.openforis.collect'
minSdkVersion 16
targetSdkVersion 33
minSdkVersion 21
targetSdkVersion 34
versionCode actualVersionCode
versionName actualVersionName
multiDexEnabled true
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_6
targetCompatibility JavaVersion.VERSION_1_6
sourceCompatibility JavaVersion.VERSION_1_9
targetCompatibility JavaVersion.VERSION_11
}
if (isRelease)
signingConfigs {
Expand Down Expand Up @@ -140,19 +140,20 @@ android {
}
}
packagingOptions {
exclude 'META-INF/DEPENDENCIES'
exclude 'META-INF/license.txt'
exclude 'META-INF/LICENSE.txt'
exclude 'META-INF/notice.txt'
exclude 'META-INF/NOTICE.txt'
exclude 'META-INF/spring.*'
}
lintOptions {
disable 'InvalidPackage'
abortOnError false
jniLibs {
excludes += ['META-INF/spring.*']
}
resources {
excludes += ['META-INF/DEPENDENCIES', 'META-INF/license.txt', 'META-INF/LICENSE.txt', 'META-INF/notice.txt', 'META-INF/NOTICE.txt', 'META-INF/spring.*']
}
}
productFlavors {
}
namespace 'org.openforis.collect'
lint {
abortOnError false
disable 'InvalidPackage'
}
}
//
//publishing {
Expand Down
12 changes: 8 additions & 4 deletions android/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -1,19 +1,23 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
package="org.openforis.collect">
xmlns:tools="http://schemas.android.com/tools">

<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-permission android:name="android.permission.CAMERA" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.RECORD_AUDIO" />
<uses-permission android:name="android.permission.WAKE_LOCK" />
<uses-permission android:name="android.permission.READ_MEDIA_AUDIO" />
<!-- Devices running Android 12L (API level 32) or lower -->
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<!-- Devices running Android 13 (API level 33) or higher -->
<uses-permission android:name="android.permission.READ_MEDIA_IMAGES" />
<uses-permission android:name="android.permission.READ_MEDIA_VIDEO" />
<!-- To handle the reselection within the app on devices running Android 14
or higher if your app targets Android 14 (API level 34) or higher. -->
<uses-permission android:name="android.permission.READ_MEDIA_VISUAL_USER_SELECTED" />

<uses-feature
android:name="android.hardware.sensor.compass"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,14 +30,12 @@ public class UiTaxonAdapter extends BaseAdapter implements Filterable {
private static final int MAX_RESULTS = 50;
// TODO: Use custom layout
private static final int LAYOUT_RESOURCE_ID = R.layout.taxon_dropdown_item;
private static final List<UiTaxon> UNKNOWN_UNLISTED_TAXON_ITEMS = Arrays.asList(
new UiTaxon("UNK", "Unknown"),
new UiTaxon("UNL", "Unlisted")
);
private static final UiTaxon UNKNOWN_TAXON_ITEM = new UiTaxon("UNK", "Unknown");
private static final UiTaxon UNLISTED_TAXON_ITEM = new UiTaxon("UNL", "Unlisted");
private final Context context;
private final UiTaxonAttribute attribute;
private final TaxonService taxonService;
private List<UiTaxon> filteredValues = new CopyOnWriteArrayList<UiTaxon>();
private final List<UiTaxon> filteredValues = new CopyOnWriteArrayList<UiTaxon>();
private String query = "";

public UiTaxonAdapter(Context context, UiTaxonAttribute attribute, TaxonService taxonService) {
Expand Down Expand Up @@ -94,8 +92,11 @@ protected FilterResults performFiltering(CharSequence constraint) {

constraint = ((String) constraint).trim();
List<UiTaxon> values = taxonService.find(constraint.toString(), attribute.getDefinition().taxonomy, MAX_RESULTS);
if (values.isEmpty() && attribute.getDefinition().allowUnlisted) {
values.addAll(UNKNOWN_UNLISTED_TAXON_ITEMS);
if (values.isEmpty()) {
values.add(UNKNOWN_TAXON_ITEM);
if (attribute.getDefinition().allowUnlisted) {
values.add(UNLISTED_TAXON_ITEM);
}
}
results.values = values;
results.count = values.size();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,4 +55,8 @@ public static boolean greaterEqualThan33() {
return greaterEqualThan(VERSION_CODES.TIRAMISU);
}

public static boolean greaterEqualThan34() {
return greaterEqualThan(VERSION_CODES.UPSIDE_DOWN_CAKE);
}

}
Original file line number Diff line number Diff line change
@@ -1,13 +1,19 @@
package org.openforis.collect.android.sqlite;

import android.annotation.SuppressLint;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.content.IntentFilter;
import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteOpenHelper;
import android.os.Build;
import android.util.Log;

import androidx.annotation.RequiresApi;

import org.openforis.collect.android.gui.util.AndroidFiles;
import org.openforis.collect.android.gui.util.AndroidVersion;
import org.openforis.collect.android.util.persistence.ConnectionCallback;
import org.openforis.collect.android.util.persistence.Database;
import org.openforis.collect.android.util.persistence.PersistenceException;
Expand Down Expand Up @@ -66,12 +72,15 @@ public void onReceive(Context context, Intent intent) {
private void listenToPrepareEjectionBroadcasts(Context context) {
IntentFilter filter = new IntentFilter();
filter.addAction(ACTION_PREPARE_EJECT);
context.getApplicationContext().registerReceiver(new BroadcastReceiver() {
public void onReceive(Context context, Intent intent) {
Log.i("android_database", "Received storage ejection request for " + dataSource);
close();
}
}, filter);
if (AndroidVersion.greaterEqualThan33()) {
BroadcastReceiver receiver = new BroadcastReceiver() {
public void onReceive(Context context, Intent intent) {
Log.i("android_database", "Received storage ejection request for " + dataSource);
close();
}
};
context.getApplicationContext().registerReceiver(receiver, filter, Context.RECEIVER_NOT_EXPORTED);
}
}

private void setupDatabase(File databasePath) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,9 @@ private enum Status {
if (AndroidVersion.greaterEqualThan33()) {
readStoragePermissionsList.addAll(Arrays.asList(
Manifest.permission.READ_MEDIA_AUDIO, Manifest.permission.READ_MEDIA_IMAGES, Manifest.permission.READ_MEDIA_VIDEO));
if (AndroidVersion.greaterEqualThan34()) {
readStoragePermissionsList.add(Manifest.permission.READ_MEDIA_VISUAL_USER_SELECTED);
}
} else {
readStoragePermissionsList.add(Manifest.permission.READ_EXTERNAL_STORAGE);
}
Expand Down
4 changes: 2 additions & 2 deletions gradle.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#Fri Apr 19 00:03:35 CEST 2024
currentVersionCode=226
#Tue Feb 11 11:42:38 CET 2025
currentVersionCode=228
currentVersionName=1.7.13
org.gradle.jvmargs=-Xmx1536M
android.enableJetifier=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-6.5-all.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-7.5-all.zip
28 changes: 14 additions & 14 deletions model/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -2,24 +2,24 @@ buildscript {
repositories {
mavenCentral()
jcenter()
maven { url "http://repository.jboss.org/nexus/content/groups/public" }
maven { url "https://repository.jboss.org/nexus/content/groups/public" }
}
}

apply plugin: 'java'
apply plugin: 'java-library'
apply plugin: 'groovy'
sourceCompatibility = 1.6
targetCompatibility = 1.6
sourceCompatibility = 1.9
targetCompatibility = 11

repositories {
mavenCentral()
jcenter()
maven { url "http://repository.jboss.org/nexus/content/groups/public" }
maven { url "https://repository.jboss.org/nexus/content/groups/public" }
maven { url "https://jitpack.io" }
}

dependencies {
compile ('org.openforis.collect:collect-core:4.0.82') {
api('org.openforis.collect:collect-core:4.0.92') {
exclude group: 'org.apache.poi'
exclude group: 'org.springframework'
exclude group: 'org.liquibase'
Expand All @@ -29,17 +29,17 @@ dependencies {
exclude module: 'commons-lang3'
}
// jxpath repacked using openbeans instead of java.beans
compile ('com.github.openforis.android-ports:android-jxpath:android-ports-1.0-Alpha2') {
api('com.github.openforis.android-ports:android-jxpath:android-ports-1.0-Alpha2') {
exclude module: 'servlet-api'
exclude module: 'javax.servlet'
}
compile 'com.github.openforis.android-ports:android-liquibase-core:android-ports-1.0-Alpha2'
compile 'me.champeau.openbeans:openbeans:1.0.2'
compile 'commons-io:commons-io:2.5' // latest version compatible with API 16
compile 'org.apache.commons:commons-lang3:3.9' // latest version compatible with API 16
testCompile 'org.spockframework:spock-core:0.7-groovy-2.0'
testCompile 'org.codehaus.groovy:groovy-all:2.4.15'
testCompile 'com.h2database:h2:1.4.189'
api 'com.github.openforis.android-ports:android-liquibase-core:android-ports-1.0-Alpha2'
api 'me.champeau.openbeans:openbeans:1.0.2'
api 'commons-io:commons-io:2.5' // latest version compatible with API 16
api 'org.apache.commons:commons-lang3:3.9' // latest version compatible with API 16
testImplementation 'org.spockframework:spock-core:0.7-groovy-2.0'
testImplementation 'org.codehaus.groovy:groovy-all:2.4.15'
testImplementation 'com.h2database:h2:1.4.189'
}

task copyTestResources(type: Copy) {
Expand Down

0 comments on commit fa3ccd3

Please sign in to comment.