ComboV2PairingActivity: toolbar
This commit is contained in:
parent
eda7c1e552
commit
510e640673
3 changed files with 27 additions and 38 deletions
|
@ -8,6 +8,6 @@
|
||||||
<activity
|
<activity
|
||||||
android:name=".activities.ComboV2PairingActivity"
|
android:name=".activities.ComboV2PairingActivity"
|
||||||
android:exported="false"
|
android:exported="false"
|
||||||
android:theme="@style/AppTheme.NoActionBar" />
|
android:theme="@style/AppTheme" />
|
||||||
</application>
|
</application>
|
||||||
</manifest>
|
</manifest>
|
||||||
|
|
|
@ -7,12 +7,16 @@ import android.os.Build
|
||||||
import android.os.Bundle
|
import android.os.Bundle
|
||||||
import android.text.Editable
|
import android.text.Editable
|
||||||
import android.text.TextWatcher
|
import android.text.TextWatcher
|
||||||
|
import android.view.Menu
|
||||||
|
import android.view.MenuInflater
|
||||||
|
import android.view.MenuItem
|
||||||
import android.view.View
|
import android.view.View
|
||||||
import androidx.activity.ComponentActivity
|
import androidx.activity.ComponentActivity
|
||||||
import androidx.activity.OnBackPressedCallback
|
import androidx.activity.OnBackPressedCallback
|
||||||
import androidx.activity.result.ActivityResultLauncher
|
import androidx.activity.result.ActivityResultLauncher
|
||||||
import androidx.activity.result.contract.ActivityResultContracts
|
import androidx.activity.result.contract.ActivityResultContracts
|
||||||
import androidx.core.content.ContextCompat
|
import androidx.core.content.ContextCompat
|
||||||
|
import androidx.core.view.MenuProvider
|
||||||
import androidx.databinding.DataBindingUtil
|
import androidx.databinding.DataBindingUtil
|
||||||
import androidx.lifecycle.Lifecycle
|
import androidx.lifecycle.Lifecycle
|
||||||
import androidx.lifecycle.lifecycleScope
|
import androidx.lifecycle.lifecycleScope
|
||||||
|
@ -113,6 +117,10 @@ class ComboV2PairingActivity : TranslatedDaggerAppCompatActivity() {
|
||||||
val binding: Combov2PairingActivityBinding = DataBindingUtil.setContentView(
|
val binding: Combov2PairingActivityBinding = DataBindingUtil.setContentView(
|
||||||
this, R.layout.combov2_pairing_activity)
|
this, R.layout.combov2_pairing_activity)
|
||||||
|
|
||||||
|
title = rh.gs(R.string.combov2_pair_with_pump_title)
|
||||||
|
supportActionBar?.setDisplayHomeAsUpEnabled(true)
|
||||||
|
supportActionBar?.setDisplayShowHomeEnabled(true)
|
||||||
|
|
||||||
val thisActivity = this
|
val thisActivity = this
|
||||||
|
|
||||||
// Set the pairing sections to initially show the "not initialized" one
|
// Set the pairing sections to initially show the "not initialized" one
|
||||||
|
@ -194,6 +202,20 @@ class ComboV2PairingActivity : TranslatedDaggerAppCompatActivity() {
|
||||||
finish()
|
finish()
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
// 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 onDestroy() {
|
override fun onDestroy() {
|
||||||
|
@ -342,8 +364,8 @@ class ComboV2PairingActivity : TranslatedDaggerAppCompatActivity() {
|
||||||
return@setOnClickListener
|
return@setOnClickListener
|
||||||
}
|
}
|
||||||
runBlocking {
|
runBlocking {
|
||||||
val PIN = PairingPIN(pinString.map { it - '0' }.toIntArray())
|
val pin = PairingPIN(pinString.map { it - '0' }.toIntArray())
|
||||||
combov2Plugin.providePairingPIN(PIN)
|
combov2Plugin.providePairingPIN(pin)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -383,14 +405,14 @@ class ComboV2PairingActivity : TranslatedDaggerAppCompatActivity() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
binding.combov2CurrentPairingStepDesc.text = when (val progStage = stage) {
|
binding.combov2CurrentPairingStepDesc.text = when (stage) {
|
||||||
BasicProgressStage.ScanningForPumpStage ->
|
BasicProgressStage.ScanningForPumpStage ->
|
||||||
rh.gs(R.string.combov2_scanning_for_pump)
|
rh.gs(R.string.combov2_scanning_for_pump)
|
||||||
|
|
||||||
is BasicProgressStage.EstablishingBtConnection -> {
|
is BasicProgressStage.EstablishingBtConnection -> {
|
||||||
rh.gs(
|
rh.gs(
|
||||||
R.string.combov2_establishing_bt_connection,
|
R.string.combov2_establishing_bt_connection,
|
||||||
progStage.currentAttemptNr
|
stage.currentAttemptNr
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,5 @@
|
||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<layout xmlns:android="http://schemas.android.com/apk/res/android"
|
<layout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
|
||||||
xmlns:tools="http://schemas.android.com/tools">
|
xmlns:tools="http://schemas.android.com/tools">
|
||||||
|
|
||||||
<androidx.appcompat.widget.LinearLayoutCompat
|
<androidx.appcompat.widget.LinearLayoutCompat
|
||||||
|
@ -9,38 +8,6 @@
|
||||||
android:orientation="vertical"
|
android:orientation="vertical"
|
||||||
tools:context=".activities.ComboV2PairingActivity">
|
tools:context=".activities.ComboV2PairingActivity">
|
||||||
|
|
||||||
<androidx.appcompat.widget.LinearLayoutCompat
|
|
||||||
android:id="@+id/header"
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:layout_marginBottom="10dp"
|
|
||||||
android:background="?attr/activity_title_backgroundColor"
|
|
||||||
android:orientation="horizontal"
|
|
||||||
android:padding="5dp">
|
|
||||||
|
|
||||||
<ImageView
|
|
||||||
android:id="@+id/imageView"
|
|
||||||
android:layout_width="42dp"
|
|
||||||
android:layout_height="42dp"
|
|
||||||
android:importantForAccessibility="no"
|
|
||||||
android:scaleType="fitXY"
|
|
||||||
app:srcCompat="@drawable/ic_combo_128" />
|
|
||||||
|
|
||||||
<TextView
|
|
||||||
android:id="@+id/textView2"
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:layout_centerHorizontal="true"
|
|
||||||
android:layout_centerVertical="true"
|
|
||||||
android:layout_gravity="center"
|
|
||||||
android:layout_marginStart="10dp"
|
|
||||||
android:layout_marginEnd="10dp"
|
|
||||||
android:text="@string/combov2_pair_with_pump_title"
|
|
||||||
android:textAlignment="center"
|
|
||||||
android:textAppearance="?android:attr/textAppearanceLarge" />
|
|
||||||
|
|
||||||
</androidx.appcompat.widget.LinearLayoutCompat>
|
|
||||||
|
|
||||||
<ScrollView
|
<ScrollView
|
||||||
android:id="@+id/combov2_pairing_section_cannot_pair_driver_not_initialized"
|
android:id="@+id/combov2_pairing_section_cannot_pair_driver_not_initialized"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
|
|
Loading…
Reference in a new issue