fix(twitch/settings): add missing classes (#226)

This commit is contained in:
Tim Schneeberger 2022-11-30 00:45:05 +01:00 committed by GitHub
parent bca96cc8b4
commit 35aa4f92c6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 72 additions and 0 deletions

View File

@ -0,0 +1,9 @@
package app.revanced.twitch.patches;
import app.revanced.twitch.settings.SettingsEnum;
public class AudioAdsPatch {
public static boolean shouldBlockAudioAds() {
return SettingsEnum.BLOCK_AUDIO_ADS.getBoolean();
}
}

View File

@ -0,0 +1,10 @@
package app.revanced.twitch.patches;
import app.revanced.twitch.settings.SettingsEnum;
public class DebugModePatch {
public static boolean isDebugModeEnabled() {
return SettingsEnum.DEBUG_MODE.getBoolean();
}
}

View File

@ -0,0 +1,44 @@
package app.revanced.twitch.patches;
import android.graphics.Color;
import android.graphics.Typeface;
import android.text.SpannableStringBuilder;
import android.text.Spanned;
import android.text.SpannedString;
import android.text.style.ForegroundColorSpan;
import android.text.style.StrikethroughSpan;
import android.text.style.StyleSpan;
import java.util.Objects;
import app.revanced.twitch.settings.SettingsEnum;
import app.revanced.twitch.utils.ReVancedUtils;
import tv.twitch.android.shared.chat.util.ClickableUsernameSpan;
public class ShowDeletedMessagesPatch {
public static boolean shouldUseSpoiler() {
return Objects.equals(SettingsEnum.SHOW_DELETED_MESSAGES.getString(), "spoiler");
}
public static boolean shouldCrossOut() {
return Objects.equals(SettingsEnum.SHOW_DELETED_MESSAGES.getString(), "cross-out");
}
public static Spanned reformatDeletedMessage(Spanned original) {
if (!shouldCrossOut())
return null;
SpannableStringBuilder ssb = new SpannableStringBuilder(original);
ssb.setSpan(new StrikethroughSpan(), 0, original.length(), 0);
ssb.append(" (").append(ReVancedUtils.getString("revanced_deleted_msg")).append(")");
ssb.setSpan(new StyleSpan(Typeface.ITALIC), original.length(), ssb.length(), 0);
// Gray-out username
ClickableUsernameSpan[] usernameSpans = original.getSpans(0, original.length(), ClickableUsernameSpan.class);
if (usernameSpans.length > 0) {
ssb.setSpan(new ForegroundColorSpan(Color.parseColor("#ADADB8")), 0, original.getSpanEnd(usernameSpans[0]), 0);
}
return new SpannedString(ssb);
}
}

View File

@ -0,0 +1,9 @@
package app.revanced.twitch.patches;
import app.revanced.twitch.settings.SettingsEnum;
public class VideoAdsPatch {
public static boolean shouldBlockVideoAds() {
return SettingsEnum.BLOCK_VIDEO_ADS.getBoolean();
}
}