mirror of
https://github.com/d4rken-org/capod.git
synced 2026-09-15 02:36:12 -04:00
fix(logging): Promote user-triggered action logs to INFO level
This commit is contained in:
+28
-9
@@ -4,6 +4,7 @@ import dagger.hilt.android.lifecycle.HiltViewModel
|
||||
import eu.darken.capod.common.bluetooth.BluetoothManager2
|
||||
import eu.darken.capod.common.coroutine.DispatcherProvider
|
||||
import eu.darken.capod.common.datastore.value
|
||||
import eu.darken.capod.common.debug.logging.Logging.Priority.INFO
|
||||
import eu.darken.capod.common.debug.logging.Logging.Priority.WARN
|
||||
import eu.darken.capod.common.debug.logging.log
|
||||
import eu.darken.capod.common.debug.logging.logTag
|
||||
@@ -167,7 +168,7 @@ class DeviceSettingsViewModel @Inject constructor(
|
||||
log(TAG, WARN) { "nudgeConnection threw: ${e.message}" }
|
||||
false
|
||||
}
|
||||
log(TAG) { "nudgeConnection($bonded) accepted=$accepted" }
|
||||
log(TAG, INFO) { "nudgeConnection($bonded) accepted=$accepted" }
|
||||
if (!accepted) {
|
||||
events.tryEmit(Event.OpenBluetoothSettings)
|
||||
}
|
||||
@@ -180,7 +181,7 @@ class DeviceSettingsViewModel @Inject constructor(
|
||||
val address = currentAddress() ?: return false
|
||||
return try {
|
||||
aapManager.sendCommand(address, command)
|
||||
log(TAG) { "Sent $command to $address" }
|
||||
log(TAG, INFO) { "Sent $command to $address" }
|
||||
true
|
||||
} catch (e: Exception) {
|
||||
log(TAG, WARN) { "Failed to send $command: ${e.message}" }
|
||||
@@ -253,7 +254,7 @@ class DeviceSettingsViewModel @Inject constructor(
|
||||
val address = currentAddress() ?: return@launch
|
||||
try {
|
||||
aapManager.sendCommand(address, AapCommand.SetDeviceName(name))
|
||||
log(TAG) { "Sent SetDeviceName to $address" }
|
||||
log(TAG, INFO) { "Sent SetDeviceName to $address" }
|
||||
} catch (e: Exception) {
|
||||
log(TAG, WARN) { "Failed to send SetDeviceName: ${e.message}" }
|
||||
events.emit(Event.SendFailed(AapCommand.SetDeviceName(name), e.message))
|
||||
@@ -296,40 +297,57 @@ class DeviceSettingsViewModel @Inject constructor(
|
||||
updateProfileNow(transform)
|
||||
}
|
||||
|
||||
fun setOnePodMode(enabled: Boolean) = launch { updateProfileNow { it.copy(onePodMode = enabled) } }
|
||||
fun setOnePodMode(enabled: Boolean) {
|
||||
log(TAG, INFO) { "setOnePodMode($enabled)" }
|
||||
launch { updateProfileNow { it.copy(onePodMode = enabled) } }
|
||||
}
|
||||
|
||||
fun setAutoPlay(enabled: Boolean) = proGatedReaction(enabled) { it.copy(autoPlay = enabled) }
|
||||
fun setAutoPlay(enabled: Boolean) {
|
||||
log(TAG, INFO) { "setAutoPlay($enabled)" }
|
||||
proGatedReaction(enabled) { it.copy(autoPlay = enabled) }
|
||||
}
|
||||
|
||||
fun setAutoPause(enabled: Boolean) = proGatedReaction(enabled) { it.copy(autoPause = enabled) }
|
||||
fun setAutoPause(enabled: Boolean) {
|
||||
log(TAG, INFO) { "setAutoPause($enabled)" }
|
||||
proGatedReaction(enabled) { it.copy(autoPause = enabled) }
|
||||
}
|
||||
|
||||
fun setAutoConnect(enabled: Boolean) = launch {
|
||||
log(TAG, INFO) { "setAutoConnect($enabled)" }
|
||||
updateProfileNow { it.copy(autoConnect = enabled) }
|
||||
if (enabled) {
|
||||
// Auto-connect requires ALWAYS mode to react to BLE/case/ear events when
|
||||
// nothing is connected. We intentionally do NOT revert on disable — the user
|
||||
// may have set ALWAYS manually, or another profile may still need it.
|
||||
if (generalSettings.monitorMode.value() != MonitorMode.ALWAYS) {
|
||||
log(TAG) { "Forcing monitorMode to ALWAYS because autoConnect was enabled" }
|
||||
log(TAG, INFO) { "Forcing monitorMode to ALWAYS because autoConnect was enabled" }
|
||||
generalSettings.monitorMode.value(MonitorMode.ALWAYS)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fun setAutoConnectCondition(condition: AutoConnectCondition) = launch {
|
||||
log(TAG, INFO) { "setAutoConnectCondition($condition)" }
|
||||
updateProfileNow { it.copy(autoConnectCondition = condition) }
|
||||
}
|
||||
|
||||
fun setShowPopUpOnCaseOpen(enabled: Boolean) =
|
||||
fun setShowPopUpOnCaseOpen(enabled: Boolean) {
|
||||
log(TAG, INFO) { "setShowPopUpOnCaseOpen($enabled)" }
|
||||
proGatedReaction(enabled) { it.copy(showPopUpOnCaseOpen = enabled) }
|
||||
}
|
||||
|
||||
fun setShowPopUpOnConnection(enabled: Boolean) =
|
||||
fun setShowPopUpOnConnection(enabled: Boolean) {
|
||||
log(TAG, INFO) { "setShowPopUpOnConnection($enabled)" }
|
||||
proGatedReaction(enabled) { it.copy(showPopUpOnConnection = enabled) }
|
||||
}
|
||||
|
||||
fun setMonitorModeAutomatic() = launch {
|
||||
log(TAG, INFO) { "setMonitorModeAutomatic()" }
|
||||
generalSettings.monitorMode.value(MonitorMode.AUTOMATIC)
|
||||
}
|
||||
|
||||
fun navToStemConfig() = launch {
|
||||
log(TAG, INFO) { "navToStemConfig()" }
|
||||
if (upgradeRepo.isPro()) {
|
||||
navTo(Nav.Main.StemActionConfig)
|
||||
} else {
|
||||
@@ -338,6 +356,7 @@ class DeviceSettingsViewModel @Inject constructor(
|
||||
}
|
||||
|
||||
fun launchUpgrade() {
|
||||
log(TAG, INFO) { "launchUpgrade()" }
|
||||
navTo(Nav.Main.Upgrade)
|
||||
}
|
||||
|
||||
|
||||
@@ -4,6 +4,8 @@ import dagger.hilt.android.lifecycle.HiltViewModel
|
||||
import eu.darken.capod.common.PrivacyPolicy
|
||||
import eu.darken.capod.common.WebpageTool
|
||||
import eu.darken.capod.common.coroutine.DispatcherProvider
|
||||
import eu.darken.capod.common.debug.logging.Logging.Priority.INFO
|
||||
import eu.darken.capod.common.debug.logging.log
|
||||
import eu.darken.capod.common.debug.logging.logTag
|
||||
import eu.darken.capod.common.navigation.Nav
|
||||
import eu.darken.capod.common.uix.ViewModel4
|
||||
@@ -19,10 +21,12 @@ class OnboardingViewModel @Inject constructor(
|
||||
) : ViewModel4(dispatcherProvider) {
|
||||
|
||||
fun openPrivacyPolicy() {
|
||||
log(TAG, INFO) { "openPrivacyPolicy()" }
|
||||
webpageTool.open(PrivacyPolicy.URL)
|
||||
}
|
||||
|
||||
fun finishOnboarding() = launch {
|
||||
log(TAG, INFO) { "finishOnboarding()" }
|
||||
generalSettings.isOnboardingDone.valueBlocking = true
|
||||
navTo(Nav.Main.Overview, popUpTo = Nav.Main.Onboarding, inclusive = true)
|
||||
}
|
||||
|
||||
@@ -6,6 +6,8 @@ import eu.darken.capod.common.bluetooth.BluetoothManager2
|
||||
import eu.darken.capod.common.coroutine.DispatcherProvider
|
||||
import eu.darken.capod.common.datastore.valueBlocking
|
||||
import eu.darken.capod.common.debug.DebugSettings
|
||||
import eu.darken.capod.common.debug.logging.Logging.Priority.INFO
|
||||
import eu.darken.capod.common.debug.logging.Logging.Priority.WARN
|
||||
import eu.darken.capod.common.debug.logging.log
|
||||
import eu.darken.capod.common.debug.logging.logTag
|
||||
import eu.darken.capod.common.flow.SingleEventFlow
|
||||
@@ -157,32 +159,39 @@ class OverviewViewModel @Inject constructor(
|
||||
}
|
||||
|
||||
fun goToSettings() {
|
||||
log(TAG, INFO) { "goToSettings()" }
|
||||
navTo(Nav.Settings.Index)
|
||||
}
|
||||
|
||||
fun goToDeviceManager() {
|
||||
log(TAG, INFO) { "goToDeviceManager()" }
|
||||
navTo(Nav.Main.DeviceManager)
|
||||
}
|
||||
|
||||
fun goToDeviceSettings(device: PodDevice) {
|
||||
val profileId = device.profileId ?: return
|
||||
log(TAG, INFO) { "goToDeviceSettings(profileId=$profileId)" }
|
||||
navTo(Nav.Main.DeviceSettings(profileId))
|
||||
}
|
||||
|
||||
fun goToEditProfile(device: PodDevice) {
|
||||
val profileId = device.profileId ?: return
|
||||
log(TAG, INFO) { "goToEditProfile(profileId=$profileId)" }
|
||||
navTo(Nav.Main.DeviceProfileCreation(profileId = profileId))
|
||||
}
|
||||
|
||||
fun onUpgrade() {
|
||||
log(TAG, INFO) { "onUpgrade()" }
|
||||
navTo(Nav.Main.Upgrade)
|
||||
}
|
||||
|
||||
fun toggleUnmatchedDevices() {
|
||||
log(TAG, INFO) { "toggleUnmatchedDevices()" }
|
||||
showUnmatchedDevices.value = !showUnmatchedDevices.value
|
||||
}
|
||||
|
||||
fun requestPermission(permission: Permission) {
|
||||
log(TAG, INFO) { "requestPermission($permission)" }
|
||||
requestPermissionEvent.tryEmit(permission)
|
||||
}
|
||||
|
||||
@@ -191,9 +200,9 @@ class OverviewViewModel @Inject constructor(
|
||||
launch {
|
||||
try {
|
||||
aapManager.sendCommand(address, AapCommand.SetAncMode(mode))
|
||||
log(TAG) { "ANC mode set to $mode for $address" }
|
||||
log(TAG, INFO) { "ANC mode set to $mode for $address" }
|
||||
} catch (e: Exception) {
|
||||
log(TAG) { "Failed to set ANC mode: ${e.message}" }
|
||||
log(TAG, WARN) { "Failed to set ANC mode: ${e.message}" }
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+14
@@ -3,6 +3,8 @@ package eu.darken.capod.main.ui.settings.general
|
||||
import dagger.hilt.android.lifecycle.HiltViewModel
|
||||
import eu.darken.capod.common.bluetooth.ScannerMode
|
||||
import eu.darken.capod.common.coroutine.DispatcherProvider
|
||||
import eu.darken.capod.common.debug.logging.Logging.Priority.INFO
|
||||
import eu.darken.capod.common.debug.logging.log
|
||||
import eu.darken.capod.common.debug.logging.logTag
|
||||
import eu.darken.capod.common.navigation.Nav
|
||||
import eu.darken.capod.common.theming.ThemeColor
|
||||
@@ -76,34 +78,42 @@ class GeneralSettingsViewModel @Inject constructor(
|
||||
}.asLiveState()
|
||||
|
||||
fun setMonitorMode(mode: MonitorMode) {
|
||||
log(TAG, INFO) { "setMonitorMode($mode)" }
|
||||
generalSettings.monitorMode.valueBlocking = mode
|
||||
}
|
||||
|
||||
fun setScannerMode(mode: ScannerMode) {
|
||||
log(TAG, INFO) { "setScannerMode($mode)" }
|
||||
generalSettings.scannerMode.valueBlocking = mode
|
||||
}
|
||||
|
||||
fun setShowConnectedNotification(enabled: Boolean) {
|
||||
log(TAG, INFO) { "setShowConnectedNotification($enabled)" }
|
||||
generalSettings.useExtraMonitorNotification.valueBlocking = enabled
|
||||
}
|
||||
|
||||
fun setKeepNotificationAfterDisconnect(enabled: Boolean) {
|
||||
log(TAG, INFO) { "setKeepNotificationAfterDisconnect($enabled)" }
|
||||
generalSettings.keepConnectedNotificationAfterDisconnect.valueBlocking = enabled
|
||||
}
|
||||
|
||||
fun setOffloadedFilteringDisabled(disabled: Boolean) {
|
||||
log(TAG, INFO) { "setOffloadedFilteringDisabled($disabled)" }
|
||||
generalSettings.isOffloadedFilteringDisabled.valueBlocking = disabled
|
||||
}
|
||||
|
||||
fun setOffloadedBatchingDisabled(disabled: Boolean) {
|
||||
log(TAG, INFO) { "setOffloadedBatchingDisabled($disabled)" }
|
||||
generalSettings.isOffloadedBatchingDisabled.valueBlocking = disabled
|
||||
}
|
||||
|
||||
fun setUseIndirectScanResultCallback(enabled: Boolean) {
|
||||
log(TAG, INFO) { "setUseIndirectScanResultCallback($enabled)" }
|
||||
generalSettings.useIndirectScanResultCallback.valueBlocking = enabled
|
||||
}
|
||||
|
||||
fun setThemeMode(mode: ThemeMode) = launch {
|
||||
log(TAG, INFO) { "setThemeMode($mode)" }
|
||||
if (isPro.first()) {
|
||||
generalSettings.themeMode.valueBlocking = mode
|
||||
} else {
|
||||
@@ -112,6 +122,7 @@ class GeneralSettingsViewModel @Inject constructor(
|
||||
}
|
||||
|
||||
fun setThemeStyle(style: ThemeStyle) = launch {
|
||||
log(TAG, INFO) { "setThemeStyle($style)" }
|
||||
if (isPro.first()) {
|
||||
generalSettings.themeStyle.valueBlocking = style
|
||||
} else {
|
||||
@@ -120,6 +131,7 @@ class GeneralSettingsViewModel @Inject constructor(
|
||||
}
|
||||
|
||||
fun setThemeColor(color: ThemeColor) = launch {
|
||||
log(TAG, INFO) { "setThemeColor($color)" }
|
||||
if (isPro.first()) {
|
||||
generalSettings.themeColor.valueBlocking = color
|
||||
} else {
|
||||
@@ -128,10 +140,12 @@ class GeneralSettingsViewModel @Inject constructor(
|
||||
}
|
||||
|
||||
fun launchUpgrade() {
|
||||
log(TAG, INFO) { "launchUpgrade()" }
|
||||
navTo(Nav.Main.Upgrade)
|
||||
}
|
||||
|
||||
fun goToDebugSettings() {
|
||||
log(TAG, INFO) { "goToDebugSettings()" }
|
||||
navTo(Nav.Settings.Debug)
|
||||
}
|
||||
|
||||
|
||||
+5
@@ -3,6 +3,8 @@ package eu.darken.capod.main.ui.settings.general.debug
|
||||
import dagger.hilt.android.lifecycle.HiltViewModel
|
||||
import eu.darken.capod.common.coroutine.DispatcherProvider
|
||||
import eu.darken.capod.common.debug.DebugSettings
|
||||
import eu.darken.capod.common.debug.logging.Logging.Priority.INFO
|
||||
import eu.darken.capod.common.debug.logging.log
|
||||
import eu.darken.capod.common.debug.logging.logTag
|
||||
|
||||
import eu.darken.capod.common.uix.ViewModel4
|
||||
@@ -35,14 +37,17 @@ class DebugSettingsViewModel @Inject constructor(
|
||||
}.asLiveState()
|
||||
|
||||
fun setDebugModeEnabled(enabled: Boolean) {
|
||||
log(TAG, INFO) { "setDebugModeEnabled($enabled)" }
|
||||
debugSettings.isDebugModeEnabled.valueBlocking = enabled
|
||||
}
|
||||
|
||||
fun setShowFakeData(enabled: Boolean) {
|
||||
log(TAG, INFO) { "setShowFakeData($enabled)" }
|
||||
debugSettings.showFakeData.valueBlocking = enabled
|
||||
}
|
||||
|
||||
fun setShowUnfiltered(enabled: Boolean) {
|
||||
log(TAG, INFO) { "setShowUnfiltered($enabled)" }
|
||||
debugSettings.showUnfiltered.valueBlocking = enabled
|
||||
}
|
||||
|
||||
|
||||
@@ -2,6 +2,9 @@ package eu.darken.capod.main.ui.stemactions
|
||||
|
||||
import dagger.hilt.android.lifecycle.HiltViewModel
|
||||
import eu.darken.capod.common.coroutine.DispatcherProvider
|
||||
import eu.darken.capod.common.debug.logging.Logging.Priority.INFO
|
||||
import eu.darken.capod.common.debug.logging.log
|
||||
import eu.darken.capod.common.debug.logging.logTag
|
||||
import eu.darken.capod.common.uix.ViewModel4
|
||||
import eu.darken.capod.reaction.core.stem.StemAction
|
||||
import eu.darken.capod.reaction.core.stem.StemActionSettings
|
||||
@@ -49,41 +52,49 @@ class StemActionConfigViewModel @Inject constructor(
|
||||
)
|
||||
|
||||
fun setLeftSingle(action: StemAction) = launch {
|
||||
log(TAG, INFO) { "setLeftSingle($action)" }
|
||||
stemActionSettings.leftSingle.update { action }
|
||||
applyCrossSideEffect(action, stemActionSettings.rightSingle)
|
||||
}
|
||||
|
||||
fun setLeftDouble(action: StemAction) = launch {
|
||||
log(TAG, INFO) { "setLeftDouble($action)" }
|
||||
stemActionSettings.leftDouble.update { action }
|
||||
applyCrossSideEffect(action, stemActionSettings.rightDouble)
|
||||
}
|
||||
|
||||
fun setLeftTriple(action: StemAction) = launch {
|
||||
log(TAG, INFO) { "setLeftTriple($action)" }
|
||||
stemActionSettings.leftTriple.update { action }
|
||||
applyCrossSideEffect(action, stemActionSettings.rightTriple)
|
||||
}
|
||||
|
||||
fun setLeftLong(action: StemAction) = launch {
|
||||
log(TAG, INFO) { "setLeftLong($action)" }
|
||||
stemActionSettings.leftLong.update { action }
|
||||
applyCrossSideEffect(action, stemActionSettings.rightLong)
|
||||
}
|
||||
|
||||
fun setRightSingle(action: StemAction) = launch {
|
||||
log(TAG, INFO) { "setRightSingle($action)" }
|
||||
stemActionSettings.rightSingle.update { action }
|
||||
applyCrossSideEffect(action, stemActionSettings.leftSingle)
|
||||
}
|
||||
|
||||
fun setRightDouble(action: StemAction) = launch {
|
||||
log(TAG, INFO) { "setRightDouble($action)" }
|
||||
stemActionSettings.rightDouble.update { action }
|
||||
applyCrossSideEffect(action, stemActionSettings.leftDouble)
|
||||
}
|
||||
|
||||
fun setRightTriple(action: StemAction) = launch {
|
||||
log(TAG, INFO) { "setRightTriple($action)" }
|
||||
stemActionSettings.rightTriple.update { action }
|
||||
applyCrossSideEffect(action, stemActionSettings.leftTriple)
|
||||
}
|
||||
|
||||
fun setRightLong(action: StemAction) = launch {
|
||||
log(TAG, INFO) { "setRightLong($action)" }
|
||||
stemActionSettings.rightLong.update { action }
|
||||
applyCrossSideEffect(action, stemActionSettings.leftLong)
|
||||
}
|
||||
@@ -103,5 +114,12 @@ class StemActionConfigViewModel @Inject constructor(
|
||||
}
|
||||
}
|
||||
|
||||
fun resetAll() = launch { stemActionSettings.resetAll() }
|
||||
fun resetAll() = launch {
|
||||
log(TAG, INFO) { "resetAll()" }
|
||||
stemActionSettings.resetAll()
|
||||
}
|
||||
|
||||
companion object {
|
||||
private val TAG = logTag("StemAction", "Config", "VM")
|
||||
}
|
||||
}
|
||||
|
||||
@@ -6,6 +6,7 @@ import androidx.lifecycle.SavedStateHandle
|
||||
import dagger.hilt.android.lifecycle.HiltViewModel
|
||||
import dagger.hilt.android.qualifiers.ApplicationContext
|
||||
import eu.darken.capod.common.coroutine.DispatcherProvider
|
||||
import eu.darken.capod.common.debug.logging.Logging.Priority.INFO
|
||||
import eu.darken.capod.common.debug.logging.log
|
||||
import eu.darken.capod.common.debug.logging.logTag
|
||||
import eu.darken.capod.common.flow.combine
|
||||
@@ -83,12 +84,12 @@ class WidgetConfigurationViewModel @Inject constructor(
|
||||
}
|
||||
|
||||
fun selectProfile(profileId: ProfileId) {
|
||||
log(TAG) { "selectProfile(profileId=$profileId)" }
|
||||
log(TAG, INFO) { "selectProfile(profileId=$profileId)" }
|
||||
selectedProfile.value = profileId
|
||||
}
|
||||
|
||||
fun selectPreset(preset: WidgetTheme.Preset) {
|
||||
log(TAG) { "selectPreset(preset=$preset)" }
|
||||
log(TAG, INFO) { "selectPreset(preset=$preset)" }
|
||||
forceCustomMode.value = false
|
||||
currentTheme.value = WidgetTheme(
|
||||
backgroundColor = preset.presetBg,
|
||||
@@ -99,7 +100,7 @@ class WidgetConfigurationViewModel @Inject constructor(
|
||||
}
|
||||
|
||||
fun enterCustomMode(resolvedBg: Int, resolvedFg: Int) {
|
||||
log(TAG) { "enterCustomMode(resolvedBg=${String.format("#%06X", 0xFFFFFF and resolvedBg)}, resolvedFg=${String.format("#%06X", 0xFFFFFF and resolvedFg)})" }
|
||||
log(TAG, INFO) { "enterCustomMode(resolvedBg=${String.format("#%06X", 0xFFFFFF and resolvedBg)}, resolvedFg=${String.format("#%06X", 0xFFFFFF and resolvedFg)})" }
|
||||
forceCustomMode.value = true
|
||||
// Populate null colors with the currently displayed values so the user has a starting point
|
||||
val theme = currentTheme.value
|
||||
@@ -110,33 +111,33 @@ class WidgetConfigurationViewModel @Inject constructor(
|
||||
}
|
||||
|
||||
fun setBackgroundColor(color: Int) {
|
||||
log(TAG) { "setBackgroundColor(color=${String.format("#%06X", 0xFFFFFF and color)})" }
|
||||
log(TAG, INFO) { "setBackgroundColor(color=${String.format("#%06X", 0xFFFFFF and color)})" }
|
||||
currentTheme.value = currentTheme.value.copy(backgroundColor = color or 0xFF000000.toInt())
|
||||
}
|
||||
|
||||
fun setForegroundColor(color: Int) {
|
||||
log(TAG) { "setForegroundColor(color=${String.format("#%06X", 0xFFFFFF and color)})" }
|
||||
log(TAG, INFO) { "setForegroundColor(color=${String.format("#%06X", 0xFFFFFF and color)})" }
|
||||
currentTheme.value = currentTheme.value.copy(foregroundColor = color or 0xFF000000.toInt())
|
||||
}
|
||||
|
||||
fun setBackgroundAlpha(alpha: Int) {
|
||||
log(TAG) { "setBackgroundAlpha(alpha=$alpha)" }
|
||||
log(TAG, INFO) { "setBackgroundAlpha(alpha=$alpha)" }
|
||||
currentTheme.value = currentTheme.value.copy(backgroundAlpha = alpha.coerceIn(0, 255))
|
||||
}
|
||||
|
||||
fun toggleDeviceLabel() {
|
||||
val newValue = !currentTheme.value.showDeviceLabel
|
||||
log(TAG) { "toggleDeviceLabel(showDeviceLabel=$newValue)" }
|
||||
log(TAG, INFO) { "toggleDeviceLabel(showDeviceLabel=$newValue)" }
|
||||
currentTheme.value = currentTheme.value.copy(showDeviceLabel = newValue)
|
||||
}
|
||||
|
||||
fun setShowDeviceLabel(show: Boolean) {
|
||||
log(TAG) { "setShowDeviceLabel(show=$show)" }
|
||||
log(TAG, INFO) { "setShowDeviceLabel(show=$show)" }
|
||||
currentTheme.value = currentTheme.value.copy(showDeviceLabel = show)
|
||||
}
|
||||
|
||||
fun resetToDefaults() {
|
||||
log(TAG) { "resetToDefaults()" }
|
||||
log(TAG, INFO) { "resetToDefaults()" }
|
||||
forceCustomMode.value = false
|
||||
currentTheme.value = WidgetTheme.DEFAULT
|
||||
}
|
||||
@@ -144,13 +145,13 @@ class WidgetConfigurationViewModel @Inject constructor(
|
||||
fun confirmSelection() {
|
||||
val selectedProfile = selectedProfile.value
|
||||
if (selectedProfile != null) {
|
||||
log(TAG) { "confirmSelection(widgetId=$widgetId, selectedProfile=$selectedProfile)" }
|
||||
log(TAG, INFO) { "confirmSelection(widgetId=$widgetId, selectedProfile=$selectedProfile)" }
|
||||
widgetSettings.saveWidgetProfile(widgetId, selectedProfile)
|
||||
}
|
||||
|
||||
// Save theme to AppWidgetOptions bundle
|
||||
val theme = currentTheme.value
|
||||
log(TAG) { "confirmSelection: saving theme=$theme" }
|
||||
log(TAG, INFO) { "confirmSelection: saving theme=$theme" }
|
||||
val options = appWidgetManager.getAppWidgetOptions(widgetId)
|
||||
theme.toBundle(options)
|
||||
appWidgetManager.updateAppWidgetOptions(widgetId, options)
|
||||
|
||||
@@ -2,6 +2,7 @@ package eu.darken.capod.profiles.ui
|
||||
|
||||
import dagger.hilt.android.lifecycle.HiltViewModel
|
||||
import eu.darken.capod.common.coroutine.DispatcherProvider
|
||||
import eu.darken.capod.common.debug.logging.Logging.Priority.INFO
|
||||
import eu.darken.capod.common.debug.logging.log
|
||||
import eu.darken.capod.common.debug.logging.logTag
|
||||
|
||||
@@ -28,22 +29,22 @@ class DeviceManagerViewModel @Inject constructor(
|
||||
)
|
||||
|
||||
fun onAddDevice() {
|
||||
log(TAG) { "onAddDevice()" }
|
||||
log(TAG, INFO) { "onAddDevice()" }
|
||||
navTo(Nav.Main.DeviceProfileCreation())
|
||||
}
|
||||
|
||||
fun onEditProfile(profile: DeviceProfile) {
|
||||
log(TAG) { "onEditProfile(): $profile" }
|
||||
log(TAG, INFO) { "onEditProfile(): $profile" }
|
||||
navTo(Nav.Main.DeviceProfileCreation(profileId = profile.id))
|
||||
}
|
||||
|
||||
fun onDeviceSettings(profile: DeviceProfile) {
|
||||
log(TAG) { "onDeviceSettings(): $profile" }
|
||||
log(TAG, INFO) { "onDeviceSettings(): $profile" }
|
||||
navTo(Nav.Main.DeviceSettings(profileId = profile.id))
|
||||
}
|
||||
|
||||
fun onReorder(profileIds: List<ProfileId>) = launch {
|
||||
log(TAG) { "onReorder(): ${profileIds.size} profiles" }
|
||||
log(TAG, INFO) { "onReorder(): ${profileIds.size} profiles" }
|
||||
deviceProfilesRepo.reorderProfilesById(profileIds)
|
||||
}
|
||||
|
||||
|
||||
+20
-18
@@ -8,6 +8,8 @@ import eu.darken.capod.common.WebpageTool
|
||||
import eu.darken.capod.common.bluetooth.BluetoothDevice2
|
||||
import eu.darken.capod.common.bluetooth.BluetoothManager2
|
||||
import eu.darken.capod.common.coroutine.DispatcherProvider
|
||||
import eu.darken.capod.common.debug.logging.Logging.Priority.INFO
|
||||
import eu.darken.capod.common.debug.logging.Logging.Priority.WARN
|
||||
import eu.darken.capod.common.debug.logging.log
|
||||
import eu.darken.capod.common.debug.logging.logTag
|
||||
import eu.darken.capod.common.flow.SingleEventFlow
|
||||
@@ -163,27 +165,27 @@ class DeviceProfileCreationViewModel @Inject constructor(
|
||||
|
||||
fun updateModel(model: PodModel) {
|
||||
_currentState.value = _currentState.value.copy(selectedModel = model)
|
||||
log(TAG) { "Selected model: $model" }
|
||||
log(TAG, INFO) { "Selected model: $model" }
|
||||
}
|
||||
|
||||
fun updateIdentityKey(key: IdentityResolvingKey?) {
|
||||
_currentState.value = _currentState.value.copy(identityKeyHex = key?.toHex())
|
||||
log(TAG) { "Identity key updated: ${key != null}" }
|
||||
log(TAG, INFO) { "Identity key updated: ${key != null}" }
|
||||
}
|
||||
|
||||
fun updateEncryptionKey(key: ProximityEncryptionKey?) {
|
||||
_currentState.value = _currentState.value.copy(encryptionKeyHex = key?.toHex())
|
||||
log(TAG) { "Encryption key updated: ${key != null}" }
|
||||
log(TAG, INFO) { "Encryption key updated: ${key != null}" }
|
||||
}
|
||||
|
||||
fun updateSelectedDevice(device: BluetoothDevice2?) {
|
||||
_currentState.value = _currentState.value.copy(selectedDeviceAddress = device?.address)
|
||||
log(TAG) { "Selected device updated: ${device?.name} (${device?.address})" }
|
||||
log(TAG, INFO) { "Selected device updated: ${device?.name} (${device?.address})" }
|
||||
}
|
||||
|
||||
fun updateMinimumSignalQuality(quality: Float) {
|
||||
_currentState.value = _currentState.value.copy(minimumSignalQuality = quality)
|
||||
log(TAG) { "Minimum signal quality updated: $quality" }
|
||||
log(TAG, INFO) { "Minimum signal quality updated: $quality" }
|
||||
}
|
||||
|
||||
fun hasUnsavedChanges(): Boolean = _currentState.value != _initialState.value
|
||||
@@ -194,7 +196,7 @@ class DeviceProfileCreationViewModel @Inject constructor(
|
||||
}
|
||||
|
||||
fun onBackPressed() {
|
||||
log(TAG) { "onBackPressed()" }
|
||||
log(TAG, INFO) { "onBackPressed()" }
|
||||
if (hasUnsavedChanges()) {
|
||||
showUnsavedChangesEvent.tryEmit(Unit)
|
||||
} else {
|
||||
@@ -203,7 +205,7 @@ class DeviceProfileCreationViewModel @Inject constructor(
|
||||
}
|
||||
|
||||
fun saveProfile() {
|
||||
log(TAG) { "saveProfile()" }
|
||||
log(TAG, INFO) { "saveProfile()" }
|
||||
val editorState = _currentState.value
|
||||
val name = editorState.name.trim()
|
||||
|
||||
@@ -213,7 +215,7 @@ class DeviceProfileCreationViewModel @Inject constructor(
|
||||
}
|
||||
|
||||
if (editorState.selectedModel == null) {
|
||||
log(TAG) { "No model selected" }
|
||||
log(TAG, INFO) { "No model selected" }
|
||||
return
|
||||
}
|
||||
|
||||
@@ -232,7 +234,7 @@ class DeviceProfileCreationViewModel @Inject constructor(
|
||||
address = editorState.selectedDeviceAddress,
|
||||
)
|
||||
}
|
||||
log(TAG) { "Profile updated: $profileId" }
|
||||
log(TAG, INFO) { "Profile updated: $profileId" }
|
||||
} else {
|
||||
val profile = AppleDeviceProfile(
|
||||
id = UUID.randomUUID().toString(),
|
||||
@@ -244,18 +246,18 @@ class DeviceProfileCreationViewModel @Inject constructor(
|
||||
address = editorState.selectedDeviceAddress,
|
||||
)
|
||||
deviceProfilesRepo.addProfile(profile)
|
||||
log(TAG) { "Profile created: $profile" }
|
||||
log(TAG, INFO) { "Profile created: $profile" }
|
||||
}
|
||||
exitScreen()
|
||||
} catch (e: Exception) {
|
||||
log(TAG) { "Failed to save profile: $e" }
|
||||
log(TAG, WARN) { "Failed to save profile: $e" }
|
||||
errorEvents.emitBlocking(e)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fun requestDeleteProfile() {
|
||||
log(TAG) { "requestDeleteProfile()" }
|
||||
log(TAG, INFO) { "requestDeleteProfile()" }
|
||||
showDeleteConfirmationEvent.tryEmit(Unit)
|
||||
}
|
||||
|
||||
@@ -265,10 +267,10 @@ class DeviceProfileCreationViewModel @Inject constructor(
|
||||
launch {
|
||||
try {
|
||||
deviceProfilesRepo.removeProfile(id)
|
||||
log(TAG) { "Profile deleted: $id" }
|
||||
log(TAG, INFO) { "Profile deleted: $id" }
|
||||
exitScreen()
|
||||
} catch (e: Exception) {
|
||||
log(TAG) { "Failed to delete profile: $e" }
|
||||
log(TAG, WARN) { "Failed to delete profile: $e" }
|
||||
errorEvents.emitBlocking(e)
|
||||
}
|
||||
}
|
||||
@@ -276,7 +278,7 @@ class DeviceProfileCreationViewModel @Inject constructor(
|
||||
}
|
||||
|
||||
fun discardChanges() {
|
||||
log(TAG) { "discardChanges()" }
|
||||
log(TAG, INFO) { "discardChanges()" }
|
||||
exitScreen()
|
||||
}
|
||||
|
||||
@@ -300,13 +302,13 @@ class DeviceProfileCreationViewModel @Inject constructor(
|
||||
)
|
||||
_initialState.value = loadedState
|
||||
_currentState.value = loadedState
|
||||
log(TAG) { "Profile loaded: ${profile.label}" }
|
||||
log(TAG, INFO) { "Profile loaded: ${profile.label}" }
|
||||
} else {
|
||||
log(TAG) { "Profile not found: $profileId" }
|
||||
log(TAG, WARN) { "Profile not found: $profileId" }
|
||||
errorEvents.emitBlocking(IllegalArgumentException("Profile not found"))
|
||||
}
|
||||
} catch (e: Exception) {
|
||||
log(TAG) { "Failed to load profile: $e" }
|
||||
log(TAG, WARN) { "Failed to load profile: $e" }
|
||||
errorEvents.emitBlocking(e)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -17,6 +17,7 @@ import androidx.savedstate.SavedStateRegistryOwner
|
||||
import androidx.savedstate.setViewTreeSavedStateRegistryOwner
|
||||
import dagger.hilt.android.qualifiers.ApplicationContext
|
||||
import eu.darken.capod.common.debug.logging.Logging.Priority.ERROR
|
||||
import eu.darken.capod.common.debug.logging.Logging.Priority.INFO
|
||||
import eu.darken.capod.common.debug.logging.asLog
|
||||
import eu.darken.capod.common.debug.logging.log
|
||||
import eu.darken.capod.common.debug.logging.logTag
|
||||
@@ -60,7 +61,7 @@ class PopUpWindow @Inject constructor(
|
||||
return
|
||||
}
|
||||
try {
|
||||
log(TAG) { "open()" }
|
||||
log(TAG, INFO) { "open()" }
|
||||
|
||||
if (composeView?.parent != null && deviceState != null) {
|
||||
log(TAG) { "Popup already visible, updating device." }
|
||||
@@ -101,7 +102,7 @@ class PopUpWindow @Inject constructor(
|
||||
}
|
||||
|
||||
fun close() = try {
|
||||
log(TAG) { "close()" }
|
||||
log(TAG, INFO) { "close()" }
|
||||
if (composeView?.parent != null) {
|
||||
teardown()
|
||||
} else {
|
||||
|
||||
@@ -82,7 +82,7 @@ class TroubleShooterViewModel @Inject constructor(
|
||||
}
|
||||
|
||||
fun troubleShootBle() = launch(context = dispatcherProvider.IO) {
|
||||
log(TAG) { "troubleShootBle()" }
|
||||
log(TAG, INFO) { "troubleShootBle()" }
|
||||
|
||||
generalSettings.scannerMode.valueBlocking = ScannerMode.LOW_LATENCY
|
||||
|
||||
|
||||
Reference in New Issue
Block a user