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
|
|
|
|
import android.widget.LinearLayout
|
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 {
|
|
|
|
@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
|
2020-10-26 22:55:22 +01:00
|
|
|
@LayoutRes fun actionsLayout(isLandscape : Boolean, isSmallWidth : Boolean): Int = R.layout.actions_fragment
|
2020-11-22 20:48:36 +01:00
|
|
|
|
|
|
|
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
|
|
|
}
|