diff --git a/.github/workflows/android.yml b/.github/workflows/ci.yml
similarity index 55%
rename from .github/workflows/android.yml
rename to .github/workflows/ci.yml
index 5a94984fa..a18332dbd 100644
--- a/.github/workflows/android.yml
+++ b/.github/workflows/ci.yml
@@ -1,4 +1,4 @@
-name: Android CI
+name: CI
# We run the tests on master, development and for PR's.
on:
@@ -9,43 +9,46 @@ on:
pull_request:
jobs:
- build-debug:
- name: Test debug
+ test:
+ name: Test
runs-on: ubuntu-latest
+ strategy:
+ matrix:
+ command: [testOpenDebug, testOpenRelease, testStoreDebug, testStoreRelease]
steps:
- uses: actions/checkout@v1
- - name: Set up JDK 11
+ - name: Set up JDK
uses: actions/setup-java@v1
with:
- java-version: 11
+ java-version: 13
- name: Cache Gradle files
uses: actions/cache@v1
with:
path: ~/.gradle/caches
- key: debug-${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle') }}
+ key: ${{ matrix.command }}-${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle') }}
restore-keys: |
- debug-${{ runner.os }}-gradle-
+ ${{ matrix.command }}-${{ runner.os }}-gradle-
- name: Test with Gradle
uses: eskatos/gradle-command-action@v1
with:
- arguments: testDebug
- build-release:
- name: Test release
+ arguments: ${{ matrix.command }}
+ lint:
+ name: Lint
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v1
- - name: Set up JDK 11
+ - name: Set up JDK
uses: actions/setup-java@v1
with:
- java-version: 11
+ java-version: 13
- name: Cache Gradle files
uses: actions/cache@v1
with:
path: ~/.gradle/caches
- key: release-${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle') }}
+ key: lint-${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle') }}
restore-keys: |
- release-${{ runner.os }}-gradle-
- - name: Test with Gradle
+ lint-${{ runner.os }}-gradle-
+ - name: Lint with Gradle
uses: eskatos/gradle-command-action@v1
with:
- arguments: testRelease
+ arguments: lint
diff --git a/.travis.yml b/.travis.yml
deleted file mode 100644
index 7b7106b62..000000000
--- a/.travis.yml
+++ /dev/null
@@ -1,36 +0,0 @@
-language: android
-dist: trusty
-jdk: openjdk11
-
-# See https://stackoverflow.com/a/51644855/1831741 for the Java options
-env:
- - COMMAND=testDebug
- - COMMAND=testRelease
-
-android:
- components:
- - tools
- - build-tools-29.0.2
- - android-29
- licenses:
- - 'android-sdk-preview-license-.+'
- - 'android-sdk-license-.+'
- - 'google-gdk-license-.+'
-
-script:
- - ./gradlew $COMMAND
-
-# Caching according to the docs at https://docs.travis-ci.com/user/languages/java/#Projects-Using-Gradle
-before_cache:
- - rm -f $HOME/.gradle/caches/modules-2/modules-2.lock
- - rm -fr $HOME/.gradle/caches/*/plugin-resolution/
-cache:
- directories:
- - $HOME/.gradle/caches/
- - $HOME/.gradle/wrapper/
-
-# We only build on these branches.
-branches:
- only:
- - master
- - development
diff --git a/README.md b/README.md
index cb8efd882..8a387e62e 100644
--- a/README.md
+++ b/README.md
@@ -1,8 +1,8 @@
-# Hydra (Android) [![Build Status](https://travis-ci.org/ZeusWPI/hydra-android.svg?branch=development)](https://travis-ci.org/ZeusWPI/hydra-android)
+# Hydra (Android) ![Android CI](https://github.com/ZeusWPI/hydra-android/workflows/Android%20CI/badge.svg?branch=development)
-Android version of the Hydra app, available for Jelly Bean and up. Available on [Google Play](https://play.google.com/store/apps/details?id=be.ugent.zeus.hydra) or as a download [here](https://github.com/ZeusWPI/hydra-android/releases) (apk file).
+The Android version of the Hydra app, available for Jelly Bean and up. Available on [Google Play](https://play.google.com/store/apps/details?id=be.ugent.zeus.hydra) or as a download [here](https://github.com/ZeusWPI/hydra-android/releases) (apk file).
## Contributing
@@ -21,6 +21,11 @@ If you want to use the Google Maps integration, you will need the API keys. You
After you've obtained the keys, you will need to copy the file `app/secrets.properties.example` to `app/secrets.properties` and insert the correct keys.
+### Build variants
+
+Hydra comes in two build variants: `store` and `open`.
+The `store` variant is the main variant, and used for the Play Store and is the recommended version for most people. The `open` variant only uses open-source software (e.g. OpenStreetMaps instead of Google Maps). Since the open variant contains no crash reporting functionality, crashes from that version not accompanied by a stack trace will not be considered.
+
### Useful links
- [How to Write a Git Commit Message](https://chris.beams.io/posts/git-commit/)
- [Android Developer Guides](https://developer.android.com/guide/)
diff --git a/app/build.gradle b/app/build.gradle
index d14138ce0..b2ccb9477 100644
--- a/app/build.gradle
+++ b/app/build.gradle
@@ -1,13 +1,14 @@
apply plugin: 'com.android.application'
-apply plugin: 'com.google.android.gms.oss-licenses-plugin'
-apply plugin: 'io.fabric'
+apply plugin: 'be.ugent.zeus.hydra.licenses'
+apply plugin: 'com.google.gms.google-services'
+apply plugin: 'com.google.firebase.crashlytics'
// Read our properties, see bottom for details.
def props = loadProperties()
android {
compileSdkVersion 29
- buildToolsVersion "29.0.2"
+ buildToolsVersion "29.0.3"
// Use resources in robolectric
testOptions.unitTests.includeAndroidResources = true
@@ -17,14 +18,11 @@ android {
applicationId "be.ugent.zeus.hydra"
minSdkVersion 16
targetSdkVersion 29
- versionCode 21400
- versionName "2.14"
+ versionCode 21402
+ versionName "2.14.2"
vectorDrawables.useSupportLibrary = true
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
- manifestPlaceholders = [
- google_maps_key: props.getProperty('MAPS_API_KEY'),
- ]
// For a description of what these do, see the config.properties file.
buildConfigField "boolean", "DEBUG_HOME_STREAM_PRIORITY", props.getProperty('hydra.debug.home.stream.priority')
buildConfigField "boolean", "DEBUG_HOME_STREAM_STALL", props.getProperty('hydra.debug.home.stream.stall')
@@ -42,6 +40,50 @@ android {
}
}
+ viewBinding {
+ enabled = true
+ }
+
+ lintOptions {
+ warningsAsErrors true
+ // We don't support Right to Left layouts.
+ disable "RtlSymmetry", "RtlHardcoded",
+ // We don't care about long vector paths.
+ "VectorPath",
+ // Http is still allowed for now.
+ "InsecureBaseConfiguration",
+ // Allow overdraw, mainly used for selectable backgrounds
+ "Overdraw",
+ // Disabled until AS 4.0 is available
+ "UnusedResources",
+ // We use dependabot for dependencies
+ "GradleDependency",
+ // We will choose for ourselves when we update
+ "OldTargetApi"
+ }
+
+ flavorDimensions "distribution"
+
+ productFlavors {
+
+ // Play Store and officially supported version
+ store {
+ isDefault = true
+ manifestPlaceholders = [
+ google_maps_key: props.getProperty('MAPS_API_KEY'),
+ ]
+ }
+
+ open {
+ ext.enableCrashlytics = false
+ versionNameSuffix "-open"
+ applicationIdSuffix ".open"
+ firebaseCrashlytics {
+ mappingFileUploadEnabled false
+ }
+ }
+ }
+
// used by Room, to test migrations
sourceSets {
test.resources.srcDirs += files("$projectDir/schemas".toString())
@@ -96,15 +138,15 @@ android {
dependencies {
implementation 'androidx.multidex:multidex:2.0.1'
- implementation 'androidx.core:core:1.2.0'
+ implementation 'androidx.core:core:1.3.1'
implementation 'androidx.media:media:1.1.0'
- implementation 'androidx.fragment:fragment:1.2.3'
- implementation 'androidx.appcompat:appcompat:1.1.0'
- implementation 'androidx.preference:preference:1.1.0'
+ implementation 'androidx.fragment:fragment:1.2.5'
+ implementation 'androidx.appcompat:appcompat:1.2.0'
+ implementation 'androidx.preference:preference:1.1.1'
implementation 'androidx.cardview:cardview:1.0.0'
implementation 'androidx.recyclerview:recyclerview:1.1.0'
- implementation 'androidx.swiperefreshlayout:swiperefreshlayout:1.0.0'
- implementation 'com.google.android.material:material:1.1.0'
+ implementation 'androidx.swiperefreshlayout:swiperefreshlayout:1.1.0'
+ implementation 'com.google.android.material:material:1.2.0'
implementation 'androidx.browser:browser:1.2.0'
implementation 'androidx.slice:slice-builders:1.0.0'
implementation 'androidx.lifecycle:lifecycle-extensions:2.2.0'
@@ -113,52 +155,61 @@ dependencies {
annotationProcessor 'androidx.room:room-compiler:2.2.5'
// Do not upgrade beyond 3.12.x until we require API 21+
//noinspection GradleDependency
- implementation 'com.squareup.okhttp3:okhttp:3.12.10'
- implementation 'com.squareup.moshi:moshi:1.9.2'
- implementation 'com.jakewharton.threetenabp:threetenabp:1.2.2'
- implementation 'net.sourceforge.streamsupport:android-retrostreams:1.7.1'
- implementation 'com.squareup.picasso:picasso:2.71828'
+ implementation 'com.squareup.okhttp3:okhttp:3.12.12'
+ implementation 'com.squareup.moshi:moshi:1.10.0'
+ implementation 'com.jakewharton.threetenabp:threetenabp:1.2.4'
+ implementation 'net.sourceforge.streamsupport:android-retrostreams:1.7.2'
+ implementation 'com.squareup.picasso:picasso:2.8'
implementation 'net.cachapa.expandablelayout:expandablelayout:2.9.2'
- implementation 'com.heinrichreimersoftware:material-intro:2.0.0'
+ implementation 'com.github.niknetniko:material-intro:9903deb6c4'
implementation 'com.jonathanfinerty.once:once:1.3.0'
implementation 'blue.aodev:material-values:1.1.1'
- implementation 'com.google.android.gms:play-services-oss-licenses:17.0.0'
- implementation 'com.google.android.gms:play-services-maps:17.0.0'
- implementation 'com.google.firebase:firebase-analytics:17.2.3'
- implementation 'com.crashlytics.sdk.android:crashlytics:2.10.1'
+
+ // Dependencies for the Play Store version.
+ storeImplementation 'com.google.android.gms:play-services-maps:17.0.0'
+ storeImplementation 'com.google.firebase:firebase-analytics:17.5.0'
+ storeImplementation 'com.google.firebase:firebase-crashlytics:17.2.1'
+
+ // Dependencies for open version.
+ openImplementation 'org.osmdroid:osmdroid-android:6.1.8'
if (props.getProperty("hydra.debug.leaks").toBoolean()) {
logger.info("Leak tracking enabled...")
- debugImplementation 'com.squareup.leakcanary:leakcanary-android:2.0'
+ debugImplementation 'com.squareup.leakcanary:leakcanary-android:2.4'
}
testImplementation 'junit:junit:4.13'
- testImplementation 'org.mockito:mockito-core:3.2.4'
- testImplementation 'org.robolectric:robolectric:4.3.1'
- testImplementation 'androidx.test:core:1.2.0'
- testImplementation 'androidx.test.ext:junit:1.1.1'
- testImplementation 'androidx.test:rules:1.2.0'
- testImplementation 'androidx.test.espresso:espresso-core:3.2.0'
- testImplementation 'androidx.test.espresso:espresso-intents:3.2.0'
- testImplementation 'androidx.test.espresso:espresso-contrib:3.2.0'
+ testImplementation 'org.mockito:mockito-core:3.5.7'
+ testImplementation 'org.robolectric:robolectric:4.4'
+ testImplementation 'androidx.test:core:1.3.0'
+ testImplementation 'androidx.test.ext:junit:1.1.2'
+ testImplementation 'androidx.test:rules:1.3.0'
+ testImplementation 'androidx.test.espresso:espresso-core:3.3.0'
+ testImplementation 'androidx.test.espresso:espresso-intents:3.3.0'
+ testImplementation 'androidx.test.espresso:espresso-contrib:3.3.0'
testImplementation 'androidx.arch.core:core-testing:2.1.0'
testImplementation 'androidx.room:room-testing:2.2.5'
// Enable the normal library for unit tests.
- testImplementation('org.threeten:threetenbp:1.4.1') {
+ testImplementation('org.threeten:threetenbp:1.4.4') {
exclude group: 'com.jakewharton.threetenabp', module: 'threetenabp'
}
//noinspection GradleDependency
- testImplementation 'com.squareup.okhttp3:mockwebserver:3.12.6'
- testImplementation 'nl.jqno.equalsverifier:equalsverifier:3.1.12'
+ testImplementation 'com.squareup.okhttp3:mockwebserver:3.12.12'
+ testImplementation 'nl.jqno.equalsverifier:equalsverifier:3.4.2'
testImplementation 'com.github.niknetniko:GetterSetterVerifier:0.0.11'
testImplementation 'com.shazam:shazamcrest:0.11'
testImplementation 'org.skyscreamer:jsonassert:1.5.0'
- testImplementation 'org.jeasy:easy-random-core:4.1.0'
- testImplementation 'org.apache.commons:commons-lang3:3.9'
+ testImplementation 'org.jeasy:easy-random-core:4.2.0'
+ testImplementation 'org.apache.commons:commons-lang3:3.11'
testImplementation 'commons-validator:commons-validator:1.6'
}
-apply plugin: 'com.google.gms.google-services'
+
+// Disable Google services for open variant.
+android.applicationVariants.all { variant ->
+ def googleTask = tasks.findByName("process${variant.name.capitalize()}GoogleServices")
+ googleTask.enabled = "open" != variant.flavorName
+}
/**
* Loads the default properties, and the user properties. This will also load the
@@ -189,7 +240,7 @@ def loadProperties() {
if (actualKeyFile.exists()) {
actualKeys.load(actualKeyFile.newReader())
} else {
- logger.warn('A secrets.properties file was not found. Maps will not work.')
+ logger.warn('A secrets.properties file was not found.')
}
return actualKeys
diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml
index 1b0ecfc6f..3fc82b9c2 100644
--- a/app/src/main/AndroidManifest.xml
+++ b/app/src/main/AndroidManifest.xml
@@ -18,6 +18,7 @@
- GoogleAppIndexingWarning: not currently used
-->
-
-
-
-
-
-
-
-
-
-
Android Design in Action: Navigation Anti-Patterns, pattern 6
*/
-public class MainActivity extends BaseActivity implements NavigationView.OnNavigationItemSelectedListener {
+public class MainActivity extends BaseActivity implements NavigationView.OnNavigationItemSelectedListener {
public static final String ARG_TAB = "argTab";
@SuppressWarnings("WeakerAccess")
@@ -164,7 +162,7 @@ public class MainActivity extends BaseActivity implements NavigationView.OnNavig
private static final String UFORA = "com.d2l.brightspace.student.android";
@VisibleForTesting
- static final String ONCE_ONBOARDING = "once_onboarding_v1_debug";
+ static final String ONCE_ONBOARDING = "once_onboarding_v1";
private static final int ONBOARDING_REQUEST = 5;
private static final String STATE_IS_ONBOARDING_OPEN = "state_is_onboarding_open";
@@ -179,11 +177,7 @@ public class MainActivity extends BaseActivity implements NavigationView.OnNavig
private static final String SHORTCUT_EVENTS = "events";
private static final String SHORTCUT_LIBRARIES = "libraries";
- private DrawerLayout drawer;
- private ProgressBar drawerLoader;
private ActionBarDrawerToggle toggle;
- private NavigationView navigationView;
- private AppBarLayout appBarLayout;
private boolean isOnboardingOpen;
@@ -197,7 +191,7 @@ public class MainActivity extends BaseActivity implements NavigationView.OnNavig
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
- setContentView(R.layout.activity_main);
+ setContentView(ActivityMainBinding::inflate);
if (savedInstanceState != null) {
isOnboardingOpen = savedInstanceState.getBoolean(STATE_IS_ONBOARDING_OPEN, false);
@@ -220,15 +214,11 @@ protected void onSaveInstanceState(@NonNull Bundle outState) {
}
private void initialize(@Nullable Bundle savedInstanceState) {
- drawer = findViewById(R.id.drawer_layout);
- navigationView = findViewById(R.id.navigation_view);
- appBarLayout = findViewById(R.id.app_bar_layout);
- drawerLoader = findViewById(R.id.drawer_loading);
// Register the listener for navigation events from the drawer.
- navigationView.setNavigationItemSelectedListener(this);
+ binding.navigationView.setNavigationItemSelectedListener(this);
- toggle = new ActionBarDrawerToggle(this, drawer, findViewById(R.id.toolbar), R.string.action_drawer_open, R.string.action_drawer_close) {
+ toggle = new ActionBarDrawerToggle(this, binding.drawerLayout, binding.toolbar, R.string.action_drawer_open, R.string.action_drawer_close) {
@Override
public void onDrawerSlide(View drawerView, float slideOffset) {
super.onDrawerSlide(drawerView, 0); // this disables the animation
@@ -240,8 +230,8 @@ public void onDrawerOpened(View drawerView) {
Once.markDone(ONCE_DRAWER);
}
};
- drawer.addDrawerListener(toggle);
- drawer.addDrawerListener(new DrawerLayout.SimpleDrawerListener() {
+ binding.drawerLayout.addDrawerListener(toggle);
+ binding.drawerLayout.addDrawerListener(new DrawerLayout.SimpleDrawerListener() {
@Override
public void onDrawerClosed(View drawerView) {
// This is used to prevent lag during closing of the navigation drawer.
@@ -257,23 +247,23 @@ public void onDrawerClosed(View drawerView) {
// If we get a position, use that (for the shortcuts)
if (getIntent().hasExtra(ARG_TAB_SHORTCUT)) {
int position = getIntent().getIntExtra(ARG_TAB_SHORTCUT, 0);
- MenuItem menuItem = navigationView.getMenu().getItem(position);
+ MenuItem menuItem = binding.navigationView.getMenu().getItem(position);
selectDrawerItem(menuItem, NavigationSource.INITIALISATION);
} else {
// Get start position & select it
int start = getIntent().getIntExtra(ARG_TAB, R.id.drawer_feed);
- selectDrawerItem(navigationView.getMenu().findItem(start), NavigationSource.INITIALISATION);
+ selectDrawerItem(binding.navigationView.getMenu().findItem(start), NavigationSource.INITIALISATION);
}
} else { //Update title, since this is not saved apparently.
//Current fragment
FragmentManager manager = getSupportFragmentManager();
Fragment current = manager.findFragmentById(R.id.content);
- setTitle(navigationView.getMenu().findItem(getFragmentMenuId(current)).getTitle());
+ setTitle(binding.navigationView.getMenu().findItem(getFragmentMenuId(current)).getTitle());
}
// If this is the first time, open the drawer.
if (!Once.beenDone(ONCE_DRAWER)) {
- drawer.openDrawer(GravityCompat.START);
+ binding.drawerLayout.openDrawer(GravityCompat.START);
}
}
@@ -308,13 +298,13 @@ private void selectDrawerItem(MenuItem menuItem, @NavigationSource int navigatio
// First check if it are settings, then we don't update anything.
if (menuItem.getItemId() == R.id.drawer_pref) {
- drawer.closeDrawer(GravityCompat.START);
+ binding.drawerLayout.closeDrawer(GravityCompat.START);
PreferenceActivity.start(this, null);
return;
}
if (menuItem.getItemId() == R.id.drawer_ufora) {
- drawer.closeDrawer(GravityCompat.START);
+ binding.drawerLayout.closeDrawer(GravityCompat.START);
Intent launchIntent = getPackageManager().getLaunchIntentForPackage(UFORA);
if (launchIntent != null) {
startActivity(launchIntent);
@@ -379,13 +369,13 @@ private void selectDrawerItem(MenuItem menuItem, @NavigationSource int navigatio
// Show the toolbar, in case the new fragment is not scrollable. We must do this before the fragment
// begins animating, otherwise glitches can occur.
- appBarLayout.setExpanded(true);
+ binding.appBarLayout.setExpanded(true);
- if (drawer.isDrawerOpen(GravityCompat.START)) {
+ if (binding.drawerLayout.isDrawerOpen(GravityCompat.START)) {
// Hide the current fragment now, similar to how GMail handles things.
if (current != null && current.getView() != null) {
current.getView().setVisibility(View.GONE);
- drawerLoader.setVisibility(View.VISIBLE);
+ binding.progressBar.progressBar.setVisibility(View.VISIBLE);
}
// Since there will be a delay, notify the fragment to prevent lingering snackbars or action modes.
if (current instanceof ScheduledRemovalListener) {
@@ -412,7 +402,7 @@ private void updateDrawer(Fragment fragment, MenuItem item) {
Reporting.getTracker(this)
.setCurrentScreen(this, item.getTitle().toString(), fragment.getClass().getSimpleName());
// Close the navigation drawer
- drawer.closeDrawer(GravityCompat.START);
+ binding.drawerLayout.closeDrawer(GravityCompat.START);
}
/**
@@ -447,7 +437,7 @@ private void setFragment(Fragment fragment, MenuItem menuItem, @NavigationSource
transaction.commitAllowingStateLoss();
// Hide the loader.
- drawerLoader.setVisibility(View.GONE);
+ binding.progressBar.progressBar.setVisibility(View.GONE);
}
/**
@@ -457,8 +447,8 @@ private void setFragment(Fragment fragment, MenuItem menuItem, @NavigationSource
@Override
public void onBackPressed() {
// If the drawer is open, close it.
- if (drawer.isDrawerOpen(GravityCompat.START)) {
- drawer.closeDrawer(GravityCompat.START);
+ if (binding.drawerLayout.isDrawerOpen(GravityCompat.START)) {
+ binding.drawerLayout.closeDrawer(GravityCompat.START);
return;
}
@@ -470,7 +460,7 @@ public void onBackPressed() {
if (current == null) {
return;
}
- MenuItem item = navigationView.getMenu().findItem(getFragmentMenuId(current));
+ MenuItem item = binding.navigationView.getMenu().findItem(getFragmentMenuId(current));
updateDrawer(current, item);
};
// We need to listen to the back stack to update the drawer.
@@ -553,7 +543,7 @@ protected void onNewIntent(Intent intent) {
if (intent.hasExtra(ARG_TAB)) {
setIntent(intent);
int start = intent.getIntExtra(ARG_TAB, R.id.drawer_feed);
- selectDrawerItem(navigationView.getMenu().findItem(start), NavigationSource.INNER);
+ selectDrawerItem(binding.navigationView.getMenu().findItem(start), NavigationSource.INNER);
}
}
diff --git a/app/src/main/java/be/ugent/zeus/hydra/association/Association.java b/app/src/main/java/be/ugent/zeus/hydra/association/Association.java
index dcd48d207..9d59035c5 100644
--- a/app/src/main/java/be/ugent/zeus/hydra/association/Association.java
+++ b/app/src/main/java/be/ugent/zeus/hydra/association/Association.java
@@ -4,6 +4,8 @@
import android.os.Parcelable;
import androidx.annotation.NonNull;
+import java.util.Locale;
+
import be.ugent.zeus.hydra.common.network.Endpoints;
import com.squareup.moshi.Json;
import java9.util.Objects;
@@ -63,7 +65,7 @@ public String getParentAssociation() {
}
public String getImageLink() {
- return String.format(IMAGE_LINK, internalName.toLowerCase());
+ return String.format(IMAGE_LINK, internalName.toLowerCase(Locale.ROOT));
}
public static final Creator CREATOR = new Creator() {
diff --git a/app/src/main/java/be/ugent/zeus/hydra/association/event/DisabledEventRemover.java b/app/src/main/java/be/ugent/zeus/hydra/association/event/DisabledEventRemover.java
index 14868163c..f316c0cbf 100644
--- a/app/src/main/java/be/ugent/zeus/hydra/association/event/DisabledEventRemover.java
+++ b/app/src/main/java/be/ugent/zeus/hydra/association/event/DisabledEventRemover.java
@@ -8,6 +8,7 @@
import java9.util.stream.StreamSupport;
import java.util.List;
+import java.util.Locale;
import java.util.Set;
import static be.ugent.zeus.hydra.association.preference.AssociationSelectionPreferenceFragment.PREF_ASSOCIATIONS_SHOWING;
@@ -31,7 +32,7 @@ public List apply(List events) {
.map(String::toLowerCase)
.collect(Collectors.toSet());
return StreamSupport.stream(events)
- .filter(event -> !disabled.contains(event.getAssociation().getInternalName().toLowerCase()))
+ .filter(event -> !disabled.contains(event.getAssociation().getInternalName().toLowerCase(Locale.ROOT)))
.collect(Collectors.toList());
}
}
diff --git a/app/src/main/java/be/ugent/zeus/hydra/association/event/EventDetailsActivity.java b/app/src/main/java/be/ugent/zeus/hydra/association/event/EventDetailsActivity.java
index 0e125d785..6e4ae830a 100644
--- a/app/src/main/java/be/ugent/zeus/hydra/association/event/EventDetailsActivity.java
+++ b/app/src/main/java/be/ugent/zeus/hydra/association/event/EventDetailsActivity.java
@@ -5,21 +5,21 @@
import android.net.Uri;
import android.os.Bundle;
import android.provider.CalendarContract;
-import androidx.annotation.Nullable;
-import androidx.core.text.util.LinkifyCompat;
import android.text.util.Linkify;
import android.view.Menu;
import android.view.MenuItem;
import android.widget.ImageView;
import android.widget.LinearLayout;
-import android.widget.TextView;
import android.widget.Toast;
+import androidx.annotation.Nullable;
+import androidx.core.text.util.LinkifyCompat;
import be.ugent.zeus.hydra.R;
-import be.ugent.zeus.hydra.common.reporting.Reporting;
import be.ugent.zeus.hydra.common.reporting.BaseEvents;
+import be.ugent.zeus.hydra.common.reporting.Reporting;
import be.ugent.zeus.hydra.common.ui.BaseActivity;
import be.ugent.zeus.hydra.common.utils.NetworkUtils;
+import be.ugent.zeus.hydra.databinding.ActivityEventDetailBinding;
import com.squareup.picasso.Callback;
import com.squareup.picasso.Picasso;
import org.threeten.bp.format.DateTimeFormatter;
@@ -29,7 +29,7 @@
*
* @author Niko Strijbol
*/
-public class EventDetailsActivity extends BaseActivity {
+public class EventDetailsActivity extends BaseActivity {
public static final String PARCEL_EVENT = "eventParcelable";
private static final DateTimeFormatter format = DateTimeFormatter.ofPattern("dd/MM/yyyy HH:mm");
@@ -46,59 +46,51 @@ public static Intent start(Context context, Event event) {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
- setContentView(R.layout.activity_event_detail);
+ setContentView(ActivityEventDetailBinding::inflate);
//Get data from saved instance, or from intent
event = getIntent().getParcelableExtra(PARCEL_EVENT);
+ assert event != null;
- TextView title = findViewById(R.id.title);
- TextView location = findViewById(R.id.location);
- TextView description = findViewById(R.id.description);
- final ImageView organisatorImage = findViewById(R.id.event_organisator_image);
- TextView mainName = findViewById(R.id.event_organisator_main);
- TextView smallName = findViewById(R.id.event_organisator_small);
if (event.getTitle() != null) {
- title.setText(event.getTitle());
+ binding.title.setText(event.getTitle());
requireToolbar().setTitle(event.getTitle());
}
if (event.getAssociation() != null) {
- mainName.setText(event.getAssociation().getDisplayName());
- smallName.setText(event.getAssociation().getFullName());
+ binding.eventOrganisatorMain.setText(event.getAssociation().getDisplayName());
+ binding.eventOrganisatorSmall.setText(event.getAssociation().getFullName());
}
if (event.getDescription() != null && !event.getDescription().trim().isEmpty()) {
- description.setText(event.getDescription());
- LinkifyCompat.addLinks(description, Linkify.ALL);
+ binding.description.setText(event.getDescription());
+ LinkifyCompat.addLinks(binding.description, Linkify.ALL);
}
if (event.hasPreciseLocation() || event.hasLocation()) {
if (event.hasLocation()) {
- location.setText(event.getLocation());
+ binding.location.setText(event.getLocation());
} else {
- location.setText(getString(R.string.event_detail_precise_location, event.getLatitude(), event.getLongitude()));
+ binding.location.setText(getString(R.string.event_detail_precise_location, event.getLatitude(), event.getLongitude()));
}
// Make location clickable
- findViewById(R.id.location_row).setOnClickListener(view -> NetworkUtils.maybeLaunchIntent(this, getLocationIntent()));
+ binding.locationRow.setOnClickListener(view -> NetworkUtils.maybeLaunchIntent(this, getLocationIntent()));
} else {
- location.setText(R.string.event_detail_no_location);
+ binding.location.setText(R.string.event_detail_no_location);
}
- TextView startTime = findViewById(R.id.time_start);
- TextView endTime = findViewById(R.id.time_end);
-
- startTime.setText(event.getLocalStart().format(format));
+ binding.timeStart.setText(event.getLocalStart().format(format));
if (event.getLocalEnd() != null) {
- endTime.setText(event.getLocalEnd().format(format));
+ binding.timeEnd.setText(event.getLocalEnd().format(format));
} else {
- endTime.setText(R.string.event_detail_date_unknown);
+ binding.timeEnd.setText(R.string.event_detail_date_unknown);
}
if (event.getAssociation() != null) {
- Picasso.get().load(event.getAssociation().getImageLink()).into(organisatorImage, new EventCallback(organisatorImage));
+ Picasso.get().load(event.getAssociation().getImageLink()).into(binding.eventOrganisatorImage, new EventCallback(binding.eventOrganisatorImage));
} else {
- organisatorImage.setLayoutParams(new LinearLayout.LayoutParams(0, 0));
+ binding.eventOrganisatorImage.setLayoutParams(new LinearLayout.LayoutParams(0, 0));
}
Reporting.getTracker(this)
diff --git a/app/src/main/java/be/ugent/zeus/hydra/association/event/list/EventFragment.java b/app/src/main/java/be/ugent/zeus/hydra/association/event/list/EventFragment.java
index 4c91398f5..58aef4b8e 100644
--- a/app/src/main/java/be/ugent/zeus/hydra/association/event/list/EventFragment.java
+++ b/app/src/main/java/be/ugent/zeus/hydra/association/event/list/EventFragment.java
@@ -9,7 +9,7 @@
import androidx.annotation.Nullable;
import androidx.appcompat.widget.SearchView;
import androidx.fragment.app.Fragment;
-import androidx.lifecycle.ViewModelProviders;
+import androidx.lifecycle.ViewModelProvider;
import androidx.recyclerview.widget.RecyclerView;
import androidx.swiperefreshlayout.widget.SwipeRefreshLayout;
@@ -18,9 +18,9 @@
import be.ugent.zeus.hydra.common.arch.observers.PartialErrorObserver;
import be.ugent.zeus.hydra.common.arch.observers.ProgressObserver;
import be.ugent.zeus.hydra.common.ui.recyclerview.EmptyViewObserver;
+import be.ugent.zeus.hydra.common.utils.ColourUtils;
import be.ugent.zeus.hydra.preferences.PreferenceActivity;
import be.ugent.zeus.hydra.preferences.PreferenceEntry;
-import be.ugent.zeus.hydra.common.utils.ColourUtils;
import com.google.android.material.snackbar.Snackbar;
import static be.ugent.zeus.hydra.common.utils.FragmentUtils.requireBaseActivity;
@@ -65,11 +65,11 @@ public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceStat
SwipeRefreshLayout swipeRefreshLayout = view.findViewById(R.id.swipeRefreshLayout);
swipeRefreshLayout.setColorSchemeColors(secondaryColour);
- viewModel = ViewModelProviders.of(this).get(EventViewModel.class);
- viewModel.getData().observe(this, PartialErrorObserver.with(this::onError));
- viewModel.getData().observe(this, new ProgressObserver<>(view.findViewById(R.id.progress_bar)));
- viewModel.getData().observe(this, new AdapterObserver<>(adapter));
- viewModel.getRefreshing().observe(this, swipeRefreshLayout::setRefreshing);
+ viewModel = new ViewModelProvider(this).get(EventViewModel.class);
+ viewModel.getData().observe(getViewLifecycleOwner(), PartialErrorObserver.with(this::onError));
+ viewModel.getData().observe(getViewLifecycleOwner(), new ProgressObserver<>(view.findViewById(R.id.progress_bar)));
+ viewModel.getData().observe(getViewLifecycleOwner(), new AdapterObserver<>(adapter));
+ viewModel.getRefreshing().observe(getViewLifecycleOwner(), swipeRefreshLayout::setRefreshing);
swipeRefreshLayout.setOnRefreshListener(viewModel);
Button refresh = view.findViewById(R.id.events_no_data_button_refresh);
diff --git a/app/src/main/java/be/ugent/zeus/hydra/association/event/list/EventSearchPredicate.java b/app/src/main/java/be/ugent/zeus/hydra/association/event/list/EventSearchPredicate.java
index 20bbe43c4..ed1c1010f 100644
--- a/app/src/main/java/be/ugent/zeus/hydra/association/event/list/EventSearchPredicate.java
+++ b/app/src/main/java/be/ugent/zeus/hydra/association/event/list/EventSearchPredicate.java
@@ -1,5 +1,7 @@
package be.ugent.zeus.hydra.association.event.list;
+import java.util.Locale;
+
import be.ugent.zeus.hydra.association.Association;
import be.ugent.zeus.hydra.association.event.Event;
import java9.util.function.BiPredicate;
@@ -22,15 +24,15 @@ public boolean test(EventItem eventItem, String searchTerm) {
return true;
}
Event event = eventItem.getItem();
- if (event.getTitle() != null && event.getTitle().toLowerCase().contains(searchTerm)) {
+ if (event.getTitle() != null && event.getTitle().toLowerCase(Locale.getDefault()).contains(searchTerm)) {
return true;
}
if (event.getAssociation() != null) {
Association association = event.getAssociation();
- if (association.getDisplayName() != null && association.getDisplayName().toLowerCase().contains(searchTerm)) {
+ if (association.getDisplayName() != null && association.getDisplayName().toLowerCase(Locale.ROOT).contains(searchTerm)) {
return true;
}
- if (association.getFullName() != null && association.getFullName().toLowerCase().contains(searchTerm)) {
+ if (association.getFullName() != null && association.getFullName().toLowerCase(Locale.getDefault()).contains(searchTerm)) {
return true;
}
if (association.getInternalName().contains(searchTerm)) {
diff --git a/app/src/main/java/be/ugent/zeus/hydra/association/preference/AssociationSelectionPreferenceFragment.java b/app/src/main/java/be/ugent/zeus/hydra/association/preference/AssociationSelectionPreferenceFragment.java
index 05174dcfb..f5a15becc 100644
--- a/app/src/main/java/be/ugent/zeus/hydra/association/preference/AssociationSelectionPreferenceFragment.java
+++ b/app/src/main/java/be/ugent/zeus/hydra/association/preference/AssociationSelectionPreferenceFragment.java
@@ -5,13 +5,11 @@
import android.util.Log;
import android.util.Pair;
import android.view.*;
-
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.appcompat.widget.SearchView;
import androidx.fragment.app.Fragment;
import androidx.lifecycle.ViewModelProvider;
-import androidx.lifecycle.ViewModelProviders;
import androidx.preference.PreferenceManager;
import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;
diff --git a/app/src/main/java/be/ugent/zeus/hydra/association/preference/SearchableAssociationsAdapter.java b/app/src/main/java/be/ugent/zeus/hydra/association/preference/SearchableAssociationsAdapter.java
index 170e9c762..e7b7b3bc7 100644
--- a/app/src/main/java/be/ugent/zeus/hydra/association/preference/SearchableAssociationsAdapter.java
+++ b/app/src/main/java/be/ugent/zeus/hydra/association/preference/SearchableAssociationsAdapter.java
@@ -10,6 +10,7 @@
import be.ugent.zeus.hydra.common.ui.recyclerview.adapters.MultiSelectSearchableAdapter;
import java.util.Collections;
+import java.util.Locale;
/**
*
@@ -18,9 +19,9 @@
class SearchableAssociationsAdapter extends MultiSelectSearchableAdapter {
SearchableAssociationsAdapter() {
- super(text -> a -> a.getDisplayName().toLowerCase().contains(text) ||
- (a.getFullName() != null && a.getFullName().toLowerCase().contains(text)) ||
- a.getInternalName().toLowerCase().contains(text));
+ super(text -> a -> a.getDisplayName().toLowerCase(Locale.getDefault()).contains(text) ||
+ (a.getFullName() != null && a.getFullName().toLowerCase(Locale.getDefault()).contains(text)) ||
+ a.getInternalName().toLowerCase(Locale.ROOT).contains(text));
}
@NonNull
diff --git a/app/src/main/java/be/ugent/zeus/hydra/common/arch/observers/ProgressObserver.java b/app/src/main/java/be/ugent/zeus/hydra/common/arch/observers/ProgressObserver.java
index 1d37a40a9..1034c1f71 100644
--- a/app/src/main/java/be/ugent/zeus/hydra/common/arch/observers/ProgressObserver.java
+++ b/app/src/main/java/be/ugent/zeus/hydra/common/arch/observers/ProgressObserver.java
@@ -1,22 +1,30 @@
package be.ugent.zeus.hydra.common.arch.observers;
+import androidx.annotation.NonNull;
import androidx.lifecycle.Observer;
import androidx.annotation.Nullable;
import android.view.View;
import android.widget.ProgressBar;
import be.ugent.zeus.hydra.common.request.Result;
+import be.ugent.zeus.hydra.databinding.XProgressBarBinding;
/**
+ * Observes a progress bar and hides it once the data is loaded.
+ *
* @author Niko Strijbol
*/
public class ProgressObserver implements Observer> {
private final ProgressBar progressBar;
- public ProgressObserver(ProgressBar progressBar) {
+ public ProgressObserver(@NonNull ProgressBar progressBar) {
this.progressBar = progressBar;
}
+ public ProgressObserver(@NonNull XProgressBarBinding binding) {
+ this.progressBar = binding.progressBar;
+ }
+
@Override
public void onChanged(@Nullable Result result) {
if (result == null || result.isDone()) {
diff --git a/app/src/main/java/be/ugent/zeus/hydra/common/network/InstanceProvider.java b/app/src/main/java/be/ugent/zeus/hydra/common/network/InstanceProvider.java
index 205f26e4e..e3423072c 100644
--- a/app/src/main/java/be/ugent/zeus/hydra/common/network/InstanceProvider.java
+++ b/app/src/main/java/be/ugent/zeus/hydra/common/network/InstanceProvider.java
@@ -2,8 +2,6 @@
import android.content.Context;
import android.os.Build;
-import android.util.Log;
-
import androidx.annotation.VisibleForTesting;
import java.io.File;
@@ -11,11 +9,6 @@
import be.ugent.zeus.hydra.common.converter.BooleanJsonAdapter;
import be.ugent.zeus.hydra.common.converter.DateThreeTenAdapter;
import be.ugent.zeus.hydra.common.converter.DateTypeConverters;
-
-import com.google.android.gms.common.GoogleApiAvailability;
-import com.google.android.gms.common.GooglePlayServicesNotAvailableException;
-import com.google.android.gms.common.GooglePlayServicesRepairableException;
-import com.google.android.gms.security.ProviderInstaller;
import com.squareup.moshi.Moshi;
import okhttp3.Cache;
import okhttp3.OkHttpClient;
@@ -27,8 +20,6 @@
*/
public final class InstanceProvider {
- private static final String TAG = "InstanceProvider";
-
private static OkHttpClient client;
private static final long CACHE_SIZE = 20 * 1024 * 1024; // 20 MiB
@@ -63,7 +54,7 @@ public static OkHttpClient.Builder getBuilder(File cacheDir) {
public static synchronized OkHttpClient getClient(Context context) {
if (Build.VERSION.SDK_INT <= 20) {
- installGoogleProvider(context);
+ CertificateProvider.installProvider(context);
}
File cacheDir = new File(context.getCacheDir(), "http");
@@ -90,17 +81,4 @@ public static void reset() {
client = null;
moshi = null;
}
-
- private static void installGoogleProvider(Context context) {
- Log.i(TAG, "Installing Play Services to enable TLSv1.2");
- try {
- ProviderInstaller.installIfNeeded(context);
- } catch (GooglePlayServicesRepairableException e) {
- Log.w(TAG, "Play Services are outdated", e);
- // Prompt the user to install/update/enable Google Play services.
- GoogleApiAvailability.getInstance().showErrorNotification(context, e.getConnectionStatusCode());
- } catch (GooglePlayServicesNotAvailableException e) {
- Log.e(TAG, "Unable to install provider, SSL will not work", e);
- }
- }
}
\ No newline at end of file
diff --git a/app/src/main/java/be/ugent/zeus/hydra/common/reporting/Reporting.java b/app/src/main/java/be/ugent/zeus/hydra/common/reporting/Manager.java
similarity index 67%
rename from app/src/main/java/be/ugent/zeus/hydra/common/reporting/Reporting.java
rename to app/src/main/java/be/ugent/zeus/hydra/common/reporting/Manager.java
index a245c86ea..2e6d8b5f5 100644
--- a/app/src/main/java/be/ugent/zeus/hydra/common/reporting/Reporting.java
+++ b/app/src/main/java/be/ugent/zeus/hydra/common/reporting/Manager.java
@@ -3,44 +3,21 @@
import android.content.Context;
import android.content.SharedPreferences;
import android.util.Log;
-import androidx.annotation.VisibleForTesting;
import androidx.preference.PreferenceManager;
+
import be.ugent.zeus.hydra.BuildConfig;
/**
- * Produces the default tracker.
+ * Manage reporting permissions.
*
* @author Niko Strijbol
*/
-public final class Reporting {
+public class Manager {
private static final String TAG = "Reporting";
-
private static final String PREF_ALLOW_ANALYTICS = "be.ugent.zeus.hydra.reporting.allow_analytics";
private static final String PREF_ALLOW_CRASH_REPORTING = "be.ugent.zeus.hydra.reporting.allow_crash_reporting";
- private static Tracker tracker;
- private final static Object lock = new Object();
-
- /**
- * Get the default tracker.
- *
- * @param context The context.
- * @return The tracker.
- */
- public static Tracker getTracker(Context context) {
- synchronized (lock) {
- if (tracker == null) {
- tracker = new FirebaseTracker(context);
- }
- }
- return tracker;
- }
-
- public static BaseEvents getEvents() {
- return FirebaseEvents.getInstance();
- }
-
public static void saveAnalyticsPermission(Context context, boolean allowed) {
SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(context);
preferences.edit()
@@ -65,7 +42,7 @@ public static void saveCrashReportingPermission(Context context, boolean allowed
*/
public static void syncPermissions(Context context) {
SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(context);
- Tracker tracker = getTracker(context);
+ Tracker tracker = Reporting.getTracker(context);
// Enable or disable analytics
boolean areAnalyticsAllowed = preferences.getBoolean(PREF_ALLOW_ANALYTICS, false) && allowDebugReporting();
@@ -79,17 +56,6 @@ public static void syncPermissions(Context context) {
}
public static boolean allowDebugReporting() {
- // If a DEBUG build, use the property, otherwise OK!
- if (BuildConfig.DEBUG) {
- Log.d(TAG, "allowDebugReporting: this is debug mode");
- return BuildConfig.DEBUG_ENABLE_REPORTING;
- } else {
- return true;
- }
- }
-
- @VisibleForTesting
- public static void setTracker(Tracker tracker) {
- Reporting.tracker = tracker;
+ return BuildConfig.DEBUG_ENABLE_REPORTING;
}
}
diff --git a/app/src/main/java/be/ugent/zeus/hydra/common/reporting/Tracker.java b/app/src/main/java/be/ugent/zeus/hydra/common/reporting/Tracker.java
index 5190b1ab3..3bb30ee62 100644
--- a/app/src/main/java/be/ugent/zeus/hydra/common/reporting/Tracker.java
+++ b/app/src/main/java/be/ugent/zeus/hydra/common/reporting/Tracker.java
@@ -36,6 +36,7 @@ public interface Tracker {
* @param classOverride The name of the screen class. By default, this is the current activity.
*/
@MainThread
+ @SuppressWarnings("EmptyMethod")
void setCurrentScreen(@NonNull Activity activity, String screenName, String classOverride);
/**
@@ -53,13 +54,6 @@ public interface Tracker {
*/
void logError(Throwable throwable);
- /**
- * Log an error string to the crash service.
- *
- * @param message The message to log.
- */
- void logErrorMessage(String message);
-
/**
* Configure the underlying service to allow analytics or not.
*
diff --git a/app/src/main/java/be/ugent/zeus/hydra/common/ui/BaseActivity.java b/app/src/main/java/be/ugent/zeus/hydra/common/ui/BaseActivity.java
index d4b740315..addf490e0 100644
--- a/app/src/main/java/be/ugent/zeus/hydra/common/ui/BaseActivity.java
+++ b/app/src/main/java/be/ugent/zeus/hydra/common/ui/BaseActivity.java
@@ -1,29 +1,44 @@
package be.ugent.zeus.hydra.common.ui;
import android.graphics.drawable.Drawable;
+import android.view.LayoutInflater;
+import android.view.Menu;
import androidx.annotation.ColorInt;
-import androidx.annotation.LayoutRes;
import androidx.annotation.NonNull;
-import androidx.core.graphics.drawable.DrawableCompat;
import androidx.appcompat.app.ActionBar;
import androidx.appcompat.app.AppCompatActivity;
import androidx.appcompat.widget.Toolbar;
-import android.view.Menu;
+import androidx.core.app.ActivityCompat;
+import androidx.core.graphics.drawable.DrawableCompat;
+import androidx.viewbinding.ViewBinding;
+
+import java9.util.function.Function;
import be.ugent.zeus.hydra.R;
import be.ugent.zeus.hydra.common.utils.ColourUtils;
/**
* The base activity. Contains code related to common things for almost all activities.
+ *
* Such features include:
*
*
Support for the toolbar
*
Better Google Reporting support
+ *
View binding, see below.
*
*
+ *
+ *
View binding
+ *
+ * This activity requires the use of view binding. To set up the view on the
+ * activity, call {@link #setContentView(Function)}, to which you must pass
+ * the view binding constructor.
+ *
* @author Niko Strijbol
*/
-public abstract class BaseActivity extends AppCompatActivity {
+public abstract class BaseActivity extends AppCompatActivity {
+
+ protected B binding;
/**
* Returns the action bar of this activity. If the ActionBar is not present or the method is called at the wrong
@@ -42,15 +57,11 @@ public ActionBar requireToolbar() {
}
}
- private Toolbar findToolbar() {
- return findViewById(R.id.toolbar);
- }
-
/**
* Set the toolbar as action bar, and set it up to have an up button.
*/
private void setUpActionBar() {
- Toolbar toolbar = findToolbar();
+ Toolbar toolbar = ActivityCompat.requireViewById(this, R.id.toolbar);
setSupportActionBar(toolbar);
@@ -60,9 +71,9 @@ private void setUpActionBar() {
}
}
- @Override
- public void setContentView(@LayoutRes int layoutResID) {
- super.setContentView(layoutResID);
+ public void setContentView(Function binder) {
+ this.binding = binder.apply(getLayoutInflater());
+ setContentView(this.binding.getRoot());
setUpActionBar();
}
diff --git a/app/src/main/java/be/ugent/zeus/hydra/common/ui/WebViewActivity.java b/app/src/main/java/be/ugent/zeus/hydra/common/ui/WebViewActivity.java
index 32972a7b6..f45531317 100644
--- a/app/src/main/java/be/ugent/zeus/hydra/common/ui/WebViewActivity.java
+++ b/app/src/main/java/be/ugent/zeus/hydra/common/ui/WebViewActivity.java
@@ -8,15 +8,15 @@
import android.webkit.WebView;
import android.widget.ProgressBar;
-import be.ugent.zeus.hydra.R;
import be.ugent.zeus.hydra.common.network.InterceptingWebViewClient;
+import be.ugent.zeus.hydra.databinding.ActivityWebviewBinding;
/**
* Displays a web view.
*
* @author Niko Strijbol
*/
-public class WebViewActivity extends BaseActivity {
+public class WebViewActivity extends BaseActivity {
public static final String URL = "be.ugent.zeus.hydra.url";
public static final String TITLE = "be.ugent.zeus.hydra.title";
@@ -25,13 +25,10 @@ public class WebViewActivity extends BaseActivity {
@SuppressLint("SetJavaScriptEnabled")
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
- setContentView(R.layout.activity_webview);
+ setContentView(ActivityWebviewBinding::inflate);
- WebView webView = findViewById(R.id.web_view);
- ProgressBar progressBar = findViewById(R.id.progress_bar);
-
- webView.getSettings().setJavaScriptEnabled(true);
- webView.setWebViewClient(new ProgressClient(progressBar, this));
+ binding.webView.getSettings().setJavaScriptEnabled(true);
+ binding.webView.setWebViewClient(new ProgressClient(binding.progressBar.progressBar, this));
Intent intent = getIntent();
String url = intent.getStringExtra(URL);
@@ -41,7 +38,7 @@ protected void onCreate(Bundle savedInstanceState) {
getSupportActionBar().setTitle(title);
}
- webView.loadUrl(url);
+ binding.webView.loadUrl(url);
}
private static class ProgressClient extends InterceptingWebViewClient {
diff --git a/app/src/main/java/be/ugent/zeus/hydra/common/ui/customtabs/ActivityHelper.java b/app/src/main/java/be/ugent/zeus/hydra/common/ui/customtabs/ActivityHelper.java
index cde27e245..445fb9adc 100644
--- a/app/src/main/java/be/ugent/zeus/hydra/common/ui/customtabs/ActivityHelper.java
+++ b/app/src/main/java/be/ugent/zeus/hydra/common/ui/customtabs/ActivityHelper.java
@@ -3,8 +3,6 @@
import android.app.Activity;
import android.net.Uri;
import android.os.Bundle;
-import androidx.annotation.Nullable;
-import androidx.browser.customtabs.CustomTabsCallback;
import java.util.List;
diff --git a/app/src/main/java/be/ugent/zeus/hydra/common/ui/recyclerview/adapters/SearchableAdapter.java b/app/src/main/java/be/ugent/zeus/hydra/common/ui/recyclerview/adapters/SearchableAdapter.java
index f98d4f964..7fdaaa738 100644
--- a/app/src/main/java/be/ugent/zeus/hydra/common/ui/recyclerview/adapters/SearchableAdapter.java
+++ b/app/src/main/java/be/ugent/zeus/hydra/common/ui/recyclerview/adapters/SearchableAdapter.java
@@ -90,7 +90,7 @@ public boolean onQueryTextChange(String newText) {
}
this.isSearching = true;
List filtered = StreamSupport.stream(allData)
- .filter(s -> searchPredicate.test(s, newText.toLowerCase()))
+ .filter(s -> searchPredicate.test(s, newText.toLowerCase(Locale.getDefault())))
.collect(Collectors.toList());
filtered = filter.apply(filtered);
super.submitData(filtered);
diff --git a/app/src/main/java/be/ugent/zeus/hydra/common/ui/recyclerview/viewholders/DateHeaderViewHolder.java b/app/src/main/java/be/ugent/zeus/hydra/common/ui/recyclerview/viewholders/DateHeaderViewHolder.java
index f4eb6c157..185a08a7b 100644
--- a/app/src/main/java/be/ugent/zeus/hydra/common/ui/recyclerview/viewholders/DateHeaderViewHolder.java
+++ b/app/src/main/java/be/ugent/zeus/hydra/common/ui/recyclerview/viewholders/DateHeaderViewHolder.java
@@ -1,11 +1,15 @@
package be.ugent.zeus.hydra.common.ui.recyclerview.viewholders;
import android.content.Context;
+import android.text.TextUtils;
import android.view.View;
import android.widget.TextView;
+import java.util.Locale;
+
import be.ugent.zeus.hydra.R;
import be.ugent.zeus.hydra.common.utils.DateUtils;
+import be.ugent.zeus.hydra.common.utils.StringUtils;
import org.threeten.bp.LocalDate;
import org.threeten.bp.OffsetDateTime;
import org.threeten.bp.format.FormatStyle;
@@ -31,7 +35,7 @@ public void populate(OffsetDateTime date) {
public static String format(Context context, LocalDate localDate) {
String date = DateUtils.getFriendlyDate(context, localDate, FormatStyle.LONG);
- date = date.substring(0, 1).toUpperCase() + date.substring(1);
+ date = StringUtils.capitaliseFirst(date);
return date;
}
}
diff --git a/app/src/main/java/be/ugent/zeus/hydra/common/ui/widgets/ButtonBarLayout.java b/app/src/main/java/be/ugent/zeus/hydra/common/ui/widgets/ButtonBarLayout.java
index db81208f3..96c8886f5 100644
--- a/app/src/main/java/be/ugent/zeus/hydra/common/ui/widgets/ButtonBarLayout.java
+++ b/app/src/main/java/be/ugent/zeus/hydra/common/ui/widgets/ButtonBarLayout.java
@@ -1,5 +1,6 @@
/*
* Copyright (C) 2015 The Android Open Source Project
+ * Copyright (C) 2020 Niko Strijbol
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -15,7 +16,6 @@
*/
package be.ugent.zeus.hydra.common.ui.widgets;
-import android.annotation.SuppressLint;
import android.content.Context;
import android.content.res.TypedArray;
import android.os.Build;
@@ -133,7 +133,6 @@ public int getMinimumHeight() {
return Math.max(mMinimumHeight, super.getMinimumHeight());
}
- @SuppressLint("RtlHardcoded")
private void setStacked(boolean stacked) {
setOrientation(stacked ? LinearLayout.VERTICAL : LinearLayout.HORIZONTAL);
setGravity(stacked ? Gravity.RIGHT : Gravity.BOTTOM);
diff --git a/app/src/main/java/be/ugent/zeus/hydra/common/ui/widgets/DisplayableMenu.java b/app/src/main/java/be/ugent/zeus/hydra/common/ui/widgets/DisplayableMenu.java
index d5bc6bc31..6422a0079 100644
--- a/app/src/main/java/be/ugent/zeus/hydra/common/ui/widgets/DisplayableMenu.java
+++ b/app/src/main/java/be/ugent/zeus/hydra/common/ui/widgets/DisplayableMenu.java
@@ -1,15 +1,14 @@
package be.ugent.zeus.hydra.common.ui.widgets;
import android.content.Context;
-import androidx.annotation.DrawableRes;
-import androidx.appcompat.content.res.AppCompatResources;
-import androidx.core.content.res.TypedArrayUtils;
import android.view.Gravity;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.TableRow;
import android.widget.TextView;
+import androidx.annotation.DrawableRes;
+import androidx.appcompat.content.res.AppCompatResources;
import java.util.List;
@@ -40,7 +39,7 @@ public class DisplayableMenu {
DisplayableMenu(Context context, RestoMenu menu, boolean selectable) {
this.menu = menu;
this.selectable = selectable;
- normalStyle = TypedArrayUtils.getAttr(context, R.attr.textAppearanceBody2, 0);
+ normalStyle = ViewUtils.getAttr(context, R.attr.textAppearanceBody2);
}
/**
diff --git a/app/src/main/java/be/ugent/zeus/hydra/common/ui/widgets/MenuTable.java b/app/src/main/java/be/ugent/zeus/hydra/common/ui/widgets/MenuTable.java
index af81a7bde..921aad16a 100644
--- a/app/src/main/java/be/ugent/zeus/hydra/common/ui/widgets/MenuTable.java
+++ b/app/src/main/java/be/ugent/zeus/hydra/common/ui/widgets/MenuTable.java
@@ -7,17 +7,16 @@
import android.widget.TableLayout;
import android.widget.TableRow;
import android.widget.TextView;
-
import androidx.annotation.IntDef;
import androidx.annotation.Nullable;
import androidx.annotation.VisibleForTesting;
-import androidx.core.content.res.TypedArrayUtils;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import be.ugent.zeus.hydra.R;
import be.ugent.zeus.hydra.common.ui.html.Utils;
+import be.ugent.zeus.hydra.common.utils.ViewUtils;
import be.ugent.zeus.hydra.resto.RestoMenu;
import com.google.android.material.textview.MaterialTextView;
@@ -78,7 +77,7 @@ private void init(Context context, @Nullable AttributeSet attrs) {
selectable = a.getBoolean(R.styleable.MenuTable_selectable, false);
showTitles = a.getBoolean(R.styleable.MenuTable_showTitles, false);
messagePaddingTop = a.getBoolean(R.styleable.MenuTable_messagePaddingTop, false);
- normalStyle = TypedArrayUtils.getAttr(context, R.attr.textAppearanceBody2, 0);
+ normalStyle = ViewUtils.getAttr(context, R.attr.textAppearanceBody2);
} finally {
a.recycle();
}
diff --git a/app/src/main/java/be/ugent/zeus/hydra/common/ui/widgets/TimePreference.java b/app/src/main/java/be/ugent/zeus/hydra/common/ui/widgets/TimePreference.java
index e26210e2e..99459533a 100644
--- a/app/src/main/java/be/ugent/zeus/hydra/common/ui/widgets/TimePreference.java
+++ b/app/src/main/java/be/ugent/zeus/hydra/common/ui/widgets/TimePreference.java
@@ -5,13 +5,12 @@
import android.os.Parcel;
import android.os.Parcelable;
import android.util.AttributeSet;
-
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
-import androidx.core.content.res.TypedArrayUtils;
import androidx.preference.DialogPreference;
import be.ugent.zeus.hydra.R;
+import be.ugent.zeus.hydra.common.utils.ViewUtils;
import org.threeten.bp.LocalTime;
/**
@@ -35,7 +34,7 @@ public TimePreference(Context context, AttributeSet attrs, int defStyleAttr, int
TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.TimePreference, defStyleAttr, defStyleRes);
- if (TypedArrayUtils.getBoolean(a, R.styleable.TimePreference_useDefaultSummary,
+ if (ViewUtils.getBoolean(a, R.styleable.TimePreference_useDefaultSummary,
R.styleable.TimePreference_useDefaultSummary, false)) {
setSummaryProvider(new TimeSummaryProvider());
}
@@ -48,7 +47,7 @@ public TimePreference(Context context, AttributeSet attrs, int defStyleAttr) {
}
public TimePreference(Context context, AttributeSet attrs) {
- this(context, attrs, TypedArrayUtils.getAttr(context,
+ this(context, attrs, ViewUtils.getAttr(context,
androidx.preference.R.attr.dialogPreferenceStyle,
android.R.attr.dialogPreferenceStyle));
}
diff --git a/app/src/main/java/be/ugent/zeus/hydra/common/utils/ColourUtils.java b/app/src/main/java/be/ugent/zeus/hydra/common/utils/ColourUtils.java
index 62e66cade..8c068b56f 100644
--- a/app/src/main/java/be/ugent/zeus/hydra/common/utils/ColourUtils.java
+++ b/app/src/main/java/be/ugent/zeus/hydra/common/utils/ColourUtils.java
@@ -1,9 +1,7 @@
package be.ugent.zeus.hydra.common.utils;
import android.content.Context;
-import android.content.res.Resources;
import android.content.res.TypedArray;
-import android.util.TypedValue;
import androidx.annotation.AttrRes;
import androidx.annotation.ColorInt;
import androidx.core.graphics.ColorUtils;
diff --git a/app/src/main/java/be/ugent/zeus/hydra/common/utils/FragmentUtils.java b/app/src/main/java/be/ugent/zeus/hydra/common/utils/FragmentUtils.java
index c468458e4..1d16ca40a 100644
--- a/app/src/main/java/be/ugent/zeus/hydra/common/utils/FragmentUtils.java
+++ b/app/src/main/java/be/ugent/zeus/hydra/common/utils/FragmentUtils.java
@@ -13,10 +13,10 @@
public class FragmentUtils {
@NonNull
- public static BaseActivity requireBaseActivity(Fragment fragment) {
+ public static BaseActivity> requireBaseActivity(Fragment fragment) {
Activity activity = fragment.requireActivity();
if (activity instanceof BaseActivity) {
- return (BaseActivity) activity;
+ return (BaseActivity>) activity;
} else {
throw new IllegalStateException("This method can only be used if the Fragment is attached to a BaseActivity.");
}
diff --git a/app/src/main/java/be/ugent/zeus/hydra/common/utils/StringUtils.java b/app/src/main/java/be/ugent/zeus/hydra/common/utils/StringUtils.java
index 210821c4e..8c372f239 100644
--- a/app/src/main/java/be/ugent/zeus/hydra/common/utils/StringUtils.java
+++ b/app/src/main/java/be/ugent/zeus/hydra/common/utils/StringUtils.java
@@ -2,6 +2,8 @@
import androidx.annotation.NonNull;
+import java.util.Locale;
+
/**
* @author Niko Strijbol
*/
@@ -15,6 +17,6 @@ public class StringUtils {
* @return Capitalised string.
*/
public static String capitaliseFirst(@NonNull String s) {
- return s.substring(0, 1).toUpperCase() + s.substring(1);
+ return s.substring(0, 1).toUpperCase(Locale.getDefault()) + s.substring(1);
}
}
diff --git a/app/src/main/java/be/ugent/zeus/hydra/common/utils/ViewUtils.java b/app/src/main/java/be/ugent/zeus/hydra/common/utils/ViewUtils.java
index 6aa53af92..8ee134aba 100644
--- a/app/src/main/java/be/ugent/zeus/hydra/common/utils/ViewUtils.java
+++ b/app/src/main/java/be/ugent/zeus/hydra/common/utils/ViewUtils.java
@@ -2,8 +2,10 @@
import android.content.Context;
import android.content.res.Resources;
+import android.content.res.TypedArray;
import android.graphics.drawable.Drawable;
import android.util.DisplayMetrics;
+import android.util.TypedValue;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
@@ -11,8 +13,6 @@
import androidx.appcompat.content.res.AppCompatResources;
import androidx.core.graphics.drawable.DrawableCompat;
-import be.ugent.zeus.hydra.common.utils.ColourUtils;
-
/**
* @author Niko Strijbol
*/
@@ -91,4 +91,30 @@ public static View inflate(ViewGroup parent, @LayoutRes int resource) {
LayoutInflater inflater = LayoutInflater.from(parent.getContext());
return inflater.inflate(resource, parent, false);
}
+
+ /**
+ * @return The resource ID value in the {@code context} specified by {@code attr}.
+ */
+ public static int getAttr(@NonNull Context context, int attr) {
+ return getAttr(context, attr, 0);
+ }
+
+ public static int getAttr(@NonNull Context context, int attr, int defaultAttr) {
+ TypedValue value = new TypedValue();
+ context.getTheme().resolveAttribute(attr, value, true);
+ if (value.resourceId != 0) {
+ return value.resourceId;
+ }
+ return defaultAttr;
+ }
+
+ /**
+ * @return a boolean value of {@code index}. If it does not exist, a boolean value of
+ * {@code fallbackIndex}. If it still does not exist, {@code defaultValue}.
+ */
+ public static boolean getBoolean(@NonNull TypedArray a, @StyleableRes int index,
+ @StyleableRes int fallbackIndex, boolean defaultValue) {
+ boolean val = a.getBoolean(fallbackIndex, defaultValue);
+ return a.getBoolean(index, val);
+ }
}
diff --git a/app/src/main/java/be/ugent/zeus/hydra/feed/FeedViewModel.java b/app/src/main/java/be/ugent/zeus/hydra/feed/FeedViewModel.java
index 40b594d13..326360f5e 100644
--- a/app/src/main/java/be/ugent/zeus/hydra/feed/FeedViewModel.java
+++ b/app/src/main/java/be/ugent/zeus/hydra/feed/FeedViewModel.java
@@ -1,6 +1,7 @@
package be.ugent.zeus.hydra.feed;
import android.app.Application;
+import android.os.AsyncTask;
import androidx.lifecycle.LiveData;
import androidx.lifecycle.MutableLiveData;
@@ -13,7 +14,6 @@
import be.ugent.zeus.hydra.feed.cards.Card;
import be.ugent.zeus.hydra.feed.commands.CommandResult;
import be.ugent.zeus.hydra.feed.commands.FeedCommand;
-import io.fabric.sdk.android.services.concurrency.AsyncTask;
/**
* @author Niko Strijbol
diff --git a/app/src/main/java/be/ugent/zeus/hydra/feed/cards/library/LibraryViewHolder.java b/app/src/main/java/be/ugent/zeus/hydra/feed/cards/library/LibraryViewHolder.java
index 0bd525875..71baf81cb 100644
--- a/app/src/main/java/be/ugent/zeus/hydra/feed/cards/library/LibraryViewHolder.java
+++ b/app/src/main/java/be/ugent/zeus/hydra/feed/cards/library/LibraryViewHolder.java
@@ -7,13 +7,13 @@
import android.widget.LinearLayout;
import android.widget.TableRow;
import android.widget.TextView;
-import androidx.core.content.res.TypedArrayUtils;
import java9.util.Optional;
import be.ugent.zeus.hydra.MainActivity;
import be.ugent.zeus.hydra.R;
import be.ugent.zeus.hydra.common.request.Result;
+import be.ugent.zeus.hydra.common.utils.ViewUtils;
import be.ugent.zeus.hydra.feed.HomeFeedAdapter;
import be.ugent.zeus.hydra.feed.cards.Card;
import be.ugent.zeus.hydra.feed.cards.CardViewHolder;
@@ -38,8 +38,8 @@ public LibraryViewHolder(View itemView, HomeFeedAdapter adapter) {
list = itemView.findViewById(R.id.library_list);
Context c = itemView.getContext();
- styleName = TypedArrayUtils.getAttr(c, R.attr.textAppearanceBody2, 0);
- styleHours = TypedArrayUtils.getAttr(c, R.attr.textAppearanceCaption, 0);
+ styleName = ViewUtils.getAttr(c, R.attr.textAppearanceBody2);
+ styleHours = ViewUtils.getAttr(c, R.attr.textAppearanceCaption);
rowPadding = c.getResources().getDimensionPixelSize(R.dimen.material_baseline_grid_1x);
itemView.setOnClickListener(v -> {
diff --git a/app/src/main/java/be/ugent/zeus/hydra/feed/preferences/HomeFeedPrefActivity.java b/app/src/main/java/be/ugent/zeus/hydra/feed/preferences/HomeFeedPrefActivity.java
index cfe1969c0..ab450780a 100644
--- a/app/src/main/java/be/ugent/zeus/hydra/feed/preferences/HomeFeedPrefActivity.java
+++ b/app/src/main/java/be/ugent/zeus/hydra/feed/preferences/HomeFeedPrefActivity.java
@@ -5,8 +5,8 @@
import android.os.Parcelable;
import androidx.annotation.Nullable;
-import be.ugent.zeus.hydra.R;
import be.ugent.zeus.hydra.common.ui.BaseActivity;
+import be.ugent.zeus.hydra.databinding.ActivityPreferencesHomefeedBinding;
import be.ugent.zeus.hydra.preferences.PreferenceActivity;
import be.ugent.zeus.hydra.preferences.PreferenceEntry;
@@ -15,12 +15,12 @@
*
* @author Niko Strijbol
*/
-public class HomeFeedPrefActivity extends BaseActivity {
+public class HomeFeedPrefActivity extends BaseActivity {
@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
- setContentView(R.layout.activity_preferences_homefeed);
+ setContentView(ActivityPreferencesHomefeedBinding::inflate);
}
@Override
diff --git a/app/src/main/java/be/ugent/zeus/hydra/feed/preferences/HomeFragment.java b/app/src/main/java/be/ugent/zeus/hydra/feed/preferences/HomeFragment.java
index 7e5b5b71c..e5065e4a6 100644
--- a/app/src/main/java/be/ugent/zeus/hydra/feed/preferences/HomeFragment.java
+++ b/app/src/main/java/be/ugent/zeus/hydra/feed/preferences/HomeFragment.java
@@ -3,9 +3,14 @@
import android.content.Context;
import android.content.SharedPreferences;
import android.os.Bundle;
+import android.view.LayoutInflater;
+import android.view.View;
+import android.view.ViewGroup;
import android.widget.Toast;
+import androidx.annotation.NonNull;
+import androidx.annotation.Nullable;
import androidx.annotation.StringDef;
-import androidx.lifecycle.ViewModelProviders;
+import androidx.lifecycle.ViewModelProvider;
import androidx.preference.PreferenceManager;
import java.lang.annotation.Retention;
@@ -32,8 +37,14 @@ public class HomeFragment extends PreferenceFragment {
public void onCreatePreferences(Bundle savedInstanceState, String rootKey) {
setPreferencesFromResource(R.xml.pref_home_feed, rootKey);
- viewModel = ViewModelProviders.of(this).get(DeleteViewModel.class);
- viewModel.getLiveData().observe(this, new EventObserver() {
+
+ }
+
+ @Override
+ public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
+ View v = super.onCreateView(inflater, container, savedInstanceState);
+ viewModel = new ViewModelProvider(this).get(DeleteViewModel.class);
+ viewModel.getLiveData().observe(getViewLifecycleOwner(), new EventObserver() {
@Override
protected void onUnhandled(Context data) {
Toast.makeText(data, R.string.feed_pref_hidden_cleared, Toast.LENGTH_SHORT).show();
@@ -44,6 +55,7 @@ protected void onUnhandled(Context data) {
viewModel.deleteAll();
return true;
});
+ return v;
}
private static final String PREF_RESTO_KINDS = "pref_feed_resto_kinds";
diff --git a/app/src/main/java/be/ugent/zeus/hydra/info/InfoSubItemActivity.java b/app/src/main/java/be/ugent/zeus/hydra/info/InfoSubItemActivity.java
index 9476783a3..86dedb2e6 100644
--- a/app/src/main/java/be/ugent/zeus/hydra/info/InfoSubItemActivity.java
+++ b/app/src/main/java/be/ugent/zeus/hydra/info/InfoSubItemActivity.java
@@ -5,10 +5,11 @@
import be.ugent.zeus.hydra.R;
import be.ugent.zeus.hydra.common.ui.BaseActivity;
+import be.ugent.zeus.hydra.databinding.ActivityInfoSubItemBinding;
import java.util.ArrayList;
-public class InfoSubItemActivity extends BaseActivity {
+public class InfoSubItemActivity extends BaseActivity {
public static final String INFO_TITLE = "be.ugent.zeus.hydra.infoTitle";
public static final String INFO_ITEMS = "be.ugent.zeus.hydra.infoItems";
@@ -16,7 +17,7 @@ public class InfoSubItemActivity extends BaseActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
- setContentView(R.layout.activity_info_sub_item);
+ setContentView(ActivityInfoSubItemBinding::inflate);
// Display the fragment as the main content.
InfoFragment fragment = new InfoFragment();
diff --git a/app/src/main/java/be/ugent/zeus/hydra/library/details/LibraryDetailActivity.java b/app/src/main/java/be/ugent/zeus/hydra/library/details/LibraryDetailActivity.java
index cf5b8303d..2731d4ed1 100644
--- a/app/src/main/java/be/ugent/zeus/hydra/library/details/LibraryDetailActivity.java
+++ b/app/src/main/java/be/ugent/zeus/hydra/library/details/LibraryDetailActivity.java
@@ -12,7 +12,9 @@
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
-import android.widget.*;
+import android.widget.TableLayout;
+import android.widget.TableRow;
+import android.widget.TextView;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.core.content.ContextCompat;
@@ -34,14 +36,14 @@
import be.ugent.zeus.hydra.common.reporting.Event;
import be.ugent.zeus.hydra.common.reporting.Reporting;
import be.ugent.zeus.hydra.common.ui.BaseActivity;
-import be.ugent.zeus.hydra.common.utils.ViewUtils;
import be.ugent.zeus.hydra.common.ui.html.Utils;
+import be.ugent.zeus.hydra.common.utils.DateUtils;
+import be.ugent.zeus.hydra.common.utils.NetworkUtils;
+import be.ugent.zeus.hydra.common.utils.ViewUtils;
+import be.ugent.zeus.hydra.databinding.ActivityLibraryDetailsBinding;
import be.ugent.zeus.hydra.library.Library;
import be.ugent.zeus.hydra.library.favourites.FavouritesRepository;
import be.ugent.zeus.hydra.library.favourites.LibraryFavourite;
-import be.ugent.zeus.hydra.common.utils.DateUtils;
-import be.ugent.zeus.hydra.common.utils.NetworkUtils;
-import com.google.android.material.appbar.CollapsingToolbarLayout;
import com.google.android.material.snackbar.Snackbar;
import com.squareup.picasso.Picasso;
import net.cachapa.expandablelayout.ExpandableLayout;
@@ -51,16 +53,13 @@
*
* @author Niko Strijbol
*/
-public class LibraryDetailActivity extends BaseActivity {
+public class LibraryDetailActivity extends BaseActivity {
public static final String ARG_LIBRARY = "argLibrary";
private static final String TAG = "LibraryDetailActivity";
private Library library;
- private Button button;
- private Button expandButton;
- private FrameLayout layout;
public static void launchActivity(Context context, Library library) {
Intent intent = new Intent(context, LibraryDetailActivity.class);
@@ -71,90 +70,79 @@ public static void launchActivity(Context context, Library library) {
@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
- setContentView(R.layout.activity_library_details);
+ setContentView(ActivityLibraryDetailsBinding::inflate);
library = getIntent().getParcelableExtra(ARG_LIBRARY);
- layout = findViewById(R.id.frame_layout);
- ImageView header = findViewById(R.id.header_image);
- Picasso.get().load(library.getHeaderImage(this)).into(header);
+ Picasso.get().load(library.getHeaderImage(this)).into(binding.headerImage);
- CollapsingToolbarLayout collapsingToolbarLayout = findViewById(R.id.collapsing_toolbar);
- collapsingToolbarLayout.setTitle(library.getName());
+ binding.collapsingToolbar.setTitle(library.getName());
// TODO: why is this necessary?
int white = ContextCompat.getColor(this, R.color.white);
- collapsingToolbarLayout.setExpandedTitleColor(white);
- collapsingToolbarLayout.setCollapsedTitleTextColor(white);
+ binding.collapsingToolbar.setExpandedTitleColor(white);
+ binding.collapsingToolbar.setCollapsedTitleTextColor(white);
String address = makeFullAddressText();
if (TextUtils.isEmpty(address)) {
- findViewById(R.id.library_address_card).setVisibility(View.GONE);
+ binding.libraryAddressCard.setVisibility(View.GONE);
} else {
- TextView textView = findViewById(R.id.library_address);
- textView.setText(makeFullAddressText());
- textView.setOnClickListener(v -> NetworkUtils.maybeLaunchIntent(LibraryDetailActivity.this, mapsIntent()));
+ binding.libraryAddress.setText(makeFullAddressText());
+ binding.libraryAddress.setOnClickListener(v -> NetworkUtils.maybeLaunchIntent(LibraryDetailActivity.this, mapsIntent()));
}
final ViewModelProvider provider = new ViewModelProvider(this);
- button = findViewById(R.id.library_favourite);
FavouriteViewModel viewModel = provider.get(FavouriteViewModel.class);
viewModel.setLibrary(library);
viewModel.getData().observe(this, isFavourite -> {
Drawable drawable;
Context c = LibraryDetailActivity.this;
if (isFavourite) {
- button.setSelected(true);
+ binding.libraryFavourite.setSelected(true);
drawable = ViewUtils.getTintedVectorDrawableAttr(c, R.drawable.ic_star, R.attr.colorSecondary);
} else {
drawable = ViewUtils.getTintedVectorDrawableAttr(c, R.drawable.ic_star, R.attr.colorPrimary);
- button.setSelected(false);
+ binding.libraryFavourite.setSelected(false);
}
- button.setCompoundDrawablesWithIntrinsicBounds(drawable, null, null, null);
+ binding.libraryFavourite.setCompoundDrawablesWithIntrinsicBounds(drawable, null, null, null);
});
- button.setOnClickListener(v -> updateStatus(library, button.isSelected()));
+ binding.libraryFavourite.setOnClickListener(v -> updateStatus(library, binding.libraryFavourite.isSelected()));
- ExpandableLayout layout = findViewById(R.id.expandable_layout);
- expandButton = findViewById(R.id.expand_button);
- expandButton.setOnClickListener(v -> layout.toggle());
+ binding.expandButton.setOnClickListener(v -> binding.expandableLayout.toggle());
- layout.setOnExpansionUpdateListener((value, state) -> {
+ binding.expandableLayout.setOnExpansionUpdateListener((value, state) -> {
if (state == ExpandableLayout.State.COLLAPSED) {
- expandButton.setText(R.string.library_more);
+ binding.expandButton.setText(R.string.library_more);
} else if (state == ExpandableLayout.State.EXPANDED) {
- expandButton.setText(R.string.library_less);
+ binding.expandButton.setText(R.string.library_less);
}
});
- TextView remarks = findViewById(R.id.library_remarks);
String comments = library.getCommentsAsString();
if (TextUtils.isEmpty(comments)) {
- remarks.setVisibility(View.GONE);
- findViewById(R.id.library_remarks_divider).setVisibility(View.GONE);
- findViewById(R.id.library_remarks_title).setVisibility(View.GONE);
+ binding.libraryRemarks.setVisibility(View.GONE);
+ binding.libraryRemarksDivider.setVisibility(View.GONE);
+ binding.libraryRemarksTitle.setVisibility(View.GONE);
} else {
- remarks.setText(Utils.fromHtml(comments));
- layout.setExpanded(true, false);
+ binding.libraryRemarks.setText(Utils.fromHtml(comments));
+ binding.expandableLayout.setExpanded(true, false);
}
- TextView email = findViewById(R.id.library_mail_row_text);
- email.setText(library.getEmail());
- LinkifyCompat.addLinks(email, Linkify.EMAIL_ADDRESSES);
- TextView phone = findViewById(R.id.library_phone_row_text);
+ binding.libraryMailRowText.setText(library.getEmail());
+ LinkifyCompat.addLinks(binding.libraryMailRowText, Linkify.EMAIL_ADDRESSES);
String phoneString = library.getPhones();
if (TextUtils.isEmpty(phoneString)) {
- phone.setText(R.string.library_detail_no_phone);
+ binding.libraryPhoneRowText.setText(R.string.library_detail_no_phone);
} else {
- phone.setText(phoneString);
- LinkifyCompat.addLinks(phone, Linkify.PHONE_NUMBERS);
+ binding.libraryPhoneRowText.setText(phoneString);
+ LinkifyCompat.addLinks(binding.libraryPhoneRowText, Linkify.PHONE_NUMBERS);
}
- TextView contact = findViewById(R.id.library_contact_row_text);
- contact.setText(library.getContact());
+ binding.libraryContactRowText.setText(library.getContact());
HoursViewModel model = provider.get(HoursViewModel.class);
model.setLibrary(library);
model.getData().observe(this, PartialErrorObserver.with(this::onError));
- model.getData().observe(this, new ProgressObserver<>(findViewById(R.id.progress_bar)));
+ model.getData().observe(this, new ProgressObserver<>(binding.progressBar));
model.getData().observe(this, SuccessObserver.with(this::receiveData));
Reporting.getTracker(this).log(new LibraryViewEvent(library));
@@ -175,7 +163,7 @@ private void updateStatus(Library library, boolean isSelected) {
protected void onSaveInstanceState(@NonNull Bundle outState) {
super.onSaveInstanceState(outState);
// Save the toggle button state.
- outState.putString("button", String.valueOf(expandButton.getText()));
+ outState.putString("button", String.valueOf(binding.expandButton.getText()));
}
@Override
@@ -183,7 +171,7 @@ protected void onRestoreInstanceState(@NonNull Bundle savedInstanceState) {
super.onRestoreInstanceState(savedInstanceState);
// Restore the toggle button state.
if (savedInstanceState.get("button") != null) {
- expandButton.setText(savedInstanceState.getString("button"));
+ binding.expandButton.setText(savedInstanceState.getString("button"));
}
}
@@ -221,7 +209,7 @@ private void receiveData(List list) {
tableLayout.addView(tableRow);
}
- layout.addView(tableLayout);
+ binding.frameLayout.addView(tableLayout);
}
@Override
diff --git a/app/src/main/java/be/ugent/zeus/hydra/library/details/OpeningHoursRequest.java b/app/src/main/java/be/ugent/zeus/hydra/library/details/OpeningHoursRequest.java
index 83c87523f..ccf0b9530 100644
--- a/app/src/main/java/be/ugent/zeus/hydra/library/details/OpeningHoursRequest.java
+++ b/app/src/main/java/be/ugent/zeus/hydra/library/details/OpeningHoursRequest.java
@@ -3,10 +3,7 @@
import android.content.Context;
import androidx.annotation.NonNull;
-import java.util.List;
-
import java9.util.Optional;
-import java9.util.function.Function;
import java9.util.stream.StreamSupport;
import be.ugent.zeus.hydra.common.network.Endpoints;
diff --git a/app/src/main/java/be/ugent/zeus/hydra/library/favourites/FavouritesRepository.java b/app/src/main/java/be/ugent/zeus/hydra/library/favourites/FavouritesRepository.java
index 3d3d9bfbd..10fa9696a 100644
--- a/app/src/main/java/be/ugent/zeus/hydra/library/favourites/FavouritesRepository.java
+++ b/app/src/main/java/be/ugent/zeus/hydra/library/favourites/FavouritesRepository.java
@@ -1,14 +1,11 @@
package be.ugent.zeus.hydra.library.favourites;
-import androidx.arch.core.util.Function;
import androidx.lifecycle.LiveData;
import androidx.lifecycle.Transformations;
import androidx.room.*;
import java.util.List;
-import java.util.Set;
-import be.ugent.zeus.hydra.common.arch.data.BaseLiveData;
import be.ugent.zeus.hydra.library.Library;
/**
diff --git a/app/src/main/java/be/ugent/zeus/hydra/library/list/LibraryListAdapter.java b/app/src/main/java/be/ugent/zeus/hydra/library/list/LibraryListAdapter.java
index 1d3b99697..51e8282e3 100644
--- a/app/src/main/java/be/ugent/zeus/hydra/library/list/LibraryListAdapter.java
+++ b/app/src/main/java/be/ugent/zeus/hydra/library/list/LibraryListAdapter.java
@@ -10,6 +10,7 @@
import java.util.ArrayList;
import java.util.List;
+import java.util.Locale;
import java9.util.Optional;
import java9.util.stream.StreamSupport;
@@ -34,10 +35,10 @@ class LibraryListAdapter extends SearchableAdapter, Libra
super((pair, s) -> {
Library library = pair.first;
boolean contained = false;
- if (library.getName() != null && library.getName().toLowerCase().contains(s)) {
+ if (library.getName() != null && library.getName().toLowerCase(Locale.getDefault()).contains(s)) {
contained = true;
}
- if (library.getCampus() != null && library.getCampus().toLowerCase().contains(s)) {
+ if (library.getCampus() != null && library.getCampus().toLowerCase(Locale.getDefault()).contains(s)) {
contained = true;
}
return contained;
diff --git a/app/src/main/java/be/ugent/zeus/hydra/onboarding/OnboardingActivity.java b/app/src/main/java/be/ugent/zeus/hydra/onboarding/OnboardingActivity.java
index b9dce3365..4af744ef5 100644
--- a/app/src/main/java/be/ugent/zeus/hydra/onboarding/OnboardingActivity.java
+++ b/app/src/main/java/be/ugent/zeus/hydra/onboarding/OnboardingActivity.java
@@ -35,13 +35,15 @@ protected void onCreate(Bundle savedInstanceState) {
.backgroundDark(R.color.hydra_color_primary)
.build());
- // Check for permission for data collection
- addSlide(new FragmentSlide.Builder()
- .background(R.color.hydra_color_primary)
- .backgroundDark(R.color.hydra_color_primary)
- .fragment(new ReportingFragment())
- .build()
- );
+ if (Reporting.hasReportingOptions()) {
+ // Check for permission for data collection
+ addSlide(new FragmentSlide.Builder()
+ .background(R.color.hydra_color_primary)
+ .backgroundDark(R.color.hydra_color_primary)
+ .fragment(new ReportingFragment())
+ .build()
+ );
+ }
// Home feed selector
addSlide(new FragmentSlide.Builder()
diff --git a/app/src/main/java/be/ugent/zeus/hydra/onboarding/ReportingFragment.java b/app/src/main/java/be/ugent/zeus/hydra/onboarding/ReportingFragment.java
index 51f6b0833..c573d724a 100644
--- a/app/src/main/java/be/ugent/zeus/hydra/onboarding/ReportingFragment.java
+++ b/app/src/main/java/be/ugent/zeus/hydra/onboarding/ReportingFragment.java
@@ -12,7 +12,7 @@
import be.ugent.zeus.hydra.BuildConfig;
import be.ugent.zeus.hydra.R;
-import be.ugent.zeus.hydra.common.reporting.Reporting;
+import be.ugent.zeus.hydra.common.reporting.Manager;
import be.ugent.zeus.hydra.common.ui.customtabs.CustomTabsHelper;
import com.google.android.material.radiobutton.MaterialRadioButton;
import com.google.android.material.switchmaterial.SwitchMaterial;
@@ -67,9 +67,9 @@ public void onPause() {
super.onPause();
// Save settings if present.
if (canGoForward()) {
- Reporting.saveAnalyticsPermission(requireContext(), allowsAnalytics());
- Reporting.saveCrashReportingPermission(requireContext(), allowsCrashReporting());
- Reporting.syncPermissions(requireContext());
+ Manager.saveAnalyticsPermission(requireContext(), allowsAnalytics());
+ Manager.saveCrashReportingPermission(requireContext(), allowsCrashReporting());
+ Manager.syncPermissions(requireContext());
}
}
diff --git a/app/src/main/java/be/ugent/zeus/hydra/preferences/AboutFragment.java b/app/src/main/java/be/ugent/zeus/hydra/preferences/AboutFragment.java
index 2eb7b7d3e..6830574f2 100644
--- a/app/src/main/java/be/ugent/zeus/hydra/preferences/AboutFragment.java
+++ b/app/src/main/java/be/ugent/zeus/hydra/preferences/AboutFragment.java
@@ -3,7 +3,6 @@
import android.content.Intent;
import android.os.Build;
import android.os.Bundle;
-
import androidx.appcompat.content.res.AppCompatResources;
import androidx.preference.Preference;
@@ -11,7 +10,7 @@
import be.ugent.zeus.hydra.R;
import be.ugent.zeus.hydra.common.reporting.Reporting;
import be.ugent.zeus.hydra.common.ui.PreferenceFragment;
-import com.google.android.gms.oss.licenses.OssLicensesMenuActivity;
+import be.ugent.zeus.hydra.common.ui.WebViewActivity;
/**
* @author Niko Strijbol
@@ -32,8 +31,10 @@ public void onCreatePreferences(Bundle savedInstanceState, String rootKey) {
));
requirePreference("pref_about_licenses").setOnPreferenceClickListener(preference -> {
- OssLicensesMenuActivity.setActivityTitle(getString(R.string.pref_licenses_title));
- startActivity(new Intent(getActivity(), OssLicensesMenuActivity.class));
+ Intent intent = new Intent(requireActivity(), WebViewActivity.class);
+ intent.putExtra(WebViewActivity.TITLE, getString(R.string.pref_licenses_title));
+ intent.putExtra(WebViewActivity.URL, "file:///android_res/raw/third_party_licenses.html");
+ startActivity(intent);
return false;
});
diff --git a/app/src/main/java/be/ugent/zeus/hydra/preferences/OverviewFragment.java b/app/src/main/java/be/ugent/zeus/hydra/preferences/OverviewFragment.java
index 717636627..0a700fa9b 100644
--- a/app/src/main/java/be/ugent/zeus/hydra/preferences/OverviewFragment.java
+++ b/app/src/main/java/be/ugent/zeus/hydra/preferences/OverviewFragment.java
@@ -8,6 +8,7 @@
import androidx.preference.PreferenceScreen;
import be.ugent.zeus.hydra.R;
+import be.ugent.zeus.hydra.common.reporting.Reporting;
import be.ugent.zeus.hydra.common.utils.ViewUtils;
import be.ugent.zeus.hydra.common.utils.ColourUtils;
@@ -24,6 +25,12 @@ public void onCreatePreferences(Bundle savedInstanceState, String rootKey) {
PreferenceScreen screen = getPreferenceManager().createPreferenceScreen(context);
for (PreferenceEntry entry : PreferenceEntry.values()) {
+
+ // Skip data reporting if there is no data reporting.
+ if (entry == PreferenceEntry.DATA && !Reporting.hasReportingOptions()) {
+ continue;
+ }
+
Preference preference = new Preference(context);
preference.setTitle(entry.getName());
preference.setSummary(entry.getDescription());
@@ -38,6 +45,7 @@ public void onCreatePreferences(Bundle savedInstanceState, String rootKey) {
return true;
});
screen.addPreference(preference);
+
}
setPreferenceScreen(screen);
}
diff --git a/app/src/main/java/be/ugent/zeus/hydra/preferences/PreferenceActivity.java b/app/src/main/java/be/ugent/zeus/hydra/preferences/PreferenceActivity.java
index f2b36fd9e..c009a5c30 100644
--- a/app/src/main/java/be/ugent/zeus/hydra/preferences/PreferenceActivity.java
+++ b/app/src/main/java/be/ugent/zeus/hydra/preferences/PreferenceActivity.java
@@ -11,13 +11,14 @@
import be.ugent.zeus.hydra.R;
import be.ugent.zeus.hydra.common.ui.BaseActivity;
+import be.ugent.zeus.hydra.databinding.ActivityPreferencesBinding;
/**
* Activity that will show a fragment.
*
* @author Niko Strijbol
*/
-public class PreferenceActivity extends BaseActivity {
+public class PreferenceActivity extends BaseActivity {
/**
* Argument for the activity, indicating which fragment should be shown.
@@ -40,7 +41,7 @@ public static void start(@NonNull Context context, @Nullable PreferenceEntry ent
@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
- setContentView(R.layout.activity_preferences);
+ setContentView(ActivityPreferencesBinding::inflate);
if (savedInstanceState != null) {
// If a specific screen is requested, use that one.
diff --git a/app/src/main/java/be/ugent/zeus/hydra/preferences/ReportingFragment.java b/app/src/main/java/be/ugent/zeus/hydra/preferences/ReportingFragment.java
index 89659e9f6..091257e62 100644
--- a/app/src/main/java/be/ugent/zeus/hydra/preferences/ReportingFragment.java
+++ b/app/src/main/java/be/ugent/zeus/hydra/preferences/ReportingFragment.java
@@ -5,6 +5,7 @@
import androidx.preference.PreferenceFragmentCompat;
import be.ugent.zeus.hydra.R;
+import be.ugent.zeus.hydra.common.reporting.Manager;
import be.ugent.zeus.hydra.common.reporting.Reporting;
/**
@@ -29,6 +30,6 @@ public void onResume() {
@Override
public void onPause() {
super.onPause();
- Reporting.syncPermissions(getActivity());
+ Manager.syncPermissions(getActivity());
}
}
\ No newline at end of file
diff --git a/app/src/main/java/be/ugent/zeus/hydra/resto/extrafood/ExtraFoodActivity.java b/app/src/main/java/be/ugent/zeus/hydra/resto/extrafood/ExtraFoodActivity.java
index 63d660396..7b3a4aa1f 100644
--- a/app/src/main/java/be/ugent/zeus/hydra/resto/extrafood/ExtraFoodActivity.java
+++ b/app/src/main/java/be/ugent/zeus/hydra/resto/extrafood/ExtraFoodActivity.java
@@ -10,28 +10,24 @@
import be.ugent.zeus.hydra.R;
import be.ugent.zeus.hydra.common.reporting.Reporting;
import be.ugent.zeus.hydra.common.ui.BaseActivity;
-import com.google.android.material.tabs.TabLayout;
+import be.ugent.zeus.hydra.databinding.ActivityExtraFoodBinding;
-public class ExtraFoodActivity extends BaseActivity {
+public class ExtraFoodActivity extends BaseActivity {
private ExtraFoodViewModel viewModel;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
- setContentView(R.layout.activity_extra_food);
-
- TabLayout tabLayout = findViewById(R.id.tab_layout);
- ViewPager viewPager = findViewById(R.id.pager);
+ setContentView(ActivityExtraFoodBinding::inflate);
ExtraFoodPagerAdapter adapter = new ExtraFoodPagerAdapter(getSupportFragmentManager(), this);
- viewPager.setAdapter(adapter);
- tabLayout.setupWithViewPager(viewPager);
- viewPager.addOnPageChangeListener(new ViewPager.SimpleOnPageChangeListener() {
+ binding.pager.setAdapter(adapter);
+ binding.tabLayout.setupWithViewPager(binding.pager);
+ binding.pager.addOnPageChangeListener(new ViewPager.SimpleOnPageChangeListener() {
@Override
public void onPageSelected(int position) {
- //noinspection ConstantConditions
- Reporting.getTracker(getApplicationContext())
+ Reporting.getTracker(ExtraFoodActivity.this)
.setCurrentScreen(
ExtraFoodActivity.this,
adapter.getPageTitle(position).toString(),
diff --git a/app/src/main/java/be/ugent/zeus/hydra/resto/extrafood/ExtraFoodPagerAdapter.java b/app/src/main/java/be/ugent/zeus/hydra/resto/extrafood/ExtraFoodPagerAdapter.java
index acfaa8b87..08d945a11 100644
--- a/app/src/main/java/be/ugent/zeus/hydra/resto/extrafood/ExtraFoodPagerAdapter.java
+++ b/app/src/main/java/be/ugent/zeus/hydra/resto/extrafood/ExtraFoodPagerAdapter.java
@@ -30,6 +30,7 @@ public Fragment getItem(int position) {
return FoodFragment.newInstance(position);
}
+ @NonNull
@Override
public CharSequence getPageTitle(int position) {
@StringRes int string;
diff --git a/app/src/main/java/be/ugent/zeus/hydra/resto/history/HistoryActivity.java b/app/src/main/java/be/ugent/zeus/hydra/resto/history/HistoryActivity.java
index ae1a7b3de..d1caca73e 100644
--- a/app/src/main/java/be/ugent/zeus/hydra/resto/history/HistoryActivity.java
+++ b/app/src/main/java/be/ugent/zeus/hydra/resto/history/HistoryActivity.java
@@ -4,9 +4,10 @@
import android.os.Bundle;
import android.util.Log;
import android.view.View;
-import android.widget.*;
+import android.widget.AdapterView;
+import android.widget.ArrayAdapter;
+import android.widget.DatePicker;
import androidx.annotation.NonNull;
-import androidx.appcompat.widget.Toolbar;
import androidx.fragment.app.Fragment;
import androidx.fragment.app.FragmentManager;
import androidx.lifecycle.ViewModelProvider;
@@ -20,17 +21,20 @@
import be.ugent.zeus.hydra.common.network.IOFailureException;
import be.ugent.zeus.hydra.common.ui.BaseActivity;
import be.ugent.zeus.hydra.common.ui.NoPaddingArrayAdapter;
+import be.ugent.zeus.hydra.common.utils.DateUtils;
+import be.ugent.zeus.hydra.databinding.ActivityRestoHistoryBinding;
import be.ugent.zeus.hydra.resto.RestoChoice;
import be.ugent.zeus.hydra.resto.RestoMenu;
import be.ugent.zeus.hydra.resto.SingleDayFragment;
import be.ugent.zeus.hydra.resto.meta.selectable.SelectableMetaViewModel;
import be.ugent.zeus.hydra.resto.meta.selectable.SelectedResto;
-import be.ugent.zeus.hydra.common.utils.DateUtils;
import org.threeten.bp.LocalDate;
import org.threeten.bp.Month;
import org.threeten.bp.ZoneId;
-public class HistoryActivity extends BaseActivity implements DatePickerDialog.OnDateSetListener, AdapterView.OnItemSelectedListener {
+public class HistoryActivity
+ extends BaseActivity
+ implements DatePickerDialog.OnDateSetListener, AdapterView.OnItemSelectedListener {
private static final String ARG_DATE = "arg_date";
@@ -39,15 +43,12 @@ public class HistoryActivity extends BaseActivity implements DatePickerDialog.On
private LocalDate localDate;
private RestoChoice restoChoice;
private SingleDayViewModel viewModel;
- private Spinner restoSpinner;
- private ProgressBar restoProgressBar;
private ArrayAdapter restoAdapter;
- private TextView errorView;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
- setContentView(R.layout.activity_resto_history);
+ setContentView(ActivityRestoHistoryBinding::inflate);
if (savedInstanceState != null && savedInstanceState.containsKey(ARG_DATE)) {
localDate = (LocalDate) savedInstanceState.getSerializable(ARG_DATE);
@@ -57,32 +58,27 @@ protected void onCreate(Bundle savedInstanceState) {
localDate = LocalDate.now();
}
- Toolbar bottomToolbar = findViewById(R.id.bottom_toolbar);
-
- restoSpinner = findViewById(R.id.resto_spinner);
- restoSpinner.setEnabled(false);
- restoProgressBar = findViewById(R.id.resto_progress_bar);
- restoAdapter = new NoPaddingArrayAdapter<>(bottomToolbar.getContext(), R.layout.x_spinner_title_resto);
+ binding.restoSpinner.setEnabled(false);
+ restoAdapter = new NoPaddingArrayAdapter<>(binding.bottomToolbar.getContext(), R.layout.x_spinner_title_resto);
restoAdapter.add(new SelectedResto.Wrapper(getString(R.string.resto_spinner_loading)));
restoAdapter.setDropDownViewResource(R.layout.x_simple_spinner_dropdown_item);
- restoSpinner.setAdapter(restoAdapter);
+ binding.restoSpinner.setAdapter(restoAdapter);
final ViewModelProvider provider = new ViewModelProvider(this);
- errorView = findViewById(R.id.error_view);
viewModel = provider.get(SingleDayViewModel.class);
viewModel.changeDate(localDate); // Set the initial date
viewModel.getData().observe(this, new SuccessObserver() {
@Override
protected void onSuccess(@NonNull RestoMenu data) {
// Add the fragment
- errorView.setVisibility(View.GONE);
+ binding.errorView.setVisibility(View.GONE);
setTitle(getString(R.string.resto_history_title, DateUtils.getFriendlyDate(HistoryActivity.this, data.getDate())));
showFragment(data);
}
});
viewModel.getData().observe(this, PartialErrorObserver.with(this::onError));
- viewModel.getData().observe(this, new ProgressObserver<>(findViewById(R.id.progress_bar)));
+ viewModel.getData().observe(this, new ProgressObserver<>(binding.progressBar));
SelectableMetaViewModel metaViewModel = provider.get(SelectableMetaViewModel.class);
metaViewModel.getData().observe(this, SuccessObserver.with(this::onReceiveRestos));
@@ -112,11 +108,11 @@ private void onError(Throwable throwable) {
Log.w(TAG, "Error", throwable);
hideFragment();
setTitle(R.string.resto_history_error);
- errorView.setVisibility(View.VISIBLE);
+ binding.errorView.setVisibility(View.VISIBLE);
if (throwable instanceof IOFailureException) {
- errorView.setText(R.string.error_network);
+ binding.errorView.setText(R.string.error_network);
} else {
- errorView.setText(getString(R.string.resto_history_not_found, DateUtils.getFriendlyDate(this, localDate)));
+ binding.errorView.setText(getString(R.string.resto_history_not_found, DateUtils.getFriendlyDate(this, localDate)));
}
}
@@ -129,10 +125,10 @@ private void onReceiveRestos(List choices) {
List wrappers = selectedResto.getAsWrappers();
restoAdapter.clear();
restoAdapter.addAll(wrappers);
- restoSpinner.setSelection(selectedResto.getSelectedIndex(), false);
- restoSpinner.setEnabled(true);
- restoProgressBar.setVisibility(View.GONE);
- restoSpinner.setOnItemSelectedListener(this);
+ binding.restoSpinner.setSelection(selectedResto.getSelectedIndex(), false);
+ binding.restoSpinner.setEnabled(true);
+ binding.restoProgressBar.setVisibility(View.GONE);
+ binding.restoSpinner.setOnItemSelectedListener(this);
}
private DatePickerDialog createAndSetupDialog() {
diff --git a/app/src/main/java/be/ugent/zeus/hydra/resto/menu/RestoFragment.java b/app/src/main/java/be/ugent/zeus/hydra/resto/menu/RestoFragment.java
index bd49f472d..3d1e2b53e 100644
--- a/app/src/main/java/be/ugent/zeus/hydra/resto/menu/RestoFragment.java
+++ b/app/src/main/java/be/ugent/zeus/hydra/resto/menu/RestoFragment.java
@@ -21,8 +21,8 @@
import be.ugent.zeus.hydra.common.arch.observers.ErrorObserver;
import be.ugent.zeus.hydra.common.arch.observers.ProgressObserver;
import be.ugent.zeus.hydra.common.arch.observers.SuccessObserver;
-import be.ugent.zeus.hydra.common.ui.BaseActivity;
import be.ugent.zeus.hydra.common.ui.NoPaddingArrayAdapter;
+import be.ugent.zeus.hydra.common.utils.NetworkUtils;
import be.ugent.zeus.hydra.resto.RestoChoice;
import be.ugent.zeus.hydra.resto.RestoMenu;
import be.ugent.zeus.hydra.resto.RestoPreferenceFragment;
@@ -32,7 +32,6 @@
import be.ugent.zeus.hydra.resto.meta.selectable.SelectableMetaViewModel;
import be.ugent.zeus.hydra.resto.meta.selectable.SelectedResto;
import be.ugent.zeus.hydra.resto.sandwich.SandwichActivity;
-import be.ugent.zeus.hydra.common.utils.NetworkUtils;
import com.google.android.material.appbar.AppBarLayout;
import com.google.android.material.bottomnavigation.BottomNavigationView;
import com.google.android.material.snackbar.Snackbar;
@@ -113,7 +112,7 @@ public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceStat
super.onViewCreated(view, savedInstanceState);
Log.d(TAG, "receiveResto: on view created");
- getBaseActivity().requireToolbar().setDisplayShowTitleEnabled(false);
+ requireBaseActivity(this).requireToolbar().setDisplayShowTitleEnabled(false);
// Create the adapter that will return a fragment for each of the three
// primary sections of the activity.
@@ -147,7 +146,7 @@ public void onPageSelected(int position) {
spinner = requireActivity().findViewById(R.id.spinner);
spinner.setEnabled(false);
spinner.setVisibility(View.VISIBLE);
- restoAdapter = new NoPaddingArrayAdapter<>(getBaseActivity().requireToolbar().getThemedContext(), R.layout.x_spinner_title_main);
+ restoAdapter = new NoPaddingArrayAdapter<>(requireBaseActivity(this).requireToolbar().getThemedContext(), R.layout.x_spinner_title_main);
restoAdapter.add(new SelectedResto.Wrapper(getString(R.string.resto_spinner_loading)));
restoAdapter.setDropDownViewResource(R.layout.x_simple_spinner_dropdown_item);
spinner.setAdapter(restoAdapter);
@@ -327,7 +326,7 @@ public void onDestroyView() {
tabLayout.setVisibility(View.GONE);
spinner.setVisibility(View.GONE);
spinnerProgress.setVisibility(View.GONE);
- getBaseActivity().requireToolbar().setDisplayShowTitleEnabled(true);
+ requireBaseActivity(this).requireToolbar().setDisplayShowTitleEnabled(true);
spinner.setOnItemSelectedListener(null);
}
@@ -335,8 +334,4 @@ private void hideExternalViews() {
bottomNavigation.setVisibility(View.GONE);
bottomNavigation.setOnNavigationItemSelectedListener(null);
}
-
- private BaseActivity getBaseActivity() {
- return (BaseActivity) getActivity();
- }
}
diff --git a/app/src/main/java/be/ugent/zeus/hydra/resto/sandwich/SandwichActivity.java b/app/src/main/java/be/ugent/zeus/hydra/resto/sandwich/SandwichActivity.java
index 43f489a1f..565d8637f 100644
--- a/app/src/main/java/be/ugent/zeus/hydra/resto/sandwich/SandwichActivity.java
+++ b/app/src/main/java/be/ugent/zeus/hydra/resto/sandwich/SandwichActivity.java
@@ -8,32 +8,28 @@
import be.ugent.zeus.hydra.R;
import be.ugent.zeus.hydra.common.reporting.Reporting;
import be.ugent.zeus.hydra.common.ui.BaseActivity;
-import be.ugent.zeus.hydra.resto.extrafood.FoodFragment;
import be.ugent.zeus.hydra.common.utils.NetworkUtils;
-import com.google.android.material.tabs.TabLayout;
+import be.ugent.zeus.hydra.databinding.ActivityExtraFoodBinding;
+import be.ugent.zeus.hydra.resto.extrafood.FoodFragment;
/**
* Activity for the sandwiches.
*/
-public class SandwichActivity extends BaseActivity {
+public class SandwichActivity extends BaseActivity{
public static final String URL = "https://www.ugent.be/student/nl/meer-dan-studeren/resto/broodjes";
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
- setContentView(R.layout.activity_extra_food);
-
- TabLayout tabLayout = findViewById(R.id.tab_layout);
- ViewPager viewPager = findViewById(R.id.pager);
+ setContentView(ActivityExtraFoodBinding::inflate);
SandwichPagerAdapter adapter = new SandwichPagerAdapter(getSupportFragmentManager(), this);
- viewPager.setAdapter(adapter);
- tabLayout.setupWithViewPager(viewPager);
- viewPager.addOnPageChangeListener(new ViewPager.SimpleOnPageChangeListener() {
+ binding.pager.setAdapter(adapter);
+ binding.tabLayout.setupWithViewPager(binding.pager);
+ binding.pager.addOnPageChangeListener(new ViewPager.SimpleOnPageChangeListener() {
@Override
public void onPageSelected(int position) {
- //noinspection ConstantConditions
Reporting.getTracker(getApplicationContext())
.setCurrentScreen(
SandwichActivity.this,
diff --git a/app/src/main/java/be/ugent/zeus/hydra/resto/sandwich/SandwichPagerAdapter.java b/app/src/main/java/be/ugent/zeus/hydra/resto/sandwich/SandwichPagerAdapter.java
index e48976aa7..7dd7e338e 100644
--- a/app/src/main/java/be/ugent/zeus/hydra/resto/sandwich/SandwichPagerAdapter.java
+++ b/app/src/main/java/be/ugent/zeus/hydra/resto/sandwich/SandwichPagerAdapter.java
@@ -40,6 +40,7 @@ public Fragment getItem(int position) {
}
@Override
+ @NonNull
public CharSequence getPageTitle(int position) {
@StringRes int string;
switch (position) {
diff --git a/app/src/main/java/be/ugent/zeus/hydra/resto/sandwich/ecological/EcologicalFragment.java b/app/src/main/java/be/ugent/zeus/hydra/resto/sandwich/ecological/EcologicalFragment.java
index de228577f..72d662ab9 100644
--- a/app/src/main/java/be/ugent/zeus/hydra/resto/sandwich/ecological/EcologicalFragment.java
+++ b/app/src/main/java/be/ugent/zeus/hydra/resto/sandwich/ecological/EcologicalFragment.java
@@ -3,11 +3,10 @@
import android.os.Bundle;
import android.util.Log;
import android.view.*;
-
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.fragment.app.Fragment;
-import androidx.lifecycle.ViewModelProviders;
+import androidx.lifecycle.ViewModelProvider;
import androidx.recyclerview.widget.DividerItemDecoration;
import androidx.recyclerview.widget.RecyclerView;
import androidx.swiperefreshlayout.widget.SwipeRefreshLayout;
@@ -72,11 +71,11 @@ public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceStat
SwipeRefreshLayout swipeRefreshLayout = view.findViewById(R.id.swipeRefreshLayout);
swipeRefreshLayout.setColorSchemeColors(ColourUtils.resolveColour(requireContext(), R.attr.colorSecondary));
- viewModel = ViewModelProviders.of(this).get(EcologicalViewModel.class);
- viewModel.getData().observe(this, PartialErrorObserver.with(this::onError));
- viewModel.getData().observe(this, new ProgressObserver<>(view.findViewById(R.id.progress_bar)));
- viewModel.getData().observe(this, new AdapterObserver<>(adapter));
- viewModel.getRefreshing().observe(this, swipeRefreshLayout::setRefreshing);
+ viewModel = new ViewModelProvider(this).get(EcologicalViewModel.class);
+ viewModel.getData().observe(getViewLifecycleOwner(), PartialErrorObserver.with(this::onError));
+ viewModel.getData().observe(getViewLifecycleOwner(), new ProgressObserver<>(view.findViewById(R.id.progress_bar)));
+ viewModel.getData().observe(getViewLifecycleOwner(), new AdapterObserver<>(adapter));
+ viewModel.getRefreshing().observe(getViewLifecycleOwner(), swipeRefreshLayout::setRefreshing);
swipeRefreshLayout.setOnRefreshListener(viewModel);
}
diff --git a/app/src/main/java/be/ugent/zeus/hydra/schamper/SchamperFragment.java b/app/src/main/java/be/ugent/zeus/hydra/schamper/SchamperFragment.java
index 45751bd93..7fb82d48d 100644
--- a/app/src/main/java/be/ugent/zeus/hydra/schamper/SchamperFragment.java
+++ b/app/src/main/java/be/ugent/zeus/hydra/schamper/SchamperFragment.java
@@ -74,7 +74,7 @@ public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceStat
public void onCreateOptionsMenu(@NonNull Menu menu, @NonNull MenuInflater inflater) {
super.onCreateOptionsMenu(menu, inflater);
inflater.inflate(R.menu.menu_refresh, menu);
- BaseActivity activity = requireBaseActivity(this);
+ BaseActivity> activity = requireBaseActivity(this);
activity.tintToolbarIcons(menu, R.id.action_refresh);
}
diff --git a/app/src/main/java/be/ugent/zeus/hydra/sko/ArtistDetailsActivity.java b/app/src/main/java/be/ugent/zeus/hydra/sko/ArtistDetailsActivity.java
index 10db75ed4..8e077f749 100644
--- a/app/src/main/java/be/ugent/zeus/hydra/sko/ArtistDetailsActivity.java
+++ b/app/src/main/java/be/ugent/zeus/hydra/sko/ArtistDetailsActivity.java
@@ -8,9 +8,7 @@
import android.text.TextUtils;
import android.view.Menu;
import android.view.MenuItem;
-import android.widget.ImageView;
-import android.widget.TextView;
-
+import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import be.ugent.zeus.hydra.R;
@@ -19,6 +17,7 @@
import be.ugent.zeus.hydra.common.reporting.Reporting;
import be.ugent.zeus.hydra.common.ui.BaseActivity;
import be.ugent.zeus.hydra.common.utils.NetworkUtils;
+import be.ugent.zeus.hydra.databinding.ActivitySkoArtistBinding;
import com.squareup.picasso.Picasso;
/**
@@ -26,13 +25,14 @@
*
* @author Niko Strijbol
*/
-public class ArtistDetailsActivity extends BaseActivity {
+public class ArtistDetailsActivity extends BaseActivity {
private static final String PARCEL_ARTIST = "artist";
private Artist artist;
- public static Intent start(Context context, Artist artist) {
+ @NonNull
+ public static Intent start(@NonNull Context context, @NonNull Artist artist) {
Intent intent = new Intent(context, ArtistDetailsActivity.class);
intent.putExtra(PARCEL_ARTIST, artist);
return intent;
@@ -41,38 +41,34 @@ public static Intent start(Context context, Artist artist) {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
- setContentView(R.layout.activity_sko_artist);
+ setContentView(ActivitySkoArtistBinding::inflate);
Intent intent = getIntent();
artist = intent.getParcelableExtra(PARCEL_ARTIST);
+ assert artist != null;
- TextView title = findViewById(R.id.title);
- TextView date = findViewById(R.id.date);
- TextView content = findViewById(R.id.content);
- ImageView headerImage = findViewById(R.id.header_image);
-
- title.setText(artist.getName());
+ binding.title.setText(artist.getName());
setTitle(artist.getName());
if (artist.getImage() != null) {
- Picasso.get().load(artist.getImage()).fit().centerInside().into(headerImage);
+ Picasso.get().load(artist.getImage()).fit().centerInside().into(binding.headerImage);
}
- date.setText(artist.getDisplayDate(this));
+ binding.date.setText(artist.getDisplayDate(this));
if (!TextUtils.isEmpty(artist.getDescription())) {
- content.setText(artist.getDescription());
+ binding.content.setText(artist.getDescription());
} else {
- content.setText(R.string.sko_artist_no_content);
+ binding.content.setText(R.string.sko_artist_no_content);
}
- findViewById(R.id.sko_artist_search_web).setOnClickListener(view -> {
+ binding.skoArtistSearchWeb.setOnClickListener(view -> {
Intent searchIntent = new Intent(Intent.ACTION_WEB_SEARCH);
searchIntent.putExtra(SearchManager.QUERY, artist.getName());
NetworkUtils.maybeLaunchIntent(ArtistDetailsActivity.this, searchIntent);
});
- findViewById(R.id.sko_artist_search_music).setOnClickListener(view -> {
+ binding.skoArtistSearchMusic.setOnClickListener(view -> {
Intent musicIntent = new Intent(MediaStore.INTENT_ACTION_MEDIA_PLAY_FROM_SEARCH);
musicIntent.putExtra(MediaStore.EXTRA_MEDIA_FOCUS, MediaStore.Audio.Artists.ENTRY_CONTENT_TYPE);
musicIntent.putExtra(MediaStore.EXTRA_MEDIA_ARTIST, artist.getName());
diff --git a/app/src/main/java/be/ugent/zeus/hydra/sko/OverviewActivity.java b/app/src/main/java/be/ugent/zeus/hydra/sko/OverviewActivity.java
index 381048b02..7ff8bb7c7 100644
--- a/app/src/main/java/be/ugent/zeus/hydra/sko/OverviewActivity.java
+++ b/app/src/main/java/be/ugent/zeus/hydra/sko/OverviewActivity.java
@@ -12,13 +12,14 @@
import be.ugent.zeus.hydra.common.network.Endpoints;
import be.ugent.zeus.hydra.common.ui.BaseActivity;
import be.ugent.zeus.hydra.common.utils.NetworkUtils;
+import be.ugent.zeus.hydra.databinding.ActivitySkoMainBinding;
/**
* SKO overview activity. Only displays the line-up.
*
* @author Niko Strijbol
*/
-public class OverviewActivity extends BaseActivity {
+public class OverviewActivity extends BaseActivity {
private static final String SKO_WEBSITE = Endpoints.SKO;
@@ -36,7 +37,7 @@ public static Intent start(Context context) {
@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
- setContentView(R.layout.activity_sko_main);
+ setContentView(ActivitySkoMainBinding::inflate);
}
@Override
diff --git a/app/src/main/java/be/ugent/zeus/hydra/specialevent/SpecialEvent.java b/app/src/main/java/be/ugent/zeus/hydra/specialevent/SpecialEvent.java
index 831406e63..cec9cfeda 100644
--- a/app/src/main/java/be/ugent/zeus/hydra/specialevent/SpecialEvent.java
+++ b/app/src/main/java/be/ugent/zeus/hydra/specialevent/SpecialEvent.java
@@ -92,6 +92,7 @@ public void setPriority(int priority) {
this.priority = priority;
}
+ @NonNull
public OffsetDateTime getStart() {
return start;
}
diff --git a/app/src/main/res/drawable/ic_settings_24dp.xml b/app/src/main/res/drawable/ic_settings_24dp.xml
index ace746c40..7c0394bbe 100644
--- a/app/src/main/res/drawable/ic_settings_24dp.xml
+++ b/app/src/main/res/drawable/ic_settings_24dp.xml
@@ -1,9 +1,9 @@
+ android:width="24dp"
+ android:height="24dp"
+ android:viewportWidth="24.0"
+ android:viewportHeight="24.0">
+ android:pathData="M19.43,12.98c0.04,-0.32 0.07,-0.64 0.07,-0.98s-0.03,-0.66 -0.07,-0.98l2.11,-1.65c0.19,-0.15 0.24,-0.42 0.12,-0.64l-2,-3.46c-0.12,-0.22 -0.39,-0.3 -0.61,-0.22l-2.49,1c-0.52,-0.4 -1.08,-0.73 -1.69,-0.98l-0.38,-2.65C14.46,2.18 14.25,2 14,2h-4c-0.25,0 -0.46,0.18 -0.49,0.42l-0.38,2.65c-0.61,0.25 -1.17,0.59 -1.69,0.98l-2.49,-1c-0.23,-0.09 -0.49,0 -0.61,0.22l-2,3.46c-0.13,0.22 -0.07,0.49 0.12,0.64l2.11,1.65c-0.04,0.32 -0.07,0.65 -0.07,0.98s0.03,0.66 0.07,0.98l-2.11,1.65c-0.19,0.15 -0.24,0.42 -0.12,0.64l2,3.46c0.12,0.22 0.39,0.3 0.61,0.22l2.49,-1c0.52,0.4 1.08,0.73 1.69,0.98l0.38,2.65c0.03,0.24 0.24,0.42 0.49,0.42h4c0.25,0 0.46,-0.18 0.49,-0.42l0.38,-2.65c0.61,-0.25 1.17,-0.59 1.69,-0.98l2.49,1c0.23,0.09 0.49,0 0.61,-0.22l2,-3.46c0.12,-0.22 0.07,-0.49 -0.12,-0.64l-2.11,-1.65zM12,15.5c-1.93,0 -3.5,-1.57 -3.5,-3.5s1.57,-3.5 3.5,-3.5 3.5,1.57 3.5,3.5 -1.57,3.5 -3.5,3.5z" />
diff --git a/app/src/main/res/layout-sw600dp-land/activity_event_detail.xml b/app/src/main/res/layout-sw600dp-land/activity_event_detail.xml
index 3beab1048..170c07f08 100644
--- a/app/src/main/res/layout-sw600dp-land/activity_event_detail.xml
+++ b/app/src/main/res/layout-sw600dp-land/activity_event_detail.xml
@@ -37,11 +37,11 @@
android:layout_marginRight="32dp"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
- android:tint="@color/white"
app:srcCompat="@drawable/ic_event_note"
tools:src="@drawable/ic_event_note"
- tools:ignore="MissingPrefix,RtlHardcoded"
- android:contentDescription="@string/content_desc_calendar_icon"/>
+ tools:ignore="MissingPrefix"
+ android:contentDescription="@string/content_desc_calendar_icon"
+ app:tint="@color/white" />
+ android:layout_marginTop="@dimen/card_spacing">
+ android:contentDescription="@string/content_desc_location"
+ app:tint="?colorPrimaryVariant" />
+ android:contentDescription="@string/content_desc_time"
+ app:tint="?colorPrimaryVariant" />
+ style="?textAppearanceBody2" />
+ android:text="@string/event_detail_to" />
-
+ android:contentDescription="@string/content_desc_library" />
+ android:contentDescription="@string/content_desc_library" />
-
-
-
+ style="?textAppearanceBody2"
+ android:paddingBottom="@dimen/card_text_padding_bottom"
+ android:focusable="true"
+ tools:ignore="UnusedAttribute" />
-
+
-
+ style="?attr/borderlessButtonStyle" />
-
+ style="?attr/borderlessButtonStyle" />
+ android:layout_height="wrap_content">
+ style="@style/Divider" />
-
-
-
-
+ android:paddingRight="4dp"
+ tools:ignore="TooDeepLayout" />
-
-
+ android:paddingRight="4dp" />
-
-
-
+
+
-
-
+
-
-
+
@@ -280,5 +290,4 @@
-
\ No newline at end of file
diff --git a/app/src/main/res/layout-sw900dp/activity_event_detail.xml b/app/src/main/res/layout-sw900dp/activity_event_detail.xml
index 3beab1048..170c07f08 100644
--- a/app/src/main/res/layout-sw900dp/activity_event_detail.xml
+++ b/app/src/main/res/layout-sw900dp/activity_event_detail.xml
@@ -37,11 +37,11 @@
android:layout_marginRight="32dp"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
- android:tint="@color/white"
app:srcCompat="@drawable/ic_event_note"
tools:src="@drawable/ic_event_note"
- tools:ignore="MissingPrefix,RtlHardcoded"
- android:contentDescription="@string/content_desc_calendar_icon"/>
+ tools:ignore="MissingPrefix"
+ android:contentDescription="@string/content_desc_calendar_icon"
+ app:tint="@color/white" />
+ android:layout_marginTop="@dimen/card_spacing">
+ android:contentDescription="@string/content_desc_location"
+ app:tint="?colorPrimaryVariant" />
+ android:contentDescription="@string/content_desc_time"
+ app:tint="?colorPrimaryVariant" />
+ style="?textAppearanceBody2" />
+ android:text="@string/event_detail_to" />
-
+ android:contentDescription="@string/content_desc_library" />
+ android:contentDescription="@string/content_desc_library" />
-
-
-
+ style="?textAppearanceBody2"
+ android:paddingBottom="@dimen/card_text_padding_bottom"
+ android:focusable="true"
+ tools:ignore="UnusedAttribute" />
-
+
-
+ style="?attr/borderlessButtonStyle" />
-
+ style="?attr/borderlessButtonStyle" />
+ android:layout_height="wrap_content">
+ style="@style/Divider" />
-
-
-
-
+ android:paddingRight="4dp"
+ tools:ignore="TooDeepLayout" />
-
-
+ android:paddingRight="4dp" />
-
-
-
+
+
-
-
+
-
-
+
@@ -280,5 +290,4 @@
-
\ No newline at end of file
diff --git a/app/src/main/res/layout/activity_event_detail.xml b/app/src/main/res/layout/activity_event_detail.xml
index 59db369fc..fa13e1af6 100644
--- a/app/src/main/res/layout/activity_event_detail.xml
+++ b/app/src/main/res/layout/activity_event_detail.xml
@@ -40,11 +40,11 @@
android:layout_marginRight="32dp"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
- android:tint="@color/white"
app:srcCompat="@drawable/ic_event_note"
tools:src="@drawable/ic_event_note"
- tools:ignore="MissingPrefix,RtlHardcoded"
- android:contentDescription="@string/content_desc_calendar_icon"/>
+ tools:ignore="MissingPrefix"
+ android:contentDescription="@string/content_desc_calendar_icon"
+ app:tint="@color/white" />
+ tools:ignore="MissingPrefix"
+ android:contentDescription="@string/content_desc_location"
+ app:tint="?colorPrimarySecondary" />
+ tools:text="Locatie van het evenement" />
+ style="@style/Divider" />
+ tools:ignore="MissingPrefix"
+ android:contentDescription="@string/content_desc_time"
+ app:tint="?colorPrimarySecondary" />
+ android:columnCount="2">
+ style="?textAppearanceBody2" />
+ tools:text="Starttijd van het evenement" />
+ android:text="@string/event_detail_to" />
+ tools:text="Endtijd van het evenement" />
@@ -198,7 +195,7 @@
+ style="@style/Divider" />
+ android:contentDescription="@string/content_desc_hydra_logo" />
+ tools:text="Kleine organisator" />
@@ -245,7 +241,7 @@
-
+
+ style="?textAppearanceBody2" />
diff --git a/app/src/main/res/layout/activity_library_details.xml b/app/src/main/res/layout/activity_library_details.xml
index 28ee0488e..1c86b0558 100644
--- a/app/src/main/res/layout/activity_library_details.xml
+++ b/app/src/main/res/layout/activity_library_details.xml
@@ -124,8 +124,7 @@
android:layout_height="wrap_content"
android:gravity="left|center_vertical"
android:text="@string/library_favourite"
- style="?attr/borderlessButtonStyle"
- tools:ignore="RtlHardcoded" />
+ style="?attr/borderlessButtonStyle" />
+ tools:ignore="TooDeepLayout" />
+ android:paddingRight="4dp" />
+ android:paddingRight="4dp" />
-
+
diff --git a/app/src/main/res/layout/activity_main.xml b/app/src/main/res/layout/activity_main.xml
index d7c6270fd..9f5ad6113 100644
--- a/app/src/main/res/layout/activity_main.xml
+++ b/app/src/main/res/layout/activity_main.xml
@@ -2,7 +2,6 @@
+
+
+ app:tabMode="fixed" />
@@ -53,7 +54,10 @@
android:layout_height="match_parent"
app:layout_behavior="@string/appbar_scrolling_view_behavior">
-
+
diff --git a/app/src/main/res/layout/activity_resto_history.xml b/app/src/main/res/layout/activity_resto_history.xml
index 2b54395fb..4501b51c4 100644
--- a/app/src/main/res/layout/activity_resto_history.xml
+++ b/app/src/main/res/layout/activity_resto_history.xml
@@ -30,7 +30,9 @@
android:layout_width="match_parent"
android:layout_height="wrap_content">
-
+
+ style="?toolbarStyle">
+ android:contentDescription="@string/content_desc_search"
+ app:tint="?colorPrimarySecondary" />
+ android:text="@string/sko_artist_search_web" />
@@ -193,8 +192,8 @@
android:layout_width="wrap_content"
android:layout_height="wrap_content"
app:srcCompat="@drawable/ic_library_music"
- android:tint="?colorPrimarySecondary"
- android:contentDescription="@string/content_desc_search_artist" />
+ android:contentDescription="@string/content_desc_search_artist"
+ app:tint="?colorPrimarySecondary" />
+ style="?textAppearanceBody2" />
diff --git a/app/src/main/res/layout/activity_webview.xml b/app/src/main/res/layout/activity_webview.xml
index c4833a477..c17c0d222 100644
--- a/app/src/main/res/layout/activity_webview.xml
+++ b/app/src/main/res/layout/activity_webview.xml
@@ -19,16 +19,16 @@
android:layout_width="match_parent"
android:layout_height="match_parent"
android:animateLayoutChanges="true"
- app:layout_behavior="@string/appbar_scrolling_view_behavior"
- >
+ app:layout_behavior="@string/appbar_scrolling_view_behavior">
+ android:id="@+id/web_view" />
-
+
diff --git a/app/src/main/res/layout/drawer_header.xml b/app/src/main/res/layout/drawer_header.xml
index 4f1c1b9e8..132fdb6c3 100644
--- a/app/src/main/res/layout/drawer_header.xml
+++ b/app/src/main/res/layout/drawer_header.xml
@@ -15,13 +15,13 @@
android:layout_marginTop="10dp"
android:layout_marginBottom="10dp"
android:id="@+id/main_logo"
- android:tint="@color/white"
app:srcCompat="@drawable/logo_hydra"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:scaleType="fitStart"
tools:src="@drawable/logo_hydra"
- android:contentDescription="@string/content_desc_hydra_logo" />
+ android:contentDescription="@string/content_desc_hydra_logo"
+ app:tint="@color/white" />
diff --git a/app/src/main/res/layout/fragment_resto_menu_legend.xml b/app/src/main/res/layout/fragment_resto_menu_legend.xml
index 1a388b24a..748575f56 100644
--- a/app/src/main/res/layout/fragment_resto_menu_legend.xml
+++ b/app/src/main/res/layout/fragment_resto_menu_legend.xml
@@ -34,8 +34,7 @@
android:contentDescription="@string/resto_legend_soup"
android:paddingEnd="16dp"
android:paddingRight="16dp"
- app:srcCompat="@drawable/resto_soup"
- tools:ignore="RtlSymmetry" />
+ app:srcCompat="@drawable/resto_soup" />
+ app:srcCompat="@drawable/resto_vegetables" />
+ app:srcCompat="@drawable/resto_fish" />
+ app:srcCompat="@drawable/resto_meat" />
+ app:srcCompat="@drawable/resto_vegetarian" />
+ app:srcCompat="@drawable/resto_vegan" />
+ style="?textAppearanceBody2" />
+ android:paddingRight="16dp" />
+ style="?textAppearanceBody2" />
+ app:srcCompat="@drawable/ic_play_arrow_24dp"
+ android:contentDescription="@string/content_desc_urgent_play" />
@@ -122,7 +123,8 @@
android:layout_height="@dimen/urgent_social_icon_size"
android:scaleType="fitCenter"
app:srcCompat="@drawable/ic_social_facebook_inner"
- android:tint="?colorPrimary" />
+ android:tint="?colorPrimary"
+ android:contentDescription="@string/content_desc_facebook" />
+ android:tint="?colorPrimary"
+ android:contentDescription="@string/content_desc_instagram" />
+ android:tint="?colorPrimary"
+ android:contentDescription="@string/content_desc_website" />
+ android:tint="?colorPrimary"
+ android:contentDescription="@string/content_desc_youtube" />
diff --git a/app/src/main/res/layout/home_card_schamper.xml b/app/src/main/res/layout/home_card_schamper.xml
index 3e54ea692..431eea0e2 100644
--- a/app/src/main/res/layout/home_card_schamper.xml
+++ b/app/src/main/res/layout/home_card_schamper.xml
@@ -7,7 +7,8 @@
android:layout_height="wrap_content"
android:foreground="?android:attr/selectableItemBackground"
android:layout_marginBottom="@dimen/card_spacing"
- android:clickable="true">
+ android:clickable="true"
+ android:focusable="true">
+ android:contentDescription="@string/content_desc_schamper_image" />
diff --git a/app/src/main/res/layout/home_card_special.xml b/app/src/main/res/layout/home_card_special.xml
index 4c5b0164d..7acf93fc6 100644
--- a/app/src/main/res/layout/home_card_special.xml
+++ b/app/src/main/res/layout/home_card_special.xml
@@ -48,7 +48,7 @@
android:scaleType="fitEnd"
android:paddingTop="16dp"
android:id="@+id/image"
- android:contentDescription="@string/content_desc_special_event_icon"/>
+ android:contentDescription="@string/content_desc_special_event_icon" />
diff --git a/app/src/main/res/layout/item_checkbox_string.xml b/app/src/main/res/layout/item_checkbox_string.xml
index 55eda4e47..063333cba 100644
--- a/app/src/main/res/layout/item_checkbox_string.xml
+++ b/app/src/main/res/layout/item_checkbox_string.xml
@@ -10,8 +10,7 @@
android:clickable="true"
android:focusable="true"
android:paddingLeft="@dimen/material_list_icon_first_position_margin_start"
- android:paddingStart="@dimen/material_list_icon_first_position_margin_start"
- tools:ignore="RtlSymmetry">
+ android:paddingStart="@dimen/material_list_icon_first_position_margin_start">
+ android:focusable="true">
+ tools:text="Start" />
diff --git a/app/src/main/res/layout/item_library.xml b/app/src/main/res/layout/item_library.xml
index f0d81f754..7956cbada 100644
--- a/app/src/main/res/layout/item_library.xml
+++ b/app/src/main/res/layout/item_library.xml
@@ -53,7 +53,7 @@
android:layout_width="@dimen/material_list_icon_size"
android:layout_height="@dimen/material_list_icon_size"
app:srcCompat="@drawable/ic_star"
- android:tint="?colorSecondary"
- android:contentDescription="@string/content_desc_library" />
+ android:contentDescription="@string/content_desc_library"
+ app:tint="?colorSecondary" />
diff --git a/app/src/main/res/layout/x_now_toolbar.xml b/app/src/main/res/layout/x_now_toolbar.xml
index b834778d7..f850110ce 100644
--- a/app/src/main/res/layout/x_now_toolbar.xml
+++ b/app/src/main/res/layout/x_now_toolbar.xml
@@ -1,7 +1,8 @@
+
+
+ tools:ignore="MissingPrefix"
+ android:contentDescription="@string/content_desc_resto"
+ app:tint="@color/hydra_color_primary_variant_light" />
+ tools:text="Menu voor de toekomst!" />
+ app:tint="?colorOnSurface" />
diff --git a/app/src/main/res/layout/x_progress_bar.xml b/app/src/main/res/layout/x_progress_bar.xml
index fd7b93177..cfc6fcb96 100644
--- a/app/src/main/res/layout/x_progress_bar.xml
+++ b/app/src/main/res/layout/x_progress_bar.xml
@@ -1,8 +1,6 @@
-
\ No newline at end of file
+ android:layout_gravity="center_vertical" />
\ No newline at end of file
diff --git a/app/src/main/res/values-en/strings.xml b/app/src/main/res/values-en/strings.xml
index da7bb3a09..5ab8c576f 100644
--- a/app/src/main/res/values-en/strings.xml
+++ b/app/src/main/res/values-en/strings.xml
@@ -331,4 +331,9 @@
Icon special eventUrgent.fm iconIcon organisation
+ Play
+ Instagram
+ Website
+ Facebook
+ YouTube
diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml
index 68cdd3bd4..104bcb07b 100644
--- a/app/src/main/res/values/strings.xml
+++ b/app/src/main/res/values/strings.xml
@@ -337,4 +337,9 @@
Icoon speciaal evenementLogo Urgent.fmIcon vereniging
+ Spelen
+ Instagram
+ Website
+ Facebook
+ YouTube
diff --git a/app/src/open/AndroidManifest.xml b/app/src/open/AndroidManifest.xml
new file mode 100644
index 000000000..92c538477
--- /dev/null
+++ b/app/src/open/AndroidManifest.xml
@@ -0,0 +1,9 @@
+
+
+
+
+
+
+
+
diff --git a/app/src/open/java/be/ugent/zeus/hydra/common/network/CertificateProvider.java b/app/src/open/java/be/ugent/zeus/hydra/common/network/CertificateProvider.java
new file mode 100644
index 000000000..5af8c57e0
--- /dev/null
+++ b/app/src/open/java/be/ugent/zeus/hydra/common/network/CertificateProvider.java
@@ -0,0 +1,14 @@
+package be.ugent.zeus.hydra.common.network;
+
+import android.content.Context;
+
+/**
+ * @author Niko Strijbol
+ */
+public class CertificateProvider {
+
+ @SuppressWarnings({"unused", "EmptyMethod"})
+ public static void installProvider(Context context) {
+ // Nothing.
+ }
+}
diff --git a/app/src/open/java/be/ugent/zeus/hydra/common/reporting/DummyHolder.java b/app/src/open/java/be/ugent/zeus/hydra/common/reporting/DummyHolder.java
new file mode 100644
index 000000000..be05604ab
--- /dev/null
+++ b/app/src/open/java/be/ugent/zeus/hydra/common/reporting/DummyHolder.java
@@ -0,0 +1,101 @@
+package be.ugent.zeus.hydra.common.reporting;
+
+/**
+ * @author Niko Strijbol
+ */
+class DummyHolder implements BaseEvents {
+
+ private static class DummyParams implements Params {
+
+ @Override
+ public String method() {
+ return "null";
+ }
+
+ @Override
+ public String searchTerm() {
+ return "null";
+ }
+
+ @Override
+ public String contentType() {
+ return "null";
+ }
+
+ @Override
+ public String itemId() {
+ return "null";
+ }
+
+ @Override
+ public String itemName() {
+ return "null";
+ }
+
+ @Override
+ public String itemCategory() {
+ return "null";
+ }
+
+ @Override
+ public String dismissalType() {
+ return "null";
+ }
+
+ @Override
+ public String cardType() {
+ return "null";
+ }
+
+ @Override
+ public String cardIdentifier() {
+ return "null";
+ }
+ }
+
+
+ @Override
+ public Params params() {
+ return new DummyParams();
+ }
+
+ @Override
+ public String login() {
+ return "null";
+ }
+
+ @Override
+ public String search() {
+ return "null";
+ }
+
+ @Override
+ public String selectContent() {
+ return "null";
+ }
+
+ @Override
+ public String share() {
+ return "null";
+ }
+
+ @Override
+ public String tutorialBegin() {
+ return "null";
+ }
+
+ @Override
+ public String tutorialComplete() {
+ return "null";
+ }
+
+ @Override
+ public String viewItem() {
+ return "null";
+ }
+
+ @Override
+ public String cardDismissal() {
+ return "null";
+ }
+}
diff --git a/app/src/open/java/be/ugent/zeus/hydra/common/reporting/DummyTracker.java b/app/src/open/java/be/ugent/zeus/hydra/common/reporting/DummyTracker.java
new file mode 100644
index 000000000..23ac3dad5
--- /dev/null
+++ b/app/src/open/java/be/ugent/zeus/hydra/common/reporting/DummyTracker.java
@@ -0,0 +1,41 @@
+package be.ugent.zeus.hydra.common.reporting;
+
+import android.app.Activity;
+import androidx.annotation.NonNull;
+
+/**
+ * Tracker that does nothing.
+ *
+ * @author Niko Strijbol
+ */
+class DummyTracker implements Tracker {
+ @Override
+ public void log(Event event) {
+ // Nothing.
+ }
+
+ @Override
+ public void setCurrentScreen(@NonNull Activity activity, String screenName, String classOverride) {
+ // Nothing.
+ }
+
+ @Override
+ public void setUserProperty(String name, String value) {
+ // Nothing.
+ }
+
+ @Override
+ public void logError(Throwable throwable) {
+ // Nothing.
+ }
+
+ @Override
+ public void allowAnalytics(boolean allowed) {
+ // Nothing.
+ }
+
+ @Override
+ public void allowCrashReporting(boolean allowed) {
+ // Nothing.
+ }
+}
diff --git a/app/src/open/java/be/ugent/zeus/hydra/common/reporting/Reporting.java b/app/src/open/java/be/ugent/zeus/hydra/common/reporting/Reporting.java
new file mode 100644
index 000000000..abebfb507
--- /dev/null
+++ b/app/src/open/java/be/ugent/zeus/hydra/common/reporting/Reporting.java
@@ -0,0 +1,47 @@
+package be.ugent.zeus.hydra.common.reporting;
+
+import android.content.Context;
+import android.content.SharedPreferences;
+import android.util.Log;
+import androidx.annotation.VisibleForTesting;
+import androidx.preference.PreferenceManager;
+import be.ugent.zeus.hydra.BuildConfig;
+
+/**
+ * Produces the default tracker.
+ *
+ * @author Niko Strijbol
+ */
+public final class Reporting {
+
+ private static Tracker tracker;
+ private final static Object lock = new Object();
+
+ /**
+ * Get the default tracker.
+ *
+ * @param context The context.
+ * @return The tracker.
+ */
+ public static Tracker getTracker(Context context) {
+ synchronized (lock) {
+ if (tracker == null) {
+ tracker = new DummyTracker();
+ }
+ }
+ return tracker;
+ }
+
+ public static BaseEvents getEvents() {
+ return new DummyHolder();
+ }
+
+ @VisibleForTesting
+ public static void setTracker(Tracker tracker) {
+ Reporting.tracker = tracker;
+ }
+
+ public static boolean hasReportingOptions() {
+ return false;
+ }
+}
diff --git a/app/src/open/java/be/ugent/zeus/hydra/resto/meta/RestoLocationActivity.java b/app/src/open/java/be/ugent/zeus/hydra/resto/meta/RestoLocationActivity.java
new file mode 100644
index 000000000..c3793362f
--- /dev/null
+++ b/app/src/open/java/be/ugent/zeus/hydra/resto/meta/RestoLocationActivity.java
@@ -0,0 +1,155 @@
+package be.ugent.zeus.hydra.resto.meta;
+
+import android.Manifest;
+import android.content.Context;
+import android.content.pm.PackageManager;
+import android.os.Bundle;
+import android.util.Log;
+import android.view.Menu;
+import android.view.MenuItem;
+import android.view.View;
+import androidx.annotation.NonNull;
+import androidx.core.app.ActivityCompat;
+import androidx.core.content.ContextCompat;
+import androidx.lifecycle.ViewModelProvider;
+import androidx.preference.PreferenceManager;
+
+import be.ugent.zeus.hydra.R;
+import be.ugent.zeus.hydra.common.arch.observers.PartialErrorObserver;
+import be.ugent.zeus.hydra.common.arch.observers.ProgressObserver;
+import be.ugent.zeus.hydra.common.arch.observers.SuccessObserver;
+import be.ugent.zeus.hydra.common.ui.BaseActivity;
+import be.ugent.zeus.hydra.databinding.ActivityRestoLocationBinding;
+import com.google.android.material.snackbar.Snackbar;
+import org.osmdroid.api.IMapController;
+import org.osmdroid.config.Configuration;
+import org.osmdroid.tileprovider.tilesource.TileSourceFactory;
+import org.osmdroid.util.GeoPoint;
+import org.osmdroid.views.CustomZoomButtonsController;
+import org.osmdroid.views.overlay.Marker;
+import org.osmdroid.views.overlay.mylocation.GpsMyLocationProvider;
+import org.osmdroid.views.overlay.mylocation.MyLocationNewOverlay;
+
+public class RestoLocationActivity extends BaseActivity {
+
+ private static final String TAG = "RestoLocationActivity";
+
+ private static final GeoPoint DEFAULT_LOCATION = new GeoPoint(51.05, 3.72); //Gent
+ private static final float DEFAULT_ZOOM = 15;
+
+ private static final int MY_LOCATION_REQUEST_CODE = 1;
+
+ private RestoMeta meta;
+ private MetaViewModel viewModel;
+ private MyLocationNewOverlay myLocation;
+
+ @Override
+ protected void onCreate(Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+
+ Context ctx = getApplicationContext();
+ Configuration.getInstance().load(ctx, PreferenceManager.getDefaultSharedPreferences(ctx));
+
+ setContentView(ActivityRestoLocationBinding::inflate);
+
+ binding.map.setTileSource(TileSourceFactory.MAPNIK);
+ binding.map.getZoomController().setVisibility(CustomZoomButtonsController.Visibility.ALWAYS);
+ binding.map.setMultiTouchControls(true);
+
+ IMapController mapController = binding.map.getController();
+ mapController.setZoom(DEFAULT_ZOOM);
+ mapController.setCenter(DEFAULT_LOCATION);
+
+ viewModel = new ViewModelProvider(this).get(MetaViewModel.class);
+ viewModel.getData().observe(this, PartialErrorObserver.with(this::onError));
+ viewModel.getData().observe(this, new ProgressObserver<>(binding.progressBar));
+ viewModel.getData().observe(this, SuccessObserver.with(this::receiveData));
+
+ if (ContextCompat.checkSelfPermission(this, Manifest.permission.ACCESS_FINE_LOCATION) == PackageManager.PERMISSION_GRANTED) {
+ enableLocation();
+ } else {
+ ActivityCompat.requestPermissions(this, new String[]{Manifest.permission.ACCESS_FINE_LOCATION}, MY_LOCATION_REQUEST_CODE);
+ }
+ }
+
+ private void receiveData(@NonNull RestoMeta data) {
+ meta = data;
+ addData();
+ }
+
+ @Override
+ public boolean onCreateOptionsMenu(Menu menu) {
+ getMenuInflater().inflate(R.menu.menu_resto_location, menu);
+ tintToolbarIcons(menu, R.id.resto_refresh, R.id.resto_center);
+ return super.onCreateOptionsMenu(menu);
+ }
+
+ @Override
+ public boolean onOptionsItemSelected(MenuItem item) {
+ switch (item.getItemId()) {
+ case R.id.resto_refresh:
+ viewModel.onRefresh();
+ return true;
+ case R.id.resto_center:
+ if (this.myLocation != null) {
+ IMapController mapController = binding.map.getController();
+ mapController.setCenter(myLocation.getMyLocation());
+ }
+ return true;
+ default:
+ return super.onOptionsItemSelected(item);
+ }
+ }
+
+ private void addData() {
+
+ for (Resto location : meta.locations) {
+ GeoPoint point = new GeoPoint(location.getLatitude(), location.getLongitude());
+ Marker m = new Marker(binding.map);
+ m.setPosition(point);
+ m.setTitle(location.getName());
+ m.setSubDescription(location.getAddress());
+ m.setDraggable(false);
+ binding.map.getOverlayManager().add(m);
+ }
+ binding.progressBar.progressBar.setVisibility(View.GONE);
+ }
+
+ @Override
+ public void onRequestPermissionsResult(int requestCode, @NonNull String[] permissions, @NonNull int[] grantResults) {
+ if (requestCode == MY_LOCATION_REQUEST_CODE) {
+ if (permissions.length == 1 && permissions[0].equals(Manifest.permission.ACCESS_FINE_LOCATION) && grantResults[0] == PackageManager.PERMISSION_GRANTED) {
+ enableLocation();
+ }
+ }
+ }
+
+ private void enableLocation() {
+ if (myLocation != null) {
+ myLocation.disableMyLocation();
+ binding.map.getOverlayManager().remove(myLocation);
+ }
+ myLocation = new MyLocationNewOverlay(new GpsMyLocationProvider(this), binding.map);
+ myLocation.enableMyLocation();
+ binding.map.getOverlayManager().add(myLocation);
+ }
+
+ private void onError(Throwable throwable) {
+ Log.e(TAG, "Error while getting data.", throwable);
+ Snackbar.make(findViewById(android.R.id.content), getString(R.string.error_network), Snackbar.LENGTH_LONG)
+ .setAction(getString(R.string.action_again), v -> viewModel.onRefresh())
+ .show();
+ }
+
+ @Override
+ protected void onResume() {
+ super.onResume();
+ binding.map.onResume();
+ }
+
+ @Override
+ protected void onPause() {
+ super.onPause();
+ binding.map.onPause();
+ }
+}
diff --git a/app/src/open/res/layout/activity_resto_location.xml b/app/src/open/res/layout/activity_resto_location.xml
new file mode 100644
index 000000000..1c8cdec6e
--- /dev/null
+++ b/app/src/open/res/layout/activity_resto_location.xml
@@ -0,0 +1,32 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/app/src/store/AndroidManifest.xml b/app/src/store/AndroidManifest.xml
new file mode 100644
index 000000000..e5f5fae7a
--- /dev/null
+++ b/app/src/store/AndroidManifest.xml
@@ -0,0 +1,21 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/app/google-services.json b/app/src/store/google-services.json
similarity index 100%
rename from app/google-services.json
rename to app/src/store/google-services.json
diff --git a/app/src/store/java/be/ugent/zeus/hydra/common/network/CertificateProvider.java b/app/src/store/java/be/ugent/zeus/hydra/common/network/CertificateProvider.java
new file mode 100644
index 000000000..0ee6a881f
--- /dev/null
+++ b/app/src/store/java/be/ugent/zeus/hydra/common/network/CertificateProvider.java
@@ -0,0 +1,30 @@
+package be.ugent.zeus.hydra.common.network;
+
+import android.content.Context;
+import android.util.Log;
+
+import com.google.android.gms.common.GoogleApiAvailability;
+import com.google.android.gms.common.GooglePlayServicesNotAvailableException;
+import com.google.android.gms.common.GooglePlayServicesRepairableException;
+import com.google.android.gms.security.ProviderInstaller;
+
+/**
+ * @author Niko Strijbol
+ */
+public class CertificateProvider {
+
+ private static final String TAG = "CertificateProvider";
+
+ public static void installProvider(Context context) {
+ Log.i(TAG, "Installing Play Services to enable TLSv1.2");
+ try {
+ ProviderInstaller.installIfNeeded(context);
+ } catch (GooglePlayServicesRepairableException e) {
+ Log.w(TAG, "Play Services are outdated", e);
+ // Prompt the user to install/update/enable Google Play services.
+ GoogleApiAvailability.getInstance().showErrorNotification(context, e.getConnectionStatusCode());
+ } catch (GooglePlayServicesNotAvailableException e) {
+ Log.e(TAG, "Unable to install provider, SSL will not work", e);
+ }
+ }
+}
diff --git a/app/src/main/java/be/ugent/zeus/hydra/common/reporting/FirebaseEvents.java b/app/src/store/java/be/ugent/zeus/hydra/common/reporting/FirebaseEvents.java
similarity index 100%
rename from app/src/main/java/be/ugent/zeus/hydra/common/reporting/FirebaseEvents.java
rename to app/src/store/java/be/ugent/zeus/hydra/common/reporting/FirebaseEvents.java
diff --git a/app/src/main/java/be/ugent/zeus/hydra/common/reporting/FirebaseTracker.java b/app/src/store/java/be/ugent/zeus/hydra/common/reporting/FirebaseTracker.java
similarity index 77%
rename from app/src/main/java/be/ugent/zeus/hydra/common/reporting/FirebaseTracker.java
rename to app/src/store/java/be/ugent/zeus/hydra/common/reporting/FirebaseTracker.java
index 5c93565d0..00194cba5 100644
--- a/app/src/main/java/be/ugent/zeus/hydra/common/reporting/FirebaseTracker.java
+++ b/app/src/store/java/be/ugent/zeus/hydra/common/reporting/FirebaseTracker.java
@@ -2,15 +2,15 @@
import android.app.Activity;
import android.content.Context;
-
+import android.os.Bundle;
import androidx.annotation.NonNull;
-import com.crashlytics.android.Crashlytics;
import com.google.firebase.analytics.FirebaseAnalytics;
-import io.fabric.sdk.android.Fabric;
+import com.google.firebase.crashlytics.FirebaseCrashlytics;
/**
* A tracker implemented using Firebase Analytics and Crashlytics.
+ *
* @author Niko Strijbol
*/
class FirebaseTracker implements Tracker {
@@ -32,8 +32,11 @@ public void log(Event event) {
@Override
public void setCurrentScreen(@NonNull Activity activity, String screenName, String classOverride) {
+ Bundle bundle = new Bundle();
+ bundle.putString(FirebaseAnalytics.Param.SCREEN_NAME, screenName);
+ bundle.putString(FirebaseAnalytics.Param.SCREEN_CLASS, classOverride);
FirebaseAnalytics.getInstance(applicationContext)
- .setCurrentScreen(activity, screenName, classOverride);
+ .logEvent(FirebaseAnalytics.Event.SCREEN_VIEW, bundle);
}
@Override
@@ -46,14 +49,7 @@ public void setUserProperty(String name, String value) {
public void logError(Throwable throwable) {
// Prevent logging exceptions if it is not enabled.
if (isCrashReportingAllowed) {
- Crashlytics.logException(throwable);
- }
- }
-
- @Override
- public void logErrorMessage(String message) {
- if (isCrashReportingAllowed) {
- Crashlytics.log(message);
+ FirebaseCrashlytics.getInstance().recordException(throwable);
}
}
@@ -69,7 +65,7 @@ public void allowAnalytics(boolean allowed) {
public void allowCrashReporting(boolean allowed) {
isCrashReportingAllowed = allowed;
if (allowed) {
- Fabric.with(applicationContext, new Crashlytics());
+ FirebaseCrashlytics.getInstance().setCrashlyticsCollectionEnabled(true);
}
}
}
\ No newline at end of file
diff --git a/app/src/store/java/be/ugent/zeus/hydra/common/reporting/Reporting.java b/app/src/store/java/be/ugent/zeus/hydra/common/reporting/Reporting.java
new file mode 100644
index 000000000..6c49f8208
--- /dev/null
+++ b/app/src/store/java/be/ugent/zeus/hydra/common/reporting/Reporting.java
@@ -0,0 +1,43 @@
+package be.ugent.zeus.hydra.common.reporting;
+
+import android.content.Context;
+import androidx.annotation.VisibleForTesting;
+
+/**
+ * Produces the default tracker.
+ *
+ * @author Niko Strijbol
+ */
+public final class Reporting {
+
+ private static Tracker tracker;
+ private final static Object lock = new Object();
+
+ /**
+ * Get the default tracker.
+ *
+ * @param context The context.
+ * @return The tracker.
+ */
+ public static Tracker getTracker(Context context) {
+ synchronized (lock) {
+ if (tracker == null) {
+ tracker = new FirebaseTracker(context);
+ }
+ }
+ return tracker;
+ }
+
+ public static BaseEvents getEvents() {
+ return FirebaseEvents.getInstance();
+ }
+
+ @VisibleForTesting
+ public static void setTracker(Tracker tracker) {
+ Reporting.tracker = tracker;
+ }
+
+ public static boolean hasReportingOptions() {
+ return true;
+ }
+}
diff --git a/app/src/main/java/be/ugent/zeus/hydra/resto/meta/RestoLocationActivity.java b/app/src/store/java/be/ugent/zeus/hydra/resto/meta/RestoLocationActivity.java
similarity index 93%
rename from app/src/main/java/be/ugent/zeus/hydra/resto/meta/RestoLocationActivity.java
rename to app/src/store/java/be/ugent/zeus/hydra/resto/meta/RestoLocationActivity.java
index 2d40ed468..51e8fdc1c 100644
--- a/app/src/main/java/be/ugent/zeus/hydra/resto/meta/RestoLocationActivity.java
+++ b/app/src/store/java/be/ugent/zeus/hydra/resto/meta/RestoLocationActivity.java
@@ -1,13 +1,13 @@
package be.ugent.zeus.hydra.resto.meta;
import android.Manifest;
+import android.annotation.SuppressLint;
import android.content.pm.PackageManager;
import android.os.Bundle;
import android.util.Log;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
-import android.widget.ProgressBar;
import androidx.annotation.NonNull;
import androidx.core.app.ActivityCompat;
import androidx.core.content.ContextCompat;
@@ -18,6 +18,7 @@
import be.ugent.zeus.hydra.common.arch.observers.ProgressObserver;
import be.ugent.zeus.hydra.common.arch.observers.SuccessObserver;
import be.ugent.zeus.hydra.common.ui.BaseActivity;
+import be.ugent.zeus.hydra.databinding.ActivityRestoLocationBinding;
import com.google.android.gms.maps.CameraUpdateFactory;
import com.google.android.gms.maps.GoogleMap;
import com.google.android.gms.maps.OnMapReadyCallback;
@@ -27,7 +28,7 @@
import com.google.android.gms.maps.model.MarkerOptions;
import com.google.android.material.snackbar.Snackbar;
-public class RestoLocationActivity extends BaseActivity implements OnMapReadyCallback {
+public class RestoLocationActivity extends BaseActivity implements OnMapReadyCallback {
private static final String TAG = "RestoLocationActivity";
@@ -38,21 +39,19 @@ public class RestoLocationActivity extends BaseActivity implements OnMapReadyCal
private GoogleMap map;
private RestoMeta meta;
- private ProgressBar progressBar;
private MetaViewModel viewModel;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
- setContentView(R.layout.activity_resto_location);
- progressBar = findViewById(R.id.progress_bar);
+ setContentView(ActivityRestoLocationBinding::inflate);
// Obtain the SupportMapFragment and get notified when the map is ready to be used.
SupportMapFragment mapFragment = (SupportMapFragment) getSupportFragmentManager().findFragmentById(R.id.map);
assert mapFragment != null;
mapFragment.getMapAsync(this);
viewModel = new ViewModelProvider(this).get(MetaViewModel.class);
viewModel.getData().observe(this, PartialErrorObserver.with(this::onError));
- viewModel.getData().observe(this, new ProgressObserver<>(progressBar));
+ viewModel.getData().observe(this, new ProgressObserver<>(binding.progressBar));
viewModel.getData().observe(this, SuccessObserver.with(this::receiveData));
}
@@ -101,6 +100,7 @@ public boolean onOptionsItemSelected(MenuItem item) {
}
}
+ @SuppressLint("MissingPermission")
private void addData() {
if (ContextCompat.checkSelfPermission(this, Manifest.permission.ACCESS_FINE_LOCATION) == PackageManager.PERMISSION_GRANTED) {
@@ -122,7 +122,7 @@ private void addData() {
);
}
centerDefault();
- progressBar.setVisibility(View.GONE);
+ binding.progressBar.progressBar.setVisibility(View.GONE);
}
private void centerDefault() {
diff --git a/app/src/main/res/layout/activity_resto_location.xml b/app/src/store/res/layout/activity_resto_location.xml
similarity index 83%
rename from app/src/main/res/layout/activity_resto_location.xml
rename to app/src/store/res/layout/activity_resto_location.xml
index e11c2aa80..d68186278 100644
--- a/app/src/main/res/layout/activity_resto_location.xml
+++ b/app/src/store/res/layout/activity_resto_location.xml
@@ -4,7 +4,7 @@
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent"
- tools:context=".resto.meta.RestoLocationActivity" >
+ tools:context=".resto.meta.RestoLocationActivity">
+ app:layout_behavior="@string/appbar_scrolling_view_behavior">
-
-
+
diff --git a/app/src/test/java/be/ugent/zeus/hydra/MainActivityTest.java b/app/src/test/java/be/ugent/zeus/hydra/MainActivityTest.java
index 419ecc317..198129d07 100644
--- a/app/src/test/java/be/ugent/zeus/hydra/MainActivityTest.java
+++ b/app/src/test/java/be/ugent/zeus/hydra/MainActivityTest.java
@@ -16,6 +16,7 @@
import okhttp3.OkHttpClient;
import org.junit.After;
import org.junit.Before;
+import org.junit.Ignore;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.robolectric.annotation.LooperMode;
@@ -34,6 +35,7 @@
/**
* @author Niko Strijbol
*/
+@Ignore("Race conditions make these tests unreliable")
@LooperMode(PAUSED)
@RunWith(AndroidJUnit4.class)
public class MainActivityTest {
diff --git a/app/src/test/java/be/ugent/zeus/hydra/TestApp.java b/app/src/test/java/be/ugent/zeus/hydra/TestApp.java
index 753808a14..dc39eb477 100644
--- a/app/src/test/java/be/ugent/zeus/hydra/TestApp.java
+++ b/app/src/test/java/be/ugent/zeus/hydra/TestApp.java
@@ -2,7 +2,7 @@
import android.content.Context;
-import be.ugent.zeus.hydra.common.reporting.Reporting;
+import be.ugent.zeus.hydra.common.reporting.Manager;
import jonathanfinerty.once.Once;
import static be.ugent.zeus.hydra.testing.RobolectricUtils.setupPicasso;
@@ -30,9 +30,9 @@ protected void onAttachBaseContextInitialize(Context base) {
protected void onCreateInitialise() {
Once.initialise(this);
- Reporting.saveAnalyticsPermission(this, false);
- Reporting.saveCrashReportingPermission(this, false);
- Reporting.syncPermissions(this);
+ Manager.saveAnalyticsPermission(this, false);
+ Manager.saveCrashReportingPermission(this, false);
+ Manager.syncPermissions(this);
setupPicasso();
diff --git a/app/src/test/java/be/ugent/zeus/hydra/association/event/DisabledEventRemoverTest.java b/app/src/test/java/be/ugent/zeus/hydra/association/event/DisabledEventRemoverTest.java
index 91cd48092..86c5e686e 100644
--- a/app/src/test/java/be/ugent/zeus/hydra/association/event/DisabledEventRemoverTest.java
+++ b/app/src/test/java/be/ugent/zeus/hydra/association/event/DisabledEventRemoverTest.java
@@ -11,7 +11,6 @@
import java.util.*;
import java.util.stream.Collectors;
-import be.ugent.zeus.hydra.TestApp;
import be.ugent.zeus.hydra.association.Association;
import be.ugent.zeus.hydra.common.network.InstanceProvider;
import be.ugent.zeus.hydra.testing.Utils;
@@ -21,7 +20,6 @@
import org.junit.Test;
import org.junit.runner.RunWith;
import org.robolectric.RobolectricTestRunner;
-import org.robolectric.annotation.Config;
import static be.ugent.zeus.hydra.association.preference.AssociationSelectionPreferenceFragment.PREF_ASSOCIATIONS_SHOWING;
import static org.junit.Assert.assertTrue;
diff --git a/app/src/test/java/be/ugent/zeus/hydra/association/event/EventDetailsActivityDeviceTest.java b/app/src/test/java/be/ugent/zeus/hydra/association/event/EventDetailsActivityDeviceTest.java
index 242e43f10..b54e4efc3 100644
--- a/app/src/test/java/be/ugent/zeus/hydra/association/event/EventDetailsActivityDeviceTest.java
+++ b/app/src/test/java/be/ugent/zeus/hydra/association/event/EventDetailsActivityDeviceTest.java
@@ -12,10 +12,7 @@
import be.ugent.zeus.hydra.testing.NoNetworkInterceptor;
import be.ugent.zeus.hydra.testing.Utils;
import okhttp3.OkHttpClient;
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Rule;
-import org.junit.Test;
+import org.junit.*;
import org.junit.runner.RunWith;
import static androidx.test.espresso.Espresso.onView;
@@ -25,6 +22,7 @@
/**
* @author Niko Strijbol
*/
+@Ignore("Race conditions make these tests unreliable")
@RunWith(AndroidJUnit4.class)
public class EventDetailsActivityDeviceTest {
diff --git a/app/src/test/java/be/ugent/zeus/hydra/association/event/EventDetailsActivityTest.java b/app/src/test/java/be/ugent/zeus/hydra/association/event/EventDetailsActivityTest.java
index 098740df6..a2d905f6b 100644
--- a/app/src/test/java/be/ugent/zeus/hydra/association/event/EventDetailsActivityTest.java
+++ b/app/src/test/java/be/ugent/zeus/hydra/association/event/EventDetailsActivityTest.java
@@ -11,6 +11,7 @@
import be.ugent.zeus.hydra.testing.Utils;
import okhttp3.OkHttpClient;
import org.junit.Before;
+import org.junit.Ignore;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.robolectric.RobolectricTestRunner;
@@ -20,6 +21,7 @@
/**
* @author Niko Strijbol
*/
+@Ignore("Race conditions make these tests unreliable")
@RunWith(RobolectricTestRunner.class)
public class EventDetailsActivityTest {
diff --git a/app/src/test/java/be/ugent/zeus/hydra/association/event/EventTest.java b/app/src/test/java/be/ugent/zeus/hydra/association/event/EventTest.java
index bade97899..0842dd445 100644
--- a/app/src/test/java/be/ugent/zeus/hydra/association/event/EventTest.java
+++ b/app/src/test/java/be/ugent/zeus/hydra/association/event/EventTest.java
@@ -1,6 +1,7 @@
package be.ugent.zeus.hydra.association.event;
import java.util.ArrayList;
+import java.util.Collections;
import java.util.Comparator;
import java.util.List;
import java.util.stream.Collectors;
@@ -11,7 +12,6 @@
import be.ugent.zeus.hydra.testing.Utils;
import be.ugent.zeus.hydra.common.utils.DateUtils;
import de.jaehrig.gettersetterverifier.GetterSetterVerifier;
-import edu.emory.mathcs.backport.java.util.Collections;
import org.junit.Test;
import org.threeten.bp.LocalDateTime;
import org.threeten.bp.OffsetDateTime;
diff --git a/app/src/test/java/be/ugent/zeus/hydra/association/event/list/EventSearchFilterTest.java b/app/src/test/java/be/ugent/zeus/hydra/association/event/list/EventSearchFilterTest.java
index 2f7cf42bf..34a9b2475 100644
--- a/app/src/test/java/be/ugent/zeus/hydra/association/event/list/EventSearchFilterTest.java
+++ b/app/src/test/java/be/ugent/zeus/hydra/association/event/list/EventSearchFilterTest.java
@@ -9,10 +9,10 @@
import java.util.stream.Collectors;
import static be.ugent.zeus.hydra.testing.Utils.generate;
+import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.empty;
import static org.hamcrest.Matchers.is;
import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertThat;
/**
* @author Niko Strijbol
diff --git a/app/src/test/java/be/ugent/zeus/hydra/association/event/list/EventSearchPredicateTest.java b/app/src/test/java/be/ugent/zeus/hydra/association/event/list/EventSearchPredicateTest.java
index 55e45fd7b..ecc59f8cf 100644
--- a/app/src/test/java/be/ugent/zeus/hydra/association/event/list/EventSearchPredicateTest.java
+++ b/app/src/test/java/be/ugent/zeus/hydra/association/event/list/EventSearchPredicateTest.java
@@ -12,9 +12,9 @@
import java.util.stream.Collectors;
import static be.ugent.zeus.hydra.testing.Utils.generate;
+import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.*;
import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertThat;
/**
* @author Niko Strijbol
diff --git a/app/src/test/java/be/ugent/zeus/hydra/common/network/JsonOkHttpRequestTest.java b/app/src/test/java/be/ugent/zeus/hydra/common/network/JsonOkHttpRequestTest.java
index e9c80c85d..68c84110d 100644
--- a/app/src/test/java/be/ugent/zeus/hydra/common/network/JsonOkHttpRequestTest.java
+++ b/app/src/test/java/be/ugent/zeus/hydra/common/network/JsonOkHttpRequestTest.java
@@ -395,9 +395,7 @@ private static class TestRequest extends JsonOkHttpRequest {
private final Duration cacheDuration;
TestRequest(HttpUrl url) {
- super(ApplicationProvider.getApplicationContext(), Integer.class);
- this.url = url;
- this.cacheDuration = Duration.ofHours(1);
+ this(url, Duration.ofHours(1));
}
TestRequest(HttpUrl url, Duration duration) {
diff --git a/app/src/test/java/be/ugent/zeus/hydra/common/ui/recyclerview/adapters/DiffUpdateTest.java b/app/src/test/java/be/ugent/zeus/hydra/common/ui/recyclerview/adapters/DiffUpdateTest.java
index 505dbc8f8..efb96dc9b 100644
--- a/app/src/test/java/be/ugent/zeus/hydra/common/ui/recyclerview/adapters/DiffUpdateTest.java
+++ b/app/src/test/java/be/ugent/zeus/hydra/common/ui/recyclerview/adapters/DiffUpdateTest.java
@@ -103,7 +103,7 @@ public void testBothEmpty() {
assertEquals(newData, actualNewData);
update.applyUpdatesTo(callback);
- verifyZeroInteractions(callback);
+ verifyNoInteractions(callback);
}
@Test
@@ -112,7 +112,7 @@ public void testBothNull() {
List actualNewData = update.getNewData(null);
assertNull(actualNewData);
update.applyUpdatesTo(callback);
- verifyZeroInteractions(callback);
+ verifyNoInteractions(callback);
}
@Test
diff --git a/app/src/test/java/be/ugent/zeus/hydra/feed/commands/DisableIndividualCardTest.java b/app/src/test/java/be/ugent/zeus/hydra/feed/commands/DisableIndividualCardTest.java
index 2abcff1aa..496e74139 100644
--- a/app/src/test/java/be/ugent/zeus/hydra/feed/commands/DisableIndividualCardTest.java
+++ b/app/src/test/java/be/ugent/zeus/hydra/feed/commands/DisableIndividualCardTest.java
@@ -54,12 +54,12 @@ public void testExecuteAndUndo() {
assertTrue(newDismissals.isEmpty());
}
+ @SuppressWarnings("MismatchedQueryAndUpdateOfCollection")
private static class MemoryTracker implements Tracker {
private final List logged = new ArrayList<>();
private final Map userValues = new HashMap<>();
private final List errors = new ArrayList<>();
- private final List errorMessages = new ArrayList<>();
private boolean allowingAnalytics;
private boolean allowingCrashReporting;
@@ -88,13 +88,6 @@ public void logError(Throwable throwable) {
}
}
- @Override
- public void logErrorMessage(String message) {
- if (allowingCrashReporting) {
- this.errorMessages.add(message);
- }
- }
-
@Override
public void allowAnalytics(boolean allowed) {
this.allowingAnalytics = allowed;
diff --git a/app/src/test/java/be/ugent/zeus/hydra/library/details/OpeningHoursRequestTest.java b/app/src/test/java/be/ugent/zeus/hydra/library/details/OpeningHoursRequestTest.java
index e84ae5058..a4890b0db 100644
--- a/app/src/test/java/be/ugent/zeus/hydra/library/details/OpeningHoursRequestTest.java
+++ b/app/src/test/java/be/ugent/zeus/hydra/library/details/OpeningHoursRequestTest.java
@@ -11,9 +11,9 @@
import org.junit.runner.RunWith;
import org.robolectric.RobolectricTestRunner;
+import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.endsWith;
import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertThat;
/**
* @author Niko Strijbol
diff --git a/app/src/test/java/be/ugent/zeus/hydra/library/favourites/FavouriteDaoTest.java b/app/src/test/java/be/ugent/zeus/hydra/library/favourites/FavouriteDaoTest.java
index ea346dab9..862572b89 100644
--- a/app/src/test/java/be/ugent/zeus/hydra/library/favourites/FavouriteDaoTest.java
+++ b/app/src/test/java/be/ugent/zeus/hydra/library/favourites/FavouriteDaoTest.java
@@ -20,14 +20,16 @@
import be.ugent.zeus.hydra.feed.cards.dismissal.DismissalDao;
import be.ugent.zeus.hydra.library.Library;
import be.ugent.zeus.hydra.testing.Utils;
-import org.junit.*;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Rule;
+import org.junit.Test;
import org.junit.runner.RunWith;
import org.robolectric.annotation.Config;
import org.robolectric.annotation.LooperMode;
import static be.ugent.zeus.hydra.testing.Utils.generate;
import static be.ugent.zeus.hydra.testing.Utils.getRandom;
-import static org.hamcrest.core.Is.is;
import static org.junit.Assert.*;
/**
diff --git a/app/src/test/java/be/ugent/zeus/hydra/library/list/LibraryViewHolderTest.java b/app/src/test/java/be/ugent/zeus/hydra/library/list/LibraryViewHolderTest.java
index 93e8c115e..942efcd80 100644
--- a/app/src/test/java/be/ugent/zeus/hydra/library/list/LibraryViewHolderTest.java
+++ b/app/src/test/java/be/ugent/zeus/hydra/library/list/LibraryViewHolderTest.java
@@ -14,7 +14,6 @@
import static be.ugent.zeus.hydra.testing.RobolectricUtils.*;
import static be.ugent.zeus.hydra.testing.Utils.generate;
import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertTrue;
import static org.mockito.Mockito.mock;
/**
@@ -49,10 +48,10 @@ public void populateFavourite() {
Library library = generate(Library.class);
LibraryListAdapter adapter = mock(LibraryListAdapter.class);
LibraryViewHolder viewHolder = new LibraryViewHolder(view, adapter);
-
+
viewHolder.populate(Pair.create(library, true));
assertEquals(view.findViewById(R.id.library_favourite_image).getVisibility(), View.VISIBLE);
-
+
viewHolder.populate(Pair.create(library, false));
assertEquals(view.findViewById(R.id.library_favourite_image).getVisibility(), View.GONE);
}
diff --git a/app/src/test/java/be/ugent/zeus/hydra/resto/history/DayRequestTest.java b/app/src/test/java/be/ugent/zeus/hydra/resto/history/DayRequestTest.java
index 87260b59b..1b0c80aad 100644
--- a/app/src/test/java/be/ugent/zeus/hydra/resto/history/DayRequestTest.java
+++ b/app/src/test/java/be/ugent/zeus/hydra/resto/history/DayRequestTest.java
@@ -10,8 +10,8 @@
import org.robolectric.RobolectricTestRunner;
import org.threeten.bp.LocalDate;
+import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.endsWith;
-import static org.junit.Assert.assertThat;
/**
* @author Niko Strijbol
diff --git a/app/src/test/java/be/ugent/zeus/hydra/resto/menu/MenuFilterTest.java b/app/src/test/java/be/ugent/zeus/hydra/resto/menu/MenuFilterTest.java
index b0651aadc..5d82ae8cc 100644
--- a/app/src/test/java/be/ugent/zeus/hydra/resto/menu/MenuFilterTest.java
+++ b/app/src/test/java/be/ugent/zeus/hydra/resto/menu/MenuFilterTest.java
@@ -21,9 +21,9 @@
import org.robolectric.RobolectricTestRunner;
import org.threeten.bp.*;
+import static be.ugent.zeus.hydra.testing.Assert.assertThat;
import static be.ugent.zeus.hydra.testing.Utils.generate;
import static org.hamcrest.Matchers.*;
-import static org.junit.Assert.assertThat;
import static org.junit.Assert.assertTrue;
/**
diff --git a/app/src/test/java/be/ugent/zeus/hydra/testing/Assert.java b/app/src/test/java/be/ugent/zeus/hydra/testing/Assert.java
index 44c734384..d45a0e560 100644
--- a/app/src/test/java/be/ugent/zeus/hydra/testing/Assert.java
+++ b/app/src/test/java/be/ugent/zeus/hydra/testing/Assert.java
@@ -16,7 +16,6 @@
import org.hamcrest.Matcher;
import org.hamcrest.StringDescription;
import org.hamcrest.TypeSafeDiagnosingMatcher;
-import org.hamcrest.beans.SamePropertyValuesAs;
import org.junit.ComparisonFailure;
import org.threeten.bp.OffsetDateTime;
import org.threeten.bp.ZonedDateTime;
diff --git a/app/src/test/java/be/ugent/zeus/hydra/testing/Utils.java b/app/src/test/java/be/ugent/zeus/hydra/testing/Utils.java
index e89158509..7b0af29cf 100644
--- a/app/src/test/java/be/ugent/zeus/hydra/testing/Utils.java
+++ b/app/src/test/java/be/ugent/zeus/hydra/testing/Utils.java
@@ -15,8 +15,9 @@
import com.squareup.moshi.JsonAdapter;
import com.squareup.moshi.Moshi;
import nl.jqno.equalsverifier.EqualsVerifier;
-import nl.jqno.equalsverifier.EqualsVerifierApi;
import nl.jqno.equalsverifier.Warning;
+import nl.jqno.equalsverifier.api.EqualsVerifierApi;
+import nl.jqno.equalsverifier.api.SingleTypeEqualsVerifierApi;
import okio.BufferedSource;
import okio.Okio;
import org.jeasy.random.EasyRandom;
@@ -69,7 +70,7 @@ public static Stream generate(Class clazz, int amount, String... exclu
*
* @return The verifier.
*/
- public static EqualsVerifierApi defaultVerifier(Class clazz) {
+ public static SingleTypeEqualsVerifierApi defaultVerifier(Class clazz) {
return EqualsVerifier.forClass(clazz)
.suppress(Warning.NONFINAL_FIELDS)
.withPrefabValues(ZonedDateTime.class, ZonedDateTime.now(), ZonedDateTime.now().minusDays(2));
diff --git a/app/src/test/resources/robolectric.properties b/app/src/test/resources/robolectric.properties
index 6f61bd111..5bee0d088 100644
--- a/app/src/test/resources/robolectric.properties
+++ b/app/src/test/resources/robolectric.properties
@@ -1,2 +1,2 @@
application = be.ugent.zeus.hydra.TestApp
-sdk=29
+sdk=16,29
diff --git a/build.gradle b/build.gradle
index cce789308..dda072824 100644
--- a/build.gradle
+++ b/build.gradle
@@ -4,17 +4,14 @@ buildscript {
repositories {
// For Google-related dependencies
google()
- // For Fabric (Firebase Crashlytics)
- maven { url 'https://maven.fabric.io/public' }
// For the license plugin
mavenCentral()
jcenter()
}
dependencies {
- classpath 'com.android.tools.build:gradle:3.6.1'
+ classpath 'com.android.tools.build:gradle:4.0.1'
classpath 'com.google.gms:google-services:4.3.3'
- classpath 'com.google.android.gms:oss-licenses-plugin:0.10.2'
- classpath 'io.fabric.tools:gradle:1.31.2'
+ classpath 'com.google.firebase:firebase-crashlytics-gradle:2.2.1'
}
}
diff --git a/buildSrc/README.md b/buildSrc/README.md
new file mode 100644
index 000000000..230c82d32
--- /dev/null
+++ b/buildSrc/README.md
@@ -0,0 +1,6 @@
+# License plugin
+
+This plugin will collect licences of dependencies.
+It is a fork of https://github.com/google/play-services-plugins/tree/master/oss-licenses-plugin, where the output is not some weird format, but an HTML file.
+
+The fork is based on version oss-licenses-plugin-v0.10.2
\ No newline at end of file
diff --git a/buildSrc/build.gradle b/buildSrc/build.gradle
new file mode 100644
index 000000000..072292b70
--- /dev/null
+++ b/buildSrc/build.gradle
@@ -0,0 +1,18 @@
+plugins {
+ id 'groovy'
+ id 'java'
+ id 'idea'
+}
+
+repositories {
+ google()
+ jcenter()
+}
+
+dependencies {
+ implementation gradleApi()
+ implementation localGroovy()
+ implementation 'com.android.tools.build:gradle:4.0.0'
+ testImplementation 'junit:junit:4.13'
+ testImplementation 'org.mockito:mockito-core:3.3.3'
+}
\ No newline at end of file
diff --git a/buildSrc/src/main/groovy/be/ugent/zeus/hydra/licenses/ArtifactInfo.groovy b/buildSrc/src/main/groovy/be/ugent/zeus/hydra/licenses/ArtifactInfo.groovy
new file mode 100644
index 000000000..b6dc3106a
--- /dev/null
+++ b/buildSrc/src/main/groovy/be/ugent/zeus/hydra/licenses/ArtifactInfo.groovy
@@ -0,0 +1,50 @@
+/**
+ * Copyright 2018 Google LLC
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * https://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package be.ugent.zeus.hydra.licenses
+
+class ArtifactInfo {
+ private String group
+ private String name
+ private String fileLocation
+ private String version
+
+ ArtifactInfo(String group,
+ String name,
+ String fileLocation,
+ String version) {
+ this.group = group
+ this.name = name
+ this.fileLocation = fileLocation
+ this.version = version
+ }
+
+ String getGroup() {
+ return group
+ }
+
+ String getName() {
+ return name
+ }
+
+ String getFileLocation() {
+ return fileLocation
+ }
+
+ String getVersion() {
+ return version
+ }
+}
\ No newline at end of file
diff --git a/buildSrc/src/main/groovy/be/ugent/zeus/hydra/licenses/DependencyTask.groovy b/buildSrc/src/main/groovy/be/ugent/zeus/hydra/licenses/DependencyTask.groovy
new file mode 100644
index 000000000..8aff88594
--- /dev/null
+++ b/buildSrc/src/main/groovy/be/ugent/zeus/hydra/licenses/DependencyTask.groovy
@@ -0,0 +1,241 @@
+/**
+ * Copyright 2018 Google LLC
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * https://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package be.ugent.zeus.hydra.licenses
+
+import groovy.json.JsonBuilder
+import groovy.json.JsonException
+import groovy.json.JsonSlurper
+import org.gradle.api.DefaultTask
+import org.gradle.api.artifacts.Configuration
+import org.gradle.api.artifacts.ConfigurationContainer
+import org.gradle.api.artifacts.ResolveException
+import org.gradle.api.artifacts.ResolvedArtifact
+import org.gradle.api.artifacts.ResolvedDependency
+import org.gradle.api.tasks.Input
+import org.gradle.api.tasks.OutputDirectory
+import org.gradle.api.tasks.OutputFile
+import org.gradle.api.tasks.TaskAction
+import org.gradle.internal.component.AmbiguousVariantSelectionException
+import org.slf4j.LoggerFactory
+
+/**
+ * This task does the following:
+ * First it finds all dependencies that meet all the requirements below:
+ * 1. Can be resolved.
+ * 2. Not test compile.
+ * Then it finds all the artifacts associated with the dependencies.
+ * Finally it generates a json file that contains the information about these
+ * artifacts.
+ */
+class DependencyTask extends DefaultTask {
+ protected Set artifactSet = []
+ protected Set artifactInfos = []
+ protected static final String LOCAL_LIBRARY_VERSION = "unspecified"
+ private static final String TEST_PREFIX = "test"
+ private static final String ANDROID_TEST_PREFIX = "androidTest"
+ private static final Set TEST_COMPILE = ["testCompile",
+ "androidTestCompile"]
+
+ private static final Set PACKAGED_DEPENDENCIES_PREFIXES = ["compile",
+ "implementation",
+ "api"]
+
+ private static final logger = LoggerFactory.getLogger(DependencyTask.class)
+
+ protected String variant
+
+ @Input
+ public ConfigurationContainer configurations
+
+ @OutputDirectory
+ public File outputDir
+
+ @OutputFile
+ public File outputFile
+
+ @TaskAction
+ void action() {
+ initOutput()
+ updateDependencyArtifacts()
+
+ if (outputFile.exists() && checkArtifactSet(outputFile)) {
+ return
+ }
+
+ outputFile.newWriter()
+ outputFile.write(new JsonBuilder(artifactInfos).toPrettyString())
+ }
+
+ /**
+ * Checks if current artifact set is the same as the artifact set in the
+ * json file
+ * @param file
+ * @return true if artifactSet is the same as the json file,
+ * false otherwise
+ */
+ protected boolean checkArtifactSet(File file) {
+ try {
+ def previousArtifacts = new JsonSlurper().parse(file)
+ for (entry in previousArtifacts) {
+ String key = "${entry.fileLocation}"
+ if (artifactSet.contains(key)) {
+ artifactSet.remove(key)
+ } else {
+ return false
+ }
+ }
+ return artifactSet.isEmpty()
+ } catch (JsonException ignored) {
+ return false
+ }
+ }
+
+ protected void updateDependencyArtifacts() {
+ for (Configuration configuration : configurations) {
+ if (!isForVariant(configuration)) {
+ continue
+ }
+ Set artifacts = getResolvedArtifacts(configuration)
+ if (artifacts == null) {
+ continue
+ }
+
+ addArtifacts(artifacts)
+ }
+ }
+
+ protected addArtifacts(Set artifacts) {
+ for (ResolvedArtifact artifact : artifacts) {
+ String group = artifact.moduleVersion.id.group
+ String artifact_key = artifact.file.getAbsolutePath()
+
+ if (artifactSet.contains(artifact_key)) {
+ continue
+ }
+
+ artifactSet.add(artifact_key)
+ artifactInfos.add(new ArtifactInfo(group, artifact.name,
+ artifact.file.getAbsolutePath(),
+ artifact.moduleVersion.id.version))
+ }
+ }
+
+ /**
+ * Checks if the configuration can be resolved. isCanBeResolved is added to
+ * gradle Api since 3.3. For the previous version, all the configurations
+ * can be resolved.
+ * @param configuration
+ * @return true if configuration can be resolved or the api is lower than
+ * 3.3, otherwise false.
+ */
+ protected static boolean canBeResolved(Configuration configuration) {
+ return configuration.metaClass.respondsTo(configuration, "isCanBeResolved") ? configuration.isCanBeResolved() : true
+ }
+
+ /**
+ * Checks if the configuration is from test.
+ * @param configuration
+ * @return true if configuration is a test configuration or its parent
+ * configurations are either testCompile or androidTestCompile, otherwise
+ * false.
+ */
+ protected static boolean isTest(Configuration configuration) {
+ boolean isTestConfiguration = (
+ configuration.name.startsWith(TEST_PREFIX) ||
+ configuration.name.startsWith(ANDROID_TEST_PREFIX))
+ configuration.hierarchy.each {
+ isTestConfiguration |= TEST_COMPILE.contains(it.name)
+ }
+ return isTestConfiguration
+ }
+
+ /**
+ * Checks if the configuration is for a packaged dependency (rather than e.g. a build or test time dependency)
+ * @param configuration
+ * @return true if the configuration is in the set of @link #BINARY_DEPENDENCIES
+ */
+ protected static boolean isPackagedDependency(Configuration configuration) {
+ boolean isPackagedDependency = PACKAGED_DEPENDENCIES_PREFIXES.any {
+ configuration.name.startsWith(it)
+ }
+ configuration.hierarchy.each {
+ String configurationHierarchyName = it.name
+ isPackagedDependency |= PACKAGED_DEPENDENCIES_PREFIXES.any {
+ configurationHierarchyName.startsWith(it)
+ }
+ }
+
+ return isPackagedDependency
+ }
+
+ protected boolean isForVariant(Configuration configuration) {
+ return configuration.name.startsWith(this.variant)
+ }
+
+ protected Set getResolvedArtifacts(Configuration configuration) {
+ /**
+ * skip the configurations that, cannot be resolved in
+ * newer version of gradle api, are tests, or are not packaged dependencies.
+ */
+
+ if (!canBeResolved(configuration) || isTest(configuration) || !isPackagedDependency(configuration)) {
+ return null
+ }
+
+ try {
+ return getResolvedArtifactsFromResolvedDependencies(
+ configuration.getResolvedConfiguration()
+ .getLenientConfiguration()
+ .getFirstLevelModuleDependencies())
+ } catch (ResolveException exception) {
+ logger.warn("Failed to resolve OSS licenses for $configuration.name.", exception)
+ return null
+ }
+ }
+
+ protected Set getResolvedArtifactsFromResolvedDependencies(
+ Set resolvedDependencies) {
+
+ HashSet resolvedArtifacts = new HashSet<>()
+ for (resolvedDependency in resolvedDependencies) {
+ try {
+ if (resolvedDependency.getModuleVersion() == LOCAL_LIBRARY_VERSION) {
+ /**
+ * Attempting to getAllModuleArtifacts on a local library project will result
+ * in AmbiguousVariantSelectionException as there are not enough criteria
+ * to match a specific variant of the library project. Instead we skip the
+ * the library project itself and enumerate its dependencies.
+ */
+ resolvedArtifacts.addAll(
+ getResolvedArtifactsFromResolvedDependencies(
+ resolvedDependency.getChildren()))
+ } else {
+ resolvedArtifacts.addAll(resolvedDependency.getAllModuleArtifacts())
+ }
+ } catch (AmbiguousVariantSelectionException exception) {
+ logger.warn("Failed to process $resolvedDependency.name", exception)
+ }
+ }
+ return resolvedArtifacts
+ }
+
+ private void initOutput() {
+ if (!outputDir.exists()) {
+ outputDir.mkdirs()
+ }
+ }
+}
\ No newline at end of file
diff --git a/buildSrc/src/main/groovy/be/ugent/zeus/hydra/licenses/LicenseMap.groovy b/buildSrc/src/main/groovy/be/ugent/zeus/hydra/licenses/LicenseMap.groovy
new file mode 100644
index 000000000..549b6b65d
--- /dev/null
+++ b/buildSrc/src/main/groovy/be/ugent/zeus/hydra/licenses/LicenseMap.groovy
@@ -0,0 +1,68 @@
+/**
+ * Copyright 2016 Jared Burrows
+ * Copyright 2020 Niko Strijbol
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * https://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed : in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package be.ugent.zeus.hydra.licenses
+
+/**
+ * Maps URLs : a license.
+ *
+ * Based on https://github.com/jaredsburrows/gradle-license-plugin/blob/master/src/main/kotlin/com/jaredsburrows/license/internal/LicenseHelper.kt
+ *
+ * @author Niko Strijbol
+ */
+@Singleton
+class LicenseMap {
+
+ def mapping = [
+ // Apache License 2.0
+ // https://github.com/github/choosealicense.com/blob/gh-pages/_licenses/apache-2.0.txt
+ "Apache 2.0" : "apache-2.0.txt",
+ "Apache License 2.0" : "apache-2.0.txt",
+ "The Apache Software License" : "apache-2.0.txt",
+ "The Apache Software License, Version 2.0" : "apache-2.0.txt",
+ "http://www.apache.org/licenses/LICENSE-2.0.txt" : "apache-2.0.txt",
+ "https://www.apache.org/licenses/LICENSE-2.0.txt" : "apache-2.0.txt",
+ "http://opensource.org/licenses/Apache-2.0" : "apache-2.0.txt",
+ "https://opensource.org/licenses/Apache-2.0" : "apache-2.0.txt",
+ // For OSM-droid, see https://github.com/osmdroid/osmdroid/issues/1542
+ "http://www.apache.org/licenses/" : "apache-2.0.txt",
+
+
+ // MIT License
+ // https://github.com/github/choosealicense.com/blob/gh-pages/_licenses/mit.txt
+ "MIT License" : "mit.txt",
+ "http://opensource.org/licenses/MIT" : "mit.txt",
+ "https://opensource.org/licenses/MIT" : "mit.txt",
+ "http://www.opensource.org/licenses/mit-license.php" : "mit.txt",
+
+ // GPLv2 + Classpath Exception
+ // https://github.com/github/choosealicense.com/blob/gh-pages/_licenses/mpl-2.0.txt
+ "http://openjdk.java.net/legal/gplv2+ce.html" : "gplv2ce.txt",
+
+ // Not a license -- skip these
+ "https://developer.android.com/studio/terms.html" : null,
+ "http://developer.android.com/studio/terms.html" : null,
+ "https://answers.io/terms" : null,
+ "http://answers.io/terms" : null,
+ "https://fabric.io/terms" : null,
+ "https://fabric.io/term" : null,
+ "http://try.crashlytics.com/terms/terms-of-service.pdf": null,
+
+ // Library specific licenses
+ "org.threeten:threetenbp" : "threeten.txt",
+ "com.heinrichreimersoftware:material-intro" : "material-intro.txt"
+ ]
+}
diff --git a/buildSrc/src/main/groovy/be/ugent/zeus/hydra/licenses/LicensesCleanUpTask.groovy b/buildSrc/src/main/groovy/be/ugent/zeus/hydra/licenses/LicensesCleanUpTask.groovy
new file mode 100644
index 000000000..fa4c16246
--- /dev/null
+++ b/buildSrc/src/main/groovy/be/ugent/zeus/hydra/licenses/LicensesCleanUpTask.groovy
@@ -0,0 +1,58 @@
+/**
+ * Copyright 2018 Google LLC
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * https://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package be.ugent.zeus.hydra.licenses
+
+import org.gradle.api.DefaultTask
+import org.gradle.api.tasks.Input
+import org.gradle.api.tasks.TaskAction
+
+/**
+ * Task to clean up the generated dependency.json, third_party_licenses and
+ * third_party_license_metadata files.
+ */
+class LicensesCleanUpTask extends DefaultTask {
+ @Input
+ public File dependencyFile
+
+ @Input
+ public File dependencyDir
+
+ @Input
+ public File htmlFile
+
+ @Input
+ public File licensesDir
+
+ @TaskAction
+ void action() {
+ if (dependencyFile.exists()) {
+ dependencyFile.delete()
+ }
+
+ if (dependencyDir.isDirectory() && dependencyDir.list().length == 0) {
+ dependencyDir.delete()
+ }
+
+ if (htmlFile.exists()) {
+ htmlFile.delete()
+ }
+
+ if (licensesDir.isDirectory() && licensesDir.list().length == 0) {
+ licensesDir.delete()
+ }
+ }
+}
\ No newline at end of file
diff --git a/buildSrc/src/main/groovy/be/ugent/zeus/hydra/licenses/LicensesTask.groovy b/buildSrc/src/main/groovy/be/ugent/zeus/hydra/licenses/LicensesTask.groovy
new file mode 100644
index 000000000..2dba559f0
--- /dev/null
+++ b/buildSrc/src/main/groovy/be/ugent/zeus/hydra/licenses/LicensesTask.groovy
@@ -0,0 +1,314 @@
+/**
+ * Copyright 2018 Google LLC
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * https://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package be.ugent.zeus.hydra.licenses
+
+import com.sun.jndi.toolkit.url.Uri
+import groovy.json.JsonSlurper
+import groovy.xml.MarkupBuilder
+import org.gradle.api.DefaultTask
+import org.gradle.api.artifacts.component.ModuleComponentIdentifier
+import org.gradle.api.artifacts.result.ResolvedArtifactResult
+import org.gradle.api.internal.artifacts.DefaultModuleIdentifier
+import org.gradle.api.tasks.InputFile
+import org.gradle.api.tasks.OutputDirectory
+import org.gradle.api.tasks.OutputFile
+import org.gradle.api.tasks.TaskAction
+import org.gradle.internal.component.external.model.DefaultModuleComponentIdentifier
+import org.gradle.maven.MavenModule
+import org.gradle.maven.MavenPomArtifact
+import org.slf4j.LoggerFactory
+
+import java.util.zip.ZipEntry
+import java.util.zip.ZipFile
+
+/**
+ * Task to find available licenses from the artifacts stored in the json
+ * file generated by DependencyTask, and then generate the third_party_licenses
+ * and third_party_license_metadata file.
+ */
+class LicensesTask extends DefaultTask {
+ private static final String UTF_8 = "UTF-8"
+ private static final int GRANULAR_BASE_VERSION = 14
+ private static final String GOOGLE_PLAY_SERVICES_GROUP =
+ "com.google.android.gms"
+ private static final String LICENSE_ARTIFACT_SURFIX = "-license"
+ private static final String FIREBASE_GROUP = "com.google.firebase"
+ private static final String FAIL_READING_LICENSES_ERROR =
+ "Failed to read license text."
+
+ private static final logger = LoggerFactory.getLogger(LicensesTask.class)
+
+ protected Set googleServiceLicenses = []
+ protected Map licensesMap = [:]
+
+ @InputFile
+ public File dependenciesJson
+
+ @OutputDirectory
+ public File outputDir
+
+ @OutputFile
+ public File html
+
+ @TaskAction
+ void action() {
+ initOutputDir()
+ initLicenseFile()
+
+ def allDependencies = new JsonSlurper().parse(dependenciesJson)
+ for (entry in allDependencies) {
+ String group = entry.group
+ String name = entry.name
+ String fileLocation = entry.fileLocation
+ String version = entry.version
+ File artifactLocation = new File(fileLocation)
+
+ if (isGoogleServices(group)) {
+ // Add license info for google-play-services itself
+ if (!name.endsWith(LICENSE_ARTIFACT_SURFIX)) {
+ addLicensesFromPom(group, name, version)
+ }
+ // Add transitive licenses info for google-play-services. For
+ // post-granular versions, this is located in the artifact
+ // itself, whereas for pre-granular versions, this information
+ // is located at the complementary license artifact as a runtime
+ // dependency.
+ if (isGranularVersion(version)) {
+ addGooglePlayServiceLicenses(artifactLocation)
+ } else if (name.endsWith(LICENSE_ARTIFACT_SURFIX)) {
+ addGooglePlayServiceLicenses(artifactLocation)
+ }
+ } else {
+ addLicensesFromPom(group, name, version)
+ }
+ }
+
+ writeMetadata()
+ }
+
+ protected void initOutputDir() {
+ if (!outputDir.exists()) {
+ outputDir.mkdirs()
+ }
+ }
+
+ protected void initLicenseFile() {
+ if (html == null) {
+ logger.error("License file is undefined")
+ }
+ html.newWriter().withWriter { w ->
+ w << ''
+ }
+ }
+
+ protected static boolean isGoogleServices(String group) {
+ return (GOOGLE_PLAY_SERVICES_GROUP.equalsIgnoreCase(group)
+ || FIREBASE_GROUP.equalsIgnoreCase(group))
+ }
+
+ protected static boolean isGranularVersion(String version) {
+ String[] versions = version.split("\\.")
+ return (versions.length > 0
+ && Integer.valueOf(versions[0]) >= GRANULAR_BASE_VERSION)
+ }
+
+ protected void addGooglePlayServiceLicenses(File artifactFile) {
+ ZipFile licensesZip = new ZipFile(artifactFile)
+ JsonSlurper jsonSlurper = new JsonSlurper()
+
+ ZipEntry jsonFile = licensesZip.getEntry("third_party_licenses.json")
+ ZipEntry txtFile = licensesZip.getEntry("third_party_licenses.txt")
+
+ if (!jsonFile || !txtFile) {
+ return
+ }
+
+ Object licensesObj = jsonSlurper.parse(licensesZip.getInputStream(
+ jsonFile))
+ if (licensesObj == null) {
+ return
+ }
+
+ for (entry in licensesObj) {
+ String key = entry.key
+ int startValue = entry.value.start
+ int lengthValue = entry.value.length
+
+ if (!googleServiceLicenses.contains(key)) {
+ googleServiceLicenses.add(key)
+ byte[] content = getBytesFromInputStream(
+ licensesZip.getInputStream(txtFile),
+ startValue,
+ lengthValue)
+ appendLicense(key, content)
+ }
+ }
+ }
+
+ protected static byte[] getBytesFromInputStream(
+ InputStream stream,
+ long offset,
+ int length) {
+ try {
+ byte[] buffer = new byte[1024]
+ ByteArrayOutputStream textArray = new ByteArrayOutputStream()
+
+ stream.skip(offset)
+ int bytesRemaining = length > 0 ? length : Integer.MAX_VALUE
+ int bytes = 0
+
+ while (bytesRemaining > 0 && (bytes = stream.read(buffer, 0, Math.min(bytesRemaining, buffer.length))) != -1) {
+ textArray.write(buffer, 0, bytes)
+ bytesRemaining -= bytes
+ }
+ stream.close()
+
+ return textArray.toByteArray()
+ } catch (Exception e) {
+ throw new RuntimeException(FAIL_READING_LICENSES_ERROR, e)
+ }
+ }
+
+ protected void addLicensesFromPom(String group, String name, String version) {
+ def pomFile = resolvePomFileArtifact(group, name, version)
+ addLicensesFromPom((File) pomFile, group, name)
+ }
+
+ protected void addLicensesFromPom(File pomFile, String group, String name) {
+ if (pomFile == null || !pomFile.exists()) {
+ logger.error("POM file $pomFile for $group:$name does not exist.")
+ return
+ }
+
+ def rootNode = new XmlSlurper().parse(pomFile)
+ if (rootNode.licenses.size() == 0) {
+ return
+ }
+
+ String licenseKey = "${group}:${name}"
+ if (rootNode.licenses.license.size() > 1) {
+ rootNode.licenses.license.each { node ->
+ String nodeName = node.name
+ String nodeUrl = node.url
+ appendLicense("${licenseKey} ${nodeName}", nodeUrl.getBytes(UTF_8))
+ }
+ } else {
+ String nodeUrl = rootNode.licenses.license.url
+ appendLicense(licenseKey, nodeUrl.getBytes(UTF_8))
+ }
+ }
+
+ private File resolvePomFileArtifact(String group, String name, String version) {
+ def moduleComponentIdentifier =
+ createModuleComponentIdentifier(group, name, version)
+ logger.info("Resolving POM file for $moduleComponentIdentifier licenses.")
+ def components = getProject().getDependencies()
+ .createArtifactResolutionQuery()
+ .forComponents(moduleComponentIdentifier)
+ .withArtifacts(MavenModule.class, MavenPomArtifact.class)
+ .execute()
+ if (components.resolvedComponents.isEmpty()) {
+ logger.warn("$moduleComponentIdentifier has no POM file.")
+ return null
+ }
+
+ def artifacts = components.resolvedComponents[0].getArtifacts(MavenPomArtifact.class)
+ if (artifacts.isEmpty()) {
+ logger.error("$moduleComponentIdentifier empty POM artifact list.")
+ return null
+ }
+ if (!(artifacts[0] instanceof ResolvedArtifactResult)) {
+ logger.error("$moduleComponentIdentifier unexpected type ${artifacts[0].class}")
+ return null
+ }
+ return ((ResolvedArtifactResult) artifacts[0]).getFile()
+ }
+
+ protected void appendLicense(String key, byte[] content) {
+ if (licensesMap.containsKey(key)) {
+ return
+ }
+
+ licensesMap.put(key, new String(content, UTF_8))
+ }
+
+ protected void writeMetadata() {
+
+ // Generate the correct map with content.
+ def newMap = [:]
+
+ def keys = LicenseMap.instance.mapping.keySet()
+ for (entry in licensesMap) {
+
+ if (entry.value in keys || entry.key in keys) {
+ newMap[entry.key] = getLicenseText(entry)
+ if (newMap[entry.key] == null) {
+ newMap.remove(entry.key)
+ }
+ } else {
+ // If more than 100, assume we have an url.
+
+ if (isUrl(entry.value)) {
+ logger.warn("Cound not find library text for ${entry.key}")
+ logger.warn("URL is ${entry}")
+ }
+ newMap[entry.key] = entry.value
+ }
+ }
+
+ def writer = html.newWriter(UTF_8)
+ def html = new MarkupBuilder(writer)
+ html.doubleQuotes = true
+ html.expandEmptyElements = true
+ html.omitEmptyAttributes = false
+ html.omitNullAttributes = false
+ html.mkp.yieldUnescaped ""
+ html.html {
+ head {
+ title("Licenties")
+ }
+ body {
+ newMap.each { e ->
+ details {
+ summary(e.key)
+ pre(e.value)
+ }
+ }
+ }
+ }
+ writer.close()
+ }
+
+ private static ModuleComponentIdentifier createModuleComponentIdentifier(String group, String name, String version) {
+ return new DefaultModuleComponentIdentifier(DefaultModuleIdentifier.newId(group, name), version)
+ }
+
+ private getLicenseText(def entry) {
+ String name = LicenseMap.instance.mapping.get(entry.value, LicenseMap.instance.mapping[entry.key])
+ return getClass().getResource("/license/${name}")?.text
+ }
+
+ private static boolean isUrl(String text) {
+ try {
+ URI.create(text)
+ return true
+ } catch (IllegalArgumentException ignored) {
+ return false
+ }
+ }
+
+}
\ No newline at end of file
diff --git a/buildSrc/src/main/groovy/be/ugent/zeus/hydra/licenses/OssLicensesPlugin.groovy b/buildSrc/src/main/groovy/be/ugent/zeus/hydra/licenses/OssLicensesPlugin.groovy
new file mode 100644
index 000000000..2e3bc53db
--- /dev/null
+++ b/buildSrc/src/main/groovy/be/ugent/zeus/hydra/licenses/OssLicensesPlugin.groovy
@@ -0,0 +1,76 @@
+/**
+ * Copyright 2018 Google LLC
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * https://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package be.ugent.zeus.hydra.licenses
+
+import com.android.build.gradle.api.BaseVariant
+import org.gradle.api.Plugin
+import org.gradle.api.Project
+
+class OssLicensesPlugin implements Plugin {
+
+ private static Tuple2 generate(Project project, String variant) {
+
+ def getDependencies = project.tasks.create("get${variant.capitalize()}Dependencies", DependencyTask)
+ def dependencyOutput = new File(project.buildDir, "generated/third_party_licenses")
+ def generatedJson = new File(dependencyOutput, "dependencies.json")
+ getDependencies.configurations = project.getConfigurations()
+ getDependencies.outputDir = dependencyOutput
+ getDependencies.outputFile = generatedJson
+ getDependencies.variant = variant
+
+ def resourceOutput = new File(dependencyOutput, "/res")
+ def outputDir = new File(resourceOutput, "/raw")
+ def licensesFile = new File(outputDir, "third_party_licenses.html")
+
+ def licenseTask = project.tasks.create("generate${variant.capitalize()}Licenses", LicensesTask)
+
+ licenseTask.dependenciesJson = generatedJson
+ licenseTask.outputDir = outputDir
+ licenseTask.html = licensesFile
+
+ licenseTask.inputs.file(generatedJson)
+ licenseTask.outputs.dir(outputDir)
+ licenseTask.outputs.files(licensesFile)
+
+ licenseTask.dependsOn(getDependencies)
+
+
+ def cleanupTask = project.tasks.create("${variant}LicensesCleanUp", LicensesCleanUpTask)
+ cleanupTask.dependencyFile = generatedJson
+ cleanupTask.dependencyDir = dependencyOutput
+ cleanupTask.htmlFile = licensesFile
+ cleanupTask.licensesDir = outputDir
+
+ project.tasks.findByName("clean").dependsOn(cleanupTask)
+
+ [licenseTask, resourceOutput]
+ }
+
+ void apply(Project project) {
+
+ project.android.applicationVariants.all { BaseVariant variant ->
+
+ def (LicensesTask licenseTask, File resourceOutput) = generate(project, variant.name)
+
+ variant.preBuildProvider.configure { dependsOn(licenseTask) }
+
+ def generated = project.files(resourceOutput).builtBy(licenseTask)
+ variant.registerGeneratedResFolders(generated)
+ variant.mergeResourcesProvider.configure { dependsOn(licenseTask) }
+ }
+ }
+}
\ No newline at end of file
diff --git a/buildSrc/src/main/resources/META-INF/gradle-plugins/be.ugent.zeus.hydra.licenses.properties b/buildSrc/src/main/resources/META-INF/gradle-plugins/be.ugent.zeus.hydra.licenses.properties
new file mode 100644
index 000000000..1cd39b971
--- /dev/null
+++ b/buildSrc/src/main/resources/META-INF/gradle-plugins/be.ugent.zeus.hydra.licenses.properties
@@ -0,0 +1 @@
+implementation-class=be.ugent.zeus.hydra.licenses.OssLicensesPlugin
diff --git a/buildSrc/src/main/resources/license/android-terms.txt b/buildSrc/src/main/resources/license/android-terms.txt
new file mode 100644
index 000000000..798609147
--- /dev/null
+++ b/buildSrc/src/main/resources/license/android-terms.txt
@@ -0,0 +1,161 @@
+This is not a license.
+View the latest version at: https://developer.android.com/studio/terms.html
+
+This is the Android Software Development Kit License Agreement
+
+1. Introduction
+
+1.1 The Android Software Development Kit (referred to in the License Agreement
+ as the "SDK" and specifically including the Android system files, packaged
+ APIs, and Google APIs add-ons) is licensed to you subject to the terms of the
+ License Agreement. The License Agreement forms a legally binding contract
+ between you and Google in relation to your use of the SDK.
+
+1.2 "Android" means the Android software stack for devices, as made available
+ under the Android Open Source Project, which is located at the following URL:
+ http://source.android.com/, as updated from time to time.
+
+1.3 A "compatible implementation" means any Android device that (i) complies
+ with the Android Compatibility Definition document, which can be found at the
+ Android compatibility website (http://source.android.com/compatibility) and
+ which may be updated from time to time; and (ii) successfully passes the
+ Android Compatibility Test Suite (CTS).
+
+1.4 "Google" means Google LLC, a Delaware corporation with principal place of
+ business at 1600 Amphitheatre Parkway, Mountain View, CA 94043, United States.
+
+
+2. Accepting this License Agreement
+
+2.1 In order to use the SDK, you must first agree to the License Agreement. You
+ may not use the SDK if you do not accept the License Agreement.
+
+2.2 By clicking to accept, you hereby agree to the terms of the License Agreement.
+
+2.3 You may not use the SDK and may not accept the License Agreement if you are a person barred from receiving the SDK under the laws of the United States or other countries, including the country in which you are resident or from which you use the SDK.
+
+2.4 If you are agreeing to be bound by the License Agreement on behalf of your employer or other entity, you represent and warrant that you have full legal authority to bind your employer or such entity to the License Agreement. If you do not have the requisite authority, you may not accept the License Agreement or use the SDK on behalf of your employer or other entity.
+
+
+3. SDK License from Google
+
+3.1 Subject to the terms of the License Agreement, Google grants you a limited, worldwide, royalty-free, non-assignable, non-exclusive, and non-sublicensable license to use the SDK solely to develop applications for compatible implementations of Android.
+
+3.2 You may not use this SDK to develop applications for other platforms (including non-compatible implementations of Android) or to develop another SDK. You are of course free to develop applications for other platforms, including non-compatible implementations of Android, provided that this SDK is not used for that purpose.
+
+3.3 You agree that Google or third parties own all legal right, title and interest in and to the SDK, including any Intellectual Property Rights that subsist in the SDK. "Intellectual Property Rights" means any and all rights under patent law, copyright law, trade secret law, trademark law, and any and all other proprietary rights. Google reserves all rights not expressly granted to you.
+
+3.4 You may not use the SDK for any purpose not expressly permitted by the License Agreement. Except to the extent required by applicable third party licenses, you may not copy (except for backup purposes), modify, adapt, redistribute, decompile, reverse engineer, disassemble, or create derivative works of the SDK or any part of the SDK.
+
+3.5 Use, reproduction and distribution of components of the SDK licensed under an open source software license are governed solely by the terms of that open source software license and not the License Agreement.
+
+3.6 You agree that the form and nature of the SDK that Google provides may change without prior notice to you and that future versions of the SDK may be incompatible with applications developed on previous versions of the SDK. You agree that Google may stop (permanently or temporarily) providing the SDK (or any features within the SDK) to you or to users generally at Google's sole discretion, without prior notice to you.
+
+3.7 Nothing in the License Agreement gives you a right to use any of Google's trade names, trademarks, service marks, logos, domain names, or other distinctive brand features.
+
+3.8 You agree that you will not remove, obscure, or alter any proprietary rights notices (including copyright and trademark notices) that may be affixed to or contained within the SDK.
+
+
+4. Use of the SDK by You
+
+4.1 Google agrees that it obtains no right, title or interest from you (or your licensors) under the License Agreement in or to any software applications that you develop using the SDK, including any intellectual property rights that subsist in those applications.
+
+4.2 You agree to use the SDK and write applications only for purposes that are permitted by (a) the License Agreement and (b) any applicable law, regulation or generally accepted practices or guidelines in the relevant jurisdictions (including any laws regarding the export of data or software to and from the United States or other relevant countries).
+
+4.3 You agree that if you use the SDK to develop applications for general public users, you will protect the privacy and legal rights of those users. If the users provide you with user names, passwords, or other login information or personal information, you must make the users aware that the information will be available to your application, and you must provide legally adequate privacy notice and protection for those users. If your application stores personal or sensitive information provided by users, it must do so securely. If the user provides your application with Google Account information, your application may only use that information to access the user's Google Account when, and for the limited purposes for which, the user has given you permission to do so.
+
+4.4 You agree that you will not engage in any activity with the SDK, including the development or distribution of an application, that interferes with, disrupts, damages, or accesses in an unauthorized manner the servers, networks, or other properties or services of any third party including, but not limited to, Google or any mobile communications carrier.
+
+4.5 You agree that you are solely responsible for (and that Google has no responsibility to you or to any third party for) any data, content, or resources that you create, transmit or display through Android and/or applications for Android, and for the consequences of your actions (including any loss or damage which Google may suffer) by doing so.
+
+4.6 You agree that you are solely responsible for (and that Google has no responsibility to you or to any third party for) any breach of your obligations under the License Agreement, any applicable third party contract or Terms of Service, or any applicable law or regulation, and for the consequences (including any loss or damage which Google or any third party may suffer) of any such breach.
+
+
+5. Your Developer Credentials
+
+5.1 You agree that you are responsible for maintaining the confidentiality of any developer credentials that may be issued to you by Google or which you may choose yourself and that you will be solely responsible for all applications that are developed under your developer credentials.
+
+
+6. Privacy and Information
+
+6.1 In order to continually innovate and improve the SDK, Google may collect certain usage statistics from the software including but not limited to a unique identifier, associated IP address, version number of the software, and information on which tools and/or services in the SDK are being used and how they are being used. Before any of this information is collected, the SDK will notify you and seek your consent. If you withhold consent, the information will not be collected.
+
+6.2 The data collected is examined in the aggregate to improve the SDK and is maintained in accordance with Google's Privacy Policy.
+
+
+7. Third Party Applications
+
+7.1 If you use the SDK to run applications developed by a third party or that access data, content or resources provided by a third party, you agree that Google is not responsible for those applications, data, content, or resources. You understand that all data, content or resources which you may access through such third party applications are the sole responsibility of the person from which they originated and that Google is not liable for any loss or damage that you may experience as a result of the use or access of any of those third party applications, data, content, or resources.
+
+7.2 You should be aware the data, content, and resources presented to you through such a third party application may be protected by intellectual property rights which are owned by the providers (or by other persons or companies on their behalf). You may not modify, rent, lease, loan, sell, distribute or create derivative works based on these data, content, or resources (either in whole or in part) unless you have been specifically given permission to do so by the relevant owners.
+
+7.3 You acknowledge that your use of such third party applications, data, content, or resources may be subject to separate terms between you and the relevant third party. In that case, the License Agreement does not affect your legal relationship with these third parties.
+
+
+8. Using Android APIs
+
+8.1 Google Data APIs
+
+8.1.1 If you use any API to retrieve data from Google, you acknowledge that the data may be protected by intellectual property rights which are owned by Google or those parties that provide the data (or by other persons or companies on their behalf). Your use of any such API may be subject to additional Terms of Service. You may not modify, rent, lease, loan, sell, distribute or create derivative works based on this data (either in whole or in part) unless allowed by the relevant Terms of Service.
+
+8.1.2 If you use any API to retrieve a user's data from Google, you acknowledge and agree that you shall retrieve data only with the user's explicit consent and only when, and for the limited purposes for which, the user has given you permission to do so. If you use the Android Recognition Service API, documented at the following URL: https://developer.android.com/reference/android/speech/RecognitionService, as updated from time to time, you acknowledge that the use of the API is subject to the Data Processing Addendum for Products where Google is a Data Processor, which is located at the following URL: https://privacy.google.com/businesses/gdprprocessorterms/, as updated from time to time. By clicking to accept, you hereby agree to the terms of the Data Processing Addendum for Products where Google is a Data Processor.
+
+
+
+9. Terminating this License Agreement
+
+9.1 The License Agreement will continue to apply until terminated by either you or Google as set out below.
+
+9.2 If you want to terminate the License Agreement, you may do so by ceasing your use of the SDK and any relevant developer credentials.
+
+9.3 Google may at any time, terminate the License Agreement with you if:
+(A) you have breached any provision of the License Agreement; or
+(B) Google is required to do so by law; or
+(C) the partner with whom Google offered certain parts of SDK (such as APIs) to you has terminated its relationship with Google or ceased to offer certain parts of the SDK to you; or
+(D) Google decides to no longer provide the SDK or certain parts of the SDK to users in the country in which you are resident or from which you use the service, or the provision of the SDK or certain SDK services to you by Google is, in Google's sole discretion, no longer commercially viable.
+
+9.4 When the License Agreement comes to an end, all of the legal rights, obligations and liabilities that you and Google have benefited from, been subject to (or which have accrued over time whilst the License Agreement has been in force) or which are expressed to continue indefinitely, shall be unaffected by this cessation, and the provisions of paragraph 14.7 shall continue to apply to such rights, obligations and liabilities indefinitely.
+
+
+10. DISCLAIMER OF WARRANTIES
+
+10.1 YOU EXPRESSLY UNDERSTAND AND AGREE THAT YOUR USE OF THE SDK IS AT YOUR SOLE RISK AND THAT THE SDK IS PROVIDED "AS IS" AND "AS AVAILABLE" WITHOUT WARRANTY OF ANY KIND FROM GOOGLE.
+
+10.2 YOUR USE OF THE SDK AND ANY MATERIAL DOWNLOADED OR OTHERWISE OBTAINED THROUGH THE USE OF THE SDK IS AT YOUR OWN DISCRETION AND RISK AND YOU ARE SOLELY RESPONSIBLE FOR ANY DAMAGE TO YOUR COMPUTER SYSTEM OR OTHER DEVICE OR LOSS OF DATA THAT RESULTS FROM SUCH USE.
+
+10.3 GOOGLE FURTHER EXPRESSLY DISCLAIMS ALL WARRANTIES AND CONDITIONS OF ANY KIND, WHETHER EXPRESS OR IMPLIED, INCLUDING, BUT NOT LIMITED TO THE IMPLIED WARRANTIES AND CONDITIONS OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
+
+
+11. LIMITATION OF LIABILITY
+
+11.1 YOU EXPRESSLY UNDERSTAND AND AGREE THAT GOOGLE, ITS SUBSIDIARIES AND AFFILIATES, AND ITS LICENSORS SHALL NOT BE LIABLE TO YOU UNDER ANY THEORY OF LIABILITY FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, CONSEQUENTIAL OR EXEMPLARY DAMAGES THAT MAY BE INCURRED BY YOU, INCLUDING ANY LOSS OF DATA, WHETHER OR NOT GOOGLE OR ITS REPRESENTATIVES HAVE BEEN ADVISED OF OR SHOULD HAVE BEEN AWARE OF THE POSSIBILITY OF ANY SUCH LOSSES ARISING.
+
+
+12. Indemnification
+
+12.1 To the maximum extent permitted by law, you agree to defend, indemnify and hold harmless Google, its affiliates and their respective directors, officers, employees and agents from and against any and all claims, actions, suits or proceedings, as well as any and all losses, liabilities, damages, costs and expenses (including reasonable attorneys fees) arising out of or accruing from (a) your use of the SDK, (b) any application you develop on the SDK that infringes any copyright, trademark, trade secret, trade dress, patent or other intellectual property right of any person or defames any person or violates their rights of publicity or privacy, and (c) any non-compliance by you with the License Agreement.
+
+
+13. Changes to the License Agreement
+
+13.1 Google may make changes to the License Agreement as it distributes new versions of the SDK. When these changes are made, Google will make a new version of the License Agreement available on the website where the SDK is made available.
+
+
+14. General Legal Terms
+
+14.1 The License Agreement constitutes the whole legal agreement between you and Google and governs your use of the SDK (excluding any services which Google may provide to you under a separate written agreement), and completely replaces any prior agreements between you and Google in relation to the SDK.
+
+14.2 You agree that if Google does not exercise or enforce any legal right or remedy which is contained in the License Agreement (or which Google has the benefit of under any applicable law), this will not be taken to be a formal waiver of Google's rights and that those rights or remedies will still be available to Google.
+
+14.3 If any court of law, having the jurisdiction to decide on this matter, rules that any provision of the License Agreement is invalid, then that provision will be removed from the License Agreement without affecting the rest of the License Agreement. The remaining provisions of the License Agreement will continue to be valid and enforceable.
+
+14.4 You acknowledge and agree that each member of the group of companies of which Google is the parent shall be third party beneficiaries to the License Agreement and that such other companies shall be entitled to directly enforce, and rely upon, any provision of the License Agreement that confers a benefit on (or rights in favor of) them. Other than this, no other person or company shall be third party beneficiaries to the License Agreement.
+
+14.5 EXPORT RESTRICTIONS. THE SDK IS SUBJECT TO UNITED STATES EXPORT LAWS AND REGULATIONS. YOU MUST COMPLY WITH ALL DOMESTIC AND INTERNATIONAL EXPORT LAWS AND REGULATIONS THAT APPLY TO THE SDK. THESE LAWS INCLUDE RESTRICTIONS ON DESTINATIONS, END USERS AND END USE.
+
+14.6 The rights granted in the License Agreement may not be assigned or transferred by either you or Google without the prior written approval of the other party. Neither you nor Google shall be permitted to delegate their responsibilities or obligations under the License Agreement without the prior written approval of the other party.
+
+14.7 The License Agreement, and your relationship with Google under the License Agreement, shall be governed by the laws of the State of California without regard to its conflict of laws provisions. You and Google agree to submit to the exclusive jurisdiction of the courts located within the county of Santa Clara, California to resolve any legal matter arising from the License Agreement. Notwithstanding this, you agree that Google shall still be allowed to apply for injunctive remedies (or an equivalent type of urgent legal relief) in any jurisdiction.
+
+
+January 16, 2019
\ No newline at end of file
diff --git a/buildSrc/src/main/resources/license/apache-2.0.txt b/buildSrc/src/main/resources/license/apache-2.0.txt
new file mode 100644
index 000000000..f7f9c345a
--- /dev/null
+++ b/buildSrc/src/main/resources/license/apache-2.0.txt
@@ -0,0 +1,176 @@
+ Apache License
+ Version 2.0, January 2004
+ http://www.apache.org/licenses/
+
+TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
+
+1. Definitions.
+
+ "License" shall mean the terms and conditions for use, reproduction,
+ and distribution as defined by Sections 1 through 9 of this document.
+
+ "Licensor" shall mean the copyright owner or entity authorized by
+ the copyright owner that is granting the License.
+
+ "Legal Entity" shall mean the union of the acting entity and all
+ other entities that control, are controlled by, or are under common
+ control with that entity. For the purposes of this definition,
+ "control" means (i) the power, direct or indirect, to cause the
+ direction or management of such entity, whether by contract or
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
+ outstanding shares, or (iii) beneficial ownership of such entity.
+
+ "You" (or "Your") shall mean an individual or Legal Entity
+ exercising permissions granted by this License.
+
+ "Source" form shall mean the preferred form for making modifications,
+ including but not limited to software source code, documentation
+ source, and configuration files.
+
+ "Object" form shall mean any form resulting from mechanical
+ transformation or translation of a Source form, including but
+ not limited to compiled object code, generated documentation,
+ and conversions to other media types.
+
+ "Work" shall mean the work of authorship, whether in Source or
+ Object form, made available under the License, as indicated by a
+ copyright notice that is included in or attached to the work
+ (an example is provided in the Appendix below).
+
+ "Derivative Works" shall mean any work, whether in Source or Object
+ form, that is based on (or derived from) the Work and for which the
+ editorial revisions, annotations, elaborations, or other modifications
+ represent, as a whole, an original work of authorship. For the purposes
+ of this License, Derivative Works shall not include works that remain
+ separable from, or merely link (or bind by name) to the interfaces of,
+ the Work and Derivative Works thereof.
+
+ "Contribution" shall mean any work of authorship, including
+ the original version of the Work and any modifications or additions
+ to that Work or Derivative Works thereof, that is intentionally
+ submitted to Licensor for inclusion in the Work by the copyright owner
+ or by an individual or Legal Entity authorized to submit on behalf of
+ the copyright owner. For the purposes of this definition, "submitted"
+ means any form of electronic, verbal, or written communication sent
+ to the Licensor or its representatives, including but not limited to
+ communication on electronic mailing lists, source code control systems,
+ and issue tracking systems that are managed by, or on behalf of, the
+ Licensor for the purpose of discussing and improving the Work, but
+ excluding communication that is conspicuously marked or otherwise
+ designated in writing by the copyright owner as "Not a Contribution."
+
+ "Contributor" shall mean Licensor and any individual or Legal Entity
+ on behalf of whom a Contribution has been received by Licensor and
+ subsequently incorporated within the Work.
+
+2. Grant of Copyright License. Subject to the terms and conditions of
+ this License, each Contributor hereby grants to You a perpetual,
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ copyright license to reproduce, prepare Derivative Works of,
+ publicly display, publicly perform, sublicense, and distribute the
+ Work and such Derivative Works in Source or Object form.
+
+3. Grant of Patent License. Subject to the terms and conditions of
+ this License, each Contributor hereby grants to You a perpetual,
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ (except as stated in this section) patent license to make, have made,
+ use, offer to sell, sell, import, and otherwise transfer the Work,
+ where such license applies only to those patent claims licensable
+ by such Contributor that are necessarily infringed by their
+ Contribution(s) alone or by combination of their Contribution(s)
+ with the Work to which such Contribution(s) was submitted. If You
+ institute patent litigation against any entity (including a
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
+ or a Contribution incorporated within the Work constitutes direct
+ or contributory patent infringement, then any patent licenses
+ granted to You under this License for that Work shall terminate
+ as of the date such litigation is filed.
+
+4. Redistribution. You may reproduce and distribute copies of the
+ Work or Derivative Works thereof in any medium, with or without
+ modifications, and in Source or Object form, provided that You
+ meet the following conditions:
+
+ (a) You must give any other recipients of the Work or
+ Derivative Works a copy of this License; and
+
+ (b) You must cause any modified files to carry prominent notices
+ stating that You changed the files; and
+
+ (c) You must retain, in the Source form of any Derivative Works
+ that You distribute, all copyright, patent, trademark, and
+ attribution notices from the Source form of the Work,
+ excluding those notices that do not pertain to any part of
+ the Derivative Works; and
+
+ (d) If the Work includes a "NOTICE" text file as part of its
+ distribution, then any Derivative Works that You distribute must
+ include a readable copy of the attribution notices contained
+ within such NOTICE file, excluding those notices that do not
+ pertain to any part of the Derivative Works, in at least one
+ of the following places: within a NOTICE text file distributed
+ as part of the Derivative Works; within the Source form or
+ documentation, if provided along with the Derivative Works; or,
+ within a display generated by the Derivative Works, if and
+ wherever such third-party notices normally appear. The contents
+ of the NOTICE file are for informational purposes only and
+ do not modify the License. You may add Your own attribution
+ notices within Derivative Works that You distribute, alongside
+ or as an addendum to the NOTICE text from the Work, provided
+ that such additional attribution notices cannot be construed
+ as modifying the License.
+
+ You may add Your own copyright statement to Your modifications and
+ may provide additional or different license terms and conditions
+ for use, reproduction, or distribution of Your modifications, or
+ for any such Derivative Works as a whole, provided Your use,
+ reproduction, and distribution of the Work otherwise complies with
+ the conditions stated in this License.
+
+5. Submission of Contributions. Unless You explicitly state otherwise,
+ any Contribution intentionally submitted for inclusion in the Work
+ by You to the Licensor shall be under the terms and conditions of
+ this License, without any additional terms or conditions.
+ Notwithstanding the above, nothing herein shall supersede or modify
+ the terms of any separate license agreement you may have executed
+ with Licensor regarding such Contributions.
+
+6. Trademarks. This License does not grant permission to use the trade
+ names, trademarks, service marks, or product names of the Licensor,
+ except as required for reasonable and customary use in describing the
+ origin of the Work and reproducing the content of the NOTICE file.
+
+7. Disclaimer of Warranty. Unless required by applicable law or
+ agreed to in writing, Licensor provides the Work (and each
+ Contributor provides its Contributions) on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+ implied, including, without limitation, any warranties or conditions
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
+ PARTICULAR PURPOSE. You are solely responsible for determining the
+ appropriateness of using or redistributing the Work and assume any
+ risks associated with Your exercise of permissions under this License.
+
+8. Limitation of Liability. In no event and under no legal theory,
+ whether in tort (including negligence), contract, or otherwise,
+ unless required by applicable law (such as deliberate and grossly
+ negligent acts) or agreed to in writing, shall any Contributor be
+ liable to You for damages, including any direct, indirect, special,
+ incidental, or consequential damages of any character arising as a
+ result of this License or out of the use or inability to use the
+ Work (including but not limited to damages for loss of goodwill,
+ work stoppage, computer failure or malfunction, or any and all
+ other commercial damages or losses), even if such Contributor
+ has been advised of the possibility of such damages.
+
+9. Accepting Warranty or Additional Liability. While redistributing
+ the Work or Derivative Works thereof, You may choose to offer,
+ and charge a fee for, acceptance of support, warranty, indemnity,
+ or other liability obligations and/or rights consistent with this
+ License. However, in accepting such obligations, You may act only
+ on Your own behalf and on Your sole responsibility, not on behalf
+ of any other Contributor, and only if You agree to indemnify,
+ defend, and hold each Contributor harmless for any liability
+ incurred by, or claims asserted against, such Contributor by reason
+ of your accepting any such warranty or additional liability.
+
+END OF TERMS AND CONDITIONS
\ No newline at end of file
diff --git a/buildSrc/src/main/resources/license/gplv2ce.txt b/buildSrc/src/main/resources/license/gplv2ce.txt
new file mode 100644
index 000000000..15663f34e
--- /dev/null
+++ b/buildSrc/src/main/resources/license/gplv2ce.txt
@@ -0,0 +1,349 @@
+GNU General Public License, version 2,
+with the Classpath Exception
+The GNU General Public License (GPL)
+
+Version 2, June 1991
+
+Copyright (C) 1989, 1991 Free Software Foundation, Inc.
+59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+
+Everyone is permitted to copy and distribute verbatim copies of this license
+document, but changing it is not allowed.
+
+Preamble
+
+The licenses for most software are designed to take away your freedom to share
+and change it. By contrast, the GNU General Public License is intended to
+guarantee your freedom to share and change free software--to make sure the
+software is free for all its users. This General Public License applies to
+most of the Free Software Foundation's software and to any other program whose
+authors commit to using it. (Some other Free Software Foundation software is
+covered by the GNU Library General Public License instead.) You can apply it to
+your programs, too.
+
+When we speak of free software, we are referring to freedom, not price. Our
+General Public Licenses are designed to make sure that you have the freedom to
+distribute copies of free software (and charge for this service if you wish),
+that you receive source code or can get it if you want it, that you can change
+the software or use pieces of it in new free programs; and that you know you
+can do these things.
+
+To protect your rights, we need to make restrictions that forbid anyone to deny
+you these rights or to ask you to surrender the rights. These restrictions
+translate to certain responsibilities for you if you distribute copies of the
+software, or if you modify it.
+
+For example, if you distribute copies of such a program, whether gratis or for
+a fee, you must give the recipients all the rights that you have. You must
+make sure that they, too, receive or can get the source code. And you must
+show them these terms so they know their rights.
+
+We protect your rights with two steps: (1) copyright the software, and (2)
+offer you this license which gives you legal permission to copy, distribute
+and/or modify the software.
+
+Also, for each author's protection and ours, we want to make certain that
+everyone understands that there is no warranty for this free software. If the
+software is modified by someone else and passed on, we want its recipients to
+know that what they have is not the original, so that any problems introduced
+by others will not reflect on the original authors' reputations.
+
+Finally, any free program is threatened constantly by software patents. We
+wish to avoid the danger that redistributors of a free program will
+individually obtain patent licenses, in effect making the program proprietary.
+To prevent this, we have made it clear that any patent must be licensed for
+everyone's free use or not licensed at all.
+
+The precise terms and conditions for copying, distribution and modification
+follow.
+
+TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
+
+0. This License applies to any program or other work which contains a notice
+placed by the copyright holder saying it may be distributed under the terms of
+this General Public License. The "Program", below, refers to any such program
+or work, and a "work based on the Program" means either the Program or any
+derivative work under copyright law: that is to say, a work containing the
+Program or a portion of it, either verbatim or with modifications and/or
+translated into another language. (Hereinafter, translation is included
+without limitation in the term "modification".) Each licensee is addressed as
+"you".
+
+Activities other than copying, distribution and modification are not covered by
+this License; they are outside its scope. The act of running the Program is
+not restricted, and the output from the Program is covered only if its contents
+constitute a work based on the Program (independent of having been made by
+running the Program). Whether that is true depends on what the Program does.
+
+1. You may copy and distribute verbatim copies of the Program's source code as
+you receive it, in any medium, provided that you conspicuously and
+appropriately publish on each copy an appropriate copyright notice and
+disclaimer of warranty; keep intact all the notices that refer to this License
+and to the absence of any warranty; and give any other recipients of the
+Program a copy of this License along with the Program.
+
+You may charge a fee for the physical act of transferring a copy, and you may
+at your option offer warranty protection in exchange for a fee.
+
+2. You may modify your copy or copies of the Program or any portion of it, thus
+forming a work based on the Program, and copy and distribute such modifications
+or work under the terms of Section 1 above, provided that you also meet all of
+these conditions:
+
+ a) You must cause the modified files to carry prominent notices stating
+ that you changed the files and the date of any change.
+
+ b) You must cause any work that you distribute or publish, that in whole or
+ in part contains or is derived from the Program or any part thereof, to be
+ licensed as a whole at no charge to all third parties under the terms of
+ this License.
+
+ c) If the modified program normally reads commands interactively when run,
+ you must cause it, when started running for such interactive use in the
+ most ordinary way, to print or display an announcement including an
+ appropriate copyright notice and a notice that there is no warranty (or
+ else, saying that you provide a warranty) and that users may redistribute
+ the program under these conditions, and telling the user how to view a copy
+ of this License. (Exception: if the Program itself is interactive but does
+ not normally print such an announcement, your work based on the Program is
+ not required to print an announcement.)
+
+These requirements apply to the modified work as a whole. If identifiable
+sections of that work are not derived from the Program, and can be reasonably
+considered independent and separate works in themselves, then this License, and
+its terms, do not apply to those sections when you distribute them as separate
+works. But when you distribute the same sections as part of a whole which is a
+work based on the Program, the distribution of the whole must be on the terms
+of this License, whose permissions for other licensees extend to the entire
+whole, and thus to each and every part regardless of who wrote it.
+
+Thus, it is not the intent of this section to claim rights or contest your
+rights to work written entirely by you; rather, the intent is to exercise the
+right to control the distribution of derivative or collective works based on
+the Program.
+
+In addition, mere aggregation of another work not based on the Program with the
+Program (or with a work based on the Program) on a volume of a storage or
+distribution medium does not bring the other work under the scope of this
+License.
+
+3. You may copy and distribute the Program (or a work based on it, under
+Section 2) in object code or executable form under the terms of Sections 1 and
+2 above provided that you also do one of the following:
+
+ a) Accompany it with the complete corresponding machine-readable source
+ code, which must be distributed under the terms of Sections 1 and 2 above
+ on a medium customarily used for software interchange; or,
+
+ b) Accompany it with a written offer, valid for at least three years, to
+ give any third party, for a charge no more than your cost of physically
+ performing source distribution, a complete machine-readable copy of the
+ corresponding source code, to be distributed under the terms of Sections 1
+ and 2 above on a medium customarily used for software interchange; or,
+
+ c) Accompany it with the information you received as to the offer to
+ distribute corresponding source code. (This alternative is allowed only
+ for noncommercial distribution and only if you received the program in
+ object code or executable form with such an offer, in accord with
+ Subsection b above.)
+
+The source code for a work means the preferred form of the work for making
+modifications to it. For an executable work, complete source code means all
+the source code for all modules it contains, plus any associated interface
+definition files, plus the scripts used to control compilation and installation
+of the executable. However, as a special exception, the source code
+distributed need not include anything that is normally distributed (in either
+source or binary form) with the major components (compiler, kernel, and so on)
+of the operating system on which the executable runs, unless that component
+itself accompanies the executable.
+
+If distribution of executable or object code is made by offering access to copy
+from a designated place, then offering equivalent access to copy the source
+code from the same place counts as distribution of the source code, even though
+third parties are not compelled to copy the source along with the object code.
+
+4. You may not copy, modify, sublicense, or distribute the Program except as
+expressly provided under this License. Any attempt otherwise to copy, modify,
+sublicense or distribute the Program is void, and will automatically terminate
+your rights under this License. However, parties who have received copies, or
+rights, from you under this License will not have their licenses terminated so
+long as such parties remain in full compliance.
+
+5. You are not required to accept this License, since you have not signed it.
+However, nothing else grants you permission to modify or distribute the Program
+or its derivative works. These actions are prohibited by law if you do not
+accept this License. Therefore, by modifying or distributing the Program (or
+any work based on the Program), you indicate your acceptance of this License to
+do so, and all its terms and conditions for copying, distributing or modifying
+the Program or works based on it.
+
+6. Each time you redistribute the Program (or any work based on the Program),
+the recipient automatically receives a license from the original licensor to
+copy, distribute or modify the Program subject to these terms and conditions.
+You may not impose any further restrictions on the recipients' exercise of the
+rights granted herein. You are not responsible for enforcing compliance by
+third parties to this License.
+
+7. If, as a consequence of a court judgment or allegation of patent
+infringement or for any other reason (not limited to patent issues), conditions
+are imposed on you (whether by court order, agreement or otherwise) that
+contradict the conditions of this License, they do not excuse you from the
+conditions of this License. If you cannot distribute so as to satisfy
+simultaneously your obligations under this License and any other pertinent
+obligations, then as a consequence you may not distribute the Program at all.
+For example, if a patent license would not permit royalty-free redistribution
+of the Program by all those who receive copies directly or indirectly through
+you, then the only way you could satisfy both it and this License would be to
+refrain entirely from distribution of the Program.
+
+If any portion of this section is held invalid or unenforceable under any
+particular circumstance, the balance of the section is intended to apply and
+the section as a whole is intended to apply in other circumstances.
+
+It is not the purpose of this section to induce you to infringe any patents or
+other property right claims or to contest validity of any such claims; this
+section has the sole purpose of protecting the integrity of the free software
+distribution system, which is implemented by public license practices. Many
+people have made generous contributions to the wide range of software
+distributed through that system in reliance on consistent application of that
+system; it is up to the author/donor to decide if he or she is willing to
+distribute software through any other system and a licensee cannot impose that
+choice.
+
+This section is intended to make thoroughly clear what is believed to be a
+consequence of the rest of this License.
+
+8. If the distribution and/or use of the Program is restricted in certain
+countries either by patents or by copyrighted interfaces, the original
+copyright holder who places the Program under this License may add an explicit
+geographical distribution limitation excluding those countries, so that
+distribution is permitted only in or among countries not thus excluded. In
+such case, this License incorporates the limitation as if written in the body
+of this License.
+
+9. The Free Software Foundation may publish revised and/or new versions of the
+General Public License from time to time. Such new versions will be similar in
+spirit to the present version, but may differ in detail to address new problems
+or concerns.
+
+Each version is given a distinguishing version number. If the Program
+specifies a version number of this License which applies to it and "any later
+version", you have the option of following the terms and conditions either of
+that version or of any later version published by the Free Software Foundation.
+If the Program does not specify a version number of this License, you may
+choose any version ever published by the Free Software Foundation.
+
+10. If you wish to incorporate parts of the Program into other free programs
+whose distribution conditions are different, write to the author to ask for
+permission. For software which is copyrighted by the Free Software Foundation,
+write to the Free Software Foundation; we sometimes make exceptions for this.
+Our decision will be guided by the two goals of preserving the free status of
+all derivatives of our free software and of promoting the sharing and reuse of
+software generally.
+
+NO WARRANTY
+
+11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY FOR
+THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN OTHERWISE
+STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES PROVIDE THE
+PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED,
+INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
+FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND
+PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE,
+YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
+
+12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING WILL
+ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR REDISTRIBUTE THE
+PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY
+GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR
+INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA
+BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A
+FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), EVEN IF SUCH HOLDER
+OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
+
+END OF TERMS AND CONDITIONS
+
+How to Apply These Terms to Your New Programs
+
+If you develop a new program, and you want it to be of the greatest possible
+use to the public, the best way to achieve this is to make it free software
+which everyone can redistribute and change under these terms.
+
+To do so, attach the following notices to the program. It is safest to attach
+them to the start of each source file to most effectively convey the exclusion
+of warranty; and each file should have at least the "copyright" line and a
+pointer to where the full notice is found.
+
+ One line to give the program's name and a brief idea of what it does.
+
+ Copyright (C)
+
+ This program is free software; you can redistribute it and/or modify it
+ under the terms of the GNU General Public License as published by the Free
+ Software Foundation; either version 2 of the License, or (at your option)
+ any later version.
+
+ This program is distributed in the hope that it will be useful, but WITHOUT
+ ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
+ more details.
+
+ You should have received a copy of the GNU General Public License along
+ with this program; if not, write to the Free Software Foundation, Inc., 59
+ Temple Place, Suite 330, Boston, MA 02111-1307 USA
+
+Also add information on how to contact you by electronic and paper mail.
+
+If the program is interactive, make it output a short notice like this when it
+starts in an interactive mode:
+
+ Gnomovision version 69, Copyright (C) year name of author Gnomovision comes
+ with ABSOLUTELY NO WARRANTY; for details type 'show w'. This is free
+ software, and you are welcome to redistribute it under certain conditions;
+ type 'show c' for details.
+
+The hypothetical commands 'show w' and 'show c' should show the appropriate
+parts of the General Public License. Of course, the commands you use may be
+called something other than 'show w' and 'show c'; they could even be
+mouse-clicks or menu items--whatever suits your program.
+
+You should also get your employer (if you work as a programmer) or your school,
+if any, to sign a "copyright disclaimer" for the program, if necessary. Here
+is a sample; alter the names:
+
+ Yoyodyne, Inc., hereby disclaims all copyright interest in the program
+ 'Gnomovision' (which makes passes at compilers) written by James Hacker.
+
+ signature of Ty Coon, 1 April 1989
+
+ Ty Coon, President of Vice
+
+This General Public License does not permit incorporating your program into
+proprietary programs. If your program is a subroutine library, you may
+consider it more useful to permit linking proprietary applications with the
+library. If this is what you want to do, use the GNU Library General Public
+License instead of this License.
+
+
+"CLASSPATH" EXCEPTION TO THE GPL
+
+Certain source files distributed by Oracle America and/or its affiliates are
+subject to the following clarification and special exception to the GPL, but
+only where Oracle has expressly included in the particular source file's header
+the words "Oracle designates this particular file as subject to the "Classpath"
+exception as provided by Oracle in the LICENSE file that accompanied this code."
+
+ Linking this library statically or dynamically with other modules is making
+ a combined work based on this library. Thus, the terms and conditions of
+ the GNU General Public License cover the whole combination.
+
+ As a special exception, the copyright holders of this library give you
+ permission to link this library with independent modules to produce an
+ executable, regardless of the license terms of these independent modules,
+ and to copy and distribute the resulting executable under terms of your
+ choice, provided that you also meet, for each linked independent module,
+ the terms and conditions of the license of that module. An independent
+ module is a module which is not derived from or based on this library. If
+ you modify this library, you may extend this exception to your version of
+ the library, but you are not obligated to do so. If you do not wish to do
+ so, delete this exception statement from your version.
\ No newline at end of file
diff --git a/buildSrc/src/main/resources/license/material-intro.txt b/buildSrc/src/main/resources/license/material-intro.txt
new file mode 100644
index 000000000..acdf845aa
--- /dev/null
+++ b/buildSrc/src/main/resources/license/material-intro.txt
@@ -0,0 +1,21 @@
+MIT License
+
+Copyright (c) 2017 Jan Heinrich Reimer
+
+Permission is hereby granted, free of charge, to any person obtaining a copy
+of this software and associated documentation files (the "Software"), to deal
+in the Software without restriction, including without limitation the rights
+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the Software is
+furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in all
+copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+SOFTWARE.
\ No newline at end of file
diff --git a/buildSrc/src/main/resources/license/threeten.txt b/buildSrc/src/main/resources/license/threeten.txt
new file mode 100644
index 000000000..287ec7014
--- /dev/null
+++ b/buildSrc/src/main/resources/license/threeten.txt
@@ -0,0 +1,29 @@
+Copyright (c) 2007-present, Stephen Colebourne & Michael Nascimento Santos.
+
+All rights reserved.
+
+Redistribution and use in source and binary forms, with or without
+modification, are permitted provided that the following conditions are met:
+
+* Redistributions of source code must retain the above copyright notice,
+ this list of conditions and the following disclaimer.
+
+* Redistributions in binary form must reproduce the above copyright notice,
+ this list of conditions and the following disclaimer in the documentation
+ and/or other materials provided with the distribution.
+
+* Neither the name of JSR-310 nor the names of its contributors
+ may be used to endorse or promote products derived from this software
+ without specific prior written permission.
+
+THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
+CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
+LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
\ No newline at end of file
diff --git a/buildSrc/src/test/java/be/ugent/zeus/hydra/licenses/DependencyTaskTest.java b/buildSrc/src/test/java/be/ugent/zeus/hydra/licenses/DependencyTaskTest.java
new file mode 100644
index 000000000..bcd606230
--- /dev/null
+++ b/buildSrc/src/test/java/be/ugent/zeus/hydra/licenses/DependencyTaskTest.java
@@ -0,0 +1,412 @@
+/*
+ * Copyright 2018 Google LLC
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * https://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package be.ugent.zeus.hydra.licenses;
+
+import static org.hamcrest.MatcherAssert.assertThat;
+import static org.hamcrest.core.Is.is;
+import static org.hamcrest.core.IsNull.nullValue;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertTrue;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.never;
+import static org.mockito.Mockito.verify;
+import static org.mockito.Mockito.when;
+
+import java.io.File;
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.HashSet;
+import java.util.Set;
+import org.gradle.api.Project;
+import org.gradle.api.artifacts.Configuration;
+import org.gradle.api.artifacts.LenientConfiguration;
+import org.gradle.api.artifacts.ModuleVersionIdentifier;
+import org.gradle.api.artifacts.ResolveException;
+import org.gradle.api.artifacts.ResolvedArtifact;
+import org.gradle.api.artifacts.ResolvedConfiguration;
+import org.gradle.api.artifacts.ResolvedDependency;
+import org.gradle.api.artifacts.ResolvedModuleVersion;
+import org.gradle.testfixtures.ProjectBuilder;
+import org.jetbrains.annotations.NotNull;
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.junit.runners.JUnit4;
+
+/** Tests for {@link DependencyTask} */
+@RunWith(JUnit4.class)
+public class DependencyTaskTest {
+ private DependencyTask dependencyTask;
+
+ @Before
+ public void setUp() {
+ Project project = ProjectBuilder.builder().build();
+ dependencyTask = project.getTasks().create("getDependency", DependencyTask.class);
+ }
+
+ @Test
+ public void testCheckArtifactSet_missingSet() {
+ File dependencies = new File("src/test/resources", "testDependency.json");
+ String[] artifactSet =
+ new String[] {"dependencies/groupA/deps1.txt", "dependencies/groupB/abc/deps2.txt"};
+ dependencyTask.artifactSet = new HashSet<>(Arrays.asList(artifactSet));
+
+ assertFalse(dependencyTask.checkArtifactSet(dependencies));
+ }
+
+ @Test
+ public void testCheckArtifactSet_correctSet() {
+ File dependencies = new File("src/test/resources", "testDependency.json");
+ String[] artifactSet =
+ new String[] {
+ "dependencies/groupA/deps1.txt",
+ "dependencies/groupB/abc/deps2.txt",
+ "src/test/resources/dependencies/groupC/deps3.txt",
+ "src/test/resources/dependencies/groupD/deps4.txt"
+ };
+ dependencyTask.artifactSet = new HashSet<>(Arrays.asList(artifactSet));
+ assertTrue(dependencyTask.checkArtifactSet(dependencies));
+ }
+
+ @Test
+ public void testCheckArtifactSet_addMoreSet() {
+ File dependencies = new File("src/test/resources", "testDependency.json");
+ String[] artifactSet =
+ new String[] {
+ "dependencies/groupA/deps1.txt",
+ "dependencies/groupB/abc/deps2.txt",
+ "src/test/resources/dependencies/groupC/deps3.txt",
+ "src/test/resources/dependencies/groupD/deps4.txt",
+ "dependencies/groupE/deps5.txt"
+ };
+ dependencyTask.artifactSet = new HashSet<>(Arrays.asList(artifactSet));
+ assertFalse(dependencyTask.checkArtifactSet(dependencies));
+ }
+
+ @Test
+ public void testCheckArtifactSet_replaceSet() {
+ File dependencies = new File("src/test/resources", "testDependency.json");
+ String[] artifactSet =
+ new String[] {
+ "dependencies/groupA/deps1.txt",
+ "dependencies/groupB/abc/deps2.txt",
+ "src/test/resources/dependencies/groupC/deps3.txt",
+ "dependencies/groupE/deps5.txt"
+ };
+ dependencyTask.artifactSet = new HashSet<>(Arrays.asList(artifactSet));
+ assertFalse(dependencyTask.checkArtifactSet(dependencies));
+ }
+
+ @Test
+ public void testGetResolvedArtifacts_cannotResolve() {
+ Set artifactSet = prepareArtifactSet(2);
+ ResolvedConfiguration resolvedConfiguration = mockResolvedConfiguration(artifactSet);
+
+ Configuration configuration = mock(Configuration.class);
+ when(configuration.getName()).thenReturn("implementation");
+ when(configuration.getResolvedConfiguration()).thenReturn(resolvedConfiguration);
+
+ when(configuration.isCanBeResolved()).thenReturn(false);
+
+ assertThat(dependencyTask.getResolvedArtifacts(configuration), is(nullValue()));
+ }
+
+ @Test
+ public void testGetResolvedArtifacts_isTest() {
+ Set artifactSet = prepareArtifactSet(2);
+ ResolvedConfiguration resolvedConfiguration = mockResolvedConfiguration(artifactSet);
+
+ Configuration configuration = mock(Configuration.class);
+ when(configuration.isCanBeResolved()).thenReturn(true);
+ when(configuration.getResolvedConfiguration()).thenReturn(resolvedConfiguration);
+
+ when(configuration.getName()).thenReturn("testCompile");
+
+ assertThat(dependencyTask.getResolvedArtifacts(configuration), is(nullValue()));
+ }
+
+ @Test
+ public void testGetResolvedArtifacts_isNotPackaged() {
+ Set artifactSet = prepareArtifactSet(2);
+ ResolvedConfiguration resolvedConfiguration = mockResolvedConfiguration(artifactSet);
+
+ Configuration configuration = mock(Configuration.class);
+ when(configuration.isCanBeResolved()).thenReturn(true);
+ when(configuration.getResolvedConfiguration()).thenReturn(resolvedConfiguration);
+
+ when(configuration.getName()).thenReturn("random");
+
+ assertThat(dependencyTask.getResolvedArtifacts(configuration), is(nullValue()));
+ }
+
+ @Test
+ public void testGetResolvedArtifacts_isPackagedApi() {
+ Set artifactSet = prepareArtifactSet(2);
+ ResolvedConfiguration resolvedConfiguration = mockResolvedConfiguration(artifactSet);
+
+ Configuration configuration = mock(Configuration.class);
+ when(configuration.isCanBeResolved()).thenReturn(true);
+ when(configuration.getResolvedConfiguration()).thenReturn(resolvedConfiguration);
+
+ when(configuration.getName()).thenReturn("api");
+
+ assertThat(dependencyTask.getResolvedArtifacts(configuration), is(artifactSet));
+ }
+
+ @Test
+ public void testGetResolvedArtifacts_isPackagedImplementation() {
+ Set artifactSet = prepareArtifactSet(2);
+ ResolvedConfiguration resolvedConfiguration = mockResolvedConfiguration(artifactSet);
+
+ Configuration configuration = mock(Configuration.class);
+ when(configuration.isCanBeResolved()).thenReturn(true);
+ when(configuration.getResolvedConfiguration()).thenReturn(resolvedConfiguration);
+
+ when(configuration.getName()).thenReturn("implementation");
+
+ assertThat(dependencyTask.getResolvedArtifacts(configuration), is(artifactSet));
+ }
+
+ @Test
+ public void testGetResolvedArtifacts_isPackagedCompile() {
+ Set artifactSet = prepareArtifactSet(2);
+ ResolvedConfiguration resolvedConfiguration = mockResolvedConfiguration(artifactSet);
+
+ Configuration configuration = mock(Configuration.class);
+ when(configuration.isCanBeResolved()).thenReturn(true);
+ when(configuration.getResolvedConfiguration()).thenReturn(resolvedConfiguration);
+
+ when(configuration.getName()).thenReturn("compile");
+
+ assertThat(dependencyTask.getResolvedArtifacts(configuration), is(artifactSet));
+ }
+
+ @Test
+ public void testGetResolvedArtifacts_isPackagedInHierarchy() {
+ Set artifactSet = prepareArtifactSet(2);
+ ResolvedConfiguration resolvedConfiguration = mockResolvedConfiguration(artifactSet);
+
+ Configuration configuration = mock(Configuration.class);
+ when(configuration.getName()).thenReturn("random");
+ when(configuration.isCanBeResolved()).thenReturn(true);
+ when(configuration.getResolvedConfiguration()).thenReturn(resolvedConfiguration);
+
+ Configuration parent = mock(Configuration.class);
+ when(parent.getName()).thenReturn("compile");
+ Set hierarchy = new HashSet<>();
+ hierarchy.add(parent);
+ when(configuration.getHierarchy()).thenReturn(hierarchy);
+
+ assertThat(dependencyTask.getResolvedArtifacts(configuration), is(artifactSet));
+ }
+
+ @Test
+ public void testGetResolvedArtifacts_ResolveException() {
+ ResolvedConfiguration resolvedConfiguration = mock(ResolvedConfiguration.class);
+ when(resolvedConfiguration.getLenientConfiguration()).thenThrow(ResolveException.class);
+
+ Configuration configuration = mock(Configuration.class);
+ when(configuration.getName()).thenReturn("compile");
+ when(configuration.isCanBeResolved()).thenReturn(true);
+ when(configuration.getResolvedConfiguration()).thenReturn(resolvedConfiguration);
+
+ assertThat(dependencyTask.getResolvedArtifacts(configuration), is(nullValue()));
+ }
+
+ @Test
+ public void testGetResolvedArtifacts_returnArtifact() {
+ Set artifactSet = prepareArtifactSet(2);
+ ResolvedConfiguration resolvedConfiguration = mockResolvedConfiguration(artifactSet);
+
+ Configuration configuration = mock(Configuration.class);
+ when(configuration.getName()).thenReturn("compile");
+ when(configuration.isCanBeResolved()).thenReturn(true);
+ when(configuration.getResolvedConfiguration()).thenReturn(resolvedConfiguration);
+
+ assertThat(dependencyTask.getResolvedArtifacts(configuration), is(artifactSet));
+ }
+
+ @Test
+ public void testGetResolvedArtifacts_libraryProject_returnsArtifacts() {
+ ResolvedDependency libraryResolvedDependency = mock(ResolvedDependency.class);
+ when(libraryResolvedDependency.getModuleVersion())
+ .thenReturn(DependencyTask.LOCAL_LIBRARY_VERSION);
+ ResolvedDependency libraryChildResolvedDependency = mock(ResolvedDependency.class);
+ Set libraryChildArtifactSet =
+ prepareArtifactSet(/* start= */ 0, /* count= */ 2);
+ when(libraryChildResolvedDependency.getAllModuleArtifacts())
+ .thenReturn(libraryChildArtifactSet);
+ when(libraryResolvedDependency.getChildren())
+ .thenReturn(Collections.singleton(libraryChildResolvedDependency));
+
+ Set appArtifactSet = prepareArtifactSet(/* start= */ 2, /* count= */ 2);
+ ResolvedDependency appResolvedDependency = mock(ResolvedDependency.class);
+ when(appResolvedDependency.getAllModuleArtifacts()).thenReturn(appArtifactSet);
+
+ Set resolvedDependencySet = new HashSet<>(
+ Arrays.asList(libraryResolvedDependency, appResolvedDependency));
+ ResolvedConfiguration resolvedConfiguration = mockResolvedConfigurationFromDependencySet(
+ resolvedDependencySet);
+
+ Configuration configuration = mock(Configuration.class);
+ when(configuration.getName()).thenReturn("compile");
+ when(configuration.isCanBeResolved()).thenReturn(true);
+ when(configuration.getResolvedConfiguration()).thenReturn(resolvedConfiguration);
+
+ Set artifactSuperSet = new HashSet<>();
+ artifactSuperSet.addAll(appArtifactSet);
+ artifactSuperSet.addAll(libraryChildArtifactSet);
+ assertThat(dependencyTask.getResolvedArtifacts(configuration), is(artifactSuperSet));
+ // Calling getAllModuleArtifacts on a library will cause an exception.
+ verify(libraryResolvedDependency, never()).getAllModuleArtifacts();
+ }
+
+ @NotNull
+ private ResolvedConfiguration mockResolvedConfiguration(Set artifactSet) {
+ ResolvedDependency resolvedDependency = mock(ResolvedDependency.class);
+ when(resolvedDependency.getAllModuleArtifacts()).thenReturn(artifactSet);
+ Set resolvedDependencySet = Collections.singleton(resolvedDependency);
+ return mockResolvedConfigurationFromDependencySet(resolvedDependencySet);
+ }
+
+ @NotNull
+ private ResolvedConfiguration mockResolvedConfigurationFromDependencySet(
+ Set resolvedDependencySet) {
+
+ LenientConfiguration lenientConfiguration = mock(LenientConfiguration.class);
+ when(lenientConfiguration.getFirstLevelModuleDependencies()).thenReturn(resolvedDependencySet);
+ ResolvedConfiguration resolvedConfiguration = mock(ResolvedConfiguration.class);
+ when(resolvedConfiguration.getLenientConfiguration()).thenReturn(lenientConfiguration);
+ return resolvedConfiguration;
+ }
+
+ @Test
+ public void testAddArtifacts() {
+ Set artifacts = prepareArtifactSet(3);
+
+ dependencyTask.addArtifacts(artifacts);
+ assertThat(dependencyTask.artifactInfos.size(), is(3));
+ }
+
+ @Test
+ public void testAddArtifacts_willNotAddDuplicate() {
+ Set artifacts = prepareArtifactSet(2);
+
+ String[] keySets = new String[] {"location1", "location2"};
+ dependencyTask.artifactSet = new HashSet<>(Arrays.asList(keySets));
+ dependencyTask.addArtifacts(artifacts);
+
+ assertThat(dependencyTask.artifactInfos.size(), is(1));
+ }
+
+ @Test
+ public void testCanBeResolved_isTrue() {
+ Configuration configuration = mock(Configuration.class);
+ when(configuration.isCanBeResolved()).thenReturn(true);
+
+ assertTrue(DependencyTask.canBeResolved(configuration));
+ }
+
+ @Test
+ public void testCanBeResolved_isFalse() {
+ Configuration configuration = mock(Configuration.class);
+ when(configuration.isCanBeResolved()).thenReturn(false);
+
+ assertFalse(DependencyTask.canBeResolved(configuration));
+ }
+
+ @Test
+ public void testIsTest_isNotTest() {
+ Configuration configuration = mock(Configuration.class);
+ when(configuration.getName()).thenReturn("random");
+
+ assertFalse(DependencyTask.isTest(configuration));
+ }
+
+ @Test
+ public void testIsTest_isTestCompile() {
+ Configuration configuration = mock(Configuration.class);
+ when(configuration.getName()).thenReturn("testCompile");
+
+ assertTrue(DependencyTask.isTest(configuration));
+ }
+
+ @Test
+ public void testIsTest_isAndroidTestCompile() {
+ Configuration configuration = mock(Configuration.class);
+ when(configuration.getName()).thenReturn("androidTestCompile");
+
+ assertTrue(DependencyTask.isTest(configuration));
+ }
+
+ @Test
+ public void testIsTest_fromHierarchy() {
+ Configuration configuration = mock(Configuration.class);
+ when(configuration.getName()).thenReturn("random");
+
+ Configuration parent = mock(Configuration.class);
+ when(parent.getName()).thenReturn("testCompile");
+
+ Set hierarchy = new HashSet<>();
+ hierarchy.add(parent);
+
+ when(configuration.getHierarchy()).thenReturn(hierarchy);
+ assertTrue(DependencyTask.isTest(configuration));
+ }
+
+ private Set prepareArtifactSet(int count) {
+ return prepareArtifactSet(0, count);
+ }
+
+ private Set prepareArtifactSet(int start, int count) {
+ Set artifacts = new HashSet<>();
+ String namePrefix = "artifact";
+ String groupPrefix = "group";
+ String locationPrefix = "location";
+ String versionPostfix = ".0";
+ for (int i = start; i < start + count; i++) {
+ String index = String.valueOf(i);
+ artifacts.add(
+ prepareArtifact(
+ namePrefix + index,
+ groupPrefix + index,
+ locationPrefix + index,
+ index + versionPostfix));
+ }
+ return artifacts;
+ }
+
+ private ResolvedArtifact prepareArtifact(
+ String name, String group, String filePath, String version) {
+ ModuleVersionIdentifier moduleId = mock(ModuleVersionIdentifier.class);
+ when(moduleId.getGroup()).thenReturn(group);
+ when(moduleId.getVersion()).thenReturn(version);
+
+ ResolvedModuleVersion moduleVersion = mock(ResolvedModuleVersion.class);
+ when(moduleVersion.getId()).thenReturn(moduleId);
+
+ File artifactFile = mock(File.class);
+ when(artifactFile.getAbsolutePath()).thenReturn(filePath);
+
+ ResolvedArtifact artifact = mock(ResolvedArtifact.class);
+ when(artifact.getName()).thenReturn(name);
+ when(artifact.getFile()).thenReturn(artifactFile);
+ when(artifact.getModuleVersion()).thenReturn(moduleVersion);
+
+ return artifact;
+ }
+}
diff --git a/buildSrc/src/test/java/be/ugent/zeus/hydra/licenses/GoogleServicesLicenseTest.java b/buildSrc/src/test/java/be/ugent/zeus/hydra/licenses/GoogleServicesLicenseTest.java
new file mode 100644
index 000000000..67aa574fb
--- /dev/null
+++ b/buildSrc/src/test/java/be/ugent/zeus/hydra/licenses/GoogleServicesLicenseTest.java
@@ -0,0 +1,54 @@
+/*
+ * Copyright 2018 Google LLC
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * https://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package be.ugent.zeus.hydra.licenses;
+
+import java.util.Arrays;
+
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.junit.runners.Parameterized;
+import org.junit.runners.Parameterized.Parameter;
+import org.junit.runners.Parameterized.Parameters;
+
+import static org.junit.Assert.assertEquals;
+
+/** Test for {@link LicensesTask#isGoogleServices(String)} */
+@RunWith(Parameterized.class)
+public class GoogleServicesLicenseTest {
+ private static final String BASE_DIR = "src/test/resources";
+
+ @Parameters
+ public static Iterable