Skip to content

Commit

Permalink
feat: Add "Select All" button to PID list dialog
Browse files Browse the repository at this point in the history
  • Loading branch information
tzebrowski committed Sep 3, 2023
1 parent 67aaa21 commit 2d609d0
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 1 deletion.
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package org.obd.graphs.preferences.pid

import android.annotation.SuppressLint
import android.graphics.Color
import android.graphics.drawable.ColorDrawable
import android.os.Bundle
Expand Down Expand Up @@ -44,11 +45,12 @@ class PIDsListPreferenceDialog(private val key: String, private val priority: St
}
private lateinit var listOfItems: List<PidDefinitionDetails>

@SuppressLint("NotifyDataSetChanged")
override fun onCreateView(
inflater: LayoutInflater,
container: ViewGroup?,
savedInstanceState: Bundle?
): View? {
): View {

root = inflater.inflate(R.layout.dialog_pids, container, false)
val toolbar = root.findViewById<Toolbar>(R.id.custom_dialog_layout_toolbar)
Expand Down Expand Up @@ -91,6 +93,15 @@ class PIDsListPreferenceDialog(private val key: String, private val priority: St
}
}

root.findViewById<Button>(R.id.pid_list_select_all).apply {
setOnClickListener {
adapter.data.forEach {
it.checked = true
}
adapter.notifyDataSetChanged()
}
}

return root
}

Expand All @@ -103,6 +114,7 @@ class PIDsListPreferenceDialog(private val key: String, private val priority: St
Prefs.updateStringSet(key, pidList)
}

@SuppressLint("NotifyDataSetChanged")
private fun filterListOfItems(newText: String) {
val adapter = getAdapter()

Expand Down
10 changes: 10 additions & 0 deletions app/src/main/res/layout/dialog_pids.xml
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,16 @@
android:layout_alignParentBottom="true"
android:orientation="horizontal">

<Button
android:id="@+id/pid_list_select_all"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="6dp"
android:backgroundTint="@color/rainbow_indigo"
android:text="@string/dialog_select_all_action"
android:textSize="12sp"
style="?android:attr/buttonBarButtonStyle" />

<Button
android:id="@+id/pid_list_close_window"
android:layout_width="wrap_content"
Expand Down
1 change: 1 addition & 0 deletions app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -250,6 +250,7 @@
<string name="trip_vehicle_profile">Profile</string>
<string name="trip_action">Action</string>
<string name="trip_action_delete">Del</string>
<string name="dialog_select_all_action">Select all</string>
<string name="dialog_close_window_action">Close window</string>
<string name="trip_dialog_delete_all_trips">Delete all</string>
<string name="trip_delete_dialog_ask_question">Are you sure you want to Delete?</string>
Expand Down

0 comments on commit 2d609d0

Please sign in to comment.