OverviewFragment simplify
This commit is contained in:
parent
a15522fd50
commit
f2e5ef76aa
|
@ -65,8 +65,7 @@ import io.reactivex.android.schedulers.AndroidSchedulers
|
||||||
import io.reactivex.disposables.CompositeDisposable
|
import io.reactivex.disposables.CompositeDisposable
|
||||||
import io.reactivex.schedulers.Schedulers
|
import io.reactivex.schedulers.Schedulers
|
||||||
import kotlinx.android.synthetic.main.overview_buttons_layout.*
|
import kotlinx.android.synthetic.main.overview_buttons_layout.*
|
||||||
import kotlinx.android.synthetic.main.overview_fragment.overview_notifications
|
import kotlinx.android.synthetic.main.overview_fragment.*
|
||||||
import kotlinx.android.synthetic.main.overview_fragment_nsclient.*
|
|
||||||
import kotlinx.android.synthetic.main.overview_graphs_layout.*
|
import kotlinx.android.synthetic.main.overview_graphs_layout.*
|
||||||
import kotlinx.android.synthetic.main.overview_info_layout.*
|
import kotlinx.android.synthetic.main.overview_info_layout.*
|
||||||
import kotlinx.android.synthetic.main.overview_loop_pumpstatus_layout.*
|
import kotlinx.android.synthetic.main.overview_loop_pumpstatus_layout.*
|
||||||
|
@ -138,20 +137,21 @@ class OverviewFragment : DaggerFragment(), View.OnClickListener, OnLongClickList
|
||||||
dm = DisplayMetrics()
|
dm = DisplayMetrics()
|
||||||
activity?.windowManager?.defaultDisplay?.getMetrics(dm)
|
activity?.windowManager?.defaultDisplay?.getMetrics(dm)
|
||||||
|
|
||||||
val screenWidth = dm.widthPixels
|
return inflater.inflate(R.layout.overview_fragment, container, false)
|
||||||
val screenHeight = dm.heightPixels
|
|
||||||
smallWidth = screenWidth <= Constants.SMALL_WIDTH
|
|
||||||
smallHeight = screenHeight <= Constants.SMALL_HEIGHT
|
|
||||||
val landscape = screenHeight < screenWidth
|
|
||||||
|
|
||||||
return inflater.inflate(skinProvider.activeSkin().overviewLayout(landscape, resourceHelper.gb(R.bool.isTablet), smallHeight), container, false)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
|
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
|
||||||
super.onViewCreated(view, savedInstanceState)
|
super.onViewCreated(view, savedInstanceState)
|
||||||
|
|
||||||
// pre-process landscape mode
|
// pre-process landscape mode
|
||||||
skinProvider.activeSkin().preProcessLandscapeOverviewLayout(dm, view, resourceHelper.gb(R.bool.isTablet))
|
val screenWidth = dm.widthPixels
|
||||||
|
val screenHeight = dm.heightPixels
|
||||||
|
smallWidth = screenWidth <= Constants.SMALL_WIDTH
|
||||||
|
smallHeight = screenHeight <= Constants.SMALL_HEIGHT
|
||||||
|
val landscape = screenHeight < screenWidth
|
||||||
|
|
||||||
|
skinProvider.activeSkin().preProcessLandscapeOverviewLayout(dm, view, landscape, resourceHelper.gb(R.bool.isTablet), smallHeight)
|
||||||
|
nsclient_layout?.visibility = config.NSCLIENT.toVisibility()
|
||||||
|
|
||||||
overview_pumpstatus?.setBackgroundColor(resourceHelper.gc(R.color.colorInitializingBorder))
|
overview_pumpstatus?.setBackgroundColor(resourceHelper.gc(R.color.colorInitializingBorder))
|
||||||
|
|
||||||
|
|
|
@ -11,11 +11,4 @@ class SkinButtonsOn @Inject constructor(private val config: Config) : SkinInterf
|
||||||
override val description: Int get() = R.string.buttonson_description
|
override val description: Int get() = R.string.buttonson_description
|
||||||
override val mainGraphHeight: Int get() = 200
|
override val mainGraphHeight: Int get() = 200
|
||||||
override val secondaryGraphHeight: Int get() = 100
|
override val secondaryGraphHeight: Int get() = 100
|
||||||
|
|
||||||
override fun overviewLayout(isLandscape: Boolean, isTablet: Boolean, isSmallHeight: Boolean): Int =
|
|
||||||
when {
|
|
||||||
config.NSCLIENT -> R.layout.overview_fragment_nsclient
|
|
||||||
else -> R.layout.overview_fragment
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
|
@ -1,5 +1,8 @@
|
||||||
package info.nightscout.androidaps.skins
|
package info.nightscout.androidaps.skins
|
||||||
|
|
||||||
|
import android.util.DisplayMetrics
|
||||||
|
import android.view.View
|
||||||
|
import android.widget.LinearLayout
|
||||||
import info.nightscout.androidaps.Config
|
import info.nightscout.androidaps.Config
|
||||||
import info.nightscout.androidaps.R
|
import info.nightscout.androidaps.R
|
||||||
import javax.inject.Inject
|
import javax.inject.Inject
|
||||||
|
@ -12,11 +15,8 @@ class SkinClassic @Inject constructor(private val config: Config): SkinInterface
|
||||||
override val mainGraphHeight: Int get() = 200
|
override val mainGraphHeight: Int get() = 200
|
||||||
override val secondaryGraphHeight: Int get() = 100
|
override val secondaryGraphHeight: Int get() = 100
|
||||||
|
|
||||||
override fun overviewLayout(isLandscape: Boolean, isTablet: Boolean, isSmallHeight: Boolean): Int =
|
override fun preProcessLandscapeOverviewLayout(dm: DisplayMetrics, view: View, isLandscape: Boolean, isTablet: Boolean, isSmallHeight: Boolean) {
|
||||||
when {
|
super.preProcessLandscapeOverviewLayout(dm, view, isLandscape, isTablet, isSmallHeight)
|
||||||
config.NSCLIENT -> R.layout.overview_fragment_nsclient
|
if (!config.NSCLIENT && (isSmallHeight || isLandscape)) moveButtonsLayout(view as LinearLayout)
|
||||||
isSmallHeight || isLandscape -> R.layout.overview_fragment_landscape
|
|
||||||
else -> R.layout.overview_fragment
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
|
@ -17,13 +17,10 @@ interface SkinInterface {
|
||||||
val mainGraphHeight: Int // in dp
|
val mainGraphHeight: Int // in dp
|
||||||
val secondaryGraphHeight: Int // in dp
|
val secondaryGraphHeight: Int // in dp
|
||||||
|
|
||||||
@LayoutRes
|
|
||||||
fun overviewLayout(isLandscape: Boolean, isTablet: Boolean, isSmallHeight: Boolean): Int
|
|
||||||
|
|
||||||
@LayoutRes
|
@LayoutRes
|
||||||
fun actionsLayout(isLandscape: Boolean, isSmallWidth: Boolean): Int = R.layout.actions_fragment
|
fun actionsLayout(isLandscape: Boolean, isSmallWidth: Boolean): Int = R.layout.actions_fragment
|
||||||
|
|
||||||
fun preProcessLandscapeOverviewLayout(dm: DisplayMetrics, view: View, isTablet: Boolean) {
|
fun preProcessLandscapeOverviewLayout(dm: DisplayMetrics, view: View, isLandscape: Boolean, isTablet: Boolean, isSmallHeight: Boolean) {
|
||||||
// pre-process landscape mode
|
// pre-process landscape mode
|
||||||
val screenWidth = dm.widthPixels
|
val screenWidth = dm.widthPixels
|
||||||
val screenHeight = dm.heightPixels
|
val screenHeight = dm.heightPixels
|
||||||
|
@ -81,4 +78,11 @@ interface SkinInterface {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
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)
|
||||||
|
}
|
||||||
}
|
}
|
|
@ -1,5 +1,8 @@
|
||||||
package info.nightscout.androidaps.skins
|
package info.nightscout.androidaps.skins
|
||||||
|
|
||||||
|
import android.util.DisplayMetrics
|
||||||
|
import android.view.View
|
||||||
|
import android.widget.LinearLayout
|
||||||
import info.nightscout.androidaps.Config
|
import info.nightscout.androidaps.Config
|
||||||
import info.nightscout.androidaps.R
|
import info.nightscout.androidaps.R
|
||||||
import javax.inject.Inject
|
import javax.inject.Inject
|
||||||
|
@ -12,11 +15,8 @@ class SkinLargeDisplay @Inject constructor(private val config: Config): SkinInte
|
||||||
override val mainGraphHeight: Int get() = 400
|
override val mainGraphHeight: Int get() = 400
|
||||||
override val secondaryGraphHeight: Int get() = 150
|
override val secondaryGraphHeight: Int get() = 150
|
||||||
|
|
||||||
override fun overviewLayout(isLandscape: Boolean, isTablet: Boolean, isSmallHeight: Boolean): Int =
|
override fun preProcessLandscapeOverviewLayout(dm: DisplayMetrics, view: View, isLandscape: Boolean, isTablet: Boolean, isSmallHeight: Boolean) {
|
||||||
when {
|
super.preProcessLandscapeOverviewLayout(dm, view, isLandscape, isTablet, isSmallHeight)
|
||||||
config.NSCLIENT -> R.layout.overview_fragment_nsclient
|
if (!config.NSCLIENT && (isSmallHeight || isLandscape)) moveButtonsLayout(view as LinearLayout)
|
||||||
isSmallHeight || isLandscape -> R.layout.overview_fragment_landscape
|
|
||||||
else -> R.layout.overview_fragment
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
|
@ -2,6 +2,7 @@ package info.nightscout.androidaps.skins
|
||||||
|
|
||||||
import android.util.DisplayMetrics
|
import android.util.DisplayMetrics
|
||||||
import android.view.View
|
import android.view.View
|
||||||
|
import android.widget.LinearLayout
|
||||||
import info.nightscout.androidaps.Config
|
import info.nightscout.androidaps.Config
|
||||||
import info.nightscout.androidaps.R
|
import info.nightscout.androidaps.R
|
||||||
import javax.inject.Inject
|
import javax.inject.Inject
|
||||||
|
@ -14,18 +15,13 @@ class SkinLowRes @Inject constructor(private val config: Config) : SkinInterface
|
||||||
override val mainGraphHeight: Int get() = 200
|
override val mainGraphHeight: Int get() = 200
|
||||||
override val secondaryGraphHeight: Int get() = 100
|
override val secondaryGraphHeight: Int get() = 100
|
||||||
|
|
||||||
override fun overviewLayout(isLandscape: Boolean, isTablet: Boolean, isSmallHeight: Boolean): Int =
|
|
||||||
when {
|
|
||||||
config.NSCLIENT -> R.layout.overview_fragment_nsclient
|
|
||||||
isLandscape -> R.layout.overview_fragment_landscape
|
|
||||||
else -> R.layout.overview_fragment
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun actionsLayout(isLandscape: Boolean, isSmallWidth: Boolean): Int =
|
override fun actionsLayout(isLandscape: Boolean, isSmallWidth: Boolean): Int =
|
||||||
when {
|
when {
|
||||||
isLandscape -> R.layout.actions_fragment
|
isLandscape -> R.layout.actions_fragment
|
||||||
else -> R.layout.actions_fragment_lowres
|
else -> R.layout.actions_fragment_lowres
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun preProcessLandscapeOverviewLayout(dm: DisplayMetrics, view: View, isTablet: Boolean) {}
|
override fun preProcessLandscapeOverviewLayout(dm: DisplayMetrics, view: View, isLandscape: Boolean, isTablet: Boolean, isSmallHeight: Boolean) {
|
||||||
|
if (!config.NSCLIENT && isLandscape) moveButtonsLayout(view as LinearLayout)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -8,11 +8,13 @@
|
||||||
|
|
||||||
<ScrollView
|
<ScrollView
|
||||||
android:id="@+id/overview_toppart_scrollbar"
|
android:id="@+id/overview_toppart_scrollbar"
|
||||||
android:layout_weight="1"
|
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="0dp">
|
android:layout_height="0dp"
|
||||||
|
android:layout_weight="1"
|
||||||
|
tools:ignore="UselessParent">
|
||||||
|
|
||||||
<LinearLayout
|
<LinearLayout
|
||||||
|
android:id="@+id/inner_layout"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:orientation="vertical">
|
android:orientation="vertical">
|
||||||
|
@ -28,12 +30,59 @@
|
||||||
|
|
||||||
<include layout="@layout/overview_statuslights_layout" />
|
<include layout="@layout/overview_statuslights_layout" />
|
||||||
|
|
||||||
|
<com.google.android.flexbox.FlexboxLayout xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||||
|
android:id="@+id/nsclient_layout"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:background="?attr/colorControlHighlight"
|
||||||
|
app:alignContent="stretch"
|
||||||
|
app:alignItems="stretch"
|
||||||
|
app:flexDirection="row"
|
||||||
|
app:flexWrap="wrap"
|
||||||
|
app:justifyContent="center">
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/overview_pump"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:paddingStart="4sp"
|
||||||
|
android:paddingEnd="4sp"
|
||||||
|
android:text="Pump: running"
|
||||||
|
android:textColor="@android:color/white"
|
||||||
|
android:textSize="16sp" />
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/overview_openaps"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_weight="1"
|
||||||
|
android:paddingStart="4sp"
|
||||||
|
android:paddingEnd="4sp"
|
||||||
|
android:text="OAPS: 3 min ago"
|
||||||
|
android:textColor="@android:color/white"
|
||||||
|
android:textSize="16sp" />
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/overview_uploader"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_weight="1"
|
||||||
|
android:paddingStart="4sp"
|
||||||
|
android:paddingEnd="4sp"
|
||||||
|
android:text="UPLD: 84%"
|
||||||
|
android:textColor="@android:color/white"
|
||||||
|
android:textSize="16sp" />
|
||||||
|
|
||||||
|
</com.google.android.flexbox.FlexboxLayout>
|
||||||
|
|
||||||
<include layout="@layout/overview_graphs_layout" />
|
<include layout="@layout/overview_graphs_layout" />
|
||||||
|
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
|
|
||||||
</ScrollView>
|
</ScrollView>
|
||||||
|
|
||||||
<include layout="@layout/overview_buttons_layout" />
|
<include
|
||||||
|
android:id="@+id/buttons_layout"
|
||||||
|
layout="@layout/overview_buttons_layout" />
|
||||||
|
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
|
|
|
@ -1,40 +0,0 @@
|
||||||
<?xml version="1.0" encoding="utf-8"?>
|
|
||||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
|
||||||
xmlns:tools="http://schemas.android.com/tools"
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="match_parent"
|
|
||||||
android:orientation="vertical"
|
|
||||||
tools:context=".plugins.general.overview.OverviewFragment">
|
|
||||||
|
|
||||||
<ScrollView
|
|
||||||
android:id="@+id/overview_toppart_scrollbar"
|
|
||||||
android:layout_width="wrap_content"
|
|
||||||
android:layout_height="0dp"
|
|
||||||
android:layout_weight="1"
|
|
||||||
tools:ignore="UselessParent">
|
|
||||||
|
|
||||||
<LinearLayout
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:orientation="vertical">
|
|
||||||
|
|
||||||
<androidx.recyclerview.widget.RecyclerView
|
|
||||||
android:id="@+id/overview_notifications"
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="wrap_content" />
|
|
||||||
|
|
||||||
<include layout="@layout/overview_loop_pumpstatus_layout" />
|
|
||||||
|
|
||||||
<include layout="@layout/overview_info_layout" />
|
|
||||||
|
|
||||||
<include layout="@layout/overview_statuslights_layout" />
|
|
||||||
|
|
||||||
<include layout="@layout/overview_graphs_layout" />
|
|
||||||
|
|
||||||
<include layout="@layout/overview_buttons_layout" />
|
|
||||||
|
|
||||||
</LinearLayout>
|
|
||||||
|
|
||||||
</ScrollView>
|
|
||||||
|
|
||||||
</LinearLayout>
|
|
|
@ -1,83 +0,0 @@
|
||||||
<?xml version="1.0" encoding="utf-8"?>
|
|
||||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
|
||||||
xmlns:tools="http://schemas.android.com/tools"
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="match_parent"
|
|
||||||
android:orientation="vertical"
|
|
||||||
tools:context=".plugins.general.overview.OverviewFragment">
|
|
||||||
|
|
||||||
<ScrollView
|
|
||||||
android:id="@+id/overview_toppart_scrollbar"
|
|
||||||
android:layout_width="wrap_content"
|
|
||||||
android:layout_height="0dp"
|
|
||||||
android:layout_weight="1">
|
|
||||||
|
|
||||||
<LinearLayout
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:orientation="vertical">
|
|
||||||
|
|
||||||
<androidx.recyclerview.widget.RecyclerView
|
|
||||||
android:id="@+id/overview_notifications"
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="wrap_content" />
|
|
||||||
|
|
||||||
<include layout="@layout/overview_loop_pumpstatus_layout" />
|
|
||||||
|
|
||||||
<include layout="@layout/overview_info_layout" />
|
|
||||||
|
|
||||||
<include layout="@layout/overview_statuslights_layout" />
|
|
||||||
|
|
||||||
<com.google.android.flexbox.FlexboxLayout xmlns:app="http://schemas.android.com/apk/res-auto"
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:background="?attr/colorControlHighlight"
|
|
||||||
app:alignContent="stretch"
|
|
||||||
app:alignItems="stretch"
|
|
||||||
app:flexDirection="row"
|
|
||||||
app:flexWrap="wrap"
|
|
||||||
app:justifyContent="center">
|
|
||||||
|
|
||||||
<TextView
|
|
||||||
android:id="@+id/overview_pump"
|
|
||||||
android:layout_width="wrap_content"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:paddingStart="4sp"
|
|
||||||
android:paddingEnd="4sp"
|
|
||||||
android:text="Pump: running"
|
|
||||||
android:textColor="@android:color/white"
|
|
||||||
android:textSize="16sp" />
|
|
||||||
|
|
||||||
<TextView
|
|
||||||
android:id="@+id/overview_openaps"
|
|
||||||
android:layout_width="wrap_content"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:layout_weight="1"
|
|
||||||
android:paddingStart="4sp"
|
|
||||||
android:paddingEnd="4sp"
|
|
||||||
android:text="OAPS: 3 min ago"
|
|
||||||
android:textColor="@android:color/white"
|
|
||||||
android:textSize="16sp" />
|
|
||||||
|
|
||||||
<TextView
|
|
||||||
android:id="@+id/overview_uploader"
|
|
||||||
android:layout_width="wrap_content"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:layout_weight="1"
|
|
||||||
android:paddingStart="4sp"
|
|
||||||
android:paddingEnd="4sp"
|
|
||||||
android:text="UPLD: 84%"
|
|
||||||
android:textColor="@android:color/white"
|
|
||||||
android:textSize="16sp" />
|
|
||||||
|
|
||||||
</com.google.android.flexbox.FlexboxLayout>
|
|
||||||
|
|
||||||
<include layout="@layout/overview_graphs_layout" />
|
|
||||||
|
|
||||||
</LinearLayout>
|
|
||||||
|
|
||||||
</ScrollView>
|
|
||||||
|
|
||||||
<include layout="@layout/overview_buttons_layout" />
|
|
||||||
|
|
||||||
</LinearLayout>
|
|
Loading…
Reference in a new issue