mirror of
https://github.com/libre-tube/LibreTube.git
synced 2025-04-29 00:10:32 +05:30
Redesigned searchbar and login/register fragment;Fixed subscribe button color change on action.
This commit is contained in:
parent
fca1048983
commit
db3c452d0a
@ -2,17 +2,18 @@ package com.github.libretube
|
|||||||
|
|
||||||
|
|
||||||
import android.annotation.SuppressLint
|
import android.annotation.SuppressLint
|
||||||
|
import android.app.Activity
|
||||||
import android.content.Context
|
import android.content.Context
|
||||||
import android.os.Bundle
|
import android.os.Bundle
|
||||||
import android.util.Log
|
import android.util.Log
|
||||||
import androidx.fragment.app.Fragment
|
import android.util.TypedValue
|
||||||
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.ScrollView
|
import android.widget.ScrollView
|
||||||
import android.widget.TextView
|
import android.widget.TextView
|
||||||
import android.widget.Toast
|
import androidx.fragment.app.Fragment
|
||||||
import androidx.lifecycle.lifecycleScope
|
import androidx.lifecycle.lifecycleScope
|
||||||
import androidx.recyclerview.widget.LinearLayoutManager
|
import androidx.recyclerview.widget.LinearLayoutManager
|
||||||
import androidx.recyclerview.widget.RecyclerView
|
import androidx.recyclerview.widget.RecyclerView
|
||||||
@ -95,23 +96,37 @@ class ChannelFragment : Fragment() {
|
|||||||
Log.e(TAG, "HttpException, unexpected response")
|
Log.e(TAG, "HttpException, unexpected response")
|
||||||
return@launchWhenCreated
|
return@launchWhenCreated
|
||||||
}
|
}
|
||||||
|
val colorPrimary = TypedValue()
|
||||||
|
(context as Activity).theme.resolveAttribute(
|
||||||
|
android.R.attr.colorPrimary,
|
||||||
|
colorPrimary,
|
||||||
|
true)
|
||||||
|
|
||||||
|
val ColorText = TypedValue()
|
||||||
|
(context as Activity).theme.resolveAttribute(
|
||||||
|
R.attr.colorOnSurface,
|
||||||
|
ColorText,
|
||||||
|
true)
|
||||||
|
|
||||||
runOnUiThread {
|
runOnUiThread {
|
||||||
if (response.subscribed==true){
|
if (response.subscribed==true){
|
||||||
isSubscribed=true
|
isSubscribed=true
|
||||||
button.text=getString(R.string.unsubscribe)
|
button.text=getString(R.string.unsubscribe)
|
||||||
button.setTextColor(R.attr.colorPrimaryDark)
|
button.setTextColor(ColorText.data)
|
||||||
|
|
||||||
}
|
}
|
||||||
if(response.subscribed!=null){
|
if(response.subscribed!=null){
|
||||||
button.setOnClickListener {
|
button.setOnClickListener {
|
||||||
if(isSubscribed){
|
if(isSubscribed){
|
||||||
unsubscribe()
|
unsubscribe()
|
||||||
button.text=getString(R.string.subscribe)
|
button.text=getString(R.string.subscribe)
|
||||||
button.setTextColor(resources.getColor(R.color.md_theme_light_primary))
|
button.setTextColor(colorPrimary.data)
|
||||||
|
|
||||||
|
|
||||||
}else{
|
}else{
|
||||||
subscribe()
|
subscribe()
|
||||||
button.text=getString(R.string.unsubscribe)
|
button.text=getString(R.string.unsubscribe)
|
||||||
button.setTextColor(R.attr.colorPrimaryDark)
|
button.setTextColor(ColorText.data)
|
||||||
}
|
}
|
||||||
}}
|
}}
|
||||||
}
|
}
|
||||||
|
@ -26,6 +26,7 @@ import kotlin.math.abs
|
|||||||
import com.google.android.exoplayer2.util.MimeTypes
|
import com.google.android.exoplayer2.util.MimeTypes
|
||||||
import com.google.common.collect.ImmutableList
|
import com.google.common.collect.ImmutableList
|
||||||
import android.app.ActionBar
|
import android.app.ActionBar
|
||||||
|
import android.app.Activity
|
||||||
import android.content.Context
|
import android.content.Context
|
||||||
import android.content.DialogInterface
|
import android.content.DialogInterface
|
||||||
import android.content.Intent
|
import android.content.Intent
|
||||||
@ -51,6 +52,7 @@ import android.graphics.drawable.ColorDrawable
|
|||||||
import android.os.Build
|
import android.os.Build
|
||||||
import android.text.Html
|
import android.text.Html
|
||||||
import android.util.Log
|
import android.util.Log
|
||||||
|
import android.util.TypedValue
|
||||||
import androidx.appcompat.app.AlertDialog
|
import androidx.appcompat.app.AlertDialog
|
||||||
import androidx.constraintlayout.widget.ConstraintLayout
|
import androidx.constraintlayout.widget.ConstraintLayout
|
||||||
import androidx.core.os.bundleOf
|
import androidx.core.os.bundleOf
|
||||||
@ -412,23 +414,35 @@ class PlayerFragment : Fragment() {
|
|||||||
Log.e(TAG, "HttpException, unexpected response")
|
Log.e(TAG, "HttpException, unexpected response")
|
||||||
return@launchWhenCreated
|
return@launchWhenCreated
|
||||||
}
|
}
|
||||||
|
val colorPrimary = TypedValue()
|
||||||
|
(context as Activity).theme.resolveAttribute(
|
||||||
|
android.R.attr.colorPrimary,
|
||||||
|
colorPrimary,
|
||||||
|
true)
|
||||||
|
|
||||||
|
val ColorText = TypedValue()
|
||||||
|
(context as Activity).theme.resolveAttribute(
|
||||||
|
R.attr.colorOnSurface,
|
||||||
|
ColorText,
|
||||||
|
true)
|
||||||
|
|
||||||
runOnUiThread {
|
runOnUiThread {
|
||||||
if (response.subscribed==true){
|
if (response.subscribed==true){
|
||||||
isSubscribed=true
|
isSubscribed=true
|
||||||
button.text=getString(R.string.unsubscribe)
|
button.text=getString(R.string.unsubscribe)
|
||||||
button.setTextColor(R.attr.colorPrimaryDark)
|
button.setTextColor(ColorText.data)
|
||||||
}
|
}
|
||||||
if(response.subscribed!=null){
|
if(response.subscribed!=null){
|
||||||
button.setOnClickListener {
|
button.setOnClickListener {
|
||||||
if(isSubscribed){
|
if(isSubscribed){
|
||||||
unsubscribe(channel_id)
|
unsubscribe(channel_id)
|
||||||
button.text=getString(R.string.subscribe)
|
button.text=getString(R.string.subscribe)
|
||||||
button.setTextColor(resources.getColor(R.color.md_theme_light_primary))
|
button.setTextColor(colorPrimary.data)
|
||||||
|
|
||||||
}else{
|
}else{
|
||||||
subscribe(channel_id)
|
subscribe(channel_id)
|
||||||
button.text=getString(R.string.unsubscribe)
|
button.text=getString(R.string.unsubscribe)
|
||||||
button.setTextColor(R.attr.colorPrimaryDark)
|
button.setTextColor(colorPrimary.data)
|
||||||
}
|
}
|
||||||
}}
|
}}
|
||||||
}
|
}
|
||||||
|
@ -1,8 +1,12 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||||
android:orientation="vertical"
|
android:orientation="vertical"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content">
|
android:layout_height="wrap_content"
|
||||||
|
>
|
||||||
|
|
||||||
|
|
||||||
<ImageView
|
<ImageView
|
||||||
android:src="@drawable/ic_libretube_foreground"
|
android:src="@drawable/ic_libretube_foreground"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
@ -10,27 +14,48 @@
|
|||||||
android:scaleType="center"
|
android:scaleType="center"
|
||||||
android:background="#CD5757"
|
android:background="#CD5757"
|
||||||
android:contentDescription="@string/app_name" />
|
android:contentDescription="@string/app_name" />
|
||||||
<EditText
|
|
||||||
android:id="@+id/username"
|
<com.google.android.material.textfield.TextInputLayout
|
||||||
android:inputType="textShortMessage"
|
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_marginTop="16dp"
|
android:layout_marginTop="16dp"
|
||||||
android:layout_marginLeft="4dp"
|
android:layout_marginLeft="7dp"
|
||||||
android:layout_marginRight="4dp"
|
android:layout_marginRight="7dp"
|
||||||
android:layout_marginBottom="4dp"
|
android:layout_marginBottom="4dp"
|
||||||
android:hint="@string/username" />
|
>
|
||||||
<EditText
|
|
||||||
android:id="@+id/password"
|
<com.google.android.material.textfield.TextInputEditText
|
||||||
android:inputType="textPassword"
|
android:id="@+id/username"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_marginTop="4dp"
|
android:hint="@string/username"
|
||||||
android:layout_marginLeft="4dp"
|
android:inputType="text"
|
||||||
android:layout_marginRight="4dp"
|
android:padding="12dp" />
|
||||||
android:layout_marginBottom="16dp"
|
</com.google.android.material.textfield.TextInputLayout>
|
||||||
android:fontFamily="sans-serif"
|
|
||||||
android:hint="@string/password"/>
|
<com.google.android.material.textfield.TextInputLayout
|
||||||
|
style="@style/Widget.MaterialComponents.TextInputLayout.OutlinedBox"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
app:hintEnabled="false"
|
||||||
|
android:layout_marginTop="16dp"
|
||||||
|
android:layout_marginLeft="7dp"
|
||||||
|
android:layout_marginRight="7dp"
|
||||||
|
android:layout_marginBottom="4dp"
|
||||||
|
>
|
||||||
|
|
||||||
|
<com.google.android.material.textfield.TextInputEditText
|
||||||
|
android:id="@+id/password"
|
||||||
|
android:inputType="textPassword"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:hint="@string/password"
|
||||||
|
android:padding="12dp" />
|
||||||
|
</com.google.android.material.textfield.TextInputLayout>
|
||||||
|
|
||||||
|
|
||||||
<LinearLayout
|
<LinearLayout
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
@ -51,4 +76,5 @@
|
|||||||
android:padding="8dp"
|
android:padding="8dp"
|
||||||
android:layout_margin="8dp"/>
|
android:layout_margin="8dp"/>
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
|
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
|
@ -4,48 +4,44 @@
|
|||||||
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.textfield.TextInputLayout
|
<com.google.android.material.card.MaterialCardView
|
||||||
android:id="@+id/outlinedTextField"
|
|
||||||
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_margin="20dp"
|
android:id="@+id/outlinedTextField"
|
||||||
app:hintEnabled="false"
|
style="@style/Widget.Material3.CardView.Filled"
|
||||||
app:boxCornerRadiusBottomEnd="20dp"
|
|
||||||
app:boxCornerRadiusBottomStart="20dp"
|
|
||||||
app:boxCornerRadiusTopEnd="20dp"
|
|
||||||
app:boxCornerRadiusTopStart="20dp"
|
|
||||||
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"
|
||||||
<AutoCompleteTextView
|
>
|
||||||
android:id="@+id/autoCompleteTextView"
|
<com.google.android.material.textfield.TextInputLayout
|
||||||
|
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:hint="Search"
|
app:hintEnabled="false"
|
||||||
android:imeOptions="actionSearch"
|
android:layout_marginRight="20dp"
|
||||||
android:inputType="text"
|
android:layout_marginLeft="20dp"
|
||||||
android:maxLines="1"
|
android:background="@android:color/transparent"
|
||||||
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:hint="Search"
|
||||||
|
android:imeOptions="actionSearch"
|
||||||
|
android:inputType="text"
|
||||||
|
android:maxLines="1"
|
||||||
|
android:background="@android:color/transparent"
|
||||||
|
android:padding="12dp" />
|
||||||
|
|
||||||
|
</com.google.android.material.textfield.TextInputLayout>
|
||||||
|
|
||||||
|
</com.google.android.material.card.MaterialCardView>
|
||||||
|
|
||||||
<!-- <com.google.android.material.textfield.MaterialAutoCompleteTextView-->
|
|
||||||
<!-- android:id="@+id/autoCompleteTextView"-->
|
|
||||||
<!-- android:layout_width="0dp"-->
|
|
||||||
<!-- android:layout_height="wrap_content"-->
|
|
||||||
<!-- android:layout_marginTop="7dp"-->
|
|
||||||
<!-- android:hint="@string/search_hint"-->
|
|
||||||
<!-- android:imeOptions="actionSearch"-->
|
|
||||||
<!-- android:inputType="text"-->
|
|
||||||
<!-- android:maxLines="1"-->
|
|
||||||
<!-- android:minHeight="48dp"-->
|
|
||||||
<!-- app:layout_constraintEnd_toEndOf="parent"-->
|
|
||||||
<!-- app:layout_constraintStart_toStartOf="parent"-->
|
|
||||||
<!-- app:layout_constraintTop_toTopOf="parent" />-->
|
|
||||||
|
|
||||||
|
|
||||||
<androidx.recyclerview.widget.RecyclerView
|
<androidx.recyclerview.widget.RecyclerView
|
||||||
|
Loading…
x
Reference in New Issue
Block a user