Skip to content

Commit

Permalink
Merge pull request #247 from RADAR-base/release-1.1.0
Browse files Browse the repository at this point in the history
Release 1.1.0
  • Loading branch information
blootsvoets authored Feb 10, 2021
2 parents 6e1e80e + 3692ff7 commit fa66f91
Show file tree
Hide file tree
Showing 23 changed files with 183 additions and 209 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,15 +41,15 @@ repositories {
maven { url 'http://dl.bintray.com/radar-base/org.radarbase' }
}
dependencies {
api 'org.radarbase:radar-commons-android:1.0.10'
api 'org.radarbase:radar-commons-android:1.1.0'
}
```

Include additional plugins by adding:

```gradle
dependencies {
implementation 'org.radarbase:<plugin name>:1.0.10'
implementation 'org.radarbase:<plugin name>:1.1.0'
}
```

Expand Down
10 changes: 5 additions & 5 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@
* limitations under the License.
*/
buildscript {
ext.kotlin_version = '1.4.21'
ext.kotlin_version = '1.4.30'
ext.dokka_version = '1.4.20'
repositories {
google()
jcenter()
Expand All @@ -25,9 +26,8 @@ buildscript {
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
classpath 'com.jfrog.bintray.gradle:gradle-bintray-plugin:1.8.5'
classpath 'de.mobilej.unmock:UnMockPlugin:0.7.6'
classpath 'com.github.dcendents:android-maven-gradle-plugin:2.1'
classpath 'digital.wup:android-maven-publish:3.6.3'
classpath "org.jetbrains.dokka:dokka-android-gradle-plugin:0.9.18"
classpath("org.jetbrains.dokka:dokka-gradle-plugin:$dokka_version")
}
}

Expand All @@ -38,10 +38,10 @@ allprojects {
ext.issueUrl = 'https://github.com/' + githubRepoName + '/issues'
ext.website = 'http://radar-base.org'

version = '1.0.10'
version = '1.1.0'
group = 'org.radarbase'

ext.versionCode = 44
ext.versionCode = 45
}

subprojects {
Expand Down
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
# Default value: -Xmx10248m -XX:MaxPermSize=256m
android.enableJetifier=true
android.useAndroidX=true
org.gradle.jvmargs=-Xmx2048m -XX:MaxMetaspaceSize=512m -XX:MaxPermSize=512m -Dfile.encoding=UTF-8
org.gradle.jvmargs=-Xmx3072m -XX:MaxMetaspaceSize=1536m -XX:MaxPermSize=512m -Dfile.encoding=UTF-8
org.gradle.parallel=true
org.gradle.vfs.watch=true

Expand Down
30 changes: 10 additions & 20 deletions gradle/publishing.gradle
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
apply plugin: 'maven-publish'
apply plugin: 'digital.wup.android-maven-publish'
//apply plugin: 'org.jetbrains.dokka-android'
apply plugin: "org.jetbrains.dokka"

ext.sharedManifest = manifest {
attributes("Implementation-Title": name,
Expand All @@ -13,28 +12,17 @@ task sourcesJar(type: Jar) {
manifest.from sharedManifest
}

task javadoc(type: Javadoc) {
source = android.sourceSets.main.java.srcDirs
android.libraryVariants.all { variant ->
if (variant.name == 'release') {
owner.classpath += variant.javaCompileProvider.get().classpath
dokkaJavadoc.configure {
dokkaSourceSets {
named("main") {
noAndroidSdkLink.set(false)
}
}
classpath += project.files(android.getBootClasspath().join(File.pathSeparator))
exclude '**/BuildConfig.java'
exclude '**/R.java'
exclude '**/*.kt'
}

//dokka {
// outputFormat = 'html'
// outputDirectory = javadoc.destinationDir
//}

//task javadocJar(type: Jar, dependsOn: [dokka, javadoc]) {
task javadocJar(type: Jar, dependsOn: javadoc) {
task javadocJar(type: Jar, dependsOn: dokkaJavadoc) {
archiveClassifier.set('javadoc')
from javadoc.destinationDir
from dokkaJavadoc.outputDirectory
manifest.from sharedManifest
}

Expand All @@ -43,7 +31,9 @@ ext.nexusRepoBase = 'https://repo.thehyve.nl/content/repositories'
publishing {
publications {
mavenAar(MavenPublication) {
from components.android
afterEvaluate {
from components.release
}
artifact sourcesJar
artifact javadocJar

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
package org.radarbase.android

import android.app.Application
import android.content.Context
import android.os.Bundle
import androidx.annotation.CallSuper
import org.radarbase.android.config.CombinedRadarConfig
Expand Down Expand Up @@ -63,9 +62,10 @@ abstract class AbstractRadarApplication : Application(), RadarApplication {
*/
protected open fun createConfiguration(): RadarConfiguration {
return CombinedRadarConfig(
LocalConfiguration(this),
createRemoteConfiguration(),
::createDefaultConfiguration)
LocalConfiguration(this),
createRemoteConfiguration(),
::createDefaultConfiguration
)
}

/**
Expand All @@ -80,12 +80,4 @@ abstract class AbstractRadarApplication : Application(), RadarApplication {
* Create default configuration for the app.
*/
protected open fun createDefaultConfiguration(): Map<String, String> = mapOf()

companion object {
val Context.radarApp: AbstractRadarApplication
get() = applicationContext as AbstractRadarApplication

val Context.radarConfig: RadarConfiguration
get() = radarApp.configuration
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -19,24 +19,17 @@ package org.radarbase.android
import android.annotation.SuppressLint
import android.content.Context
import androidx.lifecycle.LiveData
import com.google.firebase.analytics.FirebaseAnalytics
import com.google.firebase.crashlytics.FirebaseCrashlytics
import org.radarbase.android.auth.AppAuthState
import org.radarbase.android.auth.AuthService.Companion.BASE_URL_PROPERTY
import org.radarbase.android.auth.portal.GetSubjectParser
import org.radarbase.android.config.SingleRadarConfiguration
import org.slf4j.LoggerFactory
import java.util.*
import java.util.regex.Pattern
import java.util.regex.Pattern.CASE_INSENSITIVE

interface RadarConfiguration {
val status: RemoteConfigStatus
val latestConfig: SingleRadarConfiguration
val config: LiveData<SingleRadarConfiguration>

enum class RemoteConfigStatus {
UNAVAILABLE, INITIAL, ERROR, READY, FETCHING, FETCHED
UNAVAILABLE, INITIAL, ERROR, READY, FETCHING, FETCHED, PARTIALLY_FETCHED
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,22 +17,17 @@
package org.radarbase.android

import android.Manifest.permission.*
import android.app.AppOpsManager
import android.app.AppOpsManager.MODE_ALLOWED
import android.app.Notification
import android.app.PendingIntent
import android.content.ComponentName
import android.content.Context
import android.content.Intent
import android.content.pm.PackageManager
import android.content.pm.PackageManager.PERMISSION_GRANTED
import android.location.LocationManager
import android.os.*
import android.os.Process.THREAD_PRIORITY_BACKGROUND
import android.provider.Settings
import android.widget.Toast
import androidx.annotation.CallSuper
import androidx.core.content.ContextCompat
import androidx.lifecycle.LifecycleService
import androidx.localbroadcastmanager.content.LocalBroadcastManager
import org.apache.avro.specific.SpecificRecord
Expand All @@ -56,7 +51,6 @@ import org.radarbase.android.util.NotificationHandler.Companion.NOTIFICATION_CHA
import org.radarbase.android.util.PermissionHandler.Companion.isPermissionGranted
import org.radarcns.kafka.ObservationKey
import org.slf4j.LoggerFactory
import java.security.Permission
import java.util.*
import java.util.concurrent.atomic.AtomicBoolean

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,21 +35,25 @@ import kotlin.collections.HashMap
@Keep
@Suppress("unused")
class AppAuthState private constructor(builder: Builder) {
val projectId: String?
val userId: String?
val token: String?
val tokenType: Int
val authenticationSource: String?
val needsRegisteredSources: Boolean
val expiration: Long
val lastUpdate: Long
val attributes: Map<String, String>
val headers: List<Map.Entry<String, String>>
val sourceMetadata: List<SourceMetadata>
val sourceTypes: List<SourceType>
val isPrivacyPolicyAccepted: Boolean
val okHttpHeaders: Headers
val baseUrl: String?
val projectId: String? = builder.projectId
val userId: String? = builder.userId
val token: String? = builder.token
val tokenType: Int = builder.tokenType
val authenticationSource: String? = builder.authenticationSource
val needsRegisteredSources: Boolean = builder.needsRegisteredSources
val expiration: Long = builder.expiration
val lastUpdate: Long = builder.lastUpdate
val attributes: Map<String, String> = HashMap(builder.attributes)
val headers: List<Map.Entry<String, String>> = ArrayList(builder.headers)
val sourceMetadata: List<SourceMetadata> = ArrayList(builder.sourceMetadata)
val sourceTypes: List<SourceType> = ArrayList(builder.sourceTypes)
val isPrivacyPolicyAccepted: Boolean = builder.isPrivacyPolicyAccepted
val okHttpHeaders: Headers = Headers.Builder().apply {
for (header in headers) {
add(header.key, header.value)
}
}.build()
val baseUrl: String? = attributes[AuthService.BASE_URL_PROPERTY]?.stripEndSlashes()

val isValid: Boolean
get() = isPrivacyPolicyAccepted && expiration > System.currentTimeMillis()
Expand All @@ -61,28 +65,6 @@ class AppAuthState private constructor(builder: Builder) {

constructor(initializer: Builder.() -> Unit) : this(Builder().also(initializer))

init {
this.projectId = builder.projectId
this.userId = builder.userId
this.token = builder.token
this.tokenType = builder.tokenType
this.expiration = builder.expiration
this.attributes = HashMap(builder.attributes)
this.sourceTypes = ArrayList(builder.sourceTypes)
this.sourceMetadata = ArrayList(builder.sourceMetadata)
this.headers = ArrayList(builder.headers)
this.lastUpdate = builder.lastUpdate
this.isPrivacyPolicyAccepted = builder.isPrivacyPolicyAccepted
this.authenticationSource = builder.authenticationSource
this.needsRegisteredSources = builder.needsRegisteredSources
this.okHttpHeaders = Headers.Builder().apply {
for (header in headers) {
add(header.key, header.value)
}
}.build()
this.baseUrl = attributes[AuthService.BASE_URL_PROPERTY]?.stripEndSlashes()
}

fun getAttribute(key: String) = attributes[key]

fun serializableAttributeList() = serializedMap(attributes.entries)
Expand Down Expand Up @@ -212,20 +194,22 @@ class AppAuthState private constructor(builder: Builder) {
}

override fun toString(): String {
return ("AppAuthState{"
+ "authenticationSource='" + authenticationSource + '\''.toString()
+ ", \nprojectId='" + projectId + '\''.toString() +
", \nuserId='" + userId + '\''.toString() +
", \ntoken='" + token + '\''.toString() +
", \ntokenType=" + tokenType +
", \nexpiration=" + expiration +
", \nlastUpdate=" + lastUpdate +
", \nattributes=" + attributes +
", \nsourceTypes=" + sourceTypes +
", \nsourceMetadata=" + sourceMetadata +
", \nparseHeaders=" + headers +
", \nisPrivacyPolicyAccepted=" + isPrivacyPolicyAccepted +
"\n")
return """
AppAuthState{
authenticationSource='$authenticationSource',
projectId='$projectId',
userId='$userId',
token='$token',
tokenType=$tokenType,
expiration=$expiration,
lastUpdate=$lastUpdate,
attributes=$attributes,
sourceTypes=$sourceTypes,
sourceMetadata=$sourceMetadata,
parseHeaders=$headers,
isPrivacyPolicyAccepted=$isPrivacyPolicyAccepted,
}
""".trimIndent()
}

override fun equals(other: Any?): Boolean {
Expand All @@ -234,29 +218,23 @@ class AppAuthState private constructor(builder: Builder) {

other as AppAuthState

if (projectId != other.projectId) return false
if (userId != other.userId) return false
if (token != other.token) return false
if (tokenType != other.tokenType) return false
if (authenticationSource != other.authenticationSource) return false
if (needsRegisteredSources != other.needsRegisteredSources) return false
if (expiration != other.expiration) return false
if (attributes != other.attributes) return false
if (headers != other.headers) return false
if (sourceMetadata != other.sourceMetadata) return false
if (sourceTypes != other.sourceTypes) return false
if (isPrivacyPolicyAccepted != other.isPrivacyPolicyAccepted) return false

return true
}
return projectId == other.projectId
&& userId == other.userId
&& token == other.token
&& tokenType == other.tokenType
&& authenticationSource == other.authenticationSource
&& needsRegisteredSources == other.needsRegisteredSources
&& expiration == other.expiration
&& attributes == other.attributes
&& headers == other.headers
&& sourceMetadata == other.sourceMetadata
&& sourceTypes == other.sourceTypes
&& isPrivacyPolicyAccepted == other.isPrivacyPolicyAccepted

override fun hashCode(): Int {
var result = projectId?.hashCode() ?: 0
result = 31 * result + (userId?.hashCode() ?: 0)
result = 31 * result + (token?.hashCode() ?: 0)
return result
}

override fun hashCode(): Int = Objects.hash(projectId, userId, token)

companion object {
private val logger = LoggerFactory.getLogger(AppAuthState::class.java)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,8 +72,8 @@ abstract class AuthService : Service(), LoginListener {

override fun loginSucceeded(manager: LoginManager?, authState: AppAuthState) {
refreshDelay.reset()
config.updateWithAuthState(this@AuthService, appAuth)
authSerialization.store(appAuth)
config.updateWithAuthState(this@AuthService, appAuth)
}
})
}
Expand All @@ -97,6 +97,12 @@ abstract class AuthService : Service(), LoginListener {
}
}

fun triggerFlush() {
handler.executeReentrant {
authSerialization.store(appAuth)
}
}

private fun doRefresh() {
if (relevantManagers.none { it.refresh(appAuth) }) {
startLogin()
Expand Down Expand Up @@ -320,6 +326,8 @@ abstract class AuthService : Service(), LoginListener {

fun update(manager: LoginManager) = this@AuthService.update(manager)

fun triggerFlush() = this@AuthService.triggerFlush()

fun refresh() = this@AuthService.refresh()

fun refreshIfOnline() = this@AuthService.refreshIfOnline()
Expand Down
Loading

0 comments on commit fa66f91

Please sign in to comment.