diff --git a/app/src/main/java/org/schabi/newpipe/local/subscription/item/ImportSubscriptionsHintPlaceholderItem.kt b/app/src/main/java/org/schabi/newpipe/local/subscription/item/ImportSubscriptionsHintPlaceholderItem.kt index 93b551895..cf0b8c3ff 100644 --- a/app/src/main/java/org/schabi/newpipe/local/subscription/item/ImportSubscriptionsHintPlaceholderItem.kt +++ b/app/src/main/java/org/schabi/newpipe/local/subscription/item/ImportSubscriptionsHintPlaceholderItem.kt @@ -3,14 +3,18 @@ package org.schabi.newpipe.local.subscription.item import android.view.View import com.xwray.groupie.viewbinding.BindableItem import org.schabi.newpipe.R -import org.schabi.newpipe.databinding.ListEmptyViewBinding +import org.schabi.newpipe.databinding.ListEmptyViewSubscriptionsBinding +import org.schabi.newpipe.ui.emptystate.EmptyStateSpec +import org.schabi.newpipe.ui.emptystate.setEmptyStateComposable /** * When there are no subscriptions, show a hint to the user about how to import subscriptions */ -class ImportSubscriptionsHintPlaceholderItem : BindableItem() { +class ImportSubscriptionsHintPlaceholderItem : BindableItem() { override fun getLayout(): Int = R.layout.list_empty_view_subscriptions - override fun bind(viewBinding: ListEmptyViewBinding, position: Int) {} + override fun bind(viewBinding: ListEmptyViewSubscriptionsBinding, position: Int) { + viewBinding.root.setEmptyStateComposable(EmptyStateSpec.NoSubscriptionsHint) + } override fun getSpanSize(spanCount: Int, position: Int): Int = spanCount - override fun initializeViewBinding(view: View) = ListEmptyViewBinding.bind(view) + override fun initializeViewBinding(view: View) = ListEmptyViewSubscriptionsBinding.bind(view) } diff --git a/app/src/main/java/org/schabi/newpipe/settings/SelectChannelFragment.java b/app/src/main/java/org/schabi/newpipe/settings/SelectChannelFragment.java index c566313e3..cbd6b0656 100644 --- a/app/src/main/java/org/schabi/newpipe/settings/SelectChannelFragment.java +++ b/app/src/main/java/org/schabi/newpipe/settings/SelectChannelFragment.java @@ -11,6 +11,7 @@ import android.widget.TextView; import androidx.annotation.NonNull; import androidx.annotation.Nullable; +import androidx.compose.ui.platform.ComposeView; import androidx.fragment.app.DialogFragment; import androidx.recyclerview.widget.LinearLayoutManager; import androidx.recyclerview.widget.RecyclerView; @@ -19,6 +20,8 @@ import org.schabi.newpipe.R; import org.schabi.newpipe.database.subscription.SubscriptionEntity; import org.schabi.newpipe.error.ErrorUtil; import org.schabi.newpipe.local.subscription.SubscriptionManager; +import org.schabi.newpipe.ui.emptystate.EmptyStateSpec; +import org.schabi.newpipe.ui.emptystate.EmptyStateUtil; import org.schabi.newpipe.util.ThemeHelper; import org.schabi.newpipe.util.image.CoilHelper; @@ -57,7 +60,7 @@ public class SelectChannelFragment extends DialogFragment { private OnCancelListener onCancelListener = null; private ProgressBar progressBar; - private TextView emptyView; + private ComposeView emptyView; private RecyclerView recyclerView; private List subscriptions = new Vector<>(); @@ -91,6 +94,9 @@ public class SelectChannelFragment extends DialogFragment { progressBar = v.findViewById(R.id.progressBar); emptyView = v.findViewById(R.id.empty_state_view); + + EmptyStateUtil.setEmptyStateComposable(emptyView, + EmptyStateSpec.Companion.getNoSubscriptions()); progressBar.setVisibility(View.VISIBLE); recyclerView.setVisibility(View.GONE); emptyView.setVisibility(View.GONE); diff --git a/app/src/main/java/org/schabi/newpipe/ui/emptystate/EmptyStateComposable.kt b/app/src/main/java/org/schabi/newpipe/ui/emptystate/EmptyStateComposable.kt index c76dac38c..3e101d760 100644 --- a/app/src/main/java/org/schabi/newpipe/ui/emptystate/EmptyStateComposable.kt +++ b/app/src/main/java/org/schabi/newpipe/ui/emptystate/EmptyStateComposable.kt @@ -13,6 +13,7 @@ import androidx.compose.runtime.Composable import androidx.compose.ui.Alignment import androidx.compose.ui.Modifier import androidx.compose.ui.res.stringResource +import androidx.compose.ui.text.style.TextAlign import androidx.compose.ui.tooling.preview.Preview import androidx.compose.ui.unit.dp import org.schabi.newpipe.R @@ -42,6 +43,7 @@ private fun EmptyStateComposable( Text( text = emojiText, style = MaterialTheme.typography.titleLarge, + textAlign = TextAlign.Center, ) Text( @@ -50,6 +52,7 @@ private fun EmptyStateComposable( .padding(horizontal = 16.dp), text = descriptionText, style = MaterialTheme.typography.bodyMedium, + textAlign = TextAlign.Center, ) } } @@ -120,5 +123,17 @@ data class EmptyStateSpec( emojiText = { "(╥﹏╥)" }, descriptionText = { stringResource(id = R.string.no_playlist_bookmarked_yet) }, ) + + val NoSubscriptionsHint = + EmptyStateSpec( + modifier = { it }, + emojiText = { "(꩜ᯅ꩜)" }, + descriptionText = { stringResource(id = R.string.import_subscriptions_hint) }, + ) + + val NoSubscriptions = + NoSubscriptionsHint.copy( + descriptionText = { stringResource(id = R.string.no_channel_subscribed_yet) }, + ) } } diff --git a/app/src/main/java/us/shandian/giga/ui/fragment/MissionsFragment.java b/app/src/main/java/us/shandian/giga/ui/fragment/MissionsFragment.java index 690ed4a97..ad9a3b7cd 100644 --- a/app/src/main/java/us/shandian/giga/ui/fragment/MissionsFragment.java +++ b/app/src/main/java/us/shandian/giga/ui/fragment/MissionsFragment.java @@ -22,6 +22,7 @@ import androidx.activity.result.ActivityResultLauncher; import androidx.activity.result.contract.ActivityResultContracts.StartActivityForResult; import androidx.annotation.NonNull; import androidx.appcompat.app.AlertDialog; +import androidx.compose.ui.platform.ComposeView; import androidx.fragment.app.Fragment; import androidx.preference.PreferenceManager; import androidx.recyclerview.widget.GridLayoutManager; @@ -34,6 +35,7 @@ import org.schabi.newpipe.R; import org.schabi.newpipe.settings.NewPipeSettings; import org.schabi.newpipe.streams.io.NoFileManagerSafeGuard; import org.schabi.newpipe.streams.io.StoredFileHelper; +import org.schabi.newpipe.ui.emptystate.EmptyStateUtil; import org.schabi.newpipe.util.FilePickerActivityHelper; import java.io.File; @@ -108,7 +110,8 @@ public class MissionsFragment extends Fragment { mContext.bindService(new Intent(mContext, DownloadManagerService.class), mConnection, Context.BIND_AUTO_CREATE); // Views - mEmpty = v.findViewById(R.id.list_empty_view); + mEmpty = v.findViewById(R.id.empty_state_view); + EmptyStateUtil.setEmptyStateComposable((ComposeView) mEmpty); mList = v.findViewById(R.id.mission_recycler); // Init layouts managers diff --git a/app/src/main/res/layout/list_empty_view.xml b/app/src/main/res/layout/list_empty_view.xml deleted file mode 100644 index a25042aed..000000000 --- a/app/src/main/res/layout/list_empty_view.xml +++ /dev/null @@ -1,25 +0,0 @@ - - - - - - - diff --git a/app/src/main/res/layout/list_empty_view_subscriptions.xml b/app/src/main/res/layout/list_empty_view_subscriptions.xml index 74a5eced4..ad1820199 100644 --- a/app/src/main/res/layout/list_empty_view_subscriptions.xml +++ b/app/src/main/res/layout/list_empty_view_subscriptions.xml @@ -1,25 +1,6 @@ - - - - - - + xmlns:android="http://schemas.android.com/apk/res/android" /> diff --git a/app/src/main/res/layout/missions.xml b/app/src/main/res/layout/missions.xml index 641e28693..291d19306 100644 --- a/app/src/main/res/layout/missions.xml +++ b/app/src/main/res/layout/missions.xml @@ -3,10 +3,11 @@ android:layout_height="match_parent" android:orientation="vertical"> - + - - + android:layout_margin="10dp" /> + android:layout_margin="10dp" />