Stick info header when selecting subscriptions in the feed group dialog
- Avoid creating plural translation by using a different wording
This commit is contained in:
parent
3f32573638
commit
2c783ff911
|
@ -29,7 +29,6 @@ import org.schabi.newpipe.database.subscription.SubscriptionEntity
|
|||
import org.schabi.newpipe.local.subscription.FeedGroupIcon
|
||||
import org.schabi.newpipe.local.subscription.dialog.FeedGroupDialogViewModel.FeedDialogEvent
|
||||
import org.schabi.newpipe.local.subscription.item.EmptyPlaceholderItem
|
||||
import org.schabi.newpipe.local.subscription.item.HeaderTextSideItem
|
||||
import org.schabi.newpipe.local.subscription.item.PickerIconItem
|
||||
import org.schabi.newpipe.local.subscription.item.PickerSubscriptionItem
|
||||
import org.schabi.newpipe.util.AnimationUtils.animateView
|
||||
|
@ -82,7 +81,7 @@ class FeedGroupDialog : DialogFragment() {
|
|||
super.onSaveInstanceState(outState)
|
||||
|
||||
iconsListState = icon_selector.layoutManager?.onSaveInstanceState()
|
||||
subscriptionsListState = subscriptions_selector.layoutManager?.onSaveInstanceState()
|
||||
subscriptionsListState = subscriptions_selector_list.layoutManager?.onSaveInstanceState()
|
||||
|
||||
Icepick.saveInstanceState(this, outState)
|
||||
}
|
||||
|
@ -185,9 +184,7 @@ class FeedGroupDialog : DialogFragment() {
|
|||
|
||||
val selectedCountText = getString(R.string.feed_group_dialog_selection_count, this.selectedSubscriptions.size)
|
||||
selected_subscription_count_view.text = selectedCountText
|
||||
|
||||
val headerInfoItem = HeaderTextSideItem(getString(R.string.tab_subscriptions), selectedCountText)
|
||||
groupAdapter.add(headerInfoItem)
|
||||
subscriptions_selector_header_info.text = selectedCountText
|
||||
|
||||
Section().apply {
|
||||
addAll(subscriptions.map {
|
||||
|
@ -199,16 +196,11 @@ class FeedGroupDialog : DialogFragment() {
|
|||
groupAdapter.add(this)
|
||||
}
|
||||
|
||||
subscriptions_selector.apply {
|
||||
if (useGridLayout) {
|
||||
layoutManager = GridLayoutManager(requireContext(), groupAdapter.spanCount, RecyclerView.VERTICAL, false).apply {
|
||||
spanSizeLookup = object : GridLayoutManager.SpanSizeLookup() {
|
||||
override fun getSpanSize(position: Int) =
|
||||
if (position == 0) 4 else 1
|
||||
}
|
||||
}
|
||||
subscriptions_selector_list.apply {
|
||||
layoutManager = if (useGridLayout) {
|
||||
GridLayoutManager(requireContext(), groupAdapter.spanCount, RecyclerView.VERTICAL, false)
|
||||
} else {
|
||||
layoutManager = LinearLayoutManager(requireContext(), RecyclerView.VERTICAL, false)
|
||||
LinearLayoutManager(requireContext(), RecyclerView.VERTICAL, false)
|
||||
}
|
||||
|
||||
adapter = groupAdapter
|
||||
|
@ -237,14 +229,13 @@ class FeedGroupDialog : DialogFragment() {
|
|||
|
||||
val updateSelectedCountText = getString(R.string.feed_group_dialog_selection_count, this.selectedSubscriptions.size)
|
||||
selected_subscription_count_view.text = updateSelectedCountText
|
||||
headerInfoItem.infoText = updateSelectedCountText
|
||||
headerInfoItem.notifyChanged(HeaderTextSideItem.UPDATE_INFO)
|
||||
subscriptions_selector_header_info.text = updateSelectedCountText
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
select_channel_button.setOnClickListener {
|
||||
subscriptions_selector.scrollToPosition(0)
|
||||
subscriptions_selector_list.scrollToPosition(0)
|
||||
showSubscriptionsPicker()
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,37 +0,0 @@
|
|||
package org.schabi.newpipe.local.subscription.item
|
||||
|
||||
import android.view.View.OnClickListener
|
||||
import com.xwray.groupie.kotlinandroidextensions.Item
|
||||
import com.xwray.groupie.kotlinandroidextensions.GroupieViewHolder
|
||||
import kotlinx.android.synthetic.main.header_with_text_item.*
|
||||
import org.schabi.newpipe.R
|
||||
|
||||
class HeaderTextSideItem(
|
||||
val title: String,
|
||||
var infoText: String? = null,
|
||||
private val onClickListener: (() -> Unit)? = null
|
||||
) : Item() {
|
||||
|
||||
companion object {
|
||||
const val UPDATE_INFO = 123
|
||||
}
|
||||
|
||||
override fun getLayout(): Int = R.layout.header_with_text_item
|
||||
|
||||
override fun bind(viewHolder: GroupieViewHolder, position: Int, payloads: MutableList<Any>) {
|
||||
if (payloads.contains(UPDATE_INFO)) {
|
||||
viewHolder.header_info.text = infoText
|
||||
return
|
||||
}
|
||||
|
||||
super.bind(viewHolder, position, payloads)
|
||||
}
|
||||
|
||||
override fun bind(viewHolder: GroupieViewHolder, position: Int) {
|
||||
viewHolder.header_title.text = title
|
||||
viewHolder.header_info.text = infoText
|
||||
|
||||
val listener: OnClickListener? = if (onClickListener != null) OnClickListener { onClickListener.invoke() } else null
|
||||
viewHolder.root.setOnClickListener(listener)
|
||||
}
|
||||
}
|
|
@ -15,8 +15,7 @@
|
|||
android:minHeight="150dp"
|
||||
android:orientation="vertical"
|
||||
android:padding="8dp"
|
||||
android:visibility="gone"
|
||||
tools:visibility="visible">
|
||||
android:visibility="gone">
|
||||
|
||||
<ImageButton
|
||||
android:id="@+id/icon_preview"
|
||||
|
@ -34,10 +33,10 @@
|
|||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginStart="8dp"
|
||||
android:paddingTop="6dp"
|
||||
android:paddingBottom="6dp"
|
||||
android:gravity="center_vertical"
|
||||
android:hint="@string/feed_group_dialog_name_input"
|
||||
android:paddingTop="6dp"
|
||||
android:paddingBottom="6dp"
|
||||
app:errorEnabled="true"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toEndOf="@+id/icon_preview"
|
||||
|
@ -93,19 +92,56 @@
|
|||
android:paddingBottom="16dp"
|
||||
android:visibility="gone"
|
||||
tools:layoutManager="androidx.recyclerview.widget.GridLayoutManager"
|
||||
tools:listItem="@layout/item_icon_picker"
|
||||
tools:listitem="@layout/picker_icon_item"
|
||||
tools:spanCount="7" />
|
||||
|
||||
<androidx.recyclerview.widget.RecyclerView
|
||||
<LinearLayout
|
||||
android:id="@+id/subscriptions_selector"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="0dp"
|
||||
android:layout_weight="1"
|
||||
android:orientation="vertical"
|
||||
android:visibility="gone"
|
||||
tools:itemCount="200"
|
||||
tools:layoutManager="androidx.recyclerview.widget.GridLayoutManager"
|
||||
tools:listItem="@layout/item_icon_picker"
|
||||
tools:spanCount="4" />
|
||||
tools:visibility="visible">
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="horizontal"
|
||||
android:paddingLeft="16dp"
|
||||
android:paddingTop="12dp"
|
||||
android:paddingRight="16dp"
|
||||
android:paddingBottom="12dp">
|
||||
|
||||
<TextView
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="1"
|
||||
android:gravity="start|center_vertical"
|
||||
android:text="@string/tab_subscriptions"
|
||||
android:textColor="?android:attr/textColorPrimary"
|
||||
android:textSize="16sp"
|
||||
android:textStyle="bold" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/subscriptions_selector_header_info"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:gravity="start|center_vertical"
|
||||
android:textColor="?android:attr/textColorPrimary"
|
||||
android:textSize="12sp"
|
||||
tools:text="1 selected" />
|
||||
</LinearLayout>
|
||||
|
||||
<androidx.recyclerview.widget.RecyclerView
|
||||
android:id="@+id/subscriptions_selector_list"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
tools:itemCount="200"
|
||||
tools:layoutManager="androidx.recyclerview.widget.GridLayoutManager"
|
||||
tools:listitem="@layout/picker_subscription_item"
|
||||
tools:spanCount="4" />
|
||||
</LinearLayout>
|
||||
|
||||
<View
|
||||
android:id="@+id/separator"
|
||||
|
|
|
@ -606,7 +606,7 @@
|
|||
<string name="feed_notification_loading">Loading feed…</string>
|
||||
<string name="feed_processing_message">Processing feed…</string>
|
||||
<string name="feed_group_dialog_select_subscriptions">Select subscriptions</string>
|
||||
<string name="feed_group_dialog_selection_count">%d selected</string>
|
||||
<string name="feed_group_dialog_selection_count">Selected: %d</string>
|
||||
<string name="feed_group_dialog_empty_selection">No subscription selected</string>
|
||||
<string name="feed_group_dialog_empty_name">Empty group name</string>
|
||||
<string name="feed_group_dialog_name_input">Name</string>
|
||||
|
|
Loading…
Reference in New Issue