Merge branch 'master' into dev

This commit is contained in:
TobiGr 2021-08-22 22:22:37 +02:00
commit 6fbb601802
5 changed files with 53 additions and 21 deletions

View File

@ -17,8 +17,8 @@ android {
resValue "string", "app_name", "NewPipe"
minSdkVersion 19
targetSdkVersion 29
versionCode 974
versionName "0.21.8"
versionCode 975
versionName "0.21.9"
multiDexEnabled true
@ -189,7 +189,7 @@ dependencies {
// name and the commit hash with the commit hash of the (pushed) commit you want to test
// This works thanks to JitPack: https://jitpack.io/
implementation 'com.github.TeamNewPipe:nanojson:1d9e1aea9049fc9f85e68b43ba39fe7be1c1f751'
implementation 'com.github.TeamNewPipe:NewPipeExtractor:v0.21.8'
implementation 'com.github.TeamNewPipe:NewPipeExtractor:v0.21.9'
/** Checkstyle **/
checkstyle "com.puppycrawl.tools:checkstyle:${checkstyleVersion}"

View File

@ -73,7 +73,7 @@ import org.schabi.newpipe.player.helper.PlayerHolder
import org.schabi.newpipe.util.Localization
import org.schabi.newpipe.util.NavigationHelper
import org.schabi.newpipe.util.StreamDialogEntry
import org.schabi.newpipe.util.ThemeHelper.getGridSpanCount
import org.schabi.newpipe.util.ThemeHelper.getGridSpanCountStreams
import org.schabi.newpipe.util.ThemeHelper.shouldUseGridLayout
import java.time.OffsetDateTime
import java.util.ArrayList
@ -161,7 +161,7 @@ class FeedFragment : BaseStateFragment<FeedState>() {
fun setupListViewMode() {
// does everything needed to setup the layouts for grid or list modes
groupAdapter.spanCount = if (shouldUseGridLayout(context)) getGridSpanCount(context) else 1
groupAdapter.spanCount = if (shouldUseGridLayout(context)) getGridSpanCountStreams(context) else 1
feedBinding.itemsList.layoutManager = GridLayoutManager(requireContext(), groupAdapter.spanCount).apply {
spanSizeLookup = groupAdapter.spanSizeLookup
}
@ -349,7 +349,15 @@ class FeedFragment : BaseStateFragment<FeedState>() {
)
)
}
if (item.streamType != StreamType.AUDIO_LIVE_STREAM && item.streamType != StreamType.LIVE_STREAM) {
// show "mark as watched" only when watch history is enabled
val isWatchHistoryEnabled = PreferenceManager
.getDefaultSharedPreferences(context)
.getBoolean(getString(R.string.enable_watch_history_key), false)
if (item.streamType != StreamType.AUDIO_LIVE_STREAM &&
item.streamType != StreamType.LIVE_STREAM &&
isWatchHistoryEnabled
) {
entries.add(
StreamDialogEntry.mark_as_watched
)

View File

@ -58,7 +58,7 @@ import org.schabi.newpipe.local.subscription.services.SubscriptionsImportService
import org.schabi.newpipe.streams.io.StoredFileHelper
import org.schabi.newpipe.util.NavigationHelper
import org.schabi.newpipe.util.OnClickGesture
import org.schabi.newpipe.util.ThemeHelper.getGridSpanCount
import org.schabi.newpipe.util.ThemeHelper.getGridSpanCountChannels
import org.schabi.newpipe.util.ThemeHelper.shouldUseGridLayout
import org.schabi.newpipe.util.external_communication.ShareUtils
import java.text.SimpleDateFormat
@ -267,7 +267,7 @@ class SubscriptionFragment : BaseStateFragment<SubscriptionState>() {
super.initViews(rootView, savedInstanceState)
_binding = FragmentSubscriptionBinding.bind(rootView)
groupAdapter.spanCount = if (shouldUseGridLayout(context)) getGridSpanCount(context) else 1
groupAdapter.spanCount = if (shouldUseGridLayout(context)) getGridSpanCountChannels(context) else 1
binding.itemsList.layoutManager = GridLayoutManager(requireContext(), groupAdapter.spanCount).apply {
spanSizeLookup = groupAdapter.spanSizeLookup
}

View File

@ -1,5 +1,9 @@
package org.schabi.newpipe.player;
import static org.schabi.newpipe.player.helper.PlayerHelper.formatSpeed;
import static org.schabi.newpipe.util.Localization.assureCorrectAppLanguage;
import static org.schabi.newpipe.util.external_communication.ShareUtils.shareText;
import android.content.ComponentName;
import android.content.Context;
import android.content.Intent;
@ -40,15 +44,12 @@ import org.schabi.newpipe.player.playqueue.PlayQueueItemTouchCallback;
import org.schabi.newpipe.util.Localization;
import org.schabi.newpipe.util.NavigationHelper;
import org.schabi.newpipe.util.PermissionHelper;
import org.schabi.newpipe.util.ServiceHelper;
import org.schabi.newpipe.util.ThemeHelper;
import java.util.Collections;
import java.util.List;
import static org.schabi.newpipe.player.helper.PlayerHelper.formatSpeed;
import static org.schabi.newpipe.util.Localization.assureCorrectAppLanguage;
import static org.schabi.newpipe.util.external_communication.ShareUtils.shareText;
public final class PlayQueueActivity extends AppCompatActivity
implements PlayerEventListener, SeekBar.OnSeekBarChangeListener,
View.OnClickListener, PlaybackParameterDialog.Callback {
@ -83,7 +84,7 @@ public final class PlayQueueActivity extends AppCompatActivity
protected void onCreate(final Bundle savedInstanceState) {
assureCorrectAppLanguage(this);
super.onCreate(savedInstanceState);
ThemeHelper.setTheme(this);
ThemeHelper.setTheme(this, ServiceHelper.getSelectedServiceId(this));
queueControlBinding = ActivityPlayerQueueControlBinding.inflate(getLayoutInflater());
setContentView(queueControlBinding.getRoot());

View File

@ -324,17 +324,40 @@ public final class ThemeHelper {
}
/**
* Calculates the number of grid items that can fit horizontally on the screen. The width of a
* grid item is obtained from the thumbnail width plus the right and left paddings.
* Calculates the number of grid channel info items that can fit horizontally on the screen.
*
* @param context the context to use
* @return the span count of grid channel info items
*/
public static int getGridSpanCountChannels(final Context context) {
return getGridSpanCount(context,
context.getResources().getDimensionPixelSize(R.dimen.channel_item_grid_min_width));
}
/**
* Calculates the number of grid stream info items that can fit horizontally on the screen. The
* width of a grid stream info item is obtained from the thumbnail width plus the right and left
* paddings.
*
* @param context the context to use
* @return the span count of grid stream info items
*/
public static int getGridSpanCountStreams(final Context context) {
final Resources res = context.getResources();
return getGridSpanCount(context,
res.getDimensionPixelSize(R.dimen.video_item_grid_thumbnail_image_width)
+ res.getDimensionPixelSize(R.dimen.video_item_search_padding) * 2);
}
/**
* Calculates the number of grid items that can fit horizontally on the screen based on the
* minimum width.
*
* @param context the context to use
* @param minWidth the minimum width of items in the grid
* @return the span count of grid list items
*/
public static int getGridSpanCount(final Context context) {
final Resources res = context.getResources();
final int minWidth
= res.getDimensionPixelSize(R.dimen.video_item_grid_thumbnail_image_width)
+ res.getDimensionPixelSize(R.dimen.video_item_search_padding) * 2;
return Math.max(1, res.getDisplayMetrics().widthPixels / minWidth);
public static int getGridSpanCount(final Context context, final int minWidth) {
return Math.max(1, context.getResources().getDisplayMetrics().widthPixels / minWidth);
}
}