-
-
Notifications
You must be signed in to change notification settings - Fork 128
Bubble level change color when reach threshold #3241
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
base: main
Are you sure you want to change the base?
Changes from all commits
e152aaf
24c18a6
a7f27e1
1a51a1d
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,17 @@ | ||
| package com.kylecorry.trail_sense.settings.infrastructure | ||
|
|
||
| import android.content.Context | ||
| import com.kylecorry.andromeda.preferences.FloatPreference | ||
| import com.kylecorry.trail_sense.R | ||
| import com.kylecorry.trail_sense.shared.preferences.PreferencesSubsystem | ||
|
|
||
| class BubbleLevelPreferences(private val context: Context) : IBubbleLevelPreferences { | ||
|
|
||
| private val cache by lazy { PreferencesSubsystem.getInstance(context).preferences } | ||
|
|
||
| override var threshold by FloatPreference( | ||
| cache, | ||
| context.getString(R.string.pref_bubble_level_threshold), | ||
| 2.0f | ||
| ) | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| package com.kylecorry.trail_sense.settings.infrastructure | ||
|
|
||
| interface IBubbleLevelPreferences { | ||
| var threshold: Float | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,25 @@ | ||
| package com.kylecorry.trail_sense.tools.level.ui | ||
|
|
||
| import android.os.Bundle | ||
| import com.kylecorry.andromeda.fragments.AndromedaPreferenceFragment | ||
| import com.kylecorry.trail_sense.R | ||
| import com.kylecorry.trail_sense.settings.infrastructure.BubbleLevelPreferences | ||
| import com.kylecorry.trail_sense.shared.preferences.setupThresholdSetting | ||
|
|
||
| class BubbleLevelSettingsFragment : AndromedaPreferenceFragment() { | ||
|
|
||
| private val prefs by lazy { BubbleLevelPreferences(requireContext()) } | ||
|
|
||
| override fun onCreatePreferences(savedInstanceState: Bundle?, rootKey: String?) { | ||
| setPreferencesFromResource(R.xml.bubble_level_preferences, rootKey) | ||
|
|
||
| setupThresholdSetting( | ||
| getString(R.string.pref_bubble_level_threshold), | ||
| { prefs.threshold.toInt() }, | ||
| { prefs.threshold = it.toFloat() }, | ||
| minValue = 1, | ||
|
Owner
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is it possible to make the minimum value 0? That way if a user doesn't want it to show they can set it to 0 and it should never appear |
||
| maxValue = 10, | ||
| formatValue = { getString(R.string.degree_format, it.toFloat()) } | ||
|
Owner
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can the FormatService be used? Available with AppServiceRegistry.get() |
||
| ) | ||
| } | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,17 @@ | ||
| <?xml version="1.0" encoding="utf-8"?> | ||
| <PreferenceScreen xmlns:app="http://schemas.android.com/apk/res-auto"> | ||
|
|
||
| <PreferenceCategory | ||
| app:iconSpaceReserved="false" | ||
| app:singleLineTitle="false" | ||
| app:title="@string/tool_bubble_level_title"> | ||
|
|
||
| <Preference | ||
| app:iconSpaceReserved="false" | ||
| app:key="@string/pref_bubble_level_threshold" | ||
| app:singleLineTitle="false" | ||
| app:title="@string/pref_bubble_level_threshold_title" /> | ||
|
|
||
| </PreferenceCategory> | ||
|
|
||
| </PreferenceScreen> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can this extend the PreferenceRepo as well?
(that removes the need to define cache)