Merge pull request #632 from Bnyro/master

suggestions UI improvements
This commit is contained in:
Bnyro 2022-06-27 18:48:11 +02:00 committed by GitHub
commit d389f10dea
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 43 additions and 20 deletions

View File

@ -5,12 +5,12 @@ import android.view.LayoutInflater
import android.view.View import android.view.View
import android.view.ViewGroup import android.view.ViewGroup
import android.widget.EditText import android.widget.EditText
import android.widget.ImageView
import android.widget.TextView import android.widget.TextView
import androidx.recyclerview.widget.RecyclerView import androidx.recyclerview.widget.RecyclerView
import com.github.libretube.R import com.github.libretube.R
import com.github.libretube.fragments.SearchFragment import com.github.libretube.fragments.SearchFragment
import com.github.libretube.util.PreferenceHelper import com.github.libretube.util.PreferenceHelper
import com.google.android.material.imageview.ShapeableImageView
class SearchHistoryAdapter( class SearchHistoryAdapter(
private val context: Context, private val context: Context,
@ -34,7 +34,7 @@ class SearchHistoryAdapter(
val history = historyList[position] val history = historyList[position]
holder.v.findViewById<TextView>(R.id.history_text).text = history holder.v.findViewById<TextView>(R.id.history_text).text = history
holder.v.findViewById<ShapeableImageView>(R.id.delete_history).setOnClickListener { holder.v.findViewById<ImageView>(R.id.delete_history).setOnClickListener {
historyList = historyList - history historyList = historyList - history
PreferenceHelper.saveHistory(context, historyList) PreferenceHelper.saveHistory(context, historyList)
notifyDataSetChanged() notifyDataSetChanged()

View File

@ -0,0 +1,11 @@
<?xml version="1.0" encoding="utf-8"?>
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:tint="?android:attr/colorControlNormal"
android:viewportWidth="24"
android:viewportHeight="24">
<path
android:fillColor="#FF000000"
android:pathData="M19,17.59L17.59,19L7,8.41V15H5V5H15V7H8.41L19,17.59Z" />
</vector>

View File

@ -329,7 +329,7 @@
android:id="@+id/history_recycler" android:id="@+id/history_recycler"
android:layout_width="0dp" android:layout_width="0dp"
android:layout_height="0dp" android:layout_height="0dp"
android:layout_margin="10dp" android:layout_marginVertical="10dp"
app:layout_constraintBottom_toBottomOf="parent" app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent" app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent" app:layout_constraintStart_toStartOf="parent"

View File

@ -3,8 +3,8 @@
xmlns:app="http://schemas.android.com/apk/res-auto" xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_margin="8dp" android:paddingHorizontal="16dp"
android:layout_marginBottom="16dp" android:paddingVertical="8dp"
android:background="?android:attr/selectableItemBackground"> android:background="?android:attr/selectableItemBackground">
<ImageView <ImageView
@ -21,15 +21,13 @@
android:id="@+id/history_text" android:id="@+id/history_text"
android:layout_width="0dp" android:layout_width="0dp"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_marginStart="8dp" android:layout_marginHorizontal="8dp"
android:text=""
app:layout_constraintBottom_toBottomOf="parent" app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toStartOf="@id/delete_history" app:layout_constraintEnd_toStartOf="@id/delete_history"
app:layout_constraintStart_toEndOf="@id/history_icon" app:layout_constraintStart_toEndOf="@id/history_icon"
app:layout_constraintTop_toTopOf="parent" /> app:layout_constraintTop_toTopOf="parent" />
<ImageView
<com.google.android.material.imageview.ShapeableImageView
android:id="@+id/delete_history" android:id="@+id/delete_history"
android:layout_width="0dp" android:layout_width="0dp"
android:layout_height="wrap_content" android:layout_height="wrap_content"

View File

@ -1,25 +1,39 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" <androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_marginHorizontal="8dp" android:paddingHorizontal="16dp"
android:paddingVertical="8dp" android:paddingVertical="8dp"
android:background="?android:attr/selectableItemBackground"> android:background="?android:attr/selectableItemBackground">
<ImageView <ImageView
android:id="@+id/search_icon" android:id="@+id/search_icon"
android:layout_width="18dp" android:layout_width="0dp"
android:layout_height="18dp" android:layout_height="wrap_content"
android:src="@drawable/ic_search" android:src="@drawable/ic_search"
android:layout_marginTop="3dp" app:layout_constraintStart_toStartOf="parent"
android:layout_marginHorizontal="5dp" /> app:layout_constraintTop_toTopOf="parent"
app:layout_constraintBottom_toBottomOf="parent"
android:layout_margin="5dp" />
<TextView <TextView
android:id="@+id/suggestion_text" android:id="@+id/suggestion_text"
android:layout_width="match_parent" android:layout_width="0dp"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_marginStart="8dp" android:layout_marginHorizontal="8dp"
android:layout_marginEnd="8dp" app:layout_constraintBottom_toBottomOf="parent"
android:layout_gravity="center" /> app:layout_constraintEnd_toStartOf="@id/arrow"
app:layout_constraintStart_toEndOf="@id/search_icon"
app:layout_constraintTop_toTopOf="parent" />
</LinearLayout> <ImageView
android:id="@+id/arrow"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:padding="5dp"
android:src="@drawable/ic_arrow_up_left"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:shapeAppearanceOverlay="@style/roundedImageViewRounded" />
</androidx.constraintlayout.widget.ConstraintLayout>