Skip to content

Commit

Permalink
Final work on application class, source row, and auth service
Browse files Browse the repository at this point in the history
  • Loading branch information
this-Aditya committed Dec 2, 2024
1 parent f15575c commit e2c3c93
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 10 deletions.
4 changes: 3 additions & 1 deletion app/src/main/java/org/radarcns/detail/AuthServiceImpl.kt
Original file line number Diff line number Diff line change
@@ -1,14 +1,16 @@
package org.radarcns.detail

import kotlinx.coroutines.flow.StateFlow
import org.radarbase.android.auth.AppAuthState
import org.radarbase.android.auth.AuthService
import org.radarbase.android.auth.LoginManager
import org.radarbase.android.auth.portal.ManagementPortalLoginManager

class AuthServiceImpl : AuthService() {
override fun createLoginManagers(appAuth: AppAuthState): List<LoginManager> = listOf(
override suspend fun createLoginManagers(appAuth: StateFlow<AppAuthState>): List<LoginManager> = listOf(
ManagementPortalLoginManager(this, appAuth),
)

override fun showLoginNotification() = Unit
}

13 changes: 8 additions & 5 deletions app/src/main/java/org/radarcns/detail/MainActivityViewImpl.kt
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ import android.view.View
import android.view.ViewGroup
import android.widget.*
import androidx.appcompat.widget.Toolbar
import androidx.lifecycle.lifecycleScope
import kotlinx.coroutines.launch
import org.radarbase.android.IRadarBinder
import org.radarbase.android.MainActivityView
import org.radarbase.android.source.SourceProvider
Expand Down Expand Up @@ -59,7 +61,7 @@ class MainActivityViewImpl(

private val serverStatusMessage: String?
get() {
return mainActivity.radarService?.latestNumberOfRecordsSent?.let { numberOfRecords ->
return mainActivity.radarBinder?.latestNumberOfRecordsSent?.let { numberOfRecords ->
if (numberOfRecords.time >= 0) {
timestampCache.applyIfChanged(numberOfRecords)
} else {
Expand Down Expand Up @@ -87,8 +89,9 @@ class MainActivityViewImpl(
mActionWrapperLayout = findViewById(R.id.actionWrapperLayout)

mDevicesNoneText = findViewById(R.id.no_devices)

findViewById<ImageView>(R.id.logo).repeatAnimation()
lifecycleScope.launch {
findViewById<ImageView>(R.id.logo).repeatAnimation()
}
this@MainActivityViewImpl.update()
}
}
Expand All @@ -98,12 +101,12 @@ class MainActivityViewImpl(
}

override fun update() {
val providers = mainActivity.radarService
val providers = mainActivity.radarBinder
?.connections
?.filter { it.isDisplayable }
?: emptyList()

val currentActions = mainActivity.radarService
val currentActions = mainActivity.radarBinder
?.connections
?.flatMap { it.actions }
?: emptyList()
Expand Down
6 changes: 4 additions & 2 deletions app/src/main/java/org/radarcns/detail/RadarApplicationImpl.kt
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ import com.google.firebase.analytics.FirebaseAnalytics
import com.google.firebase.crashlytics.FirebaseCrashlytics
import org.radarbase.android.AbstractRadarApplication
import org.radarbase.android.RadarConfiguration
import org.radarbase.android.RadarService
import org.radarbase.android.config.AppConfigRadarConfiguration
import org.radarbase.android.config.FirebaseRemoteConfiguration
import org.radarbase.android.config.RemoteConfig
Expand All @@ -36,6 +37,7 @@ import org.slf4j.impl.HandroidLoggerAdapter
* Radar application class for the detailed application.
*/
class RadarApplicationImpl : AbstractRadarApplication(), LifecycleEventObserver {

var enableCrashRecovery: Boolean = false
private set

Expand Down Expand Up @@ -66,12 +68,12 @@ class RadarApplicationImpl : AbstractRadarApplication(), LifecycleEventObserver

val smallIcon = R.drawable.ic_bt_connected

override fun createRemoteConfiguration(): List<RemoteConfig> = listOf(
override suspend fun createRemoteConfiguration(): List<RemoteConfig> = listOf(
FirebaseRemoteConfiguration(this, BuildConfig.DEBUG, R.xml.remote_config_defaults),
AppConfigRadarConfiguration(this)
)

override fun createConfiguration(): RadarConfiguration {
override suspend fun createConfiguration(): RadarConfiguration {
FirebaseAnalytics.getInstance(this).apply {
setUserProperty(TEST_PHASE, if (BuildConfig.DEBUG) "dev" else "production")
}
Expand Down
8 changes: 6 additions & 2 deletions app/src/main/java/org/radarcns/detail/SourceRowView.kt
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import android.widget.*
import androidx.lifecycle.lifecycleScope
import kotlinx.coroutines.launch
import org.radarbase.android.MainActivity
import org.radarbase.android.source.BaseSourceState
import org.radarbase.android.source.SourceProvider
Expand Down Expand Up @@ -111,7 +113,7 @@ class SourceRowView internal constructor(

logger.info("setting source filter {}", allowed)

mainActivity.radarService?.setAllowedSourceIds(connection, allowed)
mainActivity.radarBinder?.setAllowedSourceIds(connection, allowed)
}
}

Expand Down Expand Up @@ -157,7 +159,9 @@ class SourceRowView internal constructor(
SourceStatusListener.Status.CONNECTING -> R.drawable.avd_connecting
else -> sourceStatusIconDefault
})
mStatusIcon.repeatAnimation()
mainActivity.lifecycleScope.launch {
mStatusIcon.repeatAnimation()
}
}
}

Expand Down

0 comments on commit e2c3c93

Please sign in to comment.