2020-05-03 15:04:08 +02:00
|
|
|
package info.nightscout.androidaps.skins
|
|
|
|
|
2020-11-22 20:48:36 +01:00
|
|
|
import android.util.DisplayMetrics
|
2020-11-23 13:24:38 +01:00
|
|
|
import android.util.TypedValue.COMPLEX_UNIT_PX
|
|
|
|
import android.view.View
|
2020-11-22 20:48:36 +01:00
|
|
|
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
|
2020-11-22 20:48:36 +01:00
|
|
|
import androidx.constraintlayout.widget.ConstraintLayout
|
2020-10-26 22:55:22 +01:00
|
|
|
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-22 20:48:36 +01:00
|
|
|
|
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) {
|
2020-11-22 20:48:36 +01:00
|
|
|
// 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
|
2020-11-22 20:48:36 +01:00
|
|
|
iobLayoutParams.startToStart = ConstraintLayout.LayoutParams.UNSET
|
2020-11-23 13:24:38 +01:00
|
|
|
iobLayoutParams.startToEnd = view.overview_time_llayout.id
|
2020-11-22 20:48:36 +01:00
|
|
|
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
|
2020-11-22 20:48:36 +01:00
|
|
|
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) {
|
2020-12-07 22:42:04 +01:00
|
|
|
for (v in listOf<TextView?>(
|
2020-11-23 13:24:38 +01:00
|
|
|
view.overview_bg,
|
|
|
|
view.overview_time,
|
|
|
|
view.overview_timeagoshort,
|
|
|
|
view.overview_iob,
|
|
|
|
view.overview_cob,
|
|
|
|
view.overview_basebasal,
|
|
|
|
view.overview_extendedbolus,
|
|
|
|
view.overview_sensitivity
|
2020-12-07 22:42:04 +01:00
|
|
|
)) v?.setTextSize(COMPLEX_UNIT_PX, v.textSize * 1.5f)
|
|
|
|
for (v in listOf<TextView?>(
|
2020-11-23 13:24:38 +01:00
|
|
|
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
|
2020-12-07 22:42:04 +01:00
|
|
|
)) 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)
|
|
|
|
|
|
|
|
view.overview_delta_large?.visibility = View.VISIBLE
|
|
|
|
} else {
|
|
|
|
view.overview_delta_large?.visibility = View.GONE
|
2020-11-23 13:24:38 +01:00
|
|
|
}
|
2020-11-22 20:48:36 +01:00
|
|
|
}
|
|
|
|
}
|
2020-05-03 15:04:08 +02:00
|
|
|
}
|