mirror of
https://github.com/libre-tube/LibreTube.git
synced 2025-04-29 16:30:31 +05:30
Codebase built
This commit is contained in:
parent
c6c4cdfd2b
commit
c619056b67
@ -1,6 +1,7 @@
|
|||||||
package com.github.libretube
|
package com.github.libretube
|
||||||
|
|
||||||
import android.content.Context
|
import android.content.Context
|
||||||
|
import android.content.DialogInterface
|
||||||
import android.os.Bundle
|
import android.os.Bundle
|
||||||
import android.text.Editable
|
import android.text.Editable
|
||||||
import android.text.TextWatcher
|
import android.text.TextWatcher
|
||||||
@ -13,7 +14,10 @@ import android.view.inputmethod.EditorInfo
|
|||||||
import android.view.inputmethod.InputMethodManager
|
import android.view.inputmethod.InputMethodManager
|
||||||
import android.widget.ArrayAdapter
|
import android.widget.ArrayAdapter
|
||||||
import android.widget.AutoCompleteTextView
|
import android.widget.AutoCompleteTextView
|
||||||
|
import android.widget.ImageView
|
||||||
import android.widget.TextView.*
|
import android.widget.TextView.*
|
||||||
|
import android.widget.Toast
|
||||||
|
import androidx.appcompat.app.AlertDialog
|
||||||
import androidx.fragment.app.Fragment
|
import androidx.fragment.app.Fragment
|
||||||
import androidx.lifecycle.lifecycleScope
|
import androidx.lifecycle.lifecycleScope
|
||||||
import androidx.preference.PreferenceManager
|
import androidx.preference.PreferenceManager
|
||||||
@ -25,6 +29,7 @@ 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
|
||||||
|
import org.chromium.base.ThreadUtils.runOnUiThread
|
||||||
import retrofit2.HttpException
|
import retrofit2.HttpException
|
||||||
import java.io.IOException
|
import java.io.IOException
|
||||||
|
|
||||||
@ -55,6 +60,19 @@ class SearchFragment : Fragment() {
|
|||||||
|
|
||||||
val historyRecycler = view.findViewById<RecyclerView>(R.id.history_recycler)
|
val historyRecycler = view.findViewById<RecyclerView>(R.id.history_recycler)
|
||||||
|
|
||||||
|
val filterImageView = view.findViewById<ImageView>(R.id.filterMenu_imageView)
|
||||||
|
filterImageView.setOnClickListener {
|
||||||
|
val options = arrayOf("Alle", "Videos")
|
||||||
|
var checkItem = 1
|
||||||
|
AlertDialog.Builder(view.context)
|
||||||
|
.setTitle("Choose an Option")
|
||||||
|
.setSingleChoiceItems(options, checkItem, DialogInterface.OnClickListener {
|
||||||
|
dialog, id -> Toast.makeText(view.context,id.toString(),Toast.LENGTH_LONG).show()
|
||||||
|
})
|
||||||
|
|
||||||
|
.create()
|
||||||
|
.show()
|
||||||
|
}
|
||||||
|
|
||||||
//show search history
|
//show search history
|
||||||
|
|
||||||
|
@ -16,19 +16,27 @@ import com.github.libretube.R
|
|||||||
import com.github.libretube.formatShort
|
import com.github.libretube.formatShort
|
||||||
import com.github.libretube.obj.SearchItem
|
import com.github.libretube.obj.SearchItem
|
||||||
import com.squareup.picasso.Picasso
|
import com.squareup.picasso.Picasso
|
||||||
|
import kotlinx.coroutines.NonDisposableHandle.parent
|
||||||
|
|
||||||
|
private val showVideos = true
|
||||||
|
private val showChannels = true
|
||||||
|
private val showPlaylists = true
|
||||||
|
|
||||||
class SearchAdapter(private val searchItems: List<SearchItem>): RecyclerView.Adapter<CustomViewHolder1>() {
|
class SearchAdapter(private val searchItems: List<SearchItem>): RecyclerView.Adapter<CustomViewHolder1>() {
|
||||||
|
|
||||||
override fun getItemCount(): Int {
|
override fun getItemCount(): Int {
|
||||||
return searchItems.size
|
return searchItems.size
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): CustomViewHolder1 {
|
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): CustomViewHolder1 {
|
||||||
val layout = when (viewType) {
|
val layout = if (viewType == 0 && showVideos) {
|
||||||
0 -> R.layout.video_search_row
|
R.layout.video_search_row
|
||||||
1 -> R.layout.channel_search_row
|
} else if (viewType == 1 && showChannels){
|
||||||
2 -> R.layout.playlist_search_row
|
R.layout.channel_search_row
|
||||||
else -> throw IllegalArgumentException("Invalid type")
|
} else if (viewType == 2 && showPlaylists) {
|
||||||
|
R.layout.playlist_search_row
|
||||||
|
} else {
|
||||||
|
R.layout.layout_empty
|
||||||
}
|
}
|
||||||
val layoutInflater = LayoutInflater.from(parent.context)
|
val layoutInflater = LayoutInflater.from(parent.context)
|
||||||
val cell = layoutInflater.inflate(layout,parent,false)
|
val cell = layoutInflater.inflate(layout,parent,false)
|
||||||
@ -120,12 +128,9 @@ class CustomViewHolder1(private val v: View): RecyclerView.ViewHolder(v){
|
|||||||
}
|
}
|
||||||
|
|
||||||
fun bind(searchItem: SearchItem) {
|
fun bind(searchItem: SearchItem) {
|
||||||
when {
|
if (searchItem.url!!.startsWith("/watch",false) && showVideos) bindWatch(searchItem)
|
||||||
searchItem.url!!.startsWith("/watch",false) -> bindWatch(searchItem)
|
else if (searchItem.url!!.startsWith("/channel",false) && showChannels) bindChannel(searchItem)
|
||||||
searchItem.url!!.startsWith("/channel",false) -> bindChannel(searchItem)
|
else if (searchItem.url!!.startsWith("/playlist",false) && showPlaylists) bindPlaylist(searchItem)
|
||||||
searchItem.url!!.startsWith("/playlist",false) -> bindPlaylist(searchItem)
|
else {}
|
||||||
else -> {
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
10
app/src/main/res/drawable/ic_filter.xml
Normal file
10
app/src/main/res/drawable/ic_filter.xml
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
android:height="24dp"
|
||||||
|
android:tint="?attr/colorControlNormal"
|
||||||
|
android:viewportHeight="24"
|
||||||
|
android:viewportWidth="24"
|
||||||
|
android:width="24dp">
|
||||||
|
<path
|
||||||
|
android:fillColor="@android:color/white"
|
||||||
|
android:pathData="M10,18h4v-2h-4v2zM3,6v2h18L21,6L3,6zM6,13h12v-2L6,11v2z"/>
|
||||||
|
</vector>
|
@ -6,41 +6,57 @@
|
|||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent"
|
||||||
tools:context=".SearchFragment">
|
tools:context=".SearchFragment">
|
||||||
|
|
||||||
<com.google.android.material.card.MaterialCardView
|
<RelativeLayout
|
||||||
android:id="@+id/outlinedTextField"
|
android:id="@+id/searchbar_holder"
|
||||||
style="@style/Widget.Material3.CardView.Filled"
|
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_margin="16dp"
|
|
||||||
app:cardCornerRadius="27dp"
|
|
||||||
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">
|
||||||
|
|
||||||
<com.google.android.material.textfield.TextInputLayout
|
<com.google.android.material.card.MaterialCardView
|
||||||
style="@style/Widget.MaterialComponents.TextInputLayout.OutlinedBox"
|
android:id="@+id/outlinedTextField"
|
||||||
android:layout_width="match_parent"
|
style="@style/Widget.Material3.CardView.Filled"
|
||||||
|
android:layout_width="320dp"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_marginLeft="20dp"
|
android:layout_margin="16dp"
|
||||||
android:layout_marginRight="20dp"
|
app:cardCornerRadius="27dp"
|
||||||
android:background="@android:color/transparent"
|
app:layout_constraintEnd_toEndOf="parent"
|
||||||
app:hintEnabled="false">
|
app:layout_constraintStart_toStartOf="parent"
|
||||||
|
app:layout_constraintTop_toTopOf="parent">
|
||||||
|
|
||||||
<AutoCompleteTextView
|
<com.google.android.material.textfield.TextInputLayout
|
||||||
android:id="@+id/autoCompleteTextView"
|
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"
|
||||||
|
android:layout_marginLeft="20dp"
|
||||||
|
android:layout_marginRight="20dp"
|
||||||
android:background="@android:color/transparent"
|
android:background="@android:color/transparent"
|
||||||
android:hint="@string/search_hint"
|
app:hintEnabled="false">
|
||||||
android:imeOptions="actionSearch"
|
|
||||||
android:inputType="text"
|
|
||||||
android:maxLines="1"
|
|
||||||
android:padding="12dp" />
|
|
||||||
|
|
||||||
</com.google.android.material.textfield.TextInputLayout>
|
<AutoCompleteTextView
|
||||||
|
android:id="@+id/autoCompleteTextView"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:background="@android:color/transparent"
|
||||||
|
android:hint="@string/search_hint"
|
||||||
|
android:imeOptions="actionSearch"
|
||||||
|
android:inputType="text"
|
||||||
|
android:maxLines="1"
|
||||||
|
android:padding="12dp" />
|
||||||
|
|
||||||
</com.google.android.material.card.MaterialCardView>
|
</com.google.android.material.textfield.TextInputLayout>
|
||||||
|
|
||||||
|
</com.google.android.material.card.MaterialCardView>
|
||||||
|
|
||||||
|
<ImageView
|
||||||
|
android:id="@+id/filterMenu_imageView"
|
||||||
|
android:layout_width="30dp"
|
||||||
|
android:layout_height="30dp"
|
||||||
|
android:layout_alignParentRight="true"
|
||||||
|
android:layout_marginTop="25dp"
|
||||||
|
android:layout_marginRight="20dp"
|
||||||
|
android:src="@drawable/ic_filter" />
|
||||||
|
</RelativeLayout>
|
||||||
|
|
||||||
<!-- <TextView-->
|
<!-- <TextView-->
|
||||||
<!-- android:id="@+id/tv_genres"-->
|
<!-- android:id="@+id/tv_genres"-->
|
||||||
@ -297,7 +313,7 @@
|
|||||||
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"
|
||||||
app:layout_constraintTop_toBottomOf="@+id/outlinedTextField"
|
app:layout_constraintTop_toBottomOf="@+id/searchbar_holder"
|
||||||
android:visibility="gone"/>
|
android:visibility="gone"/>
|
||||||
|
|
||||||
<androidx.recyclerview.widget.RecyclerView
|
<androidx.recyclerview.widget.RecyclerView
|
||||||
@ -311,7 +327,7 @@
|
|||||||
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"
|
||||||
app:layout_constraintTop_toBottomOf="@+id/outlinedTextField"
|
app:layout_constraintTop_toBottomOf="@+id/searchbar_holder"
|
||||||
/>
|
/>
|
||||||
|
|
||||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
</androidx.constraintlayout.widget.ConstraintLayout>
|
6
app/src/main/res/layout/layout_empty.xml
Normal file
6
app/src/main/res/layout/layout_empty.xml
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content">
|
||||||
|
|
||||||
|
</androidx.constraintlayout.widget.ConstraintLayout>
|
26
app/src/main/res/menu/filter_menu.xml
Normal file
26
app/src/main/res/menu/filter_menu.xml
Normal file
@ -0,0 +1,26 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<menu xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
xmlns:app="http://schemas.android.com/apk/res-auto">
|
||||||
|
|
||||||
|
<item
|
||||||
|
android:id="@+id/overflowMenu"
|
||||||
|
android:icon="@drawable/ic_filter"
|
||||||
|
android:title=""
|
||||||
|
app:showAsAction="always">
|
||||||
|
<menu>
|
||||||
|
<item
|
||||||
|
android:id="@+id/settings"
|
||||||
|
android:icon="@drawable/ic_settings"
|
||||||
|
android:title="SETTINGS"
|
||||||
|
app:showAsAction="never" />
|
||||||
|
<item
|
||||||
|
android:id="@+id/about"
|
||||||
|
android:title="ABOUT"
|
||||||
|
app:showAsAction="never" />
|
||||||
|
<item
|
||||||
|
android:id="@+id/exit"
|
||||||
|
android:title="EXIT"
|
||||||
|
app:showAsAction="never" />
|
||||||
|
</menu>
|
||||||
|
</item>
|
||||||
|
</menu>
|
Loading…
x
Reference in New Issue
Block a user