diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/general/actions/ActionsFragment.kt b/app/src/main/java/info/nightscout/androidaps/plugins/general/actions/ActionsFragment.kt index a767da136a..86e4212def 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/general/actions/ActionsFragment.kt +++ b/app/src/main/java/info/nightscout/androidaps/plugins/general/actions/ActionsFragment.kt @@ -2,6 +2,7 @@ package info.nightscout.androidaps.plugins.general.actions import android.content.Intent import android.os.Bundle +import android.util.DisplayMetrics import android.view.LayoutInflater import android.view.View import android.view.ViewGroup @@ -9,6 +10,7 @@ import android.widget.LinearLayout import androidx.core.content.ContextCompat import dagger.android.support.DaggerFragment import info.nightscout.androidaps.Config +import info.nightscout.androidaps.Constants import info.nightscout.androidaps.MainApp import info.nightscout.androidaps.R import info.nightscout.androidaps.activities.ErrorHelperActivity @@ -62,10 +64,23 @@ class ActionsFragment : DaggerFragment() { private val pumpCustomActions = HashMap() private val pumpCustomButtons = ArrayList() + private var smallWidth = false + private var smallHeight = false + private lateinit var dm: DisplayMetrics override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View? { - return inflater.inflate(R.layout.actions_fragment, container, false) + //check screen width + dm = DisplayMetrics() + activity?.windowManager?.defaultDisplay?.getMetrics(dm) + + val screenWidth = dm.widthPixels + val screenHeight = dm.heightPixels + smallWidth = screenWidth <= Constants.SMALL_WIDTH + smallHeight = screenHeight <= Constants.SMALL_HEIGHT + val landscape = screenHeight < screenWidth + + return inflater.inflate(skinProvider.activeSkin().actionsLayout(landscape, smallWidth), container, false) } override fun onViewCreated(view: View, savedInstanceState: Bundle?) { @@ -242,29 +257,9 @@ class ActionsFragment : DaggerFragment() { actions_temptarget?.visibility = (profile != null && config.APS).toVisibility() actions_tddstats?.visibility = pump.pumpDescription.supportsTDDs.toVisibility() - val shortlabel = skinProvider.activeSkin().description == R.string.lowres_description - if (shortlabel) { - careportal_pblabel?.text = resourceHelper.gs(R.string.pump) - careportal_sensoragelabel?.text = "" - careportal_insulinagelabel?.text = "" - careportal_canulaagelabel?.text = "" - careportal_pbagelabel?.text = "" - } else { - careportal_pblabel.text = resourceHelper.gs(R.string.careportal_pb_label) - careportal_sensoragelabel.text = resourceHelper.gs(R.string.careportal_age_label) - careportal_insulinagelabel.text =resourceHelper.gs(R.string.careportal_age_label) - careportal_canulaagelabel.text =resourceHelper.gs(R.string.careportal_age_label) - careportal_pbagelabel.text =resourceHelper.gs(R.string.careportal_age_label) - } - if (!config.NSCLIENT) { statusLightHandler.updateStatusLights(careportal_canulaage, careportal_insulinage, careportal_reservoirlevel, careportal_sensorage, careportal_sensorlevel, careportal_pbage, careportal_batterylevel) - if (activeBgSource.sensorBatteryLevel == -1) - careportal_senslevellabel?.text = "" - else - careportal_senslevellabel?.text = if (shortlabel) "" else resourceHelper.gs(R.string.careportal_level_label) - careportal_inslevellabel?.text = if (shortlabel) "" else resourceHelper.gs(R.string.careportal_level_label) - careportal_pblevellabel?.text = if (shortlabel) "" else resourceHelper.gs(R.string.careportal_level_label) + careportal_senslevellabel?.text = if (activeBgSource.sensorBatteryLevel == -1) "" else resourceHelper.gs(R.string.careportal_level_label) } else { statusLightHandler.updateStatusLights(careportal_canulaage, careportal_insulinage, null, careportal_sensorage, null, careportal_pbage, null) careportal_senslevellabel?.text = "" 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 73c047d100..0722029b25 100644 --- a/app/src/main/java/info/nightscout/androidaps/skins/SkinInterface.kt +++ b/app/src/main/java/info/nightscout/androidaps/skins/SkinInterface.kt @@ -2,6 +2,7 @@ package info.nightscout.androidaps.skins import androidx.annotation.LayoutRes import androidx.annotation.StringRes +import info.nightscout.androidaps.R interface SkinInterface { @get:StringRes val description : Int @@ -9,4 +10,5 @@ interface SkinInterface { val mainGraphHeight : Int // in dp val secondaryGraphHeight : Int // in dp @LayoutRes fun overviewLayout(isLandscape : Boolean, isTablet : Boolean, isSmallHeight : Boolean): Int + @LayoutRes fun actionsLayout(isLandscape : Boolean, isSmallWidth : Boolean): Int = R.layout.actions_fragment } \ No newline at end of file diff --git a/app/src/main/java/info/nightscout/androidaps/skins/SkinLowRes.kt b/app/src/main/java/info/nightscout/androidaps/skins/SkinLowRes.kt index b6c76f66bd..529ff83e08 100644 --- a/app/src/main/java/info/nightscout/androidaps/skins/SkinLowRes.kt +++ b/app/src/main/java/info/nightscout/androidaps/skins/SkinLowRes.kt @@ -19,5 +19,9 @@ class SkinLowRes @Inject constructor(private val config: Config): SkinInterface isSmallHeight || isLandscape -> R.layout.overview_fragment_landscape else -> R.layout.overview_fragment } - + override fun actionsLayout(isLandscape : Boolean, isSmallWidth : Boolean): Int = + when { + isLandscape || !isSmallWidth -> R.layout.actions_fragment + else -> R.layout.actions_fragment_lowres + } } \ No newline at end of file diff --git a/app/src/main/res/layout/actions_fragment_lowres.xml b/app/src/main/res/layout/actions_fragment_lowres.xml new file mode 100644 index 0000000000..dc7a4fc204 --- /dev/null +++ b/app/src/main/res/layout/actions_fragment_lowres.xml @@ -0,0 +1,304 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/app/src/main/res/layout/careportal_fragment.xml b/app/src/main/res/layout/careportal_fragment.xml index ec0bd04bc7..f926492f62 100644 --- a/app/src/main/res/layout/careportal_fragment.xml +++ b/app/src/main/res/layout/careportal_fragment.xml @@ -4,7 +4,7 @@ android:layout_width="fill_parent" android:layout_height="wrap_content" android:paddingTop="5dp" - tools:context=".plugins.general.careportal.CareportalFragment"> + tools:context=".plugins.general.actions.ActionsFragment"> + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +