forked from sakarie9/BiliRoamingM
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Revert "feat: remove trial vip quality"
This reverts commit 4eb3502.
- Loading branch information
1 parent
86e8db4
commit 84250a9
Showing
9 changed files
with
158 additions
and
1 deletion.
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
63 changes: 63 additions & 0 deletions
63
integrations/app/src/main/java/app/revanced/bilibili/patches/TrialQualityPatch.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,63 @@ | ||
package app.revanced.bilibili.patches; | ||
|
||
import android.view.View; | ||
import android.widget.TextView; | ||
|
||
import androidx.annotation.Keep; | ||
|
||
import com.bapis.bilibili.app.playerunite.v1.PlayViewUniteReply; | ||
import com.bapis.bilibili.app.playurl.v1.PlayViewReply; | ||
import com.bapis.bilibili.app.playurl.v1.Stream; | ||
|
||
import app.revanced.bilibili.account.Accounts; | ||
import app.revanced.bilibili.settings.Settings; | ||
import app.revanced.bilibili.utils.Utils; | ||
|
||
public class TrialQualityPatch { | ||
|
||
private static int dp2px(float dp) { | ||
return (int) ((dp * Utils.getContext().getResources().getDisplayMetrics().density) + 0.5f); | ||
} | ||
|
||
public static void makeVipFree(PlayViewReply playViewReply) { | ||
playViewReply.clearAb(); | ||
playViewReply.getVideoInfo().getStreamListList().stream().filter(Stream::hasDashVideo) | ||
.forEach(e -> { | ||
var streamInfo = e.getStreamInfo(); | ||
if (streamInfo.getNeedVip()) { | ||
streamInfo.setNeedVip(false); | ||
streamInfo.setVipFree(true); | ||
} | ||
}); | ||
} | ||
|
||
public static void makeVipFree(PlayViewUniteReply playViewUniteReply) { | ||
playViewUniteReply.clearQnTrialInfo(); | ||
playViewUniteReply.getVodInfo().getStreamListList().stream().filter(com.bapis.bilibili.playershared.Stream::hasDashVideo) | ||
.forEach(e -> { | ||
var streamInfo = e.getStreamInfo(); | ||
if (streamInfo.getNeedVip()) { | ||
streamInfo.setNeedVip(false); | ||
streamInfo.setVipFree(true); | ||
} | ||
}); | ||
} | ||
|
||
@Keep | ||
public static void onBindOnline(boolean selected, TextView strokeBadge, TextView solidBadge) { | ||
if (Settings.TrialVipQuality.get() && !Accounts.isEffectiveVip() | ||
&& Utils.getString("try_listening_tips") // 限免中 | ||
.equals(solidBadge.getText().toString())) { | ||
solidBadge.setVisibility(View.GONE); | ||
var strokeText = selected ? Utils.getString("player_try_watching") // 试看中 | ||
: Utils.getString("player_try_watch_enable"); // 可试看 | ||
strokeBadge.setText(strokeText); | ||
strokeBadge.setVisibility(View.VISIBLE); | ||
if (strokeText.length() > 2) { | ||
strokeBadge.setPadding(dp2px(4f), dp2px(1f), dp2px(4f), dp2px(2f)); | ||
} else { | ||
strokeBadge.setPadding(dp2px(8.5f), dp2px(1f), dp2px(8.5f), dp2px(2f)); | ||
} | ||
} | ||
} | ||
} |
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
48 changes: 48 additions & 0 deletions
48
patches/src/main/kotlin/app/revanced/patches/bilibili/misc/other/patch/TrialQualityPatch.kt
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,48 @@ | ||
package app.revanced.patches.bilibili.misc.other.patch | ||
|
||
import app.revanced.patcher.data.BytecodeContext | ||
import app.revanced.patcher.extensions.InstructionExtensions.addInstructions | ||
import app.revanced.patcher.patch.annotation.CompatiblePackage | ||
import app.revanced.patcher.patch.annotation.Patch | ||
import app.revanced.patches.bilibili.misc.other.fingerprints.QualityViewHolderFingerprint | ||
import app.revanced.patches.bilibili.patcher.patch.MultiMethodBytecodePatch | ||
import app.revanced.patches.bilibili.utils.cloneMutable | ||
import app.revanced.patches.bilibili.utils.exception | ||
|
||
@Patch( | ||
name = "Trial quality", | ||
description = "试用画质辅助补丁", | ||
compatiblePackages = [ | ||
CompatiblePackage(name = "tv.danmaku.bili"), | ||
CompatiblePackage(name = "tv.danmaku.bilibilihd"), | ||
CompatiblePackage(name = "com.bilibili.app.in") | ||
] | ||
) | ||
object TrialQualityPatch : MultiMethodBytecodePatch( | ||
multiFingerprints = setOf(QualityViewHolderFingerprint) | ||
) { | ||
override fun execute(context: BytecodeContext) { | ||
super.execute(context) | ||
val patchMethod = context.findClass("Lapp/revanced/bilibili/patches/TrialQualityPatch;")!! | ||
.mutableClass.methods.first { it.name == "onBindOnline" } | ||
QualityViewHolderFingerprint.result.associate { r -> | ||
r.mutableClass.methods to r.mutableClass.methods.first { m -> | ||
m.parameterTypes.let { it.size == 5 && it[1] == "Z" && it[3] == "Landroid/widget/TextView;" && it[4] == "Landroid/widget/TextView;" } | ||
} | ||
}.ifEmpty { | ||
throw QualityViewHolderFingerprint.exception | ||
}.forEach { (methods, method) -> | ||
val originMethod = method.cloneMutable(name = method.name + "_Origin") | ||
.also { methods.add(it) } | ||
method.also { methods.remove(it) }.cloneMutable(registerCount = 6, clearImplementation = true).apply { | ||
addInstructions( | ||
""" | ||
invoke-direct/range {p0 .. p5}, $originMethod | ||
invoke-static {p2, p4, p5}, $patchMethod | ||
return-void | ||
""".trimIndent() | ||
) | ||
}.also { methods.add(it) } | ||
} | ||
} | ||
} |
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