mirror of
https://gitlab.futo.org/videostreaming/grayjay.git
synced 2026-05-16 04:52:39 +02:00
add creator unhide page in settings
Changelog: added
This commit is contained in:
@@ -218,6 +218,10 @@
|
||||
android:name=".activities.ManageTabsActivity"
|
||||
android:screenOrientation="sensorPortrait"
|
||||
android:theme="@style/Theme.FutoVideo.NoActionBar" />
|
||||
<activity
|
||||
android:name=".activities.UnhideCreatorsActivity"
|
||||
android:screenOrientation="sensorPortrait"
|
||||
android:theme="@style/Theme.FutoVideo.NoActionBar" />
|
||||
<activity
|
||||
android:name=".activities.QRCaptureActivity"
|
||||
android:screenOrientation="sensorPortrait"
|
||||
|
||||
@@ -12,6 +12,7 @@ import com.futo.platformplayer.activities.PolycentricHomeActivity
|
||||
import com.futo.platformplayer.activities.PolycentricProfileActivity
|
||||
import com.futo.platformplayer.activities.SettingsActivity
|
||||
import com.futo.platformplayer.activities.SyncHomeActivity
|
||||
import com.futo.platformplayer.activities.UnhideCreatorsActivity
|
||||
import com.futo.platformplayer.api.http.ManagedHttpClient
|
||||
import com.futo.platformplayer.constructs.Event0
|
||||
import com.futo.platformplayer.fragment.mainactivity.bottombar.MenuBottomBarFragment
|
||||
@@ -138,8 +139,6 @@ class Settings : FragmentedStorageFileJson() {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
@FormField(R.string.import_data, FieldForm.BUTTON, R.string.import_data_description, -3)
|
||||
@FormFieldButton(R.drawable.ic_move_up)
|
||||
fun import() {
|
||||
@@ -234,6 +233,17 @@ class Settings : FragmentedStorageFileJson() {
|
||||
@FormField(R.string.progress_bar, FieldForm.TOGGLE, R.string.progress_bar_description, 6)
|
||||
var progressBar: Boolean = true;
|
||||
|
||||
@FormField(R.string.unhide_creators, FieldForm.BUTTON, R.string.unhide_creators_description, 6)
|
||||
@FormFieldButton(R.drawable.ic_visibility_off)
|
||||
fun unhideCreators() {
|
||||
try {
|
||||
SettingsActivity.getActivity()?.let {
|
||||
it.startActivity(Intent(it, UnhideCreatorsActivity::class.java));
|
||||
}
|
||||
} catch (e: Throwable) {
|
||||
//Ignored
|
||||
}
|
||||
}
|
||||
|
||||
@FormField(R.string.clear_hidden, FieldForm.BUTTON, R.string.clear_hidden_description, 8)
|
||||
@FormFieldButton(R.drawable.ic_visibility_off)
|
||||
|
||||
@@ -0,0 +1,75 @@
|
||||
package com.futo.platformplayer.activities
|
||||
|
||||
import android.content.Context
|
||||
import android.os.Bundle
|
||||
import android.view.View
|
||||
import android.widget.ImageButton
|
||||
import android.widget.LinearLayout
|
||||
import androidx.appcompat.app.AppCompatActivity
|
||||
import androidx.recyclerview.widget.RecyclerView
|
||||
import com.futo.platformplayer.R
|
||||
import com.futo.platformplayer.setNavigationBarColorAndIcons
|
||||
import com.futo.platformplayer.states.StateApp
|
||||
import com.futo.platformplayer.states.StateMeta
|
||||
import com.futo.platformplayer.views.AnyAdapterView.Companion.asAny
|
||||
import com.futo.platformplayer.views.adapters.viewholders.HiddenCreatorViewHolder
|
||||
import com.futo.platformplayer.views.adapters.viewholders.HiddenCreatorViewHolderData
|
||||
import com.futo.platformplayer.views.buttons.BigButton
|
||||
|
||||
class UnhideCreatorsActivity : AppCompatActivity() {
|
||||
override fun attachBaseContext(newBase: Context?) {
|
||||
super.attachBaseContext(StateApp.instance.getLocaleContext(newBase))
|
||||
}
|
||||
|
||||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
super.onCreate(savedInstanceState)
|
||||
setContentView(R.layout.activity_unhide_creators)
|
||||
setNavigationBarColorAndIcons()
|
||||
|
||||
val backButton: ImageButton = findViewById(R.id.button_back)
|
||||
val zeroState: LinearLayout = findViewById(R.id.zero_state)
|
||||
val returnButton: BigButton = findViewById(R.id.return_button)
|
||||
val recyclerHiddenCreators: RecyclerView = findViewById(R.id.recycler_tabs)
|
||||
|
||||
val items = ArrayList(StateMeta.instance.hiddenCreators.values.map {
|
||||
HiddenCreatorViewHolderData(it)
|
||||
})
|
||||
|
||||
if (items.isEmpty()) {
|
||||
zeroState.visibility = View.VISIBLE
|
||||
recyclerHiddenCreators.visibility = View.GONE
|
||||
}
|
||||
|
||||
returnButton.onClick.subscribe {
|
||||
onBackPressedDispatcher.onBackPressed()
|
||||
}
|
||||
|
||||
recyclerHiddenCreators.asAny<HiddenCreatorViewHolderData, HiddenCreatorViewHolder>(items) {
|
||||
it.onUnhide.subscribe {
|
||||
it.data?.creatorUrl?.let { creatorUrl ->
|
||||
StateMeta.instance.removeHiddenCreator(creatorUrl)
|
||||
|
||||
val position = items.indexOfFirst { item -> item.creatorUrl == creatorUrl }
|
||||
if (position != -1) {
|
||||
items.removeAt(position)
|
||||
recyclerHiddenCreators.adapter!!.notifyItemRemoved(position)
|
||||
}
|
||||
|
||||
if (items.isEmpty()) {
|
||||
zeroState.visibility = View.VISIBLE
|
||||
recyclerHiddenCreators.visibility = View.GONE
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
backButton.setOnClickListener {
|
||||
onBackPressedDispatcher.onBackPressed()
|
||||
}
|
||||
}
|
||||
|
||||
companion object {
|
||||
@Suppress("unused")
|
||||
private const val TAG = "UnhideCreatorsActivity"
|
||||
}
|
||||
}
|
||||
+34
@@ -0,0 +1,34 @@
|
||||
package com.futo.platformplayer.views.adapters.viewholders
|
||||
|
||||
import android.view.LayoutInflater
|
||||
import android.view.ViewGroup
|
||||
import android.widget.ImageButton
|
||||
import android.widget.TextView
|
||||
import com.futo.platformplayer.R
|
||||
import com.futo.platformplayer.constructs.Event0
|
||||
import com.futo.platformplayer.views.adapters.AnyAdapter
|
||||
|
||||
data class HiddenCreatorViewHolderData(val creatorUrl: String)
|
||||
|
||||
class HiddenCreatorViewHolder(viewGroup: ViewGroup) :
|
||||
AnyAdapter.AnyViewHolder<HiddenCreatorViewHolderData>(
|
||||
LayoutInflater.from(viewGroup.context)
|
||||
.inflate(R.layout.list_hidden_creator, viewGroup, false)
|
||||
) {
|
||||
var data: HiddenCreatorViewHolderData? = null
|
||||
private val _creatorLabel: TextView = _view.findViewById(R.id.text_creator_name)
|
||||
|
||||
val onUnhide = Event0()
|
||||
|
||||
init {
|
||||
val unhideButton: ImageButton = _view.findViewById(R.id.button_trash)
|
||||
unhideButton.setOnClickListener {
|
||||
onUnhide.emit()
|
||||
}
|
||||
}
|
||||
|
||||
override fun bind(value: HiddenCreatorViewHolderData) {
|
||||
_creatorLabel.text = value.creatorUrl
|
||||
data = value
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,104 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<LinearLayout 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="match_parent"
|
||||
android:background="@color/black"
|
||||
android:orientation="vertical"
|
||||
android:paddingStart="20dp"
|
||||
android:paddingEnd="20dp">
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:gravity="center_vertical"
|
||||
android:orientation="horizontal"
|
||||
android:paddingTop="20dp"
|
||||
android:paddingBottom="15dp">
|
||||
|
||||
<ImageButton
|
||||
android:id="@+id/button_back"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginEnd="20dp"
|
||||
android:contentDescription="@string/back"
|
||||
android:minWidth="48dp"
|
||||
android:minHeight="48dp"
|
||||
app:srcCompat="@drawable/ic_back_thin_white_16dp" />
|
||||
|
||||
<FrameLayout
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="1">
|
||||
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:fontFamily="@font/inter_extra_light"
|
||||
android:text="@string/unhide_creators"
|
||||
android:textColor="@color/white"
|
||||
android:textSize="24sp" />
|
||||
</FrameLayout>
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
<androidx.recyclerview.widget.RecyclerView
|
||||
android:id="@+id/recycler_tabs"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent" />
|
||||
|
||||
<!-- zero state -->
|
||||
<LinearLayout
|
||||
android:id="@+id/zero_state"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:gravity="center_vertical"
|
||||
android:layout_marginHorizontal="24dp"
|
||||
android:orientation="vertical"
|
||||
android:visibility="gone">
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/icon"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="60dp"
|
||||
android:layout_marginBottom="10dp"
|
||||
android:importantForAccessibility="no"
|
||||
android:scaleType="fitCenter"
|
||||
android:src="@drawable/ic_help" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/text_title"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center"
|
||||
android:layout_marginStart="20dp"
|
||||
android:layout_marginEnd="20dp"
|
||||
android:fontFamily="@font/inter_bold"
|
||||
android:gravity="center"
|
||||
android:text="@string/no_results"
|
||||
android:textColor="@color/white"
|
||||
android:textSize="22dp" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/text_centered"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center"
|
||||
android:layout_marginStart="20dp"
|
||||
android:layout_marginEnd="20dp"
|
||||
android:layout_marginBottom="10dp"
|
||||
android:fontFamily="@font/inter_regular"
|
||||
android:gravity="center"
|
||||
android:text="@string/no_hidden_creators"
|
||||
android:textColor="@color/gray_ac"
|
||||
android:textSize="13dp" />
|
||||
|
||||
<com.futo.platformplayer.views.buttons.BigButton
|
||||
android:id="@+id/return_button"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
app:buttonIcon="@drawable/ic_settings"
|
||||
app:buttonSubText="Go back to settings"
|
||||
app:buttonText="Back" />
|
||||
</LinearLayout>
|
||||
</LinearLayout>
|
||||
@@ -0,0 +1,29 @@
|
||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
android:id="@+id/root"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_margin="5dp"
|
||||
android:gravity="center_vertical"
|
||||
android:orientation="horizontal">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/text_creator_name"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_marginEnd="8dp"
|
||||
android:layout_weight="1"
|
||||
android:fontFamily="@font/inter_light"
|
||||
android:gravity="center_vertical"
|
||||
android:textColor="@color/white"
|
||||
android:textSize="16dp" />
|
||||
|
||||
<ImageButton
|
||||
android:id="@+id/button_trash"
|
||||
android:layout_width="48dp"
|
||||
android:layout_height="48dp"
|
||||
android:contentDescription="@string/cd_button_delete"
|
||||
android:padding="5dp"
|
||||
android:scaleType="fitCenter"
|
||||
app:srcCompat="@drawable/ic_trash" />
|
||||
</LinearLayout>
|
||||
@@ -91,6 +91,7 @@
|
||||
<string name="watch_later">Watch Later</string>
|
||||
<string name="no_results">Nothing to see here</string>
|
||||
<string name="no_results_shorts">The enabled sources do not have any short video results.</string>
|
||||
<string name="no_hidden_creators">There are no hidden creators.</string>
|
||||
<string name="create">Create</string>
|
||||
<string name="ok">OK</string>
|
||||
<string name="yes">Yes</string>
|
||||
@@ -509,6 +510,8 @@
|
||||
<string name="reinstall_embedded_plugins">Reinstall Embedded Plugins</string>
|
||||
<string name="remove_cached_version">Remove Cached Version</string>
|
||||
<string name="remove_the_last_downloaded_version">Remove the last downloaded version</string>
|
||||
<string name="unhide_creators">Manage Hidden Creators</string>
|
||||
<string name="unhide_creators_description">View and selectively unhide previously hidden creators, showing them again</string>
|
||||
<string name="clear_hidden">Clear Hidden</string>
|
||||
<string name="clear_hidden_description">Removes all hidden creators and videos, showing them again</string>
|
||||
<string name="reset_announcements">Reset announcements</string>
|
||||
|
||||
Reference in New Issue
Block a user