From 86c16fa5d8397aca49813d2e2e158a36eb526a6a Mon Sep 17 00:00:00 2001 From: John Zhen Mo Date: Mon, 30 Oct 2017 08:04:14 -0700 Subject: [PATCH] -Fixed activity padding. -Fixed expanded notification artist name. -Fixed playpause on complete setting wrong index. --- .../schabi/newpipe/player/BackgroundPlayer.java | 15 +++++---------- .../org/schabi/newpipe/player/BasePlayer.java | 7 +++++-- .../layout-land/activity_player_queue_control.xml | 1 - .../res/layout/activity_player_queue_control.xml | 1 - 4 files changed, 10 insertions(+), 14 deletions(-) diff --git a/app/src/main/java/org/schabi/newpipe/player/BackgroundPlayer.java b/app/src/main/java/org/schabi/newpipe/player/BackgroundPlayer.java index 9a594a2cb..a7a1e2797 100644 --- a/app/src/main/java/org/schabi/newpipe/player/BackgroundPlayer.java +++ b/app/src/main/java/org/schabi/newpipe/player/BackgroundPlayer.java @@ -191,8 +191,8 @@ public final class BackgroundPlayer extends Service { } private void setupNotification(RemoteViews remoteViews) { - bigNotRemoteView.setTextViewText(R.id.notificationSongName, basePlayerImpl.getVideoTitle()); - bigNotRemoteView.setTextViewText(R.id.notificationArtist, basePlayerImpl.getVideoTitle()); + remoteViews.setTextViewText(R.id.notificationSongName, basePlayerImpl.getVideoTitle()); + remoteViews.setTextViewText(R.id.notificationArtist, basePlayerImpl.getUploaderName()); remoteViews.setOnClickPendingIntent(R.id.notificationPlayPause, PendingIntent.getBroadcast(this, NOTIFICATION_ID, new Intent(ACTION_PLAY_PAUSE), PendingIntent.FLAG_UPDATE_CURRENT)); @@ -268,10 +268,9 @@ public final class BackgroundPlayer extends Service { super.handleIntent(intent); resetNotification(); - startForeground(NOTIFICATION_ID, notBuilder.build()); - if (bigNotRemoteView != null) bigNotRemoteView.setProgressBar(R.id.notificationProgressBar, 100, 0, false); if (notRemoteView != null) notRemoteView.setProgressBar(R.id.notificationProgressBar, 100, 0, false); + startForeground(NOTIFICATION_ID, notBuilder.build()); } @Override @@ -363,8 +362,6 @@ public final class BackgroundPlayer extends Service { @Override public void onRepeatModeChanged(int i) { resetNotification(); - setRepeatModeIcon(notRemoteView, i); - setRepeatModeIcon(bigNotRemoteView, i); updateNotification(-1); updatePlayback(); } @@ -378,10 +375,6 @@ public final class BackgroundPlayer extends Service { super.sync(item, info); resetNotification(); - notRemoteView.setTextViewText(R.id.notificationSongName, getVideoTitle()); - notRemoteView.setTextViewText(R.id.notificationArtist, getUploaderName()); - bigNotRemoteView.setTextViewText(R.id.notificationSongName, getVideoTitle()); - bigNotRemoteView.setTextViewText(R.id.notificationArtist, getUploaderName()); updateNotification(-1); updateMetadata(); } @@ -539,6 +532,8 @@ public final class BackgroundPlayer extends Service { super.onCompleted(); setControlsOpacity(255); + + resetNotification(); if (bigNotRemoteView != null) bigNotRemoteView.setProgressBar(R.id.notificationProgressBar, 100, 100, false); if (notRemoteView != null) notRemoteView.setProgressBar(R.id.notificationProgressBar, 100, 100, false); updateNotification(R.drawable.ic_replay_white); diff --git a/app/src/main/java/org/schabi/newpipe/player/BasePlayer.java b/app/src/main/java/org/schabi/newpipe/player/BasePlayer.java index 692f4fca8..8508bb237 100644 --- a/app/src/main/java/org/schabi/newpipe/player/BasePlayer.java +++ b/app/src/main/java/org/schabi/newpipe/player/BasePlayer.java @@ -706,8 +706,11 @@ public abstract class BasePlayer implements Player.EventListener, PlaybackListen } if (getCurrentState() == STATE_COMPLETED) { - playQueue.setIndex(0); - simpleExoPlayer.seekToDefaultPosition(); + if (playQueue.getIndex() == 0) { + simpleExoPlayer.seekToDefaultPosition(); + } else { + playQueue.setIndex(0); + } } simpleExoPlayer.setPlayWhenReady(!isPlaying()); diff --git a/app/src/main/res/layout-land/activity_player_queue_control.xml b/app/src/main/res/layout-land/activity_player_queue_control.xml index b6a2baf61..a577b7fe0 100644 --- a/app/src/main/res/layout-land/activity_player_queue_control.xml +++ b/app/src/main/res/layout-land/activity_player_queue_control.xml @@ -12,7 +12,6 @@ android:id="@+id/appbar" android:layout_width="match_parent" android:layout_height="wrap_content" - android:paddingTop="@dimen/appbar_padding_top" android:theme="@style/ThemeOverlay.AppCompat.ActionBar" app:popupTheme="@style/ThemeOverlay.AppCompat.ActionBar"> diff --git a/app/src/main/res/layout/activity_player_queue_control.xml b/app/src/main/res/layout/activity_player_queue_control.xml index 328cedcba..a59e5ba2e 100644 --- a/app/src/main/res/layout/activity_player_queue_control.xml +++ b/app/src/main/res/layout/activity_player_queue_control.xml @@ -12,7 +12,6 @@ android:id="@+id/appbar" android:layout_width="match_parent" android:layout_height="wrap_content" - android:paddingTop="@dimen/appbar_padding_top" android:theme="@style/ThemeOverlay.AppCompat.ActionBar" app:popupTheme="@style/ThemeOverlay.AppCompat.ActionBar">