mirror of
https://github.com/recloudstream/cloudstream.git
synced 2024-08-15 01:53:11 +00:00
Focus on last used account and improve layout for TV
This commit is contained in:
parent
3c94fbcb86
commit
25f9174ff1
3 changed files with 30 additions and 4 deletions
|
@ -1,11 +1,14 @@
|
|||
package com.lagradost.cloudstream3.ui.account
|
||||
|
||||
import android.os.Build
|
||||
import android.view.LayoutInflater
|
||||
import android.view.ViewGroup
|
||||
import androidx.annotation.RequiresApi
|
||||
import androidx.core.view.isVisible
|
||||
import androidx.recyclerview.widget.RecyclerView
|
||||
import com.lagradost.cloudstream3.databinding.AccountListItemBinding
|
||||
import com.lagradost.cloudstream3.ui.result.setImage
|
||||
import com.lagradost.cloudstream3.ui.settings.SettingsFragment.Companion.isTrueTvSettings
|
||||
import com.lagradost.cloudstream3.utils.DataStoreHelper
|
||||
|
||||
class AccountAdapter(
|
||||
|
@ -17,9 +20,17 @@ class AccountAdapter(
|
|||
RecyclerView.ViewHolder(binding.root) {
|
||||
|
||||
fun bind(account: DataStoreHelper.Account) {
|
||||
val isLastUsedAccount = account.keyIndex == DataStoreHelper.selectedKeyIndex
|
||||
|
||||
binding.accountName.text = account.name
|
||||
binding.accountImage.setImage(account.image)
|
||||
binding.lockIcon.isVisible = account.lockPin != null
|
||||
binding.outline.isVisible = isLastUsedAccount
|
||||
|
||||
@RequiresApi(Build.VERSION_CODES.O)
|
||||
if (isTrueTvSettings()) {
|
||||
binding.root.isFocusedByDefault = isLastUsedAccount
|
||||
}
|
||||
|
||||
binding.root.setOnClickListener {
|
||||
onItemClick(account)
|
||||
|
|
|
@ -4,10 +4,13 @@ import android.content.Intent
|
|||
import android.os.Bundle
|
||||
import androidx.appcompat.app.AppCompatActivity
|
||||
import androidx.recyclerview.widget.GridLayoutManager
|
||||
import androidx.recyclerview.widget.LinearLayoutManager
|
||||
import androidx.recyclerview.widget.RecyclerView
|
||||
import com.lagradost.cloudstream3.CommonActivity
|
||||
import com.lagradost.cloudstream3.MainActivity
|
||||
import com.lagradost.cloudstream3.databinding.ActivityAccountSelectBinding
|
||||
import com.lagradost.cloudstream3.ui.account.AccountDialog.showPinInputDialog
|
||||
import com.lagradost.cloudstream3.ui.settings.SettingsFragment.Companion.isTvSettings
|
||||
import com.lagradost.cloudstream3.utils.DataStoreHelper
|
||||
import com.lagradost.cloudstream3.utils.DataStoreHelper.getAccounts
|
||||
|
||||
|
@ -17,6 +20,8 @@ class AccountSelectActivity : AppCompatActivity() {
|
|||
|
||||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
super.onCreate(savedInstanceState)
|
||||
CommonActivity.init(this)
|
||||
|
||||
binding = ActivityAccountSelectBinding.inflate(layoutInflater)
|
||||
setContentView(binding.root)
|
||||
|
||||
|
@ -30,7 +35,9 @@ class AccountSelectActivity : AppCompatActivity() {
|
|||
}
|
||||
recyclerView.adapter = adapter
|
||||
|
||||
recyclerView.layoutManager = GridLayoutManager(this, 3)
|
||||
recyclerView.layoutManager = if (isTvSettings()) {
|
||||
LinearLayoutManager(this)
|
||||
} else GridLayoutManager(this, 3)
|
||||
}
|
||||
|
||||
private fun onAccountSelected(selectedAccount: DataStoreHelper.Account) {
|
||||
|
|
|
@ -1,14 +1,14 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
|
||||
<androidx.cardview.widget.CardView
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
<androidx.cardview.widget.CardView xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:id="@+id/card_view"
|
||||
android:layout_width="100dp"
|
||||
android:layout_height="100dp"
|
||||
android:animateLayoutChanges="true"
|
||||
android:backgroundTint="?attr/primaryGrayBackground"
|
||||
android:foreground="?attr/selectableItemBackgroundBorderless"
|
||||
android:foreground="?attr/selectableItemBackground"
|
||||
app:cardCornerRadius="@dimen/rounded_image_radius"
|
||||
android:layout_margin="5dp"
|
||||
android:focusable="true"
|
||||
|
@ -27,6 +27,14 @@
|
|||
android:contentDescription="@string/profile_background_des"
|
||||
android:scaleType="centerCrop" />
|
||||
|
||||
<View
|
||||
android:id="@+id/outline"
|
||||
tools:visibility="visible"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:background="@drawable/outline_card"
|
||||
android:visibility="gone" />
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/lock_icon"
|
||||
android:layout_width="24dp"
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue