Skip to content

Commit

Permalink
Improve label UI
Browse files Browse the repository at this point in the history
  • Loading branch information
karasevm committed Jun 27, 2024
1 parent baaffd3 commit 17f62ac
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,15 @@ class RecyclerAdapter(private val items: MutableList<String>, private val showDr
@SuppressLint("ClickableViewAccessibility")
override fun onBindViewHolder(holder: RecyclerAdapter.ViewHolder, position: Int) {
val item = items[position]
val parts = item.split(" : ")
if(parts.size == 2){
holder.labelTextView.text = parts[0]
holder.textView.text = parts[1]
} else{
holder.labelTextView.visibility = View.GONE
holder.textView.text = parts[0]
}

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

inner class ViewHolder(itemView: View) : RecyclerView.ViewHolder(itemView) {
val textView: TextView = itemView.findViewById(R.id.textView)
val labelTextView: TextView = itemView.findViewById(R.id.labelTextView)
val dragHandle: ImageView = itemView.findViewById(R.id.dragHandle)

init {
Expand Down
20 changes: 17 additions & 3 deletions app/src/main/res/layout/recyclerview_row.xml
Original file line number Diff line number Diff line change
Expand Up @@ -12,19 +12,33 @@
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginStart="32dp"
app:layout_constraintBottom_toBottomOf="parent"
android:textSize="18sp"
app:layout_constraintBottom_toTopOf="@id/labelTextView"
app:layout_constraintEnd_toStartOf="@+id/dragHandle"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />

<TextView
android:id="@+id/labelTextView"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginStart="32dp"
android:textSize="14sp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toStartOf="@+id/dragHandle"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/textView" />


<ImageView
android:id="@+id/dragHandle"
android:layout_width="32dp"
android:layout_height="32dp"
android:layout_marginEnd="32dp"
android:contentDescription="@string/a11y_drag_handle"
android:src="@drawable/ic_drag_handle_24"
android:visibility="gone"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintRight_toRightOf="parent"/>
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toTopOf="parent" />
</androidx.constraintlayout.widget.ConstraintLayout>
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 @@ -29,4 +29,5 @@
<string name="set_to_auto_toast">Private DNS set to auto</string>
<string name="set_to_provider_toast">Private DNS set to %1$s</string>
<string name="require_unlock_setting">Require unlocking the device to change server</string>
<string name="a11y_drag_handle">Drag handle</string>
</resources>

0 comments on commit 17f62ac

Please sign in to comment.