Fixed issue where private mode would not re-appear after closing the video.

This commit is contained in:
Koen J 2025-05-12 08:43:02 +02:00
commit 1d7429ad86
5 changed files with 22 additions and 2 deletions

View file

@ -217,6 +217,8 @@ private fun ByteArray.toInetAddress(): InetAddress {
}
fun getConnectedSocket(attemptAddresses: List<InetAddress>, port: Int): Socket? {
ensureNotMainThread()
val timeout = 2000

View file

@ -22,6 +22,7 @@ import android.widget.ImageView
import androidx.activity.result.ActivityResult
import androidx.activity.result.ActivityResultLauncher
import androidx.activity.result.contract.ActivityResultContracts
import androidx.annotation.OptIn
import androidx.appcompat.app.AppCompatActivity
import androidx.constraintlayout.motion.widget.MotionLayout
import androidx.core.app.ActivityCompat
@ -66,6 +67,7 @@ import com.futo.platformplayer.fragment.mainactivity.main.SubscriptionsFeedFragm
import com.futo.platformplayer.fragment.mainactivity.main.SuggestionsFragment
import com.futo.platformplayer.fragment.mainactivity.main.TutorialFragment
import com.futo.platformplayer.fragment.mainactivity.main.VideoDetailFragment
import com.futo.platformplayer.fragment.mainactivity.main.VideoDetailFragment.State
import com.futo.platformplayer.fragment.mainactivity.main.WatchLaterFragment
import com.futo.platformplayer.fragment.mainactivity.topbar.AddTopBarFragment
import com.futo.platformplayer.fragment.mainactivity.topbar.GeneralTopBarFragment
@ -359,6 +361,7 @@ class MainActivity : AppCompatActivity, IWithResultLauncher {
_fragMainSubscriptionsFeed.setPreviewsEnabled(true);
_fragContainerVideoDetail.visibility = View.INVISIBLE;
updateSegmentPaddings();
updatePrivateModeVisibility()
};
@ -640,8 +643,9 @@ class MainActivity : AppCompatActivity, IWithResultLauncher {
}
}
@OptIn(UnstableApi::class)
fun updatePrivateModeVisibility() {
if (_privateModeEnabled && !_pictureInPictureEnabled && !_isFullscreen && !_isMinimized) {
if (_privateModeEnabled && (_fragVideoDetail.state == State.CLOSED || !_pictureInPictureEnabled && !_isFullscreen && !_isMinimized)) {
_buttonIncognito.elevation = 99f;
_buttonIncognito.alpha = 1f;
_buttonIncognito.layoutParams = _buttonIncognito.layoutParams.apply {

View file

@ -90,6 +90,7 @@ open class ManagedHttpClient {
}
fun tryHead(url: String): Map<String, String>? {
ensureNotMainThread()
try {
val result = head(url);
if(result.isOk)
@ -104,7 +105,7 @@ open class ManagedHttpClient {
}
fun socket(url: String, headers: MutableMap<String, String> = HashMap(), listener: SocketListener): Socket {
ensureNotMainThread()
val requestBuilder: okhttp3.Request.Builder = okhttp3.Request.Builder()
.url(url);
if(user_agent.isNotEmpty() && !headers.any { it.key.lowercase() == "user-agent" })
@ -300,6 +301,7 @@ open class ManagedHttpClient {
}
fun send(msg: String) {
ensureNotMainThread()
socket.send(msg);
}

View file

@ -1,5 +1,6 @@
package com.futo.platformplayer.sync.internal
import com.futo.platformplayer.ensureNotMainThread
import com.futo.platformplayer.logging.Logger
import com.futo.platformplayer.noise.protocol.CipherStatePair
import com.futo.platformplayer.noise.protocol.DHState
@ -54,6 +55,7 @@ class ChannelSocket(private val session: SyncSocketSession) : IChannel {
}
override fun send(opcode: UByte, subOpcode: UByte, data: ByteBuffer?, contentEncoding: ContentEncoding?) {
ensureNotMainThread()
if (data != null) {
session.send(opcode, subOpcode, data, contentEncoding)
} else {
@ -152,6 +154,7 @@ class ChannelRelayed(
private fun sendPacket(packet: ByteArray) {
throwIfDisposed()
ensureNotMainThread()
synchronized(sendLock) {
val encryptedPayload = ByteArray(packet.size + 16)
@ -169,6 +172,7 @@ class ChannelRelayed(
fun sendError(errorCode: SyncErrorCode) {
throwIfDisposed()
ensureNotMainThread()
synchronized(sendLock) {
val packet = ByteArray(4)
@ -189,6 +193,7 @@ class ChannelRelayed(
override fun send(opcode: UByte, subOpcode: UByte, data: ByteBuffer?, ce: ContentEncoding?) {
throwIfDisposed()
ensureNotMainThread()
var contentEncoding: ContentEncoding? = ce
var processedData = data
@ -272,6 +277,7 @@ class ChannelRelayed(
fun sendRequestTransport(requestId: Int, publicKey: String, appId: UInt, pairingCode: String? = null) {
throwIfDisposed()
ensureNotMainThread()
synchronized(sendLock) {
val channelMessage = ByteArray(1024)
@ -312,6 +318,7 @@ class ChannelRelayed(
fun sendResponseTransport(remoteVersion: Int, requestId: Int, handshakeMessage: ByteArray) {
throwIfDisposed()
ensureNotMainThread()
synchronized(sendLock) {
val message = ByteArray(1024)

View file

@ -1,6 +1,7 @@
package com.futo.platformplayer.sync.internal
import com.futo.platformplayer.UIDialogs
import com.futo.platformplayer.ensureNotMainThread
import com.futo.platformplayer.logging.Logger
import com.futo.platformplayer.models.Subscription
import com.futo.platformplayer.states.StateSubscriptions
@ -192,18 +193,22 @@ class SyncSession : IAuthorizable {
}
inline fun <reified T> sendJsonData(subOpcode: UByte, data: T) {
ensureNotMainThread()
send(Opcode.DATA.value, subOpcode, Json.encodeToString(data))
}
fun sendData(subOpcode: UByte, data: String) {
ensureNotMainThread()
send(Opcode.DATA.value, subOpcode, ByteBuffer.wrap(data.toByteArray(Charsets.UTF_8)), ContentEncoding.Gzip)
}
fun send(opcode: UByte, subOpcode: UByte, data: String) {
ensureNotMainThread()
send(opcode, subOpcode, ByteBuffer.wrap(data.toByteArray(Charsets.UTF_8)), ContentEncoding.Gzip)
}
fun send(opcode: UByte, subOpcode: UByte, data: ByteBuffer? = null, contentEncoding: ContentEncoding? = null) {
ensureNotMainThread()
val channels = synchronized(_channels) { _channels.sortedBy { it.linkType.ordinal }.toList() }
if (channels.isEmpty()) {
//TODO: Should this throw?