mirror of
https://github.com/inotia00/revanced-patches.git
synced 2025-04-29 22:24:31 +02:00
fix(YouTube - Settings): When a string resource is not found, the default value of some settings is not valid
This commit is contained in:
parent
b7aa8dcc44
commit
58752ec547
@ -9,6 +9,8 @@ import java.util.regex.Pattern;
|
||||
|
||||
import app.revanced.extension.shared.patches.components.Filter;
|
||||
import app.revanced.extension.shared.patches.components.StringFilterGroup;
|
||||
import app.revanced.extension.shared.settings.StringSetting;
|
||||
import app.revanced.extension.shared.utils.ResourceUtils;
|
||||
import app.revanced.extension.youtube.settings.Settings;
|
||||
import app.revanced.extension.youtube.shared.NavigationBar;
|
||||
import app.revanced.extension.youtube.shared.RootView;
|
||||
@ -70,10 +72,26 @@ public final class FeedVideoViewsFilter extends Filter {
|
||||
return false;
|
||||
}
|
||||
|
||||
private final String ARROW = " -> ";
|
||||
private final String VIEWS = "views";
|
||||
private final String[] parts = Settings.HIDE_VIDEO_VIEW_COUNTS_MULTIPLIER.get().split("\\n");
|
||||
private Pattern[] viewCountPatterns = null;
|
||||
private static final String ARROW = " -> ";
|
||||
private static final String VIEWS = "views";
|
||||
private static final StringSetting HIDE_VIDEO_VIEW_COUNTS_MULTIPLIER =
|
||||
Settings.HIDE_VIDEO_VIEW_COUNTS_MULTIPLIER;
|
||||
private static final String HIDE_VIDEO_VIEW_COUNTS_MULTIPLIER_DEFAULT_VALUE =
|
||||
"revanced_hide_video_view_counts_multiplier_default_value";
|
||||
private static String[] parts;
|
||||
private static Pattern[] viewCountPatterns = null;
|
||||
|
||||
static {
|
||||
final String multiplierString = HIDE_VIDEO_VIEW_COUNTS_MULTIPLIER.get();
|
||||
if (multiplierString.equals(HIDE_VIDEO_VIEW_COUNTS_MULTIPLIER_DEFAULT_VALUE) &&
|
||||
ResourceUtils.getContext() != null) {
|
||||
String defaultValue = ResourceUtils.getString(HIDE_VIDEO_VIEW_COUNTS_MULTIPLIER_DEFAULT_VALUE);
|
||||
if (!multiplierString.equals(defaultValue)) {
|
||||
HIDE_VIDEO_VIEW_COUNTS_MULTIPLIER.save(defaultValue);
|
||||
}
|
||||
}
|
||||
parts = HIDE_VIDEO_VIEW_COUNTS_MULTIPLIER.get().split("\\n");
|
||||
}
|
||||
|
||||
/**
|
||||
* Hide videos based on views count
|
||||
|
@ -23,6 +23,7 @@ import java.util.Objects;
|
||||
import app.revanced.extension.shared.settings.BaseSettings;
|
||||
import app.revanced.extension.shared.settings.BooleanSetting;
|
||||
import app.revanced.extension.shared.settings.IntegerSetting;
|
||||
import app.revanced.extension.shared.settings.StringSetting;
|
||||
import app.revanced.extension.shared.utils.Logger;
|
||||
import app.revanced.extension.shared.utils.ResourceUtils;
|
||||
import app.revanced.extension.shared.utils.Utils;
|
||||
@ -116,19 +117,32 @@ public class PlayerPatch {
|
||||
* view id R.id.content
|
||||
*/
|
||||
private static final int contentId = ResourceUtils.getIdIdentifier("content");
|
||||
private static final boolean expandDescriptionEnabled = Settings.EXPAND_VIDEO_DESCRIPTION.get();
|
||||
private static final String descriptionString = Settings.EXPAND_VIDEO_DESCRIPTION_STRINGS.get();
|
||||
private static final boolean EXPAND_VIDEO_DESCRIPTION = Settings.EXPAND_VIDEO_DESCRIPTION.get();
|
||||
private static final StringSetting EXPAND_VIDEO_DESCRIPTION_STRINGS = Settings.EXPAND_VIDEO_DESCRIPTION_STRINGS;
|
||||
private static final String EXPAND_VIDEO_DESCRIPTION_STRINGS_DEFAULT_VALUE = "revanced_expand_video_description_strings_default_value";
|
||||
|
||||
static {
|
||||
final String descriptionString = EXPAND_VIDEO_DESCRIPTION_STRINGS.get();
|
||||
if (descriptionString.equals(EXPAND_VIDEO_DESCRIPTION_STRINGS_DEFAULT_VALUE) &&
|
||||
Utils.getContext() != null) {
|
||||
String defaultValue = ResourceUtils.getString(EXPAND_VIDEO_DESCRIPTION_STRINGS_DEFAULT_VALUE);
|
||||
if (!descriptionString.equals(defaultValue)) {
|
||||
EXPAND_VIDEO_DESCRIPTION_STRINGS.save(defaultValue);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static boolean isDescriptionPanel = false;
|
||||
|
||||
public static void setContentDescription(String contentDescription) {
|
||||
if (!expandDescriptionEnabled) {
|
||||
if (!EXPAND_VIDEO_DESCRIPTION) {
|
||||
return;
|
||||
}
|
||||
if (contentDescription == null || contentDescription.isEmpty()) {
|
||||
isDescriptionPanel = false;
|
||||
return;
|
||||
}
|
||||
final String descriptionString = EXPAND_VIDEO_DESCRIPTION_STRINGS.get();
|
||||
if (descriptionString.isEmpty()) {
|
||||
isDescriptionPanel = false;
|
||||
return;
|
||||
@ -141,9 +155,8 @@ public class PlayerPatch {
|
||||
*/
|
||||
private static long lastTimeDescriptionViewInvoked;
|
||||
|
||||
|
||||
public static void onVideoDescriptionCreate(RecyclerView recyclerView) {
|
||||
if (!expandDescriptionEnabled)
|
||||
if (!EXPAND_VIDEO_DESCRIPTION)
|
||||
return;
|
||||
|
||||
recyclerView.getViewTreeObserver().addOnDrawListener(() -> {
|
||||
|
Loading…
x
Reference in New Issue
Block a user