Completely remove old player notification
This commit is contained in:
parent
adef9a8acf
commit
e08480f345
@ -244,8 +244,7 @@ public final class MainPlayer extends Service {
|
||||
}
|
||||
|
||||
private void showNotificationAndStartForeground() {
|
||||
NotificationUtil.getInstance().recreateNotification(playerImpl, true);
|
||||
NotificationUtil.getInstance().setProgressbarOnOldNotifications(100, 0, false);
|
||||
NotificationUtil.getInstance().createNotificationIfNeeded(playerImpl, true);
|
||||
NotificationUtil.getInstance().startForegroundServiceWithNotification(this);
|
||||
}
|
||||
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@ -57,7 +57,6 @@ import android.widget.RelativeLayout;
|
||||
import android.widget.SeekBar;
|
||||
import android.widget.TextView;
|
||||
|
||||
import androidx.annotation.DrawableRes;
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
import androidx.appcompat.app.AppCompatActivity;
|
||||
@ -577,7 +576,7 @@ public class VideoPlayerImpl extends VideoPlayer
|
||||
void onShuffleOrRepeatModeChanged() {
|
||||
updatePlaybackButtons();
|
||||
updatePlayback();
|
||||
resetNotification(false, -1);
|
||||
resetNotification(false);
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -614,7 +613,7 @@ public class VideoPlayerImpl extends VideoPlayer
|
||||
titleTextView.setText(tag.getMetadata().getName());
|
||||
channelTextView.setText(tag.getMetadata().getUploaderName());
|
||||
|
||||
resetNotification(false, -1);
|
||||
resetNotification(false);
|
||||
updateMetadata();
|
||||
}
|
||||
|
||||
@ -642,30 +641,6 @@ public class VideoPlayerImpl extends VideoPlayer
|
||||
// setMetadata only updates the metadata when any of the metadata keys are null
|
||||
mediaSessionManager.setMetadata(getVideoTitle(), getUploaderName(), getThumbnail(),
|
||||
duration);
|
||||
|
||||
final boolean areOldNotificationsEnabled = sharedPreferences.getBoolean(
|
||||
context.getString(R.string.enable_old_notifications_key), false);
|
||||
if (areOldNotificationsEnabled) {
|
||||
if (!shouldUpdateOnProgress || getCurrentState() == BasePlayer.STATE_COMPLETED
|
||||
|| getCurrentState() == BasePlayer.STATE_PAUSED || getPlayQueue() == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (NotificationUtil.getInstance().shouldRecreateOldNotification()) {
|
||||
NotificationUtil.getInstance().recreateNotification(this, false);
|
||||
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
|
||||
NotificationUtil.getInstance().updateOldNotificationsThumbnail(getThumbnail());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
NotificationUtil.getInstance().setCachedDuration(currentProgress, duration);
|
||||
NotificationUtil.getInstance().setProgressbarOnOldNotifications(duration,
|
||||
currentProgress, false);
|
||||
|
||||
NotificationUtil.getInstance().updateNotification(this, -1);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -1083,9 +1058,9 @@ public class VideoPlayerImpl extends VideoPlayer
|
||||
animatePlayButtons(false, 100);
|
||||
getRootView().setKeepScreenOn(false);
|
||||
|
||||
NotificationUtil.getInstance().recreateNotification(this, false);
|
||||
NotificationUtil.getInstance().createNotificationIfNeeded(this, false);
|
||||
NotificationUtil.getInstance().updateNotification(
|
||||
this, R.drawable.ic_play_arrow_white_24dp);
|
||||
this);
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -1101,7 +1076,7 @@ public class VideoPlayerImpl extends VideoPlayer
|
||||
isForwardPressed = false;
|
||||
isRewindPressed = false;
|
||||
} else {
|
||||
NotificationUtil.getInstance().updateNotification(this, -1);
|
||||
NotificationUtil.getInstance().updateNotification(this);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1121,7 +1096,7 @@ public class VideoPlayerImpl extends VideoPlayer
|
||||
checkLandscape();
|
||||
getRootView().setKeepScreenOn(true);
|
||||
|
||||
resetNotification(false, R.drawable.ic_pause_white_24dp);
|
||||
resetNotification(false);
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -1137,7 +1112,7 @@ public class VideoPlayerImpl extends VideoPlayer
|
||||
|
||||
updateWindowFlags(IDLE_WINDOW_FLAGS);
|
||||
|
||||
resetNotification(false, R.drawable.ic_play_arrow_white_24dp);
|
||||
resetNotification(false);
|
||||
|
||||
// Remove running notification when user don't want music (or video in popup)
|
||||
// to be played in background
|
||||
@ -1154,9 +1129,9 @@ public class VideoPlayerImpl extends VideoPlayer
|
||||
animatePlayButtons(false, 100);
|
||||
getRootView().setKeepScreenOn(true);
|
||||
|
||||
NotificationUtil.getInstance().recreateNotification(this, false);
|
||||
NotificationUtil.getInstance().createNotificationIfNeeded(this, false);
|
||||
NotificationUtil.getInstance().updateNotification(
|
||||
this, R.drawable.ic_play_arrow_white_24dp);
|
||||
this);
|
||||
}
|
||||
|
||||
|
||||
@ -1170,11 +1145,8 @@ public class VideoPlayerImpl extends VideoPlayer
|
||||
getRootView().setKeepScreenOn(false);
|
||||
updateWindowFlags(IDLE_WINDOW_FLAGS);
|
||||
|
||||
NotificationUtil.getInstance().recreateNotification(this, false);
|
||||
NotificationUtil.getInstance().setProgressbarOnOldNotifications(100, 100, false);
|
||||
NotificationUtil.getInstance().updateOldNotificationsThumbnail(getThumbnail());
|
||||
NotificationUtil.getInstance().updateNotification(
|
||||
this, R.drawable.ic_replay_white_24dp);
|
||||
NotificationUtil.getInstance().createNotificationIfNeeded(this, false);
|
||||
NotificationUtil.getInstance().updateNotification(this);
|
||||
|
||||
super.onCompleted();
|
||||
}
|
||||
@ -1182,8 +1154,6 @@ public class VideoPlayerImpl extends VideoPlayer
|
||||
@Override
|
||||
public void destroy() {
|
||||
super.destroy();
|
||||
|
||||
NotificationUtil.getInstance().updateOldNotificationsThumbnail(null);
|
||||
service.getContentResolver().unregisterContentObserver(settingsContentObserver);
|
||||
}
|
||||
|
||||
@ -1334,10 +1304,9 @@ public class VideoPlayerImpl extends VideoPlayer
|
||||
// Thumbnail Loading
|
||||
//////////////////////////////////////////////////////////////////////////*/
|
||||
|
||||
void resetNotification(final boolean recreate, @DrawableRes final int drawableId) {
|
||||
NotificationUtil.getInstance().recreateNotification(this, recreate);
|
||||
NotificationUtil.getInstance().updateOldNotificationsThumbnail(getThumbnail());
|
||||
NotificationUtil.getInstance().updateNotification(this, drawableId);
|
||||
void resetNotification(final boolean recreate) {
|
||||
NotificationUtil.getInstance().createNotificationIfNeeded(this, recreate);
|
||||
NotificationUtil.getInstance().updateNotification(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -1347,7 +1316,7 @@ public class VideoPlayerImpl extends VideoPlayer
|
||||
// rebuild OLD notification here since remote view does not release bitmaps,
|
||||
// causing memory leaks
|
||||
super.onLoadingComplete(imageUri, view, loadedImage);
|
||||
resetNotification(true, -1);
|
||||
resetNotification(true);
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -1355,13 +1324,13 @@ public class VideoPlayerImpl extends VideoPlayer
|
||||
final View view,
|
||||
final FailReason failReason) {
|
||||
super.onLoadingFailed(imageUri, view, failReason);
|
||||
resetNotification(true, -1);
|
||||
resetNotification(true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onLoadingCancelled(final String imageUri, final View view) {
|
||||
super.onLoadingCancelled(imageUri, view);
|
||||
resetNotification(true, -1);
|
||||
resetNotification(true);
|
||||
}
|
||||
|
||||
/*//////////////////////////////////////////////////////////////////////////
|
||||
|
||||
@ -11,7 +11,6 @@ import androidx.annotation.Nullable;
|
||||
import androidx.preference.Preference;
|
||||
|
||||
import org.schabi.newpipe.R;
|
||||
import org.schabi.newpipe.player.NotificationUtil;
|
||||
import org.schabi.newpipe.util.Constants;
|
||||
|
||||
public class AppearanceSettingsFragment extends BasePreferenceFragment {
|
||||
@ -53,18 +52,8 @@ public class AppearanceSettingsFragment extends BasePreferenceFragment {
|
||||
final Preference captionSettings = findPreference(captionSettingsKey);
|
||||
getPreferenceScreen().removePreference(captionSettings);
|
||||
}
|
||||
|
||||
findPreference(getString(R.string.enable_old_notifications_key))
|
||||
.setOnPreferenceChangeListener(oldNotificationsOnPreferenceChangeListener);
|
||||
}
|
||||
|
||||
private Preference.OnPreferenceChangeListener oldNotificationsOnPreferenceChangeListener
|
||||
= (preference, newValue) -> {
|
||||
// kill player notification
|
||||
NotificationUtil.getInstance().cancelNotification();
|
||||
return true;
|
||||
};
|
||||
|
||||
@Override
|
||||
public void onCreatePreferences(final Bundle savedInstanceState, final String rootKey) {
|
||||
addPreferencesFromResource(R.xml.appearance_settings);
|
||||
|
||||
@ -114,7 +114,6 @@
|
||||
<item>144p</item>
|
||||
</string-array>
|
||||
|
||||
<string name="enable_old_notifications_key" translatable="false">enable_old_notifications</string>
|
||||
<string name="settings_notifications_compact_view_key" translatable="false">notifications_compact_view</string>
|
||||
<string name="settings_notifications_compact_view_default_value" translatable="false">0,1,2</string>
|
||||
<string name="scale_to_square_image_in_notifications_key" translatable="false">scale_to_square_image_in_notifications</string>
|
||||
|
||||
@ -58,8 +58,6 @@
|
||||
<string name="kore_package" translatable="false">org.xbmc.kore</string>
|
||||
<string name="show_play_with_kodi_title">Show \"Play with Kodi\" option</string>
|
||||
<string name="show_play_with_kodi_summary">Display an option to play a video via Kodi media center</string>
|
||||
<string name="enable_old_notifications_title">Enable old notifications</string>
|
||||
<string name="enable_old_notifications_summary">This enables the old \"Custom RemoteViews\" notifications. If disabled modern MediaStyle notifications will be used.</string>
|
||||
<string name="scale_to_square_image_in_notifications_title">Scale image to 1:1 aspect ratio</string>
|
||||
<string name="scale_to_square_image_in_notifications_summary">This will scale the notification image from 16:9 to 1:1 aspect ratio</string>
|
||||
<string name="default_notification_slot_0_title">Notification slot 0</string>
|
||||
|
||||
@ -39,13 +39,6 @@
|
||||
android:title="@string/settings_category_notifications_title"
|
||||
app:iconSpaceReserved="false">
|
||||
|
||||
<SwitchPreference
|
||||
android:defaultValue="false"
|
||||
android:key="@string/enable_old_notifications_key"
|
||||
android:summary="@string/enable_old_notifications_summary"
|
||||
android:title="@string/enable_old_notifications_title"
|
||||
app:iconSpaceReserved="false" />
|
||||
|
||||
<SwitchPreference
|
||||
android:defaultValue="false"
|
||||
android:key="@string/scale_to_square_image_in_notifications_key"
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user