DiaconnG8HistoryActivity spinner replacement
This commit is contained in:
parent
f3cb252be8
commit
578d4ca674
3 changed files with 34 additions and 37 deletions
|
@ -4,23 +4,29 @@
|
|||
|
||||
<uses-permission android:name="android.permission.BLUETOOTH" />
|
||||
<uses-permission android:name="android.permission.BLUETOOTH_ADMIN" />
|
||||
|
||||
<uses-permission android:name="android.permission.BLUETOOTH_CONNECT" />
|
||||
|
||||
<uses-permission android:name="android.permission.BLUETOOTH_SCAN" />
|
||||
|
||||
<application>
|
||||
<activity android:name="info.nightscout.androidaps.diaconn.activities.DiaconnG8HistoryActivity" />
|
||||
<activity android:name="info.nightscout.androidaps.diaconn.activities.DiaconnG8UserOptionsActivity" />
|
||||
<activity android:name="info.nightscout.androidaps.diaconn.activities.DiaconnG8BLEScanActivity">
|
||||
<activity
|
||||
android:name="info.nightscout.androidaps.diaconn.activities.DiaconnG8HistoryActivity"
|
||||
android:theme="@style/AppTheme" />
|
||||
<activity
|
||||
android:name="info.nightscout.androidaps.diaconn.activities.DiaconnG8UserOptionsActivity"
|
||||
android:theme="@style/AppTheme" />
|
||||
<activity
|
||||
android:name="info.nightscout.androidaps.diaconn.activities.DiaconnG8BLEScanActivity"
|
||||
android:theme="@style/AppTheme">
|
||||
<intent-filter>
|
||||
<action android:name="info.nightscout.androidaps.plugins.PumpDiaconnG8.activities.DiaconnG8BLEScanActivity" />
|
||||
<category android:name="android.intent.category.DEFAULT" />
|
||||
</intent-filter>
|
||||
</activity>
|
||||
<service android:name="info.nightscout.androidaps.diaconn.service.DiaconnG8Service"
|
||||
|
||||
<service
|
||||
android:name="info.nightscout.androidaps.diaconn.service.DiaconnG8Service"
|
||||
android:enabled="true"
|
||||
android:exported="false"/>
|
||||
android:exported="false" />
|
||||
</application>
|
||||
|
||||
</manifest>
|
|
@ -87,11 +87,10 @@ class DiaconnG8HistoryActivity : NoSplashAppCompatActivity() {
|
|||
typeList.add(TypeList(RecordTypes.RECORD_TYPE_DAILY, rh.gs(R.string.diaconn_g8_history_dailyinsulin)))
|
||||
typeList.add(TypeList(RecordTypes.RECORD_TYPE_REFILL, rh.gs(R.string.diaconn_g8_history_refill)))
|
||||
typeList.add(TypeList(RecordTypes.RECORD_TYPE_SUSPEND, rh.gs(R.string.diaconn_g8_history_suspend)))
|
||||
binding.spinner.adapter = ArrayAdapter(this, R.layout.spinner_centered, typeList)
|
||||
binding.typeList.setAdapter(ArrayAdapter(this, R.layout.spinner_centered, typeList))
|
||||
|
||||
binding.reload.setOnClickListener {
|
||||
val selected = binding.spinner.selectedItem as TypeList?
|
||||
?: return@setOnClickListener
|
||||
val selected = typeList.firstOrNull { it.name == binding.typeList.text.toString() } ?: return@setOnClickListener
|
||||
runOnUiThread {
|
||||
binding.reload.visibility = View.GONE
|
||||
binding.status.visibility = View.VISIBLE
|
||||
|
@ -107,16 +106,10 @@ class DiaconnG8HistoryActivity : NoSplashAppCompatActivity() {
|
|||
}
|
||||
})
|
||||
}
|
||||
binding.spinner.onItemSelectedListener = object : AdapterView.OnItemSelectedListener {
|
||||
override fun onItemSelected(parent: AdapterView<*>?, view: View?, position: Int, id: Long) {
|
||||
val selected = typeList[position]
|
||||
swapAdapter(selected.type)
|
||||
showingType = selected.type
|
||||
}
|
||||
|
||||
override fun onNothingSelected(parent: AdapterView<*>?) {
|
||||
clearCardView()
|
||||
}
|
||||
binding.typeList.onItemClickListener = AdapterView.OnItemClickListener { _, _, position, _ ->
|
||||
val selected = typeList[position]
|
||||
showingType = selected.type
|
||||
swapAdapter(selected.type)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -44,34 +44,32 @@
|
|||
android:orientation="horizontal"
|
||||
android:padding="5dp" />
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/spinner_layout"
|
||||
<com.google.android.material.textfield.TextInputLayout
|
||||
style="@style/Widget.MaterialComponents.TextInputLayout.OutlinedBox.ExposedDropdownMenu"
|
||||
android:id="@+id/typeListLayout"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginStart="5dp"
|
||||
android:layout_marginEnd="5dp"
|
||||
android:hint="@string/eventtype"
|
||||
android:layout_below="@+id/spacer"
|
||||
android:orientation="horizontal">
|
||||
app:boxStrokeColor="@color/list_delimiter" >
|
||||
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
<androidx.appcompat.widget.AppCompatAutoCompleteTextView
|
||||
android:id="@+id/typeList"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginStart="15dp"
|
||||
android:layout_marginEnd="20dp"
|
||||
android:text="@string/eventtype"
|
||||
android:textAppearance="?android:attr/textAppearanceSmall" />
|
||||
android:clickable="true"
|
||||
android:enabled="false"
|
||||
tools:ignore="KeyboardInaccessibleWidget" />
|
||||
|
||||
<Spinner
|
||||
android:id="@+id/spinner"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginEnd="20dp" />
|
||||
|
||||
</LinearLayout>
|
||||
</com.google.android.material.textfield.TextInputLayout>
|
||||
|
||||
<TextView
|
||||
android:id="@+id/status"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_below="@id/spinner_layout"
|
||||
android:layout_below="@id/typeListLayout"
|
||||
android:layout_gravity="center_horizontal"
|
||||
android:gravity="center_horizontal" />
|
||||
|
||||
|
|
Loading…
Reference in a new issue