Skip to content

Commit 404d9f3

Browse files
committed
Use empty state view in a few more places
1 parent 55e4014 commit 404d9f3

9 files changed

Lines changed: 44 additions & 63 deletions

File tree

app/src/main/java/org/schabi/newpipe/local/subscription/item/ImportSubscriptionsHintPlaceholderItem.kt

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,18 @@ package org.schabi.newpipe.local.subscription.item
33
import android.view.View
44
import com.xwray.groupie.viewbinding.BindableItem
55
import org.schabi.newpipe.R
6-
import org.schabi.newpipe.databinding.ListEmptyViewBinding
6+
import org.schabi.newpipe.databinding.ListEmptyViewSubscriptionsBinding
7+
import org.schabi.newpipe.ui.emptystate.EmptyStateSpec
8+
import org.schabi.newpipe.ui.emptystate.setEmptyStateComposable
79

810
/**
911
* When there are no subscriptions, show a hint to the user about how to import subscriptions
1012
*/
11-
class ImportSubscriptionsHintPlaceholderItem : BindableItem<ListEmptyViewBinding>() {
13+
class ImportSubscriptionsHintPlaceholderItem : BindableItem<ListEmptyViewSubscriptionsBinding>() {
1214
override fun getLayout(): Int = R.layout.list_empty_view_subscriptions
13-
override fun bind(viewBinding: ListEmptyViewBinding, position: Int) {}
15+
override fun bind(viewBinding: ListEmptyViewSubscriptionsBinding, position: Int) {
16+
viewBinding.root.setEmptyStateComposable(EmptyStateSpec.NoSubscriptionsHint)
17+
}
1418
override fun getSpanSize(spanCount: Int, position: Int): Int = spanCount
15-
override fun initializeViewBinding(view: View) = ListEmptyViewBinding.bind(view)
19+
override fun initializeViewBinding(view: View) = ListEmptyViewSubscriptionsBinding.bind(view)
1620
}

app/src/main/java/org/schabi/newpipe/settings/SelectChannelFragment.java

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111

1212
import androidx.annotation.NonNull;
1313
import androidx.annotation.Nullable;
14+
import androidx.compose.ui.platform.ComposeView;
1415
import androidx.fragment.app.DialogFragment;
1516
import androidx.recyclerview.widget.LinearLayoutManager;
1617
import androidx.recyclerview.widget.RecyclerView;
@@ -19,6 +20,8 @@
1920
import org.schabi.newpipe.database.subscription.SubscriptionEntity;
2021
import org.schabi.newpipe.error.ErrorUtil;
2122
import org.schabi.newpipe.local.subscription.SubscriptionManager;
23+
import org.schabi.newpipe.ui.emptystate.EmptyStateSpec;
24+
import org.schabi.newpipe.ui.emptystate.EmptyStateUtil;
2225
import org.schabi.newpipe.util.ThemeHelper;
2326
import org.schabi.newpipe.util.image.CoilHelper;
2427

@@ -57,7 +60,7 @@ public class SelectChannelFragment extends DialogFragment {
5760
private OnCancelListener onCancelListener = null;
5861

5962
private ProgressBar progressBar;
60-
private TextView emptyView;
63+
private ComposeView emptyView;
6164
private RecyclerView recyclerView;
6265

6366
private List<SubscriptionEntity> subscriptions = new Vector<>();
@@ -91,6 +94,9 @@ public View onCreateView(@NonNull final LayoutInflater inflater, final ViewGroup
9194

9295
progressBar = v.findViewById(R.id.progressBar);
9396
emptyView = v.findViewById(R.id.empty_state_view);
97+
98+
EmptyStateUtil.setEmptyStateComposable(emptyView,
99+
EmptyStateSpec.Companion.getNoSubscriptions());
94100
progressBar.setVisibility(View.VISIBLE);
95101
recyclerView.setVisibility(View.GONE);
96102
emptyView.setVisibility(View.GONE);

app/src/main/java/org/schabi/newpipe/ui/emptystate/EmptyStateComposable.kt

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ import androidx.compose.runtime.Composable
1313
import androidx.compose.ui.Alignment
1414
import androidx.compose.ui.Modifier
1515
import androidx.compose.ui.res.stringResource
16+
import androidx.compose.ui.text.style.TextAlign
1617
import androidx.compose.ui.tooling.preview.Preview
1718
import androidx.compose.ui.unit.dp
1819
import org.schabi.newpipe.R
@@ -42,6 +43,7 @@ private fun EmptyStateComposable(
4243
Text(
4344
text = emojiText,
4445
style = MaterialTheme.typography.titleLarge,
46+
textAlign = TextAlign.Center,
4547
)
4648

4749
Text(
@@ -50,6 +52,7 @@ private fun EmptyStateComposable(
5052
.padding(horizontal = 16.dp),
5153
text = descriptionText,
5254
style = MaterialTheme.typography.bodyMedium,
55+
textAlign = TextAlign.Center,
5356
)
5457
}
5558
}
@@ -120,5 +123,17 @@ data class EmptyStateSpec(
120123
emojiText = { "(╥﹏╥)" },
121124
descriptionText = { stringResource(id = R.string.no_playlist_bookmarked_yet) },
122125
)
126+
127+
val NoSubscriptionsHint =
128+
EmptyStateSpec(
129+
modifier = { it },
130+
emojiText = { "(꩜ᯅ꩜)" },
131+
descriptionText = { stringResource(id = R.string.import_subscriptions_hint) },
132+
)
133+
134+
val NoSubscriptions =
135+
NoSubscriptionsHint.copy(
136+
descriptionText = { stringResource(id = R.string.no_channel_subscribed_yet) },
137+
)
123138
}
124139
}

app/src/main/java/us/shandian/giga/ui/fragment/MissionsFragment.java

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
import androidx.activity.result.contract.ActivityResultContracts.StartActivityForResult;
2323
import androidx.annotation.NonNull;
2424
import androidx.appcompat.app.AlertDialog;
25+
import androidx.compose.ui.platform.ComposeView;
2526
import androidx.fragment.app.Fragment;
2627
import androidx.preference.PreferenceManager;
2728
import androidx.recyclerview.widget.GridLayoutManager;
@@ -34,6 +35,7 @@
3435
import org.schabi.newpipe.settings.NewPipeSettings;
3536
import org.schabi.newpipe.streams.io.NoFileManagerSafeGuard;
3637
import org.schabi.newpipe.streams.io.StoredFileHelper;
38+
import org.schabi.newpipe.ui.emptystate.EmptyStateUtil;
3739
import org.schabi.newpipe.util.FilePickerActivityHelper;
3840

3941
import java.io.File;
@@ -108,7 +110,8 @@ public View onCreateView(@NonNull LayoutInflater inflater, ViewGroup container,
108110
mContext.bindService(new Intent(mContext, DownloadManagerService.class), mConnection, Context.BIND_AUTO_CREATE);
109111

110112
// Views
111-
mEmpty = v.findViewById(R.id.list_empty_view);
113+
mEmpty = v.findViewById(R.id.empty_state_view);
114+
EmptyStateUtil.setEmptyStateComposable((ComposeView) mEmpty);
112115
mList = v.findViewById(R.id.mission_recycler);
113116

114117
// Init layouts managers

app/src/main/res/layout/list_empty_view.xml

Lines changed: 0 additions & 25 deletions
This file was deleted.
Lines changed: 2 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,6 @@
11
<?xml version="1.0" encoding="utf-8"?>
2-
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
3-
xmlns:tools="http://schemas.android.com/tools"
2+
<androidx.compose.ui.platform.ComposeView
43
android:layout_width="match_parent"
54
android:layout_height="wrap_content"
6-
android:gravity="center"
75
android:minHeight="128dp"
8-
android:orientation="vertical">
9-
10-
<org.schabi.newpipe.views.NewPipeTextView
11-
android:layout_width="wrap_content"
12-
android:layout_height="wrap_content"
13-
android:text="¯\\_(ツ)_/¯"
14-
android:textAppearance="?android:attr/textAppearanceLarge"
15-
tools:ignore="HardcodedText" />
16-
17-
<org.schabi.newpipe.views.NewPipeTextView
18-
android:layout_width="wrap_content"
19-
android:layout_height="wrap_content"
20-
android:layout_gravity="center"
21-
android:layout_marginTop="6dp"
22-
android:gravity="center"
23-
android:paddingHorizontal="16dp"
24-
android:text="@string/import_subscriptions_hint" />
25-
</LinearLayout>
6+
xmlns:android="http://schemas.android.com/apk/res/android" />

app/src/main/res/layout/missions.xml

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,11 @@
33
android:layout_height="match_parent"
44
android:orientation="vertical">
55

6-
<include
7-
android:id="@+id/list_empty_view"
8-
layout="@layout/list_empty_view"
9-
android:visibility="gone" />
6+
<androidx.compose.ui.platform.ComposeView
7+
android:id="@+id/empty_state_view"
8+
android:layout_width="match_parent"
9+
android:layout_height="wrap_content"
10+
android:minHeight="128dp" />
1011

1112
<androidx.recyclerview.widget.RecyclerView
1213
android:id="@+id/mission_recycler"

app/src/main/res/layout/select_channel_fragment.xml

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -24,14 +24,11 @@
2424
android:layout_height="wrap_content"
2525
tools:listitem="@layout/select_channel_item" />
2626

27-
28-
<org.schabi.newpipe.views.NewPipeTextView
27+
<androidx.compose.ui.platform.ComposeView
2928
android:id="@+id/empty_state_view"
3029
android:layout_width="match_parent"
3130
android:layout_height="wrap_content"
32-
android:layout_margin="10dp"
33-
android:text="@string/no_channel_subscribed_yet"
34-
android:textAppearance="?android:attr/textAppearanceListItem" />
31+
android:layout_margin="10dp" />
3532

3633
<ProgressBar
3734
android:id="@+id/progressBar"

app/src/main/res/layout/select_playlist_fragment.xml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,7 @@
3030
android:id="@+id/empty_state_view"
3131
android:layout_width="match_parent"
3232
android:layout_height="wrap_content"
33-
android:layout_margin="10dp"
34-
/>
33+
android:layout_margin="10dp" />
3534

3635
<ProgressBar
3736
android:id="@+id/progressBar"

0 commit comments

Comments
 (0)