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-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 actionsLayout(isLandscape: Boolean, isSmallWidth: Boolean): Int = R.layout.actions_fragment
|
|
|
|
|
2021-01-26 15:44:56 +01:00
|
|
|
fun preProcessLandscapeOverviewLayout(dm: DisplayMetrics, view: View, isLandscape: Boolean, isTablet: Boolean, isSmallHeight: 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) {
|
2021-02-04 12:03:34 +01:00
|
|
|
val iobLayout = view.findViewById<LinearLayout>(R.id.iob_layout)
|
2021-01-23 22:42:13 +01:00
|
|
|
val iobLayoutParams = iobLayout.layoutParams as ConstraintLayout.LayoutParams
|
2021-02-04 12:03:34 +01:00
|
|
|
val timeLayout = view.findViewById<LinearLayout>(R.id.time_layout)
|
2020-11-22 20:48:36 +01:00
|
|
|
iobLayoutParams.startToStart = ConstraintLayout.LayoutParams.UNSET
|
2021-01-23 22:42:13 +01:00
|
|
|
iobLayoutParams.startToEnd = timeLayout.id
|
2020-11-22 20:48:36 +01:00
|
|
|
iobLayoutParams.topToBottom = ConstraintLayout.LayoutParams.UNSET
|
|
|
|
iobLayoutParams.topToTop = ConstraintLayout.LayoutParams.PARENT_ID
|
2021-01-23 22:42:13 +01:00
|
|
|
val timeLayoutParams = timeLayout.layoutParams as ConstraintLayout.LayoutParams
|
2020-11-22 20:48:36 +01:00
|
|
|
timeLayoutParams.endToEnd = ConstraintLayout.LayoutParams.UNSET
|
2021-01-23 22:42:13 +01:00
|
|
|
timeLayoutParams.endToStart = iobLayout.id
|
2021-02-04 12:03:34 +01:00
|
|
|
val cobLayoutParams = view.findViewById<LinearLayout>(R.id.cob_layout).layoutParams as ConstraintLayout.LayoutParams
|
2020-11-26 17:02:50 +01:00
|
|
|
cobLayoutParams.topToTop = ConstraintLayout.LayoutParams.PARENT_ID
|
2021-02-04 12:03:34 +01:00
|
|
|
val basalLayoutParams = view.findViewById<LinearLayout>(R.id.basal_layout).layoutParams as ConstraintLayout.LayoutParams
|
2020-11-26 17:02:50 +01:00
|
|
|
basalLayoutParams.topToTop = ConstraintLayout.LayoutParams.PARENT_ID
|
2021-02-04 12:03:34 +01:00
|
|
|
val extendedLayoutParams = view.findViewById<LinearLayout>(R.id.extended_layout).layoutParams as ConstraintLayout.LayoutParams
|
2020-11-26 17:02:50 +01:00
|
|
|
extendedLayoutParams.topToTop = ConstraintLayout.LayoutParams.PARENT_ID
|
2021-02-04 12:03:34 +01:00
|
|
|
val asLayoutParams = view.findViewById<LinearLayout>(R.id.as_layout).layoutParams as ConstraintLayout.LayoutParams
|
2020-11-26 17:02:50 +01:00
|
|
|
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?>(
|
2021-02-04 12:03:34 +01:00
|
|
|
view.findViewById(R.id.bg),
|
|
|
|
view.findViewById(R.id.time),
|
|
|
|
view.findViewById(R.id.time_ago_short),
|
|
|
|
view.findViewById(R.id.iob),
|
|
|
|
view.findViewById(R.id.cob),
|
|
|
|
view.findViewById(R.id.base_basal),
|
|
|
|
view.findViewById(R.id.extended_bolus),
|
|
|
|
view.findViewById(R.id.sensitivity)
|
2020-12-07 22:42:04 +01:00
|
|
|
)) v?.setTextSize(COMPLEX_UNIT_PX, v.textSize * 1.5f)
|
|
|
|
for (v in listOf<TextView?>(
|
2021-02-04 12:03:34 +01:00
|
|
|
view.findViewById(R.id.pump),
|
|
|
|
view.findViewById(R.id.openaps),
|
|
|
|
view.findViewById(R.id.uploader),
|
|
|
|
view.findViewById(R.id.cannula_age),
|
|
|
|
view.findViewById(R.id.insulin_age),
|
|
|
|
view.findViewById(R.id.reservoir_level),
|
|
|
|
view.findViewById(R.id.sensor_age),
|
|
|
|
view.findViewById(R.id.pb_age),
|
|
|
|
view.findViewById(R.id.battery_level)
|
2020-12-07 22:42:04 +01:00
|
|
|
)) v?.setTextSize(COMPLEX_UNIT_PX, v.textSize * 1.3f)
|
2021-01-23 22:42:13 +01:00
|
|
|
timeLayout?.orientation = LinearLayout.HORIZONTAL
|
2021-02-04 12:03:34 +01:00
|
|
|
view.findViewById<TextView>(R.id.time_ago_short)?.setTextSize(COMPLEX_UNIT_PX, view.findViewById<TextView>(R.id.time).textSize)
|
2020-12-07 22:42:04 +01:00
|
|
|
|
2021-02-04 12:03:34 +01:00
|
|
|
view.findViewById<TextView>(R.id.delta_large)?.visibility = View.VISIBLE
|
2020-12-07 22:42:04 +01:00
|
|
|
} else {
|
2021-02-04 12:03:34 +01:00
|
|
|
view.findViewById<TextView>(R.id.delta_large)?.visibility = View.GONE
|
2020-11-23 13:24:38 +01:00
|
|
|
}
|
2020-11-22 20:48:36 +01:00
|
|
|
}
|
|
|
|
}
|
2021-01-26 15:44:56 +01:00
|
|
|
|
|
|
|
fun moveButtonsLayout(root: LinearLayout) {
|
|
|
|
val buttonsLayout = root.findViewById<LinearLayout>(R.id.buttons_layout)
|
|
|
|
root.removeView(buttonsLayout)
|
|
|
|
val innerLayout = root.findViewById<LinearLayout>(R.id.inner_layout)
|
|
|
|
innerLayout.addView(buttonsLayout)
|
|
|
|
}
|
2020-05-03 15:04:08 +02:00
|
|
|
}
|