Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Target android 13 #2366

Merged
merged 13 commits into from
Aug 11, 2023
Merged
4 changes: 2 additions & 2 deletions .github/workflows/android.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,10 @@ jobs:

steps:
- uses: actions/checkout@v1
- name: set up JDK 11
- name: set up JDK 17
uses: actions/setup-java@v1
with:
java-version: 11
java-version: 17
- name: Copy dummy keys2.txt
shell: bash
run: |
Expand Down
6 changes: 5 additions & 1 deletion .github/workflows/codeql-analysis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,11 @@ jobs:
# Details on CodeQL's query packs refer to : https://docs.github.com/en/code-security/code-scanning/automatically-scanning-your-code-for-vulnerabilities-and-errors/configuring-code-scanning#using-queries-in-ql-packs
# queries: security-extended,security-and-quality


- uses: actions/setup-java@v3
with:
distribution: 'temurin' # See 'Supported distributions' for available options
java-version: '17'

# Autobuild attempts to build any compiled languages (C/C++, C#, or Java).
# If this step fails, then you should remove it and run the build manually (see below)
- name: Autobuild
Expand Down
12 changes: 8 additions & 4 deletions BUILDING.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,21 @@ See [translations document](TRANSLATIONS.md) for information on how Vespucci is

## Java

Building 16.1 and later requires a Java 11 JDK, previous versions assume Java 8.
Building with gradle requires a Java JDK to be installed.

- 19.1 and later requires Java 17
- 16.1 - 19.0 Java 11
- up to 16.0 Java 8

Note that if you are contributing to the code you should restrict yourself only supported Java 8 and Java 11 in Android, in particular the additional de-sugaring provided in later AGP versions doesn't work for Android prior to 5, see https://github.com/MarcusWolschon/osmeditor4android/pull/2131

## Proguard

All builds now require proguard to be enabled as we have gone over the limit for the number of references in a normal APK.

## Build flavors

Due to the forced upgrade policy from google from November 1st 2018 onwards we are now supporting two build flavors: _current_ that will target a recent Android SDK and support library and _legacy_ that will support old Android versions as long as practical.
Due to the forced upgrade policy from google from November 1st 2018 onwards we supported two build flavors: _current_ that will target a recent Android SDK and support library and _legacy_ that will support old Android versions as long as practical.

For version 15.0 the legacy flavour has been removed as androidx doesn't support versions older than Android 4 and as versions older than 4.1 do not support TLS 1.2 they would be largely non-functional in any case, however flavours may be reactivated if necessary.

Expand Down Expand Up @@ -83,8 +89,6 @@ To make running individual tests simpler refreshing the gradle tasks (assuming t

For the on device tests the time to run the tests can be reduced substantially by running against multiple emulators with ``marathonCurrentDebugAndroidTest`` marathon can execute the tests sharded according to the configuration and retry failed tests. An additional bonus is that the test output is much easier to consume and understand. marathon will include a video of failed tests (we migrated from ``spoon`` to `` marathon`` for 16.1). For more information see [https://marathonlabs.github.io/marathon/](https://marathonlabs.github.io/marathon/). On a 20 core/174GB machine running 20 emulators this reduces the run time to between 15 and 20 minutes.

__Important:__ currently marathon requires requesting and granting the MANAGE_EXTERNAL_STORAGE permission on Android 11 and higher to generate coverage output. A corresponding manifest files is located in src/debug/AndroidManifest.xml with the relevant element commented out. Using this however leads to tests not reflecting the conditions they would be run under in the production app, so you should consider running the tests without the permission during the actual testing and only request it once testing is completed to generate coverage stats.

Notes:

* a number of the tests start with the splash screen activity and then wait for the main activity to be started. Experience shows that if one of these fails to complete in certain ways, the following tests that start via the splash screen will not be able to start the main activity. Reason unknown.
Expand Down
65 changes: 42 additions & 23 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,14 @@ buildscript {
}
}

classpath 'com.android.tools.build:gradle:7.2.2'
classpath 'com.android.tools.build:gradle:8.1.0'
classpath 'ch.poole.gradle:markdown-gradle-plugin:0.2.4'
classpath 'org.jacoco:org.jacoco.core:0.8.7'
classpath 'org.jacoco:org.jacoco.core:0.8.9'
classpath "ch.poole:preset-utils:0.26.0"
classpath 'com.github.ksoichiro:gradle-eclipse-aar-plugin:0.3.1'
classpath 'com.getkeepsafe.dexcount:dexcount-gradle-plugin:3.0.1'
classpath 'com.google.protobuf:protobuf-gradle-plugin:0.8.18'
classpath 'com.malinskiy.marathon:marathon-gradle-plugin:0.8.0'
classpath 'com.google.protobuf:protobuf-gradle-plugin:0.9.1'
classpath 'com.malinskiy.marathon:marathon-gradle-plugin:0.8.4'
}
}

Expand Down Expand Up @@ -220,8 +220,10 @@ ext {
}

android {

namespace "de.blau.android"

defaultConfig {
applicationId "de.blau.android"
versionCode project.getVersionCode()
versionName "${project.getVersionName()}"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
Expand Down Expand Up @@ -253,7 +255,7 @@ android {
}

// this, unluckily, cannot be set per flavour
compileSdkVersion 31
compileSdkVersion 33

// Specifies one flavor dimension.
flavorDimensions "api"
Expand All @@ -262,7 +264,7 @@ android {
dimension "api"
multiDexEnabled true
minSdkVersion 16
targetSdkVersion 31
targetSdkVersion 33
applicationIdSuffix ""
versionNameSuffix ""
resValue "string", "content_provider", "de.blau.android.provider"
Expand All @@ -276,7 +278,9 @@ android {

testOptions {
unitTests.all {
jacoco { includeNoLocationClasses = true }
jacoco {
includeNoLocationClasses = true
}
testLogging {
events "passed", "skipped", "failed", "standardOut", "standardError"
outputs.upToDateWhen {false}
Expand Down Expand Up @@ -317,6 +321,10 @@ android {
resources.srcDirs += commonTestResources
}
}

androidResources {
generateLocaleConfig true
}
}

ext {
Expand Down Expand Up @@ -517,6 +525,10 @@ afterEvaluate{
uninstallAll.dependsOn deinstallDummyMeasureApp
}

tasks.named('marathonCurrentDebugAndroidTestGenerateMarathonfile') {
doNotTrackState('Gradle 8 compatability hack')
}

// these tasks needs to be created after the uninstall tasks

// hardwired single test, this is only needed during initial developement, once the whole test suite has been run
Expand Down Expand Up @@ -579,21 +591,23 @@ dependencies {
implementation "ch.acra:acra-http:$acraVersion"
implementation "ch.acra:acra-dialog:$acraVersion"
// android support and other libraries
implementation "androidx.activity:activity:1.2.0"
implementation "androidx.fragment:fragment:1.3.0"
implementation "androidx.appcompat:appcompat:1.3.0"
implementation "androidx.activity:activity:1.2.4"
implementation "androidx.fragment:fragment:1.3.6"
implementation "androidx.appcompat:appcompat:1.6.1"
implementation "androidx.appcompat:appcompat-resources:1.6.1"
implementation "androidx.recyclerview:recyclerview:1.1.0"
implementation "androidx.preference:preference:1.1.0"
implementation "com.google.android.material:material:1.3.0"
implementation "androidx.annotation:annotation:1.1.0"
implementation "androidx.core:core:1.7.0"
implementation "androidx.exifinterface:exifinterface:1.1.0"
implementation "androidx.exifinterface:exifinterface:1.3.6"
implementation "androidx.legacy:legacy-preference-v14:1.0.0"
implementation "androidx.work:work-runtime:$work_version"
implementation "androidx.window:window:1.0.0"
implementation 'androidx.core:core-splashscreen:1.0.0-beta02'
implementation "androidx.multidex:multidex:2.0.1"
implementation "androidx.cardview:cardview:1.0.0"
implementation "androidx.viewpager:viewpager:1.1.0-alpha01"

//
implementation 'com.heinrichreimersoftware:android-issue-reporter:1.4'
Expand All @@ -602,8 +616,6 @@ dependencies {
implementation 'se.akerfeldt:okhttp-signpost:1.1.0'
implementation "com.squareup.okhttp3:okhttp:$okHttpVersion"
implementation "com.squareup.okhttp3:logging-interceptor:$okHttpVersion"
implementation "com.adobe.xmp:xmpcore:6.1.11"
implementation "com.drewnoakes:metadata-extractor:2.16.0"
implementation 'com.google.protobuf:protobuf-java:3.12.2'
implementation "com.google.code.gson:gson:2.8.9"
implementation "com.google.protobuf:protobuf-java:$googleProtobufVersion"
Expand Down Expand Up @@ -631,7 +643,6 @@ dependencies {
implementation 'com.davemorrissey.labs:subsampling-scale-image-view:3.10.0'
implementation 'io.michaelrocks:libphonenumber-android:8.12.39'
implementation 'io.noties.markwon:core:4.6.2'
implementation 'com.zeugmasolutions.localehelper:locale-helper-android:1.1.4'
implementation 'com.github.zedlabs:ElementHistoryDialog:1.0.6'
implementation 'com.caverock:androidsvg-aar:1.4'

Expand All @@ -642,9 +653,9 @@ dependencies {
testImplementation "junit:junit:4.13.2"
testImplementation 'xmlpull:xmlpull:1.1.3.1'
testImplementation 'net.sf.kxml:kxml2:2.3.0'
testImplementation 'org.robolectric:robolectric:4.8.1'
testImplementation 'androidx.test.ext:junit:1.1.3'
testImplementation 'androidx.test:rules:1.4.0'
testImplementation 'org.robolectric:robolectric:4.10.3'
testImplementation 'androidx.test.ext:junit:1.1.5'
testImplementation 'androidx.test:rules:1.5.0'
testImplementation "com.squareup.okhttp3:mockwebserver:$okHttpVersion"
testImplementation "pl.droidsonroids.yaml:snakeyaml:1.18-android"
testImplementation ("com.orhanobut:mockwebserverplus:1.0.0") {
Expand All @@ -653,8 +664,8 @@ dependencies {
testImplementation "androidx.work:work-testing:$work_version"

// Instrumentation tests
androidTestImplementation 'androidx.test.ext:junit:1.1.3'
androidTestImplementation 'androidx.test:rules:1.4.0'
androidTestImplementation 'androidx.test.ext:junit:1.1.5'
androidTestImplementation 'androidx.test:rules:1.5.0'
androidTestImplementation "org.hamcrest:hamcrest-library:2.2"
androidTestImplementation "com.squareup.okhttp3:mockwebserver:$okHttpVersion"
androidTestImplementation "pl.droidsonroids.yaml:snakeyaml:1.18-android"
Expand Down Expand Up @@ -692,7 +703,15 @@ def coverageSourceDirs = ['src/main/java']
// see https://github.com/gradle/gradle/issues/5184
tasks.withType(Test) {
jacoco.includeNoLocationClasses = true
jacoco.excludes = ['jdk.internal.*']
jacoco.excludes = ['jdk.internal.*', '*']
// java 17 reflection workarounds for FST
jvmArgs = ["--add-opens","java.base/java.lang=ALL-UNNAMED",
"--add-opens", "java.base/java.math=ALL-UNNAMED",
"--add-opens", "java.base/java.util=ALL-UNNAMED",
"--add-opens", "java.base/java.util.concurrent=ALL-UNNAMED",
"--add-opens", "java.base/java.net=ALL-UNNAMED",
"--add-opens", "java.base/java.text=ALL-UNNAMED",
"--add-opens", "java.base/java.io=ALL-UNNAMED"]
}

task jacocoTestReport(type:JacocoReport, dependsOn: "testCurrentDebugUnitTest") {
Expand All @@ -710,8 +729,8 @@ task jacocoTestReport(type:JacocoReport, dependsOn: "testCurrentDebugUnitTest")
dir : "$buildDir",
include : ['outputs/unit_test_code_coverage/currentDebugUnitTest/testCurrentDebugUnitTest.exec', 'outputs/code-coverage/connected/flavors/CURRENT/*coverage.ec', 'reports/marathon/currentDebugAndroidTest/device-files/*/coverage/*.ec'])
reports {
xml.enabled = true
html.enabled = true
xml.required = true
html.required = true
}

sourceDirectories.from = files(coverageSourceDirs)
Expand Down
4 changes: 2 additions & 2 deletions documentation/docs/help/en/Advanced preferences.md
Original file line number Diff line number Diff line change
Expand Up @@ -72,9 +72,9 @@ Select the theme to use. _Follow system_ will follow the setting in the system p

Show the menu buttons at the bottom of the screen. Default: _on_. You need to restart the app for changes to this setting to take effect.

### Disable translations
### App language

Use English for the user interface. Google does not provide a supported way to switch languages for individual apps, as a result this setting relies on multiple workarounds that may, or may not, work on your device. Preset translations can be disabled in the preset configurations.
Select a language for the user interface that is different from the device default. On devices running Android 13 and later the app language can be changed in the system settings too. Preset translations can be disabled in the preset configurations.

### Max. number of inline values

Expand Down
3 changes: 3 additions & 0 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,6 @@ android.useAndroidX=true
org.gradle.jvmargs=-Xmx6144m
android.enableJetifier=true
android.enableResourceOptimizations=false
android.nonFinalResIds=false
android.defaults.buildfeatures.buildconfig=true
android.nonTransitiveRClass=false
2 changes: 1 addition & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-7.3.3-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-8.0-all.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
5 changes: 3 additions & 2 deletions src/androidTest/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,15 @@
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.ACCESS_MOCK_LOCATION" />
<uses-permission android:name="android.permission.FOREGROUND_SERVICE" />
<uses-permission android:name="android.permission.ACCESS_MEDIA_LOCATION" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.READ_MEDIA_IMAGES" />

<uses-sdk
android:minSdkVersion="14"
android:targetSdkVersion="30"
android:targetSdkVersion="33"
tools:overrideLibrary="android_libs.ub_uiautomator" />

<instrumentation
Expand Down
16 changes: 16 additions & 0 deletions src/androidTest/java/de/blau/android/photos/PhotosTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,23 @@ public void setup() {
*/
@After
public void teardown() {
LayerUtils.removeLayer(main, LayerType.PHOTO);
map.setUpLayers(main);
map.invalidate();
PreferenceManager.getDefaultSharedPreferences(main).edit().putBoolean(main.getString(R.string.config_indexMediaStore_key), false).commit();
try (PhotoIndex index = new PhotoIndex(main)) {
RTree<Photo> tree = new RTree<>(2, 5);
index.fill(tree);
List<Photo> photos = new ArrayList<>();
tree.query(photos);
for (Photo p : photos) {
try {
main.getContentResolver().delete(p.getRefUri(main), null, null);
} catch (SecurityException ex) {
//
}
}
}
if (photo1 != null) {
photo1.delete();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,8 @@ public void geocoder() {
fail(e.getMessage());
}
assertTrue(TestUtils.clickText(device, false, main.getString(R.string.okay), true, false));
assertTrue(TestUtils.clickHome(device, true));
TestUtils.clickHome(device, false);
TestUtils.clickHome(device, false);
try (AdvancedPrefDatabase prefDb = new AdvancedPrefDatabase(main)) {
Geocoder[] geocoders = prefDb.getGeocoders();
assertEquals(3, geocoders.length);
Expand Down
14 changes: 13 additions & 1 deletion src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,10 @@
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.FOREGROUND_SERVICE" />
<uses-permission android:name="android.permission.ACCESS_MEDIA_LOCATION" />
<uses-permission android:name="android.permission.READ_MEDIA_IMAGES"/>
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />

<queries>
<intent>
Expand Down Expand Up @@ -310,6 +311,17 @@
android:configChanges="orientation|screenSize|keyboardHidden|density|screenLayout|uiMode|fontScale"
android:foregroundServiceType="location"
android:label="TrackerService" />

<!-- Service for backwards compatible per app locale support -->
<service
android:name="androidx.appcompat.app.AppLocalesMetadataHolderService"
android:enabled="false"
android:exported="false">
<meta-data
android:name="autoStoreLocales"
android:value="true" />
</service>


<provider
android:name="androidx.core.content.FileProvider"
Expand Down
4 changes: 2 additions & 2 deletions src/main/java/de/blau/android/App.java
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,9 @@

import com.faendir.rhino_android.AndroidContextFactory;
import com.faendir.rhino_android.RhinoAndroidHelper;
import com.zeugmasolutions.localehelper.LocaleAwareApplication;

import android.app.Activity;
import android.app.Application;
import android.content.Context;
import android.content.IntentFilter;
import android.content.SharedPreferences;
Expand Down Expand Up @@ -72,7 +72,7 @@
@AcraHttpSender(httpMethod = HttpSender.Method.POST, uri = "https://acrarium.vespucci.io/")
@AcraDialog(resText = R.string.crash_dialog_text, resCommentPrompt = R.string.crash_dialog_comment_prompt, resTheme = R.style.Theme_AppCompat_Light_Dialog)

public class App extends LocaleAwareApplication implements android.app.Application.ActivityLifecycleCallbacks {
public class App extends Application implements android.app.Application.ActivityLifecycleCallbacks {
private static final String DEBUG_TAG = App.class.getCanonicalName();

private static final String RHINO_LAZY_LOAD = "lazyLoad";
Expand Down
Loading