Eopatch2: toolbar, icons
This commit is contained in:
parent
502ed6c40a
commit
8d0bba379a
|
@ -4,7 +4,8 @@
|
||||||
<application>
|
<application>
|
||||||
<activity
|
<activity
|
||||||
android:name=".ui.EopatchActivity"
|
android:name=".ui.EopatchActivity"
|
||||||
android:configChanges="orientation|layoutDirection|screenLayout|density|screenSize|smallestScreenSize"/>
|
android:configChanges="orientation|layoutDirection|screenLayout|density|screenSize|smallestScreenSize"
|
||||||
|
android:theme="@style/AppTheme" />
|
||||||
<activity
|
<activity
|
||||||
android:name=".ui.AlarmHelperActivity"
|
android:name=".ui.AlarmHelperActivity"
|
||||||
android:configChanges="orientation|layoutDirection|screenLayout|density|screenSize|smallestScreenSize"/>
|
android:configChanges="orientation|layoutDirection|screenLayout|density|screenSize|smallestScreenSize"/>
|
||||||
|
|
|
@ -8,7 +8,6 @@ import androidx.databinding.DataBindingUtil
|
||||||
import androidx.databinding.ViewDataBinding
|
import androidx.databinding.ViewDataBinding
|
||||||
import androidx.lifecycle.ViewModelProvider
|
import androidx.lifecycle.ViewModelProvider
|
||||||
import info.nightscout.androidaps.plugins.pump.eopatch.dagger.EopatchPluginQualifier
|
import info.nightscout.androidaps.plugins.pump.eopatch.dagger.EopatchPluginQualifier
|
||||||
import info.nightscout.core.ui.R
|
|
||||||
import info.nightscout.core.ui.activities.TranslatedDaggerAppCompatActivity
|
import info.nightscout.core.ui.activities.TranslatedDaggerAppCompatActivity
|
||||||
import info.nightscout.rx.AapsSchedulers
|
import info.nightscout.rx.AapsSchedulers
|
||||||
import io.reactivex.rxjava3.disposables.CompositeDisposable
|
import io.reactivex.rxjava3.disposables.CompositeDisposable
|
||||||
|
@ -16,10 +15,8 @@ import javax.inject.Inject
|
||||||
|
|
||||||
abstract class EoBaseActivity<B : ViewDataBinding> : TranslatedDaggerAppCompatActivity(), EoBaseNavigator {
|
abstract class EoBaseActivity<B : ViewDataBinding> : TranslatedDaggerAppCompatActivity(), EoBaseNavigator {
|
||||||
|
|
||||||
@Inject
|
|
||||||
@EopatchPluginQualifier
|
@EopatchPluginQualifier
|
||||||
lateinit var viewModelFactory: ViewModelProvider.Factory
|
@Inject lateinit var viewModelFactory: ViewModelProvider.Factory
|
||||||
|
|
||||||
@Inject lateinit var aapsSchedulers: AapsSchedulers
|
@Inject lateinit var aapsSchedulers: AapsSchedulers
|
||||||
|
|
||||||
protected lateinit var binding: B
|
protected lateinit var binding: B
|
||||||
|
@ -28,16 +25,13 @@ abstract class EoBaseActivity<B : ViewDataBinding> : TranslatedDaggerAppCompatAc
|
||||||
|
|
||||||
protected lateinit var getResult: ActivityResultLauncher<Intent>
|
protected lateinit var getResult: ActivityResultLauncher<Intent>
|
||||||
|
|
||||||
@LayoutRes
|
@LayoutRes abstract fun getLayoutId(): Int
|
||||||
abstract fun getLayoutId(): Int
|
|
||||||
|
|
||||||
override fun onCreate(savedInstanceState: Bundle?) {
|
override fun onCreate(savedInstanceState: Bundle?) {
|
||||||
super.onCreate(savedInstanceState)
|
super.onCreate(savedInstanceState)
|
||||||
setTheme(R.style.AppTheme_NoActionBar)
|
|
||||||
|
|
||||||
binding = DataBindingUtil.setContentView(this, getLayoutId())
|
binding = DataBindingUtil.setContentView(this, getLayoutId())
|
||||||
binding.lifecycleOwner = this
|
binding.lifecycleOwner = this
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun back() {
|
override fun back() {
|
||||||
|
|
|
@ -5,9 +5,13 @@ import android.content.Context
|
||||||
import android.content.Intent
|
import android.content.Intent
|
||||||
import android.content.pm.ActivityInfo
|
import android.content.pm.ActivityInfo
|
||||||
import android.os.Bundle
|
import android.os.Bundle
|
||||||
|
import android.view.Menu
|
||||||
|
import android.view.MenuInflater
|
||||||
|
import android.view.MenuItem
|
||||||
import android.view.MotionEvent
|
import android.view.MotionEvent
|
||||||
import androidx.activity.OnBackPressedCallback
|
import androidx.activity.OnBackPressedCallback
|
||||||
import androidx.appcompat.app.AlertDialog
|
import androidx.appcompat.app.AlertDialog
|
||||||
|
import androidx.core.view.MenuProvider
|
||||||
import androidx.lifecycle.ViewModelProvider
|
import androidx.lifecycle.ViewModelProvider
|
||||||
import info.nightscout.androidaps.plugins.pump.eopatch.R
|
import info.nightscout.androidaps.plugins.pump.eopatch.R
|
||||||
import info.nightscout.androidaps.plugins.pump.eopatch.code.EventType
|
import info.nightscout.androidaps.plugins.pump.eopatch.code.EventType
|
||||||
|
@ -38,6 +42,10 @@ class EopatchActivity : EoBaseActivity<ActivityEopatchBinding>() {
|
||||||
super.onCreate(savedInstanceState)
|
super.onCreate(savedInstanceState)
|
||||||
requestedOrientation = ActivityInfo.SCREEN_ORIENTATION_LOCKED
|
requestedOrientation = ActivityInfo.SCREEN_ORIENTATION_LOCKED
|
||||||
|
|
||||||
|
title = getString(R.string.string_activate_patch)
|
||||||
|
supportActionBar?.setDisplayHomeAsUpEnabled(true)
|
||||||
|
supportActionBar?.setDisplayShowHomeEnabled(true)
|
||||||
|
|
||||||
binding.apply {
|
binding.apply {
|
||||||
viewModel = ViewModelProvider(this@EopatchActivity, viewModelFactory)[EopatchViewModel::class.java]
|
viewModel = ViewModelProvider(this@EopatchActivity, viewModelFactory)[EopatchViewModel::class.java]
|
||||||
viewModel?.apply {
|
viewModel?.apply {
|
||||||
|
@ -108,12 +116,27 @@ class EopatchActivity : EoBaseActivity<ActivityEopatchBinding>() {
|
||||||
override fun handleOnBackPressed() {
|
override fun handleOnBackPressed() {
|
||||||
binding.viewModel?.apply {
|
binding.viewModel?.apply {
|
||||||
when (patchStep.value) {
|
when (patchStep.value) {
|
||||||
|
PatchStep.WAKE_UP,
|
||||||
PatchStep.SAFE_DEACTIVATION -> this@EopatchActivity.finish()
|
PatchStep.SAFE_DEACTIVATION -> this@EopatchActivity.finish()
|
||||||
else -> Unit
|
else -> Unit
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
// Add menu items without overriding methods in the Activity
|
||||||
|
addMenuProvider(object : MenuProvider {
|
||||||
|
override fun onCreateMenu(menu: Menu, menuInflater: MenuInflater) {}
|
||||||
|
|
||||||
|
override fun onMenuItemSelected(menuItem: MenuItem): Boolean =
|
||||||
|
when (menuItem.itemId) {
|
||||||
|
android.R.id.home -> {
|
||||||
|
onBackPressedDispatcher.onBackPressed()
|
||||||
|
true
|
||||||
|
}
|
||||||
|
|
||||||
|
else -> false
|
||||||
|
}
|
||||||
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onNewIntent(intent: Intent?) {
|
override fun onNewIntent(intent: Intent?) {
|
||||||
|
|
|
@ -17,26 +17,6 @@
|
||||||
android:orientation="vertical"
|
android:orientation="vertical"
|
||||||
tools:context=".ui.EopatchActivity">
|
tools:context=".ui.EopatchActivity">
|
||||||
|
|
||||||
<androidx.constraintlayout.widget.ConstraintLayout
|
|
||||||
android:id="@+id/layout_toolbar"
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="60dp">
|
|
||||||
|
|
||||||
<TextView
|
|
||||||
android:layout_width="wrap_content"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:text="@{viewModel.title}"
|
|
||||||
|
|
||||||
android:textSize="18sp"
|
|
||||||
android:gravity="center_horizontal"
|
|
||||||
app:layout_constraintBottom_toBottomOf="parent"
|
|
||||||
app:layout_constraintStart_toStartOf="parent"
|
|
||||||
app:layout_constraintEnd_toEndOf="parent"
|
|
||||||
app:layout_constraintTop_toTopOf="parent"
|
|
||||||
tools:text="@string/string_change_patch" />
|
|
||||||
|
|
||||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
|
||||||
|
|
||||||
<FrameLayout
|
<FrameLayout
|
||||||
android:id="@+id/framelayout_fragment"
|
android:id="@+id/framelayout_fragment"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
|
|
|
@ -508,34 +508,40 @@
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_alignParentBottom="true"
|
android:layout_alignParentBottom="true"
|
||||||
android:orientation="horizontal">
|
android:orientation="horizontal">
|
||||||
<Button
|
<info.nightscout.core.ui.elements.SingleClickButton
|
||||||
android:id="@+id/button1"
|
android:id="@+id/button1"
|
||||||
style="@style/ButtonMediumFontStyle"
|
style="@style/ButtonSmallFontStyle"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="0dp"
|
||||||
android:layout_height="match_parent"
|
android:layout_height="wrap_content"
|
||||||
android:layout_weight="1"
|
android:layout_weight="1"
|
||||||
|
android:drawableTop="@drawable/ic_pod_activate_pod"
|
||||||
|
android:textAllCaps="false"
|
||||||
android:text="@string/string_activate_patch"
|
android:text="@string/string_activate_patch"
|
||||||
android:enabled="@{!viewmodel.patchConfig.activated}"
|
android:enabled="@{!viewmodel.patchConfig.activated}"
|
||||||
app:onSafeClick="@{() -> viewmodel.onClickActivation()}"/>
|
app:onSafeClick="@{() -> viewmodel.onClickActivation()}"/>
|
||||||
|
|
||||||
<Button
|
<info.nightscout.core.ui.elements.SingleClickButton
|
||||||
android:id="@+id/button2"
|
android:id="@+id/button2"
|
||||||
style="@style/ButtonMediumFontStyle"
|
style="@style/ButtonSmallFontStyle"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="0dp"
|
||||||
android:layout_height="match_parent"
|
android:layout_height="wrap_content"
|
||||||
android:layout_weight="1"
|
android:layout_weight="1"
|
||||||
|
android:drawableTop="@drawable/ic_pod_deactivate_pod"
|
||||||
android:text="@string/string_change_patch"
|
android:text="@string/string_change_patch"
|
||||||
|
android:textAllCaps="false"
|
||||||
android:enabled="@{viewmodel.patchConfig.activated}"
|
android:enabled="@{viewmodel.patchConfig.activated}"
|
||||||
app:onSafeClick="@{() -> viewmodel.onClickDeactivation()}"/>
|
app:onSafeClick="@{() -> viewmodel.onClickDeactivation()}"/>
|
||||||
|
|
||||||
<Button
|
<info.nightscout.core.ui.elements.SingleClickButton
|
||||||
android:id="@+id/button3"
|
android:id="@+id/button3"
|
||||||
style="@style/ButtonMediumFontStyle"
|
style="@style/ButtonSmallFontStyle"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="0dp"
|
||||||
android:layout_height="match_parent"
|
android:layout_height="wrap_content"
|
||||||
android:layout_weight="1"
|
android:layout_weight="1"
|
||||||
|
android:drawableTop="@drawable/ic_pod_resume_delivery"
|
||||||
android:enabled="@{viewmodel.alarms.occurred.size() == 0}"
|
android:enabled="@{viewmodel.alarms.occurred.size() == 0}"
|
||||||
app:text="@{viewmodel.pauseBtnStr}"
|
app:text="@{viewmodel.pauseBtnStr}"
|
||||||
|
android:textAllCaps="false"
|
||||||
app:visibleOrGone="@{viewmodel.patchConfig.activated}"
|
app:visibleOrGone="@{viewmodel.patchConfig.activated}"
|
||||||
app:onSafeClick="@{() -> viewmodel.onClickSuspendOrResume()}"/>
|
app:onSafeClick="@{() -> viewmodel.onClickSuspendOrResume()}"/>
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
|
|
|
@ -52,7 +52,7 @@
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent"
|
||||||
android:layout_weight="1"
|
android:layout_weight="1"
|
||||||
android:drawableTop="@drawable/ic_omnipod_overview_resume_delivery"
|
android:drawableTop="@drawable/ic_pod_resume_delivery"
|
||||||
android:drawablePadding="@dimen/omnipod_icon_button_drawable_padding"
|
android:drawablePadding="@dimen/omnipod_icon_button_drawable_padding"
|
||||||
android:text="@string/omnipod_common_overview_button_resume_delivery"
|
android:text="@string/omnipod_common_overview_button_resume_delivery"
|
||||||
android:visibility="gone" />
|
android:visibility="gone" />
|
||||||
|
|
|
@ -30,7 +30,7 @@
|
||||||
style="@style/ButtonSmallFontStyle"
|
style="@style/ButtonSmallFontStyle"
|
||||||
android:layout_width="0dp"
|
android:layout_width="0dp"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:drawableTop="@drawable/ic_pod_management_activate_pod"
|
android:drawableTop="@drawable/ic_pod_activate_pod"
|
||||||
android:text="@string/omnipod_common_pod_management_button_activate_pod"
|
android:text="@string/omnipod_common_pod_management_button_activate_pod"
|
||||||
android:textAllCaps="false"
|
android:textAllCaps="false"
|
||||||
android:visibility="visible"
|
android:visibility="visible"
|
||||||
|
@ -51,7 +51,7 @@
|
||||||
style="@style/ButtonSmallFontStyle"
|
style="@style/ButtonSmallFontStyle"
|
||||||
android:layout_width="0dp"
|
android:layout_width="0dp"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:drawableTop="@drawable/ic_pod_management_deactivate_pod"
|
android:drawableTop="@drawable/ic_pod_deactivate_pod"
|
||||||
android:text="@string/omnipod_common_pod_management_button_deactivate_pod"
|
android:text="@string/omnipod_common_pod_management_button_deactivate_pod"
|
||||||
android:textAllCaps="false"
|
android:textAllCaps="false"
|
||||||
android:visibility="visible"
|
android:visibility="visible"
|
||||||
|
|
|
@ -66,7 +66,7 @@
|
||||||
style="@style/ButtonSmallFontStyle"
|
style="@style/ButtonSmallFontStyle"
|
||||||
android:layout_width="0dp"
|
android:layout_width="0dp"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:drawableTop="@drawable/ic_pod_management_activate_pod"
|
android:drawableTop="@drawable/ic_pod_activate_pod"
|
||||||
android:text="@string/omnipod_common_pod_management_button_activate_pod"
|
android:text="@string/omnipod_common_pod_management_button_activate_pod"
|
||||||
android:textAllCaps="false"
|
android:textAllCaps="false"
|
||||||
android:visibility="visible"
|
android:visibility="visible"
|
||||||
|
@ -87,7 +87,7 @@
|
||||||
style="@style/ButtonSmallFontStyle"
|
style="@style/ButtonSmallFontStyle"
|
||||||
android:layout_width="0dp"
|
android:layout_width="0dp"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:drawableTop="@drawable/ic_pod_management_deactivate_pod"
|
android:drawableTop="@drawable/ic_pod_deactivate_pod"
|
||||||
android:text="@string/omnipod_common_pod_management_button_deactivate_pod"
|
android:text="@string/omnipod_common_pod_management_button_deactivate_pod"
|
||||||
android:textAllCaps="false"
|
android:textAllCaps="false"
|
||||||
android:visibility="visible"
|
android:visibility="visible"
|
||||||
|
|
Loading…
Reference in a new issue