Skip to content

Commit

Permalink
[Android] Update Subscribe UI update to clarify options (#24460)
Browse files Browse the repository at this point in the history
* [Android] Update Subscribe UI update to clarify options

* Make Dropbox Menu(Spinner) to clarify select options ('Keep Subscription' and 'is Fabric Filter')

* [Android] Handle Crash when interval is empty and modify variable name
* Handle Crash when interval
* modify variable name
  • Loading branch information
jeonghwan7 authored Feb 13, 2023
1 parent 181aa79 commit a6701d9
Show file tree
Hide file tree
Showing 4 changed files with 54 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,12 @@ import android.view.View
import android.view.ViewGroup
import android.widget.Button
import android.widget.EditText
import android.widget.Spinner
import androidx.fragment.app.Fragment
import androidx.lifecycle.lifecycleScope
import chip.devicecontroller.ChipDeviceController
import chip.devicecontroller.ChipIdLookup
import chip.devicecontroller.ReportCallback
import chip.devicecontroller.ReportEventCallback
import chip.devicecontroller.ResubscriptionAttemptCallback
import chip.devicecontroller.SubscriptionEstablishedCallback
import chip.devicecontroller.model.ChipAttributePath
Expand Down Expand Up @@ -186,7 +186,7 @@ class WildcardFragment : Fragment() {
setView(dialogView)
}.create()

val isFabricFilteredEd = dialogView.findViewById<EditText>(R.id.isFabricFilteredEd)
val isFabricFilteredEd = dialogView.findViewById<EditText>(R.id.isFabricFilteredSp)
dialogView.findViewById<Button>(R.id.readBtn).setOnClickListener {
scope.launch {
read(type, isFabricFilteredEd.text.toString().toBoolean())
Expand All @@ -204,11 +204,21 @@ class WildcardFragment : Fragment() {

val minIntervalEd = dialogView.findViewById<EditText>(R.id.minIntervalEd)
val maxIntervalEd = dialogView.findViewById<EditText>(R.id.maxIntervalEd)
val keepSubscriptionsEd = dialogView.findViewById<EditText>(R.id.keepSubscriptionsEd)
val isFabricFilteredEd = dialogView.findViewById<EditText>(R.id.isFabricFilteredEd)
val keepSubscriptionsSp = dialogView.findViewById<Spinner>(R.id.keepSubscriptionsSp)
val isFabricFilteredSp = dialogView.findViewById<Spinner>(R.id.isFabricFilteredSp)
dialogView.findViewById<Button>(R.id.subscribeBtn).setOnClickListener {
scope.launch {
subscribe(type, minIntervalEd.text.toString().toInt(), maxIntervalEd.text.toString().toInt(), keepSubscriptionsEd.text.toString().toBoolean(), isFabricFilteredEd.text.toString().toBoolean())
if(minIntervalEd.text.isNotBlank() && maxIntervalEd.text.isNotBlank()) {
subscribe(
type,
minIntervalEd.text.toString().toInt(),
maxIntervalEd.text.toString().toInt(),
keepSubscriptionsSp.selectedItem.toString().toBoolean(),
isFabricFilteredSp.selectedItem.toString().toBoolean()
)
} else {
Log.e(TAG, "minInterval or maxInterval is empty!" )
}
requireActivity().runOnUiThread { dialog.dismiss() }
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,15 @@
app:layout_constraintTop_toTopOf="parent" />

<EditText
android:id="@+id/isFabricFilteredEd"
android:id="@+id/isFabricFilteredSp"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:hint="@string/read_dialog_is_fabric_filtered_hint"
android:inputType="text"
android:textSize="16sp"
android:layout_marginBottom="8dp"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/isFabricFilteredEd"
app:layout_constraintTop_toBottomOf="@id/isFabricFilteredSp"
app:layout_constraintBottom_toTopOf="@+id/subscribeBtn"/>

<Button
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,28 +34,52 @@
android:layout_marginBottom="8dp"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/minIntervalEd" />

<EditText
android:id="@+id/keepSubscriptionsEd"
<TextView
android:id="@+id/titleKeepSubscriptions"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@string/subscribe_dialog_keep_subscriptions_hint"
android:textSize="16sp"
android:layout_marginTop="8dp"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/maxIntervalEd"
/>
<Spinner
android:id="@+id/keepSubscriptionsSp"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:hint="@string/subscribe_dialog_keep_subscriptions_hint"
android:entries="@array/chip_select_menu"
android:inputType="text"
android:spinnerMode="dropdown"
android:textSize="16sp"
android:layout_marginBottom="8dp"
android:layout_marginTop="8dp"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/maxIntervalEd" />
app:layout_constraintTop_toBottomOf="@id/titleKeepSubscriptions" />

<EditText
android:id="@+id/isFabricFilteredEd"
<TextView
android:id="@+id/titleIsFabricFilter"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@string/subscribe_dialog_is_fabric_filtered_hint"
android:textSize="16sp"
android:layout_marginTop="8dp"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/keepSubscriptionsSp"
/>

<Spinner
android:id="@+id/isFabricFilteredSp"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:hint="@string/subscribe_dialog_is_fabric_filtered_hint"
android:inputType="text"
android:entries="@array/chip_select_menu"
android:spinnerMode="dropdown"
android:textSize="16sp"
android:layout_marginBottom="8dp"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/keepSubscriptionsEd"
app:layout_constraintTop_toBottomOf="@id/titleIsFabricFilter"
app:layout_constraintBottom_toTopOf="@+id/subscribeBtn"/>

<Button
Expand Down
6 changes: 5 additions & 1 deletion examples/android/CHIPTool/app/src/main/res/values/arrays.xml
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>

<string-array name="chip_select_menu">
<item>false</item>
<item>true</item>
</string-array>
</resources>

0 comments on commit a6701d9

Please sign in to comment.