Merge pull request #191 from archroid/master

Added search history
This commit is contained in:
Farbod 2022-05-12 11:29:01 +04:30 committed by GitHub
commit d322b8b7d4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
14 changed files with 498 additions and 306 deletions

View File

@ -11,15 +11,17 @@ import android.view.ViewGroup
import android.view.WindowManager import android.view.WindowManager
import android.view.inputmethod.EditorInfo import android.view.inputmethod.EditorInfo
import android.view.inputmethod.InputMethodManager import android.view.inputmethod.InputMethodManager
import android.widget.AdapterView
import android.widget.ArrayAdapter import android.widget.ArrayAdapter
import android.widget.AutoCompleteTextView import android.widget.AutoCompleteTextView
import android.widget.TextView.OnEditorActionListener import android.widget.TextView.*
import androidx.fragment.app.Fragment import androidx.fragment.app.Fragment
import androidx.lifecycle.lifecycleScope import androidx.lifecycle.lifecycleScope
import androidx.preference.PreferenceManager
import androidx.recyclerview.widget.GridLayoutManager import androidx.recyclerview.widget.GridLayoutManager
import androidx.recyclerview.widget.LinearLayoutManager
import androidx.recyclerview.widget.RecyclerView import androidx.recyclerview.widget.RecyclerView
import com.github.libretube.adapters.SearchAdapter import com.github.libretube.adapters.SearchAdapter
import com.github.libretube.adapters.SearchHistoryAdapter
import kotlinx.coroutines.GlobalScope import kotlinx.coroutines.GlobalScope
import kotlinx.coroutines.delay import kotlinx.coroutines.delay
import kotlinx.coroutines.launch import kotlinx.coroutines.launch
@ -48,36 +50,70 @@ class SearchFragment : Fragment() {
override fun onViewCreated(view: View, savedInstanceState: Bundle?) { override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
super.onViewCreated(view, savedInstanceState) super.onViewCreated(view, savedInstanceState)
val recyclerView = view.findViewById<RecyclerView>(R.id.search_recycler) val recyclerView = view.findViewById<RecyclerView>(R.id.search_recycler)
recyclerView.layoutManager = GridLayoutManager(view.context, 1)
val autoTextView = view.findViewById<AutoCompleteTextView>(R.id.autoCompleteTextView) val autoTextView = view.findViewById<AutoCompleteTextView>(R.id.autoCompleteTextView)
val historyRecycler = view.findViewById<RecyclerView>(R.id.history_recycler)
//show search history
recyclerView.visibility = GONE
historyRecycler.visibility = VISIBLE
historyRecycler.layoutManager = LinearLayoutManager(view.context)
var historylist = getHistory()
if (historylist.size != 0) {
historyRecycler.adapter =
SearchHistoryAdapter(requireContext(), historylist, autoTextView)
}
recyclerView.layoutManager = GridLayoutManager(view.context, 1)
autoTextView.requestFocus() autoTextView.requestFocus()
val imm = requireContext().getSystemService(Context.INPUT_METHOD_SERVICE) as InputMethodManager val imm =
requireContext().getSystemService(Context.INPUT_METHOD_SERVICE) as InputMethodManager
imm!!.showSoftInput(autoTextView, InputMethodManager.SHOW_IMPLICIT) imm!!.showSoftInput(autoTextView, InputMethodManager.SHOW_IMPLICIT)
autoTextView.addTextChangedListener(object : TextWatcher { autoTextView.addTextChangedListener(object : TextWatcher {
override fun beforeTextChanged( override fun beforeTextChanged(
s: CharSequence?, s: CharSequence?,
start: Int, start: Int,
count: Int, count: Int,
after: Int after: Int
) { ) {
}
override fun onTextChanged(s: CharSequence?, start: Int, before: Int, count: Int) {
if (s!! != "") {
recyclerView.visibility = VISIBLE
historyRecycler.visibility = GONE
recyclerView.adapter = null
GlobalScope.launch {
fetchSuggestions(s.toString(), autoTextView)
delay(3000)
addtohistory(s.toString())
fetchSearch(s.toString(), recyclerView)
}
} }
}
override fun onTextChanged(s: CharSequence?, start: Int, before: Int, count: Int) { override fun afterTextChanged(s: Editable?) {
if(s!! != ""){ if (s!!.isEmpty()) {
GlobalScope.launch { recyclerView.visibility = GONE
fetchSuggestions(s.toString(), autoTextView) historyRecycler.visibility = VISIBLE
delay(3000) var historylist = getHistory()
fetchSearch(s.toString(),recyclerView) if (historylist.size != 0) {
} historyRecycler.adapter =
SearchHistoryAdapter(requireContext(), historylist, autoTextView)
} }
} }
}
override fun afterTextChanged(s: Editable?) { })
}
})
autoTextView.setOnEditorActionListener(OnEditorActionListener { _, actionId, _ -> autoTextView.setOnEditorActionListener(OnEditorActionListener { _, actionId, _ ->
if (actionId == EditorInfo.IME_ACTION_SEARCH) { if (actionId == EditorInfo.IME_ACTION_SEARCH) {
hideKeyboard(); hideKeyboard();
@ -143,4 +179,43 @@ class SearchFragment : Fragment() {
super.onStop() super.onStop()
hideKeyboard() hideKeyboard()
} }
private fun addtohistory(query: String) {
val sharedPreferences = PreferenceManager.getDefaultSharedPreferences(requireContext())
var historyList = getHistory()
if (historyList.size != 0 && query == historyList.get(historyList.size - 1)) {
return
} else if (query == "") {
return
} else {
historyList = historyList + query
}
if (historyList.size > 10) {
historyList = historyList.takeLast(10)
}
var set: Set<String> = HashSet(historyList)
sharedPreferences.edit().putStringSet("search_history", set)
.apply()
}
private fun getHistory(): List<String> {
try {
val sharedPreferences = PreferenceManager.getDefaultSharedPreferences(requireContext())
val set: Set<String> = sharedPreferences.getStringSet("search_history", HashSet())!!
return set.toList()
} catch (e: Exception) {
return emptyList()
}
}
} }

View File

@ -9,11 +9,11 @@ import android.widget.ImageView
import android.widget.TextView import android.widget.TextView
import androidx.appcompat.app.AppCompatActivity import androidx.appcompat.app.AppCompatActivity
import androidx.recyclerview.widget.RecyclerView import androidx.recyclerview.widget.RecyclerView
import com.squareup.picasso.Picasso
import com.github.libretube.PlayerFragment import com.github.libretube.PlayerFragment
import com.github.libretube.R import com.github.libretube.R
import com.github.libretube.obj.StreamItem
import com.github.libretube.formatShort import com.github.libretube.formatShort
import com.github.libretube.obj.StreamItem
import com.squareup.picasso.Picasso
class ChannelAdapter(private val videoFeed: MutableList<StreamItem>): RecyclerView.Adapter<ChannelViewHolder>() { class ChannelAdapter(private val videoFeed: MutableList<StreamItem>): RecyclerView.Adapter<ChannelViewHolder>() {
override fun getItemCount(): Int { override fun getItemCount(): Int {

View File

@ -12,12 +12,12 @@ import android.widget.ImageView
import android.widget.TextView import android.widget.TextView
import androidx.appcompat.app.AppCompatActivity import androidx.appcompat.app.AppCompatActivity
import androidx.recyclerview.widget.RecyclerView import androidx.recyclerview.widget.RecyclerView
import com.squareup.picasso.Picasso
import com.github.libretube.PlayerFragment import com.github.libretube.PlayerFragment
import com.github.libretube.R import com.github.libretube.R
import com.github.libretube.RetrofitInstance import com.github.libretube.RetrofitInstance
import com.github.libretube.obj.PlaylistId import com.github.libretube.obj.PlaylistId
import com.github.libretube.obj.StreamItem import com.github.libretube.obj.StreamItem
import com.squareup.picasso.Picasso
import kotlinx.coroutines.GlobalScope import kotlinx.coroutines.GlobalScope
import kotlinx.coroutines.launch import kotlinx.coroutines.launch
import retrofit2.HttpException import retrofit2.HttpException

View File

@ -2,16 +2,18 @@ package com.github.libretube.adapters
import android.app.Activity import android.app.Activity
import android.content.Context import android.content.Context
import android.os.Handler
import android.util.Log import android.util.Log
import android.view.LayoutInflater import android.view.LayoutInflater
import android.view.View import android.view.View
import android.view.ViewGroup import android.view.ViewGroup
import android.widget.* import android.widget.ImageView
import android.widget.TextView
import androidx.appcompat.app.AlertDialog import androidx.appcompat.app.AlertDialog
import androidx.core.os.bundleOf import androidx.core.os.bundleOf
import androidx.recyclerview.widget.RecyclerView import androidx.recyclerview.widget.RecyclerView
import com.github.libretube.* import com.github.libretube.MainActivity
import com.github.libretube.R
import com.github.libretube.RetrofitInstance
import com.github.libretube.obj.PlaylistId import com.github.libretube.obj.PlaylistId
import com.github.libretube.obj.Playlists import com.github.libretube.obj.Playlists
import com.squareup.picasso.Picasso import com.squareup.picasso.Picasso

View File

@ -11,11 +11,11 @@ import androidx.appcompat.app.AppCompatActivity
import androidx.core.os.bundleOf import androidx.core.os.bundleOf
import androidx.recyclerview.widget.RecyclerView import androidx.recyclerview.widget.RecyclerView
import com.github.libretube.MainActivity import com.github.libretube.MainActivity
import com.squareup.picasso.Picasso
import com.github.libretube.PlayerFragment import com.github.libretube.PlayerFragment
import com.github.libretube.R import com.github.libretube.R
import com.github.libretube.obj.SearchItem
import com.github.libretube.formatShort import com.github.libretube.formatShort
import com.github.libretube.obj.SearchItem
import com.squareup.picasso.Picasso
class SearchAdapter(private val searchItems: List<SearchItem>): RecyclerView.Adapter<CustomViewHolder1>() { class SearchAdapter(private val searchItems: List<SearchItem>): RecyclerView.Adapter<CustomViewHolder1>() {

View File

@ -0,0 +1,55 @@
package com.github.libretube.adapters
import android.content.Context
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import android.widget.AutoCompleteTextView
import android.widget.TextView
import androidx.preference.PreferenceManager
import androidx.recyclerview.widget.RecyclerView
import com.github.libretube.R
import com.google.android.material.imageview.ShapeableImageView
class SearchHistoryAdapter(private val context: Context, private var historyList: List<String> , private val editText : AutoCompleteTextView) :
RecyclerView.Adapter<SearchHistoryViewHolder>() {
override fun getItemCount(): Int {
return historyList.size
}
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): SearchHistoryViewHolder {
val layoutInflater = LayoutInflater.from(parent.context)
val cell = layoutInflater.inflate(R.layout.searchhistory_row, parent, false)
return SearchHistoryViewHolder(cell)
}
override fun onBindViewHolder(holder: SearchHistoryViewHolder, position: Int) {
val history = historyList[position]
holder.v.findViewById<TextView>(R.id.history_text).text = history
holder.v.findViewById<ShapeableImageView>(R.id.delete_history).setOnClickListener {
val sharedPreferences = PreferenceManager.getDefaultSharedPreferences(context)
historyList = historyList - history
sharedPreferences.edit().putStringSet("search_history", HashSet(historyList))
.apply()
notifyDataSetChanged()
}
holder.v.setOnClickListener {
editText.setText(history)
}
}
}
class SearchHistoryViewHolder(val v: View) : RecyclerView.ViewHolder(v) {
init {
}
}

View File

@ -12,11 +12,11 @@ import androidx.constraintlayout.motion.widget.MotionLayout
import androidx.core.os.bundleOf import androidx.core.os.bundleOf
import androidx.recyclerview.widget.RecyclerView import androidx.recyclerview.widget.RecyclerView
import com.github.libretube.MainActivity import com.github.libretube.MainActivity
import com.squareup.picasso.Picasso
import com.github.libretube.PlayerFragment import com.github.libretube.PlayerFragment
import com.github.libretube.R import com.github.libretube.R
import com.github.libretube.obj.StreamItem
import com.github.libretube.formatShort import com.github.libretube.formatShort
import com.github.libretube.obj.StreamItem
import com.squareup.picasso.Picasso
class SubscriptionAdapter(private val videoFeed: List<StreamItem>): RecyclerView.Adapter<SubscriptionViewHolder>() { class SubscriptionAdapter(private val videoFeed: List<StreamItem>): RecyclerView.Adapter<SubscriptionViewHolder>() {
//private var limitedVideoFeed: MutableList<String> = [""].toMutableList() //private var limitedVideoFeed: MutableList<String> = [""].toMutableList()

View File

@ -1,20 +1,16 @@
package com.github.libretube.adapters package com.github.libretube.adapters
import android.os.Bundle
import android.view.LayoutInflater import android.view.LayoutInflater
import android.view.View import android.view.View
import android.view.ViewGroup import android.view.ViewGroup
import android.widget.ImageView import android.widget.ImageView
import android.widget.TextView import android.widget.TextView
import androidx.appcompat.app.AppCompatActivity
import androidx.core.os.bundleOf import androidx.core.os.bundleOf
import androidx.recyclerview.widget.RecyclerView import androidx.recyclerview.widget.RecyclerView
import com.github.libretube.MainActivity import com.github.libretube.MainActivity
import com.github.libretube.PlayerFragment
import com.github.libretube.R import com.github.libretube.R
import com.github.libretube.obj.Subscription import com.github.libretube.obj.Subscription
import com.squareup.picasso.Picasso import com.squareup.picasso.Picasso
import org.w3c.dom.Text
class SubscriptionChannelAdapter(private val subscriptions: MutableList<Subscription>): RecyclerView.Adapter<SubscriptionChannelViewHolder>() { class SubscriptionChannelAdapter(private val subscriptions: MutableList<Subscription>): RecyclerView.Adapter<SubscriptionChannelViewHolder>() {
override fun getItemCount(): Int { override fun getItemCount(): Int {

View File

@ -12,11 +12,11 @@ import androidx.constraintlayout.motion.widget.MotionLayout
import androidx.core.os.bundleOf import androidx.core.os.bundleOf
import androidx.recyclerview.widget.RecyclerView import androidx.recyclerview.widget.RecyclerView
import com.github.libretube.MainActivity import com.github.libretube.MainActivity
import com.squareup.picasso.Picasso
import com.github.libretube.PlayerFragment import com.github.libretube.PlayerFragment
import com.github.libretube.R import com.github.libretube.R
import com.github.libretube.obj.StreamItem
import com.github.libretube.formatShort import com.github.libretube.formatShort
import com.github.libretube.obj.StreamItem
import com.squareup.picasso.Picasso
class TrendingAdapter(private val videoFeed: List<StreamItem>): RecyclerView.Adapter<CustomViewHolder>() { class TrendingAdapter(private val videoFeed: List<StreamItem>): RecyclerView.Adapter<CustomViewHolder>() {
override fun getItemCount(): Int { override fun getItemCount(): Int {

View File

@ -1,5 +1,11 @@
<vector android:height="24dp" android:tint="#FFFFFF" <vector xmlns:android="http://schemas.android.com/apk/res/android"
android:viewportHeight="24" android:viewportWidth="24"
android:width="24dp" xmlns:android="http://schemas.android.com/apk/res/android"> android:width="24dp"
<path android:fillColor="@android:color/white" android:pathData="M19,6.41L17.59,5 12,10.59 6.41,5 5,6.41 10.59,12 5,17.59 6.41,19 12,13.41 17.59,19 19,17.59 13.41,12z"/> android:height="24dp"
android:tint="?attr/colorControlNormal"
android:viewportWidth="24"
android:viewportHeight="24">
<path
android:fillColor="@android:color/white"
android:pathData="M19,6.41L17.59,5 12,10.59 6.41,5 5,6.41 10.59,12 5,17.59 6.41,19 12,13.41 17.59,19 19,17.59 13.41,12z" />
</vector> </vector>

View File

@ -0,0 +1,11 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:tint="?attr/colorControlNormal"
android:viewportWidth="24"
android:viewportHeight="24">
<path
android:fillColor="@android:color/white"
android:pathData="M13,3c-4.97,0 -9,4.03 -9,9L1,12l3.89,3.89 0.07,0.14L9,12L6,12c0,-3.87 3.13,-7 7,-7s7,3.13 7,7 -3.13,7 -7,7c-1.93,0 -3.68,-0.79 -4.94,-2.06l-1.42,1.42C8.27,19.99 10.51,21 13,21c4.97,0 9,-4.03 9,-9s-4.03,-9 -9,-9zM12,8v5l4.25,2.52 0.77,-1.28 -3.52,-2.09L13.5,8z" />
</vector>

View File

@ -305,257 +305,6 @@
</LinearLayout> </LinearLayout>
<!-- <LinearLayout-->
<!-- android:id="@+id/linLayout"-->
<!-- android:layout_width="match_parent"-->
<!-- android:layout_height="wrap_content"-->
<!-- android:orientation="vertical"-->
<!-- >-->
<!-- <androidx.constraintlayout.widget.ConstraintLayout-->
<!-- android:id="@+id/player_info_layout"-->
<!-- android:layout_width="match_parent"-->
<!-- android:layout_height="wrap_content">-->
<!-- <androidx.constraintlayout.widget.ConstraintLayout-->
<!-- android:id="@+id/player_title_layout"-->
<!-- android:layout_width="match_parent"-->
<!-- android:layout_height="wrap_content"-->
<!-- app:layout_constraintEnd_toEndOf="parent"-->
<!-- app:layout_constraintStart_toStartOf="parent"-->
<!-- app:layout_constraintTop_toTopOf="parent">-->
<!-- <TextView-->
<!-- android:id="@+id/player_title"-->
<!-- android:layout_width="0dp"-->
<!-- android:layout_height="wrap_content"-->
<!-- android:padding="8dp"-->
<!-- android:paddingLeft="8dp"-->
<!-- android:paddingRight="8dp"-->
<!-- android:text="Loading..."-->
<!-- android:textSize="18sp"-->
<!-- android:textStyle="bold"-->
<!-- app:layout_constraintEnd_toStartOf="@id/player_description_arrow"-->
<!-- app:layout_constraintStart_toStartOf="parent"-->
<!-- app:layout_constraintTop_toTopOf="parent" />-->
<!-- <TextView-->
<!-- android:id="@+id/player_views_info"-->
<!-- android:layout_width="0dp"-->
<!-- android:layout_height="wrap_content"-->
<!-- android:paddingLeft="8dp"-->
<!-- android:paddingRight="8dp"-->
<!-- android:text=""-->
<!-- android:textSize="12sp"-->
<!-- app:layout_constraintEnd_toStartOf="@id/player_description_arrow"-->
<!-- app:layout_constraintStart_toStartOf="parent"-->
<!-- app:layout_constraintTop_toBottomOf="@+id/player_title" />-->
<!-- <ImageView-->
<!-- android:id="@+id/player_description_arrow"-->
<!-- android:layout_width="wrap_content"-->
<!-- android:layout_height="wrap_content"-->
<!-- android:layout_marginEnd="8dp"-->
<!-- android:paddingLeft="16dp"-->
<!-- android:src="@drawable/ic_arrow_down"-->
<!-- app:layout_constraintBottom_toBottomOf="parent"-->
<!-- app:layout_constraintEnd_toEndOf="parent"-->
<!-- app:layout_constraintTop_toTopOf="parent" />-->
<!-- </androidx.constraintlayout.widget.ConstraintLayout>-->
<!-- <TextView-->
<!-- android:id="@+id/player_description"-->
<!-- android:layout_width="match_parent"-->
<!-- android:layout_height="wrap_content"-->
<!-- android:padding="8dp"-->
<!-- android:textSize="14sp"-->
<!-- android:visibility="gone"-->
<!-- android:autoLink="web"-->
<!-- android:textIsSelectable="true"-->
<!-- app:layout_constraintEnd_toEndOf="parent"-->
<!-- app:layout_constraintStart_toStartOf="parent"-->
<!-- app:layout_constraintTop_toBottomOf="@id/player_title_layout" />-->
<!-- </androidx.constraintlayout.widget.ConstraintLayout>-->
<!-- <LinearLayout-->
<!-- android:layout_width="match_parent"-->
<!-- android:layout_height="wrap_content"-->
<!-- android:orientation="horizontal"-->
<!-- android:weightSum="5"-->
<!-- android:baselineAligned="false">-->
<!-- <RelativeLayout-->
<!-- android:layout_width="wrap_content"-->
<!-- android:layout_height="wrap_content"-->
<!-- android:layout_weight="1">-->
<!-- <ImageView-->
<!-- android:id="@+id/player_like"-->
<!-- android:layout_width="wrap_content"-->
<!-- android:layout_height="wrap_content"-->
<!-- android:layout_centerInParent="true"-->
<!-- android:layout_marginBottom="16dp"-->
<!-- android:src="@drawable/ic_like"-->
<!-- android:contentDescription="like"/>-->
<!-- <TextView-->
<!-- android:id="@+id/textLike"-->
<!-- android:layout_width="wrap_content"-->
<!-- android:layout_height="wrap_content"-->
<!-- android:layout_below="@id/player_like"-->
<!-- android:layout_centerHorizontal="true"-->
<!-- android:text="1K" />-->
<!-- </RelativeLayout>-->
<!-- <RelativeLayout-->
<!-- android:id="@+id/relPlayer_share"-->
<!-- android:layout_width="wrap_content"-->
<!-- android:layout_height="wrap_content"-->
<!-- android:layout_weight="1"-->
<!-- android:background="?android:attr/selectableItemBackground">-->
<!-- <ImageView-->
<!-- android:id="@+id/player_share"-->
<!-- android:layout_width="wrap_content"-->
<!-- android:layout_height="wrap_content"-->
<!-- android:layout_centerInParent="true"-->
<!-- android:layout_marginBottom="16dp"-->
<!-- android:src="@drawable/ic_share" />-->
<!-- <TextView-->
<!-- android:id="@+id/textShare"-->
<!-- android:layout_width="wrap_content"-->
<!-- android:layout_height="wrap_content"-->
<!-- android:layout_below="@id/player_share"-->
<!-- android:layout_centerHorizontal="true"-->
<!-- android:text="@string/share" />-->
<!-- </RelativeLayout>-->
<!-- <RelativeLayout-->
<!-- android:id="@+id/relPlayer_download"-->
<!-- android:layout_width="wrap_content"-->
<!-- android:layout_height="wrap_content"-->
<!-- android:layout_weight="1"-->
<!-- android:background="?android:attr/selectableItemBackground">-->
<!-- <ImageView-->
<!-- android:id="@+id/player_download"-->
<!-- android:layout_width="wrap_content"-->
<!-- android:layout_height="wrap_content"-->
<!-- android:layout_centerInParent="true"-->
<!-- android:layout_marginBottom="16dp"-->
<!-- android:src="@drawable/ic_download" />-->
<!-- <TextView-->
<!-- android:id="@+id/textDownload"-->
<!-- android:layout_width="wrap_content"-->
<!-- android:layout_height="wrap_content"-->
<!-- android:layout_below="@id/player_download"-->
<!-- android:layout_centerHorizontal="true"-->
<!-- android:text="@string/download" />-->
<!-- </RelativeLayout>-->
<!-- <RelativeLayout-->
<!-- android:id="@+id/relPlayer_vlc"-->
<!-- android:layout_width="wrap_content"-->
<!-- android:layout_height="wrap_content"-->
<!-- android:layout_weight="1"-->
<!-- android:background="?android:attr/selectableItemBackground">-->
<!-- <ImageView-->
<!-- android:id="@+id/player_vlc"-->
<!-- android:layout_width="wrap_content"-->
<!-- android:layout_height="wrap_content"-->
<!-- android:layout_centerInParent="true"-->
<!-- android:layout_marginBottom="16dp"-->
<!-- android:src="@drawable/ic_vlc" />-->
<!-- <TextView-->
<!-- android:id="@+id/textVlc"-->
<!-- android:layout_width="wrap_content"-->
<!-- android:layout_height="wrap_content"-->
<!-- android:layout_below="@id/player_vlc"-->
<!-- android:layout_centerHorizontal="true"-->
<!-- android:text="@string/vlc" />-->
<!-- </RelativeLayout>-->
<!-- <RelativeLayout-->
<!-- android:id="@+id/save"-->
<!-- android:layout_width="wrap_content"-->
<!-- android:layout_height="wrap_content"-->
<!-- android:layout_weight="1"-->
<!-- android:background="?android:attr/selectableItemBackground">-->
<!-- <ImageView-->
<!-- android:id="@+id/player_save"-->
<!-- android:layout_width="wrap_content"-->
<!-- android:layout_height="wrap_content"-->
<!-- android:layout_centerInParent="true"-->
<!-- android:layout_marginBottom="16dp"-->
<!-- android:src="@drawable/ic_save" />-->
<!-- <TextView-->
<!-- android:id="@+id/textSave"-->
<!-- android:layout_width="wrap_content"-->
<!-- android:layout_height="wrap_content"-->
<!-- android:layout_below="@id/player_save"-->
<!-- android:layout_centerHorizontal="true"-->
<!-- android:text="@string/save" />-->
<!-- </RelativeLayout>-->
<!-- </LinearLayout>-->
<!-- <RelativeLayout-->
<!-- android:id="@+id/player_channel"-->
<!-- android:layout_width="match_parent"-->
<!-- android:layout_height="wrap_content"-->
<!-- android:layout_marginTop="8dp"-->
<!-- android:paddingLeft="8dp"-->
<!-- android:paddingRight="8dp"-->
<!-- android:layout_marginStart="8dp"-->
<!-- android:background="?android:attr/selectableItemBackground">-->
<!-- <de.hdodenhof.circleimageview.CircleImageView-->
<!-- android:id="@+id/player_channelImage"-->
<!-- android:layout_width="40dp"-->
<!-- android:layout_height="40dp"-->
<!-- android:layout_centerVertical="true"-->
<!-- android:layout_marginEnd="4dp" />-->
<!-- <TextView-->
<!-- android:id="@+id/player_channelName"-->
<!-- android:layout_width="0dp"-->
<!-- android:layout_height="wrap_content"-->
<!-- android:layout_centerVertical="true"-->
<!-- android:layout_toStartOf="@+id/player_subscribe"-->
<!-- android:layout_toEndOf="@+id/player_channelImage"-->
<!-- android:ellipsize="end"-->
<!-- android:maxLines="1"-->
<!-- android:text=""-->
<!-- android:textStyle="bold" />-->
<!-- <com.google.android.material.button.MaterialButton-->
<!-- android:id="@+id/player_subscribe"-->
<!-- android:layout_width="wrap_content"-->
<!-- android:layout_height="wrap_content"-->
<!-- android:layout_alignParentEnd="true"-->
<!-- android:layout_centerVertical="true"-->
<!-- android:background="?android:attr/selectableItemBackground"-->
<!-- android:text="@string/subscribe"-->
<!-- android:textColor="@color/colorPrimary" />-->
<!-- </RelativeLayout>-->
<!-- <RelativeLayout-->
<!-- android:layout_width="match_parent"-->
<!-- android:layout_height="wrap_content"-->
<!-- android:descendantFocusability="blocksDescendants">-->
<!-- <androidx.recyclerview.widget.RecyclerView-->
<!-- android:id="@+id/player_recView"-->
<!-- android:layout_width="match_parent"-->
<!-- android:layout_height="wrap_content"-->
<!-- android:nestedScrollingEnabled="false" />-->
<!-- </RelativeLayout>-->
<!-- </LinearLayout>-->
</ScrollView> </ScrollView>
<androidx.constraintlayout.widget.ConstraintLayout <androidx.constraintlayout.widget.ConstraintLayout

View File

@ -4,38 +4,37 @@
xmlns:tools="http://schemas.android.com/tools" xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent" android:layout_height="match_parent"
tools:context=".SearchFragment" tools:context=".SearchFragment">
>
<com.google.android.material.card.MaterialCardView <com.google.android.material.card.MaterialCardView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@+id/outlinedTextField" android:id="@+id/outlinedTextField"
style="@style/Widget.Material3.CardView.Filled" style="@style/Widget.Material3.CardView.Filled"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="16dp"
app:cardCornerRadius="27dp"
app:layout_constraintEnd_toEndOf="parent" app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent" app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" app:layout_constraintTop_toTopOf="parent">
android:layout_margin="5dp"
>
<com.google.android.material.textfield.TextInputLayout <com.google.android.material.textfield.TextInputLayout
style="@style/Widget.MaterialComponents.TextInputLayout.OutlinedBox" style="@style/Widget.MaterialComponents.TextInputLayout.OutlinedBox"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
app:hintEnabled="false"
android:layout_marginRight="20dp"
android:layout_marginLeft="20dp" android:layout_marginLeft="20dp"
android:background="@android:color/transparent" android:layout_marginRight="20dp"
> android:background="@android:color/transparent"
app:hintEnabled="false">
<AutoCompleteTextView <AutoCompleteTextView
android:id="@+id/autoCompleteTextView" android:id="@+id/autoCompleteTextView"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:background="@android:color/transparent"
android:hint="Search" android:hint="Search"
android:imeOptions="actionSearch" android:imeOptions="actionSearch"
android:inputType="text" android:inputType="text"
android:maxLines="1" android:maxLines="1"
android:background="@android:color/transparent"
android:padding="12dp" /> android:padding="12dp" />
</com.google.android.material.textfield.TextInputLayout> </com.google.android.material.textfield.TextInputLayout>
@ -43,6 +42,263 @@
</com.google.android.material.card.MaterialCardView> </com.google.android.material.card.MaterialCardView>
<!-- <TextView-->
<!-- android:id="@+id/tv_genres"-->
<!-- android:layout_width="wrap_content"-->
<!-- android:layout_height="wrap_content"-->
<!-- android:layout_margin="25dp"-->
<!-- android:text="Explore different genres"-->
<!-- android:textSize="16sp"-->
<!-- app:layout_constraintStart_toStartOf="parent"-->
<!-- app:layout_constraintTop_toBottomOf="@+id/outlinedTextField" />-->
<!-- <LinearLayout-->
<!-- android:id="@+id/genres"-->
<!-- android:layout_width="match_parent"-->
<!-- android:layout_height="wrap_content"-->
<!-- android:layout_marginLeft="10dp"-->
<!-- android:layout_marginTop="30dp"-->
<!-- android:layout_marginRight="10dp"-->
<!-- android:orientation="horizontal"-->
<!-- app:layout_constraintEnd_toEndOf="parent"-->
<!-- app:layout_constraintStart_toStartOf="parent"-->
<!-- app:layout_constraintTop_toBottomOf="@id/tv_genres">-->
<!-- <com.google.android.material.card.MaterialCardView-->
<!-- android:id="@+id/btn_trending"-->
<!-- android:layout_width="0dp"-->
<!-- android:layout_height="wrap_content"-->
<!-- android:layout_marginLeft="20dp"-->
<!-- android:layout_marginRight="20dp"-->
<!-- android:layout_weight=".5"-->
<!-- android:background="@android:color/transparent"-->
<!-- app:cardBackgroundColor="@android:color/transparent"-->
<!-- app:strokeWidth="0dp">-->
<!-- <RelativeLayout-->
<!-- android:layout_width="match_parent"-->
<!-- android:layout_height="match_parent"-->
<!-- android:orientation="horizontal">-->
<!-- <ImageView-->
<!-- android:id="@+id/iv_ic"-->
<!-- android:layout_width="25dp"-->
<!-- android:layout_height="25dp"-->
<!-- android:layout_alignParentLeft="true"-->
<!-- android:layout_centerVertical="true"-->
<!-- android:layout_marginStart="5dp"-->
<!-- android:layout_marginTop="5dp"-->
<!-- android:layout_marginEnd="5dp"-->
<!-- android:layout_marginBottom="5dp"-->
<!-- android:src="@drawable/ic_hot" />-->
<!-- <TextView-->
<!-- android:layout_width="wrap_content"-->
<!-- android:layout_height="wrap_content"-->
<!-- android:layout_centerVertical="true"-->
<!-- android:layout_marginLeft="7dp"-->
<!-- android:layout_toRightOf="@id/iv_ic"-->
<!-- android:text="@string/trending"-->
<!-- android:textSize="16sp" />-->
<!-- <ImageView-->
<!-- android:layout_width="10dp"-->
<!-- android:layout_height="10dp"-->
<!-- android:layout_alignParentRight="true"-->
<!-- android:layout_centerVertical="true"-->
<!-- android:src="@drawable/ic_arrow" />-->
<!-- </RelativeLayout>-->
<!-- </com.google.android.material.card.MaterialCardView>-->
<!-- <com.google.android.material.card.MaterialCardView-->
<!-- android:id="@+id/btn_live"-->
<!-- android:layout_width="0dp"-->
<!-- android:layout_height="wrap_content"-->
<!-- android:layout_marginLeft="30dp"-->
<!-- android:layout_marginRight="20dp"-->
<!-- android:layout_weight=".5"-->
<!-- android:background="@android:color/transparent"-->
<!-- app:cardBackgroundColor="@android:color/transparent"-->
<!-- app:strokeWidth="0dp">-->
<!-- <RelativeLayout-->
<!-- android:layout_width="match_parent"-->
<!-- android:layout_height="match_parent"-->
<!-- android:orientation="horizontal">-->
<!-- <ImageView-->
<!-- android:id="@+id/iv_ic2"-->
<!-- android:layout_width="25dp"-->
<!-- android:layout_height="25dp"-->
<!-- android:layout_alignParentLeft="true"-->
<!-- android:layout_centerVertical="true"-->
<!-- android:layout_marginStart="5dp"-->
<!-- android:layout_marginTop="5dp"-->
<!-- android:layout_marginEnd="5dp"-->
<!-- android:layout_marginBottom="5dp"-->
<!-- android:src="@drawable/ic_live" />-->
<!-- <TextView-->
<!-- android:layout_width="wrap_content"-->
<!-- android:layout_height="wrap_content"-->
<!-- android:layout_centerVertical="true"-->
<!-- android:layout_marginLeft="7dp"-->
<!-- android:layout_toRightOf="@id/iv_ic2"-->
<!-- android:text="@string/live"-->
<!-- android:textSize="16sp" />-->
<!-- <ImageView-->
<!-- android:layout_width="10dp"-->
<!-- android:layout_height="10dp"-->
<!-- android:layout_alignParentRight="true"-->
<!-- android:layout_centerVertical="true"-->
<!-- android:src="@drawable/ic_arrow" />-->
<!-- </RelativeLayout>-->
<!-- </com.google.android.material.card.MaterialCardView>-->
<!-- </LinearLayout>-->
<!-- <LinearLayout-->
<!-- android:id="@+id/genres2"-->
<!-- android:layout_width="match_parent"-->
<!-- android:layout_height="wrap_content"-->
<!-- android:layout_marginLeft="10dp"-->
<!-- android:layout_marginTop="20dp"-->
<!-- android:layout_marginRight="10dp"-->
<!-- android:orientation="horizontal"-->
<!-- app:layout_constraintEnd_toEndOf="parent"-->
<!-- app:layout_constraintStart_toStartOf="parent"-->
<!-- app:layout_constraintTop_toBottomOf="@id/genres">-->
<!-- <com.google.android.material.card.MaterialCardView-->
<!-- android:id="@+id/btn_music"-->
<!-- android:layout_width="0dp"-->
<!-- android:layout_height="wrap_content"-->
<!-- android:layout_marginLeft="20dp"-->
<!-- android:layout_marginRight="20dp"-->
<!-- android:layout_weight=".5"-->
<!-- android:background="@android:color/transparent"-->
<!-- app:cardBackgroundColor="@android:color/transparent"-->
<!-- app:strokeWidth="0dp">-->
<!-- <RelativeLayout-->
<!-- android:layout_width="match_parent"-->
<!-- android:layout_height="match_parent"-->
<!-- android:orientation="horizontal">-->
<!-- <ImageView-->
<!-- android:id="@+id/iv_ic3"-->
<!-- android:layout_width="25dp"-->
<!-- android:layout_height="25dp"-->
<!-- android:layout_alignParentLeft="true"-->
<!-- android:layout_centerVertical="true"-->
<!-- android:layout_marginStart="5dp"-->
<!-- android:layout_marginTop="5dp"-->
<!-- android:layout_marginEnd="5dp"-->
<!-- android:layout_marginBottom="5dp"-->
<!-- android:src="@drawable/ic_music" />-->
<!-- <TextView-->
<!-- android:layout_width="wrap_content"-->
<!-- android:layout_height="wrap_content"-->
<!-- android:layout_centerVertical="true"-->
<!-- android:layout_marginLeft="7dp"-->
<!-- android:layout_toRightOf="@id/iv_ic3"-->
<!-- android:text="@string/music"-->
<!-- android:textSize="16sp" />-->
<!-- <ImageView-->
<!-- android:layout_width="10dp"-->
<!-- android:layout_height="10dp"-->
<!-- android:layout_alignParentRight="true"-->
<!-- android:layout_centerVertical="true"-->
<!-- android:src="@drawable/ic_arrow" />-->
<!-- </RelativeLayout>-->
<!-- </com.google.android.material.card.MaterialCardView>-->
<!-- <com.google.android.material.card.MaterialCardView-->
<!-- android:id="@+id/btn_films"-->
<!-- android:layout_width="0dp"-->
<!-- android:layout_height="wrap_content"-->
<!-- android:layout_marginLeft="30dp"-->
<!-- android:layout_marginRight="20dp"-->
<!-- android:layout_weight=".5"-->
<!-- android:background="@android:color/transparent"-->
<!-- app:cardBackgroundColor="@android:color/transparent"-->
<!-- app:strokeWidth="0dp">-->
<!-- <RelativeLayout-->
<!-- android:layout_width="match_parent"-->
<!-- android:layout_height="match_parent"-->
<!-- android:orientation="horizontal">-->
<!-- <ImageView-->
<!-- android:id="@+id/iv_ic4"-->
<!-- android:layout_width="25dp"-->
<!-- android:layout_height="25dp"-->
<!-- android:layout_alignParentLeft="true"-->
<!-- android:layout_centerVertical="true"-->
<!-- android:layout_marginStart="5dp"-->
<!-- android:layout_marginTop="5dp"-->
<!-- android:layout_marginEnd="5dp"-->
<!-- android:layout_marginBottom="5dp"-->
<!-- android:src="@drawable/ic_film" />-->
<!-- <TextView-->
<!-- android:layout_width="wrap_content"-->
<!-- android:layout_height="wrap_content"-->
<!-- android:layout_centerVertical="true"-->
<!-- android:layout_marginLeft="7dp"-->
<!-- android:layout_toRightOf="@id/iv_ic4"-->
<!-- android:text="@string/film"-->
<!-- android:textSize="16sp" />-->
<!-- <ImageView-->
<!-- android:layout_width="10dp"-->
<!-- android:layout_height="10dp"-->
<!-- android:layout_alignParentRight="true"-->
<!-- android:layout_centerVertical="true"-->
<!-- android:src="@drawable/ic_arrow" />-->
<!-- </RelativeLayout>-->
<!-- </com.google.android.material.card.MaterialCardView>-->
<!-- </LinearLayout>-->
<!-- <TextView-->
<!-- android:id="@+id/tv_history"-->
<!-- android:layout_width="wrap_content"-->
<!-- android:layout_height="wrap_content"-->
<!-- android:layout_margin="25dp"-->
<!-- android:text="@string/history"-->
<!-- android:textSize="14sp"-->
<!-- app:layout_constraintStart_toStartOf="parent"-->
<!-- app:layout_constraintTop_toBottomOf="@+id/outlinedTextField"-->
<!-- android:visibility="gone"/>-->
<androidx.recyclerview.widget.RecyclerView
android:id="@+id/history_recycler"
android:layout_width="0dp"
android:layout_height="0dp"
android:layout_margin="10dp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/outlinedTextField"
android:visibility="gone"/>
<androidx.recyclerview.widget.RecyclerView <androidx.recyclerview.widget.RecyclerView
android:id="@+id/search_recycler" android:id="@+id/search_recycler"

View File

@ -0,0 +1,42 @@
<?xml version="1.0" encoding="utf-8"?>
<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_height="wrap_content"
android:layout_margin="8dp"
android:layout_marginBottom="16dp"
android:background="?android:attr/selectableItemBackground">
<ImageView
android:id="@+id/history_icon"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:src="@drawable/ic_history"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintBottom_toBottomOf="parent"
android:layout_margin="5dp"
/>
<TextView
android:id="@+id/history_text"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginStart="8dp"
android:text=""
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toStartOf="@id/delete_history"
app:layout_constraintStart_toEndOf="@id/history_icon"
app:layout_constraintTop_toTopOf="parent" />
<com.google.android.material.imageview.ShapeableImageView
android:id="@+id/delete_history"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:background="?android:attr/selectableItemBackground"
android:padding="5dp"
android:src="@drawable/ic_close2"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:shapeAppearanceOverlay="@style/roundedImageViewRounded" />
</androidx.constraintlayout.widget.ConstraintLayout>