Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/dev' into feat/patcher_instruc…
Browse files Browse the repository at this point in the history
…tion_filters

# Conflicts:
#	patches/src/main/kotlin/app/revanced/patches/youtube/video/speed/custom/CustomPlaybackSpeedPatch.kt
  • Loading branch information
LisoUseInAIKyrios committed Jan 18, 2025
2 parents ce7613f + 02fb26e commit 8a9c5ab
Show file tree
Hide file tree
Showing 9 changed files with 76 additions and 9 deletions.
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
# [5.9.0-dev.1](https://github.com/ReVanced/revanced-patches/compare/v5.8.2-dev.1...v5.9.0-dev.1) (2025-01-17)


### Features

* **YouTube - Hide feed components:** Handle new type of surveys ([#4295](https://github.com/ReVanced/revanced-patches/issues/4295)) ([c770e03](https://github.com/ReVanced/revanced-patches/commit/c770e03f3801367cb531af860fbdfa43dca89af0))

## [5.8.2-dev.1](https://github.com/ReVanced/revanced-patches/compare/v5.8.1...v5.8.2-dev.1) (2025-01-09)


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,8 @@ public LayoutComponentsFilter() {
inFeedSurvey = new StringFilterGroup(
Settings.HIDE_FEED_SURVEY,
"in_feed_survey",
"slimline_survey"
"slimline_survey",
"feed_nudge"
);

final var medicalPanel = new StringFilterGroup(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,11 @@ public class CustomPlaybackSpeedPatch {
*/
public static final float PLAYBACK_SPEED_MAXIMUM = 8;

/**
* Tap and hold speed.
*/
private static final float TAP_AND_HOLD_SPEED;

/**
* Custom playback speeds.
*/
Expand All @@ -48,12 +53,27 @@ public class CustomPlaybackSpeedPatch {
private static String[] preferenceListEntries, preferenceListEntryValues;

static {
final float holdSpeed = Settings.SPEED_TAP_AND_HOLD.get();
if (holdSpeed > 0 && holdSpeed <= PLAYBACK_SPEED_MAXIMUM) {
TAP_AND_HOLD_SPEED = holdSpeed;
} else {
showInvalidCustomSpeedToast();
Settings.SPEED_TAP_AND_HOLD.resetToDefault();
TAP_AND_HOLD_SPEED = Settings.SPEED_TAP_AND_HOLD.get();
}

loadCustomSpeeds();
}

private static void resetCustomSpeeds(@NonNull String toastMessage) {
Utils.showToastLong(toastMessage);
Settings.CUSTOM_PLAYBACK_SPEEDS.resetToDefault();
/**
* Injection point.
*/
public static float tapAndHoldSpeed() {
return TAP_AND_HOLD_SPEED;
}

private static void showInvalidCustomSpeedToast() {
Utils.showToastLong(str("revanced_custom_playback_speeds_invalid", PLAYBACK_SPEED_MAXIMUM));
}

private static void loadCustomSpeeds() {
Expand All @@ -74,17 +94,18 @@ private static void loadCustomSpeeds() {
}

if (speedFloat >= PLAYBACK_SPEED_MAXIMUM) {
resetCustomSpeeds(str("revanced_custom_playback_speeds_invalid", PLAYBACK_SPEED_MAXIMUM));
showInvalidCustomSpeedToast();
Settings.CUSTOM_PLAYBACK_SPEEDS.resetToDefault();
loadCustomSpeeds();
return;
}

customPlaybackSpeeds[i] = speedFloat;
i++;
customPlaybackSpeeds[i++] = speedFloat;
}
} catch (Exception ex) {
Logger.printInfo(() -> "parse error", ex);
resetCustomSpeeds(str("revanced_custom_playback_speeds_parse_exception"));
Utils.showToastLong(str("revanced_custom_playback_speeds_parse_exception"));
Settings.CUSTOM_PLAYBACK_SPEEDS.resetToDefault();
loadCustomSpeeds();
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ public class Settings extends BaseSettings {
public static final IntegerSetting VIDEO_QUALITY_DEFAULT_WIFI = new IntegerSetting("revanced_video_quality_default_wifi", -2);
public static final IntegerSetting VIDEO_QUALITY_DEFAULT_MOBILE = new IntegerSetting("revanced_video_quality_default_mobile", -2);
// Speed
public static final FloatSetting SPEED_TAP_AND_HOLD = new FloatSetting("revanced_speed_tap_and_hold", 2.0f, true);
public static final BooleanSetting REMEMBER_PLAYBACK_SPEED_LAST_SELECTED = new BooleanSetting("revanced_remember_playback_speed_last_selected", FALSE);
public static final BooleanSetting CUSTOM_SPEED_MENU = new BooleanSetting("revanced_custom_speed_menu", TRUE);
public static final FloatSetting PLAYBACK_SPEED_DEFAULT = new FloatSetting("revanced_playback_speed_default", -2.0f);
Expand Down
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@ org.gradle.jvmargs = -Xms512M -Xmx2048M
org.gradle.parallel = true
android.useAndroidX = true
kotlin.code.style = official
version = 5.8.2-dev.1
version = 5.9.0-dev.1
1 change: 1 addition & 0 deletions patches/api/patches.api
Original file line number Diff line number Diff line change
Expand Up @@ -660,6 +660,7 @@ public class app/revanced/patches/shared/misc/settings/preference/BasePreference

public final class app/revanced/patches/shared/misc/settings/preference/InputType : java/lang/Enum {
public static final field NUMBER Lapp/revanced/patches/shared/misc/settings/preference/InputType;
public static final field NUMBER_DECIMAL Lapp/revanced/patches/shared/misc/settings/preference/InputType;
public static final field TEXT Lapp/revanced/patches/shared/misc/settings/preference/InputType;
public static final field TEXT_CAP_CHARACTERS Lapp/revanced/patches/shared/misc/settings/preference/InputType;
public static final field TEXT_MULTI_LINE Lapp/revanced/patches/shared/misc/settings/preference/InputType;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,5 @@ enum class InputType(val type: String) {
TEXT_CAP_CHARACTERS("textCapCharacters"),
TEXT_MULTI_LINE("textMultiLine"),
NUMBER("number"),
NUMBER_DECIMAL("numberDecimal"),
}
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,19 @@ import app.revanced.patches.shared.misc.mapping.resourceMappingPatch
import app.revanced.patches.shared.misc.settings.preference.InputType
import app.revanced.patches.shared.misc.settings.preference.SwitchPreference
import app.revanced.patches.shared.misc.settings.preference.TextPreference
import app.revanced.patches.youtube.interaction.seekbar.disableFastForwardNoticeFingerprint
import app.revanced.patches.youtube.misc.extension.sharedExtensionPatch
import app.revanced.patches.youtube.misc.litho.filter.addLithoFilter
import app.revanced.patches.youtube.misc.litho.filter.lithoFilterPatch
import app.revanced.patches.youtube.misc.playservice.is_19_25_or_greater
import app.revanced.patches.youtube.misc.playservice.versionCheckPatch
import app.revanced.patches.youtube.misc.recyclerviewtree.hook.addRecyclerViewTreeHook
import app.revanced.patches.youtube.misc.recyclerviewtree.hook.recyclerViewTreeHookPatch
import app.revanced.patches.youtube.misc.settings.PreferenceScreen
import app.revanced.patches.youtube.misc.settings.settingsPatch
import app.revanced.util.*
import com.android.tools.smali.dexlib2.AccessFlags
import com.android.tools.smali.dexlib2.iface.instruction.NarrowLiteralInstruction
import com.android.tools.smali.dexlib2.iface.instruction.OneRegisterInstruction
import com.android.tools.smali.dexlib2.immutable.ImmutableField

Expand All @@ -42,6 +46,7 @@ internal val customPlaybackSpeedPatch = bytecodePatch(
recyclerViewTreeHookPatch,
addResourcesPatch,
resourceMappingPatch,
versionCheckPatch
)

execute {
Expand All @@ -52,6 +57,12 @@ internal val customPlaybackSpeedPatch = bytecodePatch(
TextPreference("revanced_custom_playback_speeds", inputType = InputType.TEXT_MULTI_LINE),
)

if (is_19_25_or_greater) {
PreferenceScreen.VIDEO.addPreferences(
TextPreference("revanced_speed_tap_and_hold", inputType = InputType.NUMBER_DECIMAL),
)
}

// Replace the speeds float array with custom speeds.
speedArrayGeneratorFingerprint.let {
val matches = it.instructionMatches
Expand Down Expand Up @@ -145,5 +156,27 @@ internal val customPlaybackSpeedPatch = bytecodePatch(
addLithoFilter(FILTER_CLASS_DESCRIPTOR)

// endregion


// region Custom tap and hold 2x speed.

if (is_19_25_or_greater) {
disableFastForwardNoticeFingerprint.method.apply {
val index = indexOfFirstInstructionOrThrow {
(this as? NarrowLiteralInstruction)?.narrowLiteral == 2.0f.toRawBits()
}
val register = getInstruction<OneRegisterInstruction>(index).registerA

addInstructions(
index + 1,
"""
invoke-static {}, $EXTENSION_CLASS_DESCRIPTOR->tapAndHoldSpeed()F
move-result v$register
"""
)
}
}

// endregion
}
}
2 changes: 2 additions & 0 deletions patches/src/main/resources/addresources/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -1351,6 +1351,8 @@ Enabling this can unlock higher video qualities"</string>
<string name="revanced_custom_playback_speeds_invalid">Custom speeds must be less than %s</string>
<string name="revanced_custom_playback_speeds_parse_exception">Invalid custom playback speeds</string>
<string name="revanced_custom_playback_speeds_auto">Auto</string>
<string name="revanced_speed_tap_and_hold_title">Custom tap and hold speed</string>
<string name="revanced_speed_tap_and_hold_summary">Playback speed between 0-8</string>
</patch>
<patch id="video.speed.remember.rememberPlaybackSpeedPatch">
<string name="revanced_remember_playback_speed_last_selected_title">Remember playback speed changes</string>
Expand Down

0 comments on commit 8a9c5ab

Please sign in to comment.