Skip to content

Commit ef1e7e5

Browse files
committed
Merge branch 'master' into dev
2 parents 95a65d5 + a95a5ed commit ef1e7e5

37 files changed

Lines changed: 520 additions & 262 deletions

File tree

app/build.gradle

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,8 @@ android {
1616
resValue "string", "app_name", "NewPipe"
1717
minSdk 21
1818
targetSdk 29
19-
versionCode 990
20-
versionName "0.24.0"
19+
versionCode 991
20+
versionName "0.24.1"
2121

2222
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
2323

app/src/main/java/org/schabi/newpipe/fragments/detail/VideoDetailFragment.java

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -248,6 +248,7 @@ && isAutoplayEnabled()
248248
autoPlayEnabled = true; // forcefully start playing
249249
openVideoPlayerAutoFullscreen();
250250
}
251+
updateOverlayPlayQueueButtonVisibility();
251252
}
252253

253254
@Override
@@ -337,6 +338,8 @@ public void onResume() {
337338

338339
activity.sendBroadcast(new Intent(ACTION_VIDEO_FRAGMENT_RESUMED));
339340

341+
updateOverlayPlayQueueButtonVisibility();
342+
340343
setupBrightness();
341344

342345
if (tabSettingsChanged) {
@@ -1820,6 +1823,14 @@ public void onQueueUpdate(final PlayQueue queue) {
18201823
+ title + "], playQueue = [" + playQueue + "]");
18211824
}
18221825

1826+
// Register broadcast receiver to listen to playQueue changes
1827+
// and hide the overlayPlayQueueButton when the playQueue is empty / destroyed.
1828+
if (playQueue != null && playQueue.getBroadcastReceiver() != null) {
1829+
playQueue.getBroadcastReceiver().subscribe(
1830+
event -> updateOverlayPlayQueueButtonVisibility()
1831+
);
1832+
}
1833+
18231834
// This should be the only place where we push data to stack.
18241835
// It will allow to have live instance of PlayQueue with actual information about
18251836
// deleted/added items inside Channel/Playlist queue and makes possible to have
@@ -1926,6 +1937,7 @@ public void onServiceStopped() {
19261937
currentInfo.getUploaderName(),
19271938
currentInfo.getThumbnailUrl());
19281939
}
1940+
updateOverlayPlayQueueButtonVisibility();
19291941
}
19301942

19311943
@Override
@@ -2392,6 +2404,18 @@ public void onSlide(@NonNull final View bottomSheet, final float slideOffset) {
23922404
});
23932405
}
23942406

2407+
private void updateOverlayPlayQueueButtonVisibility() {
2408+
final boolean isPlayQueueEmpty =
2409+
player == null // no player => no play queue :)
2410+
|| player.getPlayQueue() == null
2411+
|| player.getPlayQueue().isEmpty();
2412+
if (binding != null) {
2413+
// binding is null when rotating the device...
2414+
binding.overlayPlayQueueButton.setVisibility(
2415+
isPlayQueueEmpty ? View.GONE : View.VISIBLE);
2416+
}
2417+
}
2418+
23952419
private void updateOverlayData(@Nullable final String overlayTitle,
23962420
@Nullable final String uploader,
23972421
@Nullable final String thumbnailUrl) {

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

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -254,7 +254,11 @@ class SubscriptionFragment : BaseStateFragment<SubscriptionState>() {
254254

255255
viewModel = ViewModelProvider(this)[SubscriptionViewModel::class.java]
256256
viewModel.stateLiveData.observe(viewLifecycleOwner) { it?.let(this::handleResult) }
257-
viewModel.feedGroupsLiveData.observe(viewLifecycleOwner) { it?.let(this::handleFeedGroups) }
257+
viewModel.feedGroupsLiveData.observe(viewLifecycleOwner) {
258+
it?.let { (groups, listViewMode) ->
259+
handleFeedGroups(groups, listViewMode)
260+
}
261+
}
258262

259263
setupInitialLayout()
260264
}
@@ -405,24 +409,22 @@ class SubscriptionFragment : BaseStateFragment<SubscriptionState>() {
405409
}
406410
}
407411

408-
private fun handleFeedGroups(groups: List<Group>) {
409-
val listViewMode = viewModel.getListViewMode()
410-
412+
private fun handleFeedGroups(groups: List<Group>, listViewMode: Boolean) {
411413
if (feedGroupsCarouselState != null) {
412414
feedGroupsCarousel.onRestoreInstanceState(feedGroupsCarouselState)
413415
feedGroupsCarouselState = null
414416
}
415417

416-
feedGroupsCarousel.listViewMode = listViewMode
417-
feedGroupsSortMenuItem.showSortButton = groups.size > 1
418-
feedGroupsSortMenuItem.listViewMode = listViewMode
419418
binding.itemsList.post {
420419
if (context == null) {
421420
// since this part was posted to the next UI cycle, the fragment might have been
422421
// removed in the meantime
423422
return@post
424423
}
425424

425+
feedGroupsCarousel.listViewMode = listViewMode
426+
feedGroupsSortMenuItem.showSortButton = groups.size > 1
427+
feedGroupsSortMenuItem.listViewMode = listViewMode
426428
feedGroupsCarousel.notifyChanged(FeedGroupCarouselItem.PAYLOAD_UPDATE_LIST_VIEW_MODE)
427429
feedGroupsSortMenuItem.notifyChanged(GroupsHeader.PAYLOAD_UPDATE_ICONS)
428430

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

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,9 +27,9 @@ class SubscriptionViewModel(application: Application) : AndroidViewModel(applica
2727
private val listViewModeFlowable = listViewMode.distinctUntilChanged()
2828

2929
private val mutableStateLiveData = MutableLiveData<SubscriptionState>()
30-
private val mutableFeedGroupsLiveData = MutableLiveData<List<Group>>()
30+
private val mutableFeedGroupsLiveData = MutableLiveData<Pair<List<Group>, Boolean>>()
3131
val stateLiveData: LiveData<SubscriptionState> = mutableStateLiveData
32-
val feedGroupsLiveData: LiveData<List<Group>> = mutableFeedGroupsLiveData
32+
val feedGroupsLiveData: LiveData<Pair<List<Group>, Boolean>> = mutableFeedGroupsLiveData
3333

3434
private var feedGroupItemsDisposable = Flowable
3535
.combineLatest(
@@ -39,7 +39,10 @@ class SubscriptionViewModel(application: Application) : AndroidViewModel(applica
3939
)
4040
.throttleLatest(DEFAULT_THROTTLE_TIMEOUT, TimeUnit.MILLISECONDS)
4141
.map { (feedGroups, listViewMode) ->
42-
feedGroups.map(if (listViewMode) ::FeedGroupCardItem else ::FeedGroupCardGridItem)
42+
Pair(
43+
feedGroups.map(if (listViewMode) ::FeedGroupCardItem else ::FeedGroupCardGridItem),
44+
listViewMode
45+
)
4346
}
4447
.subscribeOn(Schedulers.io())
4548
.subscribe(

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

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import com.xwray.groupie.viewbinding.GroupieViewHolder
1010
import org.schabi.newpipe.R
1111
import org.schabi.newpipe.databinding.FeedItemCarouselBinding
1212
import org.schabi.newpipe.util.DeviceUtils
13-
import java.lang.Integer.max
13+
import org.schabi.newpipe.util.ThemeHelper.getGridSpanCount
1414

1515
class FeedGroupCarouselItem(
1616
private val carouselAdapter: GroupAdapter<GroupieViewHolder<FeedItemCarouselBinding>>,
@@ -71,10 +71,7 @@ class FeedGroupCarouselItem(
7171
carouselLayoutManager = if (listViewMode) {
7272
LinearLayoutManager(context)
7373
} else {
74-
GridLayoutManager(
75-
context,
76-
max(1, viewBinding.recyclerView.width / DeviceUtils.dpToPx(112, context))
77-
)
74+
GridLayoutManager(context, getGridSpanCount(context, DeviceUtils.dpToPx(112, context)))
7875
}
7976

8077
viewBinding.recyclerView.apply {
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<resources></resources>
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<resources></resources>
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<resources></resources>

0 commit comments

Comments
 (0)