Add debug options to weather settings screen
This commit is contained in:
parent
497625a9e6
commit
2a01bccb62
@ -26,6 +26,7 @@ import androidx.compose.ui.unit.dp
|
|||||||
import androidx.compose.ui.window.Dialog
|
import androidx.compose.ui.window.Dialog
|
||||||
import androidx.lifecycle.viewmodel.compose.viewModel
|
import androidx.lifecycle.viewmodel.compose.viewModel
|
||||||
import de.mm20.launcher2.preferences.Settings.WeatherSettings.WeatherProvider
|
import de.mm20.launcher2.preferences.Settings.WeatherSettings.WeatherProvider
|
||||||
|
import de.mm20.launcher2.ui.BuildConfig
|
||||||
import de.mm20.launcher2.ui.R
|
import de.mm20.launcher2.ui.R
|
||||||
import de.mm20.launcher2.ui.component.MissingPermissionBanner
|
import de.mm20.launcher2.ui.component.MissingPermissionBanner
|
||||||
import de.mm20.launcher2.ui.component.preferences.*
|
import de.mm20.launcher2.ui.component.preferences.*
|
||||||
@ -108,6 +109,18 @@ fun WeatherScreen() {
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (BuildConfig.DEBUG) {
|
||||||
|
item {
|
||||||
|
PreferenceCategory(stringResource(R.string.preference_category_debug)) {
|
||||||
|
Preference(
|
||||||
|
"Clear weather data",
|
||||||
|
summary = "Remove weather data from database",
|
||||||
|
onClick = {
|
||||||
|
viewModel.clearWeatherData()
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -92,4 +92,8 @@ class WeatherScreenVM : ViewModel(), KoinComponent {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fun clearWeatherData() {
|
||||||
|
repository.clearForecasts()
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@ -32,6 +32,8 @@ interface WeatherRepository {
|
|||||||
fun selectProvider(provider: WeatherSettings.WeatherProvider)
|
fun selectProvider(provider: WeatherSettings.WeatherProvider)
|
||||||
|
|
||||||
val selectedProvider: Flow<WeatherSettings.WeatherProvider>
|
val selectedProvider: Flow<WeatherSettings.WeatherProvider>
|
||||||
|
|
||||||
|
fun clearForecasts()
|
||||||
}
|
}
|
||||||
|
|
||||||
class WeatherRepositoryImpl(
|
class WeatherRepositoryImpl(
|
||||||
@ -174,6 +176,14 @@ class WeatherRepositoryImpl(
|
|||||||
.build()
|
.build()
|
||||||
WorkManager.getInstance(context).enqueue(weatherRequest)
|
WorkManager.getInstance(context).enqueue(weatherRequest)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
override fun clearForecasts() {
|
||||||
|
scope.launch {
|
||||||
|
withContext(Dispatchers.IO) {
|
||||||
|
database.weatherDao().deleteAll()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
class WeatherUpdateWorker(val context: Context, params: WorkerParameters) :
|
class WeatherUpdateWorker(val context: Context, params: WorkerParameters) :
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user