From 9b8aaa6bb4b46bf027ad7ff484ce3e19b0b1707b Mon Sep 17 00:00:00 2001 From: Sven Bendel Date: Mon, 13 Jul 2020 13:17:20 +0200 Subject: [PATCH 1/6] Fix auth dependency declaration in README --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 82d2c53..b02f216 100644 --- a/README.md +++ b/README.md @@ -26,7 +26,7 @@ Then add this to you app's `build.gradle`: ```groovy dependencies { - implementation 'com.github.stanwood.framework-network-android:arch:' // aar version available as well + implementation 'com.github.stanwood.framework-network-android:auth:' // aar version available as well implementation 'com.github.stanwood.framework-network-android:cache:' // aar version available as well implementation 'com.github.stanwood.framework-network-android:core:' // aar version available as well, automatically included when pulling in one of the other libraries } @@ -258,4 +258,4 @@ Make sure to check the _Run Git hooks_ checkbox if you commit via Android Studio Last thing to do is setting line length to 140 (Preferences -> Editor -> Code Style) - unfortunately `ktlintApplyToIdea` can't do that for you. -The CI will check formatting as well and won't allow non style conform commits to be merged. \ No newline at end of file +The CI will check formatting as well and won't allow non style conform commits to be merged. From ead20b05c98c81afa464d7e8d41f9780de00840a Mon Sep 17 00:00:00 2001 From: Sven Bendel Date: Tue, 18 Aug 2020 14:39:04 +0200 Subject: [PATCH 2/6] Update to Kotlin 1.4.0 and bump libraries to latest versions where possible --- auth/build.gradle | 14 +++++++------- .../framework/network/auth/Authenticator.kt | 4 ++-- build.gradle | 10 +++++----- cache/build.gradle | 6 +++--- core/build.gradle | 12 ++++++------ .../core/store/SerializationParserFactory.kt | 6 ++++-- .../core/store/SerializationReaderParser.kt | 6 +++--- .../core/store/SerializationSourceParser.kt | 6 +++--- .../core/store/SerializationStringParser.kt | 2 +- gradle/wrapper/gradle-wrapper.properties | 2 +- sample/build.gradle | 6 +++--- 11 files changed, 38 insertions(+), 36 deletions(-) diff --git a/auth/build.gradle b/auth/build.gradle index f879ab6..60d6c34 100644 --- a/auth/build.gradle +++ b/auth/build.gradle @@ -1,5 +1,5 @@ /* - * Copyright (c) 2019 stanwood GmbH + * Copyright (c) 2019 stanwood GmbH, 2020 whisp Internet GmbH * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal @@ -24,11 +24,11 @@ apply plugin: 'com.android.library' apply plugin: 'kotlin-android' android { - compileSdkVersion 28 + compileSdkVersion 29 defaultConfig { minSdkVersion 16 - targetSdkVersion 28 + targetSdkVersion 29 versionCode 1 versionName "1.0" @@ -53,16 +53,16 @@ dependencies { api project(":core") implementation 'com.android.support:support-annotations:28.0.0' - testImplementation 'junit:junit:4.12' + testImplementation 'junit:junit:4.13' - compileOnly 'com.squareup.retrofit2:retrofit:2.5.0' + compileOnly 'com.squareup.retrofit2:retrofit:2.9.0' implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk8:$kotlin_version" - def retrofit_version = '2.5.0' + def retrofit_version = '2.9.0' testImplementation "com.squareup.retrofit2:retrofit:$retrofit_version" testImplementation "com.squareup.retrofit2:converter-gson:$retrofit_version" - testImplementation 'com.google.code.gson:gson:2.8.5' + testImplementation 'com.google.code.gson:gson:2.8.6' testImplementation "com.squareup.okhttp3:logging-interceptor:$okhttp_version" diff --git a/auth/src/main/java/io/stanwood/framework/network/auth/Authenticator.kt b/auth/src/main/java/io/stanwood/framework/network/auth/Authenticator.kt index b6f0ed4..6e0f425 100644 --- a/auth/src/main/java/io/stanwood/framework/network/auth/Authenticator.kt +++ b/auth/src/main/java/io/stanwood/framework/network/auth/Authenticator.kt @@ -38,7 +38,7 @@ open class Authenticator( private val tokenReaderWriter: TokenReaderWriter, private val onAuthenticationFailedListener: OnAuthenticationFailedListener? ) : okhttp3.Authenticator { - override fun authenticate(route: Route?, response: Response): Request? = response.request().let { request -> + override fun authenticate(route: Route?, response: Response): Request? = response.request.let { request -> tokenReaderWriter.read(request)?.let { oldToken -> synchronized(authenticationProvider.lock) { if (request.header(AuthHeaderKeys.RETRY_WITH_REFRESH_HEADER_KEY) != null) { @@ -98,7 +98,7 @@ open class Authenticator( all tokens */ response.newBuilder().request( - response.request().newBuilder() + response.request.newBuilder() .header(AuthHeaderKeys.RETRY_WITH_REFRESH_HEADER_KEY, "true") .build() ).build() diff --git a/build.gradle b/build.gradle index 8400d0f..4ced58a 100644 --- a/build.gradle +++ b/build.gradle @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018 stanwood GmbH + * Copyright (c) 2018 stanwood GmbH, 2020 whisp Internet GmbH * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal @@ -23,8 +23,8 @@ // Top-level build file where you can add configuration options common to all sub-projects/modules. buildscript { - ext.kotlin_version = '1.3.31' - ext.okhttp_version = '3.13.1' + ext.kotlin_version = '1.4.0' + ext.okhttp_version = '4.8.1' repositories { google() jcenter() @@ -33,9 +33,9 @@ buildscript { } } dependencies { - classpath 'com.android.tools.build:gradle:3.4.0-rc03' + classpath 'com.android.tools.build:gradle:4.2.0-alpha07' classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version" - classpath "org.jlleitschuh.gradle:ktlint-gradle:7.3.0" + classpath "org.jlleitschuh.gradle:ktlint-gradle:9.3.0" // NOTE: Do not place your application dependencies here; they belong // in the individual module build.gradle files diff --git a/cache/build.gradle b/cache/build.gradle index c51800b..e00d00f 100644 --- a/cache/build.gradle +++ b/cache/build.gradle @@ -1,5 +1,5 @@ /* - * Copyright (c) 2019 stanwood GmbH + * Copyright (c) 2019 stanwood GmbH, 2020 whisp Internet GmbH * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal @@ -24,11 +24,11 @@ apply plugin: 'com.android.library' apply plugin: 'kotlin-android' android { - compileSdkVersion 28 + compileSdkVersion 29 defaultConfig { minSdkVersion 16 - targetSdkVersion 28 + targetSdkVersion 29 versionCode 1 versionName "1.0" diff --git a/core/build.gradle b/core/build.gradle index 1bce78e..227b33a 100644 --- a/core/build.gradle +++ b/core/build.gradle @@ -1,5 +1,5 @@ /* - * Copyright (c) 2019 stanwood GmbH + * Copyright (c) 2019 stanwood GmbH, 2020 whisp Internet GmbH * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal @@ -24,11 +24,11 @@ apply plugin: 'com.android.library' apply plugin: 'kotlin-android' android { - compileSdkVersion 28 + compileSdkVersion 29 defaultConfig { minSdkVersion 16 - targetSdkVersion 28 + targetSdkVersion 29 versionCode 1 versionName "1.0" @@ -52,12 +52,12 @@ dependencies { implementation fileTree(dir: 'libs', include: ['*.jar']) implementation 'com.android.support:support-annotations:28.0.0' - testImplementation 'junit:junit:4.12' + testImplementation 'junit:junit:4.13' api "com.squareup.okhttp3:okhttp:$okhttp_version" - compileOnly 'com.squareup.retrofit2:retrofit:2.5.0' + compileOnly 'com.squareup.retrofit2:retrofit:2.9.0' implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk8:$kotlin_version" - api "org.jetbrains.kotlinx:kotlinx-serialization-runtime:0.11.0" + api 'org.jetbrains.kotlinx:kotlinx-serialization-core:1.0.0-RC' api 'com.nytimes.android:store3:3.1.1' api 'com.nytimes.android:filesystem3:3.1.1' implementation 'io.reactivex.rxjava2:rxjava:2.2.3' // same version as defined within store diff --git a/core/src/main/java/io/stanwood/framework/network/core/store/SerializationParserFactory.kt b/core/src/main/java/io/stanwood/framework/network/core/store/SerializationParserFactory.kt index 9c6f937..ce04ba3 100644 --- a/core/src/main/java/io/stanwood/framework/network/core/store/SerializationParserFactory.kt +++ b/core/src/main/java/io/stanwood/framework/network/core/store/SerializationParserFactory.kt @@ -22,14 +22,16 @@ package io.stanwood.framework.network.core.store import com.nytimes.android.external.store3.base.Parser -import kotlinx.io.Reader import kotlinx.serialization.KSerializer import kotlinx.serialization.json.Json import kotlinx.serialization.json.JsonConfiguration import okio.BufferedSource +import java.io.Reader object SerializationParserFactory { - private val stable = Json(JsonConfiguration.Stable) + private val stable = Json { + allowStructuredMapKeys = true + } fun createReaderParser( deserializer: KSerializer, json: Json = stable diff --git a/core/src/main/java/io/stanwood/framework/network/core/store/SerializationReaderParser.kt b/core/src/main/java/io/stanwood/framework/network/core/store/SerializationReaderParser.kt index 7465153..5a3a7ea 100644 --- a/core/src/main/java/io/stanwood/framework/network/core/store/SerializationReaderParser.kt +++ b/core/src/main/java/io/stanwood/framework/network/core/store/SerializationReaderParser.kt @@ -23,15 +23,15 @@ package io.stanwood.framework.network.core.store import com.nytimes.android.external.store3.base.Parser import com.nytimes.android.external.store3.util.ParserException -import kotlinx.io.Reader import kotlinx.serialization.KSerializer import kotlinx.serialization.json.Json +import java.io.Reader class SerializationReaderParser( private val deserializer: KSerializer, - val json: Json + private val json: Json ) : Parser { @Throws(ParserException::class) override fun apply(reader: Reader): Parsed = - json.parse(deserializer, reader.use { it.readText() }) + json.decodeFromString(deserializer, reader.use { it.readText() }) } \ No newline at end of file diff --git a/core/src/main/java/io/stanwood/framework/network/core/store/SerializationSourceParser.kt b/core/src/main/java/io/stanwood/framework/network/core/store/SerializationSourceParser.kt index d7e72e1..e14f521 100644 --- a/core/src/main/java/io/stanwood/framework/network/core/store/SerializationSourceParser.kt +++ b/core/src/main/java/io/stanwood/framework/network/core/store/SerializationSourceParser.kt @@ -28,10 +28,10 @@ import kotlinx.serialization.json.Json import okio.BufferedSource class SerializationSourceParser( - private val deserializer: KSerializer, - val json: Json + private val deserializer: KSerializer, + private val json: Json ) : Parser { @Throws(ParserException::class) override fun apply(bufferedSource: BufferedSource): Parsed = - json.parse(deserializer, bufferedSource.use { it.readUtf8() }) + json.decodeFromString(deserializer, bufferedSource.use { it.readUtf8() }) } \ No newline at end of file diff --git a/core/src/main/java/io/stanwood/framework/network/core/store/SerializationStringParser.kt b/core/src/main/java/io/stanwood/framework/network/core/store/SerializationStringParser.kt index 0db4408..269625e 100644 --- a/core/src/main/java/io/stanwood/framework/network/core/store/SerializationStringParser.kt +++ b/core/src/main/java/io/stanwood/framework/network/core/store/SerializationStringParser.kt @@ -32,5 +32,5 @@ class SerializationStringParser( ) : Parser { @Throws(ParserException::class) override fun apply(string: String): Parsed = - json.parse(deserializer, string) + json.decodeFromString(deserializer, string) } \ No newline at end of file diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index 5a82d00..94ed36f 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -3,4 +3,4 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-5.4.1-all.zip +distributionUrl=https://services.gradle.org/distributions/gradle-6.5-bin.zip diff --git a/sample/build.gradle b/sample/build.gradle index 56d3182..ea30045 100644 --- a/sample/build.gradle +++ b/sample/build.gradle @@ -24,14 +24,14 @@ apply plugin: 'com.android.application' apply plugin: 'kotlin-android' android { - compileSdkVersion 27 + compileSdkVersion 29 defaultConfig { applicationId "com.github.ubuntudroid.sample" minSdkVersion 21 - targetSdkVersion 27 + targetSdkVersion 29 versionCode 1 versionName "1.0" @@ -59,7 +59,7 @@ dependencies { implementation 'com.android.support:appcompat-v7:27.1.1' implementation 'com.android.support.constraint:constraint-layout:1.1.3' - testImplementation 'junit:junit:4.12' + testImplementation 'junit:junit:4.13' androidTestImplementation 'com.android.support.test:runner:1.0.2' androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2' implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk8:$kotlin_version" From c2d6cd3adbce7e1383d6315ceaef03ec253989aa Mon Sep 17 00:00:00 2001 From: Sven Bendel Date: Fri, 27 Nov 2020 13:32:27 +0100 Subject: [PATCH 3/6] Migrate to Androidx and update Kotlin to 1.4.20 --- auth/build.gradle | 6 +++--- build.gradle | 6 +++--- cache/build.gradle | 4 ++-- .../framework/network/cache/CacheInterceptor.java | 11 +++++++---- .../network/cache/CacheNetworkInterceptor.java | 11 +++++++---- core/build.gradle | 8 ++++---- .../network/core/store/SerializationParserFactory.kt | 1 - gradle.properties | 2 ++ gradle/wrapper/gradle-wrapper.properties | 2 +- sample/build.gradle | 12 ++++++------ .../ubuntudroid/sample/ExampleInstrumentedTest.java | 6 +++--- .../com/github/ubuntudroid/sample/MainActivity.java | 2 +- sample/src/main/res/layout/activity_main.xml | 4 ++-- 13 files changed, 41 insertions(+), 34 deletions(-) diff --git a/auth/build.gradle b/auth/build.gradle index 60d6c34..1413032 100644 --- a/auth/build.gradle +++ b/auth/build.gradle @@ -32,7 +32,7 @@ android { versionCode 1 versionName "1.0" - testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner" + testInstrumentationRunner 'androidx.test.runner.AndroidJUnitRunner' } @@ -52,8 +52,8 @@ dependencies { implementation fileTree(dir: 'libs', include: ['*.jar']) api project(":core") - implementation 'com.android.support:support-annotations:28.0.0' - testImplementation 'junit:junit:4.13' + implementation 'androidx.annotation:annotation:1.1.0' + testImplementation 'junit:junit:4.13.1' compileOnly 'com.squareup.retrofit2:retrofit:2.9.0' implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk8:$kotlin_version" diff --git a/build.gradle b/build.gradle index 4ced58a..9adfc3b 100644 --- a/build.gradle +++ b/build.gradle @@ -23,8 +23,8 @@ // Top-level build file where you can add configuration options common to all sub-projects/modules. buildscript { - ext.kotlin_version = '1.4.0' - ext.okhttp_version = '4.8.1' + ext.kotlin_version = '1.4.20' + ext.okhttp_version = '4.9.0' repositories { google() jcenter() @@ -33,7 +33,7 @@ buildscript { } } dependencies { - classpath 'com.android.tools.build:gradle:4.2.0-alpha07' + classpath 'com.android.tools.build:gradle:4.2.0-alpha15' classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version" classpath "org.jlleitschuh.gradle:ktlint-gradle:9.3.0" diff --git a/cache/build.gradle b/cache/build.gradle index e00d00f..a2f9a3d 100644 --- a/cache/build.gradle +++ b/cache/build.gradle @@ -32,7 +32,7 @@ android { versionCode 1 versionName "1.0" - testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner" + testInstrumentationRunner 'androidx.test.runner.AndroidJUnitRunner' } @@ -52,6 +52,6 @@ dependencies { implementation fileTree(dir: 'libs', include: ['*.jar']) api project(":core") - implementation 'com.android.support:support-annotations:28.0.0' + implementation 'androidx.annotation:annotation:1.1.0' implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk8:$kotlin_version" } diff --git a/cache/src/main/java/io/stanwood/framework/network/cache/CacheInterceptor.java b/cache/src/main/java/io/stanwood/framework/network/cache/CacheInterceptor.java index f986eba..c77c824 100644 --- a/cache/src/main/java/io/stanwood/framework/network/cache/CacheInterceptor.java +++ b/cache/src/main/java/io/stanwood/framework/network/cache/CacheInterceptor.java @@ -23,8 +23,10 @@ package io.stanwood.framework.network.cache; import android.content.Context; -import android.support.annotation.NonNull; -import android.support.annotation.Nullable; +import androidx.annotation.NonNull; +import androidx.annotation.Nullable; + +import org.jetbrains.annotations.NotNull; import java.io.IOException; @@ -78,11 +80,12 @@ public CacheInterceptor( this.errorCallback = errorCallback; } + @NotNull @Override public Response intercept(@NonNull Chain chain) throws IOException { Request request = chain.request(); String offlineCacheHeader = request.header(CacheHeaderKeys.APPLY_OFFLINE_CACHE); - if (Boolean.valueOf(offlineCacheHeader) && !connectionState.isConnected()) { + if (Boolean.parseBoolean(offlineCacheHeader) && !connectionState.isConnected()) { Request.Builder builder = request.newBuilder(); if (queryAuthParameterKey != null) { builder.url(request @@ -100,7 +103,7 @@ public Response intercept(@NonNull Chain chain) throws IOException { } String responseCacheHeader = request.header(CacheHeaderKeys.REFRESH); - if (Boolean.valueOf(responseCacheHeader)) { + if (Boolean.parseBoolean(responseCacheHeader)) { try { return chain.proceed(request.newBuilder().cacheControl(CacheControl.FORCE_NETWORK).build()); } catch (IOException e) { diff --git a/cache/src/main/java/io/stanwood/framework/network/cache/CacheNetworkInterceptor.java b/cache/src/main/java/io/stanwood/framework/network/cache/CacheNetworkInterceptor.java index 982b8ab..e144011 100644 --- a/cache/src/main/java/io/stanwood/framework/network/cache/CacheNetworkInterceptor.java +++ b/cache/src/main/java/io/stanwood/framework/network/cache/CacheNetworkInterceptor.java @@ -22,8 +22,10 @@ package io.stanwood.framework.network.cache; -import android.support.annotation.NonNull; -import android.support.annotation.Nullable; +import androidx.annotation.NonNull; +import androidx.annotation.Nullable; + +import org.jetbrains.annotations.NotNull; import java.io.IOException; @@ -80,13 +82,14 @@ public CacheNetworkInterceptor(@Nullable String queryAuthParameterKey, long cach this.cacheForSeconds = cacheForSeconds; } + @NotNull @Override public Response intercept(@NonNull Chain chain) throws IOException { Request request = chain.request(); String responseCacheHeader = request.header(CacheHeaderKeys.APPLY_RESPONSE_CACHE); String offlineCacheHeader = request.header(CacheHeaderKeys.APPLY_OFFLINE_CACHE); - boolean isGeneralCache = Boolean.valueOf(responseCacheHeader); - boolean isOfflineCache = Boolean.valueOf(offlineCacheHeader); + boolean isGeneralCache = Boolean.parseBoolean(responseCacheHeader); + boolean isOfflineCache = Boolean.parseBoolean(offlineCacheHeader); if (isGeneralCache || isOfflineCache) { Response originalResponse = chain.proceed(request); Response.Builder builder = originalResponse.newBuilder(); diff --git a/core/build.gradle b/core/build.gradle index 227b33a..e6d48b5 100644 --- a/core/build.gradle +++ b/core/build.gradle @@ -32,7 +32,7 @@ android { versionCode 1 versionName "1.0" - testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner" + testInstrumentationRunner 'androidx.test.runner.AndroidJUnitRunner' } @@ -51,13 +51,13 @@ android { dependencies { implementation fileTree(dir: 'libs', include: ['*.jar']) - implementation 'com.android.support:support-annotations:28.0.0' - testImplementation 'junit:junit:4.13' + implementation 'androidx.annotation:annotation:1.1.0' + testImplementation 'junit:junit:4.13.1' api "com.squareup.okhttp3:okhttp:$okhttp_version" compileOnly 'com.squareup.retrofit2:retrofit:2.9.0' implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk8:$kotlin_version" - api 'org.jetbrains.kotlinx:kotlinx-serialization-core:1.0.0-RC' + api "org.jetbrains.kotlinx:kotlinx-serialization-json:1.0.1" api 'com.nytimes.android:store3:3.1.1' api 'com.nytimes.android:filesystem3:3.1.1' implementation 'io.reactivex.rxjava2:rxjava:2.2.3' // same version as defined within store diff --git a/core/src/main/java/io/stanwood/framework/network/core/store/SerializationParserFactory.kt b/core/src/main/java/io/stanwood/framework/network/core/store/SerializationParserFactory.kt index ce04ba3..32d0492 100644 --- a/core/src/main/java/io/stanwood/framework/network/core/store/SerializationParserFactory.kt +++ b/core/src/main/java/io/stanwood/framework/network/core/store/SerializationParserFactory.kt @@ -24,7 +24,6 @@ package io.stanwood.framework.network.core.store import com.nytimes.android.external.store3.base.Parser import kotlinx.serialization.KSerializer import kotlinx.serialization.json.Json -import kotlinx.serialization.json.JsonConfiguration import okio.BufferedSource import java.io.Reader diff --git a/gradle.properties b/gradle.properties index 4549be6..ec5f641 100644 --- a/gradle.properties +++ b/gradle.properties @@ -31,6 +31,8 @@ # Specifies the JVM arguments used for the daemon process. # The setting is particularly useful for tweaking memory settings. +android.enableJetifier=true +android.useAndroidX=true org.gradle.jvmargs=-Xmx1536m # When configured, Gradle will run in incubating parallel mode. diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index 94ed36f..944c284 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -3,4 +3,4 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists -distributionUrl=https://services.gradle.org/distributions/gradle-6.5-bin.zip +distributionUrl=https://services.gradle.org/distributions/gradle-6.7-bin.zip diff --git a/sample/build.gradle b/sample/build.gradle index ea30045..9734b01 100644 --- a/sample/build.gradle +++ b/sample/build.gradle @@ -35,7 +35,7 @@ android { versionCode 1 versionName "1.0" - testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner" + testInstrumentationRunner 'androidx.test.runner.AndroidJUnitRunner' } @@ -57,10 +57,10 @@ dependencies { implementation project(':auth') implementation project(':cache') - implementation 'com.android.support:appcompat-v7:27.1.1' - implementation 'com.android.support.constraint:constraint-layout:1.1.3' - testImplementation 'junit:junit:4.13' - androidTestImplementation 'com.android.support.test:runner:1.0.2' - androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2' + implementation 'androidx.appcompat:appcompat:1.2.0' + implementation 'androidx.constraintlayout:constraintlayout:2.0.4' + testImplementation 'junit:junit:4.13.1' + androidTestImplementation 'androidx.test.ext:junit:1.1.2' + androidTestImplementation 'androidx.test.espresso:espresso-core:3.3.0' implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk8:$kotlin_version" } diff --git a/sample/src/androidTest/java/com/github/ubuntudroid/sample/ExampleInstrumentedTest.java b/sample/src/androidTest/java/com/github/ubuntudroid/sample/ExampleInstrumentedTest.java index 3667be8..fe0153e 100644 --- a/sample/src/androidTest/java/com/github/ubuntudroid/sample/ExampleInstrumentedTest.java +++ b/sample/src/androidTest/java/com/github/ubuntudroid/sample/ExampleInstrumentedTest.java @@ -1,8 +1,8 @@ package com.github.ubuntudroid.sample; import android.content.Context; -import android.support.test.InstrumentationRegistry; -import android.support.test.runner.AndroidJUnit4; +import androidx.test.platform.app.InstrumentationRegistry; +import androidx.test.ext.junit.runners.AndroidJUnit4; import org.junit.Test; import org.junit.runner.RunWith; @@ -19,7 +19,7 @@ public class ExampleInstrumentedTest { @Test public void useAppContext() { // Context of the app under test. - Context appContext = InstrumentationRegistry.getTargetContext(); + Context appContext = InstrumentationRegistry.getInstrumentation().getTargetContext(); assertEquals("com.github.ubuntudroid.sample", appContext.getPackageName()); } diff --git a/sample/src/main/java/com/github/ubuntudroid/sample/MainActivity.java b/sample/src/main/java/com/github/ubuntudroid/sample/MainActivity.java index a0dc67e..6a270ff 100644 --- a/sample/src/main/java/com/github/ubuntudroid/sample/MainActivity.java +++ b/sample/src/main/java/com/github/ubuntudroid/sample/MainActivity.java @@ -22,7 +22,7 @@ package com.github.ubuntudroid.sample; -import android.support.v7.app.AppCompatActivity; +import androidx.appcompat.app.AppCompatActivity; import android.os.Bundle; /** diff --git a/sample/src/main/res/layout/activity_main.xml b/sample/src/main/res/layout/activity_main.xml index 803ad8e..90d0bdf 100644 --- a/sample/src/main/res/layout/activity_main.xml +++ b/sample/src/main/res/layout/activity_main.xml @@ -21,7 +21,7 @@ ~ SOFTWARE. --> - - \ No newline at end of file + \ No newline at end of file From 4657ce92c7b4a9c035075f07c79bb462def673fd Mon Sep 17 00:00:00 2001 From: Sven Bendel Date: Fri, 27 Nov 2020 13:42:31 +0100 Subject: [PATCH 4/6] Update README to point to correct builds --- README.md | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/README.md b/README.md index b02f216..62c925e 100644 --- a/README.md +++ b/README.md @@ -1,15 +1,13 @@ -[![Release](https://jitpack.io/v/stanwood/framework-network-android.svg?style=flat-square)](https://jitpack.io/#stanwood/framework-network-android) -[![Build Status](https://app.bitrise.io/app/983e6342cc5e0e24/status.svg?token=QtXUf2lbVhJrANROaTkluQ&branch=develop)](https://app.bitrise.io/app/983e6342cc5e0e24) +[![Release](https://jitpack.io/v/whisp-internet/framework-network-android.svg?style=flat-square)](https://jitpack.io/#stanwood/framework-network-android) [![API](https://img.shields.io/badge/API-16%2B-blue.svg?style=flat)](https://android-arsenal.com/api?level=16) -# stanwood Network Utilities (Android) +# whisp Internet Network Utilities (Android) A set of hopefully useful classes for common networking use cases. ## Import -The stanwood Network Utilities are hosted on JitPack. Therefore you can simply -import them by adding +The whisp Internet Network Utilities (based on the [stanwood Network Utilities](https://github.com/stanwood/framework-network-android/)) are hosted on JitPack. Therefore you can simply import them by adding ```groovy allprojects { @@ -26,9 +24,9 @@ Then add this to you app's `build.gradle`: ```groovy dependencies { - implementation 'com.github.stanwood.framework-network-android:auth:' // aar version available as well - implementation 'com.github.stanwood.framework-network-android:cache:' // aar version available as well - implementation 'com.github.stanwood.framework-network-android:core:' // aar version available as well, automatically included when pulling in one of the other libraries + implementation 'com.github.whisp-internet.framework-network-android:auth:' // aar version available as well + implementation 'com.github.whisp-internet.framework-network-android:cache:' // aar version available as well + implementation 'com.github.whisp-internet.framework-network-android:core:' // aar version available as well, automatically included when pulling in one of the other libraries } ``` From 2b6b330208626987039ecbab4a5eb9078af233c8 Mon Sep 17 00:00:00 2001 From: Sven Bendel Date: Fri, 27 Nov 2020 13:53:41 +0100 Subject: [PATCH 5/6] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 62c925e..dbfaae9 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -[![Release](https://jitpack.io/v/whisp-internet/framework-network-android.svg?style=flat-square)](https://jitpack.io/#stanwood/framework-network-android) +[![Release](https://jitpack.io/v/whisp-internet/framework-network-android.svg?style=flat-square)](https://jitpack.io/#whisp-internet/framework-network-android) [![API](https://img.shields.io/badge/API-16%2B-blue.svg?style=flat)](https://android-arsenal.com/api?level=16) # whisp Internet Network Utilities (Android) From 367fefdec9a78efd545209f3b90012e3afa42628 Mon Sep 17 00:00:00 2001 From: Sven Bendel Date: Wed, 14 Feb 2024 17:43:21 +0100 Subject: [PATCH 6/6] Update CacheNetworkInterceptor README with more setup details --- .../network/cache/CacheNetworkInterceptor.java | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/cache/src/main/java/io/stanwood/framework/network/cache/CacheNetworkInterceptor.java b/cache/src/main/java/io/stanwood/framework/network/cache/CacheNetworkInterceptor.java index e144011..307619e 100644 --- a/cache/src/main/java/io/stanwood/framework/network/cache/CacheNetworkInterceptor.java +++ b/cache/src/main/java/io/stanwood/framework/network/cache/CacheNetworkInterceptor.java @@ -55,13 +55,22 @@ * this library. In the future this might be added to the provided interceptors by means of * accepting a list of parameter keys instead of just the one of the auth parameter. * - *

Configuration of the interceptor classes is mainly done by means of request headers. Check - * out {@link CacheHeaderKeys} for more details on what the different headers do. + *

Configuration of the interceptor classes is mainly done via request headers. Check + * out {@link CacheHeaderKeys} for more details on what the different headers do. Add them to your + * requests like so: + *

+ * {@code @Headers({ CacheHeaderKeys.APPLY_RESPONSE_CACHE + ": true" })}
+ * 
* - *

Add it as a network interceptor to your OkHttpClient Builder like so: + *

Add instances of this interceptor as a network interceptor to your OkHttpClient Builder like so: *

  * {@code okHttpClientBuilder.addNetworkInterceptor(new CacheNetworkInterceptor("auth", 3600))}
  * 
+ * + * Don't forget to add a cache to the builder as well: + *
+ * {@code okHttpClientBuilder.cache(new Cache(new File(app.cacheDir, "okhttp-storyly-rest-api-cache"), 10 * 1024))}
+ * 
*/ public class CacheNetworkInterceptor implements Interceptor {