Skip to content

Commit 5134080

Browse files
author
Martin
authored
Merge branch 'TeamNewPipe:dev' into dev
2 parents 3e44856 + 2158802 commit 5134080

12 files changed

Lines changed: 71 additions & 54 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
minSdkVersion 19
1818
targetSdkVersion 29
19-
versionCode 980
20-
versionName "0.21.14"
19+
versionCode 981
20+
versionName "0.21.15"
2121

2222
multiDexEnabled true
2323

app/src/main/java/com/google/android/material/appbar/FlingBehavior.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,7 @@ public boolean onRequestChildRectangleOnScreen(
6363
return consumed == dy;
6464
}
6565

66+
@Override
6667
public boolean onInterceptTouchEvent(@NonNull final CoordinatorLayout parent,
6768
@NonNull final AppBarLayout child,
6869
@NonNull final MotionEvent ev) {

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -685,7 +685,7 @@ protected void initListeners() {
685685
});
686686

687687
setupBottomPlayer();
688-
if (!playerHolder.bound) {
688+
if (!playerHolder.isBound()) {
689689
setHeightThumbnail();
690690
} else {
691691
playerHolder.startService(false, this);
@@ -1434,7 +1434,7 @@ public void onReceive(final Context context, final Intent intent) {
14341434
bottomSheetBehavior.setState(BottomSheetBehavior.STATE_COLLAPSED);
14351435
}
14361436
// Rebound to the service if it was closed via notification or mini player
1437-
if (!playerHolder.bound) {
1437+
if (!playerHolder.isBound()) {
14381438
playerHolder.startService(
14391439
false, VideoDetailFragment.this);
14401440
}

app/src/main/java/org/schabi/newpipe/fragments/list/search/SearchFragment.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -724,7 +724,7 @@ private void showDeleteSuggestionDialog(final SuggestionItem item) {
724724
@Override
725725
public boolean onBackPressed() {
726726
if (suggestionsPanelVisible
727-
&& infoListAdapter.getItemsList().size() > 0
727+
&& !infoListAdapter.getItemsList().isEmpty()
728728
&& !isLoading.get()) {
729729
hideSuggestionsPanel();
730730
hideKeyboardSearch();

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

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -54,11 +54,9 @@ class ChannelItem(
5454
context.getString(R.string.subscribers_count_not_available)
5555
}
5656

57-
if (itemVersion == ItemVersion.NORMAL) {
58-
if (infoItem.streamCount >= 0) {
59-
val formattedVideoAmount = Localization.localizeStreamCount(context, infoItem.streamCount)
60-
details = Localization.concatenateStrings(details, formattedVideoAmount)
61-
}
57+
if (itemVersion == ItemVersion.NORMAL && infoItem.streamCount >= 0) {
58+
val formattedVideoAmount = Localization.localizeStreamCount(context, infoItem.streamCount)
59+
details = Localization.concatenateStrings(details, formattedVideoAmount)
6260
}
6361
return details
6462
}

app/src/main/java/org/schabi/newpipe/player/Player.java

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -2348,7 +2348,8 @@ private void onShuffleOrRepeatModeChanged() {
23482348
NotificationUtil.getInstance().createNotificationIfNeededAndUpdate(this, false);
23492349
}
23502350

2351-
private void setRepeatModeButton(final AppCompatImageButton imageButton, final int repeatMode) {
2351+
private void setRepeatModeButton(final AppCompatImageButton imageButton,
2352+
@RepeatMode final int repeatMode) {
23522353
switch (repeatMode) {
23532354
case REPEAT_MODE_OFF:
23542355
imageButton.setImageResource(R.drawable.exo_controls_repeat_off);
@@ -2362,7 +2363,7 @@ private void setRepeatModeButton(final AppCompatImageButton imageButton, final i
23622363
}
23632364
}
23642365

2365-
private void setShuffleButton(final ImageButton button, final boolean shuffled) {
2366+
private void setShuffleButton(@NonNull final ImageButton button, final boolean shuffled) {
23662367
button.setImageAlpha(shuffled ? 255 : 77);
23672368
}
23682369
//endregion
@@ -2387,7 +2388,7 @@ boolean isMuted() {
23872388
return !exoPlayerIsNull() && simpleExoPlayer.getVolume() == 0;
23882389
}
23892390

2390-
private void setMuteButton(final ImageButton button, final boolean isMuted) {
2391+
private void setMuteButton(@NonNull final ImageButton button, final boolean isMuted) {
23912392
button.setImageDrawable(AppCompatResources.getDrawable(context, isMuted
23922393
? R.drawable.ic_volume_off : R.drawable.ic_volume_up));
23932394
}
@@ -2876,7 +2877,7 @@ private void saveStreamProgressState(final long progressMillis) {
28762877
databaseUpdateDisposable
28772878
.add(recordManager.saveStreamState(currentMetadata.getMetadata(), progressMillis)
28782879
.observeOn(AndroidSchedulers.mainThread())
2879-
.doOnError((e) -> {
2880+
.doOnError(e -> {
28802881
if (DEBUG) {
28812882
e.printStackTrace();
28822883
}
@@ -3386,7 +3387,7 @@ private void buildPlaybackSpeedMenu() {
33863387
playbackSpeedPopupMenu.setOnDismissListener(this);
33873388
}
33883389

3389-
private void buildCaptionMenu(final List<String> availableLanguages) {
3390+
private void buildCaptionMenu(@NonNull final List<String> availableLanguages) {
33903391
if (captionPopupMenu == null) {
33913392
return;
33923393
}
@@ -3454,7 +3455,7 @@ private void buildCaptionMenu(final List<String> availableLanguages) {
34543455
* Called when an item of the quality selector or the playback speed selector is selected.
34553456
*/
34563457
@Override
3457-
public boolean onMenuItemClick(final MenuItem menuItem) {
3458+
public boolean onMenuItemClick(@NonNull final MenuItem menuItem) {
34583459
if (DEBUG) {
34593460
Log.d(TAG, "onMenuItemClick() called with: "
34603461
+ "menuItem = [" + menuItem + "], "
@@ -3491,7 +3492,7 @@ public boolean onMenuItemClick(final MenuItem menuItem) {
34913492
* Called when some popup menu is dismissed.
34923493
*/
34933494
@Override
3494-
public void onDismiss(final PopupMenu menu) {
3495+
public void onDismiss(@Nullable final PopupMenu menu) {
34953496
if (DEBUG) {
34963497
Log.d(TAG, "onDismiss() called with: menu = [" + menu + "]");
34973498
}
@@ -3544,7 +3545,7 @@ private void onCaptionClicked() {
35443545
isSomePopupMenuVisible = true;
35453546
}
35463547

3547-
private void setPlaybackQuality(final String quality) {
3548+
private void setPlaybackQuality(@Nullable final String quality) {
35483549
videoResolver.setPlaybackQuality(quality);
35493550
}
35503551
//endregion
@@ -3568,7 +3569,7 @@ private void setupSubtitleView() {
35683569
final int minimumLength = Math.min(metrics.heightPixels, metrics.widthPixels);
35693570
final float captionRatioInverse = 20f + 4f * (1.0f - captionScale);
35703571
binding.subtitleView.setFixedTextSize(
3571-
TypedValue.COMPLEX_UNIT_PX, (float) minimumLength / captionRatioInverse);
3572+
TypedValue.COMPLEX_UNIT_PX, minimumLength / captionRatioInverse);
35723573
}
35733574
binding.subtitleView.setApplyEmbeddedStyles(captionStyle == CaptionStyleCompat.DEFAULT);
35743575
binding.subtitleView.setStyle(captionStyle);
@@ -3845,7 +3846,7 @@ void onResizeClicked() {
38453846
}
38463847

38473848
@Override // exoplayer listener
3848-
public void onVideoSizeChanged(final VideoSize videoSize) {
3849+
public void onVideoSizeChanged(@NonNull final VideoSize videoSize) {
38493850
if (DEBUG) {
38503851
Log.d(TAG, "onVideoSizeChanged() called with: "
38513852
+ "width / height = [" + videoSize.width + " / " + videoSize.height
@@ -3959,7 +3960,7 @@ private void setInitialGestureValues() {
39593960
}
39603961
}
39613962

3962-
private int distanceFromCloseButton(final MotionEvent popupMotionEvent) {
3963+
private int distanceFromCloseButton(@NonNull final MotionEvent popupMotionEvent) {
39633964
final int closeOverlayButtonX = closeOverlayBinding.closeButton.getLeft()
39643965
+ closeOverlayBinding.closeButton.getWidth() / 2;
39653966
final int closeOverlayButtonY = closeOverlayBinding.closeButton.getTop()
@@ -3978,7 +3979,7 @@ private float getClosingRadius() {
39783979
return buttonRadius * 1.2f;
39793980
}
39803981

3981-
public boolean isInsideClosingRadius(final MotionEvent popupMotionEvent) {
3982+
public boolean isInsideClosingRadius(@NonNull final MotionEvent popupMotionEvent) {
39823983
return distanceFromCloseButton(popupMotionEvent) <= getClosingRadius();
39833984
}
39843985
//endregion
@@ -4098,6 +4099,7 @@ private void notifyProgressUpdateToListeners(final int currentProgress,
40984099
}
40994100
}
41004101

4102+
@Nullable
41014103
public AppCompatActivity getParentActivity() {
41024104
// ! instanceof ViewGroup means that view was added via windowManager for Popup
41034105
if (binding == null || !(binding.getRoot().getParent() instanceof ViewGroup)) {

app/src/main/java/org/schabi/newpipe/player/event/PlayerGestureListener.java

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,12 @@
11
package org.schabi.newpipe.player.event;
22

3+
import static org.schabi.newpipe.ktx.AnimationType.ALPHA;
4+
import static org.schabi.newpipe.ktx.AnimationType.SCALE_AND_ALPHA;
5+
import static org.schabi.newpipe.ktx.ViewUtils.animate;
6+
import static org.schabi.newpipe.player.Player.DEFAULT_CONTROLS_DURATION;
7+
import static org.schabi.newpipe.player.Player.DEFAULT_CONTROLS_HIDE_TIME;
8+
import static org.schabi.newpipe.player.Player.STATE_PLAYING;
9+
310
import android.app.Activity;
411
import android.util.Log;
512
import android.view.MotionEvent;
@@ -8,22 +15,15 @@
815
import android.view.WindowManager;
916
import android.widget.ProgressBar;
1017

18+
import androidx.annotation.NonNull;
1119
import androidx.appcompat.content.res.AppCompatResources;
1220

13-
import org.jetbrains.annotations.NotNull;
1421
import org.schabi.newpipe.MainActivity;
1522
import org.schabi.newpipe.R;
1623
import org.schabi.newpipe.player.MainPlayer;
1724
import org.schabi.newpipe.player.Player;
1825
import org.schabi.newpipe.player.helper.PlayerHelper;
1926

20-
import static org.schabi.newpipe.ktx.AnimationType.ALPHA;
21-
import static org.schabi.newpipe.ktx.AnimationType.SCALE_AND_ALPHA;
22-
import static org.schabi.newpipe.ktx.ViewUtils.animate;
23-
import static org.schabi.newpipe.player.Player.DEFAULT_CONTROLS_DURATION;
24-
import static org.schabi.newpipe.player.Player.DEFAULT_CONTROLS_HIDE_TIME;
25-
import static org.schabi.newpipe.player.Player.STATE_PLAYING;
26-
2727
/**
2828
* GestureListener for the player
2929
*
@@ -45,8 +45,8 @@ public PlayerGestureListener(final Player player, final MainPlayer service) {
4545
}
4646

4747
@Override
48-
public void onDoubleTap(@NotNull final MotionEvent event,
49-
@NotNull final DisplayPortion portion) {
48+
public void onDoubleTap(@NonNull final MotionEvent event,
49+
@NonNull final DisplayPortion portion) {
5050
if (DEBUG) {
5151
Log.d(TAG, "onDoubleTap called with playerType = ["
5252
+ player.getPlayerType() + "], portion = [" + portion + "]");
@@ -65,7 +65,7 @@ public void onDoubleTap(@NotNull final MotionEvent event,
6565
}
6666

6767
@Override
68-
public void onSingleTap(@NotNull final MainPlayer.PlayerType playerType) {
68+
public void onSingleTap(@NonNull final MainPlayer.PlayerType playerType) {
6969
if (DEBUG) {
7070
Log.d(TAG, "onSingleTap called with playerType = [" + player.getPlayerType() + "]");
7171
}
@@ -85,10 +85,10 @@ public void onSingleTap(@NotNull final MainPlayer.PlayerType playerType) {
8585
}
8686

8787
@Override
88-
public void onScroll(@NotNull final MainPlayer.PlayerType playerType,
89-
@NotNull final DisplayPortion portion,
90-
@NotNull final MotionEvent initialEvent,
91-
@NotNull final MotionEvent movingEvent,
88+
public void onScroll(@NonNull final MainPlayer.PlayerType playerType,
89+
@NonNull final DisplayPortion portion,
90+
@NonNull final MotionEvent initialEvent,
91+
@NonNull final MotionEvent movingEvent,
9292
final float distanceX, final float distanceY) {
9393
if (DEBUG) {
9494
Log.d(TAG, "onScroll called with playerType = ["
@@ -197,8 +197,8 @@ private void onScrollMainBrightness(final float distanceX, final float distanceY
197197
}
198198

199199
@Override
200-
public void onScrollEnd(@NotNull final MainPlayer.PlayerType playerType,
201-
@NotNull final MotionEvent event) {
200+
public void onScrollEnd(@NonNull final MainPlayer.PlayerType playerType,
201+
@NonNull final MotionEvent event) {
202202
if (DEBUG) {
203203
Log.d(TAG, "onScrollEnd called with playerType = ["
204204
+ player.getPlayerType() + "]");

app/src/main/java/org/schabi/newpipe/player/helper/PlayerHolder.java

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -35,13 +35,13 @@ public static synchronized PlayerHolder getInstance() {
3535
return PlayerHolder.instance;
3636
}
3737

38-
private final boolean DEBUG = MainActivity.DEBUG;
39-
private final String TAG = PlayerHolder.class.getSimpleName();
38+
private static final boolean DEBUG = MainActivity.DEBUG;
39+
private static final String TAG = PlayerHolder.class.getSimpleName();
4040

4141
private PlayerServiceExtendedEventListener listener;
4242

4343
private final PlayerServiceConnection serviceConnection = new PlayerServiceConnection();
44-
public boolean bound;
44+
private boolean bound;
4545
private MainPlayer playerService;
4646
private Player player;
4747

@@ -70,6 +70,10 @@ public boolean isPlayerOpen() {
7070
return player != null;
7171
}
7272

73+
public boolean isBound() {
74+
return bound;
75+
}
76+
7377
public int getQueueSize() {
7478
return isPlayerOpen() ? player.getPlayQueue().size() : 0;
7579
}
@@ -148,7 +152,7 @@ public void onServiceConnected(final ComponentName compName, final IBinder servi
148152
}
149153
startPlayerListener();
150154
}
151-
};
155+
}
152156

153157
private void bind(final Context context) {
154158
if (DEBUG) {

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818

1919
public abstract class BasePreferenceFragment extends PreferenceFragmentCompat {
2020
protected final String TAG = getClass().getSimpleName() + "@" + Integer.toHexString(hashCode());
21-
protected final boolean DEBUG = MainActivity.DEBUG;
21+
protected static final boolean DEBUG = MainActivity.DEBUG;
2222

2323
SharedPreferences defaultPreferences;
2424

app/src/main/java/org/schabi/newpipe/settings/tabs/Tab.java

Lines changed: 16 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,10 @@
3636
public abstract class Tab {
3737
private static final String JSON_TAB_ID_KEY = "tab_id";
3838

39+
private static final String NO_NAME = "<no-name>";
40+
private static final String NO_ID = "<no-id>";
41+
private static final String NO_URL = "<no-url>";
42+
3943
Tab() {
4044
}
4145

@@ -185,7 +189,9 @@ public int getTabId() {
185189

186190
@Override
187191
public String getTabName(final Context context) {
188-
return "NewPipe"; //context.getString(R.string.blank_page_summary);
192+
// TODO: find a better name for the blank tab (maybe "blank_tab") or replace it with
193+
// context.getString(R.string.app_name);
194+
return "NewPipe"; // context.getString(R.string.blank_page_summary);
189195
}
190196

191197
@DrawableRes
@@ -309,7 +315,7 @@ public static class KioskTab extends Tab {
309315
private String kioskId;
310316

311317
private KioskTab() {
312-
this(-1, "<no-id>");
318+
this(-1, NO_ID);
313319
}
314320

315321
public KioskTab(final int kioskServiceId, final String kioskId) {
@@ -357,7 +363,7 @@ protected void writeDataToJson(final JsonSink writerSink) {
357363
@Override
358364
protected void readDataFromJson(final JsonObject jsonObject) {
359365
kioskServiceId = jsonObject.getInt(JSON_KIOSK_SERVICE_ID_KEY, -1);
360-
kioskId = jsonObject.getString(JSON_KIOSK_ID_KEY, "<no-id>");
366+
kioskId = jsonObject.getString(JSON_KIOSK_ID_KEY, NO_ID);
361367
}
362368

363369
@Override
@@ -395,7 +401,7 @@ public static class ChannelTab extends Tab {
395401
private String channelName;
396402

397403
private ChannelTab() {
398-
this(-1, "<no-url>", "<no-name>");
404+
this(-1, NO_URL, NO_NAME);
399405
}
400406

401407
public ChannelTab(final int channelServiceId, final String channelUrl,
@@ -440,8 +446,8 @@ protected void writeDataToJson(final JsonSink writerSink) {
440446
@Override
441447
protected void readDataFromJson(final JsonObject jsonObject) {
442448
channelServiceId = jsonObject.getInt(JSON_CHANNEL_SERVICE_ID_KEY, -1);
443-
channelUrl = jsonObject.getString(JSON_CHANNEL_URL_KEY, "<no-url>");
444-
channelName = jsonObject.getString(JSON_CHANNEL_NAME_KEY, "<no-name>");
449+
channelUrl = jsonObject.getString(JSON_CHANNEL_URL_KEY, NO_URL);
450+
channelName = jsonObject.getString(JSON_CHANNEL_NAME_KEY, NO_NAME);
445451
}
446452

447453
@Override
@@ -527,15 +533,15 @@ public static class PlaylistTab extends Tab {
527533
private LocalItemType playlistType;
528534

529535
private PlaylistTab() {
530-
this(-1, "<no-name>");
536+
this(-1, NO_NAME);
531537
}
532538

533539
public PlaylistTab(final long playlistId, final String playlistName) {
534540
this.playlistName = playlistName;
535541
this.playlistId = playlistId;
536542
this.playlistType = LocalItemType.PLAYLIST_LOCAL_ITEM;
537543
this.playlistServiceId = -1;
538-
this.playlistUrl = "<no-url>";
544+
this.playlistUrl = NO_URL;
539545
}
540546

541547
public PlaylistTab(final int playlistServiceId, final String playlistUrl,
@@ -589,8 +595,8 @@ protected void writeDataToJson(final JsonSink writerSink) {
589595
@Override
590596
protected void readDataFromJson(final JsonObject jsonObject) {
591597
playlistServiceId = jsonObject.getInt(JSON_PLAYLIST_SERVICE_ID_KEY, -1);
592-
playlistUrl = jsonObject.getString(JSON_PLAYLIST_URL_KEY, "<no-url>");
593-
playlistName = jsonObject.getString(JSON_PLAYLIST_NAME_KEY, "<no-name>");
598+
playlistUrl = jsonObject.getString(JSON_PLAYLIST_URL_KEY, NO_URL);
599+
playlistName = jsonObject.getString(JSON_PLAYLIST_NAME_KEY, NO_NAME);
594600
playlistId = jsonObject.getInt(JSON_PLAYLIST_ID_KEY, -1);
595601
playlistType = LocalItemType.valueOf(
596602
jsonObject.getString(JSON_PLAYLIST_TYPE_KEY,

0 commit comments

Comments
 (0)