generated from ReVanced/revanced-patches-template
-
-
Notifications
You must be signed in to change notification settings - Fork 310
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor into DisableAutoAudioTracksPatch
- Loading branch information
1 parent
185add7
commit 735d1ca
Showing
13 changed files
with
237 additions
and
273 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
71 changes: 0 additions & 71 deletions
71
...src/main/java/app/revanced/extension/youtube/patches/ChangeDefaultAudioLanguagePatch.java
This file was deleted.
Oops, something went wrong.
41 changes: 41 additions & 0 deletions
41
...ube/src/main/java/app/revanced/extension/youtube/patches/DisableAutoAudioTracksPatch.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
package app.revanced.extension.youtube.patches; | ||
|
||
import app.revanced.extension.shared.Logger; | ||
import app.revanced.extension.youtube.settings.Settings; | ||
|
||
@SuppressWarnings("unused") | ||
public class DisableAutoAudioTracksPatch { | ||
|
||
private static final String DEFAULT_AUDIO_TRACKS_IDENTIFIER = "original"; | ||
|
||
/** | ||
* Injection point. | ||
*/ | ||
public static boolean isDefaultAudioStream(boolean isDefault, String audioTrackId, String audioTrackDisplayName) { | ||
try { | ||
if (!Settings.DISABLE_AUTO_AUDIO_TRACKS.get()) { | ||
return isDefault; | ||
} | ||
|
||
if (audioTrackDisplayName.isEmpty()) { | ||
// Older app targets can have empty audio tracks and these might be placeholders. | ||
// The real audio tracks are called after these. | ||
return isDefault; | ||
} | ||
|
||
Logger.printDebug(() -> "default: " + String.format("%-5s", isDefault) + " id: " | ||
+ String.format("%-8s", audioTrackId) + " name:" + audioTrackDisplayName); | ||
|
||
final boolean isOriginal = audioTrackDisplayName.contains(DEFAULT_AUDIO_TRACKS_IDENTIFIER); | ||
if (isOriginal) { | ||
Logger.printDebug(() -> "Using audio: " + audioTrackId); | ||
} | ||
|
||
return isOriginal; | ||
} catch (Exception ex) { | ||
Logger.printException(() -> "isDefaultAudioStream failure", ex); | ||
} | ||
|
||
return isDefault; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.