Large display skin

This commit is contained in:
Milos Kozak 2020-05-31 12:02:42 +02:00
parent 09de329934
commit 55bccafef5
8 changed files with 44 additions and 5 deletions

View file

@ -174,6 +174,7 @@ class MainActivity : NoSplashAppCompatActivity() {
private fun processPreferenceChange(ev: EventPreferenceChange) { private fun processPreferenceChange(ev: EventPreferenceChange) {
if (ev.isChanged(resourceHelper, R.string.key_keep_screen_on)) setWakeLock() if (ev.isChanged(resourceHelper, R.string.key_keep_screen_on)) setWakeLock()
if (ev.isChanged(resourceHelper, R.string.key_skin)) recreate()
} }
private fun setupViews() { private fun setupViews() {

View file

@ -8,6 +8,7 @@ import dagger.multibindings.IntoMap
import info.nightscout.androidaps.skins.SkinButtonsOn import info.nightscout.androidaps.skins.SkinButtonsOn
import info.nightscout.androidaps.skins.SkinClassic import info.nightscout.androidaps.skins.SkinClassic
import info.nightscout.androidaps.skins.SkinInterface import info.nightscout.androidaps.skins.SkinInterface
import info.nightscout.androidaps.skins.SkinLargeDisplay
import javax.inject.Qualifier import javax.inject.Qualifier
@Module @Module
@ -25,6 +26,12 @@ open class SkinsModule {
@IntKey(10) @IntKey(10)
fun bindsSkinButtonsOn(skinButtonsOn: SkinButtonsOn): SkinInterface = skinButtonsOn fun bindsSkinButtonsOn(skinButtonsOn: SkinButtonsOn): SkinInterface = skinButtonsOn
@Provides
@Skin
@IntoMap
@IntKey(20)
fun bindsSkinLargeDisplay(skinLargeDisplay: SkinLargeDisplay): SkinInterface = skinLargeDisplay
@Qualifier @Qualifier
annotation class Skin annotation class Skin
} }

View file

@ -184,6 +184,7 @@ class OverviewFragment : DaggerFragment(), View.OnClickListener, OnLongClickList
overview_bggraph?.gridLabelRenderer?.gridColor = resourceHelper.gc(R.color.graphgrid) overview_bggraph?.gridLabelRenderer?.gridColor = resourceHelper.gc(R.color.graphgrid)
overview_bggraph?.gridLabelRenderer?.reloadStyles() overview_bggraph?.gridLabelRenderer?.reloadStyles()
overview_bggraph?.gridLabelRenderer?.labelVerticalWidth = axisWidth overview_bggraph?.gridLabelRenderer?.labelVerticalWidth = axisWidth
overview_bggraph?.layoutParams?.height = resourceHelper.dpToPx(skinProvider.activeSkin().mainGraphHeight)
rangeToDisplay = sp.getInt(R.string.key_rangetodisplay, 6) rangeToDisplay = sp.getInt(R.string.key_rangetodisplay, 6)
@ -482,7 +483,7 @@ class OverviewFragment : DaggerFragment(), View.OnClickListener, OnLongClickList
overview_iobgraph.addView(label) overview_iobgraph.addView(label)
secondaryGraphsLabel.add(label) secondaryGraphsLabel.add(label)
val graph = GraphView(context) val graph = GraphView(context)
graph.layoutParams = LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, resourceHelper.dpToPx(100)).also { it.setMargins(0, resourceHelper.dpToPx(35), 0, resourceHelper.dpToPx(15)) } graph.layoutParams = LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, resourceHelper.dpToPx(skinProvider.activeSkin().secondaryGraphHeight)).also { it.setMargins(0, resourceHelper.dpToPx(35), 0, resourceHelper.dpToPx(15)) }
graph.gridLabelRenderer?.gridColor = resourceHelper.gc(R.color.graphgrid) graph.gridLabelRenderer?.gridColor = resourceHelper.gc(R.color.graphgrid)
graph.gridLabelRenderer?.reloadStyles() graph.gridLabelRenderer?.reloadStyles()
graph.gridLabelRenderer?.isHorizontalLabelsVisible = false graph.gridLabelRenderer?.isHorizontalLabelsVisible = false

View file

@ -8,7 +8,9 @@ import javax.inject.Singleton
@Singleton @Singleton
class SkinButtonsOn @Inject constructor(private val config: Config) : SkinInterface { class SkinButtonsOn @Inject constructor(private val config: Config) : SkinInterface {
override val description: Int get() = R.string.buttonson_desrciption override val description: Int get() = R.string.buttonson_description
override val mainGraphHeight: Int get() = 200
override val secondaryGraphHeight: Int get() = 100
override fun overviewLayout(isLandscape: Boolean, isTablet: Boolean, isSmallHeight: Boolean): Int = override fun overviewLayout(isLandscape: Boolean, isTablet: Boolean, isSmallHeight: Boolean): Int =
when { when {

View file

@ -8,7 +8,9 @@ import javax.inject.Singleton
@Singleton @Singleton
class SkinClassic @Inject constructor(private val config: Config): SkinInterface { class SkinClassic @Inject constructor(private val config: Config): SkinInterface {
override val description: Int get() = R.string.classic_desrciption override val description: Int get() = R.string.classic_description
override val mainGraphHeight: Int get() = 200
override val secondaryGraphHeight: Int get() = 100
override fun overviewLayout(isLandscape: Boolean, isTablet: Boolean, isSmallHeight: Boolean): Int = override fun overviewLayout(isLandscape: Boolean, isTablet: Boolean, isSmallHeight: Boolean): Int =
when { when {

View file

@ -6,5 +6,7 @@ import androidx.annotation.StringRes
interface SkinInterface { interface SkinInterface {
@get:StringRes val description : Int @get:StringRes val description : Int
val mainGraphHeight : Int // in dp
val secondaryGraphHeight : Int // in dp
@LayoutRes fun overviewLayout(isLandscape : Boolean, isTablet : Boolean, isSmallHeight : Boolean): Int @LayoutRes fun overviewLayout(isLandscape : Boolean, isTablet : Boolean, isSmallHeight : Boolean): Int
} }

View file

@ -0,0 +1,23 @@
package info.nightscout.androidaps.skins
import info.nightscout.androidaps.Config
import info.nightscout.androidaps.R
import javax.inject.Inject
import javax.inject.Singleton
@Singleton
class SkinLargeDisplay @Inject constructor(private val config: Config): SkinInterface {
override val description: Int get() = R.string.largedisplay_description
override val mainGraphHeight: Int get() = 400
override val secondaryGraphHeight: Int get() = 150
override fun overviewLayout(isLandscape: Boolean, isTablet: Boolean, isSmallHeight: Boolean): Int =
when {
config.NSCLIENT && isTablet -> R.layout.overview_fragment_nsclient_tablet
config.NSCLIENT -> R.layout.overview_fragment_nsclient
isSmallHeight || isLandscape -> R.layout.overview_fragment_landscape
else -> R.layout.overview_fragment
}
}

View file

@ -1548,8 +1548,9 @@
<string name="key_statuslights_copy_ns" translatable="false">statuslights_copy_ns</string> <string name="key_statuslights_copy_ns" translatable="false">statuslights_copy_ns</string>
<string name="copyexistingvalues">Copy NS settings (if exists)?</string> <string name="copyexistingvalues">Copy NS settings (if exists)?</string>
<string name="key_statuslights_overview_advanced" translatable="false">statuslights_overview_advanced</string> <string name="key_statuslights_overview_advanced" translatable="false">statuslights_overview_advanced</string>
<string name="classic_desrciption">Original skin</string> <string name="classic_description">Original skin</string>
<string name="buttonson_desrciption">Buttons are always displayed on bottom of screen</string> <string name="buttonson_description">Buttons are always displayed on bottom of screen</string>
<string name="largedisplay_description">Large display</string>
<string name="key_skin" translatable="false">skin</string> <string name="key_skin" translatable="false">skin</string>
<string name="skin">Skin</string> <string name="skin">Skin</string>