Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Release/0.21.13 #7291

Merged
merged 6 commits into from
Oct 21, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@ android {
resValue "string", "app_name", "NewPipe"
minSdkVersion 19
targetSdkVersion 29
versionCode 978
versionName "0.21.12"
versionCode 979
versionName "0.21.13"

multiDexEnabled true

Expand Down
1 change: 1 addition & 0 deletions app/src/main/java/org/schabi/newpipe/App.java
Original file line number Diff line number Diff line change
Expand Up @@ -254,4 +254,5 @@ private void initNotificationChannels() {
protected boolean isDisposedRxExceptionsReported() {
return false;
}

}
17 changes: 17 additions & 0 deletions app/src/main/java/org/schabi/newpipe/CheckForNewAppVersion.java
Original file line number Diff line number Diff line change
Expand Up @@ -235,6 +235,23 @@ private void handleResponse(@NonNull final Response response,
}
}

/**
* Start a new service which
* checks if all conditions for performing a version check are met,
* fetches the API endpoint {@link #NEWPIPE_API_URL} containing info
* about the latest NewPipe version
* and displays a notification about ana available update.
* <br>
* Following conditions need to be met, before data is request from the server:
* <ul>
* <li> The app is signed with the correct signing key (by TeamNewPipe / schabi).
* If the signing key differs from the one used upstream, the update cannot be installed.</li>
* <li>The user enabled searching for and notifying about updates in the settings.</li>
* <li>The app did not recently check for updates.
* We do not want to make unnecessary connections and DOS our servers.</li>
* </ul>
* <b>Must not be executed</b> when the app is in background.
*/
public static void startNewVersionCheckService() {
final Intent intent = new Intent(App.getApp().getApplicationContext(),
CheckForNewAppVersion.class);
Expand Down
11 changes: 8 additions & 3 deletions app/src/main/java/org/schabi/newpipe/MainActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
package org.schabi.newpipe;

import static org.schabi.newpipe.CheckForNewAppVersion.startNewVersionCheckService;
import static org.schabi.newpipe.util.Localization.assureCorrectAppLanguage;

import android.content.BroadcastReceiver;
import android.content.Context;
Expand Down Expand Up @@ -93,8 +94,6 @@
import java.util.List;
import java.util.Objects;

import static org.schabi.newpipe.util.Localization.assureCorrectAppLanguage;

public class MainActivity extends AppCompatActivity {
private static final String TAG = "MainActivity";
@SuppressWarnings("ConstantConditions")
Expand Down Expand Up @@ -165,8 +164,14 @@ protected void onCreate(final Bundle savedInstanceState) {
FocusOverlayView.setupFocusObserver(this);
}
openMiniPlayerUponPlayerStarted();
}

// Check for new version
@Override
protected void onPostCreate(final Bundle savedInstanceState) {
super.onPostCreate(savedInstanceState);
// Start the service which is checking all conditions
// and eventually searching for a new version.
// The service searching for a new NewPipe version must not be started in background.
startNewVersionCheckService();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1181,7 +1181,7 @@ private void openMainPlayer() {
addVideoPlayerView();

final Intent playerIntent = NavigationHelper.getPlayerIntent(requireContext(),
MainPlayer.class, queue, autoPlayEnabled);
MainPlayer.class, queue, true, autoPlayEnabled);
ContextCompat.startForegroundService(activity, playerIntent);
}

Expand Down
19 changes: 15 additions & 4 deletions app/src/main/java/org/schabi/newpipe/util/NavigationHelper.java
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,8 @@ private NavigationHelper() {
@NonNull
public static <T> Intent getPlayerIntent(@NonNull final Context context,
@NonNull final Class<T> targetClazz,
@Nullable final PlayQueue playQueue) {
@Nullable final PlayQueue playQueue,
final boolean resumePlayback) {
final Intent intent = new Intent(context, targetClazz);

if (playQueue != null) {
Expand All @@ -87,6 +88,7 @@ public static <T> Intent getPlayerIntent(@NonNull final Context context,
}
}
intent.putExtra(Player.PLAYER_TYPE, MainPlayer.PlayerType.VIDEO.ordinal());
intent.putExtra(Player.RESUME_PLAYBACK, resumePlayback);

return intent;
}
Expand All @@ -95,24 +97,33 @@ public static <T> Intent getPlayerIntent(@NonNull final Context context,
public static <T> Intent getPlayerIntent(@NonNull final Context context,
@NonNull final Class<T> targetClazz,
@Nullable final PlayQueue playQueue,
final boolean resumePlayback,
final boolean playWhenReady) {
return getPlayerIntent(context, targetClazz, playQueue)
return getPlayerIntent(context, targetClazz, playQueue, resumePlayback)
.putExtra(Player.PLAY_WHEN_READY, playWhenReady);
}

@NonNull
public static <T> Intent getPlayerEnqueueIntent(@NonNull final Context context,
@NonNull final Class<T> targetClazz,
@Nullable final PlayQueue playQueue) {
return getPlayerIntent(context, targetClazz, playQueue)
// when enqueueing `resumePlayback` is always `false` since:
// - if there is a video already playing, the value of `resumePlayback` just doesn't make
// any difference.
// - if there is nothing already playing, it is useful for the enqueue action to have a
// slightly different behaviour than the normal play action: the latter resumes playback,
// the former doesn't. (note that enqueue can be triggered when nothing is playing only
// by long pressing the video detail fragment, playlist or channel controls
return getPlayerIntent(context, targetClazz, playQueue, false)
.putExtra(Player.ENQUEUE, true);
}

@NonNull
public static <T> Intent getPlayerEnqueueNextIntent(@NonNull final Context context,
@NonNull final Class<T> targetClazz,
@Nullable final PlayQueue playQueue) {
return getPlayerIntent(context, targetClazz, playQueue)
// see comment in `getPlayerEnqueueIntent` as to why `resumePlayback` is false
return getPlayerIntent(context, targetClazz, playQueue, false)
.putExtra(Player.ENQUEUE_NEXT, true);
}

Expand Down
2 changes: 2 additions & 0 deletions fastlane/metadata/android/en-US/changelogs/979.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
- Fixed resuming playback
- Improvements to ensure that the service which determines if NewPipe should check for a new version checks is not started in background