Skip to content

Commit 17f62ac

Browse files
committed
Improve label UI
1 parent baaffd3 commit 17f62ac

File tree

3 files changed

+27
-5
lines changed

3 files changed

+27
-5
lines changed

app/src/main/java/ru/karasevm/privatednstoggle/RecyclerAdapter.kt

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,9 +27,15 @@ class RecyclerAdapter(private val items: MutableList<String>, private val showDr
2727
@SuppressLint("ClickableViewAccessibility")
2828
override fun onBindViewHolder(holder: RecyclerAdapter.ViewHolder, position: Int) {
2929
val item = items[position]
30+
val parts = item.split(" : ")
31+
if(parts.size == 2){
32+
holder.labelTextView.text = parts[0]
33+
holder.textView.text = parts[1]
34+
} else{
35+
holder.labelTextView.visibility = View.GONE
36+
holder.textView.text = parts[0]
37+
}
3038

31-
// sets the text to the textview from our itemHolder class
32-
holder.textView.text = item
3339
if(showDragHandle) {
3440
holder.dragHandle.visibility = View.VISIBLE
3541
holder.dragHandle.setOnTouchListener {
@@ -56,6 +62,7 @@ class RecyclerAdapter(private val items: MutableList<String>, private val showDr
5662

5763
inner class ViewHolder(itemView: View) : RecyclerView.ViewHolder(itemView) {
5864
val textView: TextView = itemView.findViewById(R.id.textView)
65+
val labelTextView: TextView = itemView.findViewById(R.id.labelTextView)
5966
val dragHandle: ImageView = itemView.findViewById(R.id.dragHandle)
6067

6168
init {

app/src/main/res/layout/recyclerview_row.xml

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,19 +12,33 @@
1212
android:layout_width="0dp"
1313
android:layout_height="wrap_content"
1414
android:layout_marginStart="32dp"
15-
app:layout_constraintBottom_toBottomOf="parent"
15+
android:textSize="18sp"
16+
app:layout_constraintBottom_toTopOf="@id/labelTextView"
1617
app:layout_constraintEnd_toStartOf="@+id/dragHandle"
1718
app:layout_constraintStart_toStartOf="parent"
1819
app:layout_constraintTop_toTopOf="parent" />
1920

21+
<TextView
22+
android:id="@+id/labelTextView"
23+
android:layout_width="0dp"
24+
android:layout_height="wrap_content"
25+
android:layout_marginStart="32dp"
26+
android:textSize="14sp"
27+
app:layout_constraintBottom_toBottomOf="parent"
28+
app:layout_constraintEnd_toStartOf="@+id/dragHandle"
29+
app:layout_constraintStart_toStartOf="parent"
30+
app:layout_constraintTop_toBottomOf="@id/textView" />
31+
32+
2033
<ImageView
2134
android:id="@+id/dragHandle"
2235
android:layout_width="32dp"
2336
android:layout_height="32dp"
2437
android:layout_marginEnd="32dp"
38+
android:contentDescription="@string/a11y_drag_handle"
2539
android:src="@drawable/ic_drag_handle_24"
2640
android:visibility="gone"
27-
app:layout_constraintTop_toTopOf="parent"
2841
app:layout_constraintBottom_toBottomOf="parent"
29-
app:layout_constraintRight_toRightOf="parent"/>
42+
app:layout_constraintRight_toRightOf="parent"
43+
app:layout_constraintTop_toTopOf="parent" />
3044
</androidx.constraintlayout.widget.ConstraintLayout>

app/src/main/res/values/strings.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,4 +29,5 @@
2929
<string name="set_to_auto_toast">Private DNS set to auto</string>
3030
<string name="set_to_provider_toast">Private DNS set to %1$s</string>
3131
<string name="require_unlock_setting">Require unlocking the device to change server</string>
32+
<string name="a11y_drag_handle">Drag handle</string>
3233
</resources>

0 commit comments

Comments
 (0)