Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add setting to enable/disable the apps module. #5

Merged
merged 1 commit into from
Nov 8, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,18 @@ import dagger.hilt.android.qualifiers.ApplicationContext
import eu.darken.octi.common.datastore.PreferenceScreenData
import eu.darken.octi.common.datastore.PreferenceStoreMapper
import eu.darken.octi.common.debug.logging.logTag
import eu.darken.octi.modules.apps.core.AppsSettings
import eu.darken.octi.modules.power.core.PowerSettings
import eu.darken.octi.modules.wifi.core.WifiSettings
import javax.inject.Inject
import javax.inject.Singleton

@Singleton
class GeneralModuleSettings @Inject constructor(
@ApplicationContext private val context: Context,
private val powerSettings: eu.darken.octi.modules.power.core.PowerSettings,
private val powerSettings: PowerSettings,
private val wifiSettings: WifiSettings,
private val appsSettings: AppsSettings,
) : PreferenceScreenData {
private val Context.dataStore by preferencesDataStore(name = "module_settings")

Expand All @@ -26,6 +29,7 @@ class GeneralModuleSettings @Inject constructor(
override val mapper = PreferenceStoreMapper(
powerSettings.isEnabled,
wifiSettings.isEnabled,
appsSettings.isEnabled,
)

companion object {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ import javax.inject.Inject

@HiltViewModel
class ModuleSettingsVM @Inject constructor(
private val handle: SavedStateHandle,
private val dispatcherProvider: DispatcherProvider,
@Suppress("unused") private val handle: SavedStateHandle,
dispatcherProvider: DispatcherProvider,
) : ViewModel3(dispatcherProvider) {

companion object {
Expand Down
2 changes: 2 additions & 0 deletions app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -194,4 +194,6 @@
<string name="pro_device_limit_reached_title">Device limit reached</string>
<string name="pro_device_limit_reached_description">You currently have %1$d synced devices. To view more than %2$d devices, upgrade to Octi Pro or remove devices.</string>
<string name="module_power_widget_description">Display the battery status of your synced devices.</string>
<string name="module_apps_label">Apps module</string>
<string name="module_apps_desc">Information about installed apps.</string>
</resources>
6 changes: 6 additions & 0 deletions app/src/main/res/xml/preferences_module.xml
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,10 @@
android:summary="@string/module_wifi_desc"
android:title="@string/module_wifi_label" />

<CheckBoxPreference
android:icon="@drawable/ic_baseline_apps_24"
android:key="module.apps.enabled"
android:summary="@string/module_apps_desc"
android:title="@string/module_apps_label" />

</PreferenceScreen>