persist incognito flag upon app reboot

This commit is contained in:
Yuriy Liskov
2025-08-28 20:38:33 +03:00
parent 19cca5a2e9
commit 762645602c
7 changed files with 22 additions and 12 deletions

View File

@@ -65,8 +65,8 @@ public class VideoLoaderController extends BasePlayerController {
private final Runnable mRebootApp = () -> {
Video video = getVideo();
if (getPlayer() != null && video != null && video.hasVideo()) {
Utils.restartTheApp(getContext(), video.videoId, getPlayer().getPositionMs());
if (getPlayer() != null) {
Utils.restartTheApp(getContext(), video, getPlayer().getPositionMs());
}
};
private final Runnable mOnApplyPlaybackMode = () -> {

View File

@@ -90,13 +90,13 @@ public class PlaybackPresenter extends BasePresenter<PlaybackView> implements Pl
}
public void openVideo(String videoId) {
openVideo(videoId, false, -1);
openVideo(videoId, false, -1, false);
}
/**
* Opens video item from splash view
*/
public void openVideo(String videoId, boolean finishOnEnded, long timeMs) {
public void openVideo(String videoId, boolean finishOnEnded, long timeMs, boolean incognito) {
if (videoId == null) {
return;
}
@@ -104,6 +104,7 @@ public class PlaybackPresenter extends BasePresenter<PlaybackView> implements Pl
Video video = Video.from(videoId);
video.finishOnEnded = finishOnEnded;
video.pendingPosMs = timeMs;
video.incognito = incognito;
openVideo(video);
}

View File

@@ -6,7 +6,7 @@ import android.content.Intent;
import com.liskovsoft.mediaserviceinterfaces.oauth.Account;
import com.liskovsoft.mediaserviceinterfaces.data.MediaGroup;
import com.liskovsoft.sharedutils.GlobalConstants;
import com.liskovsoft.sharedutils.helpers.GlobalConstants;
import com.liskovsoft.sharedutils.helpers.Helpers;
import com.liskovsoft.sharedutils.helpers.MessageHelpers;
import com.liskovsoft.sharedutils.mylogger.Log;
@@ -276,7 +276,9 @@ public class SplashPresenter extends BasePresenter<SplashView> {
if (videoId != null) {
long timeMs = IntentExtractor.extractVideoTimeMs(intent);
PlaybackPresenter playbackPresenter = PlaybackPresenter.instance(getContext());
playbackPresenter.openVideo(videoId, IntentExtractor.hasFinishOnEndedFlag(intent), timeMs);
boolean finishOnEnded = IntentExtractor.hasFinishOnEndedFlag(intent);
boolean incognito = intent.getBooleanExtra(GlobalConstants.INCOGNITO_INTENT, false);
playbackPresenter.openVideo(videoId, finishOnEnded, timeMs, incognito);
enablePlayerOnlyModeIfNeeded(intent);

View File

@@ -54,13 +54,14 @@ import androidx.work.PeriodicWorkRequest;
import androidx.work.WorkManager;
import com.jakewharton.processphoenix.ProcessPhoenix;
import com.liskovsoft.sharedutils.GlobalConstants;
import com.liskovsoft.sharedutils.helpers.GlobalConstants;
import com.liskovsoft.sharedutils.helpers.Helpers;
import com.liskovsoft.sharedutils.helpers.MessageHelpers;
import com.liskovsoft.sharedutils.misc.WeakHashSet;
import com.liskovsoft.sharedutils.mylogger.Log;
import com.liskovsoft.smartyoutubetv2.common.BuildConfig;
import com.liskovsoft.smartyoutubetv2.common.R;
import com.liskovsoft.smartyoutubetv2.common.app.models.data.Video;
import com.liskovsoft.smartyoutubetv2.common.app.models.playback.manager.PlayerConstants;
import com.liskovsoft.smartyoutubetv2.common.app.models.playback.manager.PlayerManager;
import com.liskovsoft.smartyoutubetv2.common.app.models.playback.service.VideoStateService;
@@ -907,15 +908,20 @@ public class Utils {
}
}
public static void restartTheApp(Context context, String videoId, long posMs) {
public static void restartTheApp(Context context, Video video, long posMs) {
if (video == null || !video.hasVideo()) {
return;
}
try {
Intent intent = new Intent(
Intent.ACTION_VIEW,
Uri.parse(String.format("https://www.youtube.com/watch?v=%s&t=%ss", videoId, posMs / 1_000)),
Uri.parse(String.format("https://www.youtube.com/watch?v=%s&t=%ss", video.videoId, posMs / 1_000)),
context,
Class.forName(BOOTSTRAP_ACTIVITY_CLASS_NAME)
);
intent.putExtra(GlobalConstants.RESTART_INTENT, true);
intent.putExtra(GlobalConstants.INCOGNITO_INTENT, video.incognito);
ProcessPhoenix.triggerRebirth(context, intent);
} catch (ClassNotFoundException e) {
e.printStackTrace();

View File

@@ -7,10 +7,11 @@ import android.content.Context;
import android.content.Intent;
import android.net.Uri;
import android.os.Build;
import com.liskovsoft.sharedutils.GlobalConstants;
import com.liskovsoft.sharedutils.configparser.AssetPropertyParser2;
import com.liskovsoft.sharedutils.configparser.ConfigParser;
import com.liskovsoft.sharedutils.helpers.AppInfoHelpers;
import com.liskovsoft.sharedutils.helpers.GlobalConstants;
public class AppUtil {
private final Context mContext;