Skip to content

Commit

Permalink
Merge pull request #298 from ZeusWPI/sko
Browse files Browse the repository at this point in the history
Update SKO line-up
  • Loading branch information
niknetniko authored Sep 19, 2019
2 parents 6bffadb + 77bad1a commit 2b8bfd4
Show file tree
Hide file tree
Showing 29 changed files with 360 additions and 245 deletions.
10 changes: 5 additions & 5 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
language: android
jdk:
- oraclejdk8
sudo: false

android:
components:
Expand All @@ -13,15 +14,13 @@ env:
- FLAVOUR=testRelease

script:
- "./gradlew clean $FLAVOUR"
- "./gradlew clean $FLAVOUR --console=plain"

notifications:
email: false

sudo: false

before_install:
- yes | sdkmanager "platforms;android-28"
#before_install:
# - yes | sdkmanager "platforms;android-28"

# Caching according to the docs at https://docs.travis-ci.com/user/languages/java/#Projects-Using-Gradle
before_cache:
Expand All @@ -31,6 +30,7 @@ cache:
directories:
- $HOME/.gradle/caches/
- $HOME/.gradle/wrapper/
- $HOME/.android/build-cache

# We only build on these branches and on release tags, which are tagged r[0-9]+.
branches:
Expand Down
24 changes: 15 additions & 9 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -113,33 +113,32 @@ dependencies {
// Network stack
// Do not upgrade beyond 3.12.x until we require API 21+
//noinspection GradleDependency
implementation 'com.squareup.okhttp3:okhttp:3.12.3'
implementation 'com.squareup.okhttp3:okhttp:3.12.5'
implementation 'com.squareup.moshi:moshi:1.8.0'

implementation 'com.jakewharton.threetenabp:threetenabp:1.2.1'
implementation 'net.sourceforge.streamsupport:android-retrostreams:1.7.1'
implementation 'com.squareup.picasso:picasso:2.71828'
implementation 'net.cachapa.expandablelayout:expandablelayout:2.9.2'

// Use our own fork, since it seems the original library is abandoned.
implementation 'com.heinrichreimersoftware:material-intro:2.0.0'
implementation 'com.jonathanfinerty.once:once:1.2.2'
implementation 'com.jonathanfinerty.once:once:1.3.0'
implementation 'com.github.captain-miao:optroundcardview:1.1.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-core:17.2.0'
implementation 'com.google.firebase:firebase-analytics:17.2.0'
implementation 'com.crashlytics.sdk.android:crashlytics:2.10.1'

if (props.getProperty("hydra.debug.leaks").toBoolean()) {
logger.info("Leak tracking enabled...")
debugImplementation 'com.squareup.leakcanary:leakcanary-android:2.0-alpha-2'
debugImplementation 'com.squareup.leakcanary:leakcanary-android:2.0-beta-3'
}

//Test code
testImplementation 'junit:junit:4.12'
testImplementation 'org.mockito:mockito-core:2.23.4'
testImplementation 'org.mockito:mockito-core:3.0.0'

testImplementation 'org.robolectric:robolectric:4.3'
testImplementation 'androidx.test:core:1.2.0'
Expand All @@ -154,11 +153,11 @@ dependencies {
exclude group: 'com.jakewharton.threetenabp', module: 'threetenabp'
}

testImplementation 'com.squareup.okhttp3:mockwebserver:3.12.2'
testImplementation 'nl.jqno.equalsverifier:equalsverifier:3.1.8'
testImplementation 'com.squareup.okhttp3:mockwebserver:3.12.5'
testImplementation 'nl.jqno.equalsverifier:equalsverifier:3.1.9'
testImplementation 'com.shazam:shazamcrest:0.11'
testImplementation 'org.skyscreamer:jsonassert:1.5.0'
testImplementation 'io.github.benas:random-beans:3.9.0'
testImplementation 'org.jeasy:easy-random-core:4.0.0'
testImplementation 'org.apache.commons:commons-lang3:3.9'
testImplementation 'org.hamcrest:hamcrest-core:1.3'
testImplementation 'commons-validator:commons-validator:1.6'
Expand Down Expand Up @@ -200,3 +199,10 @@ def loadProperties() {

return actualKeys
}

// Travis uses plain console mode, which does not output test status by default, causing time-outs.
tasks.withType(Test) {
testLogging {
events "passed", "skipped", "failed"
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,19 @@
import android.content.pm.PackageManager;
import android.content.pm.ResolveInfo;
import android.net.Uri;
import androidx.annotation.Nullable;
import androidx.browser.customtabs.CustomTabsService;
import android.text.TextUtils;
import android.util.Log;

import androidx.annotation.Nullable;
import androidx.browser.customtabs.CustomTabsIntent;
import androidx.browser.customtabs.CustomTabsService;

import java.util.ArrayList;
import java.util.List;

import be.ugent.zeus.hydra.R;
import be.ugent.zeus.hydra.utils.NetworkUtils;

/**
* Helper for custom tabs.
*
Expand Down Expand Up @@ -44,7 +49,7 @@ public class CustomTabsHelper {
* @param context {@link Context} to use for accessing {@link PackageManager}.
* @return The package name recommended to use for connecting to custom tabs related components.
*/
public static String getPackageNameToUse(Context context) {
static String getPackageNameToUse(Context context) {

if (packageNameToUse != null) {
return packageNameToUse;
Expand Down Expand Up @@ -122,21 +127,8 @@ private static boolean hasSpecializedHandlerIntents(Context context, Intent inte
return false;
}

protected static boolean hasSupport(Activity activity) {
return CustomTabsHelper.getPackageNameToUse(activity) != null;
}

/**
* Get an activity helper. When custom tabs are supported, it will use those. If custom tabs are not supported,
* it will open urls in a new browser window.
*
* @param activity The activity that calls the custom tab.
* @param callback The callback.
*
* @return The helper.
*/
public static ActivityHelper initHelper(Activity activity, @Nullable ActivityHelper.ConnectionCallback callback) {
return initHelper(activity, true, callback);
private static boolean hasSupport(Context context) {
return CustomTabsHelper.getPackageNameToUse(context) != null;
}

/**
Expand All @@ -145,16 +137,33 @@ public static ActivityHelper initHelper(Activity activity, @Nullable ActivityHel
* an app is available that can handle a certain url. A normal intent will be launched then.
*
* @param activity The activity that calls the custom tab.
* @param nativeApp If the native app should be used if available.
* @param callback The callback.
*
* @return The helper.
*/
public static ActivityHelper initHelper(Activity activity, boolean nativeApp, @Nullable ActivityHelper.ConnectionCallback callback) {
public static ActivityHelper initHelper(Activity activity, @Nullable ActivityHelper.ConnectionCallback callback) {
if(hasSupport(activity)) {
return new HasTabActivityHelper(activity, nativeApp, callback);
return new HasTabActivityHelper(activity, callback);
} else {
return new NoTabActivityHelper(activity, callback);
}
}

/**
* Open an URI in a Custom Tab if supported. Otherwise, an attempt is made to open a browser.
*
* @param context Context to use.
* @param uri The URI to open.
*/
public static void openUri(Context context, Uri uri) {
if (hasSupport(context)) {
CustomTabsIntent.Builder builder = new CustomTabsIntent.Builder();
//noinspection deprecation
builder.setToolbarColor(context.getResources().getColor(R.color.hydra_primary_color));
CustomTabsIntent customTabsIntent = builder.build();
customTabsIntent.launchUrl(context, uri);
} else {
NetworkUtils.maybeLaunchBrowser(context, uri.toString());
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@ class HasTabActivityHelper implements ActivityHelper {

private final ConnectionCallback connectionCallback;
private final WeakReference<Activity> activity;
private final boolean nativeApp;

private boolean showShareMenu;
private int intentFlags;
Expand All @@ -45,10 +44,9 @@ class HasTabActivityHelper implements ActivityHelper {
/**
* Package local constructor.
*/
HasTabActivityHelper(Activity activity, boolean nativeApp, @Nullable ConnectionCallback connectionCallback) {
HasTabActivityHelper(Activity activity, @Nullable ConnectionCallback connectionCallback) {
this.activity = new WeakReference<>(activity);
this.connectionCallback = connectionCallback;
this.nativeApp = nativeApp;
}

@Override
Expand All @@ -74,7 +72,7 @@ public void openCustomTab(Uri uri) {
builder.setToolbarColor(ViewUtils.getPrimaryColor(activity.get()));

Set<String> nat = getNativeAppPackage(activity.get(), uri);
if (nativeApp && !nat.isEmpty()) {
if (!nat.isEmpty()) {
Log.d(TAG, "Using normal intent because of native app, i.e. " + nat.iterator().next());
Intent browserIntent = new Intent(Intent.ACTION_VIEW, uri);
browserIntent.setFlags(this.intentFlags);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package be.ugent.zeus.hydra.onboarding;

import android.net.Uri;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
Expand All @@ -14,6 +15,9 @@
import be.ugent.zeus.hydra.R;
import be.ugent.zeus.hydra.common.reporting.Reporting;

import be.ugent.zeus.hydra.common.ui.customtabs.ActivityHelper;
import be.ugent.zeus.hydra.common.ui.customtabs.CustomTabsHelper;
import be.ugent.zeus.hydra.utils.NetworkUtils;
import com.heinrichreimersoftware.materialintro.app.SlideFragment;

import static androidx.core.view.ViewCompat.requireViewById;
Expand All @@ -23,6 +27,8 @@
*/
public class ReportingFragment extends SlideFragment {

private static final String PRIVACY_POLICY = "https://hydra.ugent.be/privacy-policy.html";

private RadioGroup analyticsChooser;
private Switch crashReportingChooser;

Expand All @@ -40,6 +46,7 @@ public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceStat
addOnNavigationBlockedListener((position, direction) ->
Toast.makeText(requireContext().getApplicationContext(), R.string.onboarding_reporting_required, Toast.LENGTH_SHORT)
.show());
requireViewById(view, R.id.read_policy).setOnClickListener(v -> CustomTabsHelper.openUri(v.getContext(), Uri.parse(PRIVACY_POLICY)));
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,11 @@
import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import androidx.annotation.Nullable;
import android.view.Menu;
import android.view.MenuItem;

import androidx.annotation.Nullable;

import be.ugent.zeus.hydra.R;
import be.ugent.zeus.hydra.common.network.Endpoints;
import be.ugent.zeus.hydra.common.ui.BaseActivity;
Expand Down
Loading

0 comments on commit 2b8bfd4

Please sign in to comment.