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