AndroidAPS/app/src/main/java/info/nightscout/androidaps/skins/SkinInterface.kt

81 lines
3.9 KiB
Kotlin
Raw Normal View History

2020-05-03 15:04:08 +02:00
package info.nightscout.androidaps.skins
import android.util.DisplayMetrics
2020-11-23 13:24:38 +01:00
import android.util.TypedValue.COMPLEX_UNIT_PX
import android.view.View
import android.widget.LinearLayout
2020-11-23 13:24:38 +01:00
import android.widget.TextView
2020-05-03 15:04:08 +02:00
import androidx.annotation.LayoutRes
import androidx.annotation.StringRes
import androidx.constraintlayout.widget.ConstraintLayout
import info.nightscout.androidaps.R
2020-11-23 13:24:38 +01:00
import kotlinx.android.synthetic.main.overview_fragment_nsclient.view.*
import kotlinx.android.synthetic.main.overview_info_layout.view.*
import kotlinx.android.synthetic.main.overview_statuslights_layout.view.*
2020-05-03 15:04:08 +02:00
interface SkinInterface {
2020-11-23 13:24:38 +01:00
@get:StringRes val description: Int
2020-11-23 13:24:38 +01:00
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
fun preProcessLandscapeOverviewLayout(dm: DisplayMetrics, view: View, isTablet: Boolean) {
// pre-process landscape mode
val screenWidth = dm.widthPixels
val screenHeight = dm.heightPixels
val landscape = screenHeight < screenWidth
if (landscape) {
2020-11-23 13:24:38 +01:00
val iobLayoutParams = view.overview_iob_llayout.layoutParams as ConstraintLayout.LayoutParams
iobLayoutParams.startToStart = ConstraintLayout.LayoutParams.UNSET
2020-11-23 13:24:38 +01:00
iobLayoutParams.startToEnd = view.overview_time_llayout.id
iobLayoutParams.topToBottom = ConstraintLayout.LayoutParams.UNSET
iobLayoutParams.topToTop = ConstraintLayout.LayoutParams.PARENT_ID
2020-11-23 13:24:38 +01:00
val timeLayoutParams = view.overview_time_llayout.layoutParams as ConstraintLayout.LayoutParams
timeLayoutParams.endToEnd = ConstraintLayout.LayoutParams.UNSET
2020-11-23 13:24:38 +01:00
timeLayoutParams.endToStart = view.overview_iob_llayout.id
2020-11-26 17:02:50 +01:00
val cobLayoutParams = view.overview_cob_llayout.layoutParams as ConstraintLayout.LayoutParams
cobLayoutParams.topToTop = ConstraintLayout.LayoutParams.PARENT_ID
val basalLayoutParams = view.overview_basal_llayout.layoutParams as ConstraintLayout.LayoutParams
basalLayoutParams.topToTop = ConstraintLayout.LayoutParams.PARENT_ID
val extendedLayoutParams = view.overview_extended_llayout.layoutParams as ConstraintLayout.LayoutParams
extendedLayoutParams.topToTop = ConstraintLayout.LayoutParams.PARENT_ID
val asLayoutParams = view.overview_as_llayout.layoutParams as ConstraintLayout.LayoutParams
asLayoutParams.topToTop = ConstraintLayout.LayoutParams.PARENT_ID
2020-11-23 13:24:38 +01:00
if (isTablet) {
for (v in listOf<TextView>(
view.overview_bg,
view.overview_time,
view.overview_timeagoshort,
view.overview_iob,
view.overview_cob,
view.overview_basebasal,
view.overview_extendedbolus,
view.overview_sensitivity
)) v.setTextSize(COMPLEX_UNIT_PX, v.textSize * 1.5f)
for (v in listOf<TextView>(
view.overview_pump,
view.overview_openaps,
view.overview_uploader,
view.careportal_canulaage,
view.careportal_insulinage,
view.careportal_reservoirlevel,
view.careportal_reservoirlevel,
view.careportal_sensorage,
view.careportal_pbage,
view.careportal_batterylevel
)) v.setTextSize(COMPLEX_UNIT_PX, v.textSize * 1.3f)
view.overview_time_llayout.orientation = LinearLayout.HORIZONTAL
view.overview_timeagoshort.setTextSize(COMPLEX_UNIT_PX, view.overview_time.textSize)
}
}
}
2020-05-03 15:04:08 +02:00
}