Skip to content

Commit

Permalink
Tweaking API usage switch handling
Browse files Browse the repository at this point in the history
  • Loading branch information
Ixam97 committed Jul 18, 2024
1 parent 3baeb4f commit 6ad0a99
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ abstract class LiveDataApi(
*/
protected abstract suspend fun sendNow(realTimeData: RealTimeData)

private fun updateWatchdog() {
protected fun updateWatchdog() {
val currentApiStateMap = CarStatsViewer.watchdog.getCurrentWatchdogState().apiState.toMutableMap()
currentApiStateMap[apiIdentifier] = connectionStatus.status
CarStatsViewer.watchdog.updateWatchdogState(CarStatsViewer.watchdog.getCurrentWatchdogState().copy(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,8 @@ class AbrpLiveData (

abrp_use_api.setSwitchClickListener() {
AppPreferences(context).abrpUseApi = abrp_use_api.isChecked
if(!abrp_use_api.isChecked) connectionStatus = ConnectionStatus.UNUSED
updateWatchdog()
}

abrp_use_location.setSwitchClickListener() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,8 @@ class HttpLiveData (

httpLiveDataEnabled.setSwitchClickListener {
AppPreferences(context).httpLiveDataEnabled = httpLiveDataEnabled.isChecked
if (!httpLiveDataEnabled.isChecked) connectionStatus = ConnectionStatus.UNUSED
updateWatchdog()
}
httpLiveDataLocation.setSwitchClickListener {
AppPreferences(context).httpLiveDataLocation = httpLiveDataLocation.isChecked
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package com.ixam97.carStatsViewer.ui.activities
import android.app.AlertDialog
import android.content.Context
import android.content.Intent
import android.graphics.PorterDuff
import android.os.Bundle
import android.view.LayoutInflater
import android.view.View
Expand Down Expand Up @@ -122,6 +123,14 @@ class HistoryActivity : FragmentActivity() {
createMultiDeleteDialog()
}

if (CarStatsViewer.liveDataApis[1].connectionStatus == ConnectionStatus.UNUSED) {
historyButtonUpload.isEnabled = false
historyButtonUpload.setColorFilter(
getColor(R.color.disabled_tint),
PorterDuff.Mode.SRC_IN
)
}

historyButtonUpload.setOnClickListener {
openUploadDialog()
}
Expand Down

0 comments on commit 6ad0a99

Please sign in to comment.