Skip to content

Commit

Permalink
Bump to AGP 8.1, Gradle to 8.2.1, Java 17, latest libs, Mockito 5.7 (#6)
Browse files Browse the repository at this point in the history
  • Loading branch information
TWiStErRob authored Nov 22, 2023
1 parent 6fc9bc2 commit ed13f11
Show file tree
Hide file tree
Showing 29 changed files with 271 additions and 164 deletions.
8 changes: 2 additions & 6 deletions .github/workflows/CI-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,8 @@ jobs:
# https://github.com/actions/runner-images/blob/ubuntu22/20231016.1/images/linux/Ubuntu2204-Readme.md#android
- name: "Set up Android SDK"
uses: android-actions/setup-android@v3

- name: "Set up JDK 8."
uses: actions/setup-java@v3
with:
java-version: 8
distribution: temurin
log-accepted-android-sdk-licenses: false

- name: "Checkout ${{ github.ref }} branch in ${{ github.repository }} repository."
uses: actions/checkout@v3
Expand All @@ -53,7 +49,7 @@ jobs:
--stacktrace
--continue
--no-build-cache
build -x :Android:lint
build
- name: "Upload 'Unit Test Results' artifact."
if: success() || failure()
Expand Down
55 changes: 36 additions & 19 deletions Android/build.gradle
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
//name = 'Better London Travel Android App'
apply plugin: 'net.twisterrob.android-app'
apply plugin: 'net.twisterrob.gradle.plugin.android-app'
apply plugin: 'com.android.application'

repositories {
maven { // jcenter() deprecated
name = "jcenter"
setUrl("https://jcenter.bintray.com/")
maven {
name = "jitpack.io"
url = uri("https://jitpack.io/")
content {
includeModule("com.rarepebble", "colorpicker")
includeModule("com.github.martin-stone", "hsv-alpha-color-picker-android")
}
}
}
Expand All @@ -18,27 +18,28 @@ dependencies {
implementation("net.twisterrob.lib:twister-lib-android-slf4j")
implementation("net.twisterrob.lib:twister-lib-android-widgets")
implementation("net.twisterrob.lib:twister-lib-android-stringers")

implementation("net.twisterrob.lib:twister-lib-android-about")
implementation("net.twisterrob.lib:twister-lib-android-color_picker")
implementation("net.twisterrob.lib:twister-lib-android-settings")

implementation(project(':Shared')) {
exclude module: 'android-polyfill'
}
implementation("com.google.android.gms:play-services-maps:${VERSION_MAPS}")
implementation("com.google.android.gms:play-services-places:${VERSION_MAPS}")
implementation("com.android.support:support-v4:${VERSION_SUPPORT}")
implementation("com.android.support:appcompat-v7:${VERSION_SUPPORT}")
implementation("com.android.support:design:${VERSION_SUPPORT}")
implementation("com.google.code.findbugs:jsr305:${VERSION_JSR305}")
implementation("com.github.bumptech.glide:glide:${VERSION_GLIDE}")

apply from: "${rootDir}/gradle/testCompile.gradle", to: project
}

android {
compileSdkVersion 28
namespace = "net.twisterrob.blt.android"
compileSdk = 34
defaultConfig {
targetSdkVersion 19
applicationId 'net.twisterrob.blt'
minSdk = 21
targetSdk = 21
version {
major = 1
}
Expand All @@ -53,33 +54,49 @@ android {
matchingFallbacks = ['release']
}
}
lintOptions {
buildFeatures {
buildConfig = true
}
lint {
checkAllWarnings = true
checkDependencies = true
abortOnError = false
lintConfig = file("lint.xml")
baseline file("lint-baseline.xml")

}
flavorDimensions "app-build"
flavorDimensions += "app-build"
productFlavors {
full {
// default
applicationId = 'net.twisterrob.blt'
dimension "app-build"
}
range {
applicationId 'net.twisterrob.blt.range'
applicationId = 'net.twisterrob.blt.range'
dimension "app-build"
}
}
}

def generateDataBase = tasks.register("generateDataBase", Copy.class) {
abstract class GenerateDatabase extends Copy {
@Internal("An intermediate property to satisfy AGP, tracked in destination.")
abstract DirectoryProperty getOutput()
}
def generateDataBase = tasks.register("generateDataBase", GenerateDatabase.class) {
dependsOn(":Data:runNetwork", ":Data:runPostCode")
from(new File(project(':Data').projectDir, 'output')) {
include '*.data.*.sql'
}
into android.sourceSets.main.assets.srcDirs[0]
into(output)
}
android.applicationVariants.all { com.android.build.gradle.api.ApplicationVariant variant ->
variant.mergeAssetsProvider.configure { dependsOn(generateDataBase) }
androidComponents {
onVariants(selector().all()) { variant ->
variant.sources.assets.addGeneratedSourceDirectory(generateDataBase, { it.output })
afterEvaluate {
tasks.named("generate${variant.name.capitalize()}Assets").configure {
// This should be not necessary with addGeneratedSourceDirectory, but without this, it doesn't work.
dependsOn(generateDataBase)
}
}
}
}
2 changes: 0 additions & 2 deletions Android/gradle.properties

This file was deleted.

2 changes: 1 addition & 1 deletion Android/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest
xmlns:android="http://schemas.android.com/apk/res/android"
package="net.twisterrob.blt.android">
>

<!-- App required -->
<uses-permission android:name="android.permission.INTERNET" />
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
package net.twisterrob.android.utils.concurrent;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import android.os.AsyncTask;

import net.twisterrob.java.io.MailSender;

public class MailSenderAsyncTask extends AsyncTask<String, Void, Boolean> {
private static final Logger LOG = LoggerFactory.getLogger(MailSenderAsyncTask.class);

private final MailSender m = new MailSender();

public MailSenderAsyncTask(String subject, String from, String... to) {
m.setTo(to);
m.setFrom(from);
m.setSubject(subject);
}

@Override protected Boolean doInBackground(String... params) {
try {
m.setBody(params[0]);
m.send();
return true;
} catch (Exception ex) {
LOG.error("Cannot send {}.", m, ex);
return false;
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
import android.view.View;
import android.view.View.OnClickListener;

import net.twisterrob.android.utils.tools.DialogTools;
import net.twisterrob.android.utils.tools.DialogTools.PopupCallbacks;
import net.twisterrob.android.utils.tools.DialogToolsColor;

public class ColorPickerWidget {
private final View display;
Expand All @@ -28,7 +28,7 @@ public ColorPickerWidget(View view) {
this.display = view;
this.display.setOnClickListener(new OnClickListener() {
@Override public void onClick(View v) {
DialogTools.pickColor(v.getContext(), value, new PopupCallbacks<Integer>() {
DialogToolsColor.pickColor(v.getContext(), value, new PopupCallbacks<Integer>() {
@Override public void finished(Integer value) {
if (value != null) {
setValueInternal(value, true);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -227,17 +227,16 @@ protected void restoreExpandedState() {
}

@Override public boolean onOptionsItemSelected(MenuItem item) {
switch (item.getItemId()) {
case R.id.menu__option__compass_east:
case R.id.menu__option__compass_west:
case R.id.menu__option__compass_north:
case R.id.menu__option__compass_south:
case R.id.menu__option__compass_others:
toggleCompass(menuIDs.get(item.getItemId()));
return true;
default:
return super.onOptionsItemSelected(item);
int id = item.getItemId();
if (id == R.id.menu__option__compass_east
|| id == R.id.menu__option__compass_west
|| id == R.id.menu__option__compass_north
|| id == R.id.menu__option__compass_south
|| id == R.id.menu__option__compass_others) {
toggleCompass(menuIDs.get(item.getItemId()));
return true;
}
return super.onOptionsItemSelected(item);
}

protected final Set<PlatformDirection> m_directionsEnabled = EnumSet.noneOf(PlatformDirection.class);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -263,17 +263,17 @@ private ColorPickerWidget color(@IdRes int menuItemId,
.show();
return true;
}
switch (item.getItemId()) {
case R.id.menu__action__range__reset_generator:
genConfig.set(new RangeMapGeneratorConfig());
bindConfigs(genConfig, drawConfig); // update self UI
configsUpdatedListener.onConfigsUpdated();
return true;
case R.id.menu__action__range__reset_drawing:
drawConfig.set(new RangeMapDrawerConfig());
bindConfigs(genConfig, drawConfig); // update self UI
configsUpdatedListener.onConfigsUpdated();
return true;
int id = item.getItemId();
if (id == R.id.menu__action__range__reset_generator) {
genConfig.set(new RangeMapGeneratorConfig());
bindConfigs(genConfig, drawConfig); // update self UI
configsUpdatedListener.onConfigsUpdated();
return true;
} else if (id == R.id.menu__action__range__reset_drawing) {
drawConfig.set(new RangeMapDrawerConfig());
bindConfigs(genConfig, drawConfig); // update self UI
configsUpdatedListener.onConfigsUpdated();
return true;
}
return super.onOptionsItemSelected(item);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,10 +59,10 @@ public class MainActivity extends BaseActivity {
}

@Override public boolean onOptionsItemSelected(MenuItem item) {
switch (item.getItemId()) {
case R.id.menu__action__about:
startActivity(new Intent(getApplicationContext(), AboutActivity.class));
return true;
int id = item.getItemId();
if (id == R.id.menu__action__about) {
startActivity(new Intent(getApplicationContext(), AboutActivity.class));
return true;
}
return super.onOptionsItemSelected(item);
}
Expand Down
2 changes: 1 addition & 1 deletion Android/src/range/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<manifest
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
package="net.twisterrob.blt.android">
>

<!-- Not required per se, but it might be a good idea to keep it for future, not to nag the users again. -->
<!--<uses-permission android:name="android.permission.INTERNET" tools:node="remove" />-->
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,11 @@ public class StandaloneRangeMapActivity extends RangeMapActivity {
}

@Override public boolean onOptionsItemSelected(MenuItem item) {
switch (item.getItemId()) {
case android.R.id.home:
case R.id.menu__action__about:
startActivity(new Intent(getApplicationContext(), AboutActivity.class));
return true;
int id = item.getItemId();
if (id == android.R.id.home
|| id == R.id.menu__action__about) {
startActivity(new Intent(getApplicationContext(), AboutActivity.class));
return true;
}
return super.onOptionsItemSelected(item);
}
Expand Down
16 changes: 9 additions & 7 deletions AppEngine/build.gradle
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
apply plugin: 'java'
apply plugin: 'war'
apply plugin: 'com.google.cloud.tools.appengine'
apply plugin: 'com.google.cloud.tools.endpoints-framework-server'
apply plugin: 'com.google.cloud.tools.appengine-appenginewebxml'
//apply plugin: 'com.google.cloud.tools.endpoints-framework-server'
apply plugin: 'idea'

sourceCompatibility = JavaVersion.VERSION_1_7
targetCompatibility = JavaVersion.VERSION_1_8
java {
sourceCompatibility = JavaVersion.VERSION_1_8
targetCompatibility = JavaVersion.VERSION_1_8
}

configurations {
dev
Expand Down Expand Up @@ -80,6 +82,6 @@ appengine { com.google.cloud.tools.gradle.appengine.standard.AppEngineStandardEx
}
}

endpointsServer {
hostname = "twisterrob-london.appspot.com"
}
//endpointsServer {
// hostname = "twisterrob-london.appspot.com"
//}
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@

import org.junit.*;
import org.mockito.*;
import org.mockito.junit.MockitoJUnit;
import org.mockito.junit.MockitoRule;

import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.*;
Expand All @@ -14,11 +16,9 @@
import net.twisterrob.blt.model.*;

public class LineColorTest {
@Mock LineColors colors;
@Rule public final MockitoRule mockito = MockitoJUnit.rule();

@Before public void setUp() {
MockitoAnnotations.initMocks(this);
}
@Mock LineColors colors;

@Test public void testShortColor() {
testColors(0x000000AB, "#0000AB", 0x000000CD, "#0000CD");
Expand Down Expand Up @@ -54,7 +54,7 @@ private void testColors(int bgColor, String bgExpect, int fgColor, String fgExpe
}
}
assertThat(seen, hasSize(Line.values().length));
verifyZeroInteractions(colors);
verifyNoInteractions(colors);
}

@Test(expected = UnsupportedOperationException.class) public void testAllColorsCannotRemove() {
Expand Down
10 changes: 6 additions & 4 deletions Data/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,13 @@ version = '0.0.1-SNAPSHOT'
// <description>Standalone project to handle large feeds</description>

apply plugin: 'java-library'
apply plugin: 'net.twisterrob.java'
apply plugin: 'net.twisterrob.gradle.plugin.java'

dependencies {
//configurations.implementation.resolutionStrategy.cacheChangingModulesFor 0, 'seconds' // -SNAPSHOT
api project(':Shared')
implementation("com.google.code.findbugs:jsr305:${VERSION_JSR305}")
implementation("org.slf4j:slf4j-api:${VERSION_SLF4J}")
runtimeOnly "org.slf4j:slf4j-simple:${VERSION_SLF4J}"
implementation 'org.xerial:sqlite-jdbc:3.7.15-M1'

Expand Down Expand Up @@ -46,7 +48,7 @@ task runNetwork(type: JavaExec) {
outputs.dir outputDir
group = ApplicationPlugin.APPLICATION_GROUP
classpath = sourceSets.main.runtimeClasspath
main = 'net.twisterrob.blt.data.apps.TravelNetworkParser'
mainClass = 'net.twisterrob.blt.data.apps.TravelNetworkParser'
args = [ inputDir, outputDir ]
enableAssertions = true
}
Expand All @@ -58,14 +60,14 @@ task runPostCode(type: JavaExec) {
outputs.file outputFile
group = ApplicationPlugin.APPLICATION_GROUP
classpath = sourceSets.main.runtimeClasspath
main = 'net.twisterrob.blt.data.apps.PostCodeAreas'
mainClass = 'net.twisterrob.blt.data.apps.PostCodeAreas'
enableAssertions = true
}

task runDisplay(type: JavaExec) {
group = ApplicationPlugin.APPLICATION_GROUP
classpath = sourceSets.main.runtimeClasspath
main = 'net.twisterrob.blt.data.apps.DisplayLine'
mainClass = 'net.twisterrob.blt.data.apps.DisplayLine'
args = [ 'DLR' ]
if (project.hasProperty('lines')) {
args = project.property('lines').toString().split(',') as List;
Expand Down
Loading

0 comments on commit ed13f11

Please sign in to comment.