From 55bccafef5d246bc1255d8db622eb43ca565c817 Mon Sep 17 00:00:00 2001 From: Milos Kozak Date: Sun, 31 May 2020 12:02:42 +0200 Subject: [PATCH] Large display skin --- .../nightscout/androidaps/MainActivity.kt | 1 + .../dependencyInjection/SkinsModule.kt | 7 ++++++ .../general/overview/OverviewFragment.kt | 3 ++- .../androidaps/skins/SkinButtonsOn.kt | 4 +++- .../androidaps/skins/SkinClassic.kt | 4 +++- .../androidaps/skins/SkinInterface.kt | 2 ++ .../androidaps/skins/SkinLargeDisplay.kt | 23 +++++++++++++++++++ app/src/main/res/values/strings.xml | 5 ++-- 8 files changed, 44 insertions(+), 5 deletions(-) create mode 100644 app/src/main/java/info/nightscout/androidaps/skins/SkinLargeDisplay.kt diff --git a/app/src/main/java/info/nightscout/androidaps/MainActivity.kt b/app/src/main/java/info/nightscout/androidaps/MainActivity.kt index f25cf49fc9..7881fea604 100644 --- a/app/src/main/java/info/nightscout/androidaps/MainActivity.kt +++ b/app/src/main/java/info/nightscout/androidaps/MainActivity.kt @@ -174,6 +174,7 @@ class MainActivity : NoSplashAppCompatActivity() { private fun processPreferenceChange(ev: EventPreferenceChange) { if (ev.isChanged(resourceHelper, R.string.key_keep_screen_on)) setWakeLock() + if (ev.isChanged(resourceHelper, R.string.key_skin)) recreate() } private fun setupViews() { diff --git a/app/src/main/java/info/nightscout/androidaps/dependencyInjection/SkinsModule.kt b/app/src/main/java/info/nightscout/androidaps/dependencyInjection/SkinsModule.kt index ebd4691f38..cd71cc8fd2 100644 --- a/app/src/main/java/info/nightscout/androidaps/dependencyInjection/SkinsModule.kt +++ b/app/src/main/java/info/nightscout/androidaps/dependencyInjection/SkinsModule.kt @@ -8,6 +8,7 @@ import dagger.multibindings.IntoMap import info.nightscout.androidaps.skins.SkinButtonsOn import info.nightscout.androidaps.skins.SkinClassic import info.nightscout.androidaps.skins.SkinInterface +import info.nightscout.androidaps.skins.SkinLargeDisplay import javax.inject.Qualifier @Module @@ -25,6 +26,12 @@ open class SkinsModule { @IntKey(10) fun bindsSkinButtonsOn(skinButtonsOn: SkinButtonsOn): SkinInterface = skinButtonsOn + @Provides + @Skin + @IntoMap + @IntKey(20) + fun bindsSkinLargeDisplay(skinLargeDisplay: SkinLargeDisplay): SkinInterface = skinLargeDisplay + @Qualifier annotation class Skin } \ No newline at end of file diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/general/overview/OverviewFragment.kt b/app/src/main/java/info/nightscout/androidaps/plugins/general/overview/OverviewFragment.kt index c9ea872345..07dbc14b94 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/general/overview/OverviewFragment.kt +++ b/app/src/main/java/info/nightscout/androidaps/plugins/general/overview/OverviewFragment.kt @@ -184,6 +184,7 @@ class OverviewFragment : DaggerFragment(), View.OnClickListener, OnLongClickList overview_bggraph?.gridLabelRenderer?.gridColor = resourceHelper.gc(R.color.graphgrid) overview_bggraph?.gridLabelRenderer?.reloadStyles() overview_bggraph?.gridLabelRenderer?.labelVerticalWidth = axisWidth + overview_bggraph?.layoutParams?.height = resourceHelper.dpToPx(skinProvider.activeSkin().mainGraphHeight) rangeToDisplay = sp.getInt(R.string.key_rangetodisplay, 6) @@ -482,7 +483,7 @@ class OverviewFragment : DaggerFragment(), View.OnClickListener, OnLongClickList overview_iobgraph.addView(label) secondaryGraphsLabel.add(label) 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?.reloadStyles() graph.gridLabelRenderer?.isHorizontalLabelsVisible = false diff --git a/app/src/main/java/info/nightscout/androidaps/skins/SkinButtonsOn.kt b/app/src/main/java/info/nightscout/androidaps/skins/SkinButtonsOn.kt index b2243d3336..9584ce2f4b 100644 --- a/app/src/main/java/info/nightscout/androidaps/skins/SkinButtonsOn.kt +++ b/app/src/main/java/info/nightscout/androidaps/skins/SkinButtonsOn.kt @@ -8,7 +8,9 @@ import javax.inject.Singleton @Singleton 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 = when { diff --git a/app/src/main/java/info/nightscout/androidaps/skins/SkinClassic.kt b/app/src/main/java/info/nightscout/androidaps/skins/SkinClassic.kt index deef2440f3..9388843db8 100644 --- a/app/src/main/java/info/nightscout/androidaps/skins/SkinClassic.kt +++ b/app/src/main/java/info/nightscout/androidaps/skins/SkinClassic.kt @@ -8,7 +8,9 @@ import javax.inject.Singleton @Singleton 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 = when { diff --git a/app/src/main/java/info/nightscout/androidaps/skins/SkinInterface.kt b/app/src/main/java/info/nightscout/androidaps/skins/SkinInterface.kt index 6a9d055a13..73c047d100 100644 --- a/app/src/main/java/info/nightscout/androidaps/skins/SkinInterface.kt +++ b/app/src/main/java/info/nightscout/androidaps/skins/SkinInterface.kt @@ -6,5 +6,7 @@ import androidx.annotation.StringRes interface SkinInterface { @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 } \ No newline at end of file diff --git a/app/src/main/java/info/nightscout/androidaps/skins/SkinLargeDisplay.kt b/app/src/main/java/info/nightscout/androidaps/skins/SkinLargeDisplay.kt new file mode 100644 index 0000000000..b28a0e3e0a --- /dev/null +++ b/app/src/main/java/info/nightscout/androidaps/skins/SkinLargeDisplay.kt @@ -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 + } + +} \ No newline at end of file diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 8f40ffbbe3..01a74eb73e 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -1548,8 +1548,9 @@ statuslights_copy_ns Copy NS settings (if exists)? statuslights_overview_advanced - Original skin - Buttons are always displayed on bottom of screen + Original skin + Buttons are always displayed on bottom of screen + Large display skin Skin