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

35 lines
1.5 KiB
Kotlin
Raw Normal View History

2020-05-03 15:04:08 +02:00
package info.nightscout.androidaps.skins
import android.util.DisplayMetrics
import android.widget.LinearLayout
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-05-03 15:04:08 +02:00
interface SkinInterface {
@get:StringRes val description : Int
2020-05-31 12:02:42 +02:00
val mainGraphHeight : Int // in dp
val secondaryGraphHeight : Int // in dp
2020-05-03 15:04:08 +02:00
@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, iobLayout: LinearLayout, timeLayout: LinearLayout) {
// pre-process landscape mode
val screenWidth = dm.widthPixels
val screenHeight = dm.heightPixels
val landscape = screenHeight < screenWidth
if (landscape) {
val iobLayoutParams = iobLayout.layoutParams as ConstraintLayout.LayoutParams
iobLayoutParams.startToStart = ConstraintLayout.LayoutParams.UNSET
iobLayoutParams.startToEnd = timeLayout.id
iobLayoutParams.topToBottom = ConstraintLayout.LayoutParams.UNSET
iobLayoutParams.topToTop = ConstraintLayout.LayoutParams.PARENT_ID
val timeLayoutParams = timeLayout.layoutParams as ConstraintLayout.LayoutParams
timeLayoutParams.endToEnd = ConstraintLayout.LayoutParams.UNSET
timeLayoutParams.endToStart = iobLayout.id
}
}
2020-05-03 15:04:08 +02:00
}