mirror of
https://github.com/inotia00/revanced-patches.git
synced 2025-05-02 23:54:33 +02:00
feat(YouTube - Fullscreen components): Remove Force fullscreen
setting
This commit is contained in:
parent
c6ad8331bc
commit
a596959d71
@ -5,8 +5,6 @@ import static app.revanced.extension.shared.utils.Utils.hideViewByRemovingFromPa
|
|||||||
import static app.revanced.extension.shared.utils.Utils.hideViewUnderCondition;
|
import static app.revanced.extension.shared.utils.Utils.hideViewUnderCondition;
|
||||||
import static app.revanced.extension.youtube.utils.ExtendedUtils.validateValue;
|
import static app.revanced.extension.youtube.utils.ExtendedUtils.validateValue;
|
||||||
|
|
||||||
import android.app.Activity;
|
|
||||||
import android.content.pm.ActivityInfo;
|
|
||||||
import android.support.v7.widget.RecyclerView;
|
import android.support.v7.widget.RecyclerView;
|
||||||
import android.util.TypedValue;
|
import android.util.TypedValue;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
@ -20,7 +18,6 @@ import androidx.annotation.NonNull;
|
|||||||
import androidx.annotation.Nullable;
|
import androidx.annotation.Nullable;
|
||||||
import androidx.coordinatorlayout.widget.CoordinatorLayout;
|
import androidx.coordinatorlayout.widget.CoordinatorLayout;
|
||||||
|
|
||||||
import java.lang.ref.WeakReference;
|
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
|
|
||||||
import app.revanced.extension.shared.settings.BaseSettings;
|
import app.revanced.extension.shared.settings.BaseSettings;
|
||||||
@ -328,37 +325,6 @@ public class PlayerPatch {
|
|||||||
Utils.runOnMainThreadDelayed(() -> isScreenOn = false, Settings.KEEP_LANDSCAPE_MODE_TIMEOUT.get());
|
Utils.runOnMainThreadDelayed(() -> isScreenOn = false, Settings.KEEP_LANDSCAPE_MODE_TIMEOUT.get());
|
||||||
}
|
}
|
||||||
|
|
||||||
private static WeakReference<Activity> watchDescriptorActivityRef = new WeakReference<>(null);
|
|
||||||
private static volatile boolean isLandScapeVideo = true;
|
|
||||||
|
|
||||||
public static void setWatchDescriptorActivity(Activity activity) {
|
|
||||||
watchDescriptorActivityRef = new WeakReference<>(activity);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static boolean forceFullscreen(boolean original) {
|
|
||||||
if (!Settings.FORCE_FULLSCREEN.get())
|
|
||||||
return original;
|
|
||||||
|
|
||||||
Utils.runOnMainThreadDelayed(PlayerPatch::setOrientation, 1000);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
private static void setOrientation() {
|
|
||||||
final Activity watchDescriptorActivity = watchDescriptorActivityRef.get();
|
|
||||||
final int requestedOrientation = isLandScapeVideo
|
|
||||||
? ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE
|
|
||||||
: watchDescriptorActivity.getRequestedOrientation();
|
|
||||||
|
|
||||||
watchDescriptorActivity.setRequestedOrientation(requestedOrientation);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void setVideoPortrait(int width, int height) {
|
|
||||||
if (!Settings.FORCE_FULLSCREEN.get())
|
|
||||||
return;
|
|
||||||
|
|
||||||
isLandScapeVideo = width > height;
|
|
||||||
}
|
|
||||||
|
|
||||||
// endregion
|
// endregion
|
||||||
|
|
||||||
// region [Hide comments component] patch
|
// region [Hide comments component] patch
|
||||||
|
@ -353,7 +353,6 @@ public class Settings extends BaseSettings {
|
|||||||
|
|
||||||
public static final BooleanSetting DISABLE_LANDSCAPE_MODE = new BooleanSetting("revanced_disable_landscape_mode", FALSE, true);
|
public static final BooleanSetting DISABLE_LANDSCAPE_MODE = new BooleanSetting("revanced_disable_landscape_mode", FALSE, true);
|
||||||
public static final BooleanSetting ENABLE_COMPACT_CONTROLS_OVERLAY = new BooleanSetting("revanced_enable_compact_controls_overlay", FALSE, true);
|
public static final BooleanSetting ENABLE_COMPACT_CONTROLS_OVERLAY = new BooleanSetting("revanced_enable_compact_controls_overlay", FALSE, true);
|
||||||
public static final BooleanSetting FORCE_FULLSCREEN = new BooleanSetting("revanced_force_fullscreen", FALSE, true);
|
|
||||||
public static final BooleanSetting KEEP_LANDSCAPE_MODE = new BooleanSetting("revanced_keep_landscape_mode", FALSE, true);
|
public static final BooleanSetting KEEP_LANDSCAPE_MODE = new BooleanSetting("revanced_keep_landscape_mode", FALSE, true);
|
||||||
public static final LongSetting KEEP_LANDSCAPE_MODE_TIMEOUT = new LongSetting("revanced_keep_landscape_mode_timeout", 3000L, true);
|
public static final LongSetting KEEP_LANDSCAPE_MODE_TIMEOUT = new LongSetting("revanced_keep_landscape_mode_timeout", 3000L, true);
|
||||||
|
|
||||||
|
@ -49,7 +49,6 @@ public class ReVancedSettingsPreference extends ReVancedPreferenceFragment {
|
|||||||
ChangeHeaderPreferenceLinks();
|
ChangeHeaderPreferenceLinks();
|
||||||
ExternalDownloaderPreferenceLinks();
|
ExternalDownloaderPreferenceLinks();
|
||||||
FullScreenPanelPreferenceLinks();
|
FullScreenPanelPreferenceLinks();
|
||||||
LayoutOverrideLinks();
|
|
||||||
MiniPlayerPreferenceLinks();
|
MiniPlayerPreferenceLinks();
|
||||||
NavigationPreferenceLinks();
|
NavigationPreferenceLinks();
|
||||||
RYDPreferenceLinks();
|
RYDPreferenceLinks();
|
||||||
@ -93,16 +92,6 @@ public class ReVancedSettingsPreference extends ReVancedPreferenceFragment {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Enable/Disable Layout Override Preference
|
|
||||||
*/
|
|
||||||
private static void LayoutOverrideLinks() {
|
|
||||||
enableDisablePreferences(
|
|
||||||
ExtendedUtils.isTablet(),
|
|
||||||
Settings.FORCE_FULLSCREEN
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Enable/Disable Preferences not working in tablet layout
|
* Enable/Disable Preferences not working in tablet layout
|
||||||
*/
|
*/
|
||||||
@ -139,17 +128,6 @@ public class ReVancedSettingsPreference extends ReVancedPreferenceFragment {
|
|||||||
Settings.HIDE_QUICK_ACTIONS_SAVE_TO_PLAYLIST_BUTTON,
|
Settings.HIDE_QUICK_ACTIONS_SAVE_TO_PLAYLIST_BUTTON,
|
||||||
Settings.HIDE_QUICK_ACTIONS_SHARE_BUTTON
|
Settings.HIDE_QUICK_ACTIONS_SHARE_BUTTON
|
||||||
);
|
);
|
||||||
|
|
||||||
enableDisablePreferences(
|
|
||||||
Settings.DISABLE_LANDSCAPE_MODE.get(),
|
|
||||||
Settings.FORCE_FULLSCREEN
|
|
||||||
);
|
|
||||||
|
|
||||||
enableDisablePreferences(
|
|
||||||
Settings.FORCE_FULLSCREEN.get(),
|
|
||||||
Settings.DISABLE_LANDSCAPE_MODE
|
|
||||||
);
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -23,19 +23,6 @@ internal val broadcastReceiverFingerprint = legacyFingerprint(
|
|||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|
||||||
internal val clientSettingEndpointFingerprint = legacyFingerprint(
|
|
||||||
name = "clientSettingEndpointFingerprint",
|
|
||||||
returnType = "V",
|
|
||||||
accessFlags = AccessFlags.PUBLIC or AccessFlags.FINAL,
|
|
||||||
parameters = listOf("L", "Ljava/util/Map;"),
|
|
||||||
strings = listOf(
|
|
||||||
"OVERRIDE_EXIT_FULLSCREEN_TO_MAXIMIZED",
|
|
||||||
"force_fullscreen",
|
|
||||||
"start_watch_minimized",
|
|
||||||
"watch"
|
|
||||||
)
|
|
||||||
)
|
|
||||||
|
|
||||||
internal val engagementPanelFingerprint = legacyFingerprint(
|
internal val engagementPanelFingerprint = legacyFingerprint(
|
||||||
name = "engagementPanelFingerprint",
|
name = "engagementPanelFingerprint",
|
||||||
returnType = "L",
|
returnType = "L",
|
||||||
@ -72,10 +59,3 @@ internal val relatedEndScreenResultsFingerprint = legacyFingerprint(
|
|||||||
literals = listOf(appRelatedEndScreenResults),
|
literals = listOf(appRelatedEndScreenResults),
|
||||||
)
|
)
|
||||||
|
|
||||||
internal val videoPortraitParentFingerprint = legacyFingerprint(
|
|
||||||
name = "videoPortraitParentFingerprint",
|
|
||||||
returnType = "V",
|
|
||||||
accessFlags = AccessFlags.PUBLIC or AccessFlags.FINAL,
|
|
||||||
parameters = listOf("L", "Ljava/util/Map;"),
|
|
||||||
strings = listOf("Acquiring NetLatencyActionLogger failed. taskId=")
|
|
||||||
)
|
|
||||||
|
@ -42,7 +42,6 @@ import com.android.tools.smali.dexlib2.Opcode
|
|||||||
import com.android.tools.smali.dexlib2.iface.instruction.FiveRegisterInstruction
|
import com.android.tools.smali.dexlib2.iface.instruction.FiveRegisterInstruction
|
||||||
import com.android.tools.smali.dexlib2.iface.instruction.OneRegisterInstruction
|
import com.android.tools.smali.dexlib2.iface.instruction.OneRegisterInstruction
|
||||||
import com.android.tools.smali.dexlib2.iface.instruction.ReferenceInstruction
|
import com.android.tools.smali.dexlib2.iface.instruction.ReferenceInstruction
|
||||||
import com.android.tools.smali.dexlib2.iface.instruction.TwoRegisterInstruction
|
|
||||||
import com.android.tools.smali.dexlib2.iface.instruction.WideLiteralInstruction
|
import com.android.tools.smali.dexlib2.iface.instruction.WideLiteralInstruction
|
||||||
import com.android.tools.smali.dexlib2.iface.reference.MethodReference
|
import com.android.tools.smali.dexlib2.iface.reference.MethodReference
|
||||||
|
|
||||||
@ -198,60 +197,6 @@ val fullscreenComponentsPatch = bytecodePatch(
|
|||||||
|
|
||||||
// endregion
|
// endregion
|
||||||
|
|
||||||
// region patch for force fullscreen
|
|
||||||
|
|
||||||
clientSettingEndpointFingerprint.methodOrThrow().apply {
|
|
||||||
val getActivityIndex = indexOfFirstStringInstructionOrThrow("watch") + 2
|
|
||||||
val getActivityReference =
|
|
||||||
getInstruction<ReferenceInstruction>(getActivityIndex).reference
|
|
||||||
val classRegister =
|
|
||||||
getInstruction<TwoRegisterInstruction>(getActivityIndex).registerB
|
|
||||||
|
|
||||||
val watchDescriptorMethodIndex =
|
|
||||||
indexOfFirstStringInstructionOrThrow("start_watch_minimized") - 1
|
|
||||||
val watchDescriptorRegister =
|
|
||||||
getInstruction<FiveRegisterInstruction>(watchDescriptorMethodIndex).registerD
|
|
||||||
|
|
||||||
addInstructions(
|
|
||||||
watchDescriptorMethodIndex, """
|
|
||||||
invoke-static {v$watchDescriptorRegister}, $PLAYER_CLASS_DESCRIPTOR->forceFullscreen(Z)Z
|
|
||||||
move-result v$watchDescriptorRegister
|
|
||||||
"""
|
|
||||||
)
|
|
||||||
|
|
||||||
// hooks Activity.
|
|
||||||
val insertIndex = indexOfFirstStringInstructionOrThrow("force_fullscreen")
|
|
||||||
val freeRegister = getInstruction<OneRegisterInstruction>(insertIndex).registerA
|
|
||||||
|
|
||||||
addInstructions(
|
|
||||||
insertIndex, """
|
|
||||||
iget-object v$freeRegister, v$classRegister, $getActivityReference
|
|
||||||
check-cast v$freeRegister, Landroid/app/Activity;
|
|
||||||
invoke-static {v$freeRegister}, $PLAYER_CLASS_DESCRIPTOR->setWatchDescriptorActivity(Landroid/app/Activity;)V
|
|
||||||
"""
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
||||||
videoPortraitParentFingerprint.methodOrThrow().apply {
|
|
||||||
val stringIndex =
|
|
||||||
indexOfFirstStringInstructionOrThrow("Acquiring NetLatencyActionLogger failed. taskId=")
|
|
||||||
val invokeIndex =
|
|
||||||
indexOfFirstInstructionOrThrow(stringIndex, Opcode.INVOKE_INTERFACE)
|
|
||||||
val targetIndex = indexOfFirstInstructionOrThrow(invokeIndex, Opcode.CHECK_CAST)
|
|
||||||
val targetClass =
|
|
||||||
getInstruction<ReferenceInstruction>(targetIndex).reference.toString()
|
|
||||||
|
|
||||||
// add an instruction to check the vertical video
|
|
||||||
findMethodOrThrow(targetClass) {
|
|
||||||
parameters == listOf("I", "I", "Z")
|
|
||||||
}.addInstruction(
|
|
||||||
1,
|
|
||||||
"invoke-static {p1, p2}, $PLAYER_CLASS_DESCRIPTOR->setVideoPortrait(II)V"
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
||||||
// endregion
|
|
||||||
|
|
||||||
// region patch for disable landscape mode
|
// region patch for disable landscape mode
|
||||||
|
|
||||||
onConfigurationChangedMethod.apply {
|
onConfigurationChangedMethod.apply {
|
||||||
|
@ -980,11 +980,6 @@ Limitation: Video title disappears when clicked."</string>
|
|||||||
<string name="revanced_enable_compact_controls_overlay_title">Enable compact controls overlay</string>
|
<string name="revanced_enable_compact_controls_overlay_title">Enable compact controls overlay</string>
|
||||||
<string name="revanced_enable_compact_controls_overlay_summary_on">Controls overlay does not fill the fullscreen.</string>
|
<string name="revanced_enable_compact_controls_overlay_summary_on">Controls overlay does not fill the fullscreen.</string>
|
||||||
<string name="revanced_enable_compact_controls_overlay_summary_off">Controls overlay fills the fullscreen.</string>
|
<string name="revanced_enable_compact_controls_overlay_summary_off">Controls overlay fills the fullscreen.</string>
|
||||||
<string name="revanced_force_fullscreen_title">Force fullscreen</string>
|
|
||||||
<string name="revanced_force_fullscreen_summary">"Videos will be switched to fullscreen in the following situations:
|
|
||||||
|
|
||||||
• When a video is started.
|
|
||||||
• When a timestamp in the comments is clicked on."</string>
|
|
||||||
<string name="revanced_keep_landscape_mode_title">Keep landscape mode</string>
|
<string name="revanced_keep_landscape_mode_title">Keep landscape mode</string>
|
||||||
<string name="revanced_keep_landscape_mode_summary">Keeps landscape mode when turning the screen off and on in fullscreen.</string>
|
<string name="revanced_keep_landscape_mode_summary">Keeps landscape mode when turning the screen off and on in fullscreen.</string>
|
||||||
<string name="revanced_keep_landscape_mode_timeout_title">Keep landscape mode timeout</string>
|
<string name="revanced_keep_landscape_mode_timeout_title">Keep landscape mode timeout</string>
|
||||||
|
@ -416,8 +416,7 @@
|
|||||||
</PreferenceCategory>
|
</PreferenceCategory>
|
||||||
<PreferenceCategory android:title="@string/revanced_preference_category_experimental_flag" android:layout="@layout/revanced_settings_preferences_category"/>
|
<PreferenceCategory android:title="@string/revanced_preference_category_experimental_flag" android:layout="@layout/revanced_settings_preferences_category"/>
|
||||||
<SwitchPreference android:title="@string/revanced_disable_landscape_mode_title" android:key="revanced_disable_landscape_mode" android:summaryOn="@string/revanced_disable_landscape_mode_summary_on" android:summaryOff="@string/revanced_disable_landscape_mode_summary_off" />
|
<SwitchPreference android:title="@string/revanced_disable_landscape_mode_title" android:key="revanced_disable_landscape_mode" android:summaryOn="@string/revanced_disable_landscape_mode_summary_on" android:summaryOff="@string/revanced_disable_landscape_mode_summary_off" />
|
||||||
<SwitchPreference android:title="@string/revanced_enable_compact_controls_overlay_title" android:key="revanced_enable_compact_controls_overlay" android:summaryOn="@string/revanced_enable_compact_controls_overlay_summary_on" android:summaryOff="@string/revanced_enable_compact_controls_overlay_summary_off" />
|
<SwitchPreference android:title="@string/revanced_enable_compact_controls_overlay_title" android:key="revanced_enable_compact_controls_overlay" android:summaryOn="@string/revanced_enable_compact_controls_overlay_summary_on" android:summaryOff="@string/revanced_enable_compact_controls_overlay_summary_off" />SETTINGS: FULLSCREEN_COMPONENTS -->
|
||||||
<SwitchPreference android:title="@string/revanced_force_fullscreen_title" android:key="revanced_force_fullscreen" android:summary="@string/revanced_force_fullscreen_summary" />SETTINGS: FULLSCREEN_COMPONENTS -->
|
|
||||||
|
|
||||||
<!-- SETTINGS: KEEP_LANDSCAPE_MODE
|
<!-- SETTINGS: KEEP_LANDSCAPE_MODE
|
||||||
<SwitchPreference android:title="@string/revanced_keep_landscape_mode_title" android:key="revanced_keep_landscape_mode" android:summary="@string/revanced_keep_landscape_mode_summary" />
|
<SwitchPreference android:title="@string/revanced_keep_landscape_mode_title" android:key="revanced_keep_landscape_mode" android:summary="@string/revanced_keep_landscape_mode_summary" />
|
||||||
|
Loading…
x
Reference in New Issue
Block a user