mirror of
https://github.com/revanced/revanced-integrations.git
synced 2024-09-05 05:55:26 +02:00
refactor: integrations (#17)
This commit is contained in:
parent
61ed39722e
commit
d26b9339fb
@ -2,10 +2,10 @@ apply plugin: 'com.android.application'
|
|||||||
|
|
||||||
android {
|
android {
|
||||||
compileSdkVersion 32
|
compileSdkVersion 32
|
||||||
namespace 'vanced.integrations'
|
namespace 'app.revanced.integrations'
|
||||||
|
|
||||||
defaultConfig {
|
defaultConfig {
|
||||||
applicationId "revanced.integrationsapp"
|
applicationId "app.revanced.integrations"
|
||||||
minSdkVersion 23
|
minSdkVersion 23
|
||||||
targetSdkVersion 32
|
targetSdkVersion 32
|
||||||
versionCode 1
|
versionCode 1
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
<manifest xmlns:android="http://schemas.android.com/apk/res/android">
|
<manifest xmlns:android="http://schemas.android.com/apk/res/android">
|
||||||
|
|
||||||
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
|
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
|
||||||
<uses-permission android:name="android.permission.SCHEDULE_EXACT_ALARM" />
|
<uses-permission android:name="android.permission.SCHEDULE_EXACT_ALARM" />
|
||||||
</manifest>
|
</manifest>
|
@ -0,0 +1,179 @@
|
|||||||
|
package app.revanced.integrations.adremover;
|
||||||
|
|
||||||
|
|
||||||
|
import android.view.View;
|
||||||
|
import android.view.ViewGroup;
|
||||||
|
import android.widget.FrameLayout;
|
||||||
|
import android.widget.LinearLayout;
|
||||||
|
import android.widget.RelativeLayout;
|
||||||
|
import android.widget.Toolbar;
|
||||||
|
|
||||||
|
import app.revanced.integrations.patches.HideShortsButtonPatch;
|
||||||
|
import app.revanced.integrations.settings.SettingsEnum;
|
||||||
|
import app.revanced.integrations.utils.LogHelper;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* API Class that provides the logic to the Patch classes. All methods in here should be protected/private and only be accessed from a Patch class.
|
||||||
|
*/
|
||||||
|
public class AdRemoverAPI {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Removes Reels and Home ads
|
||||||
|
*
|
||||||
|
* @param view
|
||||||
|
*/
|
||||||
|
public static void HideViewWithLayout1dp(View view) {
|
||||||
|
if (view instanceof LinearLayout) {
|
||||||
|
LinearLayout.LayoutParams layoutParams = new LinearLayout.LayoutParams(1, 1);
|
||||||
|
view.setLayoutParams(layoutParams);
|
||||||
|
} else if (view instanceof FrameLayout) {
|
||||||
|
FrameLayout.LayoutParams layoutParams2 = new FrameLayout.LayoutParams(1, 1);
|
||||||
|
view.setLayoutParams(layoutParams2);
|
||||||
|
} else if (view instanceof RelativeLayout) {
|
||||||
|
RelativeLayout.LayoutParams layoutParams3 = new RelativeLayout.LayoutParams(1, 1);
|
||||||
|
view.setLayoutParams(layoutParams3);
|
||||||
|
} else if (view instanceof Toolbar) {
|
||||||
|
Toolbar.LayoutParams layoutParams4 = new Toolbar.LayoutParams(1, 1);
|
||||||
|
view.setLayoutParams(layoutParams4);
|
||||||
|
} else if (view instanceof ViewGroup) {
|
||||||
|
ViewGroup.LayoutParams layoutParams5 = new ViewGroup.LayoutParams(1, 1);
|
||||||
|
view.setLayoutParams(layoutParams5);
|
||||||
|
} else {
|
||||||
|
LogHelper.debug("XAdRemover", "HideViewWithLayout1dp - Id: " + view.getId() + " Type: " + view.getClass().getName());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Removes the Create button
|
||||||
|
*
|
||||||
|
* @param view
|
||||||
|
*/
|
||||||
|
public static void hideCreateButton(View view) {
|
||||||
|
String message = SettingsEnum.CREATE_BUTTON_SHOWN_BOOLEAN.getBoolean() ? "Create button: shown" : "Create button: hidden";
|
||||||
|
LogHelper.debug("HideCreateButton", message);
|
||||||
|
if (!SettingsEnum.CREATE_BUTTON_SHOWN_BOOLEAN.getBoolean()) {
|
||||||
|
view.setVisibility(View.GONE);
|
||||||
|
} else {
|
||||||
|
view.setVisibility(View.VISIBLE);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Removes the shorts button
|
||||||
|
*
|
||||||
|
* @param view
|
||||||
|
*/
|
||||||
|
public static void hideShortsButton(View view) {
|
||||||
|
if (HideShortsButtonPatch.lastPivotTab != null && HideShortsButtonPatch.lastPivotTab.name() == "TAB_SHORTS") {
|
||||||
|
String message = SettingsEnum.SHORTS_BUTTON_SHOWN_BOOLEAN.getBoolean() ? "Shorts button: shown" : "Shorts button: hidden";
|
||||||
|
LogHelper.debug("HideShortsButton", message);
|
||||||
|
if (!SettingsEnum.SHORTS_BUTTON_SHOWN_BOOLEAN.getBoolean()) {
|
||||||
|
view.setVisibility(View.GONE);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Removes the InfoCardSuggestions
|
||||||
|
*
|
||||||
|
* @param InfoCardOverlayPresenter
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public static Object removeInfoCardSuggestions(Object InfoCardOverlayPresenter) {
|
||||||
|
if (!SettingsEnum.INFO_CARDS_SHOWN_BOOLEAN.getBoolean()) InfoCardOverlayPresenter = null;
|
||||||
|
String message = InfoCardOverlayPresenter == null ? "RemoveInfoCardSuggestions: true" : "RemoveInfoCardSuggestions: false";
|
||||||
|
LogHelper.debug("AdRemoverAPI", message);
|
||||||
|
return InfoCardOverlayPresenter;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Removes the Suggestions
|
||||||
|
*
|
||||||
|
* @param showSuggestions
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public static Boolean removeSuggestions(Boolean showSuggestions) {
|
||||||
|
if (!SettingsEnum.SUGGESTIONS_SHOWN_BOOLEAN.getBoolean()) showSuggestions = false;
|
||||||
|
String message = showSuggestions ? "RemoveSuggestions: true" : "RemoveSuggestions: false";
|
||||||
|
LogHelper.debug("AdRemoverAPI", message);
|
||||||
|
return showSuggestions;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public static int BrandingWatermark(int defaultValue) {
|
||||||
|
if (defaultValue == 0 && !SettingsEnum.BRANDING_SHOWN_BOOLEAN.getBoolean()) {
|
||||||
|
defaultValue = 8;
|
||||||
|
}
|
||||||
|
String message = defaultValue == 8 ? "BrandingWatermark: Removed" : "BrandingWatermark: Shown";
|
||||||
|
LogHelper.debug("AdRemoverAPI", message);
|
||||||
|
return defaultValue;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
private static void inspectComponentHost(Object item) {
|
||||||
|
StackTraceElement[] stackTraceElements = Thread.currentThread().getStackTrace();
|
||||||
|
if (stackTraceElements.length <= 3) {
|
||||||
|
LogHelper.debug("Litho", "Couldn't locate the method called from.");
|
||||||
|
} else {
|
||||||
|
String sb = "Called from method: " +
|
||||||
|
stackTraceElements[3].toString() + "\n";
|
||||||
|
LogHelper.debug("Litho", sb);
|
||||||
|
}
|
||||||
|
if (item == null) {
|
||||||
|
LogHelper.debug("Litho", "Item is null.");
|
||||||
|
} else if (item.getClass().getSimpleName().contains("cwl")) {
|
||||||
|
LogHelper.debug("Litho", "Item is a cwl item.");
|
||||||
|
LogHelper.debug("Litho", getViewHierarchy((ViewGroup) item));
|
||||||
|
} else {
|
||||||
|
LogHelper.debug("Litho", "Item is not a cwl item.");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private static String getViewHierarchy(ViewGroup v) {
|
||||||
|
StringBuffer buf = new StringBuffer();
|
||||||
|
printViews(v, buf, 0);
|
||||||
|
return buf.toString();
|
||||||
|
}
|
||||||
|
|
||||||
|
private static String printViews(ViewGroup v, StringBuffer buf, int level) {
|
||||||
|
int childCount = v.getChildCount();
|
||||||
|
v.getId();
|
||||||
|
indent(buf, level);
|
||||||
|
buf.append(v.getClass().getName());
|
||||||
|
buf.append(" children:");
|
||||||
|
buf.append(childCount);
|
||||||
|
buf.append(" id:").append(v.getId());
|
||||||
|
buf.append("\n");
|
||||||
|
for (int i = 0; i < childCount; i++) {
|
||||||
|
View child = v.getChildAt(i);
|
||||||
|
if (child instanceof ViewGroup) {
|
||||||
|
printViews((ViewGroup) child, buf, level + 1);
|
||||||
|
} else {
|
||||||
|
indent(buf, level + 1);
|
||||||
|
buf.append(child.getClass().getName());
|
||||||
|
buf.append(" id:").append(child.getId());
|
||||||
|
buf.append("\n");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return buf.toString();
|
||||||
|
}
|
||||||
|
|
||||||
|
private static void indent(StringBuffer buf, int level) {
|
||||||
|
for (int i = 0; i < level; i++) {
|
||||||
|
buf.append(" ");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private static void recursiveLoopChildren(ViewGroup parent) {
|
||||||
|
for (int i = 0; i < parent.getChildCount(); i++) {
|
||||||
|
View child = parent.getChildAt(i);
|
||||||
|
if (child instanceof ViewGroup) {
|
||||||
|
recursiveLoopChildren((ViewGroup) child);
|
||||||
|
child.setVisibility(View.GONE);
|
||||||
|
} else if (child != null) {
|
||||||
|
child.setVisibility(View.GONE);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}*/
|
||||||
|
|
||||||
|
}
|
@ -1,7 +1,7 @@
|
|||||||
package fi.razerman.youtube.litho;
|
package app.revanced.integrations.adremover;
|
||||||
|
|
||||||
import android.os.Build;
|
import android.os.Build;
|
||||||
import android.util.Log;
|
|
||||||
|
|
||||||
import androidx.annotation.RequiresApi;
|
import androidx.annotation.RequiresApi;
|
||||||
|
|
||||||
@ -13,12 +13,14 @@ import java.util.ArrayList;
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
|
|
||||||
import fi.razerman.youtube.Helpers.SharedPrefs;
|
import app.revanced.integrations.settings.SettingsEnum;
|
||||||
import fi.razerman.youtube.XGlobals;
|
import app.revanced.integrations.utils.LogHelper;
|
||||||
|
import app.revanced.integrations.utils.SharedPrefHelper;
|
||||||
|
import app.revanced.integrations.settings.Settings;
|
||||||
|
|
||||||
public class LithoAdRemoval {
|
public class LithoAdRemoval {
|
||||||
private static boolean getBoolean(String key, boolean _default) {
|
private static boolean getBoolean(String key, boolean _default) {
|
||||||
return SharedPrefs.getBoolean(Objects.requireNonNull(YouTubeTikTokRoot_Application.getAppContext()), key, _default);
|
return SharedPrefHelper.getBoolean(Objects.requireNonNull(YouTubeTikTokRoot_Application.getAppContext()), SharedPrefHelper.SharedPrefNames.YOUTUBE, key, _default);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static boolean isExperimentalInfoPanelRemoval() {
|
private static boolean isExperimentalInfoPanelRemoval() {
|
||||||
@ -33,43 +35,43 @@ public class LithoAdRemoval {
|
|||||||
return getBoolean("experimental_emergency_box", true);
|
return getBoolean("experimental_emergency_box", true);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static boolean isExperimentalAdRemoval() {
|
private static boolean isExperimentalAdRemoval() {
|
||||||
return getBoolean("experimental_ad_removal", true);
|
return getBoolean("experimental_ad_removal", true);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static boolean isExperimentalMerchandiseRemoval() {
|
private static boolean isExperimentalMerchandiseRemoval() {
|
||||||
return getBoolean("experimental_merchandise", true);
|
return getBoolean("experimental_merchandise", true);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static boolean isExperimentalCommunityPostRemoval() {
|
private static boolean isExperimentalCommunityPostRemoval() {
|
||||||
return getBoolean("experimental_community_posts", false);
|
return getBoolean("experimental_community_posts", false);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static boolean isExperimentalMovieRemoval() {
|
private static boolean isExperimentalMovieRemoval() {
|
||||||
return getBoolean("experimental_movie", true);
|
return getBoolean("experimental_movie", true);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static boolean isExperimentalCompactBannerRemoval() {
|
private static boolean isExperimentalCompactBannerRemoval() {
|
||||||
return getBoolean("experimental_compact_banner", false);
|
return getBoolean("experimental_compact_banner", false);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static boolean isExperimentalPaidContentRemoval() {
|
private static boolean isExperimentalPaidContentRemoval() {
|
||||||
return getBoolean("experimental_paid_content", true);
|
return getBoolean("experimental_paid_content", true);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static boolean isExperimentalCommentsRemoval() {
|
private static boolean isExperimentalCommentsRemoval() {
|
||||||
return getBoolean("experimental_comments", false);
|
return getBoolean("experimental_comments", false);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static boolean isInFeedSurvey() {
|
private static boolean isInFeedSurvey() {
|
||||||
return getBoolean("experimental_in_feed_survey", false);
|
return getBoolean("experimental_in_feed_survey", false);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static boolean isShortsShelf() {
|
private static boolean isShortsShelf() {
|
||||||
return getBoolean("experimental_shorts_shelf", true);
|
return getBoolean("experimental_shorts_shelf", true);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static boolean isCommunityGuidelines() {
|
private static boolean isCommunityGuidelines() {
|
||||||
return getBoolean("experimental_community_guidelines", true);
|
return getBoolean("experimental_community_guidelines", true);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -168,20 +170,20 @@ public class LithoAdRemoval {
|
|||||||
)) return false;
|
)) return false;
|
||||||
|
|
||||||
if (blockList.stream().anyMatch(value::contains)) {
|
if (blockList.stream().anyMatch(value::contains)) {
|
||||||
if (XGlobals.debug) Log.d("TemplateBlocked", value);
|
LogHelper.debug("TemplateBlocked", value);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!XGlobals.debug) return false;
|
if (!SettingsEnum.DEBUG_BOOLEAN.getBoolean()) return false;
|
||||||
if (value.contains("related_video_with_context")) {
|
if (value.contains("related_video_with_context")) {
|
||||||
Log.d("Template", value + " | " + bytesToHex(buffer.array()));
|
LogHelper.debug("Template", value + " | " + bytesToHex(buffer.array()));
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
Log.d("Template", value);
|
LogHelper.debug("Template", value);
|
||||||
return false;
|
return false;
|
||||||
} catch (
|
} catch (
|
||||||
Exception ex) {
|
Exception ex) {
|
||||||
Log.e("Template", ex.getMessage(), ex);
|
LogHelper.printException("Template", ex.getMessage(), ex);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
@ -1,15 +1,13 @@
|
|||||||
package fi.vanced.libraries.youtube.whitelisting;
|
package app.revanced.integrations.adremover.whitelist;
|
||||||
|
|
||||||
import static fi.razerman.youtube.XGlobals.debug;
|
import static app.revanced.integrations.sponsorblock.player.VideoInformation.channelName;
|
||||||
import static fi.vanced.libraries.youtube.player.VideoInformation.channelName;
|
import static app.revanced.integrations.sponsorblock.player.ui.SlimButtonContainer.adBlockButton;
|
||||||
import static fi.vanced.libraries.youtube.ui.SlimButtonContainer.adBlockButton;
|
import static app.revanced.integrations.sponsorblock.player.ui.SlimButtonContainer.sbWhitelistButton;
|
||||||
import static fi.vanced.libraries.youtube.ui.SlimButtonContainer.sbWhitelistButton;
|
import static app.revanced.integrations.sponsorblock.StringRef.str;
|
||||||
import static fi.vanced.utils.VancedUtils.getPreferences;
|
|
||||||
import static pl.jakubweg.StringRef.str;
|
|
||||||
|
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.content.SharedPreferences;
|
import android.content.SharedPreferences;
|
||||||
import android.util.Log;
|
|
||||||
import android.widget.Toast;
|
import android.widget.Toast;
|
||||||
|
|
||||||
import com.google.android.apps.youtube.app.YouTubeTikTokRoot_Application;
|
import com.google.android.apps.youtube.app.YouTubeTikTokRoot_Application;
|
||||||
@ -22,18 +20,21 @@ import java.util.Iterator;
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
import fi.vanced.libraries.youtube.player.ChannelModel;
|
import app.revanced.integrations.settings.SettingsEnum;
|
||||||
import fi.vanced.libraries.youtube.player.VideoInformation;
|
import app.revanced.integrations.utils.LogHelper;
|
||||||
import fi.vanced.utils.ObjectSerializer;
|
import app.revanced.integrations.settings.Settings;
|
||||||
import fi.vanced.utils.SharedPrefUtils;
|
import app.revanced.integrations.sponsorblock.player.ChannelModel;
|
||||||
import fi.vanced.utils.VancedUtils;
|
import app.revanced.integrations.sponsorblock.player.VideoInformation;
|
||||||
|
import app.revanced.integrations.utils.ObjectSerializer;
|
||||||
|
import app.revanced.integrations.utils.SharedPrefHelper;
|
||||||
|
|
||||||
public class Whitelist {
|
public class Whitelist {
|
||||||
private static final String TAG = "VI - Whitelisting";
|
private static final String TAG = "VI - Whitelisting";
|
||||||
private static final Map<WhitelistType, ArrayList<ChannelModel>> whitelistMap = parseWhitelist(YouTubeTikTokRoot_Application.getAppContext());
|
private static final Map<WhitelistType, ArrayList<ChannelModel>> whitelistMap = parseWhitelist(YouTubeTikTokRoot_Application.getAppContext());
|
||||||
private static final Map<WhitelistType, Boolean> enabledMap = parseEnabledMap(YouTubeTikTokRoot_Application.getAppContext());
|
private static final Map<WhitelistType, Boolean> enabledMap = parseEnabledMap(YouTubeTikTokRoot_Application.getAppContext());
|
||||||
|
|
||||||
private Whitelist() {}
|
private Whitelist() {
|
||||||
|
}
|
||||||
|
|
||||||
// injected calls
|
// injected calls
|
||||||
|
|
||||||
@ -42,9 +43,7 @@ public class Whitelist {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static void setChannelName(String channelName) {
|
public static void setChannelName(String channelName) {
|
||||||
if (debug) {
|
LogHelper.debug(TAG, "channel name set to " + channelName);
|
||||||
Log.d(TAG, "channel name set to " + channelName);
|
|
||||||
}
|
|
||||||
VideoInformation.channelName = channelName;
|
VideoInformation.channelName = channelName;
|
||||||
|
|
||||||
if (enabledMap.get(WhitelistType.ADS) && adBlockButton != null) {
|
if (enabledMap.get(WhitelistType.ADS) && adBlockButton != null) {
|
||||||
@ -69,26 +68,23 @@ public class Whitelist {
|
|||||||
Map<WhitelistType, ArrayList<ChannelModel>> whitelistMap = new EnumMap<>(WhitelistType.class);
|
Map<WhitelistType, ArrayList<ChannelModel>> whitelistMap = new EnumMap<>(WhitelistType.class);
|
||||||
|
|
||||||
for (WhitelistType whitelistType : whitelistTypes) {
|
for (WhitelistType whitelistType : whitelistTypes) {
|
||||||
SharedPreferences preferences = VancedUtils.getPreferences(context, whitelistType.getPreferencesName());
|
SharedPreferences preferences = SharedPrefHelper.getPreferences(context, whitelistType.getPreferencesName());
|
||||||
String serializedChannels = preferences.getString("channels", null);
|
String serializedChannels = preferences.getString("channels", null);
|
||||||
if (serializedChannels == null) {
|
if (serializedChannels == null) {
|
||||||
if (debug) {
|
LogHelper.debug(TAG, String.format("channels string was null for %s whitelisting", whitelistType));
|
||||||
Log.d(TAG, String.format("channels string was null for %s whitelisting", whitelistType));
|
|
||||||
}
|
|
||||||
whitelistMap.put(whitelistType, new ArrayList<>());
|
whitelistMap.put(whitelistType, new ArrayList<>());
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
ArrayList<ChannelModel> deserializedChannels = (ArrayList<ChannelModel>) ObjectSerializer.deserialize(serializedChannels);
|
ArrayList<ChannelModel> deserializedChannels = (ArrayList<ChannelModel>) ObjectSerializer.deserialize(serializedChannels);
|
||||||
if (debug) {
|
if (SettingsEnum.DEBUG_BOOLEAN.getBoolean()) {
|
||||||
Log.d(TAG, serializedChannels);
|
LogHelper.debug(TAG, serializedChannels);
|
||||||
for (ChannelModel channel : deserializedChannels) {
|
for (ChannelModel channel : deserializedChannels) {
|
||||||
Log.d(TAG, String.format("Whitelisted channel %s (%s) for type %s", channel.getAuthor(), channel.getChannelId(), whitelistType));
|
LogHelper.debug(TAG, String.format("Whitelisted channel %s (%s) for type %s", channel.getAuthor(), channel.getChannelId(), whitelistType));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
whitelistMap.put(whitelistType, deserializedChannels);
|
whitelistMap.put(whitelistType, deserializedChannels);
|
||||||
}
|
} catch (Exception ex) {
|
||||||
catch (Exception ex) {
|
|
||||||
ex.printStackTrace();
|
ex.printStackTrace();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -101,7 +97,7 @@ public class Whitelist {
|
|||||||
}
|
}
|
||||||
Map<WhitelistType, Boolean> enabledMap = new EnumMap<>(WhitelistType.class);
|
Map<WhitelistType, Boolean> enabledMap = new EnumMap<>(WhitelistType.class);
|
||||||
for (WhitelistType whitelistType : WhitelistType.values()) {
|
for (WhitelistType whitelistType : WhitelistType.values()) {
|
||||||
enabledMap.put(whitelistType, SharedPrefUtils.getBoolean(context, whitelistType.getSharedPreferencesName(), whitelistType.getPreferenceEnabledName()));
|
enabledMap.put(whitelistType, SharedPrefHelper.getBoolean(context, whitelistType.getSharedPreferencesName(), whitelistType.getPreferenceEnabledName()));
|
||||||
}
|
}
|
||||||
return enabledMap;
|
return enabledMap;
|
||||||
}
|
}
|
||||||
@ -112,17 +108,14 @@ public class Whitelist {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if (channelName == null || channelName.trim().isEmpty()) {
|
if (channelName == null || channelName.trim().isEmpty()) {
|
||||||
if (debug) {
|
LogHelper.debug(TAG, String.format("Can't check whitelist status for %s because channel name was missing", whitelistType));
|
||||||
Log.d(TAG, String.format("Can't check whitelist status for %s because channel name was missing", whitelistType));
|
|
||||||
}
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
List<ChannelModel> whitelistedChannels = whitelistMap.get(whitelistType);
|
List<ChannelModel> whitelistedChannels = whitelistMap.get(whitelistType);
|
||||||
for (ChannelModel channel : whitelistedChannels) {
|
for (ChannelModel channel : whitelistedChannels) {
|
||||||
if (channel.getAuthor().equals(channelName)) {
|
if (channel.getAuthor().equals(channelName)) {
|
||||||
if (debug) {
|
LogHelper.debug(TAG, String.format("Whitelist for channel %s for type %s", channelName, whitelistType));
|
||||||
Log.d(TAG, String.format("Whitelist for channel %s for type %s", channelName, whitelistType));
|
|
||||||
}
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -134,10 +127,8 @@ public class Whitelist {
|
|||||||
for (ChannelModel whitelistedChannel : whitelisted) {
|
for (ChannelModel whitelistedChannel : whitelisted) {
|
||||||
String channelId = channel.getChannelId();
|
String channelId = channel.getChannelId();
|
||||||
if (whitelistedChannel.getChannelId().equals(channelId)) {
|
if (whitelistedChannel.getChannelId().equals(channelId)) {
|
||||||
if (debug) {
|
LogHelper.debug(TAG, String.format("Tried whitelisting an existing channel again. Old info (%1$s | %2$s) - New info (%3$s | %4$s)",
|
||||||
Log.d(TAG, String.format("Tried whitelisting an existing channel again. Old info (%1$s | %2$s) - New info (%3$s | %4$s)",
|
|
||||||
whitelistedChannel.getAuthor(), channelId, channelName, channelId));
|
whitelistedChannel.getAuthor(), channelId, channelName, channelId));
|
||||||
}
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -159,8 +150,7 @@ public class Whitelist {
|
|||||||
String friendlyName = whitelistType.getFriendlyName();
|
String friendlyName = whitelistType.getFriendlyName();
|
||||||
if (success) {
|
if (success) {
|
||||||
Toast.makeText(context, str("vanced_whitelisting_removed", channelName, friendlyName), Toast.LENGTH_SHORT).show();
|
Toast.makeText(context, str("vanced_whitelisting_removed", channelName, friendlyName), Toast.LENGTH_SHORT).show();
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
Toast.makeText(context, str("vanced_whitelisting_remove_failed", channelName, friendlyName), Toast.LENGTH_SHORT).show();
|
Toast.makeText(context, str("vanced_whitelisting_remove_failed", channelName, friendlyName), Toast.LENGTH_SHORT).show();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -169,7 +159,7 @@ public class Whitelist {
|
|||||||
if (context == null) {
|
if (context == null) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
SharedPreferences preferences = getPreferences(context, whitelistType.getPreferencesName());
|
SharedPreferences preferences = SharedPrefHelper.getPreferences(context, whitelistType.getPreferencesName());
|
||||||
SharedPreferences.Editor editor = preferences.edit();
|
SharedPreferences.Editor editor = preferences.edit();
|
||||||
|
|
||||||
try {
|
try {
|
@ -0,0 +1,38 @@
|
|||||||
|
package app.revanced.integrations.adremover.whitelist;
|
||||||
|
|
||||||
|
import static app.revanced.integrations.sponsorblock.StringRef.str;
|
||||||
|
|
||||||
|
import app.revanced.integrations.utils.SharedPrefHelper;
|
||||||
|
|
||||||
|
public enum WhitelistType {
|
||||||
|
ADS(SharedPrefHelper.SharedPrefNames.YOUTUBE, "vanced_whitelist_ads_enabled"),
|
||||||
|
SPONSORBLOCK(SharedPrefHelper.SharedPrefNames.SPONSOR_BLOCK, "vanced_whitelist_sb_enabled");
|
||||||
|
|
||||||
|
private final String friendlyName;
|
||||||
|
private final String preferencesName;
|
||||||
|
private final String preferenceEnabledName;
|
||||||
|
private final SharedPrefHelper.SharedPrefNames name;
|
||||||
|
|
||||||
|
WhitelistType(SharedPrefHelper.SharedPrefNames name, String preferenceEnabledName) {
|
||||||
|
this.friendlyName = str("vanced_whitelisting_" + name().toLowerCase());
|
||||||
|
this.name = name;
|
||||||
|
this.preferencesName = "whitelist_" + name();
|
||||||
|
this.preferenceEnabledName = preferenceEnabledName;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getFriendlyName() {
|
||||||
|
return friendlyName;
|
||||||
|
}
|
||||||
|
|
||||||
|
public SharedPrefHelper.SharedPrefNames getSharedPreferencesName() {
|
||||||
|
return name;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getPreferencesName() {
|
||||||
|
return preferencesName;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getPreferenceEnabledName() {
|
||||||
|
return preferenceEnabledName;
|
||||||
|
}
|
||||||
|
}
|
@ -1,4 +1,4 @@
|
|||||||
package fi.vanced.utils.requests;
|
package app.revanced.integrations.adremover.whitelist.requests;
|
||||||
|
|
||||||
import org.json.JSONArray;
|
import org.json.JSONArray;
|
||||||
import org.json.JSONObject;
|
import org.json.JSONObject;
|
||||||
@ -10,10 +10,9 @@ import java.io.InputStreamReader;
|
|||||||
import java.net.HttpURLConnection;
|
import java.net.HttpURLConnection;
|
||||||
import java.net.URL;
|
import java.net.URL;
|
||||||
|
|
||||||
import fi.vanced.libraries.youtube.whitelisting.requests.WhitelistRoutes;
|
|
||||||
|
|
||||||
public class Requester {
|
public class Requester {
|
||||||
private Requester() {}
|
private Requester() {
|
||||||
|
}
|
||||||
|
|
||||||
public static HttpURLConnection getConnectionFromRoute(String apiUrl, Route route, String... params) throws IOException {
|
public static HttpURLConnection getConnectionFromRoute(String apiUrl, Route route, String... params) throws IOException {
|
||||||
String url = apiUrl + route.compile(params).getCompiledRoute();
|
String url = apiUrl + route.compile(params).getCompiledRoute();
|
@ -1,6 +1,4 @@
|
|||||||
package fi.vanced.utils.requests;
|
package app.revanced.integrations.adremover.whitelist.requests;
|
||||||
|
|
||||||
import fi.vanced.utils.VancedUtils;
|
|
||||||
|
|
||||||
public class Route {
|
public class Route {
|
||||||
private final String route;
|
private final String route;
|
||||||
@ -10,9 +8,9 @@ public class Route {
|
|||||||
public Route(Route.Method method, String route) {
|
public Route(Route.Method method, String route) {
|
||||||
this.method = method;
|
this.method = method;
|
||||||
this.route = route;
|
this.route = route;
|
||||||
this.paramCount = VancedUtils.countMatches(route, '{');
|
this.paramCount = countMatches(route, '{');
|
||||||
|
|
||||||
if (paramCount != VancedUtils.countMatches(route, '}'))
|
if (paramCount != countMatches(route, '}'))
|
||||||
throw new IllegalArgumentException("Not enough parameters");
|
throw new IllegalArgumentException("Not enough parameters");
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -52,6 +50,15 @@ public class Route {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private int countMatches(CharSequence seq, char c) {
|
||||||
|
int count = 0;
|
||||||
|
for (int i = 0; i < seq.length(); i++) {
|
||||||
|
if (seq.charAt(i) == c)
|
||||||
|
count++;
|
||||||
|
}
|
||||||
|
return count;
|
||||||
|
}
|
||||||
|
|
||||||
public enum Method {
|
public enum Method {
|
||||||
GET,
|
GET,
|
||||||
POST
|
POST
|
@ -1,13 +1,11 @@
|
|||||||
package fi.vanced.libraries.youtube.whitelisting.requests;
|
package app.revanced.integrations.adremover.whitelist.requests;
|
||||||
|
|
||||||
import static fi.razerman.youtube.XGlobals.debug;
|
import static app.revanced.integrations.sponsorblock.player.VideoInformation.currentVideoId;
|
||||||
import static fi.vanced.libraries.youtube.player.VideoInformation.currentVideoId;
|
import static app.revanced.integrations.utils.ReVancedUtils.runOnMainThread;
|
||||||
import static fi.vanced.libraries.youtube.ui.AdButton.TAG;
|
import static app.revanced.integrations.sponsorblock.StringRef.str;
|
||||||
import static fi.vanced.utils.VancedUtils.runOnMainThread;
|
|
||||||
import static pl.jakubweg.StringRef.str;
|
|
||||||
|
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.util.Log;
|
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.widget.ImageView;
|
import android.widget.ImageView;
|
||||||
import android.widget.Toast;
|
import android.widget.Toast;
|
||||||
@ -19,18 +17,18 @@ import java.io.OutputStream;
|
|||||||
import java.net.HttpURLConnection;
|
import java.net.HttpURLConnection;
|
||||||
import java.nio.charset.StandardCharsets;
|
import java.nio.charset.StandardCharsets;
|
||||||
|
|
||||||
import fi.vanced.libraries.youtube.player.ChannelModel;
|
import app.revanced.integrations.settings.Settings;
|
||||||
import fi.vanced.libraries.youtube.whitelisting.Whitelist;
|
import app.revanced.integrations.utils.LogHelper;
|
||||||
import fi.vanced.libraries.youtube.whitelisting.WhitelistType;
|
import app.revanced.integrations.sponsorblock.player.ChannelModel;
|
||||||
import fi.vanced.utils.VancedUtils;
|
import app.revanced.integrations.adremover.whitelist.Whitelist;
|
||||||
import fi.vanced.utils.requests.Requester;
|
import app.revanced.integrations.adremover.whitelist.WhitelistType;
|
||||||
import fi.vanced.utils.requests.Route;
|
import app.revanced.integrations.BuildConfig;
|
||||||
import vanced.integrations.BuildConfig;
|
|
||||||
|
|
||||||
public class WhitelistRequester {
|
public class WhitelistRequester {
|
||||||
private static final String YT_API_URL = "https://www.youtube.com/youtubei/v1/";
|
private static final String YT_API_URL = "https://www.youtube.com/youtubei/v1/";
|
||||||
|
|
||||||
private WhitelistRequester() {}
|
private WhitelistRequester() {
|
||||||
|
}
|
||||||
|
|
||||||
public static void addChannelToWhitelist(WhitelistType whitelistType, View view, ImageView buttonIcon, Context context) {
|
public static void addChannelToWhitelist(WhitelistType whitelistType, View view, ImageView buttonIcon, Context context) {
|
||||||
try {
|
try {
|
||||||
@ -40,9 +38,9 @@ public class WhitelistRequester {
|
|||||||
connection.setDoOutput(true);
|
connection.setDoOutput(true);
|
||||||
connection.setConnectTimeout(2 * 1000);
|
connection.setConnectTimeout(2 * 1000);
|
||||||
|
|
||||||
String versionName = VancedUtils.getVersionName(context);
|
String versionName = Settings.getVersionName(context);
|
||||||
String jsonInputString = "{\"context\": {\"client\": { \"clientName\": \"Android\", \"clientVersion\": \"" + versionName + "\" } }, \"videoId\": \"" + currentVideoId + "\"}";
|
String jsonInputString = "{\"context\": {\"client\": { \"clientName\": \"Android\", \"clientVersion\": \"" + versionName + "\" } }, \"videoId\": \"" + currentVideoId + "\"}";
|
||||||
try(OutputStream os = connection.getOutputStream()) {
|
try (OutputStream os = connection.getOutputStream()) {
|
||||||
byte[] input = jsonInputString.getBytes(StandardCharsets.UTF_8);
|
byte[] input = jsonInputString.getBytes(StandardCharsets.UTF_8);
|
||||||
os.write(input, 0, input.length);
|
os.write(input, 0, input.length);
|
||||||
}
|
}
|
||||||
@ -52,9 +50,7 @@ public class WhitelistRequester {
|
|||||||
JSONObject videoInfo = json.getJSONObject("videoDetails");
|
JSONObject videoInfo = json.getJSONObject("videoDetails");
|
||||||
ChannelModel channelModel = new ChannelModel(videoInfo.getString("author"), videoInfo.getString("channelId"));
|
ChannelModel channelModel = new ChannelModel(videoInfo.getString("author"), videoInfo.getString("channelId"));
|
||||||
String author = channelModel.getAuthor();
|
String author = channelModel.getAuthor();
|
||||||
if (debug) {
|
LogHelper.debug("WhitelistRequester", "channelId " + channelModel.getChannelId() + " fetched for author " + author);
|
||||||
Log.d(TAG, "channelId " + channelModel.getChannelId() + " fetched for author " + author);
|
|
||||||
}
|
|
||||||
|
|
||||||
boolean success = Whitelist.addToWhitelist(whitelistType, context, channelModel);
|
boolean success = Whitelist.addToWhitelist(whitelistType, context, channelModel);
|
||||||
String whitelistTypeName = whitelistType.getFriendlyName();
|
String whitelistTypeName = whitelistType.getFriendlyName();
|
||||||
@ -62,18 +58,14 @@ public class WhitelistRequester {
|
|||||||
if (success) {
|
if (success) {
|
||||||
buttonIcon.setEnabled(whitelistType != WhitelistType.SPONSORBLOCK);
|
buttonIcon.setEnabled(whitelistType != WhitelistType.SPONSORBLOCK);
|
||||||
Toast.makeText(context, str("vanced_whitelisting_added", author, whitelistTypeName), Toast.LENGTH_SHORT).show();
|
Toast.makeText(context, str("vanced_whitelisting_added", author, whitelistTypeName), Toast.LENGTH_SHORT).show();
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
buttonIcon.setEnabled(whitelistType == WhitelistType.SPONSORBLOCK);
|
buttonIcon.setEnabled(whitelistType == WhitelistType.SPONSORBLOCK);
|
||||||
Toast.makeText(context, str("vanced_whitelisting_add_failed", author, whitelistTypeName), Toast.LENGTH_SHORT).show();
|
Toast.makeText(context, str("vanced_whitelisting_add_failed", author, whitelistTypeName), Toast.LENGTH_SHORT).show();
|
||||||
}
|
}
|
||||||
view.setEnabled(true);
|
view.setEnabled(true);
|
||||||
});
|
});
|
||||||
}
|
} else {
|
||||||
else {
|
LogHelper.debug("WhitelistRequester", "player fetch response was " + responseCode);
|
||||||
if (debug) {
|
|
||||||
Log.d(TAG, "player fetch response was " + responseCode);
|
|
||||||
}
|
|
||||||
runOnMainThread(() -> {
|
runOnMainThread(() -> {
|
||||||
Toast.makeText(context, str("vanced_whitelisting_fetch_failed", responseCode), Toast.LENGTH_SHORT).show();
|
Toast.makeText(context, str("vanced_whitelisting_fetch_failed", responseCode), Toast.LENGTH_SHORT).show();
|
||||||
buttonIcon.setEnabled(true);
|
buttonIcon.setEnabled(true);
|
||||||
@ -81,9 +73,8 @@ public class WhitelistRequester {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
connection.disconnect();
|
connection.disconnect();
|
||||||
}
|
} catch (Exception ex) {
|
||||||
catch (Exception ex) {
|
LogHelper.printException("WhitelistRequester", "Failed to fetch channelId", ex);
|
||||||
Log.e(TAG, "Failed to fetch channelId", ex);
|
|
||||||
runOnMainThread(() -> view.setEnabled(true));
|
runOnMainThread(() -> view.setEnabled(true));
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -0,0 +1,10 @@
|
|||||||
|
package app.revanced.integrations.adremover.whitelist.requests;
|
||||||
|
|
||||||
|
import static app.revanced.integrations.adremover.whitelist.requests.Route.Method.POST;
|
||||||
|
|
||||||
|
public class WhitelistRoutes {
|
||||||
|
public static final Route GET_CHANNEL_DETAILS = new Route(POST, "player?key={api_key}");
|
||||||
|
|
||||||
|
private WhitelistRoutes() {
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,19 @@
|
|||||||
|
package app.revanced.integrations.patches;
|
||||||
|
|
||||||
|
import android.os.Build;
|
||||||
|
|
||||||
|
import androidx.annotation.RequiresApi;
|
||||||
|
|
||||||
|
import java.nio.ByteBuffer;
|
||||||
|
|
||||||
|
import app.revanced.integrations.adremover.LithoAdRemoval;
|
||||||
|
|
||||||
|
public class GeneralBytecodeAdsPatch {
|
||||||
|
|
||||||
|
//Used by app.revanced.patches.youtube.ad.general.bytecode.patch.GeneralBytecodeAdsPatch
|
||||||
|
@RequiresApi(api = Build.VERSION_CODES.N)
|
||||||
|
public static boolean containsAd(String value, ByteBuffer buffer) {
|
||||||
|
return LithoAdRemoval.containsAd(value, buffer);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,11 @@
|
|||||||
|
package app.revanced.integrations.patches;
|
||||||
|
|
||||||
|
import app.revanced.integrations.settings.SettingsEnum;
|
||||||
|
|
||||||
|
public class HideCastButtonPatch {
|
||||||
|
|
||||||
|
//Used by app.revanced.patches.youtube.layout.castbutton.patch.HideCastButonPatch
|
||||||
|
public static int getCastButtonOverrideV2(int original) {
|
||||||
|
return SettingsEnum.CAST_BUTTON_SHOWN_BOOLEAN.getBoolean() ? original : 8;
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,14 @@
|
|||||||
|
package app.revanced.integrations.patches;
|
||||||
|
|
||||||
|
import android.view.View;
|
||||||
|
|
||||||
|
import app.revanced.integrations.adremover.AdRemoverAPI;
|
||||||
|
|
||||||
|
public class HideCreateButtonPatch {
|
||||||
|
|
||||||
|
//Todo: Switch BooleanPreferences to Settings class
|
||||||
|
//Used by app.revanced.patches.youtube.layout.createbutton.patch.CreateButtonRemoverPatch
|
||||||
|
public static void hideCreateButton(View view) {
|
||||||
|
AdRemoverAPI.hideCreateButton(view);
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,21 @@
|
|||||||
|
package app.revanced.integrations.patches;
|
||||||
|
|
||||||
|
import android.view.View;
|
||||||
|
|
||||||
|
import app.revanced.integrations.adremover.AdRemoverAPI;
|
||||||
|
import app.revanced.integrations.settings.Settings;
|
||||||
|
import app.revanced.integrations.settings.SettingsEnum;
|
||||||
|
|
||||||
|
public class HideHomeAdsPatch {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Used by package app.revanced.extensions.Extensions
|
||||||
|
* @param view
|
||||||
|
*/
|
||||||
|
public static void HideHomeAds(View view) {
|
||||||
|
if (!SettingsEnum.HOME_ADS_SHOWN_BOOLEAN.getBoolean()) {
|
||||||
|
AdRemoverAPI.HideViewWithLayout1dp(view);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,12 @@
|
|||||||
|
package app.revanced.integrations.patches;
|
||||||
|
|
||||||
|
import app.revanced.integrations.adremover.AdRemoverAPI;
|
||||||
|
|
||||||
|
public class HideInfoCardSuggestionsPatch {
|
||||||
|
|
||||||
|
//TODO: Create Patch
|
||||||
|
//Not used yet
|
||||||
|
public static void HideInfoCardSuggestions(Object InfoCardOverlayPresenter) {
|
||||||
|
AdRemoverAPI.removeInfoCardSuggestions(InfoCardOverlayPresenter);
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,21 @@
|
|||||||
|
package app.revanced.integrations.patches;
|
||||||
|
|
||||||
|
import android.view.View;
|
||||||
|
|
||||||
|
import app.revanced.integrations.adremover.AdRemoverAPI;
|
||||||
|
import app.revanced.integrations.settings.Settings;
|
||||||
|
import app.revanced.integrations.settings.SettingsEnum;
|
||||||
|
|
||||||
|
public class HideReelsPatch {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Used by app.revanced.patches.youtube.layout.reels.patch.HideReelsPatch
|
||||||
|
*
|
||||||
|
* @param view
|
||||||
|
*/
|
||||||
|
public static void HideReel(View view) {
|
||||||
|
if (!SettingsEnum.REEL_BUTTON_SHOWN_BOOLEAN.getBoolean()) {
|
||||||
|
AdRemoverAPI.HideViewWithLayout1dp(view);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,18 @@
|
|||||||
|
package app.revanced.integrations.patches;
|
||||||
|
|
||||||
|
|
||||||
|
import android.view.View;
|
||||||
|
|
||||||
|
import app.revanced.integrations.adremover.AdRemoverAPI;
|
||||||
|
|
||||||
|
public class HideShortsButtonPatch {
|
||||||
|
|
||||||
|
//Todo: Switch BooleanPreferences to Settings class
|
||||||
|
//Used by app.revanced.patches.youtube.layout.shorts.button.patch.ShortsButtonRemoverPatch
|
||||||
|
public static void hideShortsButton(View view) {
|
||||||
|
AdRemoverAPI.hideShortsButton(view);
|
||||||
|
}
|
||||||
|
|
||||||
|
//Needed for the ShortsButtonRemoverPatch
|
||||||
|
public static Enum lastPivotTab;
|
||||||
|
}
|
@ -0,0 +1,13 @@
|
|||||||
|
package app.revanced.integrations.patches;
|
||||||
|
|
||||||
|
import app.revanced.integrations.adremover.AdRemoverAPI;
|
||||||
|
|
||||||
|
public class HideSuggestionsPatch {
|
||||||
|
|
||||||
|
//TODO: Create Patch
|
||||||
|
//Not used yet
|
||||||
|
public static void HideSuggestions(boolean showSuggestions) {
|
||||||
|
AdRemoverAPI.removeSuggestions(showSuggestions);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,11 @@
|
|||||||
|
package app.revanced.integrations.patches;
|
||||||
|
|
||||||
|
import app.revanced.integrations.settings.SettingsEnum;
|
||||||
|
|
||||||
|
public class OldStyleQualityPatch {
|
||||||
|
|
||||||
|
//Used by app.revanced.patches.youtube.layout.oldqualitylayout.patch.OldQualityLayoutPatch
|
||||||
|
public static boolean useOldStyleQualitySettings() {
|
||||||
|
return SettingsEnum.OLD_STYLE_QUALITY_SETTINGS_BOOLEAN.getBoolean();
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,12 @@
|
|||||||
|
package app.revanced.integrations.patches;
|
||||||
|
|
||||||
|
import app.revanced.integrations.settings.SettingsEnum;
|
||||||
|
|
||||||
|
public class SeekbarTappingPatch {
|
||||||
|
|
||||||
|
//Used by app.revanced.patches.youtube.interaction.seekbar.patch.EnableSeekbarTappingPatch
|
||||||
|
public static boolean isTapSeekingEnabled() {
|
||||||
|
return SettingsEnum.TAP_SEEKING_ENABLED_BOOLEAN.getBoolean();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,12 @@
|
|||||||
|
package app.revanced.integrations.patches;
|
||||||
|
|
||||||
|
import app.revanced.integrations.adremover.whitelist.Whitelist;
|
||||||
|
|
||||||
|
public class VideoAdsPatch {
|
||||||
|
|
||||||
|
//Used by app.revanced.patches.youtube.ad.general.video.patch.VideoAdsPatch
|
||||||
|
public static boolean shouldShowAds() {
|
||||||
|
return Whitelist.shouldShowAds();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -1,10 +1,8 @@
|
|||||||
package fi.vanced.libraries.youtube.ryd;
|
package app.revanced.integrations.ryd;
|
||||||
|
|
||||||
import static fi.razerman.youtube.XGlobals.debug;
|
import static app.revanced.integrations.ryd.RYDSettings.PREFERENCES_KEY_RYD_ENABLED;
|
||||||
import static fi.vanced.libraries.youtube.ryd.RYDSettings.PREFERENCES_KEY_RYD_ENABLED;
|
import static app.revanced.integrations.ryd.RYDSettings.PREFERENCES_KEY_RYD_HINT_SHOWN;
|
||||||
import static fi.vanced.libraries.youtube.ryd.RYDSettings.PREFERENCES_KEY_RYD_HINT_SHOWN;
|
import static app.revanced.integrations.sponsorblock.StringRef.str;
|
||||||
import static fi.vanced.libraries.youtube.ryd.RYDSettings.PREFERENCES_NAME;
|
|
||||||
import static pl.jakubweg.StringRef.str;
|
|
||||||
|
|
||||||
import android.app.Activity;
|
import android.app.Activity;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
@ -17,13 +15,15 @@ import android.preference.PreferenceFragment;
|
|||||||
import android.preference.PreferenceScreen;
|
import android.preference.PreferenceScreen;
|
||||||
import android.preference.SwitchPreference;
|
import android.preference.SwitchPreference;
|
||||||
|
|
||||||
import fi.vanced.utils.SharedPrefUtils;
|
import app.revanced.integrations.settings.Settings;
|
||||||
|
import app.revanced.integrations.settings.SettingsEnum;
|
||||||
|
import app.revanced.integrations.utils.SharedPrefHelper;
|
||||||
|
|
||||||
public class RYDFragment extends PreferenceFragment {
|
public class RYDFragment extends PreferenceFragment {
|
||||||
@Override
|
@Override
|
||||||
public void onCreate(Bundle savedInstanceState) {
|
public void onCreate(Bundle savedInstanceState) {
|
||||||
super.onCreate(savedInstanceState);
|
super.onCreate(savedInstanceState);
|
||||||
getPreferenceManager().setSharedPreferencesName(PREFERENCES_NAME);
|
getPreferenceManager().setSharedPreferencesName(SharedPrefHelper.SharedPrefNames.RYD.getName());
|
||||||
|
|
||||||
final Activity context = this.getActivity();
|
final Activity context = this.getActivity();
|
||||||
|
|
||||||
@ -36,7 +36,7 @@ public class RYDFragment extends PreferenceFragment {
|
|||||||
preferenceScreen.addPreference(preference);
|
preferenceScreen.addPreference(preference);
|
||||||
preference.setKey(PREFERENCES_KEY_RYD_ENABLED);
|
preference.setKey(PREFERENCES_KEY_RYD_ENABLED);
|
||||||
preference.setDefaultValue(false);
|
preference.setDefaultValue(false);
|
||||||
preference.setChecked(SharedPrefUtils.getBoolean(context, PREFERENCES_NAME, PREFERENCES_KEY_RYD_ENABLED));
|
preference.setChecked(SharedPrefHelper.getBoolean(context, SharedPrefHelper.SharedPrefNames.RYD, PREFERENCES_KEY_RYD_ENABLED));
|
||||||
preference.setTitle(str("vanced_ryd_title"));
|
preference.setTitle(str("vanced_ryd_title"));
|
||||||
preference.setSummary(str("vanced_ryd_summary"));
|
preference.setSummary(str("vanced_ryd_summary"));
|
||||||
preference.setOnPreferenceChangeListener((pref, newValue) -> {
|
preference.setOnPreferenceChangeListener((pref, newValue) -> {
|
||||||
@ -47,12 +47,12 @@ public class RYDFragment extends PreferenceFragment {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Clear hint
|
// Clear hint
|
||||||
if (debug) {
|
if (SettingsEnum.DEBUG_BOOLEAN.getBoolean()) {
|
||||||
SwitchPreference preference = new SwitchPreference(context);
|
SwitchPreference preference = new SwitchPreference(context);
|
||||||
preferenceScreen.addPreference(preference);
|
preferenceScreen.addPreference(preference);
|
||||||
preference.setKey(PREFERENCES_KEY_RYD_HINT_SHOWN);
|
preference.setKey(PREFERENCES_KEY_RYD_HINT_SHOWN);
|
||||||
preference.setDefaultValue(false);
|
preference.setDefaultValue(false);
|
||||||
preference.setChecked(SharedPrefUtils.getBoolean(context, PREFERENCES_NAME, PREFERENCES_KEY_RYD_HINT_SHOWN));
|
preference.setChecked(SharedPrefHelper.getBoolean(context, SharedPrefHelper.SharedPrefNames.RYD, PREFERENCES_KEY_RYD_HINT_SHOWN));
|
||||||
preference.setTitle("Hint debug");
|
preference.setTitle("Hint debug");
|
||||||
preference.setSummary("Debug toggle for clearing the hint shown preference");
|
preference.setSummary("Debug toggle for clearing the hint shown preference");
|
||||||
preference.setOnPreferenceChangeListener((pref, newValue) -> true);
|
preference.setOnPreferenceChangeListener((pref, newValue) -> true);
|
@ -1,7 +1,6 @@
|
|||||||
package fi.vanced.libraries.youtube.ryd;
|
package app.revanced.integrations.ryd;
|
||||||
|
|
||||||
public class RYDSettings {
|
public class RYDSettings {
|
||||||
public static final String PREFERENCES_NAME = "ryd";
|
|
||||||
public static final String PREFERENCES_KEY_USERID = "userId";
|
public static final String PREFERENCES_KEY_USERID = "userId";
|
||||||
public static final String PREFERENCES_KEY_RYD_ENABLED = "ryd-enabled";
|
public static final String PREFERENCES_KEY_RYD_ENABLED = "ryd-enabled";
|
||||||
public static final String PREFERENCES_KEY_RYD_HINT_SHOWN = "ryd_hint_shown";
|
public static final String PREFERENCES_KEY_RYD_HINT_SHOWN = "ryd_hint_shown";
|
@ -0,0 +1,56 @@
|
|||||||
|
package app.revanced.integrations.ryd;
|
||||||
|
|
||||||
|
import static app.revanced.integrations.ryd.RYDSettings.PREFERENCES_KEY_USERID;
|
||||||
|
import static app.revanced.integrations.ryd.Utils.randomString;
|
||||||
|
|
||||||
|
import android.content.Context;
|
||||||
|
|
||||||
|
import app.revanced.integrations.utils.LogHelper;
|
||||||
|
import app.revanced.integrations.ryd.requests.RYDRequester;
|
||||||
|
import app.revanced.integrations.utils.SharedPrefHelper;
|
||||||
|
|
||||||
|
public class Registration {
|
||||||
|
private String userId;
|
||||||
|
private Context context;
|
||||||
|
|
||||||
|
public Registration(Context context) {
|
||||||
|
this.context = context;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getUserId() {
|
||||||
|
return userId != null ? userId : fetchUserId();
|
||||||
|
}
|
||||||
|
|
||||||
|
private String fetchUserId() {
|
||||||
|
try {
|
||||||
|
if (this.context == null)
|
||||||
|
throw new Exception("Unable to fetch userId because context was null");
|
||||||
|
|
||||||
|
this.userId = SharedPrefHelper.getString(context, SharedPrefHelper.SharedPrefNames.RYD, PREFERENCES_KEY_USERID, null);
|
||||||
|
|
||||||
|
if (this.userId == null) {
|
||||||
|
this.userId = register();
|
||||||
|
}
|
||||||
|
} catch (Exception ex) {
|
||||||
|
LogHelper.printException("Registration", "Unable to fetch the userId from shared preferences", ex);
|
||||||
|
}
|
||||||
|
|
||||||
|
return this.userId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void saveUserId(String userId) {
|
||||||
|
try {
|
||||||
|
if (this.context == null)
|
||||||
|
throw new Exception("Unable to save userId because context was null");
|
||||||
|
SharedPrefHelper.saveString(context, SharedPrefHelper.SharedPrefNames.RYD, PREFERENCES_KEY_USERID, userId);
|
||||||
|
} catch (Exception ex) {
|
||||||
|
LogHelper.printException("Registration", "Unable to save the userId in shared preferences", ex);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private String register() {
|
||||||
|
String userId = randomString(36);
|
||||||
|
LogHelper.debug("Registration", "Trying to register the following userId: " + userId);
|
||||||
|
return RYDRequester.register(userId, this);
|
||||||
|
}
|
||||||
|
}
|
@ -1,16 +1,14 @@
|
|||||||
package fi.vanced.libraries.youtube.ryd;
|
package app.revanced.integrations.ryd;
|
||||||
|
|
||||||
import static fi.razerman.youtube.XGlobals.debug;
|
import static app.revanced.integrations.sponsorblock.player.VideoInformation.currentVideoId;
|
||||||
import static fi.vanced.libraries.youtube.player.VideoInformation.currentVideoId;
|
import static app.revanced.integrations.sponsorblock.player.VideoInformation.dislikeCount;
|
||||||
import static fi.vanced.libraries.youtube.player.VideoInformation.dislikeCount;
|
import static app.revanced.integrations.ryd.RYDSettings.PREFERENCES_KEY_RYD_ENABLED;
|
||||||
import static fi.vanced.libraries.youtube.ryd.RYDSettings.PREFERENCES_KEY_RYD_ENABLED;
|
import static app.revanced.integrations.utils.ReVancedUtils.getIdentifier;
|
||||||
import static fi.vanced.libraries.youtube.ryd.RYDSettings.PREFERENCES_NAME;
|
|
||||||
import static fi.vanced.utils.VancedUtils.getIdentifier;
|
|
||||||
|
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.icu.text.CompactDecimalFormat;
|
import android.icu.text.CompactDecimalFormat;
|
||||||
import android.os.Build;
|
import android.os.Build;
|
||||||
import android.util.Log;
|
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.widget.TextView;
|
import android.widget.TextView;
|
||||||
|
|
||||||
@ -19,12 +17,12 @@ import com.google.android.apps.youtube.app.YouTubeTikTokRoot_Application;
|
|||||||
import java.util.Locale;
|
import java.util.Locale;
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
|
|
||||||
import fi.vanced.libraries.youtube.ryd.requests.RYDRequester;
|
import app.revanced.integrations.utils.LogHelper;
|
||||||
import fi.vanced.utils.SharedPrefUtils;
|
import app.revanced.integrations.ryd.requests.RYDRequester;
|
||||||
|
import app.revanced.integrations.utils.SharedPrefHelper;
|
||||||
|
|
||||||
public class ReturnYouTubeDislikes {
|
public class ReturnYouTubeDislikes {
|
||||||
public static boolean isEnabled;
|
public static boolean isEnabled;
|
||||||
public static final String TAG = "VI - RYD";
|
|
||||||
private static View _dislikeView = null;
|
private static View _dislikeView = null;
|
||||||
private static Thread _dislikeFetchThread = null;
|
private static Thread _dislikeFetchThread = null;
|
||||||
private static Thread _votingThread = null;
|
private static Thread _votingThread = null;
|
||||||
@ -37,16 +35,14 @@ public class ReturnYouTubeDislikes {
|
|||||||
|
|
||||||
static {
|
static {
|
||||||
Context context = YouTubeTikTokRoot_Application.getAppContext();
|
Context context = YouTubeTikTokRoot_Application.getAppContext();
|
||||||
isEnabled = SharedPrefUtils.getBoolean(Objects.requireNonNull(context), PREFERENCES_NAME, PREFERENCES_KEY_RYD_ENABLED, false);
|
isEnabled = SharedPrefHelper.getBoolean(Objects.requireNonNull(context), SharedPrefHelper.SharedPrefNames.RYD, PREFERENCES_KEY_RYD_ENABLED, false);
|
||||||
if (isEnabled) {
|
if (isEnabled) {
|
||||||
registration = new Registration(context);
|
registration = new Registration(context);
|
||||||
voting = new Voting(context, registration);
|
voting = new Voting(context, registration);
|
||||||
}
|
}
|
||||||
|
|
||||||
Locale locale = context.getResources().getConfiguration().locale;
|
Locale locale = context.getResources().getConfiguration().locale;
|
||||||
if (debug) {
|
LogHelper.debug("ReturnYoutubeDislikes", "locale - " + locale);
|
||||||
Log.d(TAG, "locale - " + locale);
|
|
||||||
}
|
|
||||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
|
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
|
||||||
compactNumberFormatter = CompactDecimalFormat.getInstance(
|
compactNumberFormatter = CompactDecimalFormat.getInstance(
|
||||||
locale,
|
locale,
|
||||||
@ -66,23 +62,18 @@ public class ReturnYouTubeDislikes {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static void newVideoLoaded(String videoId) {
|
public static void newVideoLoaded(String videoId) {
|
||||||
if (debug) {
|
LogHelper.debug("ReturnYoutubeDislikes", "newVideoLoaded - " + videoId);
|
||||||
Log.d(TAG, "newVideoLoaded - " + videoId);
|
|
||||||
}
|
|
||||||
|
|
||||||
dislikeCount = null;
|
dislikeCount = null;
|
||||||
if (!isEnabled) return;
|
if (!isEnabled) return;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
if (_dislikeFetchThread != null && _dislikeFetchThread.getState() != Thread.State.TERMINATED) {
|
if (_dislikeFetchThread != null && _dislikeFetchThread.getState() != Thread.State.TERMINATED) {
|
||||||
if (debug) {
|
LogHelper.debug("ReturnYoutubeDislikes", "Interrupting the thread. Current state " + _dislikeFetchThread.getState());
|
||||||
Log.d(TAG, "Interrupting the thread. Current state " + _dislikeFetchThread.getState());
|
|
||||||
}
|
|
||||||
_dislikeFetchThread.interrupt();
|
_dislikeFetchThread.interrupt();
|
||||||
}
|
}
|
||||||
}
|
} catch (Exception ex) {
|
||||||
catch (Exception ex) {
|
LogHelper.printException("ReturnYoutubeDislikes", "Error in the dislike fetch thread", ex);
|
||||||
Log.e(TAG, "Error in the dislike fetch thread", ex);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
_dislikeFetchThread = new Thread(() -> RYDRequester.fetchDislikes(videoId));
|
_dislikeFetchThread = new Thread(() -> RYDRequester.fetchDislikes(videoId));
|
||||||
@ -103,9 +94,8 @@ public class ReturnYouTubeDislikes {
|
|||||||
if (likeActive) {
|
if (likeActive) {
|
||||||
votingValue = 1;
|
votingValue = 1;
|
||||||
}
|
}
|
||||||
if (debug) {
|
|
||||||
Log.d(TAG, "Like tag active " + likeActive);
|
LogHelper.debug("ReturnYoutubeDislikes", "Like tag active " + likeActive);
|
||||||
}
|
|
||||||
setTag(view, "like");
|
setTag(view, "like");
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -125,9 +115,7 @@ public class ReturnYouTubeDislikes {
|
|||||||
votingValue = -1;
|
votingValue = -1;
|
||||||
}
|
}
|
||||||
_dislikeView = view;
|
_dislikeView = view;
|
||||||
if (debug) {
|
LogHelper.debug("ReturnYoutubeDislikes", "Dislike tag active " + dislikeActive);
|
||||||
Log.d(TAG, "Dislike tag active " + dislikeActive);
|
|
||||||
}
|
|
||||||
setTag(view, "dislike");
|
setTag(view, "dislike");
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -149,20 +137,16 @@ public class ReturnYouTubeDislikes {
|
|||||||
|
|
||||||
try {
|
try {
|
||||||
CharSequence tag = (CharSequence) view.getTag();
|
CharSequence tag = (CharSequence) view.getTag();
|
||||||
if (debug) {
|
LogHelper.debug("ReturnYoutubeDislikes", "handleOnSetText - " + tag + " - original text - " + originalText);
|
||||||
Log.d(TAG, "handleOnSetText - " + tag + " - original text - " + originalText);
|
|
||||||
}
|
|
||||||
if (tag == null) return originalText;
|
if (tag == null) return originalText;
|
||||||
|
|
||||||
if (tag == "like") {
|
if (tag == "like") {
|
||||||
return originalText;
|
return originalText;
|
||||||
}
|
} else if (tag == "dislike") {
|
||||||
else if (tag == "dislike") {
|
|
||||||
return dislikeCount != null ? formatDislikes(dislikeCount) : originalText;
|
return dislikeCount != null ? formatDislikes(dislikeCount) : originalText;
|
||||||
}
|
}
|
||||||
}
|
} catch (Exception ex) {
|
||||||
catch (Exception ex) {
|
LogHelper.printException("ReturnYoutubeDislikes", "Error while handling the setText", ex);
|
||||||
Log.e(TAG, "Error while handling the setText", ex);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return originalText;
|
return originalText;
|
||||||
@ -174,105 +158,100 @@ public class ReturnYouTubeDislikes {
|
|||||||
try {
|
try {
|
||||||
// Try to set normal video dislike count
|
// Try to set normal video dislike count
|
||||||
if (_dislikeView == null) {
|
if (_dislikeView == null) {
|
||||||
if (debug) { Log.d(TAG, "_dislikeView was null"); }
|
LogHelper.debug("ReturnYoutubeDislikes", "_dislikeView was null");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
View buttonView = _dislikeView.findViewById(getIdentifier("button_text", "id"));
|
View buttonView = _dislikeView.findViewById(getIdentifier("button_text", "id"));
|
||||||
if (buttonView == null) {
|
if (buttonView == null) {
|
||||||
if (debug) { Log.d(TAG, "buttonView was null"); }
|
LogHelper.debug("ReturnYoutubeDislikes", "buttonView was null");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
TextView button = (TextView) buttonView;
|
TextView button = (TextView) buttonView;
|
||||||
button.setText(dislikeCount);
|
button.setText(dislikeCount);
|
||||||
if (debug) {
|
LogHelper.debug("ReturnYoutubeDislikes", "trySetDislikes - " + dislikeCount);
|
||||||
Log.d(TAG, "trySetDislikes - " + dislikeCount);
|
} catch (Exception ex) {
|
||||||
}
|
LogHelper.printException("ReturnYoutubeDislikes", "Error while trying to set dislikes text", ex);
|
||||||
}
|
|
||||||
catch (Exception ex) {
|
|
||||||
if (debug) {
|
|
||||||
Log.e(TAG, "Error while trying to set dislikes text", ex);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void handleOnClick(View view, boolean previousState) {
|
private static void handleOnClick(View view, boolean previousState) {
|
||||||
Context context = YouTubeTikTokRoot_Application.getAppContext();
|
Context context = YouTubeTikTokRoot_Application.getAppContext();
|
||||||
if (!isEnabled || SharedPrefUtils.getBoolean(Objects.requireNonNull(context),"youtube","user_signed_out",true)) return;
|
if (!isEnabled || SharedPrefHelper.getBoolean(Objects.requireNonNull(context), SharedPrefHelper.SharedPrefNames.YOUTUBE, "user_signed_out", true))
|
||||||
|
return;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
String tag = (String) view.getTag();
|
String tag = (String) view.getTag();
|
||||||
if (debug) {
|
LogHelper.debug("ReturnYoutubeDislikes", "handleOnClick - " + tag + " - previousState - " + previousState);
|
||||||
Log.d(TAG, "handleOnClick - " + tag + " - previousState - " + previousState);
|
|
||||||
}
|
|
||||||
if (tag == null) return;
|
if (tag == null) return;
|
||||||
|
|
||||||
// If active status was removed, vote should be none
|
// If active status was removed, vote should be none
|
||||||
if (previousState) { votingValue = 0; }
|
if (previousState) {
|
||||||
|
votingValue = 0;
|
||||||
|
}
|
||||||
if (tag.equals("like")) {
|
if (tag.equals("like")) {
|
||||||
|
|
||||||
// Like was activated
|
// Like was activated
|
||||||
if (!previousState) { votingValue = 1; likeActive = true; }
|
if (!previousState) {
|
||||||
else { likeActive = false; }
|
votingValue = 1;
|
||||||
|
likeActive = true;
|
||||||
|
} else {
|
||||||
|
likeActive = false;
|
||||||
|
}
|
||||||
|
|
||||||
// Like was activated and dislike was previously activated
|
// Like was activated and dislike was previously activated
|
||||||
if (!previousState && dislikeActive) { dislikeCount--; trySetDislikes(formatDislikes(dislikeCount)); }
|
if (!previousState && dislikeActive) {
|
||||||
dislikeActive = false;
|
dislikeCount--;
|
||||||
|
trySetDislikes(formatDislikes(dislikeCount));
|
||||||
}
|
}
|
||||||
else if (tag.equals("dislike")) {
|
dislikeActive = false;
|
||||||
|
} else if (tag.equals("dislike")) {
|
||||||
likeActive = false;
|
likeActive = false;
|
||||||
|
|
||||||
// Dislike was activated
|
// Dislike was activated
|
||||||
if (!previousState) { votingValue = -1; dislikeActive = true; dislikeCount++; }
|
if (!previousState) {
|
||||||
// Dislike was removed
|
votingValue = -1;
|
||||||
else { dislikeActive = false; dislikeCount--; }
|
dislikeActive = true;
|
||||||
trySetDislikes(formatDislikes(dislikeCount));
|
dislikeCount++;
|
||||||
}
|
}
|
||||||
|
// Dislike was removed
|
||||||
else {
|
else {
|
||||||
|
dislikeActive = false;
|
||||||
|
dislikeCount--;
|
||||||
|
}
|
||||||
|
trySetDislikes(formatDislikes(dislikeCount));
|
||||||
|
} else {
|
||||||
// Unknown tag
|
// Unknown tag
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (debug) {
|
LogHelper.debug("ReturnYoutubeDislikes", "New vote status - " + votingValue);
|
||||||
Log.d(TAG, "New vote status - " + votingValue);
|
LogHelper.debug("ReturnYoutubeDislikes", "Like button " + likeActive + " | Dislike button " + dislikeActive);
|
||||||
Log.d(TAG, "Like button " + likeActive + " | Dislike button " + dislikeActive);
|
|
||||||
}
|
|
||||||
|
|
||||||
sendVote(votingValue);
|
sendVote(votingValue);
|
||||||
}
|
} catch (Exception ex) {
|
||||||
catch (Exception ex) {
|
LogHelper.printException("ReturnYoutubeDislikes", "Error while handling the onClick", ex);
|
||||||
Log.e(TAG, "Error while handling the onClick", ex);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void sendVote(int vote) {
|
private static void sendVote(int vote) {
|
||||||
if (!isEnabled) return;
|
if (!isEnabled) return;
|
||||||
|
|
||||||
if (debug) {
|
LogHelper.debug("ReturnYoutubeDislikes", "sending vote - " + vote + " for video " + currentVideoId);
|
||||||
Log.d(TAG, "sending vote - " + vote + " for video " + currentVideoId);
|
|
||||||
}
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
if (_votingThread != null && _votingThread.getState() != Thread.State.TERMINATED) {
|
if (_votingThread != null && _votingThread.getState() != Thread.State.TERMINATED) {
|
||||||
if (debug) {
|
LogHelper.debug("ReturnYoutubeDislikes", "Interrupting the thread. Current state " + _votingThread.getState());
|
||||||
Log.d(TAG, "Interrupting the thread. Current state " + _votingThread.getState());
|
|
||||||
}
|
|
||||||
_votingThread.interrupt();
|
_votingThread.interrupt();
|
||||||
}
|
}
|
||||||
}
|
} catch (Exception ex) {
|
||||||
catch (Exception ex) {
|
LogHelper.printException("ReturnYoutubeDislikes", "Error in the voting thread", ex);
|
||||||
Log.e(TAG, "Error in the voting thread", ex);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
_votingThread = new Thread(() -> {
|
_votingThread = new Thread(() -> {
|
||||||
try {
|
try {
|
||||||
boolean result = voting.sendVote(currentVideoId, vote);
|
boolean result = voting.sendVote(currentVideoId, vote);
|
||||||
if (debug) {
|
LogHelper.debug("ReturnYoutubeDislikes", "sendVote status " + result);
|
||||||
Log.d(TAG, "sendVote status " + result);
|
} catch (Exception ex) {
|
||||||
}
|
LogHelper.printException("ReturnYoutubeDislikes", "Failed to send vote", ex);
|
||||||
}
|
|
||||||
catch (Exception ex) {
|
|
||||||
Log.e(TAG, "Failed to send vote", ex);
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
_votingThread.start();
|
_votingThread.start();
|
||||||
@ -283,36 +262,23 @@ public class ReturnYouTubeDislikes {
|
|||||||
|
|
||||||
try {
|
try {
|
||||||
if (view == null) {
|
if (view == null) {
|
||||||
if (debug) {
|
LogHelper.debug("ReturnYoutubeDislikes", "View was empty");
|
||||||
Log.d(TAG, "View was empty");
|
|
||||||
}
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
LogHelper.debug("ReturnYoutubeDislikes", "setTag - " + tag);
|
||||||
if (debug) {
|
|
||||||
Log.d(TAG, "setTag - " + tag);
|
|
||||||
}
|
|
||||||
|
|
||||||
view.setTag(tag);
|
view.setTag(tag);
|
||||||
}
|
} catch (Exception ex) {
|
||||||
catch (Exception ex) {
|
LogHelper.printException("ReturnYoutubeDislikes", "Error while trying to set tag to view", ex);
|
||||||
Log.e(TAG, "Error while trying to set tag to view", ex);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static String formatDislikes(int dislikes) {
|
public static String formatDislikes(int dislikes) {
|
||||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N && compactNumberFormatter != null) {
|
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N && compactNumberFormatter != null) {
|
||||||
final String formatted = compactNumberFormatter.format(dislikes);
|
final String formatted = compactNumberFormatter.format(dislikes);
|
||||||
if (debug) {
|
LogHelper.debug("ReturnYoutubeDislikes", "Formatting dislikes - " + dislikes + " - " + formatted);
|
||||||
Log.d(TAG, "Formatting dislikes - " + dislikes + " - " + formatted);
|
|
||||||
}
|
|
||||||
|
|
||||||
return formatted;
|
return formatted;
|
||||||
}
|
}
|
||||||
|
LogHelper.debug("ReturnYoutubeDislikes", "Couldn't format dislikes, using the unformatted count - " + dislikes);
|
||||||
if (debug) {
|
|
||||||
Log.d(TAG, "Couldn't format dislikes, using the unformatted count - " + dislikes);
|
|
||||||
}
|
|
||||||
return String.valueOf(dislikes);
|
return String.valueOf(dislikes);
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -1,12 +1,18 @@
|
|||||||
package fi.vanced.libraries.youtube.ryd;
|
package app.revanced.integrations.ryd;
|
||||||
|
|
||||||
import android.util.Base64;
|
import android.util.Base64;
|
||||||
import android.util.Log;
|
|
||||||
|
|
||||||
import java.security.MessageDigest;
|
import java.security.MessageDigest;
|
||||||
|
import java.security.SecureRandom;
|
||||||
|
|
||||||
|
import app.revanced.integrations.utils.LogHelper;
|
||||||
|
|
||||||
public class Utils {
|
public class Utils {
|
||||||
private static final String TAG = "VI - RYD - Utils";
|
|
||||||
|
// https://stackoverflow.com/a/157202
|
||||||
|
private static final String AB = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";
|
||||||
|
private static SecureRandom rnd = new SecureRandom();
|
||||||
|
|
||||||
public static String solvePuzzle(String challenge, int difficulty) {
|
public static String solvePuzzle(String challenge, int difficulty) {
|
||||||
byte[] decodedChallenge = Base64.decode(challenge, Base64.NO_WRAP);
|
byte[] decodedChallenge = Base64.decode(challenge, Base64.NO_WRAP);
|
||||||
@ -20,10 +26,10 @@ public class Utils {
|
|||||||
int maxCount = (int) (Math.pow(2, difficulty + 1) * 5);
|
int maxCount = (int) (Math.pow(2, difficulty + 1) * 5);
|
||||||
MessageDigest md = MessageDigest.getInstance("SHA-512");
|
MessageDigest md = MessageDigest.getInstance("SHA-512");
|
||||||
for (int i = 0; i < maxCount; i++) {
|
for (int i = 0; i < maxCount; i++) {
|
||||||
buffer[0] = (byte)i;
|
buffer[0] = (byte) i;
|
||||||
buffer[1] = (byte)(i >> 8);
|
buffer[1] = (byte) (i >> 8);
|
||||||
buffer[2] = (byte)(i >> 16);
|
buffer[2] = (byte) (i >> 16);
|
||||||
buffer[3] = (byte)(i >> 24);
|
buffer[3] = (byte) (i >> 24);
|
||||||
byte[] messageDigest = md.digest(buffer);
|
byte[] messageDigest = md.digest(buffer);
|
||||||
|
|
||||||
if (countLeadingZeroes(messageDigest) >= difficulty) {
|
if (countLeadingZeroes(messageDigest) >= difficulty) {
|
||||||
@ -31,9 +37,8 @@ public class Utils {
|
|||||||
return encode;
|
return encode;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
} catch (Exception ex) {
|
||||||
catch (Exception ex) {
|
LogHelper.printException("RYD Utils", "Failed to solve puzzle", ex);
|
||||||
Log.e(TAG, "Failed to solve puzzle", ex);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return null;
|
return null;
|
||||||
@ -62,4 +67,11 @@ public class Utils {
|
|||||||
}
|
}
|
||||||
return zeroes;
|
return zeroes;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static String randomString(int len) {
|
||||||
|
StringBuilder sb = new StringBuilder(len);
|
||||||
|
for (int i = 0; i < len; i++)
|
||||||
|
sb.append(AB.charAt(rnd.nextInt(AB.length())));
|
||||||
|
return sb.toString();
|
||||||
|
}
|
||||||
}
|
}
|
@ -1,15 +1,12 @@
|
|||||||
package fi.vanced.libraries.youtube.ryd;
|
package app.revanced.integrations.ryd;
|
||||||
|
|
||||||
import static fi.razerman.youtube.XGlobals.debug;
|
|
||||||
|
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.util.Log;
|
|
||||||
|
|
||||||
import fi.vanced.libraries.youtube.ryd.requests.RYDRequester;
|
|
||||||
|
import app.revanced.integrations.utils.LogHelper;
|
||||||
|
import app.revanced.integrations.ryd.requests.RYDRequester;
|
||||||
|
|
||||||
public class Voting {
|
public class Voting {
|
||||||
private static final String TAG = "VI - RYD - Voting";
|
|
||||||
|
|
||||||
private Registration registration;
|
private Registration registration;
|
||||||
private Context context;
|
private Context context;
|
||||||
|
|
||||||
@ -20,9 +17,7 @@ public class Voting {
|
|||||||
|
|
||||||
public boolean sendVote(String videoId, int vote) {
|
public boolean sendVote(String videoId, int vote) {
|
||||||
String userId = registration.getUserId();
|
String userId = registration.getUserId();
|
||||||
if (debug) {
|
LogHelper.debug("Voting", "Trying to vote the following video: " + videoId + " with vote " + vote + " and userId: " + userId);
|
||||||
Log.d(TAG, "Trying to vote the following video: " + videoId + " with vote " + vote + " and userId: " + userId);
|
|
||||||
}
|
|
||||||
return RYDRequester.sendVote(videoId, userId, vote);
|
return RYDRequester.sendVote(videoId, userId, vote);
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -1,11 +1,10 @@
|
|||||||
package fi.vanced.libraries.youtube.dialog;
|
package app.revanced.integrations.ryd.dialog;
|
||||||
|
|
||||||
import static fi.vanced.libraries.youtube.ryd.RYDSettings.PREFERENCES_KEY_RYD_ENABLED;
|
import static app.revanced.integrations.ryd.RYDSettings.PREFERENCES_KEY_RYD_ENABLED;
|
||||||
import static fi.vanced.libraries.youtube.ryd.RYDSettings.PREFERENCES_KEY_RYD_HINT_SHOWN;
|
import static app.revanced.integrations.ryd.RYDSettings.PREFERENCES_KEY_RYD_HINT_SHOWN;
|
||||||
import static fi.vanced.libraries.youtube.ryd.RYDSettings.PREFERENCES_NAME;
|
import static app.revanced.integrations.sponsorblock.SponsorBlockSettings.PREFERENCES_KEY_SPONSOR_BLOCK_ENABLED;
|
||||||
import static pl.jakubweg.SponsorBlockSettings.PREFERENCES_KEY_SPONSOR_BLOCK_ENABLED;
|
import static app.revanced.integrations.sponsorblock.SponsorBlockSettings.PREFERENCES_KEY_SPONSOR_BLOCK_HINT_SHOWN;
|
||||||
import static pl.jakubweg.SponsorBlockSettings.PREFERENCES_KEY_SPONSOR_BLOCK_HINT_SHOWN;
|
import static app.revanced.integrations.sponsorblock.StringRef.str;
|
||||||
import static pl.jakubweg.StringRef.str;
|
|
||||||
|
|
||||||
import android.app.Activity;
|
import android.app.Activity;
|
||||||
import android.app.AlertDialog;
|
import android.app.AlertDialog;
|
||||||
@ -18,9 +17,8 @@ import android.os.Build;
|
|||||||
|
|
||||||
import com.google.android.apps.youtube.app.YouTubeTikTokRoot_Application;
|
import com.google.android.apps.youtube.app.YouTubeTikTokRoot_Application;
|
||||||
|
|
||||||
import fi.vanced.utils.SharedPrefUtils;
|
import app.revanced.integrations.utils.SharedPrefHelper;
|
||||||
import fi.vanced.utils.VancedUtils;
|
import app.revanced.integrations.utils.ReVancedUtils;
|
||||||
import pl.jakubweg.SponsorBlockSettings;
|
|
||||||
|
|
||||||
public class Dialogs {
|
public class Dialogs {
|
||||||
// Inject call from YT to this
|
// Inject call from YT to this
|
||||||
@ -31,14 +29,14 @@ public class Dialogs {
|
|||||||
|
|
||||||
private static void rydFirstRun(Activity activity) {
|
private static void rydFirstRun(Activity activity) {
|
||||||
Context context = YouTubeTikTokRoot_Application.getAppContext();
|
Context context = YouTubeTikTokRoot_Application.getAppContext();
|
||||||
boolean enabled = SharedPrefUtils.getBoolean(context, PREFERENCES_NAME, PREFERENCES_KEY_RYD_ENABLED, false);
|
boolean enabled = SharedPrefHelper.getBoolean(context, SharedPrefHelper.SharedPrefNames.RYD, PREFERENCES_KEY_RYD_ENABLED, false);
|
||||||
boolean hintShown = SharedPrefUtils.getBoolean(context, PREFERENCES_NAME, PREFERENCES_KEY_RYD_HINT_SHOWN, false);
|
boolean hintShown = SharedPrefHelper.getBoolean(context, SharedPrefHelper.SharedPrefNames.RYD, PREFERENCES_KEY_RYD_HINT_SHOWN, false);
|
||||||
|
|
||||||
// If RYD is enabled or hint has been shown, exit
|
// If RYD is enabled or hint has been shown, exit
|
||||||
if (enabled || hintShown) {
|
if (enabled || hintShown) {
|
||||||
// If RYD is enabled but hint hasn't been shown, mark it as shown
|
// If RYD is enabled but hint hasn't been shown, mark it as shown
|
||||||
if (enabled && !hintShown) {
|
if (enabled && !hintShown) {
|
||||||
SharedPrefUtils.saveBoolean(context, PREFERENCES_NAME, PREFERENCES_KEY_RYD_HINT_SHOWN, true);
|
SharedPrefHelper.saveBoolean(context, SharedPrefHelper.SharedPrefNames.RYD, PREFERENCES_KEY_RYD_HINT_SHOWN, true);
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -50,20 +48,20 @@ public class Dialogs {
|
|||||||
builder = new AlertDialog.Builder(activity);
|
builder = new AlertDialog.Builder(activity);
|
||||||
}
|
}
|
||||||
builder.setTitle(str("vanced_ryd"));
|
builder.setTitle(str("vanced_ryd"));
|
||||||
builder.setIcon(VancedUtils.getIdentifier("reel_dislike_icon", "drawable"));
|
builder.setIcon(ReVancedUtils.getIdentifier("reel_dislike_icon", "drawable"));
|
||||||
builder.setCancelable(false);
|
builder.setCancelable(false);
|
||||||
builder.setMessage(str("vanced_ryd_firstrun"));
|
builder.setMessage(str("vanced_ryd_firstrun"));
|
||||||
builder.setPositiveButton(str("vanced_enable"),
|
builder.setPositiveButton(str("vanced_enable"),
|
||||||
(dialog, id) -> {
|
(dialog, id) -> {
|
||||||
SharedPrefUtils.saveBoolean(context, PREFERENCES_NAME, PREFERENCES_KEY_RYD_HINT_SHOWN, true);
|
SharedPrefHelper.saveBoolean(context, SharedPrefHelper.SharedPrefNames.RYD, PREFERENCES_KEY_RYD_HINT_SHOWN, true);
|
||||||
SharedPrefUtils.saveBoolean(context, PREFERENCES_NAME, PREFERENCES_KEY_RYD_ENABLED, true);
|
SharedPrefHelper.saveBoolean(context, SharedPrefHelper.SharedPrefNames.RYD, PREFERENCES_KEY_RYD_ENABLED, true);
|
||||||
dialog.dismiss();
|
dialog.dismiss();
|
||||||
});
|
});
|
||||||
|
|
||||||
builder.setNegativeButton(str("vanced_disable"),
|
builder.setNegativeButton(str("vanced_disable"),
|
||||||
(dialog, id) -> {
|
(dialog, id) -> {
|
||||||
SharedPrefUtils.saveBoolean(context, PREFERENCES_NAME, PREFERENCES_KEY_RYD_HINT_SHOWN, true);
|
SharedPrefHelper.saveBoolean(context, SharedPrefHelper.SharedPrefNames.RYD, PREFERENCES_KEY_RYD_HINT_SHOWN, true);
|
||||||
SharedPrefUtils.saveBoolean(context, PREFERENCES_NAME, PREFERENCES_KEY_RYD_ENABLED, false);
|
SharedPrefHelper.saveBoolean(context, SharedPrefHelper.SharedPrefNames.RYD, PREFERENCES_KEY_RYD_ENABLED, false);
|
||||||
dialog.dismiss();
|
dialog.dismiss();
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -73,7 +71,7 @@ public class Dialogs {
|
|||||||
dialog.show();
|
dialog.show();
|
||||||
|
|
||||||
// Set black background
|
// Set black background
|
||||||
dialog.getWindow().getDecorView().getBackground().setColorFilter(new LightingColorFilter(0xFF000000, VancedUtils.getIdentifier("ytBrandBackgroundSolid", "color")));
|
dialog.getWindow().getDecorView().getBackground().setColorFilter(new LightingColorFilter(0xFF000000, ReVancedUtils.getIdentifier("ytBrandBackgroundSolid", "color")));
|
||||||
|
|
||||||
// Set learn more action (set here so clicking it doesn't dismiss the dialog)
|
// Set learn more action (set here so clicking it doesn't dismiss the dialog)
|
||||||
dialog.getButton(DialogInterface.BUTTON_NEUTRAL).setOnClickListener(v -> {
|
dialog.getButton(DialogInterface.BUTTON_NEUTRAL).setOnClickListener(v -> {
|
||||||
@ -85,14 +83,14 @@ public class Dialogs {
|
|||||||
|
|
||||||
private static void sbFirstRun(Activity activity) {
|
private static void sbFirstRun(Activity activity) {
|
||||||
Context context = YouTubeTikTokRoot_Application.getAppContext();
|
Context context = YouTubeTikTokRoot_Application.getAppContext();
|
||||||
boolean enabled = SharedPrefUtils.getBoolean(context, SponsorBlockSettings.PREFERENCES_NAME, PREFERENCES_KEY_SPONSOR_BLOCK_ENABLED, false);
|
boolean enabled = SharedPrefHelper.getBoolean(context, SharedPrefHelper.SharedPrefNames.RYD, PREFERENCES_KEY_SPONSOR_BLOCK_ENABLED, false);
|
||||||
boolean hintShown = SharedPrefUtils.getBoolean(context, SponsorBlockSettings.PREFERENCES_NAME, PREFERENCES_KEY_SPONSOR_BLOCK_HINT_SHOWN, false);
|
boolean hintShown = SharedPrefHelper.getBoolean(context, SharedPrefHelper.SharedPrefNames.RYD, PREFERENCES_KEY_SPONSOR_BLOCK_HINT_SHOWN, false);
|
||||||
|
|
||||||
// If SB is enabled or hint has been shown, exit
|
// If SB is enabled or hint has been shown, exit
|
||||||
if (enabled || hintShown) {
|
if (enabled || hintShown) {
|
||||||
// If SB is enabled but hint hasn't been shown, mark it as shown
|
// If SB is enabled but hint hasn't been shown, mark it as shown
|
||||||
if (enabled && !hintShown) {
|
if (enabled && !hintShown) {
|
||||||
SharedPrefUtils.saveBoolean(context, SponsorBlockSettings.PREFERENCES_NAME, PREFERENCES_KEY_SPONSOR_BLOCK_HINT_SHOWN, true);
|
SharedPrefHelper.saveBoolean(context, SharedPrefHelper.SharedPrefNames.RYD, PREFERENCES_KEY_SPONSOR_BLOCK_HINT_SHOWN, true);
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -104,20 +102,20 @@ public class Dialogs {
|
|||||||
builder = new AlertDialog.Builder(activity);
|
builder = new AlertDialog.Builder(activity);
|
||||||
}
|
}
|
||||||
builder.setTitle(str("vanced_sb"));
|
builder.setTitle(str("vanced_sb"));
|
||||||
builder.setIcon(VancedUtils.getIdentifier("ic_sb_logo", "drawable"));
|
builder.setIcon(ReVancedUtils.getIdentifier("ic_sb_logo", "drawable"));
|
||||||
builder.setCancelable(false);
|
builder.setCancelable(false);
|
||||||
builder.setMessage(str("vanced_sb_firstrun"));
|
builder.setMessage(str("vanced_sb_firstrun"));
|
||||||
builder.setPositiveButton(str("vanced_enable"),
|
builder.setPositiveButton(str("vanced_enable"),
|
||||||
(dialog, id) -> {
|
(dialog, id) -> {
|
||||||
SharedPrefUtils.saveBoolean(context, SponsorBlockSettings.PREFERENCES_NAME, PREFERENCES_KEY_SPONSOR_BLOCK_HINT_SHOWN, true);
|
SharedPrefHelper.saveBoolean(context, SharedPrefHelper.SharedPrefNames.RYD, PREFERENCES_KEY_SPONSOR_BLOCK_HINT_SHOWN, true);
|
||||||
SharedPrefUtils.saveBoolean(context, SponsorBlockSettings.PREFERENCES_NAME, PREFERENCES_KEY_SPONSOR_BLOCK_ENABLED, true);
|
SharedPrefHelper.saveBoolean(context, SharedPrefHelper.SharedPrefNames.RYD, PREFERENCES_KEY_SPONSOR_BLOCK_ENABLED, true);
|
||||||
dialog.dismiss();
|
dialog.dismiss();
|
||||||
});
|
});
|
||||||
|
|
||||||
builder.setNegativeButton(str("vanced_disable"),
|
builder.setNegativeButton(str("vanced_disable"),
|
||||||
(dialog, id) -> {
|
(dialog, id) -> {
|
||||||
SharedPrefUtils.saveBoolean(context, SponsorBlockSettings.PREFERENCES_NAME, PREFERENCES_KEY_SPONSOR_BLOCK_HINT_SHOWN, true);
|
SharedPrefHelper.saveBoolean(context, SharedPrefHelper.SharedPrefNames.RYD, PREFERENCES_KEY_SPONSOR_BLOCK_HINT_SHOWN, true);
|
||||||
SharedPrefUtils.saveBoolean(context, SponsorBlockSettings.PREFERENCES_NAME, PREFERENCES_KEY_SPONSOR_BLOCK_ENABLED, false);
|
SharedPrefHelper.saveBoolean(context, SharedPrefHelper.SharedPrefNames.RYD, PREFERENCES_KEY_SPONSOR_BLOCK_ENABLED, false);
|
||||||
dialog.dismiss();
|
dialog.dismiss();
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -127,7 +125,7 @@ public class Dialogs {
|
|||||||
dialog.show();
|
dialog.show();
|
||||||
|
|
||||||
// Set black background
|
// Set black background
|
||||||
dialog.getWindow().getDecorView().getBackground().setColorFilter(new LightingColorFilter(0xFF000000, VancedUtils.getIdentifier("ytBrandBackgroundSolid", "color")));
|
dialog.getWindow().getDecorView().getBackground().setColorFilter(new LightingColorFilter(0xFF000000, ReVancedUtils.getIdentifier("ytBrandBackgroundSolid", "color")));
|
||||||
|
|
||||||
// Set learn more action (set here so clicking it doesn't dismiss the dialog)
|
// Set learn more action (set here so clicking it doesn't dismiss the dialog)
|
||||||
dialog.getButton(DialogInterface.BUTTON_NEUTRAL).setOnClickListener(v -> {
|
dialog.getButton(DialogInterface.BUTTON_NEUTRAL).setOnClickListener(v -> {
|
@ -1,13 +1,11 @@
|
|||||||
package fi.vanced.libraries.youtube.ryd.requests;
|
package app.revanced.integrations.ryd.requests;
|
||||||
|
|
||||||
import static fi.razerman.youtube.XGlobals.debug;
|
import static app.revanced.integrations.sponsorblock.player.VideoInformation.dislikeCount;
|
||||||
import static fi.vanced.libraries.youtube.player.VideoInformation.dislikeCount;
|
import static app.revanced.integrations.adremover.whitelist.requests.Requester.parseJson;
|
||||||
import static fi.vanced.libraries.youtube.ryd.ReturnYouTubeDislikes.TAG;
|
|
||||||
import static fi.vanced.utils.requests.Requester.parseJson;
|
|
||||||
|
|
||||||
import android.os.Handler;
|
import android.os.Handler;
|
||||||
import android.os.Looper;
|
import android.os.Looper;
|
||||||
import android.util.Log;
|
|
||||||
|
|
||||||
import org.json.JSONObject;
|
import org.json.JSONObject;
|
||||||
|
|
||||||
@ -16,43 +14,40 @@ import java.io.OutputStream;
|
|||||||
import java.net.HttpURLConnection;
|
import java.net.HttpURLConnection;
|
||||||
import java.nio.charset.StandardCharsets;
|
import java.nio.charset.StandardCharsets;
|
||||||
|
|
||||||
import fi.vanced.libraries.youtube.ryd.Registration;
|
import app.revanced.integrations.utils.LogHelper;
|
||||||
import fi.vanced.libraries.youtube.ryd.ReturnYouTubeDislikes;
|
import app.revanced.integrations.ryd.Registration;
|
||||||
import fi.vanced.libraries.youtube.ryd.Utils;
|
import app.revanced.integrations.ryd.ReturnYouTubeDislikes;
|
||||||
import fi.vanced.utils.requests.Requester;
|
import app.revanced.integrations.ryd.Utils;
|
||||||
import fi.vanced.utils.requests.Route;
|
import app.revanced.integrations.adremover.whitelist.requests.Requester;
|
||||||
|
import app.revanced.integrations.adremover.whitelist.requests.Route;
|
||||||
|
|
||||||
public class RYDRequester {
|
public class RYDRequester {
|
||||||
private static final String RYD_API_URL = "https://returnyoutubedislikeapi.com/";
|
private static final String RYD_API_URL = "https://returnyoutubedislikeapi.com/";
|
||||||
|
|
||||||
private RYDRequester() {}
|
private RYDRequester() {
|
||||||
|
}
|
||||||
|
|
||||||
public static void fetchDislikes(String videoId) {
|
public static void fetchDislikes(String videoId) {
|
||||||
try {
|
try {
|
||||||
if (debug) {
|
LogHelper.debug("RYDRequester", "Fetching dislikes for " + videoId);
|
||||||
Log.d(TAG, "Fetching dislikes for " + videoId);
|
|
||||||
}
|
|
||||||
HttpURLConnection connection = getConnectionFromRoute(RYDRoutes.GET_DISLIKES, videoId);
|
HttpURLConnection connection = getConnectionFromRoute(RYDRoutes.GET_DISLIKES, videoId);
|
||||||
connection.setConnectTimeout(5 * 1000);
|
connection.setConnectTimeout(5 * 1000);
|
||||||
if (connection.getResponseCode() == 200) {
|
if (connection.getResponseCode() == 200) {
|
||||||
JSONObject json = getJSONObject(connection);
|
JSONObject json = getJSONObject(connection);
|
||||||
int dislikes = json.getInt("dislikes");
|
int dislikes = json.getInt("dislikes");
|
||||||
dislikeCount = dislikes;
|
dislikeCount = dislikes;
|
||||||
if (debug) {
|
LogHelper.debug("RYDRequester", "dislikes fetched - " + dislikeCount);
|
||||||
Log.d(TAG, "dislikes fetched - " + dislikeCount);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Set the dislikes
|
// Set the dislikes
|
||||||
new Handler(Looper.getMainLooper()).post(() -> ReturnYouTubeDislikes.trySetDislikes(ReturnYouTubeDislikes.formatDislikes(dislikes)));
|
new Handler(Looper.getMainLooper()).post(() -> ReturnYouTubeDislikes.trySetDislikes(ReturnYouTubeDislikes.formatDislikes(dislikes)));
|
||||||
}
|
} else {
|
||||||
else if (debug) {
|
LogHelper.debug("RYDRequester", "dislikes fetch response was " + connection.getResponseCode());
|
||||||
Log.d(TAG, "dislikes fetch response was " + connection.getResponseCode());
|
|
||||||
}
|
}
|
||||||
connection.disconnect();
|
connection.disconnect();
|
||||||
}
|
} catch (Exception ex) {
|
||||||
catch (Exception ex) {
|
|
||||||
dislikeCount = null;
|
dislikeCount = null;
|
||||||
Log.e(TAG, "Failed to fetch dislikes", ex);
|
LogHelper.printException("RYDRequester", "Failed to fetch dislikes", ex);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -64,65 +59,51 @@ public class RYDRequester {
|
|||||||
JSONObject json = getJSONObject(connection);
|
JSONObject json = getJSONObject(connection);
|
||||||
String challenge = json.getString("challenge");
|
String challenge = json.getString("challenge");
|
||||||
int difficulty = json.getInt("difficulty");
|
int difficulty = json.getInt("difficulty");
|
||||||
if (debug) {
|
LogHelper.debug("RYDRequester", "Registration challenge - " + challenge + " with difficulty of " + difficulty);
|
||||||
Log.d(TAG, "Registration challenge - " + challenge + " with difficulty of " + difficulty);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Solve the puzzle
|
// Solve the puzzle
|
||||||
String solution = Utils.solvePuzzle(challenge, difficulty);
|
String solution = Utils.solvePuzzle(challenge, difficulty);
|
||||||
if (debug) {
|
LogHelper.debug("RYDRequester", "Registration confirmation solution is " + solution);
|
||||||
Log.d(TAG, "Registration confirmation solution is " + solution);
|
|
||||||
}
|
|
||||||
|
|
||||||
return confirmRegistration(userId, solution, registration);
|
return confirmRegistration(userId, solution, registration);
|
||||||
}
|
} else {
|
||||||
else if (debug) {
|
LogHelper.debug("RYDRequester", "Registration response was " + connection.getResponseCode());
|
||||||
Log.d(TAG, "Registration response was " + connection.getResponseCode());
|
|
||||||
}
|
}
|
||||||
connection.disconnect();
|
connection.disconnect();
|
||||||
}
|
} catch (Exception ex) {
|
||||||
catch (Exception ex){
|
LogHelper.printException("RYDRequester", "Failed to register userId", ex);
|
||||||
Log.e(TAG, "Failed to register userId", ex);
|
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static String confirmRegistration(String userId, String solution, Registration registration) {
|
private static String confirmRegistration(String userId, String solution, Registration registration) {
|
||||||
try {
|
try {
|
||||||
if (debug) {
|
LogHelper.debug("RYDRequester", "Trying to confirm registration for the following userId: " + userId + " with solution: " + solution);
|
||||||
Log.d(TAG, "Trying to confirm registration for the following userId: " + userId + " with solution: " + solution);
|
|
||||||
}
|
|
||||||
|
|
||||||
HttpURLConnection connection = getConnectionFromRoute(RYDRoutes.CONFIRM_REGISTRATION, userId);
|
HttpURLConnection connection = getConnectionFromRoute(RYDRoutes.CONFIRM_REGISTRATION, userId);
|
||||||
applyCommonRequestSettings(connection);
|
applyCommonRequestSettings(connection);
|
||||||
|
|
||||||
String jsonInputString = "{\"solution\": \"" + solution + "\"}";
|
String jsonInputString = "{\"solution\": \"" + solution + "\"}";
|
||||||
try(OutputStream os = connection.getOutputStream()) {
|
try (OutputStream os = connection.getOutputStream()) {
|
||||||
byte[] input = jsonInputString.getBytes(StandardCharsets.UTF_8);
|
byte[] input = jsonInputString.getBytes(StandardCharsets.UTF_8);
|
||||||
os.write(input, 0, input.length);
|
os.write(input, 0, input.length);
|
||||||
}
|
}
|
||||||
if (connection.getResponseCode() == 200) {
|
if (connection.getResponseCode() == 200) {
|
||||||
String result = parseJson(connection);
|
String result = parseJson(connection);
|
||||||
if (debug) {
|
LogHelper.debug("RYDRequester", "Registration confirmation result was " + result);
|
||||||
Log.d(TAG, "Registration confirmation result was " + result);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (result.equalsIgnoreCase("true")) {
|
if (result.equalsIgnoreCase("true")) {
|
||||||
registration.saveUserId(userId);
|
registration.saveUserId(userId);
|
||||||
if (debug) {
|
LogHelper.debug("RYDRequester", "Registration was successful for user " + userId);
|
||||||
Log.d(TAG, "Registration was successful for user " + userId);
|
|
||||||
}
|
|
||||||
|
|
||||||
return userId;
|
return userId;
|
||||||
}
|
}
|
||||||
}
|
} else {
|
||||||
else if (debug) {
|
LogHelper.debug("RYDRequester", "Registration confirmation response was " + connection.getResponseCode());
|
||||||
Log.d(TAG, "Registration confirmation response was " + connection.getResponseCode());
|
|
||||||
}
|
}
|
||||||
connection.disconnect();
|
connection.disconnect();
|
||||||
}
|
} catch (Exception ex) {
|
||||||
catch (Exception ex) {
|
LogHelper.printException("RYDRequester", "Failed to confirm registration", ex);
|
||||||
Log.e(TAG, "Failed to confirm registration", ex);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return null;
|
return null;
|
||||||
@ -134,7 +115,7 @@ public class RYDRequester {
|
|||||||
applyCommonRequestSettings(connection);
|
applyCommonRequestSettings(connection);
|
||||||
|
|
||||||
String voteJsonString = "{\"userId\": \"" + userId + "\", \"videoId\": \"" + videoId + "\", \"value\": \"" + vote + "\"}";
|
String voteJsonString = "{\"userId\": \"" + userId + "\", \"videoId\": \"" + videoId + "\", \"value\": \"" + vote + "\"}";
|
||||||
try(OutputStream os = connection.getOutputStream()) {
|
try (OutputStream os = connection.getOutputStream()) {
|
||||||
byte[] input = voteJsonString.getBytes(StandardCharsets.UTF_8);
|
byte[] input = voteJsonString.getBytes(StandardCharsets.UTF_8);
|
||||||
os.write(input, 0, input.length);
|
os.write(input, 0, input.length);
|
||||||
}
|
}
|
||||||
@ -143,26 +124,20 @@ public class RYDRequester {
|
|||||||
JSONObject json = getJSONObject(connection);
|
JSONObject json = getJSONObject(connection);
|
||||||
String challenge = json.getString("challenge");
|
String challenge = json.getString("challenge");
|
||||||
int difficulty = json.getInt("difficulty");
|
int difficulty = json.getInt("difficulty");
|
||||||
if (debug) {
|
LogHelper.debug("RYDRequester", "Vote challenge - " + challenge + " with difficulty of " + difficulty);
|
||||||
Log.d(TAG, "Vote challenge - " + challenge + " with difficulty of " + difficulty);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Solve the puzzle
|
// Solve the puzzle
|
||||||
String solution = Utils.solvePuzzle(challenge, difficulty);
|
String solution = Utils.solvePuzzle(challenge, difficulty);
|
||||||
if (debug) {
|
LogHelper.debug("RYDRequester", "Vote confirmation solution is " + solution);
|
||||||
Log.d(TAG, "Vote confirmation solution is " + solution);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Confirm vote
|
// Confirm vote
|
||||||
return confirmVote(videoId, userId, solution);
|
return confirmVote(videoId, userId, solution);
|
||||||
}
|
} else {
|
||||||
else if (debug) {
|
LogHelper.debug("RYDRequester", "Vote response was " + connection.getResponseCode());
|
||||||
Log.d(TAG, "Vote response was " + connection.getResponseCode());
|
|
||||||
}
|
}
|
||||||
connection.disconnect();
|
connection.disconnect();
|
||||||
}
|
} catch (Exception ex) {
|
||||||
catch (Exception ex) {
|
LogHelper.printException("RYDRequester", "Failed to send vote", ex);
|
||||||
Log.e(TAG, "Failed to send vote", ex);
|
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -173,31 +148,26 @@ public class RYDRequester {
|
|||||||
applyCommonRequestSettings(connection);
|
applyCommonRequestSettings(connection);
|
||||||
|
|
||||||
String jsonInputString = "{\"userId\": \"" + userId + "\", \"videoId\": \"" + videoId + "\", \"solution\": \"" + solution + "\"}";
|
String jsonInputString = "{\"userId\": \"" + userId + "\", \"videoId\": \"" + videoId + "\", \"solution\": \"" + solution + "\"}";
|
||||||
try(OutputStream os = connection.getOutputStream()) {
|
try (OutputStream os = connection.getOutputStream()) {
|
||||||
byte[] input = jsonInputString.getBytes(StandardCharsets.UTF_8);
|
byte[] input = jsonInputString.getBytes(StandardCharsets.UTF_8);
|
||||||
os.write(input, 0, input.length);
|
os.write(input, 0, input.length);
|
||||||
}
|
}
|
||||||
if (connection.getResponseCode() == 200) {
|
if (connection.getResponseCode() == 200) {
|
||||||
String result = parseJson(connection);
|
String result = parseJson(connection);
|
||||||
if (debug) {
|
LogHelper.debug("RYDRequester", "Vote confirmation result was " + result);
|
||||||
Log.d(TAG, "Vote confirmation result was " + result);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (result.equalsIgnoreCase("true")) {
|
if (result.equalsIgnoreCase("true")) {
|
||||||
if (debug) {
|
LogHelper.debug("RYDRequester", "Vote was successful for user " + userId);
|
||||||
Log.d(TAG, "Vote was successful for user " + userId);
|
|
||||||
}
|
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
} else {
|
||||||
else if (debug) {
|
LogHelper.debug("RYDRequester", "Vote confirmation response was " + connection.getResponseCode());
|
||||||
Log.d(TAG, "Vote confirmation response was " + connection.getResponseCode());
|
|
||||||
}
|
}
|
||||||
connection.disconnect();
|
connection.disconnect();
|
||||||
}
|
} catch (Exception ex) {
|
||||||
catch (Exception ex) {
|
LogHelper.printException("RYDRequester", "Failed to confirm vote", ex);
|
||||||
Log.e(TAG, "Failed to confirm vote", ex);
|
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
@ -0,0 +1,17 @@
|
|||||||
|
package app.revanced.integrations.ryd.requests;
|
||||||
|
|
||||||
|
import static app.revanced.integrations.adremover.whitelist.requests.Route.Method.GET;
|
||||||
|
import static app.revanced.integrations.adremover.whitelist.requests.Route.Method.POST;
|
||||||
|
|
||||||
|
import app.revanced.integrations.adremover.whitelist.requests.Route;
|
||||||
|
|
||||||
|
public class RYDRoutes {
|
||||||
|
public static final Route SEND_VOTE = new Route(POST, "interact/vote");
|
||||||
|
public static final Route CONFIRM_VOTE = new Route(POST, "interact/confirmVote");
|
||||||
|
public static final Route GET_DISLIKES = new Route(GET, "votes?videoId={video_id}");
|
||||||
|
public static final Route GET_REGISTRATION = new Route(GET, "puzzle/registration?userId={user_id}");
|
||||||
|
public static final Route CONFIRM_REGISTRATION = new Route(POST, "puzzle/registration?userId={user_id}");
|
||||||
|
|
||||||
|
private RYDRoutes() {
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,393 @@
|
|||||||
|
package app.revanced.integrations.settings;
|
||||||
|
|
||||||
|
import android.app.Activity;
|
||||||
|
import android.app.AlertDialog;
|
||||||
|
import android.content.Context;
|
||||||
|
import android.content.DialogInterface;
|
||||||
|
import android.content.SharedPreferences;
|
||||||
|
import android.content.pm.PackageInfo;
|
||||||
|
import android.content.pm.PackageManager;
|
||||||
|
import android.content.res.Resources;
|
||||||
|
import android.os.Build;
|
||||||
|
import android.view.MotionEvent;
|
||||||
|
import android.view.ViewConfiguration;
|
||||||
|
import android.view.ViewGroup;
|
||||||
|
|
||||||
|
import com.google.android.apps.youtube.app.YouTubeTikTokRoot_Application;
|
||||||
|
|
||||||
|
import java.util.Objects;
|
||||||
|
|
||||||
|
import app.revanced.integrations.sponsorblock.player.PlayerType;
|
||||||
|
import app.revanced.integrations.sponsorblock.SponsorBlockUtils;
|
||||||
|
import app.revanced.integrations.sponsorblock.player.ui.SponsorBlockView;
|
||||||
|
import app.revanced.integrations.utils.LogHelper;
|
||||||
|
import app.revanced.integrations.utils.SharedPrefHelper;
|
||||||
|
import app.revanced.integrations.videoswipecontrols.FensterGestureController;
|
||||||
|
import app.revanced.integrations.videoswipecontrols.XFenster;
|
||||||
|
import app.revanced.integrations.utils.SwipeHelper;
|
||||||
|
import app.revanced.integrations.sponsorblock.NewSegmentHelperLayout;
|
||||||
|
|
||||||
|
public class Settings {
|
||||||
|
private static Object AutoRepeatClass;
|
||||||
|
private static PlayerType env;
|
||||||
|
private static FensterGestureController fensterGestureController;
|
||||||
|
|
||||||
|
public static Boolean userChangedQuality = false;
|
||||||
|
public static Boolean userChangedSpeed = false;
|
||||||
|
public static Boolean newVideo = false;
|
||||||
|
public static Boolean newVideoSpeed = false;
|
||||||
|
public static float[] videoSpeeds = { 0.25f, 0.5f, 0.75f, 1.0f, 1.25f, 1.5f, 2f, 3f, 4f, 5f };
|
||||||
|
|
||||||
|
public static String getManufacturer() {
|
||||||
|
String manufacturer = SettingsEnum.MANUFACTURER_OVERRIDE_STRING.getString();
|
||||||
|
if (manufacturer == null || manufacturer.isEmpty()) {
|
||||||
|
manufacturer = Build.MANUFACTURER;
|
||||||
|
}
|
||||||
|
LogHelper.debug("Settings", "getManufacturer: " + manufacturer);
|
||||||
|
return manufacturer;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static String getModel() {
|
||||||
|
String model = SettingsEnum.MODEL_OVERRIDE_STRING.getString();
|
||||||
|
if (model == null || model.isEmpty()) {
|
||||||
|
model = Build.MODEL;
|
||||||
|
}
|
||||||
|
LogHelper.debug("Settings", "getModel: " + model);
|
||||||
|
return model;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static String getStringByName(Context context, String name) {
|
||||||
|
try {
|
||||||
|
Resources res = context.getResources();
|
||||||
|
return res.getString(res.getIdentifier(name, "string", context.getPackageName()));
|
||||||
|
} catch (Throwable exception) {
|
||||||
|
LogHelper.printException("Settings", "Resource not found.", exception);
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void CheckForMicroG(Activity activity) {
|
||||||
|
AlertDialog.Builder builder;
|
||||||
|
if (!appInstalledOrNot("com.mgoogle.android.gms")) {
|
||||||
|
LogHelper.debug("XDebug", "Custom MicroG installation undetected");
|
||||||
|
if (Build.VERSION.SDK_INT >= 21) {
|
||||||
|
builder = new AlertDialog.Builder(activity, 16974374);
|
||||||
|
} else {
|
||||||
|
builder = new AlertDialog.Builder(activity);
|
||||||
|
}
|
||||||
|
builder.setTitle("Someone is not reading...").setMessage("You didn't install the MicroG as instructed, you can't login without it.\n\nInstall it and try again.").setPositiveButton("Close", new DialogInterface.OnClickListener() { // from class: app.revanced.integrations.settings.Settings.1
|
||||||
|
@Override // android.content.DialogInterface.OnClickListener
|
||||||
|
public void onClick(DialogInterface dialog, int id) {
|
||||||
|
}
|
||||||
|
}).show();
|
||||||
|
} else {
|
||||||
|
LogHelper.debug("XDebug", "Custom MicroG installation detected");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static boolean isFensterEnabled() {
|
||||||
|
if (env != null && env == PlayerType.WATCH_WHILE_FULLSCREEN && !SwipeHelper.IsControlsShown()) {
|
||||||
|
return SettingsEnum.ENABLE_SWIPE_BRIGHTNESS_BOOLEAN.getBoolean() || SettingsEnum.ENABLE_SWIPE_VOLUME_BOOLEAN.getBoolean();
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static boolean isWatchWhileFullScreen() {
|
||||||
|
if (env == null) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return env.toString().equals("WATCH_WHILE_FULLSCREEN");
|
||||||
|
}
|
||||||
|
|
||||||
|
private static boolean appInstalledOrNot(String uri) {
|
||||||
|
try {
|
||||||
|
PackageManager pm = getContext().getPackageManager();
|
||||||
|
pm.getPackageInfo(uri, PackageManager.GET_ACTIVITIES);
|
||||||
|
return true;
|
||||||
|
} catch (PackageManager.NameNotFoundException e) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static String getVersionName(Context context) {
|
||||||
|
try {
|
||||||
|
PackageInfo pInfo = context.getPackageManager().getPackageInfo(context.getPackageName(), 0);
|
||||||
|
String version = pInfo.versionName;
|
||||||
|
return (version);
|
||||||
|
} catch (PackageManager.NameNotFoundException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
|
||||||
|
return ("17.23.35");
|
||||||
|
}
|
||||||
|
|
||||||
|
public static String getPackageName() {
|
||||||
|
Context context = YouTubeTikTokRoot_Application.getAppContext();
|
||||||
|
if (context == null) {
|
||||||
|
LogHelper.printException("Settings", "Context is null, returning com.google.android.youtube!");
|
||||||
|
return "com.google.android.youtube";
|
||||||
|
}
|
||||||
|
String PACKAGE_NAME = context.getPackageName();
|
||||||
|
LogHelper.debug("Settings", "getPackageName: " + PACKAGE_NAME);
|
||||||
|
|
||||||
|
return PACKAGE_NAME;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static int getOverrideWidth(int original) {
|
||||||
|
int compatibility = SettingsEnum.CODEC_OVERRIDE_BOOLEAN.getBoolean() ? 2160 : original;
|
||||||
|
return compatibility;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static int getOverrideHeight(int original) {
|
||||||
|
int compatibility = SettingsEnum.CODEC_OVERRIDE_BOOLEAN.getBoolean() ? 3840 : original;
|
||||||
|
return compatibility;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static Context getContext() {
|
||||||
|
Context context = YouTubeTikTokRoot_Application.getAppContext();
|
||||||
|
if (context != null) {
|
||||||
|
LogHelper.debug("Settings", "getContext");
|
||||||
|
return context;
|
||||||
|
} else {
|
||||||
|
LogHelper.printException("Settings", "Context is null, returning null!");
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void setOldLayout(SharedPreferences sharedPreferences, String config, long timeStamp) {
|
||||||
|
if (!SettingsEnum.OLD_LAYOUT_XFILE_ENABLED_BOOLEAN.getBoolean()) {
|
||||||
|
sharedPreferences.edit().putString("com.google.android.libraries.youtube.innertube.cold_config_group", config).putLong("com.google.android.libraries.youtube.innertube.cold_stored_timestamp", timeStamp).apply();
|
||||||
|
LogHelper.debug("Settings", "setOldLayout: true");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (sharedPreferences.contains("com.google.android.libraries.youtube.innertube.cold_config_group")) {
|
||||||
|
sharedPreferences.edit().putString("com.google.android.libraries.youtube.innertube.cold_config_group_backup", sharedPreferences.getString("com.google.android.libraries.youtube.innertube.cold_config_group", null)).remove("com.google.android.libraries.youtube.innertube.cold_config_group").apply();
|
||||||
|
}
|
||||||
|
LogHelper.debug("Settings", "setOldLayout: false");
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void NewVideoStarted() {
|
||||||
|
newVideo = true;
|
||||||
|
newVideoSpeed = true;
|
||||||
|
LogHelper.debug("Settings", "New video started!");
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void InitializeFensterController(Context context, ViewGroup viewGroup, ViewConfiguration viewConfiguration) {
|
||||||
|
fensterGestureController = new FensterGestureController();
|
||||||
|
fensterGestureController.setFensterEventsListener(new XFenster(context, viewGroup), context, viewConfiguration);
|
||||||
|
LogHelper.debug("Settings", "XFenster initialized");
|
||||||
|
}
|
||||||
|
|
||||||
|
public static boolean FensterTouchEvent(MotionEvent motionEvent) {
|
||||||
|
if (fensterGestureController == null) {
|
||||||
|
LogHelper.debug("Settings", "fensterGestureController is null");
|
||||||
|
return false;
|
||||||
|
} else if (motionEvent == null) {
|
||||||
|
LogHelper.debug("Settings", "motionEvent is null");
|
||||||
|
return false;
|
||||||
|
} else if (!SwipeHelper.IsControlsShown()) {
|
||||||
|
return fensterGestureController.onTouchEvent(motionEvent);
|
||||||
|
} else {
|
||||||
|
LogHelper.debug("Settings", "skipping onTouchEvent dispatching because controls are shown.");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void PlayerTypeChanged(PlayerType playerType) {
|
||||||
|
LogHelper.debug("XDebug", playerType.toString());
|
||||||
|
if (env != playerType) {
|
||||||
|
if (playerType == PlayerType.WATCH_WHILE_FULLSCREEN) {
|
||||||
|
EnableXFenster();
|
||||||
|
} else {
|
||||||
|
DisableXFenster();
|
||||||
|
}
|
||||||
|
if (playerType == PlayerType.WATCH_WHILE_SLIDING_MINIMIZED_MAXIMIZED || playerType == PlayerType.WATCH_WHILE_MINIMIZED || playerType == PlayerType.WATCH_WHILE_PICTURE_IN_PICTURE) {
|
||||||
|
NewSegmentHelperLayout.hide();
|
||||||
|
}
|
||||||
|
SponsorBlockView.playerTypeChanged(playerType);
|
||||||
|
SponsorBlockUtils.playerTypeChanged(playerType);
|
||||||
|
}
|
||||||
|
env = playerType;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void EnableXFenster() {
|
||||||
|
if (SettingsEnum.ENABLE_SWIPE_BRIGHTNESS_BOOLEAN.getBoolean() || SettingsEnum.ENABLE_SWIPE_VOLUME_BOOLEAN.getBoolean()) {
|
||||||
|
FensterGestureController fensterGestureController2 = fensterGestureController;
|
||||||
|
fensterGestureController2.TouchesEnabled = true;
|
||||||
|
((XFenster) fensterGestureController2.listener).enable(SettingsEnum.ENABLE_SWIPE_BRIGHTNESS_BOOLEAN.getBoolean(), SettingsEnum.ENABLE_SWIPE_VOLUME_BOOLEAN.getBoolean());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void DisableXFenster() {
|
||||||
|
FensterGestureController fensterGestureController2 = fensterGestureController;
|
||||||
|
fensterGestureController2.TouchesEnabled = false;
|
||||||
|
((XFenster) fensterGestureController2.listener).disable();
|
||||||
|
}
|
||||||
|
|
||||||
|
/*public static boolean autoCaptions(boolean original) {
|
||||||
|
ReadSettings();
|
||||||
|
if (!settingsInitialized.booleanValue()) {
|
||||||
|
LogHelper.printException("Settings", "Context is null, returning " + original + "!");
|
||||||
|
return original;
|
||||||
|
}
|
||||||
|
Boolean captions = Boolean.valueOf(original);
|
||||||
|
if (prefAutoCaptions.booleanValue()) {
|
||||||
|
captions = true;
|
||||||
|
}
|
||||||
|
LogHelper.debug("Settings", "autoCaptions: " + captions);
|
||||||
|
return captions.booleanValue();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static boolean getOverride(boolean original) {
|
||||||
|
ReadSettings();
|
||||||
|
if (!settingsInitialized.booleanValue()) {
|
||||||
|
LogHelper.printException("Settings", "Context is null, returning " + original + "!");
|
||||||
|
return original;
|
||||||
|
}
|
||||||
|
Boolean compatibility = Boolean.valueOf(original);
|
||||||
|
if (overrideCodec.booleanValue()) {
|
||||||
|
compatibility = true;
|
||||||
|
}
|
||||||
|
LogHelper.debug("Settings", "getOverride: " + compatibility);
|
||||||
|
|
||||||
|
return compatibility.booleanValue();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static int getCommentsLocation(int original) {
|
||||||
|
ReadSettings();
|
||||||
|
if (!settingsInitialized.booleanValue()) {
|
||||||
|
LogHelper.printException("Settings", "Context is null, returning " + original + "!");
|
||||||
|
return original;
|
||||||
|
} else if (!commentsLocation.booleanValue()) {
|
||||||
|
return original;
|
||||||
|
} else {
|
||||||
|
LogHelper.debug("Settings", "getCommentsLocation: Moving comments back down");
|
||||||
|
return 3;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static boolean getTabletMiniplayerOverride(boolean original) {
|
||||||
|
ReadSettings();
|
||||||
|
if (!settingsInitialized.booleanValue()) {
|
||||||
|
LogHelper.printException("Settings", "Context is null, returning " + original + "!");
|
||||||
|
return original;
|
||||||
|
} else if (!tabletMiniplayer.booleanValue()) {
|
||||||
|
return original;
|
||||||
|
} else {
|
||||||
|
LogHelper.debug("Settings", "getTabletMiniplayerOverride: Using tablet miniplayer");
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static boolean getNewActionBar(boolean original) {
|
||||||
|
ReadSettings();
|
||||||
|
if (!settingsInitialized.booleanValue()) {
|
||||||
|
LogHelper.printException("Settings", "Context is null, returning " + original + "!");
|
||||||
|
return original;
|
||||||
|
} else if (!newActionBar.booleanValue()) {
|
||||||
|
return original;
|
||||||
|
} else {
|
||||||
|
LogHelper.debug("Settings", "getNewActionBar: Enabled");
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}*/
|
||||||
|
|
||||||
|
/*
|
||||||
|
public static boolean getNewActionBarNegated(boolean original) {
|
||||||
|
ReadSettings();
|
||||||
|
if (!settingsInitialized.booleanValue()) {
|
||||||
|
LogHelper.printException("Settings", "Context is null, returning " + original + "!");
|
||||||
|
return original;
|
||||||
|
} else if (!newActionBar.booleanValue()) {
|
||||||
|
return original;
|
||||||
|
} else {
|
||||||
|
LogHelper.debug("Settings", "getNewActionBar: Enabled");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static boolean getVerticalZoomToFit(boolean original) {
|
||||||
|
ReadSettings();
|
||||||
|
if (!settingsInitialized.booleanValue()) {
|
||||||
|
LogHelper.printException("Settings", "Context is null, returning " + original + "!");
|
||||||
|
return original;
|
||||||
|
} else if (!verticalZoomToFit.booleanValue()) {
|
||||||
|
return original;
|
||||||
|
} else {
|
||||||
|
LogHelper.debug("Settings", "getVerticalZoomToFit: Enabled");
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static int getMinimizedVideo(int original) {
|
||||||
|
int preferredType = SettingsEnum.PREFERRED_MINIMIZED_VIDEO_PREVIEW_INTEGER.getInt();
|
||||||
|
if (preferredType == -2) {
|
||||||
|
return original;
|
||||||
|
}
|
||||||
|
if (preferredType == 0 || preferredType == 1) {
|
||||||
|
return preferredType;
|
||||||
|
}
|
||||||
|
return original;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public static boolean getThemeStatus() {
|
||||||
|
ReadSettings();
|
||||||
|
if (!settingsInitialized.booleanValue()) {
|
||||||
|
LogHelper.printException("Settings", "Context is null, returning false!");
|
||||||
|
return false;
|
||||||
|
} else if (!isDarkApp.booleanValue()) {
|
||||||
|
return false;
|
||||||
|
} else {
|
||||||
|
LogHelper.debug("Settings", "getThemeStatus: Is themed");
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static boolean accessibilitySeek(boolean original) {
|
||||||
|
ReadSettings();
|
||||||
|
if (!settingsInitialized.booleanValue()) {
|
||||||
|
LogHelper.printException("Settings", "Context is null, returning " + original + "!");
|
||||||
|
return original;
|
||||||
|
}
|
||||||
|
Boolean seek = Boolean.valueOf(original);
|
||||||
|
if (accessibilitySeek.booleanValue()) {
|
||||||
|
seek = true;
|
||||||
|
}
|
||||||
|
LogHelper.debug("Settings", "accessibilitySeek: " + seek);
|
||||||
|
return seek.booleanValue();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static boolean shouldAutoRepeat() {
|
||||||
|
return SettingsEnum.PREFERRED_AUTO_REPEAT_BOOLEAN.getBoolean();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static float getHDRBrightness(float original) {
|
||||||
|
if (!SettingsEnum.USE_HDR_BRIGHTNESS_BOOLEAN.getBoolean()) return original;
|
||||||
|
return SettingsEnum.ENABLE_SWIPE_BRIGHTNESS_BOOLEAN.getBoolean() ? BrightnessHelper.getBrightness() : -1.0f;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static int getMaxBuffer(int original) {
|
||||||
|
return SettingsEnum.MAX_BUFFER_INTEGER.getInt();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
public static int getPlaybackBuffer(int original) {
|
||||||
|
return SettingsEnum.PLAYBACK_MAX_BUFFER_INTEGER.getInt();
|
||||||
|
}
|
||||||
|
*/
|
||||||
|
|
||||||
|
/*
|
||||||
|
public static int getReBuffer(int original) {
|
||||||
|
return SettingsEnum.MAX_PLAYBACK_BUFFER_AFTER_REBUFFER_INTEGER.getInt();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static boolean isFensterBrightnessEnabled() {
|
||||||
|
return SettingsEnum.ENABLE_SWIPE_BRIGHTNESS_BOOLEAN.getBoolean();
|
||||||
|
}
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,162 @@
|
|||||||
|
package app.revanced.integrations.settings;
|
||||||
|
|
||||||
|
import android.content.Context;
|
||||||
|
|
||||||
|
import com.google.android.apps.youtube.app.YouTubeTikTokRoot_Application;
|
||||||
|
|
||||||
|
import app.revanced.integrations.utils.LogHelper;
|
||||||
|
import app.revanced.integrations.utils.SharedPrefHelper;
|
||||||
|
|
||||||
|
public enum SettingsEnum {
|
||||||
|
|
||||||
|
DEBUG_BOOLEAN("debug_xfile_enabled", false),
|
||||||
|
MANUFACTURER_OVERRIDE_STRING("override_manufacturer", null),
|
||||||
|
MODEL_OVERRIDE_STRING("override_model", null),
|
||||||
|
CODEC_OVERRIDE_BOOLEAN("override_resolution_xfile_enabled", false),
|
||||||
|
PREFERRED_RESOLUTION_WIFI_INTEGER("pref_video_quality_wifi", -2),
|
||||||
|
PREFERRED_RESOLUTION_MOBILE_INTEGER("pref_video_quality_mobile", -2),
|
||||||
|
PREFERRED_VIDEO_SPEED_FLOAT("pref_video_speed", -2.0f),
|
||||||
|
PREFERRED_AUTO_CAPTIONS_BOOLEAN("pref_auto_captions", false),
|
||||||
|
PREFERRED_MINIMIZED_VIDEO_PREVIEW_INTEGER("pref_minimized_video_preview", -2),
|
||||||
|
PREFERRED_AUTO_REPEAT_BOOLEAN("pref_auto_repeat", false),
|
||||||
|
HOME_ADS_SHOWN_BOOLEAN("home_ads_enabled", false),
|
||||||
|
VIDEO_ADS_SHOWN_BOOLEAN("video_ads_enabled", false),
|
||||||
|
REEL_BUTTON_SHOWN_BOOLEAN("reel_button_enabled", false),
|
||||||
|
SHORTS_BUTTON_SHOWN_BOOLEAN("shorts_button_enabled", false),
|
||||||
|
CAST_BUTTON_SHOWN_BOOLEAN("cast_button_enabled", false),
|
||||||
|
CREATE_BUTTON_SHOWN_BOOLEAN("xfile_create_button_hidden", true),
|
||||||
|
SUGGESTIONS_SHOWN_BOOLEAN("info_card_suggestions_enabled", true),
|
||||||
|
INFO_CARDS_SHOWN_BOOLEAN("info_cards_enabled", true),
|
||||||
|
BRANDING_SHOWN_BOOLEAN("branding_watermark_enabled", true),
|
||||||
|
USE_TABLET_MINIPLAYER_BOOLEAN("tablet_miniplayer", false),
|
||||||
|
CHANGE_COMMENT_LOCATION_BOOLEAN("comments_location", false),
|
||||||
|
USE_NEW_ACTIONBAR_BOOLEAN("xfile_new_actionbar", false),
|
||||||
|
USE_VERTICAL_ZOOM_TO_FIT_BOOLEAN("xfile_zoom_to_fit_vertical", false),
|
||||||
|
USE_DARK_THEME_BOOLEAN("app_theme_dark", false),
|
||||||
|
ACCESSIBILITY_SEEK_BOOLEAN("xfile_accessibility_seek_buttons", false),
|
||||||
|
USE_HDR_BRIGHTNESS_BOOLEAN("pref_hdr_autobrightness", false),
|
||||||
|
ENABLE_SWIPE_BRIGHTNESS_BOOLEAN("pref_xfenster_brightness", false),
|
||||||
|
ENABLE_SWIPE_VOLUME_BOOLEAN("pref_xfenster_volume", false),
|
||||||
|
SWIPE_THRESHOLD_INTEGER("pref_xfenster_swipe_threshold", 30),
|
||||||
|
SWIPE_PADDING_TOP_INTEGER("pref_xfenster_swipe_padding_top", 50),
|
||||||
|
MAX_BUFFER_INTEGER("pref_max_buffer_ms", 120000),
|
||||||
|
PLAYBACK_MAX_BUFFER_INTEGER("pref_buffer_for_playback_ms", 2500),
|
||||||
|
MAX_PLAYBACK_BUFFER_AFTER_REBUFFER_INTEGER("pref_buffer_for_playback_after_rebuffer_ms", 5000),
|
||||||
|
OLD_STYLE_QUALITY_SETTINGS_BOOLEAN("old_style_quality_settings", true),
|
||||||
|
OLD_LAYOUT_XFILE_ENABLED_BOOLEAN("old_layout_xfile_enabled", false),
|
||||||
|
TAP_SEEKING_ENABLED_BOOLEAN("xfile_enable_tap_seeking", true),
|
||||||
|
;
|
||||||
|
|
||||||
|
private final String path;
|
||||||
|
private final Object defaultValue;
|
||||||
|
|
||||||
|
private Object value = null;
|
||||||
|
private static boolean loaded = false;
|
||||||
|
|
||||||
|
SettingsEnum(String path, Object defaultValue) {
|
||||||
|
this.path = path;
|
||||||
|
this.defaultValue = defaultValue;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void loadSettings() {
|
||||||
|
if (loaded) return;
|
||||||
|
|
||||||
|
Context context;
|
||||||
|
if ((context = YouTubeTikTokRoot_Application.getAppContext()) != null) {
|
||||||
|
for (SettingsEnum setting : values()) {
|
||||||
|
Object value = null;
|
||||||
|
if (setting.name().endsWith("BOOLEAN")) {
|
||||||
|
value = SharedPrefHelper.getBoolean(context, SharedPrefHelper.SharedPrefNames.YOUTUBE, setting.getPath());
|
||||||
|
} else if (setting.name().endsWith("INTEGER")) {
|
||||||
|
value = SharedPrefHelper.getInt(context, SharedPrefHelper.SharedPrefNames.YOUTUBE, setting.getPath());
|
||||||
|
} else if (setting.name().endsWith("STRING")) {
|
||||||
|
value = SharedPrefHelper.getString(context, SharedPrefHelper.SharedPrefNames.YOUTUBE, setting.getPath());
|
||||||
|
} else if (setting.name().endsWith("LONG")) {
|
||||||
|
value = SharedPrefHelper.getLong(context, SharedPrefHelper.SharedPrefNames.YOUTUBE, setting.getPath());
|
||||||
|
} else if (setting.name().endsWith(("FLOAT"))) {
|
||||||
|
value = SharedPrefHelper.getFloat(context, SharedPrefHelper.SharedPrefNames.YOUTUBE, setting.getPath());
|
||||||
|
} else {
|
||||||
|
LogHelper.printException("SettingsEnum", "Setting does not end with a valid Type. Name is: " + setting.name());
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
if (value == null) value = setting.getDefaultValue();
|
||||||
|
setting.setValue(value);
|
||||||
|
}
|
||||||
|
loaded = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static boolean isLoaded() {
|
||||||
|
return loaded;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setValue(Object newValue) {
|
||||||
|
this.value = newValue;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void saveValue(Object newValue) {
|
||||||
|
loadSettings();
|
||||||
|
Context context;
|
||||||
|
if ((context = YouTubeTikTokRoot_Application.getAppContext()) != null) {
|
||||||
|
if (name().endsWith("BOOLEAN")) {
|
||||||
|
SharedPrefHelper.saveBoolean(context, SharedPrefHelper.SharedPrefNames.YOUTUBE, getPath(), (Boolean) newValue);
|
||||||
|
} else if (name().endsWith("INTEGER")) {
|
||||||
|
SharedPrefHelper.saveInt(context, SharedPrefHelper.SharedPrefNames.YOUTUBE, getPath(), (int) newValue);
|
||||||
|
} else if (name().endsWith("STRING")) {
|
||||||
|
SharedPrefHelper.saveString(context, SharedPrefHelper.SharedPrefNames.YOUTUBE, getPath(), (String) newValue);
|
||||||
|
} else if (name().endsWith("LONG")) {
|
||||||
|
SharedPrefHelper.saveLong(context, SharedPrefHelper.SharedPrefNames.YOUTUBE, getPath(), (Long) newValue);
|
||||||
|
} else if (name().endsWith(("FLOAT"))) {
|
||||||
|
SharedPrefHelper.saveFloat(context, SharedPrefHelper.SharedPrefNames.YOUTUBE, getPath(), (Float) newValue);
|
||||||
|
} else {
|
||||||
|
LogHelper.printException("SettingsEnum", "Setting does not end with a valid Type. Name is: " + name());
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
LogHelper.printException("SettingsEnum", "Context on SaveValue is null!");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getInt() {
|
||||||
|
SettingsEnum.loadSettings();
|
||||||
|
if (value == null) value = -1;
|
||||||
|
LogHelper.debug("SettingsEnum", "Variable " + name() + " is " + value);
|
||||||
|
return (int) value;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getString() {
|
||||||
|
SettingsEnum.loadSettings();
|
||||||
|
LogHelper.debug("SettingsEnum", "Variable " + name() + " is " + value);
|
||||||
|
return (String) value;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean getBoolean() {
|
||||||
|
SettingsEnum.loadSettings();
|
||||||
|
//LogHelper.debug("SettingsEnum", "Variable " + name() + " is " + value);
|
||||||
|
return (Boolean) value;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Long getLong() {
|
||||||
|
SettingsEnum.loadSettings();
|
||||||
|
if (value == null) value = -1L;
|
||||||
|
LogHelper.debug("SettingsEnum", "Variable " + name() + " is " + value);
|
||||||
|
return (Long) value;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Float getFloat() {
|
||||||
|
SettingsEnum.loadSettings();
|
||||||
|
if (value == null) value = -1.0f;
|
||||||
|
LogHelper.debug("SettingsEnum", "Variable " + name() + " is " + value);
|
||||||
|
return (Float) value;
|
||||||
|
}
|
||||||
|
|
||||||
|
private Object getDefaultValue() {
|
||||||
|
return defaultValue;
|
||||||
|
}
|
||||||
|
|
||||||
|
private String getPath() {
|
||||||
|
return path;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -1,4 +1,4 @@
|
|||||||
package fi.razerman.youtube;
|
package app.revanced.integrations.settings;
|
||||||
|
|
||||||
import android.annotation.SuppressLint;
|
import android.annotation.SuppressLint;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
@ -11,16 +11,19 @@ import android.preference.Preference;
|
|||||||
import android.preference.PreferenceFragment;
|
import android.preference.PreferenceFragment;
|
||||||
import android.preference.PreferenceScreen;
|
import android.preference.PreferenceScreen;
|
||||||
import android.preference.SwitchPreference;
|
import android.preference.SwitchPreference;
|
||||||
import android.util.Log;
|
|
||||||
import android.widget.Toast;
|
import android.widget.Toast;
|
||||||
|
|
||||||
import com.google.android.apps.youtube.app.YouTubeTikTokRoot_Application;
|
import com.google.android.apps.youtube.app.YouTubeTikTokRoot_Application;
|
||||||
import fi.razerman.youtube.Autorepeat.AutoRepeat;
|
|
||||||
import fi.razerman.youtube.Fenster.FensterGestureListener;
|
import app.revanced.integrations.utils.LogHelper;
|
||||||
import fi.razerman.youtube.Helpers.XScreenSizeHelpers;
|
import app.revanced.integrations.videoplayer.autorepeat.AutoRepeat;
|
||||||
import fi.razerman.youtube.Helpers.XSwipeHelper;
|
import app.revanced.integrations.videoswipecontrols.FensterGestureListener;
|
||||||
import fi.razerman.youtube.VideoUrl.Copy;
|
import app.revanced.integrations.videoplayer.settings.XReboot;
|
||||||
import fi.razerman.youtube.VideoUrl.CopyWithTimeStamp;
|
import app.revanced.integrations.utils.ScreenSizeHelper;
|
||||||
import vanced.integrations.BuildConfig;
|
import app.revanced.integrations.utils.SwipeHelper;
|
||||||
|
import app.revanced.integrations.videoplayer.videourl.Copy;
|
||||||
|
import app.revanced.integrations.videoplayer.videourl.CopyWithTimeStamp;
|
||||||
|
import app.revanced.integrations.BuildConfig;
|
||||||
|
|
||||||
/* loaded from: classes6.dex */
|
/* loaded from: classes6.dex */
|
||||||
public class XSettingsFragment extends PreferenceFragment {
|
public class XSettingsFragment extends PreferenceFragment {
|
||||||
@ -62,82 +65,84 @@ public class XSettingsFragment extends PreferenceFragment {
|
|||||||
private final int neededClicks = 5;
|
private final int neededClicks = 5;
|
||||||
private boolean hiddenMenuOpened = false;
|
private boolean hiddenMenuOpened = false;
|
||||||
private boolean settingsInitialized = false;
|
private boolean settingsInitialized = false;
|
||||||
// from class: fi.razerman.youtube.XSettingsFragment.9
|
// from class: app.revanced.integrations.settings.XSettingsFragment.9
|
||||||
// android.content.SharedPreferences.OnSharedPreferenceChangeListener
|
// android.content.SharedPreferences.OnSharedPreferenceChangeListener
|
||||||
SharedPreferences.OnSharedPreferenceChangeListener listener = (sharedPreferences, str) -> {
|
SharedPreferences.OnSharedPreferenceChangeListener listener = (sharedPreferences, str) -> {
|
||||||
if ("debug_xfile_enabled".equals(str)) {
|
if ("debug_xfile_enabled".equals(str)) {
|
||||||
XGlobals.debug = ((SwitchPreference) XSettingsFragment.this.findPreference("debug_xfile_enabled")).isChecked();
|
SettingsEnum.DEBUG_BOOLEAN.setValue(((SwitchPreference) XSettingsFragment.this.findPreference("debug_xfile_enabled")).isChecked());
|
||||||
} else if ("vp9_xfile_enabled".equals(str)) {
|
} else if ("vp9_xfile_enabled".equals(str)) {
|
||||||
if (((SwitchPreference) XSettingsFragment.this.codecPreferenceScreen.findPreference("vp9_xfile_enabled")).isChecked()) {
|
if (((SwitchPreference) XSettingsFragment.this.codecPreferenceScreen.findPreference("vp9_xfile_enabled")).isChecked()) {
|
||||||
sharedPreferences.edit().putString("override_manufacturer", "samsung").apply();
|
sharedPreferences.edit().putString("override_manufacturer", "samsung").apply();
|
||||||
sharedPreferences.edit().putString("override_model", "SM-G920F").apply();
|
sharedPreferences.edit().putString("override_model", "SM-G920F").apply();
|
||||||
XGlobals.manufacturerOverride = "samsung";
|
SettingsEnum.MANUFACTURER_OVERRIDE_STRING.setValue("samsung");
|
||||||
XGlobals.modelOverride = "SM-G920F";
|
SettingsEnum.MODEL_OVERRIDE_STRING.setValue("SM-G920F");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
sharedPreferences.edit().remove("override_manufacturer").apply();
|
sharedPreferences.edit().remove("override_manufacturer").apply();
|
||||||
sharedPreferences.edit().remove("override_model").apply();
|
sharedPreferences.edit().remove("override_model").apply();
|
||||||
XGlobals.manufacturerOverride = null;
|
SettingsEnum.MANUFACTURER_OVERRIDE_STRING.setValue(null);
|
||||||
XGlobals.modelOverride = null;
|
SettingsEnum.MODEL_OVERRIDE_STRING.setValue(null);
|
||||||
} else if ("override_manufacturer".equals(str)) {
|
} else if ("override_manufacturer".equals(str)) {
|
||||||
EditTextPreference editTextPreference = (EditTextPreference) XSettingsFragment.this.codecPreferenceScreen.findPreference("override_manufacturer");
|
EditTextPreference editTextPreference = (EditTextPreference) XSettingsFragment.this.codecPreferenceScreen.findPreference("override_manufacturer");
|
||||||
if (editTextPreference != null) {
|
if (editTextPreference != null) {
|
||||||
editTextPreference.setSummary(editTextPreference.getText());
|
editTextPreference.setSummary(editTextPreference.getText());
|
||||||
XGlobals.manufacturerOverride = editTextPreference.getText();
|
SettingsEnum.MANUFACTURER_OVERRIDE_STRING.setValue(editTextPreference.getText());
|
||||||
}
|
}
|
||||||
} else if ("override_model".equals(str)) {
|
} else if ("override_model".equals(str)) {
|
||||||
EditTextPreference editTextPreference2 = (EditTextPreference) XSettingsFragment.this.codecPreferenceScreen.findPreference("override_model");
|
EditTextPreference editTextPreference2 = (EditTextPreference) XSettingsFragment.this.codecPreferenceScreen.findPreference("override_model");
|
||||||
if (editTextPreference2 != null) {
|
if (editTextPreference2 != null) {
|
||||||
editTextPreference2.setSummary(editTextPreference2.getText());
|
editTextPreference2.setSummary(editTextPreference2.getText());
|
||||||
XGlobals.modelOverride = editTextPreference2.getText();
|
SettingsEnum.MODEL_OVERRIDE_STRING.setValue(editTextPreference2.getText());
|
||||||
}
|
}
|
||||||
} else if ("home_ads_enabled".equals(str)) {
|
} else if ("home_ads_enabled".equals(str)) {
|
||||||
XGlobals.homeAdsShown = ((SwitchPreference) XSettingsFragment.this.adsSettingsPreferenceScreen.findPreference("home_ads_enabled")).isChecked();
|
SettingsEnum.HOME_ADS_SHOWN_BOOLEAN.setValue(((SwitchPreference) XSettingsFragment.this.adsSettingsPreferenceScreen.findPreference("home_ads_enabled")).isChecked());
|
||||||
if (XGlobals.getContext() != null && XSettingsFragment.this.settingsInitialized) {
|
if (Settings.getContext() != null && XSettingsFragment.this.settingsInitialized) {
|
||||||
XReboot.RebootDialog(XSettingsFragment.this.getActivity());
|
XReboot.RebootDialog(XSettingsFragment.this.getActivity());
|
||||||
}
|
}
|
||||||
} else if ("video_ads_enabled".equals(str)) {
|
} else if ("video_ads_enabled".equals(str)) {
|
||||||
XGlobals.videoAdsShown = ((SwitchPreference) XSettingsFragment.this.adsSettingsPreferenceScreen.findPreference("video_ads_enabled")).isChecked();
|
SettingsEnum.VIDEO_ADS_SHOWN_BOOLEAN.setValue(((SwitchPreference) XSettingsFragment.this.adsSettingsPreferenceScreen.findPreference("video_ads_enabled")).isChecked());
|
||||||
if (XGlobals.getContext() != null && XSettingsFragment.this.settingsInitialized) {
|
if (Settings.getContext() != null && XSettingsFragment.this.settingsInitialized) {
|
||||||
XReboot.RebootDialog(XSettingsFragment.this.getActivity());
|
XReboot.RebootDialog(XSettingsFragment.this.getActivity());
|
||||||
}
|
}
|
||||||
} else if ("reel_enabled".equals(str)) {
|
} else if ("reel_enabled".equals(str)) {
|
||||||
XGlobals.reelShown = ((SwitchPreference) XSettingsFragment.this.layoutSettingsPreferenceScreen.findPreference("reel_enabled")).isChecked();
|
SettingsEnum.REEL_BUTTON_SHOWN_BOOLEAN.setValue(((SwitchPreference) XSettingsFragment.this.layoutSettingsPreferenceScreen.findPreference("reel_enabled")).isChecked());
|
||||||
if (XGlobals.getContext() != null && XSettingsFragment.this.settingsInitialized) {
|
if (Settings.getContext() != null && XSettingsFragment.this.settingsInitialized) {
|
||||||
XReboot.RebootDialog(XSettingsFragment.this.getActivity());
|
XReboot.RebootDialog(XSettingsFragment.this.getActivity());
|
||||||
}
|
}
|
||||||
} else if ("info_card_suggestions_enabled".equals(str)) {
|
} else if ("info_card_suggestions_enabled".equals(str)) {
|
||||||
XGlobals.suggestionsShown = ((SwitchPreference) XSettingsFragment.this.layoutSettingsPreferenceScreen.findPreference("info_card_suggestions_enabled")).isChecked();
|
SettingsEnum.SUGGESTIONS_SHOWN_BOOLEAN.setValue(((SwitchPreference) XSettingsFragment.this.layoutSettingsPreferenceScreen.findPreference("info_card_suggestions_enabled")).isChecked());
|
||||||
} else if ("info_cards_enabled".equals(str)) {
|
} else if ("info_cards_enabled".equals(str)) {
|
||||||
XGlobals.infoCardsShown = ((SwitchPreference) XSettingsFragment.this.layoutSettingsPreferenceScreen.findPreference("info_cards_enabled")).isChecked();
|
SettingsEnum.INFO_CARDS_SHOWN_BOOLEAN.setValue(((SwitchPreference) XSettingsFragment.this.layoutSettingsPreferenceScreen.findPreference("info_cards_enabled")).isChecked());
|
||||||
} else if ("branding_watermark_enabled".equals(str)) {
|
} else if ("branding_watermark_enabled".equals(str)) {
|
||||||
XGlobals.brandingShown = ((SwitchPreference) XSettingsFragment.this.layoutSettingsPreferenceScreen.findPreference("branding_watermark_enabled")).isChecked();
|
SettingsEnum.BRANDING_SHOWN_BOOLEAN.setValue(((SwitchPreference) XSettingsFragment.this.layoutSettingsPreferenceScreen.findPreference("branding_watermark_enabled")).isChecked());
|
||||||
} else if ("cast_button_enabled".equals(str)) {
|
} else if ("cast_button_enabled".equals(str)) {
|
||||||
XGlobals.castButtonShown = ((SwitchPreference) XSettingsFragment.this.layoutSettingsPreferenceScreen.findPreference("cast_button_enabled")).isChecked();
|
SettingsEnum.CAST_BUTTON_SHOWN_BOOLEAN.setValue(((SwitchPreference) XSettingsFragment.this.layoutSettingsPreferenceScreen.findPreference("cast_button_enabled")).isChecked());
|
||||||
} else if ("tablet_miniplayer".equals(str)) {
|
} else if ("tablet_miniplayer".equals(str)) {
|
||||||
XGlobals.tabletMiniplayer = ((SwitchPreference) XSettingsFragment.this.layoutSettingsPreferenceScreen.findPreference("tablet_miniplayer")).isChecked();
|
SettingsEnum.USE_TABLET_MINIPLAYER_BOOLEAN.setValue(((SwitchPreference) XSettingsFragment.this.layoutSettingsPreferenceScreen.findPreference("tablet_miniplayer")).isChecked());
|
||||||
if (XGlobals.getContext() != null && XSettingsFragment.this.settingsInitialized) {
|
if (Settings.getContext() != null && XSettingsFragment.this.settingsInitialized) {
|
||||||
XReboot.RebootDialog(XSettingsFragment.this.getActivity());
|
XReboot.RebootDialog(XSettingsFragment.this.getActivity());
|
||||||
}
|
}
|
||||||
} else if ("comments_location".equals(str)) {
|
} else if ("comments_location".equals(str)) {
|
||||||
SwitchPreference switchPreference = (SwitchPreference) XSettingsFragment.this.layoutSettingsPreferenceScreen.findPreference("comments_location");
|
SwitchPreference switchPreference = (SwitchPreference) XSettingsFragment.this.layoutSettingsPreferenceScreen.findPreference("comments_location");
|
||||||
XGlobals.commentsLocation = switchPreference.isChecked();
|
SettingsEnum.CHANGE_COMMENT_LOCATION_BOOLEAN.setValue(switchPreference.isChecked());
|
||||||
XSwipeHelper.isTabletMode = switchPreference.isChecked();
|
SwipeHelper.isTabletMode = switchPreference.isChecked();
|
||||||
if (XGlobals.getContext() != null && XSettingsFragment.this.settingsInitialized) {
|
if (Settings.getContext() != null && XSettingsFragment.this.settingsInitialized) {
|
||||||
XReboot.RebootDialog(XSettingsFragment.this.getActivity());
|
XReboot.RebootDialog(XSettingsFragment.this.getActivity());
|
||||||
}
|
}
|
||||||
} else if ("xfile_create_button_hidden".equals(str)) {
|
} else if ("xfile_create_button_hidden".equals(str)) {
|
||||||
if (XGlobals.getContext() != null && XSettingsFragment.this.settingsInitialized) {
|
SwitchPreference switchPreference = (SwitchPreference) XSettingsFragment.this.layoutSettingsPreferenceScreen.findPreference("xfile_create_button_hidden");
|
||||||
|
SettingsEnum.CREATE_BUTTON_SHOWN_BOOLEAN.setValue(switchPreference.isChecked());
|
||||||
|
if (Settings.getContext() != null && XSettingsFragment.this.settingsInitialized) {
|
||||||
XReboot.RebootDialog(XSettingsFragment.this.getActivity());
|
XReboot.RebootDialog(XSettingsFragment.this.getActivity());
|
||||||
}
|
}
|
||||||
} else if ("xfile_new_actionbar".equals(str)) {
|
} else if ("xfile_new_actionbar".equals(str)) {
|
||||||
XGlobals.newActionBar = ((SwitchPreference) XSettingsFragment.this.layoutSettingsPreferenceScreen.findPreference("xfile_new_actionbar")).isChecked();
|
SettingsEnum.USE_NEW_ACTIONBAR_BOOLEAN.setValue(((SwitchPreference) XSettingsFragment.this.layoutSettingsPreferenceScreen.findPreference("xfile_new_actionbar")).isChecked());
|
||||||
if (XGlobals.getContext() != null && XSettingsFragment.this.settingsInitialized) {
|
if (Settings.getContext() != null && XSettingsFragment.this.settingsInitialized) {
|
||||||
XReboot.RebootDialog(XSettingsFragment.this.getActivity());
|
XReboot.RebootDialog(XSettingsFragment.this.getActivity());
|
||||||
}
|
}
|
||||||
} else if ("xfile_zoom_to_fit_vertical".equals(str)) {
|
} else if ("xfile_zoom_to_fit_vertical".equals(str)) {
|
||||||
XGlobals.verticalZoomToFit = ((SwitchPreference) XSettingsFragment.this.layoutSettingsPreferenceScreen.findPreference("xfile_zoom_to_fit_vertical")).isChecked();
|
SettingsEnum.USE_VERTICAL_ZOOM_TO_FIT_BOOLEAN.setValue(((SwitchPreference) XSettingsFragment.this.layoutSettingsPreferenceScreen.findPreference("xfile_zoom_to_fit_vertical")).isChecked());
|
||||||
if (XGlobals.getContext() != null && XSettingsFragment.this.settingsInitialized) {
|
if (Settings.getContext() != null && XSettingsFragment.this.settingsInitialized) {
|
||||||
XReboot.RebootDialog(XSettingsFragment.this.getActivity());
|
XReboot.RebootDialog(XSettingsFragment.this.getActivity());
|
||||||
}
|
}
|
||||||
} else if ("pref_minimized_video_preview".equals(str)) {
|
} else if ("pref_minimized_video_preview".equals(str)) {
|
||||||
@ -145,19 +150,19 @@ public class XSettingsFragment extends PreferenceFragment {
|
|||||||
String string = sharedPreferences.getString("pref_minimized_video_preview", "-2");
|
String string = sharedPreferences.getString("pref_minimized_video_preview", "-2");
|
||||||
listPreference.setDefaultValue(string);
|
listPreference.setDefaultValue(string);
|
||||||
listPreference.setSummary(XSettingsFragment.this.minimizedVideoEntries[listPreference.findIndexOfValue(string)]);
|
listPreference.setSummary(XSettingsFragment.this.minimizedVideoEntries[listPreference.findIndexOfValue(string)]);
|
||||||
if (XGlobals.getContext() != null && XSettingsFragment.this.settingsInitialized) {
|
if (Settings.getContext() != null && XSettingsFragment.this.settingsInitialized) {
|
||||||
XReboot.RebootDialog(XSettingsFragment.this.getActivity());
|
XReboot.RebootDialog(XSettingsFragment.this.getActivity());
|
||||||
}
|
}
|
||||||
} else if ("xfile_accessibility_seek_buttons".equals(str)) {
|
} else if ("xfile_accessibility_seek_buttons".equals(str)) {
|
||||||
XGlobals.accessibilitySeek = ((SwitchPreference) XSettingsFragment.this.layoutSettingsPreferenceScreen.findPreference("xfile_accessibility_seek_buttons")).isChecked();
|
SettingsEnum.ACCESSIBILITY_SEEK_BOOLEAN.setValue(((SwitchPreference) XSettingsFragment.this.layoutSettingsPreferenceScreen.findPreference("xfile_accessibility_seek_buttons")).isChecked());
|
||||||
} else if ("override_resolution_xfile_enabled".equals(str)) {
|
} else if ("override_resolution_xfile_enabled".equals(str)) {
|
||||||
XGlobals.overrideCodec = ((SwitchPreference) XSettingsFragment.this.findPreference("override_resolution_xfile_enabled")).isChecked();
|
SettingsEnum.CODEC_OVERRIDE_BOOLEAN.setValue(((SwitchPreference) XSettingsFragment.this.findPreference("override_resolution_xfile_enabled")).isChecked());
|
||||||
if (XGlobals.getContext() != null && XSettingsFragment.this.settingsInitialized) {
|
if (Settings.getContext() != null && XSettingsFragment.this.settingsInitialized) {
|
||||||
XReboot.RebootDialog(XSettingsFragment.this.getActivity());
|
XReboot.RebootDialog(XSettingsFragment.this.getActivity());
|
||||||
}
|
}
|
||||||
} else if ("pref_auto_captions".equals(str)) {
|
} else if ("pref_auto_captions".equals(str)) {
|
||||||
XGlobals.prefAutoCaptions = ((SwitchPreference) XSettingsFragment.this.findPreference("pref_auto_captions")).isChecked();
|
SettingsEnum.PREFERRED_AUTO_CAPTIONS_BOOLEAN.setValue(((SwitchPreference) XSettingsFragment.this.findPreference("pref_auto_captions")).isChecked());
|
||||||
if (XGlobals.getContext() != null && XSettingsFragment.this.settingsInitialized) {
|
if (Settings.getContext() != null && XSettingsFragment.this.settingsInitialized) {
|
||||||
XReboot.RebootDialog(XSettingsFragment.this.getActivity());
|
XReboot.RebootDialog(XSettingsFragment.this.getActivity());
|
||||||
}
|
}
|
||||||
} else if ("pref_preferred_video_quality_wifi".equals(str)) {
|
} else if ("pref_preferred_video_quality_wifi".equals(str)) {
|
||||||
@ -165,36 +170,36 @@ public class XSettingsFragment extends PreferenceFragment {
|
|||||||
String string2 = sharedPreferences.getString("pref_preferred_video_quality_wifi", "-2");
|
String string2 = sharedPreferences.getString("pref_preferred_video_quality_wifi", "-2");
|
||||||
listPreference2.setDefaultValue(string2);
|
listPreference2.setDefaultValue(string2);
|
||||||
listPreference2.setSummary(XSettingsFragment.this.videoQualityEntries[listPreference2.findIndexOfValue(string2)]);
|
listPreference2.setSummary(XSettingsFragment.this.videoQualityEntries[listPreference2.findIndexOfValue(string2)]);
|
||||||
XGlobals.prefResolutionWIFI = Integer.parseInt(string2);
|
SettingsEnum.PREFERRED_RESOLUTION_WIFI_INTEGER.setValue(Integer.parseInt(string2));
|
||||||
} else if ("pref_preferred_video_quality_mobile".equals(str)) {
|
} else if ("pref_preferred_video_quality_mobile".equals(str)) {
|
||||||
ListPreference listPreference3 = (ListPreference) XSettingsFragment.this.videoSettingsPreferenceScreen.findPreference("pref_preferred_video_quality_mobile");
|
ListPreference listPreference3 = (ListPreference) XSettingsFragment.this.videoSettingsPreferenceScreen.findPreference("pref_preferred_video_quality_mobile");
|
||||||
String string3 = sharedPreferences.getString("pref_preferred_video_quality_mobile", "-2");
|
String string3 = sharedPreferences.getString("pref_preferred_video_quality_mobile", "-2");
|
||||||
listPreference3.setDefaultValue(string3);
|
listPreference3.setDefaultValue(string3);
|
||||||
listPreference3.setSummary(XSettingsFragment.this.videoQualityEntries[listPreference3.findIndexOfValue(string3)]);
|
listPreference3.setSummary(XSettingsFragment.this.videoQualityEntries[listPreference3.findIndexOfValue(string3)]);
|
||||||
XGlobals.prefResolutionMobile = Integer.parseInt(string3);
|
SettingsEnum.PREFERRED_RESOLUTION_MOBILE_INTEGER.setValue(Integer.parseInt(string3));
|
||||||
} else if ("pref_preferred_video_speed".equals(str)) {
|
} else if ("pref_preferred_video_speed".equals(str)) {
|
||||||
ListPreference listPreference4 = (ListPreference) XSettingsFragment.this.videoSettingsPreferenceScreen.findPreference("pref_preferred_video_speed");
|
ListPreference listPreference4 = (ListPreference) XSettingsFragment.this.videoSettingsPreferenceScreen.findPreference("pref_preferred_video_speed");
|
||||||
String string4 = sharedPreferences.getString("pref_preferred_video_speed", "-2");
|
String string4 = sharedPreferences.getString("pref_preferred_video_speed", "-2");
|
||||||
listPreference4.setDefaultValue(string4);
|
listPreference4.setDefaultValue(string4);
|
||||||
listPreference4.setSummary(XSettingsFragment.this.videoSpeedEntries[listPreference4.findIndexOfValue(string4)]);
|
listPreference4.setSummary(XSettingsFragment.this.videoSpeedEntries[listPreference4.findIndexOfValue(string4)]);
|
||||||
XGlobals.prefVideoSpeed = Float.parseFloat(string4);
|
SettingsEnum.PREFERRED_VIDEO_SPEED_FLOAT.setValue(Float.parseFloat(string4));
|
||||||
} else if ("pref_max_buffer_ms".equals(str)) {
|
} else if ("pref_max_buffer_ms".equals(str)) {
|
||||||
EditTextPreference editTextPreference3 = (EditTextPreference) XSettingsFragment.this.bufferSettingsPreferenceScreen.findPreference("pref_max_buffer_ms");
|
EditTextPreference editTextPreference3 = (EditTextPreference) XSettingsFragment.this.bufferSettingsPreferenceScreen.findPreference("pref_max_buffer_ms");
|
||||||
if (editTextPreference3 != null) {
|
if (editTextPreference3 != null) {
|
||||||
editTextPreference3.setSummary(editTextPreference3.getText());
|
editTextPreference3.setSummary(editTextPreference3.getText());
|
||||||
XGlobals.maxBuffer = Integer.parseInt(editTextPreference3.getText());
|
SettingsEnum.MAX_BUFFER_INTEGER.setValue(Integer.parseInt(editTextPreference3.getText()));
|
||||||
}
|
}
|
||||||
} else if ("pref_buffer_for_playback_ms".equals(str)) {
|
} else if ("pref_buffer_for_playback_ms".equals(str)) {
|
||||||
EditTextPreference editTextPreference4 = (EditTextPreference) XSettingsFragment.this.bufferSettingsPreferenceScreen.findPreference("pref_buffer_for_playback_ms");
|
EditTextPreference editTextPreference4 = (EditTextPreference) XSettingsFragment.this.bufferSettingsPreferenceScreen.findPreference("pref_buffer_for_playback_ms");
|
||||||
if (editTextPreference4 != null) {
|
if (editTextPreference4 != null) {
|
||||||
editTextPreference4.setSummary(editTextPreference4.getText());
|
editTextPreference4.setSummary(editTextPreference4.getText());
|
||||||
XGlobals.playbackMS = Integer.parseInt(editTextPreference4.getText());
|
SettingsEnum.PLAYBACK_MAX_BUFFER_INTEGER.setValue(Integer.parseInt(editTextPreference4.getText()));
|
||||||
}
|
}
|
||||||
} else if ("pref_buffer_for_playback_after_rebuffer_ms".equals(str)) {
|
} else if ("pref_buffer_for_playback_after_rebuffer_ms".equals(str)) {
|
||||||
EditTextPreference editTextPreference5 = (EditTextPreference) XSettingsFragment.this.bufferSettingsPreferenceScreen.findPreference("pref_buffer_for_playback_after_rebuffer_ms");
|
EditTextPreference editTextPreference5 = (EditTextPreference) XSettingsFragment.this.bufferSettingsPreferenceScreen.findPreference("pref_buffer_for_playback_after_rebuffer_ms");
|
||||||
if (editTextPreference5 != null) {
|
if (editTextPreference5 != null) {
|
||||||
editTextPreference5.setSummary(editTextPreference5.getText());
|
editTextPreference5.setSummary(editTextPreference5.getText());
|
||||||
XGlobals.reBuffer = Integer.parseInt(editTextPreference5.getText());
|
SettingsEnum.MAX_PLAYBACK_BUFFER_AFTER_REBUFFER_INTEGER.setValue(Integer.parseInt(editTextPreference5.getText()));
|
||||||
}
|
}
|
||||||
} else if ("pref_auto_repeat_button".equals(str)) {
|
} else if ("pref_auto_repeat_button".equals(str)) {
|
||||||
XSettingsFragment.this.AutoRepeatLinks();
|
XSettingsFragment.this.AutoRepeatLinks();
|
||||||
@ -205,13 +210,13 @@ public class XSettingsFragment extends PreferenceFragment {
|
|||||||
} else if ("pref_copy_video_url_button_list".equals(str)) {
|
} else if ("pref_copy_video_url_button_list".equals(str)) {
|
||||||
Copy.refreshShouldBeShown();
|
Copy.refreshShouldBeShown();
|
||||||
} else if ("pref_hdr_autobrightness".equals(str)) {
|
} else if ("pref_hdr_autobrightness".equals(str)) {
|
||||||
XGlobals.HDRBrightness = ((SwitchPreference) XSettingsFragment.this.miscsPreferenceScreen.findPreference("pref_hdr_autobrightness")).isChecked();
|
SettingsEnum.USE_HDR_BRIGHTNESS_BOOLEAN.setValue(((SwitchPreference) XSettingsFragment.this.miscsPreferenceScreen.findPreference("pref_hdr_autobrightness")).isChecked());
|
||||||
} else if ("pref_xfenster_brightness".equals(str)) {
|
} else if ("pref_xfenster_brightness".equals(str)) {
|
||||||
XGlobals.EnableXFensterBrightness = ((SwitchPreference) XSettingsFragment.this.xFensterPreferenceScreen.findPreference("pref_xfenster_brightness")).isChecked();
|
SettingsEnum.ENABLE_SWIPE_BRIGHTNESS_BOOLEAN.setValue(((SwitchPreference) XSettingsFragment.this.xFensterPreferenceScreen.findPreference("pref_xfenster_brightness")).isChecked());
|
||||||
} else if ("pref_xfenster_volume".equals(str)) {
|
} else if ("pref_xfenster_volume".equals(str)) {
|
||||||
XGlobals.EnableXFensterVolume = ((SwitchPreference) XSettingsFragment.this.xFensterPreferenceScreen.findPreference("pref_xfenster_volume")).isChecked();
|
SettingsEnum.ENABLE_SWIPE_VOLUME_BOOLEAN.setValue(((SwitchPreference) XSettingsFragment.this.xFensterPreferenceScreen.findPreference("pref_xfenster_volume")).isChecked());
|
||||||
} else if ("pref_xfenster_tablet".equals(str)) {
|
} else if ("pref_xfenster_tablet".equals(str)) {
|
||||||
XSwipeHelper.isTabletMode = ((SwitchPreference) XSettingsFragment.this.xFensterPreferenceScreen.findPreference("pref_xfenster_tablet")).isChecked();
|
SwipeHelper.isTabletMode = ((SwitchPreference) XSettingsFragment.this.xFensterPreferenceScreen.findPreference("pref_xfenster_tablet")).isChecked();
|
||||||
} else if ("pref_xfenster_swipe_threshold".equals(str)) {
|
} else if ("pref_xfenster_swipe_threshold".equals(str)) {
|
||||||
EditTextPreference editTextPreference6 = (EditTextPreference) XSettingsFragment.this.xFensterPreferenceScreen.findPreference("pref_xfenster_swipe_threshold");
|
EditTextPreference editTextPreference6 = (EditTextPreference) XSettingsFragment.this.xFensterPreferenceScreen.findPreference("pref_xfenster_swipe_threshold");
|
||||||
if (editTextPreference6 != null) {
|
if (editTextPreference6 != null) {
|
||||||
@ -232,7 +237,7 @@ public class XSettingsFragment extends PreferenceFragment {
|
|||||||
FensterGestureListener.TOP_PADDING = 20;
|
FensterGestureListener.TOP_PADDING = 20;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else if ("vanced_ryd_enabled".equals(str) && XGlobals.getContext() != null && XSettingsFragment.this.settingsInitialized) {
|
} else if ("vanced_ryd_enabled".equals(str) && Settings.getContext() != null && XSettingsFragment.this.settingsInitialized) {
|
||||||
XReboot.RebootDialog(XSettingsFragment.this.getActivity());
|
XReboot.RebootDialog(XSettingsFragment.this.getActivity());
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
@ -249,26 +254,21 @@ public class XSettingsFragment extends PreferenceFragment {
|
|||||||
super.onCreate(bundle);
|
super.onCreate(bundle);
|
||||||
getPreferenceManager().setSharedPreferencesName("youtube");
|
getPreferenceManager().setSharedPreferencesName("youtube");
|
||||||
try {
|
try {
|
||||||
int identifier = getResources().getIdentifier("xfile_prefs", "xml", XGlobals.getPackageName());
|
int identifier = getResources().getIdentifier("xfile_prefs", "xml", Settings.getPackageName());
|
||||||
if (XGlobals.XFILEDEBUG) {
|
|
||||||
addPreferencesFromResource(2131689473);
|
|
||||||
} else {
|
|
||||||
addPreferencesFromResource(identifier);
|
addPreferencesFromResource(identifier);
|
||||||
}
|
String stringByName = Settings.getStringByName(getActivity(), "quality_auto");
|
||||||
if (!XGlobals.XFILEDEBUG) {
|
|
||||||
String stringByName = XGlobals.getStringByName(getActivity(), "quality_auto");
|
|
||||||
this.videoQualityEntries[0] = stringByName;
|
this.videoQualityEntries[0] = stringByName;
|
||||||
this.minimizedVideoEntries[0] = stringByName;
|
this.minimizedVideoEntries[0] = stringByName;
|
||||||
this.videoSpeedEntries[0] = stringByName;
|
this.videoSpeedEntries[0] = stringByName;
|
||||||
String stringByName2 = XGlobals.getStringByName(getActivity(), "pref_subtitles_scale_normal");
|
String stringByName2 = Settings.getStringByName(getActivity(), "pref_subtitles_scale_normal");
|
||||||
if (stringByName2.equals("")) {
|
if (stringByName2.equals("")) {
|
||||||
this.videoSpeedEntries[4] = "Normal";
|
this.videoSpeedEntries[4] = "Normal";
|
||||||
} else {
|
} else {
|
||||||
this.videoSpeedEntries[4] = stringByName2;
|
this.videoSpeedEntries[4] = stringByName2;
|
||||||
}
|
}
|
||||||
this.minimizedVideoEntries[1] = XGlobals.getStringByName(getActivity(), "xfile_miniplayer_style_video");
|
this.minimizedVideoEntries[1] = Settings.getStringByName(getActivity(), "xfile_miniplayer_style_video");
|
||||||
this.minimizedVideoEntries[2] = XGlobals.getStringByName(getActivity(), "xfile_miniplayer_style_video_controls");
|
this.minimizedVideoEntries[2] = Settings.getStringByName(getActivity(), "xfile_miniplayer_style_video_controls");
|
||||||
}
|
|
||||||
SharedPreferences sharedPreferences = getPreferenceManager().getSharedPreferences();
|
SharedPreferences sharedPreferences = getPreferenceManager().getSharedPreferences();
|
||||||
this.sharedPreferences = sharedPreferences;
|
this.sharedPreferences = sharedPreferences;
|
||||||
this.settingsInitialized = sharedPreferences.getBoolean("xfile_initialized", false);
|
this.settingsInitialized = sharedPreferences.getBoolean("xfile_initialized", false);
|
||||||
@ -302,13 +302,13 @@ public class XSettingsFragment extends PreferenceFragment {
|
|||||||
final ListPreference listPreference2 = (ListPreference) this.videoSettingsPreferenceScreen.findPreference("pref_preferred_video_quality_mobile");
|
final ListPreference listPreference2 = (ListPreference) this.videoSettingsPreferenceScreen.findPreference("pref_preferred_video_quality_mobile");
|
||||||
setListPreferenceData(listPreference, true);
|
setListPreferenceData(listPreference, true);
|
||||||
setListPreferenceData(listPreference2, false);
|
setListPreferenceData(listPreference2, false);
|
||||||
// from class: fi.razerman.youtube.XSettingsFragment.1
|
// from class: app.revanced.integrations.settings.XSettingsFragment.1
|
||||||
// android.preference.Preference.OnPreferenceClickListener
|
// android.preference.Preference.OnPreferenceClickListener
|
||||||
listPreference.setOnPreferenceClickListener(preference -> {
|
listPreference.setOnPreferenceClickListener(preference -> {
|
||||||
XSettingsFragment.this.setListPreferenceData(listPreference, true);
|
XSettingsFragment.this.setListPreferenceData(listPreference, true);
|
||||||
return false;
|
return false;
|
||||||
});
|
});
|
||||||
// from class: fi.razerman.youtube.XSettingsFragment.2
|
// from class: app.revanced.integrations.settings.XSettingsFragment.2
|
||||||
// android.preference.Preference.OnPreferenceClickListener
|
// android.preference.Preference.OnPreferenceClickListener
|
||||||
listPreference2.setOnPreferenceClickListener(preference -> {
|
listPreference2.setOnPreferenceClickListener(preference -> {
|
||||||
XSettingsFragment.this.setListPreferenceData(listPreference2, false);
|
XSettingsFragment.this.setListPreferenceData(listPreference2, false);
|
||||||
@ -316,24 +316,24 @@ public class XSettingsFragment extends PreferenceFragment {
|
|||||||
});
|
});
|
||||||
final ListPreference listPreference3 = (ListPreference) this.videoSettingsPreferenceScreen.findPreference("pref_preferred_video_speed");
|
final ListPreference listPreference3 = (ListPreference) this.videoSettingsPreferenceScreen.findPreference("pref_preferred_video_speed");
|
||||||
setSpeedListPreferenceData(listPreference3);
|
setSpeedListPreferenceData(listPreference3);
|
||||||
// from class: fi.razerman.youtube.XSettingsFragment.3
|
// from class: app.revanced.integrations.settings.XSettingsFragment.3
|
||||||
// android.preference.Preference.OnPreferenceClickListener
|
// android.preference.Preference.OnPreferenceClickListener
|
||||||
listPreference3.setOnPreferenceClickListener(preference -> {
|
listPreference3.setOnPreferenceClickListener(preference -> {
|
||||||
XSettingsFragment.this.setSpeedListPreferenceData(listPreference3);
|
XSettingsFragment.this.setSpeedListPreferenceData(listPreference3);
|
||||||
return false;
|
return false;
|
||||||
});
|
});
|
||||||
Preference findPreference = findPreference("pref_about_field");
|
Preference findPreference = findPreference("pref_about_field");
|
||||||
final String stringByName3 = XGlobals.getStringByName(getActivity(), "xfile_hiddenmenu_open");
|
final String stringByName3 = Settings.getStringByName(getActivity(), "xfile_hiddenmenu_open");
|
||||||
final String stringByName4 = XGlobals.getStringByName(getActivity(), "xfile_hiddenmenu_opened");
|
final String stringByName4 = Settings.getStringByName(getActivity(), "xfile_hiddenmenu_opened");
|
||||||
final String str = " " + XGlobals.getStringByName(getActivity(), "xfile_hiddenmenu_needed");
|
final String str = " " + Settings.getStringByName(getActivity(), "xfile_hiddenmenu_needed");
|
||||||
// from class: fi.razerman.youtube.XSettingsFragment.4
|
// from class: app.revanced.integrations.settings.XSettingsFragment.4
|
||||||
// android.preference.Preference.OnPreferenceClickListener
|
// android.preference.Preference.OnPreferenceClickListener
|
||||||
findPreference.setOnPreferenceClickListener(preference -> {
|
findPreference.setOnPreferenceClickListener(preference -> {
|
||||||
if (XSettingsFragment.this.hiddenMenuOpened) {
|
if (XSettingsFragment.this.hiddenMenuOpened) {
|
||||||
if (XSettingsFragment.this.toast != null) {
|
if (XSettingsFragment.this.toast != null) {
|
||||||
XSettingsFragment.this.toast.cancel();
|
XSettingsFragment.this.toast.cancel();
|
||||||
}
|
}
|
||||||
XSettingsFragment.this.toast = Toast.makeText(XGlobals.getContext(), stringByName3, Toast.LENGTH_SHORT);
|
XSettingsFragment.this.toast = Toast.makeText(Settings.getContext(), stringByName3, Toast.LENGTH_SHORT);
|
||||||
XSettingsFragment.this.toast.show();
|
XSettingsFragment.this.toast.show();
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -346,13 +346,13 @@ public class XSettingsFragment extends PreferenceFragment {
|
|||||||
XSettingsFragment.this.toast.cancel();
|
XSettingsFragment.this.toast.cancel();
|
||||||
}
|
}
|
||||||
if (i <= 0) {
|
if (i <= 0) {
|
||||||
XSettingsFragment.this.toast = Toast.makeText(XGlobals.getContext(), stringByName4, Toast.LENGTH_SHORT);
|
XSettingsFragment.this.toast = Toast.makeText(Settings.getContext(), stringByName4, Toast.LENGTH_SHORT);
|
||||||
XSettingsFragment.this.hiddenMenuOpened = true;
|
XSettingsFragment.this.hiddenMenuOpened = true;
|
||||||
XSettingsFragment.this.sharedPreferences.edit().putBoolean("xfile_hiddenMenu_enabled", true).apply();
|
XSettingsFragment.this.sharedPreferences.edit().putBoolean("xfile_hiddenMenu_enabled", true).apply();
|
||||||
XSettingsFragment.this.CheckHiddenMenuStatus();
|
XSettingsFragment.this.CheckHiddenMenuStatus();
|
||||||
} else {
|
} else {
|
||||||
XSettingsFragment xSettingsFragment = XSettingsFragment.this;
|
XSettingsFragment xSettingsFragment = XSettingsFragment.this;
|
||||||
Context context = XGlobals.getContext();
|
Context context = Settings.getContext();
|
||||||
xSettingsFragment.toast = Toast.makeText(context, i + str, Toast.LENGTH_SHORT);
|
xSettingsFragment.toast = Toast.makeText(context, i + str, Toast.LENGTH_SHORT);
|
||||||
}
|
}
|
||||||
XSettingsFragment.this.toast.show();
|
XSettingsFragment.this.toast.show();
|
||||||
@ -361,31 +361,31 @@ public class XSettingsFragment extends PreferenceFragment {
|
|||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
});
|
});
|
||||||
// from class: fi.razerman.youtube.XSettingsFragment.5
|
// from class: app.revanced.integrations.settings.XSettingsFragment.5
|
||||||
// android.preference.Preference.OnPreferenceClickListener
|
// android.preference.Preference.OnPreferenceClickListener
|
||||||
this.codecDefault.setOnPreferenceClickListener(preference -> {
|
this.codecDefault.setOnPreferenceClickListener(preference -> {
|
||||||
XSettingsFragment.this.ChangeCodec(preference);
|
XSettingsFragment.this.ChangeCodec(preference);
|
||||||
return false;
|
return false;
|
||||||
});
|
});
|
||||||
// from class: fi.razerman.youtube.XSettingsFragment.6
|
// from class: app.revanced.integrations.settings.XSettingsFragment.6
|
||||||
// android.preference.Preference.OnPreferenceClickListener
|
// android.preference.Preference.OnPreferenceClickListener
|
||||||
this.codecVP9.setOnPreferenceClickListener(preference -> {
|
this.codecVP9.setOnPreferenceClickListener(preference -> {
|
||||||
XSettingsFragment.this.ChangeCodec(preference);
|
XSettingsFragment.this.ChangeCodec(preference);
|
||||||
return false;
|
return false;
|
||||||
});
|
});
|
||||||
// from class: fi.razerman.youtube.XSettingsFragment.7
|
// from class: app.revanced.integrations.settings.XSettingsFragment.7
|
||||||
// android.preference.Preference.OnPreferenceClickListener
|
// android.preference.Preference.OnPreferenceClickListener
|
||||||
this.codecHDRH.setOnPreferenceClickListener(preference -> {
|
this.codecHDRH.setOnPreferenceClickListener(preference -> {
|
||||||
XSettingsFragment.this.ChangeCodec(preference);
|
XSettingsFragment.this.ChangeCodec(preference);
|
||||||
return false;
|
return false;
|
||||||
});
|
});
|
||||||
// from class: fi.razerman.youtube.XSettingsFragment.8
|
// from class: app.revanced.integrations.settings.XSettingsFragment.8
|
||||||
// android.preference.Preference.OnPreferenceClickListener
|
// android.preference.Preference.OnPreferenceClickListener
|
||||||
this.codecHDRS.setOnPreferenceClickListener(preference -> {
|
this.codecHDRS.setOnPreferenceClickListener(preference -> {
|
||||||
XSettingsFragment.this.ChangeCodec(preference);
|
XSettingsFragment.this.ChangeCodec(preference);
|
||||||
return false;
|
return false;
|
||||||
});
|
});
|
||||||
if (XScreenSizeHelpers.isTablet(YouTubeTikTokRoot_Application.getAppContext())) {
|
if (ScreenSizeHelper.isTablet(YouTubeTikTokRoot_Application.getAppContext())) {
|
||||||
if (this.layoutSettingsPreferenceScreen.findPreference("tablet_miniplayer") != null) {
|
if (this.layoutSettingsPreferenceScreen.findPreference("tablet_miniplayer") != null) {
|
||||||
this.layoutSettingsPreferenceScreen.removePreference(this.tabletMiniplayer);
|
this.layoutSettingsPreferenceScreen.removePreference(this.tabletMiniplayer);
|
||||||
}
|
}
|
||||||
@ -396,7 +396,7 @@ public class XSettingsFragment extends PreferenceFragment {
|
|||||||
this.sharedPreferences.edit().putBoolean("xfile_initialized", true);
|
this.sharedPreferences.edit().putBoolean("xfile_initialized", true);
|
||||||
this.settingsInitialized = true;
|
this.settingsInitialized = true;
|
||||||
} catch (Throwable th) {
|
} catch (Throwable th) {
|
||||||
Log.e("XSettingsFragment", "Unable to retrieve resourceId for xfile_prefs", th);
|
LogHelper.printException("XSettingsFragment", "Unable to retrieve resourceId for xfile_prefs", th);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -477,7 +477,7 @@ public class XSettingsFragment extends PreferenceFragment {
|
|||||||
}
|
}
|
||||||
if (this.codecPreferenceScreen.findPreference("pref_default_override") == null) {
|
if (this.codecPreferenceScreen.findPreference("pref_default_override") == null) {
|
||||||
this.codecPreferenceScreen.addPreference(this.codecDefault);
|
this.codecPreferenceScreen.addPreference(this.codecDefault);
|
||||||
// from class: fi.razerman.youtube.XSettingsFragment.10
|
// from class: app.revanced.integrations.settings.XSettingsFragment.10
|
||||||
// android.preference.Preference.OnPreferenceClickListener
|
// android.preference.Preference.OnPreferenceClickListener
|
||||||
this.codecDefault.setOnPreferenceClickListener(preference -> {
|
this.codecDefault.setOnPreferenceClickListener(preference -> {
|
||||||
XSettingsFragment.this.ChangeCodec(preference);
|
XSettingsFragment.this.ChangeCodec(preference);
|
||||||
@ -486,7 +486,7 @@ public class XSettingsFragment extends PreferenceFragment {
|
|||||||
}
|
}
|
||||||
if (this.codecPreferenceScreen.findPreference("pref_vp9_override") == null) {
|
if (this.codecPreferenceScreen.findPreference("pref_vp9_override") == null) {
|
||||||
this.codecPreferenceScreen.addPreference(this.codecVP9);
|
this.codecPreferenceScreen.addPreference(this.codecVP9);
|
||||||
// from class: fi.razerman.youtube.XSettingsFragment.11
|
// from class: app.revanced.integrations.settings.XSettingsFragment.11
|
||||||
// android.preference.Preference.OnPreferenceClickListener
|
// android.preference.Preference.OnPreferenceClickListener
|
||||||
this.codecVP9.setOnPreferenceClickListener(preference -> {
|
this.codecVP9.setOnPreferenceClickListener(preference -> {
|
||||||
XSettingsFragment.this.ChangeCodec(preference);
|
XSettingsFragment.this.ChangeCodec(preference);
|
||||||
@ -495,7 +495,7 @@ public class XSettingsFragment extends PreferenceFragment {
|
|||||||
}
|
}
|
||||||
if (this.codecPreferenceScreen.findPreference("pref_hdrhardware_override") == null) {
|
if (this.codecPreferenceScreen.findPreference("pref_hdrhardware_override") == null) {
|
||||||
this.codecPreferenceScreen.addPreference(this.codecHDRH);
|
this.codecPreferenceScreen.addPreference(this.codecHDRH);
|
||||||
// from class: fi.razerman.youtube.XSettingsFragment.12
|
// from class: app.revanced.integrations.settings.XSettingsFragment.12
|
||||||
// android.preference.Preference.OnPreferenceClickListener
|
// android.preference.Preference.OnPreferenceClickListener
|
||||||
this.codecHDRH.setOnPreferenceClickListener(preference -> {
|
this.codecHDRH.setOnPreferenceClickListener(preference -> {
|
||||||
XSettingsFragment.this.ChangeCodec(preference);
|
XSettingsFragment.this.ChangeCodec(preference);
|
||||||
@ -504,7 +504,7 @@ public class XSettingsFragment extends PreferenceFragment {
|
|||||||
}
|
}
|
||||||
if (this.codecPreferenceScreen.findPreference("pref_hdrsoftware_override") == null) {
|
if (this.codecPreferenceScreen.findPreference("pref_hdrsoftware_override") == null) {
|
||||||
this.codecPreferenceScreen.addPreference(this.codecHDRS);
|
this.codecPreferenceScreen.addPreference(this.codecHDRS);
|
||||||
// from class: fi.razerman.youtube.XSettingsFragment.13
|
// from class: app.revanced.integrations.settings.XSettingsFragment.13
|
||||||
// android.preference.Preference.OnPreferenceClickListener
|
// android.preference.Preference.OnPreferenceClickListener
|
||||||
this.codecHDRS.setOnPreferenceClickListener(preference -> {
|
this.codecHDRS.setOnPreferenceClickListener(preference -> {
|
||||||
XSettingsFragment.this.ChangeCodec(preference);
|
XSettingsFragment.this.ChangeCodec(preference);
|
@ -1,27 +1,27 @@
|
|||||||
package pl.jakubweg;
|
package app.revanced.integrations.sponsorblock;
|
||||||
|
|
||||||
|
|
||||||
import android.util.Log;
|
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.view.ViewGroup;
|
import android.view.ViewGroup;
|
||||||
|
|
||||||
import java.lang.reflect.Field;
|
import java.lang.reflect.Field;
|
||||||
|
|
||||||
|
import app.revanced.integrations.utils.LogHelper;
|
||||||
|
|
||||||
// invoke-static {p0}, Lpl/jakubweg/InjectedPlugin;->inject(Landroid/content/Context;)V
|
// invoke-static {p0}, Lpl/jakubweg/InjectedPlugin;->inject(Landroid/content/Context;)V
|
||||||
// invoke-static {}, Lpl/jakubweg/InjectedPlugin;->printSomething()V
|
// invoke-static {}, Lpl/jakubweg/InjectedPlugin;->printSomething()V
|
||||||
// InlineTimeBar
|
// InlineTimeBar
|
||||||
public class InjectedPlugin {
|
public class InjectedPlugin {
|
||||||
|
|
||||||
private static final String TAG = "jakubweg.InjectedPlugin";
|
|
||||||
|
|
||||||
public static void printSomething() {
|
public static void printSomething() {
|
||||||
Log.d(TAG, "printSomething called");
|
LogHelper.debug("InjectedPlugin", "printSomething called");
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void printObject(Object o, int recursive) {
|
public static void printObject(Object o, int recursive) {
|
||||||
if (o == null)
|
if (o == null)
|
||||||
Log.d(TAG, "Printed object is null");
|
LogHelper.debug("InjectedPlugin", "Printed object is null");
|
||||||
else {
|
else {
|
||||||
Log.d(TAG, "Printed object ("
|
LogHelper.debug("InjectedPlugin", "Printed object ("
|
||||||
+ o.getClass().getName()
|
+ o.getClass().getName()
|
||||||
+ ") = " + o.toString());
|
+ ") = " + o.toString());
|
||||||
for (Field field : o.getClass().getDeclaredFields()) {
|
for (Field field : o.getClass().getDeclaredFields()) {
|
||||||
@ -32,9 +32,9 @@ public class InjectedPlugin {
|
|||||||
Object value = field.get(o);
|
Object value = field.get(o);
|
||||||
try {
|
try {
|
||||||
// if ("java.lang.String".equals(field.getType().getName()))
|
// if ("java.lang.String".equals(field.getType().getName()))
|
||||||
Log.d(TAG, "Field: " + field.toString() + " has value " + value);
|
LogHelper.debug("InjectedPlugin", "Field: " + field.toString() + " has value " + value);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
Log.d(TAG, "Field: " + field.toString() + " has value that thrown an exception in toString method");
|
LogHelper.debug("InjectedPlugin", "Field: " + field.toString() + " has value that thrown an exception in toString method");
|
||||||
}
|
}
|
||||||
if (recursive > 0 && value != null && !value.getClass().isPrimitive())
|
if (recursive > 0 && value != null && !value.getClass().isPrimitive())
|
||||||
printObject(value, recursive - 1);
|
printObject(value, recursive - 1);
|
||||||
@ -63,9 +63,9 @@ public class InjectedPlugin {
|
|||||||
|
|
||||||
public static void printStackTrace() {
|
public static void printStackTrace() {
|
||||||
StackTraceElement[] stackTrace = (new Throwable()).getStackTrace();
|
StackTraceElement[] stackTrace = (new Throwable()).getStackTrace();
|
||||||
Log.d(TAG, "Printing stack trace:");
|
LogHelper.debug("InjectedPlugin", "Printing stack trace:");
|
||||||
for (StackTraceElement element : stackTrace) {
|
for (StackTraceElement element : stackTrace) {
|
||||||
Log.d(TAG, element.toString());
|
LogHelper.debug("InjectedPlugin", element.toString());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -77,19 +77,19 @@ public class InjectedPlugin {
|
|||||||
String spacesStr = builder.toString();
|
String spacesStr = builder.toString();
|
||||||
|
|
||||||
if (view == null) {
|
if (view == null) {
|
||||||
Log.i(TAG, spacesStr + "Null view");
|
LogHelper.debug("InjectedPlugin", spacesStr + "Null view");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (view instanceof ViewGroup) {
|
if (view instanceof ViewGroup) {
|
||||||
ViewGroup group = (ViewGroup) view;
|
ViewGroup group = (ViewGroup) view;
|
||||||
Log.i(TAG, spacesStr + "View group: " + view);
|
LogHelper.debug("InjectedPlugin", spacesStr + "View group: " + view);
|
||||||
int childCount = group.getChildCount();
|
int childCount = group.getChildCount();
|
||||||
Log.i(TAG, spacesStr + "Children count: " + childCount);
|
LogHelper.debug("InjectedPlugin", spacesStr + "Children count: " + childCount);
|
||||||
for (int i = 0; i < childCount; i++) {
|
for (int i = 0; i < childCount; i++) {
|
||||||
printViewStack(group.getChildAt(i), spaces + 1);
|
printViewStack(group.getChildAt(i), spaces + 1);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
Log.i(TAG, spacesStr + "Normal view: " + view);
|
LogHelper.debug("InjectedPlugin", spacesStr + "Normal view: " + view);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -1,9 +1,9 @@
|
|||||||
package pl.jakubweg;
|
package app.revanced.integrations.sponsorblock;
|
||||||
|
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
|
|
||||||
import static fi.vanced.libraries.youtube.sponsors.player.ui.SponsorBlockView.hideNewSegmentLayout;
|
import static app.revanced.integrations.sponsorblock.player.ui.SponsorBlockView.hideNewSegmentLayout;
|
||||||
import static fi.vanced.libraries.youtube.sponsors.player.ui.SponsorBlockView.showNewSegmentLayout;
|
import static app.revanced.integrations.sponsorblock.player.ui.SponsorBlockView.showNewSegmentLayout;
|
||||||
|
|
||||||
public class NewSegmentHelperLayout {
|
public class NewSegmentHelperLayout {
|
||||||
public static Context context;
|
public static Context context;
|
@ -1,19 +1,18 @@
|
|||||||
package pl.jakubweg;
|
package app.revanced.integrations.sponsorblock;
|
||||||
|
|
||||||
import static pl.jakubweg.SponsorBlockSettings.skippedSegments;
|
import static app.revanced.integrations.sponsorblock.SponsorBlockSettings.skippedSegments;
|
||||||
import static pl.jakubweg.SponsorBlockSettings.skippedTime;
|
import static app.revanced.integrations.sponsorblock.SponsorBlockSettings.skippedTime;
|
||||||
import static pl.jakubweg.SponsorBlockUtils.timeWithoutSegments;
|
import static app.revanced.integrations.sponsorblock.SponsorBlockUtils.timeWithoutSegments;
|
||||||
import static pl.jakubweg.SponsorBlockUtils.videoHasSegments;
|
import static app.revanced.integrations.sponsorblock.SponsorBlockUtils.videoHasSegments;
|
||||||
|
|
||||||
import android.annotation.SuppressLint;
|
import android.annotation.SuppressLint;
|
||||||
import android.app.Activity;
|
import android.app.Activity;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.content.SharedPreferences;
|
|
||||||
import android.graphics.Canvas;
|
import android.graphics.Canvas;
|
||||||
import android.graphics.Rect;
|
import android.graphics.Rect;
|
||||||
import android.os.Handler;
|
import android.os.Handler;
|
||||||
import android.os.Looper;
|
import android.os.Looper;
|
||||||
import android.util.Log;
|
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.view.ViewGroup;
|
import android.view.ViewGroup;
|
||||||
|
|
||||||
@ -26,14 +25,15 @@ import java.util.Arrays;
|
|||||||
import java.util.Timer;
|
import java.util.Timer;
|
||||||
import java.util.TimerTask;
|
import java.util.TimerTask;
|
||||||
|
|
||||||
import fi.vanced.libraries.youtube.player.VideoInformation;
|
import app.revanced.integrations.utils.LogHelper;
|
||||||
import fi.vanced.libraries.youtube.whitelisting.Whitelist;
|
import app.revanced.integrations.sponsorblock.player.VideoInformation;
|
||||||
import pl.jakubweg.objects.SponsorSegment;
|
import app.revanced.integrations.adremover.whitelist.Whitelist;
|
||||||
import pl.jakubweg.requests.SBRequester;
|
import app.revanced.integrations.sponsorblock.objects.SponsorSegment;
|
||||||
|
import app.revanced.integrations.sponsorblock.requests.SBRequester;
|
||||||
|
import app.revanced.integrations.utils.SharedPrefHelper;
|
||||||
|
|
||||||
@SuppressLint({"LongLogTag"})
|
@SuppressLint({"LongLogTag"})
|
||||||
public class PlayerController {
|
public class PlayerController {
|
||||||
public static final String TAG = "jakubweg.PlayerController";
|
|
||||||
public static final boolean VERBOSE = false;
|
public static final boolean VERBOSE = false;
|
||||||
@SuppressWarnings("PointlessBooleanExpression")
|
@SuppressWarnings("PointlessBooleanExpression")
|
||||||
public static final boolean VERBOSE_DRAW_OPTIONS = false && VERBOSE;
|
public static final boolean VERBOSE_DRAW_OPTIONS = false && VERBOSE;
|
||||||
@ -48,7 +48,6 @@ public class PlayerController {
|
|||||||
private static long currentVideoLength = 1L;
|
private static long currentVideoLength = 1L;
|
||||||
private static long lastKnownVideoTime = -1L;
|
private static long lastKnownVideoTime = -1L;
|
||||||
private static final Runnable findAndSkipSegmentRunnable = () -> {
|
private static final Runnable findAndSkipSegmentRunnable = () -> {
|
||||||
// Log.d(TAG, "findAndSkipSegmentRunnable");
|
|
||||||
findAndSkipSegment(false);
|
findAndSkipSegment(false);
|
||||||
};
|
};
|
||||||
private static float sponsorBarLeft = 1f;
|
private static float sponsorBarLeft = 1f;
|
||||||
@ -68,8 +67,8 @@ public class PlayerController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
Context context = YouTubeTikTokRoot_Application.getAppContext();
|
Context context = YouTubeTikTokRoot_Application.getAppContext();
|
||||||
if(context == null){
|
if (context == null) {
|
||||||
Log.e(TAG, "context is null");
|
LogHelper.printException("PlayerController", "context is null");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
SponsorBlockSettings.update(context);
|
SponsorBlockSettings.update(context);
|
||||||
@ -85,7 +84,7 @@ public class PlayerController {
|
|||||||
currentVideoId = videoId;
|
currentVideoId = videoId;
|
||||||
sponsorSegmentsOfCurrentVideo = null;
|
sponsorSegmentsOfCurrentVideo = null;
|
||||||
if (VERBOSE)
|
if (VERBOSE)
|
||||||
Log.d(TAG, "setCurrentVideoId: videoId=" + videoId);
|
LogHelper.debug("PlayerController", "setCurrentVideoId: videoId=" + videoId);
|
||||||
|
|
||||||
sponsorTimer.schedule(new TimerTask() {
|
sponsorTimer.schedule(new TimerTask() {
|
||||||
@Override
|
@Override
|
||||||
@ -102,12 +101,12 @@ public class PlayerController {
|
|||||||
// "Plugin.printStackTrace();
|
// "Plugin.printStackTrace();
|
||||||
|
|
||||||
if (o == null) {
|
if (o == null) {
|
||||||
Log.e(TAG, "onCreate called with null object");
|
LogHelper.printException("PlayerController", "onCreate called with null object");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (VERBOSE)
|
if (VERBOSE)
|
||||||
Log.i(TAG, String.format("onCreate called with object %s on thread %s", o.toString(), Thread.currentThread().toString()));
|
LogHelper.debug("PlayerController", String.format("onCreate called with object %s on thread %s", o.toString(), Thread.currentThread().toString()));
|
||||||
|
|
||||||
try {
|
try {
|
||||||
setMillisecondMethod = o.getClass().getMethod("replaceMeWithsetMillisecondMethod", Long.TYPE);
|
setMillisecondMethod = o.getClass().getMethod("replaceMeWithsetMillisecondMethod", Long.TYPE);
|
||||||
@ -121,7 +120,7 @@ public class PlayerController {
|
|||||||
SkipSegmentView.hide();
|
SkipSegmentView.hide();
|
||||||
NewSegmentHelperLayout.hide();
|
NewSegmentHelperLayout.hide();
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
Log.e(TAG, "Exception while initializing skip method", e);
|
LogHelper.printException("PlayerController", "Exception while initializing skip method", e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -135,7 +134,7 @@ public class PlayerController {
|
|||||||
|
|
||||||
if (VERBOSE)
|
if (VERBOSE)
|
||||||
for (SponsorSegment segment : segments) {
|
for (SponsorSegment segment : segments) {
|
||||||
Log.v(TAG, "Detected segment: " + segment.toString());
|
LogHelper.debug("PlayerController", "Detected segment: " + segment.toString());
|
||||||
}
|
}
|
||||||
|
|
||||||
sponsorSegmentsOfCurrentVideo = segments;
|
sponsorSegmentsOfCurrentVideo = segments;
|
||||||
@ -152,7 +151,7 @@ public class PlayerController {
|
|||||||
|
|
||||||
// if (currentVideoLink != null) {
|
// if (currentVideoLink != null) {
|
||||||
// if (VERBOSE)
|
// if (VERBOSE)
|
||||||
// Log.w(TAG, "asyncGetVideoLinkFromObject: currentVideoLink != null probably share button was clicked");
|
// Log.w("PlayerController", "asyncGetVideoLinkFromObject: currentVideoLink != null probably share button was clicked");
|
||||||
// return;
|
// return;
|
||||||
// }
|
// }
|
||||||
//
|
//
|
||||||
@ -169,7 +168,7 @@ public class PlayerController {
|
|||||||
// Object objLink = b.get(o);
|
// Object objLink = b.get(o);
|
||||||
// if (objLink == null) {
|
// if (objLink == null) {
|
||||||
// if (VERBOSE)
|
// if (VERBOSE)
|
||||||
// Log.e(TAG, "asyncGetVideoLinkFromObject: objLink is null");
|
// LogHelper.printException("PlayerController", "asyncGetVideoLinkFromObject: objLink is null");
|
||||||
// } else {
|
// } else {
|
||||||
// videoUrl = objLink.toString();
|
// videoUrl = objLink.toString();
|
||||||
// if (videoUrl.isEmpty())
|
// if (videoUrl.isEmpty())
|
||||||
@ -180,7 +179,7 @@ public class PlayerController {
|
|||||||
// break;
|
// break;
|
||||||
//
|
//
|
||||||
// if (attempts++ > 5) {
|
// if (attempts++ > 5) {
|
||||||
// Log.w(TAG, "asyncGetVideoLinkFromObject: attempts++ > 5");
|
// Log.w("PlayerController", "asyncGetVideoLinkFromObject: attempts++ > 5");
|
||||||
// return;
|
// return;
|
||||||
// }
|
// }
|
||||||
// Thread.sleep(50);
|
// Thread.sleep(50);
|
||||||
@ -189,13 +188,13 @@ public class PlayerController {
|
|||||||
// if (currentVideoLink == null) {
|
// if (currentVideoLink == null) {
|
||||||
// currentVideoLink = videoUrl;
|
// currentVideoLink = videoUrl;
|
||||||
// if (VERBOSE)
|
// if (VERBOSE)
|
||||||
// Log.d(TAG, "asyncGetVideoLinkFromObject: link set to " + videoUrl);
|
// LogH("PlayerController", "asyncGetVideoLinkFromObject: link set to " + videoUrl);
|
||||||
//
|
//
|
||||||
// executeDownloadSegments(substringVideoIdFromLink(videoUrl), false);
|
// executeDownloadSegments(substringVideoIdFromLink(videoUrl), false);
|
||||||
// }
|
// }
|
||||||
//
|
//
|
||||||
// } catch (Exception e) {
|
// } catch (Exception e) {
|
||||||
// Log.e(TAG, "Cannot get link from object", e);
|
// LogHelper.printException("PlayerController", "Cannot get link from object", e);
|
||||||
// }
|
// }
|
||||||
// }
|
// }
|
||||||
// }).start();
|
// }).start();
|
||||||
@ -210,7 +209,7 @@ public class PlayerController {
|
|||||||
*/
|
*/
|
||||||
public static void setCurrentVideoTime(long millis) {
|
public static void setCurrentVideoTime(long millis) {
|
||||||
if (VERBOSE)
|
if (VERBOSE)
|
||||||
Log.v(TAG, "setCurrentVideoTime: current video time: " + millis);
|
LogHelper.debug("PlayerController", "setCurrentVideoTime: current video time: " + millis);
|
||||||
VideoInformation.lastKnownVideoTime = millis;
|
VideoInformation.lastKnownVideoTime = millis;
|
||||||
if (!SponsorBlockSettings.isSponsorBlockEnabled) return;
|
if (!SponsorBlockSettings.isSponsorBlockEnabled) return;
|
||||||
lastKnownVideoTime = millis;
|
lastKnownVideoTime = millis;
|
||||||
@ -238,7 +237,7 @@ public class PlayerController {
|
|||||||
|
|
||||||
if (skipSponsorTask == null) {
|
if (skipSponsorTask == null) {
|
||||||
if (VERBOSE)
|
if (VERBOSE)
|
||||||
Log.d(TAG, "Scheduling skipSponsorTask");
|
LogHelper.debug("PlayerController", "Scheduling skipSponsorTask");
|
||||||
skipSponsorTask = new TimerTask() {
|
skipSponsorTask = new TimerTask() {
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
@ -251,7 +250,7 @@ public class PlayerController {
|
|||||||
sponsorTimer.schedule(skipSponsorTask, segment.start - millis);
|
sponsorTimer.schedule(skipSponsorTask, segment.start - millis);
|
||||||
} else {
|
} else {
|
||||||
if (VERBOSE)
|
if (VERBOSE)
|
||||||
Log.d(TAG, "skipSponsorTask is already scheduled...");
|
LogHelper.debug("PlayerController", "skipSponsorTask is already scheduled...");
|
||||||
}
|
}
|
||||||
|
|
||||||
break;
|
break;
|
||||||
@ -277,10 +276,9 @@ public class PlayerController {
|
|||||||
if (segment.category != SponsorBlockSettings.SegmentInfo.UNSUBMITTED) {
|
if (segment.category != SponsorBlockSettings.SegmentInfo.UNSUBMITTED) {
|
||||||
Context context = YouTubeTikTokRoot_Application.getAppContext();
|
Context context = YouTubeTikTokRoot_Application.getAppContext();
|
||||||
if (context != null) {
|
if (context != null) {
|
||||||
SharedPreferences preferences = SponsorBlockSettings.getPreferences(context);
|
|
||||||
long newSkippedTime = skippedTime + (segment.end - segment.start);
|
long newSkippedTime = skippedTime + (segment.end - segment.start);
|
||||||
preferences.edit().putInt(SponsorBlockSettings.PREFERENCES_KEY_SKIPPED_SEGMENTS, skippedSegments + 1).apply();
|
SharedPrefHelper.saveInt(context, SharedPrefHelper.SharedPrefNames.SPONSOR_BLOCK, SponsorBlockSettings.PREFERENCES_KEY_SKIPPED_SEGMENTS, skippedSegments + 1);
|
||||||
preferences.edit().putLong(SponsorBlockSettings.PREFERENCES_KEY_SKIPPED_SEGMENTS_TIME, newSkippedTime).apply();
|
SharedPrefHelper.saveLong(context, SharedPrefHelper.SharedPrefNames.SPONSOR_BLOCK, SponsorBlockSettings.PREFERENCES_KEY_SKIPPED_SEGMENTS_TIME, newSkippedTime);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
new Thread(() -> {
|
new Thread(() -> {
|
||||||
@ -304,8 +302,7 @@ public class PlayerController {
|
|||||||
if (lastKnownVideoTime > 0) {
|
if (lastKnownVideoTime > 0) {
|
||||||
lastKnownVideoTime = millis;
|
lastKnownVideoTime = millis;
|
||||||
VideoInformation.lastKnownVideoTime = lastKnownVideoTime;
|
VideoInformation.lastKnownVideoTime = lastKnownVideoTime;
|
||||||
}
|
} else
|
||||||
else
|
|
||||||
setCurrentVideoTime(millis);
|
setCurrentVideoTime(millis);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -322,7 +319,7 @@ public class PlayerController {
|
|||||||
*/
|
*/
|
||||||
public static void setVideoLength(final long length) {
|
public static void setVideoLength(final long length) {
|
||||||
if (VERBOSE_DRAW_OPTIONS)
|
if (VERBOSE_DRAW_OPTIONS)
|
||||||
Log.d(TAG, "setVideoLength: length=" + length);
|
LogHelper.debug("PlayerController", "setVideoLength: length=" + length);
|
||||||
currentVideoLength = length;
|
currentVideoLength = length;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -333,7 +330,7 @@ public class PlayerController {
|
|||||||
|
|
||||||
public static void setSponsorBarAbsoluteLeft(final float left) {
|
public static void setSponsorBarAbsoluteLeft(final float left) {
|
||||||
if (VERBOSE_DRAW_OPTIONS)
|
if (VERBOSE_DRAW_OPTIONS)
|
||||||
Log.d(TAG, String.format("setSponsorBarLeft: left=%.2f", left));
|
LogHelper.debug("PlayerController", String.format("setSponsorBarLeft: left=%.2f", left));
|
||||||
|
|
||||||
sponsorBarLeft = left;
|
sponsorBarLeft = left;
|
||||||
}
|
}
|
||||||
@ -358,7 +355,7 @@ public class PlayerController {
|
|||||||
|
|
||||||
public static void setSponsorBarAbsoluteRight(final float right) {
|
public static void setSponsorBarAbsoluteRight(final float right) {
|
||||||
if (VERBOSE_DRAW_OPTIONS)
|
if (VERBOSE_DRAW_OPTIONS)
|
||||||
Log.d(TAG, String.format("setSponsorBarRight: right=%.2f", right));
|
LogHelper.debug("PlayerController", String.format("setSponsorBarRight: right=%.2f", right));
|
||||||
|
|
||||||
sponsorBarRight = right;
|
sponsorBarRight = right;
|
||||||
}
|
}
|
||||||
@ -369,14 +366,14 @@ public class PlayerController {
|
|||||||
|
|
||||||
public static void setSponsorBarThickness(final float thickness) {
|
public static void setSponsorBarThickness(final float thickness) {
|
||||||
// if (VERBOSE_DRAW_OPTIONS)
|
// if (VERBOSE_DRAW_OPTIONS)
|
||||||
// Log.d(TAG, String.format("setSponsorBarThickness: thickness=%.2f", thickness));
|
// LogH("PlayerController", String.format("setSponsorBarThickness: thickness=%.2f", thickness));
|
||||||
|
|
||||||
sponsorBarThickness = thickness;
|
sponsorBarThickness = thickness;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void onSkipSponsorClicked() {
|
public static void onSkipSponsorClicked() {
|
||||||
if (VERBOSE)
|
if (VERBOSE)
|
||||||
Log.d(TAG, "Skip segment clicked");
|
LogHelper.debug("PlayerController", "Skip segment clicked");
|
||||||
findAndSkipSegment(true);
|
findAndSkipSegment(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -384,7 +381,7 @@ public class PlayerController {
|
|||||||
public static void addSkipSponsorView15(final View view) {
|
public static void addSkipSponsorView15(final View view) {
|
||||||
playerActivity = new WeakReference<>((Activity) view.getContext());
|
playerActivity = new WeakReference<>((Activity) view.getContext());
|
||||||
if (VERBOSE)
|
if (VERBOSE)
|
||||||
Log.d(TAG, "addSkipSponsorView15: view=" + view.toString());
|
LogHelper.debug("PlayerController", "addSkipSponsorView15: view=" + view.toString());
|
||||||
|
|
||||||
new Handler(Looper.getMainLooper()).postDelayed(() -> {
|
new Handler(Looper.getMainLooper()).postDelayed(() -> {
|
||||||
final ViewGroup viewGroup = (ViewGroup) ((ViewGroup) view).getChildAt(2);
|
final ViewGroup viewGroup = (ViewGroup) ((ViewGroup) view).getChildAt(2);
|
||||||
@ -396,7 +393,7 @@ public class PlayerController {
|
|||||||
public static void addSkipSponsorView14(final View view) {
|
public static void addSkipSponsorView14(final View view) {
|
||||||
playerActivity = new WeakReference<>((Activity) view.getContext());
|
playerActivity = new WeakReference<>((Activity) view.getContext());
|
||||||
if (VERBOSE)
|
if (VERBOSE)
|
||||||
Log.d(TAG, "addSkipSponsorView14: view=" + view.toString());
|
LogHelper.debug("PlayerController", "addSkipSponsorView14: view=" + view.toString());
|
||||||
new Handler(Looper.getMainLooper()).postDelayed(() -> {
|
new Handler(Looper.getMainLooper()).postDelayed(() -> {
|
||||||
final ViewGroup viewGroup = (ViewGroup) view.getParent();
|
final ViewGroup viewGroup = (ViewGroup) view.getParent();
|
||||||
Activity activity = (Activity) viewGroup.getContext();
|
Activity activity = (Activity) viewGroup.getContext();
|
||||||
@ -442,37 +439,37 @@ public class PlayerController {
|
|||||||
long now = System.currentTimeMillis();
|
long now = System.currentTimeMillis();
|
||||||
if (now < allowNextSkipRequestTime) {
|
if (now < allowNextSkipRequestTime) {
|
||||||
if (VERBOSE)
|
if (VERBOSE)
|
||||||
Log.w(TAG, "skipToMillisecond: to fast, slow down, because you'll fail");
|
LogHelper.debug("PlayerController", "skipToMillisecond: to fast, slow down, because you'll fail");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
allowNextSkipRequestTime = now + 100;
|
allowNextSkipRequestTime = now + 100;
|
||||||
|
|
||||||
if (setMillisecondMethod == null) {
|
if (setMillisecondMethod == null) {
|
||||||
Log.e(TAG, "setMillisecondMethod is null");
|
LogHelper.printException("PlayerController", "setMillisecondMethod is null");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
final Object currentObj = currentPlayerController.get();
|
final Object currentObj = currentPlayerController.get();
|
||||||
if (currentObj == null) {
|
if (currentObj == null) {
|
||||||
Log.e(TAG, "currentObj is null (might have been collected by GC)");
|
LogHelper.printException("PlayerController", "currentObj is null (might have been collected by GC)");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
if (VERBOSE)
|
if (VERBOSE)
|
||||||
Log.d(TAG, String.format("Requesting skip to millis=%d on thread %s", millisecond, Thread.currentThread().toString()));
|
LogHelper.debug("PlayerController", String.format("Requesting skip to millis=%d on thread %s", millisecond, Thread.currentThread().toString()));
|
||||||
|
|
||||||
final long finalMillisecond = millisecond;
|
final long finalMillisecond = millisecond;
|
||||||
new Handler(Looper.getMainLooper()).post(() -> {
|
new Handler(Looper.getMainLooper()).post(() -> {
|
||||||
try {
|
try {
|
||||||
if (VERBOSE)
|
if (VERBOSE)
|
||||||
Log.i(TAG, "Skipping to millis=" + finalMillisecond);
|
LogHelper.debug("PlayerController", "Skipping to millis=" + finalMillisecond);
|
||||||
lastKnownVideoTime = finalMillisecond;
|
lastKnownVideoTime = finalMillisecond;
|
||||||
VideoInformation.lastKnownVideoTime = lastKnownVideoTime;
|
VideoInformation.lastKnownVideoTime = lastKnownVideoTime;
|
||||||
setMillisecondMethod.invoke(currentObj, finalMillisecond);
|
setMillisecondMethod.invoke(currentObj, finalMillisecond);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
Log.e(TAG, "Cannot skip to millisecond", e);
|
LogHelper.printException("PlayerController", "Cannot skip to millisecond", e);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@ -507,7 +504,7 @@ public class PlayerController {
|
|||||||
// if (lastSkippedSegment == segment) return;
|
// if (lastSkippedSegment == segment) return;
|
||||||
// lastSkippedSegment = segment;
|
// lastSkippedSegment = segment;
|
||||||
if (VERBOSE)
|
if (VERBOSE)
|
||||||
Log.d(TAG, "Skipping segment: " + segment.toString());
|
LogHelper.debug("PlayerController", "Skipping segment: " + segment.toString());
|
||||||
|
|
||||||
if (SponsorBlockSettings.showToastWhenSkippedAutomatically && !wasClicked)
|
if (SponsorBlockSettings.showToastWhenSkippedAutomatically && !wasClicked)
|
||||||
SkipSegmentView.notifySkipped(segment);
|
SkipSegmentView.notifySkipped(segment);
|
@ -1,7 +1,7 @@
|
|||||||
package pl.jakubweg;
|
package app.revanced.integrations.sponsorblock;
|
||||||
|
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.util.Log;
|
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.view.animation.Animation;
|
import android.view.animation.Animation;
|
||||||
import android.view.animation.AnimationUtils;
|
import android.view.animation.AnimationUtils;
|
||||||
@ -12,12 +12,12 @@ import com.google.android.apps.youtube.app.YouTubeTikTokRoot_Application;
|
|||||||
|
|
||||||
import java.lang.ref.WeakReference;
|
import java.lang.ref.WeakReference;
|
||||||
|
|
||||||
import static fi.razerman.youtube.XGlobals.debug;
|
import static app.revanced.integrations.sponsorblock.PlayerController.getCurrentVideoLength;
|
||||||
import static pl.jakubweg.PlayerController.getCurrentVideoLength;
|
import static app.revanced.integrations.sponsorblock.PlayerController.getLastKnownVideoTime;
|
||||||
import static pl.jakubweg.PlayerController.getLastKnownVideoTime;
|
|
||||||
|
import app.revanced.integrations.utils.LogHelper;
|
||||||
|
|
||||||
public class ShieldButton {
|
public class ShieldButton {
|
||||||
static String TAG = "SHIELD";
|
|
||||||
static RelativeLayout _youtubeControlsLayout;
|
static RelativeLayout _youtubeControlsLayout;
|
||||||
static WeakReference<ImageView> _shieldBtn = new WeakReference<>(null);
|
static WeakReference<ImageView> _shieldBtn = new WeakReference<>(null);
|
||||||
static int fadeDurationFast;
|
static int fadeDurationFast;
|
||||||
@ -28,17 +28,15 @@ public class ShieldButton {
|
|||||||
|
|
||||||
public static void initialize(Object viewStub) {
|
public static void initialize(Object viewStub) {
|
||||||
try {
|
try {
|
||||||
if(debug){
|
LogHelper.debug("ShieldButton", "initializing shield button");
|
||||||
Log.d(TAG, "initializing shield button");
|
|
||||||
}
|
|
||||||
|
|
||||||
_youtubeControlsLayout = (RelativeLayout) viewStub;
|
_youtubeControlsLayout = (RelativeLayout) viewStub;
|
||||||
|
|
||||||
ImageView imageView = (ImageView)_youtubeControlsLayout
|
ImageView imageView = (ImageView) _youtubeControlsLayout
|
||||||
.findViewById(getIdentifier("sponsorblock_button", "id"));
|
.findViewById(getIdentifier("sponsorblock_button", "id"));
|
||||||
|
|
||||||
if (debug && imageView == null){
|
if (imageView == null) {
|
||||||
Log.d(TAG, "Couldn't find imageView with tag \"sponsorblock_button\"");
|
LogHelper.debug("ShieldButton", "Couldn't find imageView with \"sponsorblock_button\"");
|
||||||
}
|
}
|
||||||
if (imageView == null) return;
|
if (imageView == null) return;
|
||||||
imageView.setOnClickListener(SponsorBlockUtils.sponsorBlockBtnListener);
|
imageView.setOnClickListener(SponsorBlockUtils.sponsorBlockBtnListener);
|
||||||
@ -53,9 +51,8 @@ public class ShieldButton {
|
|||||||
fadeOut.setDuration(fadeDurationScheduled);
|
fadeOut.setDuration(fadeDurationScheduled);
|
||||||
isShowing = true;
|
isShowing = true;
|
||||||
changeVisibilityImmediate(false);
|
changeVisibilityImmediate(false);
|
||||||
}
|
} catch (Exception ex) {
|
||||||
catch (Exception ex) {
|
LogHelper.printException("ShieldButton", "Unable to set RelativeLayout", ex);
|
||||||
Log.e(TAG, "Unable to set RelativeLayout", ex);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -82,9 +79,8 @@ public class ShieldButton {
|
|||||||
if (getLastKnownVideoTime() >= getCurrentVideoLength()) {
|
if (getLastKnownVideoTime() >= getCurrentVideoLength()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (debug) {
|
LogHelper.debug("ShieldButton", "Fading in");
|
||||||
Log.d(TAG, "Fading in");
|
|
||||||
}
|
|
||||||
iView.setVisibility(View.VISIBLE);
|
iView.setVisibility(View.VISIBLE);
|
||||||
if (!immediate)
|
if (!immediate)
|
||||||
iView.startAnimation(fadeIn);
|
iView.startAnimation(fadeIn);
|
||||||
@ -92,9 +88,7 @@ public class ShieldButton {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (iView.getVisibility() == View.VISIBLE) {
|
if (iView.getVisibility() == View.VISIBLE) {
|
||||||
if (debug) {
|
LogHelper.debug("ShieldButton", "Fading out");
|
||||||
Log.d(TAG, "Fading out");
|
|
||||||
}
|
|
||||||
if (!immediate)
|
if (!immediate)
|
||||||
iView.startAnimation(fadeOut);
|
iView.startAnimation(fadeOut);
|
||||||
iView.setVisibility(shouldBeShown() ? View.INVISIBLE : View.GONE);
|
iView.setVisibility(shouldBeShown() ? View.INVISIBLE : View.GONE);
|
@ -1,22 +1,23 @@
|
|||||||
package pl.jakubweg;
|
package app.revanced.integrations.sponsorblock;
|
||||||
|
|
||||||
import android.annotation.SuppressLint;
|
import android.annotation.SuppressLint;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.util.DisplayMetrics;
|
import android.util.DisplayMetrics;
|
||||||
import android.util.Log;
|
|
||||||
import android.widget.Toast;
|
import android.widget.Toast;
|
||||||
|
|
||||||
import com.google.android.apps.youtube.app.YouTubeTikTokRoot_Application;
|
import com.google.android.apps.youtube.app.YouTubeTikTokRoot_Application;
|
||||||
|
|
||||||
import pl.jakubweg.objects.SponsorSegment;
|
import app.revanced.integrations.utils.LogHelper;
|
||||||
|
import app.revanced.integrations.sponsorblock.objects.SponsorSegment;
|
||||||
|
|
||||||
import static fi.vanced.libraries.youtube.sponsors.player.ui.SponsorBlockView.hideSkipButton;
|
import static app.revanced.integrations.sponsorblock.player.ui.SponsorBlockView.hideSkipButton;
|
||||||
import static fi.vanced.libraries.youtube.sponsors.player.ui.SponsorBlockView.showSkipButton;
|
import static app.revanced.integrations.sponsorblock.player.ui.SponsorBlockView.showSkipButton;
|
||||||
import static pl.jakubweg.PlayerController.VERBOSE;
|
import static app.revanced.integrations.sponsorblock.PlayerController.VERBOSE;
|
||||||
|
|
||||||
@SuppressLint({"RtlHardcoded", "SetTextI18n", "LongLogTag", "AppCompatCustomView"})
|
@SuppressLint({"RtlHardcoded", "SetTextI18n", "LongLogTag", "AppCompatCustomView"})
|
||||||
public class SkipSegmentView {
|
public class SkipSegmentView {
|
||||||
public static final String TAG = "jakubweg.SkipSegmentView";
|
|
||||||
private static SponsorSegment lastNotifiedSegment;
|
private static SponsorSegment lastNotifiedSegment;
|
||||||
|
|
||||||
public static void show() {
|
public static void show() {
|
||||||
@ -30,14 +31,14 @@ public class SkipSegmentView {
|
|||||||
public static void notifySkipped(SponsorSegment segment) {
|
public static void notifySkipped(SponsorSegment segment) {
|
||||||
if (segment == lastNotifiedSegment) {
|
if (segment == lastNotifiedSegment) {
|
||||||
if (VERBOSE)
|
if (VERBOSE)
|
||||||
Log.d(TAG, "notifySkipped; segment == lastNotifiedSegment");
|
LogHelper.debug("SkipSegmentView", "notifySkipped; segment == lastNotifiedSegment");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
lastNotifiedSegment = segment;
|
lastNotifiedSegment = segment;
|
||||||
String skipMessage = segment.category.skipMessage.toString();
|
String skipMessage = segment.category.skipMessage.toString();
|
||||||
Context context = YouTubeTikTokRoot_Application.getAppContext();
|
Context context = YouTubeTikTokRoot_Application.getAppContext();
|
||||||
if (VERBOSE)
|
if (VERBOSE)
|
||||||
Log.d(TAG, String.format("notifySkipped; message=%s", skipMessage));
|
LogHelper.debug("SkipSegmentView", String.format("notifySkipped; message=%s", skipMessage));
|
||||||
|
|
||||||
if (context != null)
|
if (context != null)
|
||||||
Toast.makeText(context, skipMessage, Toast.LENGTH_SHORT).show();
|
Toast.makeText(context, skipMessage, Toast.LENGTH_SHORT).show();
|
@ -1,28 +1,26 @@
|
|||||||
package pl.jakubweg;
|
package app.revanced.integrations.sponsorblock;
|
||||||
|
|
||||||
import static fi.razerman.youtube.XGlobals.debug;
|
import static app.revanced.integrations.sponsorblock.SponsorBlockSettings.DEFAULT_API_URL;
|
||||||
import static pl.jakubweg.SponsorBlockSettings.DEFAULT_API_URL;
|
import static app.revanced.integrations.sponsorblock.SponsorBlockSettings.PREFERENCES_KEY_ADJUST_NEW_SEGMENT_STEP;
|
||||||
import static pl.jakubweg.SponsorBlockSettings.PREFERENCES_KEY_ADJUST_NEW_SEGMENT_STEP;
|
import static app.revanced.integrations.sponsorblock.SponsorBlockSettings.PREFERENCES_KEY_API_URL;
|
||||||
import static pl.jakubweg.SponsorBlockSettings.PREFERENCES_KEY_API_URL;
|
import static app.revanced.integrations.sponsorblock.SponsorBlockSettings.PREFERENCES_KEY_BROWSER_BUTTON;
|
||||||
import static pl.jakubweg.SponsorBlockSettings.PREFERENCES_KEY_BROWSER_BUTTON;
|
import static app.revanced.integrations.sponsorblock.SponsorBlockSettings.PREFERENCES_KEY_COUNT_SKIPS;
|
||||||
import static pl.jakubweg.SponsorBlockSettings.PREFERENCES_KEY_COUNT_SKIPS;
|
import static app.revanced.integrations.sponsorblock.SponsorBlockSettings.PREFERENCES_KEY_MIN_DURATION;
|
||||||
import static pl.jakubweg.SponsorBlockSettings.PREFERENCES_KEY_MIN_DURATION;
|
import static app.revanced.integrations.sponsorblock.SponsorBlockSettings.PREFERENCES_KEY_NEW_SEGMENT_ENABLED;
|
||||||
import static pl.jakubweg.SponsorBlockSettings.PREFERENCES_KEY_NEW_SEGMENT_ENABLED;
|
import static app.revanced.integrations.sponsorblock.SponsorBlockSettings.PREFERENCES_KEY_SHOW_TIME_WITHOUT_SEGMENTS;
|
||||||
import static pl.jakubweg.SponsorBlockSettings.PREFERENCES_KEY_SHOW_TIME_WITHOUT_SEGMENTS;
|
import static app.revanced.integrations.sponsorblock.SponsorBlockSettings.PREFERENCES_KEY_SHOW_TOAST_WHEN_SKIP;
|
||||||
import static pl.jakubweg.SponsorBlockSettings.PREFERENCES_KEY_SHOW_TOAST_WHEN_SKIP;
|
import static app.revanced.integrations.sponsorblock.SponsorBlockSettings.PREFERENCES_KEY_SPONSOR_BLOCK_ENABLED;
|
||||||
import static pl.jakubweg.SponsorBlockSettings.PREFERENCES_KEY_SPONSOR_BLOCK_ENABLED;
|
import static app.revanced.integrations.sponsorblock.SponsorBlockSettings.PREFERENCES_KEY_SPONSOR_BLOCK_HINT_SHOWN;
|
||||||
import static pl.jakubweg.SponsorBlockSettings.PREFERENCES_KEY_SPONSOR_BLOCK_HINT_SHOWN;
|
import static app.revanced.integrations.sponsorblock.SponsorBlockSettings.PREFERENCES_KEY_UUID;
|
||||||
import static pl.jakubweg.SponsorBlockSettings.PREFERENCES_KEY_UUID;
|
import static app.revanced.integrations.sponsorblock.SponsorBlockSettings.PREFERENCES_KEY_VOTING_ENABLED;
|
||||||
import static pl.jakubweg.SponsorBlockSettings.PREFERENCES_KEY_VOTING_ENABLED;
|
import static app.revanced.integrations.sponsorblock.SponsorBlockSettings.adjustNewSegmentMillis;
|
||||||
import static pl.jakubweg.SponsorBlockSettings.PREFERENCES_NAME;
|
import static app.revanced.integrations.sponsorblock.SponsorBlockSettings.countSkips;
|
||||||
import static pl.jakubweg.SponsorBlockSettings.adjustNewSegmentMillis;
|
import static app.revanced.integrations.sponsorblock.SponsorBlockSettings.minDuration;
|
||||||
import static pl.jakubweg.SponsorBlockSettings.countSkips;
|
import static app.revanced.integrations.sponsorblock.SponsorBlockSettings.setSeenGuidelines;
|
||||||
import static pl.jakubweg.SponsorBlockSettings.minDuration;
|
import static app.revanced.integrations.sponsorblock.SponsorBlockSettings.showTimeWithoutSegments;
|
||||||
import static pl.jakubweg.SponsorBlockSettings.setSeenGuidelines;
|
import static app.revanced.integrations.sponsorblock.SponsorBlockSettings.showToastWhenSkippedAutomatically;
|
||||||
import static pl.jakubweg.SponsorBlockSettings.showTimeWithoutSegments;
|
import static app.revanced.integrations.sponsorblock.SponsorBlockSettings.uuid;
|
||||||
import static pl.jakubweg.SponsorBlockSettings.showToastWhenSkippedAutomatically;
|
import static app.revanced.integrations.sponsorblock.StringRef.str;
|
||||||
import static pl.jakubweg.SponsorBlockSettings.uuid;
|
|
||||||
import static pl.jakubweg.StringRef.str;
|
|
||||||
|
|
||||||
import android.app.Activity;
|
import android.app.Activity;
|
||||||
import android.app.AlertDialog;
|
import android.app.AlertDialog;
|
||||||
@ -49,10 +47,12 @@ import java.lang.ref.WeakReference;
|
|||||||
import java.text.DecimalFormat;
|
import java.text.DecimalFormat;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
|
||||||
import fi.vanced.libraries.youtube.whitelisting.WhitelistType;
|
import app.revanced.integrations.adremover.whitelist.WhitelistType;
|
||||||
import fi.vanced.utils.SharedPrefUtils;
|
import app.revanced.integrations.settings.Settings;
|
||||||
import pl.jakubweg.objects.EditTextListPreference;
|
import app.revanced.integrations.settings.SettingsEnum;
|
||||||
import pl.jakubweg.requests.SBRequester;
|
import app.revanced.integrations.utils.SharedPrefHelper;
|
||||||
|
import app.revanced.integrations.sponsorblock.objects.EditTextListPreference;
|
||||||
|
import app.revanced.integrations.sponsorblock.requests.SBRequester;
|
||||||
|
|
||||||
@SuppressWarnings({"unused", "deprecation"}) // injected
|
@SuppressWarnings({"unused", "deprecation"}) // injected
|
||||||
public class SponsorBlockPreferenceFragment extends PreferenceFragment implements SharedPreferences.OnSharedPreferenceChangeListener {
|
public class SponsorBlockPreferenceFragment extends PreferenceFragment implements SharedPreferences.OnSharedPreferenceChangeListener {
|
||||||
@ -64,7 +64,7 @@ public class SponsorBlockPreferenceFragment extends PreferenceFragment implement
|
|||||||
@Override
|
@Override
|
||||||
public void onCreate(Bundle savedInstanceState) {
|
public void onCreate(Bundle savedInstanceState) {
|
||||||
super.onCreate(savedInstanceState);
|
super.onCreate(savedInstanceState);
|
||||||
getPreferenceManager().setSharedPreferencesName(PREFERENCES_NAME);
|
getPreferenceManager().setSharedPreferencesName(SharedPrefHelper.SharedPrefNames.SPONSOR_BLOCK.getName());
|
||||||
|
|
||||||
getPreferenceManager().getSharedPreferences().registerOnSharedPreferenceChangeListener(this);
|
getPreferenceManager().getSharedPreferences().registerOnSharedPreferenceChangeListener(this);
|
||||||
|
|
||||||
@ -91,12 +91,12 @@ public class SponsorBlockPreferenceFragment extends PreferenceFragment implement
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Clear hint
|
// Clear hint
|
||||||
if (debug) {
|
if (SettingsEnum.DEBUG_BOOLEAN.getBoolean()) {
|
||||||
SwitchPreference preference = new SwitchPreference(context);
|
SwitchPreference preference = new SwitchPreference(context);
|
||||||
preferenceScreen.addPreference(preference);
|
preferenceScreen.addPreference(preference);
|
||||||
preference.setKey(PREFERENCES_KEY_SPONSOR_BLOCK_HINT_SHOWN);
|
preference.setKey(PREFERENCES_KEY_SPONSOR_BLOCK_HINT_SHOWN);
|
||||||
preference.setDefaultValue(false);
|
preference.setDefaultValue(false);
|
||||||
preference.setChecked(SharedPrefUtils.getBoolean(context, PREFERENCES_NAME, PREFERENCES_KEY_SPONSOR_BLOCK_HINT_SHOWN));
|
preference.setChecked(SharedPrefHelper.getBoolean(context, SharedPrefHelper.SharedPrefNames.SPONSOR_BLOCK, PREFERENCES_KEY_SPONSOR_BLOCK_HINT_SHOWN));
|
||||||
preference.setTitle("Hint debug");
|
preference.setTitle("Hint debug");
|
||||||
preference.setSummary("Debug toggle for clearing the hint shown preference");
|
preference.setSummary("Debug toggle for clearing the hint shown preference");
|
||||||
preference.setOnPreferenceChangeListener((pref, newValue) -> true);
|
preference.setOnPreferenceChangeListener((pref, newValue) -> true);
|
||||||
@ -393,7 +393,7 @@ public class SponsorBlockPreferenceFragment extends PreferenceFragment implement
|
|||||||
return;
|
return;
|
||||||
Context context = ((AlertDialog) dialog).getContext();
|
Context context = ((AlertDialog) dialog).getContext();
|
||||||
Context applicationContext = context.getApplicationContext();
|
Context applicationContext = context.getApplicationContext();
|
||||||
SharedPreferences preferences = SponsorBlockSettings.getPreferences(context);
|
SharedPreferences preferences = SharedPrefHelper.getPreferences(context, SharedPrefHelper.SharedPrefNames.SPONSOR_BLOCK);
|
||||||
|
|
||||||
switch (which) {
|
switch (which) {
|
||||||
case DialogInterface.BUTTON_NEUTRAL:
|
case DialogInterface.BUTTON_NEUTRAL:
|
||||||
@ -405,13 +405,11 @@ public class SponsorBlockPreferenceFragment extends PreferenceFragment implement
|
|||||||
Toast invalidToast = Toast.makeText(applicationContext, str("api_url_invalid"), Toast.LENGTH_SHORT);
|
Toast invalidToast = Toast.makeText(applicationContext, str("api_url_invalid"), Toast.LENGTH_SHORT);
|
||||||
if (text == null) {
|
if (text == null) {
|
||||||
invalidToast.show();
|
invalidToast.show();
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
String textAsString = text.toString();
|
String textAsString = text.toString();
|
||||||
if (textAsString.isEmpty() || !Patterns.WEB_URL.matcher(textAsString).matches()) {
|
if (textAsString.isEmpty() || !Patterns.WEB_URL.matcher(textAsString).matches()) {
|
||||||
invalidToast.show();
|
invalidToast.show();
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
preferences.edit().putString(PREFERENCES_KEY_API_URL, textAsString).apply();
|
preferences.edit().putString(PREFERENCES_KEY_API_URL, textAsString).apply();
|
||||||
Toast.makeText(applicationContext, str("api_url_changed"), Toast.LENGTH_SHORT).show();
|
Toast.makeText(applicationContext, str("api_url_changed"), Toast.LENGTH_SHORT).show();
|
||||||
}
|
}
|
@ -1,6 +1,6 @@
|
|||||||
package pl.jakubweg;
|
package app.revanced.integrations.sponsorblock;
|
||||||
|
|
||||||
import static pl.jakubweg.StringRef.sf;
|
import static app.revanced.integrations.sponsorblock.StringRef.sf;
|
||||||
|
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.content.SharedPreferences;
|
import android.content.SharedPreferences;
|
||||||
@ -8,16 +8,18 @@ import android.graphics.Color;
|
|||||||
import android.graphics.Paint;
|
import android.graphics.Paint;
|
||||||
import android.text.Html;
|
import android.text.Html;
|
||||||
import android.text.TextUtils;
|
import android.text.TextUtils;
|
||||||
import android.util.Log;
|
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
|
||||||
|
import app.revanced.integrations.utils.LogHelper;
|
||||||
|
import app.revanced.integrations.utils.SharedPrefHelper;
|
||||||
|
|
||||||
public class SponsorBlockSettings {
|
public class SponsorBlockSettings {
|
||||||
|
|
||||||
public static final String PREFERENCES_NAME = "sponsor-block";
|
|
||||||
public static final String PREFERENCES_KEY_SHOW_TOAST_WHEN_SKIP = "show-toast";
|
public static final String PREFERENCES_KEY_SHOW_TOAST_WHEN_SKIP = "show-toast";
|
||||||
public static final String PREFERENCES_KEY_COUNT_SKIPS = "count-skips";
|
public static final String PREFERENCES_KEY_COUNT_SKIPS = "count-skips";
|
||||||
public static final String PREFERENCES_KEY_UUID = "uuid";
|
public static final String PREFERENCES_KEY_UUID = "uuid";
|
||||||
@ -61,22 +63,19 @@ public class SponsorBlockSettings {
|
|||||||
@SuppressWarnings("unused")
|
@SuppressWarnings("unused")
|
||||||
@Deprecated
|
@Deprecated
|
||||||
public SponsorBlockSettings(Context ignored) {
|
public SponsorBlockSettings(Context ignored) {
|
||||||
Log.e("jakubweg.Settings", "Do not call SponsorBlockSettings constructor!");
|
LogHelper.printException("revanced.Settings", "Do not call SponsorBlockSettings constructor!");
|
||||||
}
|
|
||||||
|
|
||||||
public static SharedPreferences getPreferences(Context context) {
|
|
||||||
return context.getSharedPreferences(PREFERENCES_NAME, Context.MODE_PRIVATE);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void setSeenGuidelines(Context context) {
|
public static void setSeenGuidelines(Context context) {
|
||||||
SponsorBlockSettings.seenGuidelinesPopup = true;
|
SponsorBlockSettings.seenGuidelinesPopup = true;
|
||||||
getPreferences(context).edit().putBoolean(PREFERENCES_KEY_SEEN_GUIDELINES, true).apply();
|
SharedPrefHelper.getPreferences(context, SharedPrefHelper.SharedPrefNames.SPONSOR_BLOCK).edit().putBoolean(PREFERENCES_KEY_SEEN_GUIDELINES, true).apply();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void update(Context context) {
|
public static void update(Context context) {
|
||||||
if (context == null) return;
|
if (context == null) return;
|
||||||
|
|
||||||
SharedPreferences preferences = getPreferences(context);
|
SharedPreferences preferences = SharedPrefHelper.getPreferences(context, SharedPrefHelper.SharedPrefNames.SPONSOR_BLOCK);
|
||||||
|
|
||||||
isSponsorBlockEnabled = preferences.getBoolean(PREFERENCES_KEY_SPONSOR_BLOCK_ENABLED, isSponsorBlockEnabled);
|
isSponsorBlockEnabled = preferences.getBoolean(PREFERENCES_KEY_SPONSOR_BLOCK_ENABLED, isSponsorBlockEnabled);
|
||||||
seenGuidelinesPopup = preferences.getBoolean(PREFERENCES_KEY_SEEN_GUIDELINES, seenGuidelinesPopup);
|
seenGuidelinesPopup = preferences.getBoolean(PREFERENCES_KEY_SEEN_GUIDELINES, seenGuidelinesPopup);
|
||||||
|
|
||||||
@ -122,8 +121,7 @@ public class SponsorBlockSettings {
|
|||||||
}
|
}
|
||||||
if (behaviour != null) {
|
if (behaviour != null) {
|
||||||
segment.behaviour = behaviour;
|
segment.behaviour = behaviour;
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
behaviour = segment.behaviour;
|
behaviour = segment.behaviour;
|
||||||
}
|
}
|
||||||
|
|
@ -1,41 +1,38 @@
|
|||||||
package pl.jakubweg;
|
package app.revanced.integrations.sponsorblock;
|
||||||
|
|
||||||
import static android.text.Html.fromHtml;
|
import static android.text.Html.fromHtml;
|
||||||
import static android.view.View.GONE;
|
import static android.view.View.GONE;
|
||||||
import static android.view.View.VISIBLE;
|
import static android.view.View.VISIBLE;
|
||||||
import static fi.razerman.youtube.XGlobals.debug;
|
import static app.revanced.integrations.sponsorblock.PlayerController.getCurrentVideoId;
|
||||||
import static pl.jakubweg.PlayerController.getCurrentVideoId;
|
import static app.revanced.integrations.sponsorblock.PlayerController.getCurrentVideoLength;
|
||||||
import static pl.jakubweg.PlayerController.getCurrentVideoLength;
|
import static app.revanced.integrations.sponsorblock.PlayerController.getLastKnownVideoTime;
|
||||||
import static pl.jakubweg.PlayerController.getLastKnownVideoTime;
|
import static app.revanced.integrations.sponsorblock.PlayerController.sponsorSegmentsOfCurrentVideo;
|
||||||
import static pl.jakubweg.PlayerController.sponsorSegmentsOfCurrentVideo;
|
import static app.revanced.integrations.sponsorblock.SponsorBlockPreferenceFragment.FORMATTER;
|
||||||
import static pl.jakubweg.SponsorBlockPreferenceFragment.FORMATTER;
|
import static app.revanced.integrations.sponsorblock.SponsorBlockPreferenceFragment.SAVED_TEMPLATE;
|
||||||
import static pl.jakubweg.SponsorBlockPreferenceFragment.SAVED_TEMPLATE;
|
import static app.revanced.integrations.sponsorblock.SponsorBlockSettings.DEFAULT_API_URL;
|
||||||
import static pl.jakubweg.SponsorBlockSettings.DEFAULT_API_URL;
|
import static app.revanced.integrations.sponsorblock.SponsorBlockSettings.DEFAULT_SERVER_URL;
|
||||||
import static pl.jakubweg.SponsorBlockSettings.DEFAULT_SERVER_URL;
|
import static app.revanced.integrations.sponsorblock.SponsorBlockSettings.PREFERENCES_KEY_API_URL;
|
||||||
import static pl.jakubweg.SponsorBlockSettings.PREFERENCES_KEY_API_URL;
|
import static app.revanced.integrations.sponsorblock.SponsorBlockSettings.PREFERENCES_KEY_CATEGORY_COLOR_SUFFIX;
|
||||||
import static pl.jakubweg.SponsorBlockSettings.PREFERENCES_KEY_CATEGORY_COLOR_SUFFIX;
|
import static app.revanced.integrations.sponsorblock.SponsorBlockSettings.PREFERENCES_KEY_COUNT_SKIPS;
|
||||||
import static pl.jakubweg.SponsorBlockSettings.PREFERENCES_KEY_COUNT_SKIPS;
|
import static app.revanced.integrations.sponsorblock.SponsorBlockSettings.PREFERENCES_KEY_IS_VIP;
|
||||||
import static pl.jakubweg.SponsorBlockSettings.PREFERENCES_KEY_IS_VIP;
|
import static app.revanced.integrations.sponsorblock.SponsorBlockSettings.PREFERENCES_KEY_LAST_VIP_CHECK;
|
||||||
import static pl.jakubweg.SponsorBlockSettings.PREFERENCES_KEY_LAST_VIP_CHECK;
|
import static app.revanced.integrations.sponsorblock.SponsorBlockSettings.PREFERENCES_KEY_MIN_DURATION;
|
||||||
import static pl.jakubweg.SponsorBlockSettings.PREFERENCES_KEY_MIN_DURATION;
|
import static app.revanced.integrations.sponsorblock.SponsorBlockSettings.PREFERENCES_KEY_SHOW_TIME_WITHOUT_SEGMENTS;
|
||||||
import static pl.jakubweg.SponsorBlockSettings.PREFERENCES_KEY_SHOW_TIME_WITHOUT_SEGMENTS;
|
import static app.revanced.integrations.sponsorblock.SponsorBlockSettings.PREFERENCES_KEY_SHOW_TOAST_WHEN_SKIP;
|
||||||
import static pl.jakubweg.SponsorBlockSettings.PREFERENCES_KEY_SHOW_TOAST_WHEN_SKIP;
|
import static app.revanced.integrations.sponsorblock.SponsorBlockSettings.PREFERENCES_KEY_UUID;
|
||||||
import static pl.jakubweg.SponsorBlockSettings.PREFERENCES_KEY_UUID;
|
import static app.revanced.integrations.sponsorblock.SponsorBlockSettings.apiUrl;
|
||||||
import static pl.jakubweg.SponsorBlockSettings.PREFERENCES_NAME;
|
import static app.revanced.integrations.sponsorblock.SponsorBlockSettings.countSkips;
|
||||||
import static pl.jakubweg.SponsorBlockSettings.apiUrl;
|
import static app.revanced.integrations.sponsorblock.SponsorBlockSettings.isSponsorBlockEnabled;
|
||||||
import static pl.jakubweg.SponsorBlockSettings.countSkips;
|
import static app.revanced.integrations.sponsorblock.SponsorBlockSettings.lastVipCheck;
|
||||||
import static pl.jakubweg.SponsorBlockSettings.getPreferences;
|
import static app.revanced.integrations.sponsorblock.SponsorBlockSettings.minDuration;
|
||||||
import static pl.jakubweg.SponsorBlockSettings.isSponsorBlockEnabled;
|
import static app.revanced.integrations.sponsorblock.SponsorBlockSettings.showTimeWithoutSegments;
|
||||||
import static pl.jakubweg.SponsorBlockSettings.lastVipCheck;
|
import static app.revanced.integrations.sponsorblock.SponsorBlockSettings.showToastWhenSkippedAutomatically;
|
||||||
import static pl.jakubweg.SponsorBlockSettings.minDuration;
|
import static app.revanced.integrations.sponsorblock.SponsorBlockSettings.skippedSegments;
|
||||||
import static pl.jakubweg.SponsorBlockSettings.showTimeWithoutSegments;
|
import static app.revanced.integrations.sponsorblock.SponsorBlockSettings.skippedTime;
|
||||||
import static pl.jakubweg.SponsorBlockSettings.showToastWhenSkippedAutomatically;
|
import static app.revanced.integrations.sponsorblock.SponsorBlockSettings.uuid;
|
||||||
import static pl.jakubweg.SponsorBlockSettings.skippedSegments;
|
import static app.revanced.integrations.sponsorblock.SponsorBlockSettings.vip;
|
||||||
import static pl.jakubweg.SponsorBlockSettings.skippedTime;
|
import static app.revanced.integrations.sponsorblock.StringRef.str;
|
||||||
import static pl.jakubweg.SponsorBlockSettings.uuid;
|
import static app.revanced.integrations.sponsorblock.requests.SBRequester.voteForSegment;
|
||||||
import static pl.jakubweg.SponsorBlockSettings.vip;
|
|
||||||
import static pl.jakubweg.StringRef.str;
|
|
||||||
import static pl.jakubweg.requests.SBRequester.voteForSegment;
|
|
||||||
|
|
||||||
import android.annotation.SuppressLint;
|
import android.annotation.SuppressLint;
|
||||||
import android.app.AlertDialog;
|
import android.app.AlertDialog;
|
||||||
@ -49,7 +46,7 @@ import android.preference.Preference;
|
|||||||
import android.preference.PreferenceCategory;
|
import android.preference.PreferenceCategory;
|
||||||
import android.text.Html;
|
import android.text.Html;
|
||||||
import android.text.TextUtils;
|
import android.text.TextUtils;
|
||||||
import android.util.Log;
|
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.widget.EditText;
|
import android.widget.EditText;
|
||||||
import android.widget.ImageView;
|
import android.widget.ImageView;
|
||||||
@ -68,14 +65,16 @@ import java.util.List;
|
|||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
import java.util.TimeZone;
|
import java.util.TimeZone;
|
||||||
|
|
||||||
import fi.vanced.utils.SharedPrefUtils;
|
import app.revanced.integrations.sponsorblock.player.PlayerType;
|
||||||
import pl.jakubweg.objects.SponsorSegment;
|
import app.revanced.integrations.utils.LogHelper;
|
||||||
import pl.jakubweg.objects.UserStats;
|
import app.revanced.integrations.utils.SharedPrefHelper;
|
||||||
import pl.jakubweg.requests.SBRequester;
|
import app.revanced.integrations.sponsorblock.objects.SponsorSegment;
|
||||||
|
import app.revanced.integrations.sponsorblock.objects.UserStats;
|
||||||
|
import app.revanced.integrations.sponsorblock.requests.SBRequester;
|
||||||
|
|
||||||
@SuppressWarnings({"LongLogTag"})
|
@SuppressWarnings({"LongLogTag"})
|
||||||
public abstract class SponsorBlockUtils {
|
public abstract class SponsorBlockUtils {
|
||||||
public static final String TAG = "jakubweg.SponsorBlockUtils";
|
public static final String TAG = "revanced.SponsorBlockUtils";
|
||||||
public static final String DATE_FORMAT = "HH:mm:ss.SSS";
|
public static final String DATE_FORMAT = "HH:mm:ss.SSS";
|
||||||
@SuppressLint("SimpleDateFormat")
|
@SuppressLint("SimpleDateFormat")
|
||||||
public static final SimpleDateFormat dateFormatter = new SimpleDateFormat(DATE_FORMAT);
|
public static final SimpleDateFormat dateFormatter = new SimpleDateFormat(DATE_FORMAT);
|
||||||
@ -84,15 +83,11 @@ public abstract class SponsorBlockUtils {
|
|||||||
private static final int sponsorBtnId = 1234;
|
private static final int sponsorBtnId = 1234;
|
||||||
private static final String LOCKED_COLOR = "#FFC83D";
|
private static final String LOCKED_COLOR = "#FFC83D";
|
||||||
public static final View.OnClickListener sponsorBlockBtnListener = v -> {
|
public static final View.OnClickListener sponsorBlockBtnListener = v -> {
|
||||||
if (debug) {
|
LogHelper.debug(TAG, "Shield button clicked");
|
||||||
Log.d(TAG, "Shield button clicked");
|
|
||||||
}
|
|
||||||
NewSegmentHelperLayout.toggle();
|
NewSegmentHelperLayout.toggle();
|
||||||
};
|
};
|
||||||
public static final View.OnClickListener voteButtonListener = v -> {
|
public static final View.OnClickListener voteButtonListener = v -> {
|
||||||
if (debug) {
|
LogHelper.debug(TAG, "Vote button clicked");
|
||||||
Log.d(TAG, "Vote button clicked");
|
|
||||||
}
|
|
||||||
SponsorBlockUtils.onVotingClicked(v.getContext());
|
SponsorBlockUtils.onVotingClicked(v.getContext());
|
||||||
};
|
};
|
||||||
private static int shareBtnId = -1;
|
private static int shareBtnId = -1;
|
||||||
@ -230,8 +225,7 @@ public abstract class SponsorBlockUtils {
|
|||||||
String title = voteOption.title;
|
String title = voteOption.title;
|
||||||
if (vip && segment.isLocked && voteOption.shouldHighlight) {
|
if (vip && segment.isLocked && voteOption.shouldHighlight) {
|
||||||
items[i] = Html.fromHtml(String.format("<font color=\"%s\">%s</font>", LOCKED_COLOR, title));
|
items[i] = Html.fromHtml(String.format("<font color=\"%s\">%s</font>", LOCKED_COLOR, title));
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
items[i] = title;
|
items[i] = title;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -261,13 +255,13 @@ public abstract class SponsorBlockUtils {
|
|||||||
final SponsorBlockSettings.SegmentInfo segmentType = SponsorBlockUtils.newSponsorBlockSegmentType;
|
final SponsorBlockSettings.SegmentInfo segmentType = SponsorBlockUtils.newSponsorBlockSegmentType;
|
||||||
try {
|
try {
|
||||||
if (start < 0 || end < 0 || start >= end || segmentType == null || videoId == null || uuid == null) {
|
if (start < 0 || end < 0 || start >= end || segmentType == null || videoId == null || uuid == null) {
|
||||||
Log.e(TAG, "Unable to submit times, invalid parameters");
|
LogHelper.printException(TAG, "Unable to submit times, invalid parameters");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
SBRequester.submitSegments(videoId, uuid, ((float) start) / 1000f, ((float) end) / 1000f, segmentType.key, toastRunnable);
|
SBRequester.submitSegments(videoId, uuid, ((float) start) / 1000f, ((float) end) / 1000f, segmentType.key, toastRunnable);
|
||||||
newSponsorSegmentEndMillis = newSponsorSegmentStartMillis = -1;
|
newSponsorSegmentEndMillis = newSponsorSegmentStartMillis = -1;
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
Log.e(TAG, "Unable to submit segment", e);
|
LogHelper.printException(TAG, "Unable to submit segment", e);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (videoId != null)
|
if (videoId != null)
|
||||||
@ -420,9 +414,10 @@ public abstract class SponsorBlockUtils {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static void notifyShareBtnVisibilityChanged(View v) {
|
public static void notifyShareBtnVisibilityChanged(View v) {
|
||||||
if (v.getId() != shareBtnId || !/*SponsorBlockSettings.isAddNewSegmentEnabled*/false) return;
|
if (v.getId() != shareBtnId || !/*SponsorBlockSettings.isAddNewSegmentEnabled*/false)
|
||||||
|
return;
|
||||||
// if (VERBOSE)
|
// if (VERBOSE)
|
||||||
// Log.d(TAG, "VISIBILITY CHANGED of view " + v);
|
// LogH(TAG, "VISIBILITY CHANGED of view " + v);
|
||||||
ImageView sponsorBtn = ShieldButton._shieldBtn.get();
|
ImageView sponsorBtn = ShieldButton._shieldBtn.get();
|
||||||
if (sponsorBtn != null) {
|
if (sponsorBtn != null) {
|
||||||
sponsorBtn.setVisibility(v.getVisibility());
|
sponsorBtn.setVisibility(v.getVisibility());
|
||||||
@ -457,14 +452,13 @@ public abstract class SponsorBlockUtils {
|
|||||||
return String.format(" (%s)", formatted);
|
return String.format(" (%s)", formatted);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void playerTypeChanged(String playerType) {
|
public static void playerTypeChanged(PlayerType playerType) {
|
||||||
try {
|
try {
|
||||||
if (videoHasSegments && (playerType.equalsIgnoreCase("NONE"))) {
|
if (videoHasSegments && (playerType == PlayerType.NONE)) {
|
||||||
PlayerController.setCurrentVideoId(null);
|
PlayerController.setCurrentVideoId(null);
|
||||||
}
|
}
|
||||||
}
|
} catch (Exception ex) {
|
||||||
catch (Exception ex) {
|
LogHelper.printException(TAG, "Player type changed caused a crash.", ex);
|
||||||
Log.e(TAG, "Player type changed caused a crash.", ex);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -541,7 +535,8 @@ public abstract class SponsorBlockUtils {
|
|||||||
JSONObject barTypesObject = settingsJson.getJSONObject("barTypes");
|
JSONObject barTypesObject = settingsJson.getJSONObject("barTypes");
|
||||||
JSONArray categorySelectionsArray = settingsJson.getJSONArray("categorySelections");
|
JSONArray categorySelectionsArray = settingsJson.getJSONArray("categorySelections");
|
||||||
|
|
||||||
SharedPreferences.Editor editor = getPreferences(context).edit();
|
|
||||||
|
SharedPreferences.Editor editor = SharedPrefHelper.getPreferences(context, SharedPrefHelper.SharedPrefNames.SPONSOR_BLOCK).edit();
|
||||||
|
|
||||||
SponsorBlockSettings.SegmentInfo[] categories = SponsorBlockSettings.SegmentInfo.valuesWithoutUnsubmitted();
|
SponsorBlockSettings.SegmentInfo[] categories = SponsorBlockSettings.SegmentInfo.valuesWithoutUnsubmitted();
|
||||||
for (SponsorBlockSettings.SegmentInfo category : categories) {
|
for (SponsorBlockSettings.SegmentInfo category : categories) {
|
||||||
@ -585,8 +580,7 @@ public abstract class SponsorBlockUtils {
|
|||||||
editor.apply();
|
editor.apply();
|
||||||
|
|
||||||
Toast.makeText(context, str("settings_import_successful"), Toast.LENGTH_SHORT).show();
|
Toast.makeText(context, str("settings_import_successful"), Toast.LENGTH_SHORT).show();
|
||||||
}
|
} catch (Exception ex) {
|
||||||
catch (Exception ex) {
|
|
||||||
Toast.makeText(context, str("settings_import_failed"), Toast.LENGTH_SHORT).show();
|
Toast.makeText(context, str("settings_import_failed"), Toast.LENGTH_SHORT).show();
|
||||||
ex.printStackTrace();
|
ex.printStackTrace();
|
||||||
}
|
}
|
||||||
@ -631,8 +625,7 @@ public abstract class SponsorBlockUtils {
|
|||||||
json.put("serverAddress", apiAddress);
|
json.put("serverAddress", apiAddress);
|
||||||
|
|
||||||
return json.toString();
|
return json.toString();
|
||||||
}
|
} catch (Exception ex) {
|
||||||
catch (Exception ex) {
|
|
||||||
Toast.makeText(context, str("settings_export_failed"), Toast.LENGTH_SHORT).show();
|
Toast.makeText(context, str("settings_export_failed"), Toast.LENGTH_SHORT).show();
|
||||||
ex.printStackTrace();
|
ex.printStackTrace();
|
||||||
return "";
|
return "";
|
||||||
@ -644,7 +637,7 @@ public abstract class SponsorBlockUtils {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static boolean isSBButtonEnabled(Context context, String key) {
|
public static boolean isSBButtonEnabled(Context context, String key) {
|
||||||
return isSettingEnabled(SharedPrefUtils.getBoolean(context, PREFERENCES_NAME, key, false));
|
return isSettingEnabled(SharedPrefHelper.getBoolean(context, SharedPrefHelper.SharedPrefNames.SPONSOR_BLOCK, key, false));
|
||||||
}
|
}
|
||||||
|
|
||||||
public enum VoteOption {
|
public enum VoteOption {
|
@ -1,21 +1,22 @@
|
|||||||
package pl.jakubweg;
|
package app.revanced.integrations.sponsorblock;
|
||||||
|
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.content.res.Resources;
|
import android.content.res.Resources;
|
||||||
import android.util.Log;
|
|
||||||
|
|
||||||
import androidx.annotation.NonNull;
|
import androidx.annotation.NonNull;
|
||||||
|
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
|
|
||||||
public class StringRef {
|
import app.revanced.integrations.utils.LogHelper;
|
||||||
public static final String TAG = "jakubweg.StringRef";
|
|
||||||
|
|
||||||
|
public class StringRef {
|
||||||
private static Resources resources;
|
private static Resources resources;
|
||||||
private static String packageName;
|
private static String packageName;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Called in Application onCreate, should be called as soon as possible when after application startup
|
* Called in Application onCreate, should be called as soon as possible when after application startup
|
||||||
|
*
|
||||||
* @param context Any context, it will be used to obtain string resources
|
* @param context Any context, it will be used to obtain string resources
|
||||||
*/
|
*/
|
||||||
public static void setContext(Context context) {
|
public static void setContext(Context context) {
|
||||||
@ -29,6 +30,7 @@ public class StringRef {
|
|||||||
/**
|
/**
|
||||||
* Gets strings reference from shared collection or creates if not exists yet,
|
* Gets strings reference from shared collection or creates if not exists yet,
|
||||||
* this method should be called if you want to get StringRef
|
* this method should be called if you want to get StringRef
|
||||||
|
*
|
||||||
* @param id string resource name/id
|
* @param id string resource name/id
|
||||||
* @return String reference that'll resolve to excepted string, may be from cache
|
* @return String reference that'll resolve to excepted string, may be from cache
|
||||||
*/
|
*/
|
||||||
@ -44,6 +46,7 @@ public class StringRef {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets string value by string id, shorthand for <code>sf(id).toString()</code>
|
* Gets string value by string id, shorthand for <code>sf(id).toString()</code>
|
||||||
|
*
|
||||||
* @param id string resource name/id
|
* @param id string resource name/id
|
||||||
* @return String value from string.xml
|
* @return String value from string.xml
|
||||||
*/
|
*/
|
||||||
@ -55,6 +58,7 @@ public class StringRef {
|
|||||||
/**
|
/**
|
||||||
* Gets string value by string id, shorthand for <code>sf(id).toString()</code> and formats the string
|
* Gets string value by string id, shorthand for <code>sf(id).toString()</code> and formats the string
|
||||||
* with given args.
|
* with given args.
|
||||||
|
*
|
||||||
* @param id string resource name/id
|
* @param id string resource name/id
|
||||||
* @param args the args to format the string with
|
* @param args the args to format the string with
|
||||||
* @return String value from string.xml formatted with given args
|
* @return String value from string.xml formatted with given args
|
||||||
@ -67,6 +71,7 @@ public class StringRef {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates a StringRef object that'll not change it's value
|
* Creates a StringRef object that'll not change it's value
|
||||||
|
*
|
||||||
* @param value value which toString() method returns when invoked on returned object
|
* @param value value which toString() method returns when invoked on returned object
|
||||||
* @return Unique StringRef instance, its value will never change
|
* @return Unique StringRef instance, its value will never change
|
||||||
*/
|
*/
|
||||||
@ -100,7 +105,7 @@ public class StringRef {
|
|||||||
if (resources != null) {
|
if (resources != null) {
|
||||||
final int identifier = resources.getIdentifier(value, "string", packageName);
|
final int identifier = resources.getIdentifier(value, "string", packageName);
|
||||||
if (identifier == 0)
|
if (identifier == 0)
|
||||||
Log.e(TAG, "Resource not found: " + value);
|
LogHelper.printException("StringRef", "Resource not found: " + value);
|
||||||
else
|
else
|
||||||
value = resources.getString(identifier);
|
value = resources.getString(identifier);
|
||||||
}
|
}
|
@ -1,7 +1,7 @@
|
|||||||
package pl.jakubweg;
|
package app.revanced.integrations.sponsorblock;
|
||||||
|
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.util.Log;
|
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.view.animation.Animation;
|
import android.view.animation.Animation;
|
||||||
import android.view.animation.AnimationUtils;
|
import android.view.animation.AnimationUtils;
|
||||||
@ -12,12 +12,12 @@ import com.google.android.apps.youtube.app.YouTubeTikTokRoot_Application;
|
|||||||
|
|
||||||
import java.lang.ref.WeakReference;
|
import java.lang.ref.WeakReference;
|
||||||
|
|
||||||
import static fi.razerman.youtube.XGlobals.debug;
|
import static app.revanced.integrations.sponsorblock.PlayerController.getCurrentVideoLength;
|
||||||
import static pl.jakubweg.PlayerController.getCurrentVideoLength;
|
import static app.revanced.integrations.sponsorblock.PlayerController.getLastKnownVideoTime;
|
||||||
import static pl.jakubweg.PlayerController.getLastKnownVideoTime;
|
|
||||||
|
import app.revanced.integrations.utils.LogHelper;
|
||||||
|
|
||||||
public class VotingButton {
|
public class VotingButton {
|
||||||
static String TAG = "VOTING";
|
|
||||||
static RelativeLayout _youtubeControlsLayout;
|
static RelativeLayout _youtubeControlsLayout;
|
||||||
static WeakReference<ImageView> _votingButton = new WeakReference<>(null);
|
static WeakReference<ImageView> _votingButton = new WeakReference<>(null);
|
||||||
static int fadeDurationFast;
|
static int fadeDurationFast;
|
||||||
@ -28,17 +28,14 @@ public class VotingButton {
|
|||||||
|
|
||||||
public static void initialize(Object viewStub) {
|
public static void initialize(Object viewStub) {
|
||||||
try {
|
try {
|
||||||
if(debug){
|
LogHelper.debug("VotingButton", "initializing voting button");
|
||||||
Log.d(TAG, "initializing voting button");
|
|
||||||
}
|
|
||||||
|
|
||||||
_youtubeControlsLayout = (RelativeLayout) viewStub;
|
_youtubeControlsLayout = (RelativeLayout) viewStub;
|
||||||
|
|
||||||
ImageView imageView = (ImageView)_youtubeControlsLayout
|
ImageView imageView = (ImageView) _youtubeControlsLayout
|
||||||
.findViewById(getIdentifier("voting_button", "id"));
|
.findViewById(getIdentifier("voting_button", "id"));
|
||||||
|
|
||||||
if (debug && imageView == null){
|
if (imageView == null) {
|
||||||
Log.d(TAG, "Couldn't find imageView with tag \"voting_button\"");
|
LogHelper.debug("VotingButton", "Couldn't find imageView with \"voting_button\"");
|
||||||
}
|
}
|
||||||
if (imageView == null) return;
|
if (imageView == null) return;
|
||||||
imageView.setOnClickListener(SponsorBlockUtils.voteButtonListener);
|
imageView.setOnClickListener(SponsorBlockUtils.voteButtonListener);
|
||||||
@ -53,9 +50,8 @@ public class VotingButton {
|
|||||||
fadeOut.setDuration(fadeDurationScheduled);
|
fadeOut.setDuration(fadeDurationScheduled);
|
||||||
isShowing = true;
|
isShowing = true;
|
||||||
changeVisibilityImmediate(false);
|
changeVisibilityImmediate(false);
|
||||||
}
|
} catch (Exception ex) {
|
||||||
catch (Exception ex) {
|
LogHelper.printException("VotingButton", "Unable to set RelativeLayout", ex);
|
||||||
Log.e(TAG, "Unable to set RelativeLayout", ex);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -82,9 +78,7 @@ public class VotingButton {
|
|||||||
if (getLastKnownVideoTime() >= getCurrentVideoLength()) {
|
if (getLastKnownVideoTime() >= getCurrentVideoLength()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (debug) {
|
LogHelper.debug("VotingButton", "Fading in");
|
||||||
Log.d(TAG, "Fading in");
|
|
||||||
}
|
|
||||||
iView.setVisibility(View.VISIBLE);
|
iView.setVisibility(View.VISIBLE);
|
||||||
if (!immediate)
|
if (!immediate)
|
||||||
iView.startAnimation(fadeIn);
|
iView.startAnimation(fadeIn);
|
||||||
@ -92,9 +86,7 @@ public class VotingButton {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (iView.getVisibility() == View.VISIBLE) {
|
if (iView.getVisibility() == View.VISIBLE) {
|
||||||
if (debug) {
|
LogHelper.debug("VotingButton", "Fading out");
|
||||||
Log.d(TAG, "Fading out");
|
|
||||||
}
|
|
||||||
if (!immediate)
|
if (!immediate)
|
||||||
iView.startAnimation(fadeOut);
|
iView.startAnimation(fadeOut);
|
||||||
iView.setVisibility(shouldBeShown() ? View.INVISIBLE : View.GONE);
|
iView.setVisibility(shouldBeShown() ? View.INVISIBLE : View.GONE);
|
@ -1,7 +1,7 @@
|
|||||||
package pl.jakubweg.objects;
|
package app.revanced.integrations.sponsorblock.objects;
|
||||||
|
|
||||||
import static pl.jakubweg.SponsorBlockUtils.formatColorString;
|
import static app.revanced.integrations.sponsorblock.SponsorBlockUtils.formatColorString;
|
||||||
import static pl.jakubweg.StringRef.str;
|
import static app.revanced.integrations.sponsorblock.StringRef.str;
|
||||||
|
|
||||||
import android.app.AlertDialog;
|
import android.app.AlertDialog;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
@ -16,7 +16,7 @@ import android.util.AttributeSet;
|
|||||||
import android.widget.EditText;
|
import android.widget.EditText;
|
||||||
import android.widget.Toast;
|
import android.widget.Toast;
|
||||||
|
|
||||||
import pl.jakubweg.SponsorBlockSettings;
|
import app.revanced.integrations.sponsorblock.SponsorBlockSettings;
|
||||||
|
|
||||||
@SuppressWarnings("deprecation")
|
@SuppressWarnings("deprecation")
|
||||||
public class EditTextListPreference extends ListPreference {
|
public class EditTextListPreference extends ListPreference {
|
||||||
@ -49,18 +49,20 @@ public class EditTextListPreference extends ListPreference {
|
|||||||
mEditText.setText(formatColorString(category.color));
|
mEditText.setText(formatColorString(category.color));
|
||||||
mEditText.addTextChangedListener(new TextWatcher() {
|
mEditText.addTextChangedListener(new TextWatcher() {
|
||||||
@Override
|
@Override
|
||||||
public void beforeTextChanged(CharSequence s, int start, int count, int after) {}
|
public void beforeTextChanged(CharSequence s, int start, int count, int after) {
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onTextChanged(CharSequence s, int start, int before, int count) {}
|
public void onTextChanged(CharSequence s, int start, int before, int count) {
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void afterTextChanged(Editable s) {
|
public void afterTextChanged(Editable s) {
|
||||||
try {
|
try {
|
||||||
Color.parseColor(s.toString()); // validation
|
Color.parseColor(s.toString()); // validation
|
||||||
getDialog().setTitle(Html.fromHtml(String.format("<font color=\"%s\">⬤</font> %s", s, category.title)));
|
getDialog().setTitle(Html.fromHtml(String.format("<font color=\"%s\">⬤</font> %s", s, category.title)));
|
||||||
|
} catch (Exception ex) {
|
||||||
}
|
}
|
||||||
catch (Exception ex) {}
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
builder.setView(mEditText);
|
builder.setView(mEditText);
|
||||||
@ -102,8 +104,7 @@ public class EditTextListPreference extends ListPreference {
|
|||||||
Toast.makeText(applicationContext, str("color_changed"), Toast.LENGTH_SHORT).show();
|
Toast.makeText(applicationContext, str("color_changed"), Toast.LENGTH_SHORT).show();
|
||||||
getSharedPreferences().edit().putString(getColorPreferenceKey(), formatColorString(color)).apply();
|
getSharedPreferences().edit().putString(getColorPreferenceKey(), formatColorString(color)).apply();
|
||||||
reformatTitle();
|
reformatTitle();
|
||||||
}
|
} catch (Exception ex) {
|
||||||
catch (Exception ex) {
|
|
||||||
Toast.makeText(applicationContext, str("color_invalid"), Toast.LENGTH_SHORT).show();
|
Toast.makeText(applicationContext, str("color_invalid"), Toast.LENGTH_SHORT).show();
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -1,6 +1,6 @@
|
|||||||
package pl.jakubweg.objects;
|
package app.revanced.integrations.sponsorblock.objects;
|
||||||
|
|
||||||
import pl.jakubweg.SponsorBlockSettings;
|
import app.revanced.integrations.sponsorblock.SponsorBlockSettings;
|
||||||
|
|
||||||
public class SponsorSegment implements Comparable<SponsorSegment> {
|
public class SponsorSegment implements Comparable<SponsorSegment> {
|
||||||
public final long start;
|
public final long start;
|
@ -1,4 +1,4 @@
|
|||||||
package pl.jakubweg.objects;
|
package app.revanced.integrations.sponsorblock.objects;
|
||||||
|
|
||||||
public class UserStats {
|
public class UserStats {
|
||||||
private final String userName;
|
private final String userName;
|
@ -1,4 +1,4 @@
|
|||||||
package fi.vanced.libraries.youtube.player;
|
package app.revanced.integrations.sponsorblock.player;
|
||||||
|
|
||||||
import java.io.Serializable;
|
import java.io.Serializable;
|
||||||
|
|
@ -0,0 +1,18 @@
|
|||||||
|
package app.revanced.integrations.sponsorblock.player;
|
||||||
|
|
||||||
|
public enum PlayerType {
|
||||||
|
|
||||||
|
NONE,
|
||||||
|
HIDDEN,
|
||||||
|
WATCH_WHILE_MINIMIZED,
|
||||||
|
WATCH_WHILE_MAXIMIZED,
|
||||||
|
WATCH_WHILE_FULLSCREEN,
|
||||||
|
WATCH_WHILE_SLIDING_MAXIMIZED_FULLSCREEN,
|
||||||
|
WATCH_WHILE_SLIDING_MINIMIZED_MAXIMIZED,
|
||||||
|
WATCH_WHILE_SLIDING_MINIMIZED_DISMISSED,
|
||||||
|
WATCH_WHILE_SLIDING_FULLSCREEN_DISMISSED,
|
||||||
|
INLINE_MINIMAL,
|
||||||
|
VIRTUAL_REALITY_FULLSCREEN,
|
||||||
|
WATCH_WHILE_PICTURE_IN_PICTURE;
|
||||||
|
|
||||||
|
}
|
@ -1,16 +1,15 @@
|
|||||||
package fi.vanced.libraries.youtube.player;
|
package app.revanced.integrations.sponsorblock.player;
|
||||||
|
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.util.Log;
|
|
||||||
import android.widget.Toast;
|
import android.widget.Toast;
|
||||||
|
|
||||||
import com.google.android.apps.youtube.app.YouTubeTikTokRoot_Application;
|
import com.google.android.apps.youtube.app.YouTubeTikTokRoot_Application;
|
||||||
|
|
||||||
import static fi.razerman.youtube.XGlobals.debug;
|
import static app.revanced.integrations.sponsorblock.StringRef.str;
|
||||||
import static pl.jakubweg.StringRef.str;
|
|
||||||
|
import app.revanced.integrations.utils.LogHelper;
|
||||||
|
|
||||||
public class VideoHelpers {
|
public class VideoHelpers {
|
||||||
public static final String TAG = "VideoHelpers";
|
|
||||||
|
|
||||||
public static void copyVideoUrlToClipboard() {
|
public static void copyVideoUrlToClipboard() {
|
||||||
generateVideoUrl(false);
|
generateVideoUrl(false);
|
||||||
@ -24,9 +23,7 @@ public class VideoHelpers {
|
|||||||
try {
|
try {
|
||||||
String videoId = VideoInformation.currentVideoId;
|
String videoId = VideoInformation.currentVideoId;
|
||||||
if (videoId == null || videoId.isEmpty()) {
|
if (videoId == null || videoId.isEmpty()) {
|
||||||
if (debug) {
|
LogHelper.debug("VideoHelpers", "VideoId was empty");
|
||||||
Log.d(TAG, "VideoId was empty");
|
|
||||||
}
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -36,21 +33,18 @@ public class VideoHelpers {
|
|||||||
videoUrl += String.format("?t=%s", (videoTime / 1000));
|
videoUrl += String.format("?t=%s", (videoTime / 1000));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (debug) {
|
LogHelper.debug("VideoHelpers", "Video URL: " + videoUrl);
|
||||||
Log.d(TAG, "Video URL: " + videoUrl);
|
|
||||||
}
|
|
||||||
|
|
||||||
setClipboard(YouTubeTikTokRoot_Application.getAppContext(), videoUrl);
|
setClipboard(YouTubeTikTokRoot_Application.getAppContext(), videoUrl);
|
||||||
|
|
||||||
Toast.makeText(YouTubeTikTokRoot_Application.getAppContext(), str("share_copy_url_success"), Toast.LENGTH_SHORT).show();
|
Toast.makeText(YouTubeTikTokRoot_Application.getAppContext(), str("share_copy_url_success"), Toast.LENGTH_SHORT).show();
|
||||||
}
|
} catch (Exception ex) {
|
||||||
catch (Exception ex) {
|
LogHelper.printException("VideoHelpers", "Couldn't generate video url", ex);
|
||||||
Log.e(TAG, "Couldn't generate video url", ex);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void setClipboard(Context context, String text) {
|
private static void setClipboard(Context context, String text) {
|
||||||
if(android.os.Build.VERSION.SDK_INT < android.os.Build.VERSION_CODES.HONEYCOMB) {
|
if (android.os.Build.VERSION.SDK_INT < android.os.Build.VERSION_CODES.HONEYCOMB) {
|
||||||
android.text.ClipboardManager clipboard = (android.text.ClipboardManager) context.getSystemService(Context.CLIPBOARD_SERVICE);
|
android.text.ClipboardManager clipboard = (android.text.ClipboardManager) context.getSystemService(Context.CLIPBOARD_SERVICE);
|
||||||
clipboard.setText(text);
|
clipboard.setText(text);
|
||||||
} else {
|
} else {
|
@ -1,14 +1,9 @@
|
|||||||
package fi.vanced.libraries.youtube.player;
|
package app.revanced.integrations.sponsorblock.player;
|
||||||
|
|
||||||
import static fi.razerman.youtube.XGlobals.debug;
|
import app.revanced.integrations.utils.LogHelper;
|
||||||
|
import app.revanced.integrations.ryd.ReturnYouTubeDislikes;
|
||||||
import android.util.Log;
|
|
||||||
|
|
||||||
import fi.vanced.libraries.youtube.ryd.ReturnYouTubeDislikes;
|
|
||||||
|
|
||||||
public class VideoInformation {
|
public class VideoInformation {
|
||||||
private static final String TAG = "VI - VideoInfo";
|
|
||||||
|
|
||||||
public static String currentVideoId;
|
public static String currentVideoId;
|
||||||
public static Integer dislikeCount;
|
public static Integer dislikeCount;
|
||||||
public static String channelName;
|
public static String channelName;
|
||||||
@ -21,9 +16,7 @@ public class VideoInformation {
|
|||||||
// Call hook in the YT code when the video changes
|
// Call hook in the YT code when the video changes
|
||||||
public static void setCurrentVideoId(final String videoId) {
|
public static void setCurrentVideoId(final String videoId) {
|
||||||
if (videoId == null) {
|
if (videoId == null) {
|
||||||
if (debug) {
|
LogHelper.debug("VideoInformation", "setCurrentVideoId - new id was null - currentVideoId was" + currentVideoId);
|
||||||
Log.d(TAG, "setCurrentVideoId - new id was null - currentVideoId was" + currentVideoId);
|
|
||||||
}
|
|
||||||
clearInformation(true);
|
clearInformation(true);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -34,15 +27,11 @@ public class VideoInformation {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (videoId.equals(currentVideoId)) {
|
if (videoId.equals(currentVideoId)) {
|
||||||
if (debug) {
|
LogHelper.debug("VideoInformation", "setCurrentVideoId - new and current video were equal - " + videoId);
|
||||||
Log.d(TAG, "setCurrentVideoId - new and current video were equal - " + videoId);
|
|
||||||
}
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (debug) {
|
LogHelper.debug("VideoInformation", "setCurrentVideoId - video id updated from " + currentVideoId + " to " + videoId);
|
||||||
Log.d(TAG, "setCurrentVideoId - video id updated from " + currentVideoId + " to " + videoId);
|
|
||||||
}
|
|
||||||
|
|
||||||
currentVideoId = videoId;
|
currentVideoId = videoId;
|
||||||
|
|
@ -1,42 +1,38 @@
|
|||||||
package fi.vanced.libraries.youtube.ui;
|
package app.revanced.integrations.sponsorblock.player.ui;
|
||||||
|
|
||||||
import static fi.razerman.youtube.XGlobals.debug;
|
import static app.revanced.integrations.sponsorblock.player.VideoInformation.currentVideoId;
|
||||||
import static fi.vanced.libraries.youtube.player.VideoInformation.currentVideoId;
|
import static app.revanced.integrations.sponsorblock.StringRef.str;
|
||||||
import static pl.jakubweg.StringRef.str;
|
|
||||||
|
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.util.Log;
|
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.view.ViewGroup;
|
import android.view.ViewGroup;
|
||||||
import android.widget.ImageView;
|
import android.widget.ImageView;
|
||||||
|
|
||||||
import fi.vanced.libraries.youtube.player.VideoInformation;
|
import app.revanced.integrations.utils.LogHelper;
|
||||||
import fi.vanced.libraries.youtube.whitelisting.Whitelist;
|
import app.revanced.integrations.sponsorblock.player.VideoInformation;
|
||||||
import fi.vanced.libraries.youtube.whitelisting.WhitelistType;
|
import app.revanced.integrations.adremover.whitelist.Whitelist;
|
||||||
import fi.vanced.libraries.youtube.whitelisting.requests.WhitelistRequester;
|
import app.revanced.integrations.adremover.whitelist.WhitelistType;
|
||||||
import fi.vanced.utils.SharedPrefUtils;
|
import app.revanced.integrations.adremover.whitelist.requests.WhitelistRequester;
|
||||||
import fi.vanced.utils.VancedUtils;
|
import app.revanced.integrations.utils.SharedPrefHelper;
|
||||||
|
import app.revanced.integrations.utils.ReVancedUtils;
|
||||||
|
|
||||||
public class AdButton extends SlimButton {
|
public class AdButton extends SlimButton {
|
||||||
public static final String TAG = "VI - AdButton - Button";
|
|
||||||
|
|
||||||
public AdButton(Context context, ViewGroup container) {
|
public AdButton(Context context, ViewGroup container) {
|
||||||
super(context, container, SlimButton.SLIM_METADATA_BUTTON_ID,
|
super(context, container, SlimButton.SLIM_METADATA_BUTTON_ID,
|
||||||
SharedPrefUtils.getBoolean(context, WhitelistType.ADS.getSharedPreferencesName(), WhitelistType.ADS.getPreferenceEnabledName(), false));
|
SharedPrefHelper.getBoolean(context, SharedPrefHelper.SharedPrefNames.YOUTUBE, WhitelistType.ADS.getPreferenceEnabledName(), false));
|
||||||
|
|
||||||
initialize();
|
initialize();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void initialize() {
|
private void initialize() {
|
||||||
this.button_icon.setImageResource(VancedUtils.getIdentifier("vanced_yt_ad_button", "drawable"));
|
this.button_icon.setImageResource(ReVancedUtils.getIdentifier("vanced_yt_ad_button", "drawable"));
|
||||||
this.button_text.setText(str("action_ads"));
|
this.button_text.setText(str("action_ads"));
|
||||||
changeEnabled(Whitelist.shouldShowAds());
|
changeEnabled(Whitelist.shouldShowAds());
|
||||||
}
|
}
|
||||||
|
|
||||||
public void changeEnabled(boolean enabled) {
|
public void changeEnabled(boolean enabled) {
|
||||||
if (debug) {
|
LogHelper.debug("AdButton", "changeEnabled " + enabled);
|
||||||
Log.d(TAG, "changeEnabled " + enabled);
|
|
||||||
}
|
|
||||||
this.button_icon.setEnabled(enabled);
|
this.button_icon.setEnabled(enabled);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -56,9 +52,8 @@ public class AdButton extends SlimButton {
|
|||||||
try {
|
try {
|
||||||
Whitelist.removeFromWhitelist(WhitelistType.ADS, this.context, VideoInformation.channelName);
|
Whitelist.removeFromWhitelist(WhitelistType.ADS, this.context, VideoInformation.channelName);
|
||||||
changeEnabled(false);
|
changeEnabled(false);
|
||||||
}
|
} catch (Exception ex) {
|
||||||
catch (Exception ex) {
|
LogHelper.printException("AdButton", "Failed to remove from whitelist", ex);
|
||||||
Log.e(TAG, "Failed to remove from whitelist", ex);
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -67,9 +62,7 @@ public class AdButton extends SlimButton {
|
|||||||
|
|
||||||
private void addToWhiteList(View view, ImageView buttonIcon) {
|
private void addToWhiteList(View view, ImageView buttonIcon) {
|
||||||
new Thread(() -> {
|
new Thread(() -> {
|
||||||
if (debug) {
|
LogHelper.debug("AdButton", "Fetching channelId for " + currentVideoId);
|
||||||
Log.d(TAG, "Fetching channelId for " + currentVideoId);
|
|
||||||
}
|
|
||||||
WhitelistRequester.addChannelToWhitelist(WhitelistType.ADS, view, buttonIcon, this.context);
|
WhitelistRequester.addChannelToWhitelist(WhitelistType.ADS, view, buttonIcon, this.context);
|
||||||
}).start();
|
}).start();
|
||||||
}
|
}
|
@ -1,24 +1,28 @@
|
|||||||
package fi.vanced.libraries.youtube.ui;
|
package app.revanced.integrations.sponsorblock.player.ui;
|
||||||
|
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
|
|
||||||
import fi.vanced.utils.SharedPrefUtils;
|
import app.revanced.integrations.utils.SharedPrefHelper;
|
||||||
|
|
||||||
public class ButtonVisibility {
|
public class ButtonVisibility {
|
||||||
public static Visibility getButtonVisibility(Context context, String key) {
|
public static Visibility getButtonVisibility(Context context, String key) {
|
||||||
return getButtonVisibility(context, key, "youtube");
|
return getButtonVisibility(context, key, SharedPrefHelper.SharedPrefNames.YOUTUBE);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Visibility getButtonVisibility(Context context, String key, String preferenceName) {
|
public static Visibility getButtonVisibility(Context context, String key, SharedPrefHelper.SharedPrefNames name) {
|
||||||
String value = SharedPrefUtils.getString(context, preferenceName, key, null);
|
String value = SharedPrefHelper.getString(context, name, key, null);
|
||||||
|
|
||||||
if (value == null || value.isEmpty()) return Visibility.NONE;
|
if (value == null || value.isEmpty()) return Visibility.NONE;
|
||||||
|
|
||||||
switch (value.toUpperCase()) {
|
switch (value.toUpperCase()) {
|
||||||
case "PLAYER": return Visibility.PLAYER;
|
case "PLAYER":
|
||||||
case "BUTTON_CONTAINER": return Visibility.BUTTON_CONTAINER;
|
return Visibility.PLAYER;
|
||||||
case "BOTH": return Visibility.BOTH;
|
case "BUTTON_CONTAINER":
|
||||||
default: return Visibility.NONE;
|
return Visibility.BUTTON_CONTAINER;
|
||||||
|
case "BOTH":
|
||||||
|
return Visibility.BOTH;
|
||||||
|
default:
|
||||||
|
return Visibility.NONE;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -26,8 +30,8 @@ public class ButtonVisibility {
|
|||||||
return isVisibleInContainer(getButtonVisibility(context, key));
|
return isVisibleInContainer(getButtonVisibility(context, key));
|
||||||
}
|
}
|
||||||
|
|
||||||
public static boolean isVisibleInContainer(Context context, String key, String preferenceName) {
|
public static boolean isVisibleInContainer(Context context, String key, SharedPrefHelper.SharedPrefNames name) {
|
||||||
return isVisibleInContainer(getButtonVisibility(context, key, preferenceName));
|
return isVisibleInContainer(getButtonVisibility(context, key, name));
|
||||||
}
|
}
|
||||||
|
|
||||||
public static boolean isVisibleInContainer(Visibility visibility) {
|
public static boolean isVisibleInContainer(Visibility visibility) {
|
@ -1,13 +1,13 @@
|
|||||||
package fi.vanced.libraries.youtube.ui;
|
package app.revanced.integrations.sponsorblock.player.ui;
|
||||||
|
|
||||||
import static pl.jakubweg.StringRef.str;
|
import static app.revanced.integrations.sponsorblock.StringRef.str;
|
||||||
|
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.view.ViewGroup;
|
import android.view.ViewGroup;
|
||||||
|
|
||||||
import fi.vanced.libraries.youtube.player.VideoHelpers;
|
import app.revanced.integrations.sponsorblock.player.VideoHelpers;
|
||||||
import fi.vanced.utils.VancedUtils;
|
import app.revanced.integrations.utils.ReVancedUtils;
|
||||||
|
|
||||||
public class CopyButton extends SlimButton {
|
public class CopyButton extends SlimButton {
|
||||||
public CopyButton(Context context, ViewGroup container) {
|
public CopyButton(Context context, ViewGroup container) {
|
||||||
@ -17,7 +17,7 @@ public class CopyButton extends SlimButton {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void initialize() {
|
private void initialize() {
|
||||||
this.button_icon.setImageResource(VancedUtils.getIdentifier("vanced_yt_copy_icon", "drawable"));
|
this.button_icon.setImageResource(ReVancedUtils.getIdentifier("vanced_yt_copy_icon", "drawable"));
|
||||||
this.button_text.setText(str("action_copy"));
|
this.button_text.setText(str("action_copy"));
|
||||||
}
|
}
|
||||||
|
|
@ -1,13 +1,13 @@
|
|||||||
package fi.vanced.libraries.youtube.ui;
|
package app.revanced.integrations.sponsorblock.player.ui;
|
||||||
|
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.view.ViewGroup;
|
import android.view.ViewGroup;
|
||||||
|
|
||||||
import fi.vanced.libraries.youtube.player.VideoHelpers;
|
import app.revanced.integrations.sponsorblock.player.VideoHelpers;
|
||||||
import fi.vanced.utils.VancedUtils;
|
import app.revanced.integrations.utils.ReVancedUtils;
|
||||||
|
|
||||||
import static pl.jakubweg.StringRef.str;
|
import static app.revanced.integrations.sponsorblock.StringRef.str;
|
||||||
|
|
||||||
public class CopyWithTimestamp extends SlimButton {
|
public class CopyWithTimestamp extends SlimButton {
|
||||||
public CopyWithTimestamp(Context context, ViewGroup container) {
|
public CopyWithTimestamp(Context context, ViewGroup container) {
|
||||||
@ -17,7 +17,7 @@ public class CopyWithTimestamp extends SlimButton {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void initialize() {
|
private void initialize() {
|
||||||
this.button_icon.setImageResource(VancedUtils.getIdentifier("vanced_yt_copy_icon_with_time", "drawable"));
|
this.button_icon.setImageResource(ReVancedUtils.getIdentifier("vanced_yt_copy_icon_with_time", "drawable"));
|
||||||
this.button_text.setText(str("action_tcopy"));
|
this.button_text.setText(str("action_tcopy"));
|
||||||
}
|
}
|
||||||
|
|
@ -1,11 +1,11 @@
|
|||||||
package fi.vanced.libraries.youtube.sponsors.player.ui;
|
package app.revanced.integrations.sponsorblock.player.ui;
|
||||||
|
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.content.res.ColorStateList;
|
import android.content.res.ColorStateList;
|
||||||
import android.content.res.Resources;
|
import android.content.res.Resources;
|
||||||
import android.graphics.drawable.RippleDrawable;
|
import android.graphics.drawable.RippleDrawable;
|
||||||
import android.util.AttributeSet;
|
import android.util.AttributeSet;
|
||||||
import android.util.Log;
|
|
||||||
import android.util.TypedValue;
|
import android.util.TypedValue;
|
||||||
import android.view.LayoutInflater;
|
import android.view.LayoutInflater;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
@ -13,15 +13,13 @@ import android.widget.FrameLayout;
|
|||||||
import android.widget.ImageButton;
|
import android.widget.ImageButton;
|
||||||
import android.widget.LinearLayout;
|
import android.widget.LinearLayout;
|
||||||
|
|
||||||
import pl.jakubweg.NewSegmentHelperLayout;
|
import app.revanced.integrations.utils.LogHelper;
|
||||||
import pl.jakubweg.PlayerController;
|
import app.revanced.integrations.sponsorblock.NewSegmentHelperLayout;
|
||||||
import pl.jakubweg.SponsorBlockSettings;
|
import app.revanced.integrations.sponsorblock.PlayerController;
|
||||||
import pl.jakubweg.SponsorBlockUtils;
|
import app.revanced.integrations.sponsorblock.SponsorBlockSettings;
|
||||||
|
import app.revanced.integrations.sponsorblock.SponsorBlockUtils;
|
||||||
import static fi.razerman.youtube.XGlobals.debug;
|
|
||||||
|
|
||||||
public class NewSegmentLayout extends FrameLayout {
|
public class NewSegmentLayout extends FrameLayout {
|
||||||
static String TAG = "NewSegmentLayout";
|
|
||||||
|
|
||||||
private LinearLayout newSegmentContainer;
|
private LinearLayout newSegmentContainer;
|
||||||
public int defaultBottomMargin;
|
public int defaultBottomMargin;
|
||||||
@ -62,70 +60,70 @@ public class NewSegmentLayout extends FrameLayout {
|
|||||||
getContext().getTheme().resolveAttribute(android.R.attr.selectableItemBackground, rippleEffect, true);
|
getContext().getTheme().resolveAttribute(android.R.attr.selectableItemBackground, rippleEffect, true);
|
||||||
rippleEffectId = rippleEffect.resourceId;
|
rippleEffectId = rippleEffect.resourceId;
|
||||||
|
|
||||||
this.newSegmentContainer = (LinearLayout)this.findViewById(getIdentifier(context, "new_segment_container", "id"));
|
this.newSegmentContainer = (LinearLayout) this.findViewById(getIdentifier(context, "new_segment_container", "id"));
|
||||||
|
|
||||||
this.rewindButton = (ImageButton)this.findViewById(getIdentifier(context, "new_segment_rewind", "id"));
|
this.rewindButton = (ImageButton) this.findViewById(getIdentifier(context, "new_segment_rewind", "id"));
|
||||||
if (this.rewindButton != null) {
|
if (this.rewindButton != null) {
|
||||||
setClickEffect(this.rewindButton);
|
setClickEffect(this.rewindButton);
|
||||||
this.rewindButton.setOnClickListener(new View.OnClickListener() {
|
this.rewindButton.setOnClickListener(new View.OnClickListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onClick(View v) {
|
public void onClick(View v) {
|
||||||
if (debug) { Log.d(TAG, "Rewind button clicked"); }
|
LogHelper.debug("NewSegmentLayout", "Rewind button clicked");
|
||||||
PlayerController.skipRelativeMilliseconds(-SponsorBlockSettings.adjustNewSegmentMillis);
|
PlayerController.skipRelativeMilliseconds(-SponsorBlockSettings.adjustNewSegmentMillis);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
this.forwardButton = (ImageButton)this.findViewById(getIdentifier(context, "new_segment_forward", "id"));
|
this.forwardButton = (ImageButton) this.findViewById(getIdentifier(context, "new_segment_forward", "id"));
|
||||||
if (this.forwardButton != null) {
|
if (this.forwardButton != null) {
|
||||||
setClickEffect(this.forwardButton);
|
setClickEffect(this.forwardButton);
|
||||||
this.forwardButton.setOnClickListener(new View.OnClickListener() {
|
this.forwardButton.setOnClickListener(new View.OnClickListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onClick(View v) {
|
public void onClick(View v) {
|
||||||
if (debug) { Log.d(TAG, "Forward button clicked"); }
|
LogHelper.debug("NewSegmentLayout", "Forward button clicked");
|
||||||
PlayerController.skipRelativeMilliseconds(SponsorBlockSettings.adjustNewSegmentMillis);
|
PlayerController.skipRelativeMilliseconds(SponsorBlockSettings.adjustNewSegmentMillis);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
this.adjustButton = (ImageButton)this.findViewById(getIdentifier(context, "new_segment_adjust", "id"));
|
this.adjustButton = (ImageButton) this.findViewById(getIdentifier(context, "new_segment_adjust", "id"));
|
||||||
if (this.adjustButton != null) {
|
if (this.adjustButton != null) {
|
||||||
setClickEffect(this.adjustButton);
|
setClickEffect(this.adjustButton);
|
||||||
this.adjustButton.setOnClickListener(new View.OnClickListener() {
|
this.adjustButton.setOnClickListener(new View.OnClickListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onClick(View v) {
|
public void onClick(View v) {
|
||||||
if (debug) { Log.d(TAG, "Adjust button clicked"); }
|
LogHelper.debug("NewSegmentLayout", "Adjust button clicked");
|
||||||
SponsorBlockUtils.onMarkLocationClicked(NewSegmentHelperLayout.context);
|
SponsorBlockUtils.onMarkLocationClicked(NewSegmentHelperLayout.context);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
this.compareButton = (ImageButton)this.findViewById(getIdentifier(context, "new_segment_compare", "id"));
|
this.compareButton = (ImageButton) this.findViewById(getIdentifier(context, "new_segment_compare", "id"));
|
||||||
if (this.compareButton != null) {
|
if (this.compareButton != null) {
|
||||||
setClickEffect(this.compareButton);
|
setClickEffect(this.compareButton);
|
||||||
this.compareButton.setOnClickListener(new View.OnClickListener() {
|
this.compareButton.setOnClickListener(new View.OnClickListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onClick(View v) {
|
public void onClick(View v) {
|
||||||
if (debug) { Log.d(TAG, "Compare button clicked"); }
|
LogHelper.debug("NewSegmentLayout", "Compare button clicked");
|
||||||
SponsorBlockUtils.onPreviewClicked(NewSegmentHelperLayout.context);
|
SponsorBlockUtils.onPreviewClicked(NewSegmentHelperLayout.context);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
this.editButton = (ImageButton)this.findViewById(getIdentifier(context, "new_segment_edit", "id"));
|
this.editButton = (ImageButton) this.findViewById(getIdentifier(context, "new_segment_edit", "id"));
|
||||||
if (this.editButton != null) {
|
if (this.editButton != null) {
|
||||||
setClickEffect(this.editButton);
|
setClickEffect(this.editButton);
|
||||||
this.editButton.setOnClickListener(new View.OnClickListener() {
|
this.editButton.setOnClickListener(new View.OnClickListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onClick(View v) {
|
public void onClick(View v) {
|
||||||
if (debug) { Log.d(TAG, "Edit button clicked"); }
|
LogHelper.debug("NewSegmentLayout", "Edit button clicked");
|
||||||
SponsorBlockUtils.onEditByHandClicked(NewSegmentHelperLayout.context);
|
SponsorBlockUtils.onEditByHandClicked(NewSegmentHelperLayout.context);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
this.publishButton = (ImageButton)this.findViewById(getIdentifier(context, "new_segment_publish", "id"));
|
this.publishButton = (ImageButton) this.findViewById(getIdentifier(context, "new_segment_publish", "id"));
|
||||||
if (this.publishButton != null) {
|
if (this.publishButton != null) {
|
||||||
setClickEffect(this.publishButton);
|
setClickEffect(this.publishButton);
|
||||||
this.publishButton.setOnClickListener(new View.OnClickListener() {
|
this.publishButton.setOnClickListener(new View.OnClickListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onClick(View v) {
|
public void onClick(View v) {
|
||||||
if (debug) { Log.d(TAG, "Publish button clicked"); }
|
LogHelper.debug("NewSegmentLayout", "Publish button clicked");
|
||||||
SponsorBlockUtils.onPublishClicked(NewSegmentHelperLayout.context);
|
SponsorBlockUtils.onPublishClicked(NewSegmentHelperLayout.context);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@ -138,10 +136,10 @@ public class NewSegmentLayout extends FrameLayout {
|
|||||||
private void setClickEffect(ImageButton btn) {
|
private void setClickEffect(ImageButton btn) {
|
||||||
btn.setBackgroundResource(rippleEffectId);
|
btn.setBackgroundResource(rippleEffectId);
|
||||||
|
|
||||||
RippleDrawable rippleDrawable = (RippleDrawable)btn.getBackground();
|
RippleDrawable rippleDrawable = (RippleDrawable) btn.getBackground();
|
||||||
|
|
||||||
int[][] states = new int[][] { new int[] { android.R.attr.state_enabled } };
|
int[][] states = new int[][]{new int[]{android.R.attr.state_enabled}};
|
||||||
int[] colors = new int[] { 0x33ffffff }; // sets the ripple color to white
|
int[] colors = new int[]{0x33ffffff}; // sets the ripple color to white
|
||||||
|
|
||||||
ColorStateList colorStateList = new ColorStateList(states, colors);
|
ColorStateList colorStateList = new ColorStateList(states, colors);
|
||||||
rippleDrawable.setColor(colorStateList);
|
rippleDrawable.setColor(colorStateList);
|
@ -1,6 +1,6 @@
|
|||||||
package fi.vanced.libraries.youtube.ui;
|
package app.revanced.integrations.sponsorblock.player.ui;
|
||||||
|
|
||||||
import static pl.jakubweg.StringRef.str;
|
import static app.revanced.integrations.sponsorblock.StringRef.str;
|
||||||
|
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
@ -8,10 +8,10 @@ import android.net.Uri;
|
|||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.view.ViewGroup;
|
import android.view.ViewGroup;
|
||||||
|
|
||||||
import fi.vanced.libraries.youtube.player.VideoInformation;
|
import app.revanced.integrations.sponsorblock.player.VideoInformation;
|
||||||
import fi.vanced.utils.VancedUtils;
|
import app.revanced.integrations.utils.ReVancedUtils;
|
||||||
import pl.jakubweg.SponsorBlockSettings;
|
import app.revanced.integrations.sponsorblock.SponsorBlockSettings;
|
||||||
import pl.jakubweg.SponsorBlockUtils;
|
import app.revanced.integrations.sponsorblock.SponsorBlockUtils;
|
||||||
|
|
||||||
public class SBBrowserButton extends SlimButton {
|
public class SBBrowserButton extends SlimButton {
|
||||||
private static final String BROWSER_URL = "https://sb.ltn.fi/video/";
|
private static final String BROWSER_URL = "https://sb.ltn.fi/video/";
|
||||||
@ -24,7 +24,7 @@ public class SBBrowserButton extends SlimButton {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void initialize() {
|
private void initialize() {
|
||||||
this.button_icon.setImageResource(VancedUtils.getIdentifier("vanced_sb_browser", "drawable"));
|
this.button_icon.setImageResource(ReVancedUtils.getIdentifier("vanced_sb_browser", "drawable"));
|
||||||
this.button_text.setText(str("action_browser"));
|
this.button_text.setText(str("action_browser"));
|
||||||
}
|
}
|
||||||
|
|
@ -1,25 +1,23 @@
|
|||||||
package fi.vanced.libraries.youtube.ui;
|
package app.revanced.integrations.sponsorblock.player.ui;
|
||||||
|
|
||||||
import static fi.razerman.youtube.XGlobals.debug;
|
import static app.revanced.integrations.sponsorblock.player.VideoInformation.currentVideoId;
|
||||||
import static fi.vanced.libraries.youtube.player.VideoInformation.currentVideoId;
|
import static app.revanced.integrations.sponsorblock.StringRef.str;
|
||||||
import static pl.jakubweg.StringRef.str;
|
|
||||||
|
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.util.Log;
|
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.view.ViewGroup;
|
import android.view.ViewGroup;
|
||||||
import android.widget.ImageView;
|
import android.widget.ImageView;
|
||||||
|
|
||||||
import fi.vanced.libraries.youtube.player.VideoInformation;
|
import app.revanced.integrations.utils.LogHelper;
|
||||||
import fi.vanced.libraries.youtube.whitelisting.Whitelist;
|
import app.revanced.integrations.sponsorblock.player.VideoInformation;
|
||||||
import fi.vanced.libraries.youtube.whitelisting.WhitelistType;
|
import app.revanced.integrations.adremover.whitelist.Whitelist;
|
||||||
import fi.vanced.libraries.youtube.whitelisting.requests.WhitelistRequester;
|
import app.revanced.integrations.adremover.whitelist.WhitelistType;
|
||||||
import fi.vanced.utils.VancedUtils;
|
import app.revanced.integrations.adremover.whitelist.requests.WhitelistRequester;
|
||||||
import pl.jakubweg.SponsorBlockUtils;
|
import app.revanced.integrations.utils.ReVancedUtils;
|
||||||
|
import app.revanced.integrations.sponsorblock.SponsorBlockUtils;
|
||||||
|
|
||||||
public class SBWhitelistButton extends SlimButton {
|
public class SBWhitelistButton extends SlimButton {
|
||||||
public static final String TAG = "VI - SBWhitelistButton";
|
|
||||||
|
|
||||||
public SBWhitelistButton(Context context, ViewGroup container) {
|
public SBWhitelistButton(Context context, ViewGroup container) {
|
||||||
super(context, container, SlimButton.SLIM_METADATA_BUTTON_ID,
|
super(context, container, SlimButton.SLIM_METADATA_BUTTON_ID,
|
||||||
SponsorBlockUtils.isSBButtonEnabled(context, WhitelistType.SPONSORBLOCK.getPreferenceEnabledName()));
|
SponsorBlockUtils.isSBButtonEnabled(context, WhitelistType.SPONSORBLOCK.getPreferenceEnabledName()));
|
||||||
@ -28,15 +26,13 @@ public class SBWhitelistButton extends SlimButton {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void initialize() {
|
private void initialize() {
|
||||||
this.button_icon.setImageResource(VancedUtils.getIdentifier("vanced_yt_sb_button", "drawable"));
|
this.button_icon.setImageResource(ReVancedUtils.getIdentifier("vanced_yt_sb_button", "drawable"));
|
||||||
this.button_text.setText(str("action_segments"));
|
this.button_text.setText(str("action_segments"));
|
||||||
changeEnabled(Whitelist.isChannelSBWhitelisted());
|
changeEnabled(Whitelist.isChannelSBWhitelisted());
|
||||||
}
|
}
|
||||||
|
|
||||||
public void changeEnabled(boolean enabled) {
|
public void changeEnabled(boolean enabled) {
|
||||||
if (debug) {
|
LogHelper.debug("SBWhiteListButton", "changeEnabled " + enabled);
|
||||||
Log.d(TAG, "changeEnabled " + enabled);
|
|
||||||
}
|
|
||||||
this.button_icon.setEnabled(!enabled); // enabled == true -> strikethrough (no segments), enabled == false -> clear (segments)
|
this.button_icon.setEnabled(!enabled); // enabled == true -> strikethrough (no segments), enabled == false -> clear (segments)
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -56,9 +52,8 @@ public class SBWhitelistButton extends SlimButton {
|
|||||||
try {
|
try {
|
||||||
Whitelist.removeFromWhitelist(WhitelistType.SPONSORBLOCK, this.context, VideoInformation.channelName);
|
Whitelist.removeFromWhitelist(WhitelistType.SPONSORBLOCK, this.context, VideoInformation.channelName);
|
||||||
changeEnabled(false);
|
changeEnabled(false);
|
||||||
}
|
} catch (Exception ex) {
|
||||||
catch (Exception ex) {
|
LogHelper.printException("SBWhiteListButton", "Failed to remove from whitelist", ex);
|
||||||
Log.e(TAG, "Failed to remove from whitelist", ex);
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -67,9 +62,7 @@ public class SBWhitelistButton extends SlimButton {
|
|||||||
|
|
||||||
private void addToWhiteList(View view, ImageView buttonIcon) {
|
private void addToWhiteList(View view, ImageView buttonIcon) {
|
||||||
new Thread(() -> {
|
new Thread(() -> {
|
||||||
if (debug) {
|
LogHelper.debug("SBWhiteListButton", "Fetching channelId for " + currentVideoId);
|
||||||
Log.d(TAG, "Fetching channelId for " + currentVideoId);
|
|
||||||
}
|
|
||||||
WhitelistRequester.addChannelToWhitelist(WhitelistType.SPONSORBLOCK, view, buttonIcon, this.context);
|
WhitelistRequester.addChannelToWhitelist(WhitelistType.SPONSORBLOCK, view, buttonIcon, this.context);
|
||||||
}).start();
|
}).start();
|
||||||
}
|
}
|
@ -1,4 +1,4 @@
|
|||||||
package fi.vanced.libraries.youtube.sponsors.player.ui;
|
package app.revanced.integrations.sponsorblock.player.ui;
|
||||||
|
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.content.res.Resources;
|
import android.content.res.Resources;
|
||||||
@ -7,7 +7,6 @@ import android.graphics.Paint;
|
|||||||
import android.graphics.drawable.ColorDrawable;
|
import android.graphics.drawable.ColorDrawable;
|
||||||
import android.os.Build;
|
import android.os.Build;
|
||||||
import android.util.AttributeSet;
|
import android.util.AttributeSet;
|
||||||
import android.util.Log;
|
|
||||||
import android.view.LayoutInflater;
|
import android.view.LayoutInflater;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.widget.FrameLayout;
|
import android.widget.FrameLayout;
|
||||||
@ -15,12 +14,10 @@ import android.widget.ImageView;
|
|||||||
import android.widget.LinearLayout;
|
import android.widget.LinearLayout;
|
||||||
import android.widget.TextView;
|
import android.widget.TextView;
|
||||||
|
|
||||||
import pl.jakubweg.PlayerController;
|
import app.revanced.integrations.utils.LogHelper;
|
||||||
|
import app.revanced.integrations.sponsorblock.PlayerController;
|
||||||
import static fi.razerman.youtube.XGlobals.debug;
|
|
||||||
|
|
||||||
public class SkipSponsorButton extends FrameLayout {
|
public class SkipSponsorButton extends FrameLayout {
|
||||||
String TAG = "SkipSponsorButton";
|
|
||||||
public CharSequence skipSponsorTextViewText;
|
public CharSequence skipSponsorTextViewText;
|
||||||
public CharSequence skipSponsorText;
|
public CharSequence skipSponsorText;
|
||||||
public ImageView skipSponsorButtonIcon;
|
public ImageView skipSponsorButtonIcon;
|
||||||
@ -68,8 +65,8 @@ public class SkipSponsorButton extends FrameLayout {
|
|||||||
private final void initialize(Context context) {
|
private final void initialize(Context context) {
|
||||||
LayoutInflater.from(context).inflate(getIdentifier(context, "skip_sponsor_button", "layout"), this, true); // layout:skip_ad_button
|
LayoutInflater.from(context).inflate(getIdentifier(context, "skip_sponsor_button", "layout"), this, true); // layout:skip_ad_button
|
||||||
this.setMinimumHeight(this.getResources().getDimensionPixelSize(getIdentifier(context, "ad_skip_ad_button_min_height", "dimen"))); // dimen:ad_skip_ad_button_min_height
|
this.setMinimumHeight(this.getResources().getDimensionPixelSize(getIdentifier(context, "ad_skip_ad_button_min_height", "dimen"))); // dimen:ad_skip_ad_button_min_height
|
||||||
this.skipSponsorBtnContainer = (LinearLayout)this.findViewById(getIdentifier(context, "skip_sponsor_button_container", "id")); // id:skip_ad_button_container
|
this.skipSponsorBtnContainer = (LinearLayout) this.findViewById(getIdentifier(context, "skip_sponsor_button_container", "id")); // id:skip_ad_button_container
|
||||||
this.skipSponsorButtonIcon = (ImageView)this.findViewById(getIdentifier(context, "skip_sponsor_button_icon", "id")); // id:skip_ad_button_icon
|
this.skipSponsorButtonIcon = (ImageView) this.findViewById(getIdentifier(context, "skip_sponsor_button_icon", "id")); // id:skip_ad_button_icon
|
||||||
this.backgroundColor = getColor(context, getIdentifier(context, "skip_ad_button_background_color", "color")); // color:skip_ad_button_background_color
|
this.backgroundColor = getColor(context, getIdentifier(context, "skip_ad_button_background_color", "color")); // color:skip_ad_button_background_color
|
||||||
this.invertedBackgroundColor = getColor(context, getIdentifier(context, "skip_ad_button_inverted_background_color", "color")); // color:skip_ad_button_inverted_background_color
|
this.invertedBackgroundColor = getColor(context, getIdentifier(context, "skip_ad_button_inverted_background_color", "color")); // color:skip_ad_button_inverted_background_color
|
||||||
this.background.setColor(this.backgroundColor);
|
this.background.setColor(this.backgroundColor);
|
||||||
@ -79,7 +76,7 @@ public class SkipSponsorButton extends FrameLayout {
|
|||||||
float borderWidth = this.getResources().getDimension(getIdentifier(context, "ad_skip_ad_button_border_width", "dimen")); // dimen:ad_skip_ad_button_border_width
|
float borderWidth = this.getResources().getDimension(getIdentifier(context, "ad_skip_ad_button_border_width", "dimen")); // dimen:ad_skip_ad_button_border_width
|
||||||
this.border.setStrokeWidth(borderWidth);
|
this.border.setStrokeWidth(borderWidth);
|
||||||
this.border.setStyle(Paint.Style.STROKE);
|
this.border.setStyle(Paint.Style.STROKE);
|
||||||
TextView skipSponsorText = (TextView)this.findViewById(getIdentifier(context, "skip_sponsor_button_text", "id")); // id:skip_ad_button_text
|
TextView skipSponsorText = (TextView) this.findViewById(getIdentifier(context, "skip_sponsor_button_text", "id")); // id:skip_ad_button_text
|
||||||
this.skipSponsorTextView = skipSponsorText;
|
this.skipSponsorTextView = skipSponsorText;
|
||||||
this.skipSponsorTextViewText = skipSponsorText.getText();
|
this.skipSponsorTextViewText = skipSponsorText.getText();
|
||||||
this.currentTextColor = this.skipSponsorTextView.getCurrentTextColor();
|
this.currentTextColor = this.skipSponsorTextView.getCurrentTextColor();
|
||||||
@ -93,9 +90,7 @@ public class SkipSponsorButton extends FrameLayout {
|
|||||||
this.skipSponsorBtnContainer.setOnClickListener(new View.OnClickListener() {
|
this.skipSponsorBtnContainer.setOnClickListener(new View.OnClickListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onClick(View v) {
|
public void onClick(View v) {
|
||||||
if (debug) {
|
LogHelper.debug("SkipSponsorButton", "Skip button clicked");
|
||||||
Log.d(TAG, "Skip button clicked");
|
|
||||||
}
|
|
||||||
PlayerController.onSkipSponsorClicked();
|
PlayerController.onSkipSponsorClicked();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@ -107,13 +102,13 @@ public class SkipSponsorButton extends FrameLayout {
|
|||||||
int height = this.skipSponsorBtnContainer.getHeight();
|
int height = this.skipSponsorBtnContainer.getHeight();
|
||||||
int top = this.skipSponsorBtnContainer.getTop();
|
int top = this.skipSponsorBtnContainer.getTop();
|
||||||
int left = this.skipSponsorBtnContainer.getLeft();
|
int left = this.skipSponsorBtnContainer.getLeft();
|
||||||
float floatLeft = (float)left;
|
float floatLeft = (float) left;
|
||||||
float floatTop = (float)top;
|
float floatTop = (float) top;
|
||||||
float floatWidth = (float)(left + width);
|
float floatWidth = (float) (left + width);
|
||||||
float floatHeight = (float)(top + height);
|
float floatHeight = (float) (top + height);
|
||||||
canvas.drawRect(floatLeft, floatTop, floatWidth, floatHeight, this.background);
|
canvas.drawRect(floatLeft, floatTop, floatWidth, floatHeight, this.background);
|
||||||
if (!this.highContrast) {
|
if (!this.highContrast) {
|
||||||
canvas.drawLines(new float[] { floatWidth, floatTop, floatLeft, floatTop, floatLeft, floatTop, floatLeft, floatHeight, floatLeft, floatHeight, floatWidth, floatHeight }, this.border);
|
canvas.drawLines(new float[]{floatWidth, floatTop, floatLeft, floatTop, floatLeft, floatTop, floatLeft, floatHeight, floatLeft, floatHeight, floatWidth, floatHeight}, this.border);
|
||||||
}
|
}
|
||||||
|
|
||||||
super.dispatchDraw(canvas);
|
super.dispatchDraw(canvas);
|
@ -1,19 +1,17 @@
|
|||||||
package fi.vanced.libraries.youtube.ui;
|
package app.revanced.integrations.sponsorblock.player.ui;
|
||||||
|
|
||||||
import static fi.razerman.youtube.XGlobals.debug;
|
|
||||||
|
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.util.Log;
|
|
||||||
import android.view.LayoutInflater;
|
import android.view.LayoutInflater;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.view.ViewGroup;
|
import android.view.ViewGroup;
|
||||||
import android.widget.ImageView;
|
import android.widget.ImageView;
|
||||||
import android.widget.TextView;
|
import android.widget.TextView;
|
||||||
|
|
||||||
import fi.vanced.utils.VancedUtils;
|
import app.revanced.integrations.utils.LogHelper;
|
||||||
|
import app.revanced.integrations.utils.ReVancedUtils;
|
||||||
|
|
||||||
public abstract class SlimButton implements View.OnClickListener {
|
public abstract class SlimButton implements View.OnClickListener {
|
||||||
private static final String TAG = "VI - Slim - Button";
|
|
||||||
public static int SLIM_METADATA_BUTTON_ID;
|
public static int SLIM_METADATA_BUTTON_ID;
|
||||||
public final View view;
|
public final View view;
|
||||||
public final Context context;
|
public final Context context;
|
||||||
@ -23,18 +21,16 @@ public abstract class SlimButton implements View.OnClickListener {
|
|||||||
private boolean viewAdded = false;
|
private boolean viewAdded = false;
|
||||||
|
|
||||||
static {
|
static {
|
||||||
SLIM_METADATA_BUTTON_ID = VancedUtils.getIdentifier("slim_metadata_button", "layout");
|
SLIM_METADATA_BUTTON_ID = ReVancedUtils.getIdentifier("slim_metadata_button", "layout");
|
||||||
}
|
}
|
||||||
|
|
||||||
public SlimButton(Context context, ViewGroup container, int id, boolean visible) {
|
public SlimButton(Context context, ViewGroup container, int id, boolean visible) {
|
||||||
if (debug) {
|
LogHelper.debug("SlimButton", "Adding button with id " + id + " and visibility of " + visible);
|
||||||
Log.d(TAG, "Adding button with id " + id + " and visibility of " + visible);
|
|
||||||
}
|
|
||||||
this.context = context;
|
this.context = context;
|
||||||
this.container = container;
|
this.container = container;
|
||||||
view = LayoutInflater.from(context).inflate(id, container, false);
|
view = LayoutInflater.from(context).inflate(id, container, false);
|
||||||
button_icon = (ImageView)view.findViewById(VancedUtils.getIdentifier("button_icon", "id"));
|
button_icon = (ImageView) view.findViewById(ReVancedUtils.getIdentifier("button_icon", "id"));
|
||||||
button_text = (TextView)view.findViewById(VancedUtils.getIdentifier("button_text", "id"));
|
button_text = (TextView) view.findViewById(ReVancedUtils.getIdentifier("button_text", "id"));
|
||||||
|
|
||||||
view.setOnClickListener(this);
|
view.setOnClickListener(this);
|
||||||
|
|
||||||
@ -46,15 +42,13 @@ public abstract class SlimButton implements View.OnClickListener {
|
|||||||
if (!viewAdded && visible) {
|
if (!viewAdded && visible) {
|
||||||
container.addView(view);
|
container.addView(view);
|
||||||
viewAdded = true;
|
viewAdded = true;
|
||||||
}
|
} else if (viewAdded && !visible) {
|
||||||
else if (viewAdded && !visible) {
|
|
||||||
container.removeView(view);
|
container.removeView(view);
|
||||||
viewAdded = false;
|
viewAdded = false;
|
||||||
}
|
}
|
||||||
setContainerVisibility();
|
setContainerVisibility();
|
||||||
}
|
} catch (Exception ex) {
|
||||||
catch (Exception ex) {
|
LogHelper.printException("SlimButton", "Error while changing button visibility", ex);
|
||||||
Log.e(TAG, "Error while changing button visibility", ex);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -1,25 +1,25 @@
|
|||||||
package fi.vanced.libraries.youtube.ui;
|
package app.revanced.integrations.sponsorblock.player.ui;
|
||||||
|
|
||||||
import static fi.razerman.youtube.XGlobals.debug;
|
import static app.revanced.integrations.sponsorblock.SponsorBlockSettings.PREFERENCES_KEY_BROWSER_BUTTON;
|
||||||
import static pl.jakubweg.SponsorBlockSettings.PREFERENCES_KEY_BROWSER_BUTTON;
|
import static app.revanced.integrations.sponsorblock.SponsorBlockSettings.PREFERENCES_KEY_SPONSOR_BLOCK_ENABLED;
|
||||||
import static pl.jakubweg.SponsorBlockSettings.PREFERENCES_KEY_SPONSOR_BLOCK_ENABLED;
|
|
||||||
|
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.content.SharedPreferences;
|
import android.content.SharedPreferences;
|
||||||
import android.util.AttributeSet;
|
import android.util.AttributeSet;
|
||||||
import android.util.Log;
|
|
||||||
import android.view.ViewGroup;
|
import android.view.ViewGroup;
|
||||||
|
|
||||||
import com.google.android.apps.youtube.app.ui.SlimMetadataScrollableButtonContainerLayout;
|
import com.google.android.apps.youtube.app.ui.SlimMetadataScrollableButtonContainerLayout;
|
||||||
|
|
||||||
import fi.vanced.libraries.youtube.whitelisting.Whitelist;
|
import app.revanced.integrations.adremover.whitelist.Whitelist;
|
||||||
import fi.vanced.libraries.youtube.whitelisting.WhitelistType;
|
import app.revanced.integrations.adremover.whitelist.WhitelistType;
|
||||||
import fi.vanced.utils.SharedPrefUtils;
|
import app.revanced.integrations.utils.LogHelper;
|
||||||
import fi.vanced.utils.VancedUtils;
|
import app.revanced.integrations.utils.SharedPrefHelper;
|
||||||
import pl.jakubweg.SponsorBlockSettings;
|
import app.revanced.integrations.utils.ReVancedUtils;
|
||||||
|
import app.revanced.integrations.sponsorblock.SponsorBlockSettings;
|
||||||
|
|
||||||
public class SlimButtonContainer extends SlimMetadataScrollableButtonContainerLayout {
|
public class SlimButtonContainer extends SlimMetadataScrollableButtonContainerLayout {
|
||||||
private static final String TAG = "VI - Slim - Container";
|
|
||||||
private ViewGroup container;
|
private ViewGroup container;
|
||||||
private CopyButton copyButton;
|
private CopyButton copyButton;
|
||||||
private CopyWithTimestamp copyWithTimestampButton;
|
private CopyWithTimestamp copyWithTimestampButton;
|
||||||
@ -49,8 +49,9 @@ public class SlimButtonContainer extends SlimMetadataScrollableButtonContainerLa
|
|||||||
|
|
||||||
public void initialize(Context context) {
|
public void initialize(Context context) {
|
||||||
try {
|
try {
|
||||||
container = this.findViewById(VancedUtils.getIdentifier("button_container_vanced", "id"));
|
container = this.findViewById(ReVancedUtils.getIdentifier("button_container_vanced", "id"));
|
||||||
if (container == null) throw new Exception("Unable to initialize the button container because the button_container_vanced couldn't be found");
|
if (container == null)
|
||||||
|
throw new Exception("Unable to initialize the button container because the button_container_vanced couldn't be found");
|
||||||
|
|
||||||
copyButton = new CopyButton(context, this);
|
copyButton = new CopyButton(context, this);
|
||||||
copyWithTimestampButton = new CopyWithTimestamp(context, this);
|
copyWithTimestampButton = new CopyWithTimestamp(context, this);
|
||||||
@ -60,18 +61,15 @@ public class SlimButtonContainer extends SlimMetadataScrollableButtonContainerLa
|
|||||||
new SponsorBlockVoting(context, this);
|
new SponsorBlockVoting(context, this);
|
||||||
|
|
||||||
addSharedPrefsChangeListener();
|
addSharedPrefsChangeListener();
|
||||||
}
|
} catch (Exception ex) {
|
||||||
catch (Exception ex) {
|
LogHelper.printException("SlimButtonContainer", "Unable to initialize the button container", ex);
|
||||||
Log.e(TAG, "Unable to initialize the button container", ex);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void addSharedPrefsChangeListener() {
|
private void addSharedPrefsChangeListener() {
|
||||||
listener = (sharedPreferences, key) -> {
|
listener = (sharedPreferences, key) -> {
|
||||||
try {
|
try {
|
||||||
if (debug) {
|
LogHelper.debug("SlimButtonContainer", String.format("SharedPreference changed with key %s", key));
|
||||||
Log.d(TAG, String.format("SharedPreference changed with key %s", key));
|
|
||||||
}
|
|
||||||
if ("pref_copy_video_url_button_list".equals(key) && copyButton != null) {
|
if ("pref_copy_video_url_button_list".equals(key) && copyButton != null) {
|
||||||
copyButton.setVisible(ButtonVisibility.isVisibleInContainer(context, "pref_copy_video_url_button_list"));
|
copyButton.setVisible(ButtonVisibility.isVisibleInContainer(context, "pref_copy_video_url_button_list"));
|
||||||
return;
|
return;
|
||||||
@ -84,8 +82,7 @@ public class SlimButtonContainer extends SlimMetadataScrollableButtonContainerLa
|
|||||||
if (sbWhitelistButton != null) {
|
if (sbWhitelistButton != null) {
|
||||||
if (SponsorBlockSettings.isSponsorBlockEnabled) {
|
if (SponsorBlockSettings.isSponsorBlockEnabled) {
|
||||||
toggleWhitelistButton();
|
toggleWhitelistButton();
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
Whitelist.setEnabled(WhitelistType.SPONSORBLOCK, false);
|
Whitelist.setEnabled(WhitelistType.SPONSORBLOCK, false);
|
||||||
sbWhitelistButton.setVisible(false);
|
sbWhitelistButton.setVisible(false);
|
||||||
}
|
}
|
||||||
@ -93,8 +90,7 @@ public class SlimButtonContainer extends SlimMetadataScrollableButtonContainerLa
|
|||||||
if (sbBrowserButton != null) {
|
if (sbBrowserButton != null) {
|
||||||
if (SponsorBlockSettings.isSponsorBlockEnabled) {
|
if (SponsorBlockSettings.isSponsorBlockEnabled) {
|
||||||
toggleBrowserButton();
|
toggleBrowserButton();
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
sbBrowserButton.setVisible(false);
|
sbBrowserButton.setVisible(false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -106,7 +102,7 @@ public class SlimButtonContainer extends SlimMetadataScrollableButtonContainerLa
|
|||||||
WhitelistType whitelistAds = WhitelistType.ADS;
|
WhitelistType whitelistAds = WhitelistType.ADS;
|
||||||
String adsEnabledPreferenceName = whitelistAds.getPreferenceEnabledName();
|
String adsEnabledPreferenceName = whitelistAds.getPreferenceEnabledName();
|
||||||
if (adsEnabledPreferenceName.equals(key) && adBlockButton != null) {
|
if (adsEnabledPreferenceName.equals(key) && adBlockButton != null) {
|
||||||
boolean enabled = SharedPrefUtils.getBoolean(context, whitelistAds.getSharedPreferencesName(), adsEnabledPreferenceName, false);
|
boolean enabled = SharedPrefHelper.getBoolean(context, SharedPrefHelper.SharedPrefNames.YOUTUBE, adsEnabledPreferenceName, false);
|
||||||
Whitelist.setEnabled(whitelistAds, enabled);
|
Whitelist.setEnabled(whitelistAds, enabled);
|
||||||
adBlockButton.setVisible(enabled);
|
adBlockButton.setVisible(enabled);
|
||||||
return;
|
return;
|
||||||
@ -115,27 +111,26 @@ public class SlimButtonContainer extends SlimMetadataScrollableButtonContainerLa
|
|||||||
toggleWhitelistButton();
|
toggleWhitelistButton();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
} catch (Exception ex) {
|
||||||
catch (Exception ex) {
|
LogHelper.printException("SlimButtonContainer", "Error handling shared preference change", ex);
|
||||||
Log.e(TAG, "Error handling shared preference change", ex);
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
context.getSharedPreferences(WhitelistType.ADS.getSharedPreferencesName(), Context.MODE_PRIVATE)
|
context.getSharedPreferences(WhitelistType.ADS.getSharedPreferencesName().getName(), Context.MODE_PRIVATE)
|
||||||
.registerOnSharedPreferenceChangeListener(listener);
|
.registerOnSharedPreferenceChangeListener(listener);
|
||||||
context.getSharedPreferences(WhitelistType.SPONSORBLOCK.getSharedPreferencesName(), Context.MODE_PRIVATE)
|
context.getSharedPreferences(WhitelistType.SPONSORBLOCK.getSharedPreferencesName().getName(), Context.MODE_PRIVATE)
|
||||||
.registerOnSharedPreferenceChangeListener(listener);
|
.registerOnSharedPreferenceChangeListener(listener);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void toggleWhitelistButton() {
|
private void toggleWhitelistButton() {
|
||||||
WhitelistType whitelistSB = WhitelistType.SPONSORBLOCK;
|
WhitelistType whitelistSB = WhitelistType.SPONSORBLOCK;
|
||||||
String sbEnabledPreferenceName = whitelistSB.getPreferenceEnabledName();
|
String sbEnabledPreferenceName = whitelistSB.getPreferenceEnabledName();
|
||||||
boolean enabled = SharedPrefUtils.getBoolean(context, whitelistSB.getSharedPreferencesName(), sbEnabledPreferenceName, false);
|
boolean enabled = SharedPrefHelper.getBoolean(context, SharedPrefHelper.SharedPrefNames.SPONSOR_BLOCK, sbEnabledPreferenceName, false);
|
||||||
Whitelist.setEnabled(whitelistSB, enabled);
|
Whitelist.setEnabled(whitelistSB, enabled);
|
||||||
sbWhitelistButton.setVisible(enabled);
|
sbWhitelistButton.setVisible(enabled);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void toggleBrowserButton() {
|
private void toggleBrowserButton() {
|
||||||
sbBrowserButton.setVisible(SharedPrefUtils.getBoolean(context, SponsorBlockSettings.PREFERENCES_NAME, PREFERENCES_KEY_BROWSER_BUTTON, false));
|
sbBrowserButton.setVisible(SharedPrefHelper.getBoolean(context, SharedPrefHelper.SharedPrefNames.SPONSOR_BLOCK, PREFERENCES_KEY_BROWSER_BUTTON, false));
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -1,7 +1,6 @@
|
|||||||
package fi.vanced.libraries.youtube.sponsors.player.ui;
|
package app.revanced.integrations.sponsorblock.player.ui;
|
||||||
|
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.util.Log;
|
|
||||||
import android.view.LayoutInflater;
|
import android.view.LayoutInflater;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.view.ViewGroup;
|
import android.view.ViewGroup;
|
||||||
@ -11,12 +10,12 @@ import com.google.android.apps.youtube.app.YouTubeTikTokRoot_Application;
|
|||||||
|
|
||||||
import java.lang.ref.WeakReference;
|
import java.lang.ref.WeakReference;
|
||||||
|
|
||||||
import fi.razerman.youtube.Helpers.XSwipeHelper;
|
import app.revanced.integrations.sponsorblock.player.PlayerType;
|
||||||
|
import app.revanced.integrations.utils.LogHelper;
|
||||||
import static fi.razerman.youtube.XGlobals.debug;
|
import app.revanced.integrations.utils.SwipeHelper;
|
||||||
|
|
||||||
public class SponsorBlockView {
|
public class SponsorBlockView {
|
||||||
static String TAG = "SponsorBlockView";
|
|
||||||
static RelativeLayout inlineSponsorOverlay;
|
static RelativeLayout inlineSponsorOverlay;
|
||||||
static ViewGroup _youtubeOverlaysLayout;
|
static ViewGroup _youtubeOverlaysLayout;
|
||||||
static WeakReference<SkipSponsorButton> _skipSponsorButton = new WeakReference<>(null);
|
static WeakReference<SkipSponsorButton> _skipSponsorButton = new WeakReference<>(null);
|
||||||
@ -25,22 +24,20 @@ public class SponsorBlockView {
|
|||||||
|
|
||||||
public static void initialize(Object viewGroup) {
|
public static void initialize(Object viewGroup) {
|
||||||
try {
|
try {
|
||||||
if(debug){
|
LogHelper.debug("SponsorblockView", "initializing");
|
||||||
Log.d(TAG, "initializing");
|
|
||||||
}
|
|
||||||
|
|
||||||
_youtubeOverlaysLayout = (ViewGroup) viewGroup;
|
_youtubeOverlaysLayout = (ViewGroup) viewGroup;
|
||||||
|
|
||||||
addView();
|
addView();
|
||||||
}
|
} catch (Exception ex) {
|
||||||
catch (Exception ex) {
|
LogHelper.printException("SponsorblockView", "Unable to set ViewGroup", ex);
|
||||||
Log.e(TAG, "Unable to set ViewGroup", ex);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void showSkipButton() {
|
public static void showSkipButton() {
|
||||||
skipSponsorButtonVisibility(true);
|
skipSponsorButtonVisibility(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void hideSkipButton() {
|
public static void hideSkipButton() {
|
||||||
skipSponsorButtonVisibility(false);
|
skipSponsorButtonVisibility(false);
|
||||||
}
|
}
|
||||||
@ -48,15 +45,16 @@ public class SponsorBlockView {
|
|||||||
public static void showNewSegmentLayout() {
|
public static void showNewSegmentLayout() {
|
||||||
newSegmentLayoutVisibility(true);
|
newSegmentLayoutVisibility(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void hideNewSegmentLayout() {
|
public static void hideNewSegmentLayout() {
|
||||||
newSegmentLayoutVisibility(false);
|
newSegmentLayoutVisibility(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void playerTypeChanged(String playerType) {
|
public static void playerTypeChanged(PlayerType playerType) {
|
||||||
try {
|
try {
|
||||||
shouldShowOnPlayerType = playerType.equalsIgnoreCase("WATCH_WHILE_FULLSCREEN") || playerType.equalsIgnoreCase("WATCH_WHILE_MAXIMIZED");
|
shouldShowOnPlayerType = (playerType == PlayerType.WATCH_WHILE_FULLSCREEN || playerType == PlayerType.WATCH_WHILE_MAXIMIZED);
|
||||||
|
|
||||||
if (playerType.equalsIgnoreCase("WATCH_WHILE_FULLSCREEN")) {
|
if (playerType == PlayerType.WATCH_WHILE_FULLSCREEN) {
|
||||||
setSkipBtnMargins(true);
|
setSkipBtnMargins(true);
|
||||||
setNewSegmentLayoutMargins(true);
|
setNewSegmentLayoutMargins(true);
|
||||||
return;
|
return;
|
||||||
@ -64,9 +62,8 @@ public class SponsorBlockView {
|
|||||||
|
|
||||||
setSkipBtnMargins(false);
|
setSkipBtnMargins(false);
|
||||||
setNewSegmentLayoutMargins(false);
|
setNewSegmentLayoutMargins(false);
|
||||||
}
|
} catch (Exception ex) {
|
||||||
catch (Exception ex) {
|
LogHelper.printException("SponsorblockView", "Player type changed caused a crash.", ex);
|
||||||
Log.e(TAG, "Player type changed caused a crash.", ex);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -91,13 +88,13 @@ public class SponsorBlockView {
|
|||||||
private static void setSkipBtnMargins(boolean fullScreen) {
|
private static void setSkipBtnMargins(boolean fullScreen) {
|
||||||
SkipSponsorButton skipSponsorButton = _skipSponsorButton.get();
|
SkipSponsorButton skipSponsorButton = _skipSponsorButton.get();
|
||||||
if (skipSponsorButton == null) {
|
if (skipSponsorButton == null) {
|
||||||
Log.e(TAG, "Unable to setSkipBtnMargins");
|
LogHelper.printException("SponsorblockView", "Unable to setSkipBtnMargins");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
RelativeLayout.LayoutParams params = (RelativeLayout.LayoutParams) skipSponsorButton.getLayoutParams();
|
RelativeLayout.LayoutParams params = (RelativeLayout.LayoutParams) skipSponsorButton.getLayoutParams();
|
||||||
if (params == null) {
|
if (params == null) {
|
||||||
Log.e(TAG, "Unable to setSkipBtnMargins");
|
LogHelper.printException("SponsorblockView", "Unable to setSkipBtnMargins");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
params.bottomMargin = fullScreen ? skipSponsorButton.ctaBottomMargin : skipSponsorButton.defaultBottomMargin;
|
params.bottomMargin = fullScreen ? skipSponsorButton.ctaBottomMargin : skipSponsorButton.defaultBottomMargin;
|
||||||
@ -107,7 +104,7 @@ public class SponsorBlockView {
|
|||||||
private static void skipSponsorButtonVisibility(boolean visible) {
|
private static void skipSponsorButtonVisibility(boolean visible) {
|
||||||
SkipSponsorButton skipSponsorButton = _skipSponsorButton.get();
|
SkipSponsorButton skipSponsorButton = _skipSponsorButton.get();
|
||||||
if (skipSponsorButton == null) {
|
if (skipSponsorButton == null) {
|
||||||
Log.e(TAG, "Unable to skipSponsorButtonVisibility");
|
LogHelper.printException("SponsorblockView", "Unable to skipSponsorButtonVisibility");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -120,13 +117,13 @@ public class SponsorBlockView {
|
|||||||
private static void setNewSegmentLayoutMargins(boolean fullScreen) {
|
private static void setNewSegmentLayoutMargins(boolean fullScreen) {
|
||||||
NewSegmentLayout newSegmentLayout = _newSegmentLayout.get();
|
NewSegmentLayout newSegmentLayout = _newSegmentLayout.get();
|
||||||
if (newSegmentLayout == null) {
|
if (newSegmentLayout == null) {
|
||||||
Log.e(TAG, "Unable to setNewSegmentLayoutMargins");
|
LogHelper.printException("SponsorblockView", "Unable to setNewSegmentLayoutMargins");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
RelativeLayout.LayoutParams params = (RelativeLayout.LayoutParams) newSegmentLayout.getLayoutParams();
|
RelativeLayout.LayoutParams params = (RelativeLayout.LayoutParams) newSegmentLayout.getLayoutParams();
|
||||||
if (params == null) {
|
if (params == null) {
|
||||||
Log.e(TAG, "Unable to setNewSegmentLayoutMargins");
|
LogHelper.printException("SponsorblockView", "Unable to setNewSegmentLayoutMargins");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
params.bottomMargin = fullScreen ? newSegmentLayout.ctaBottomMargin : newSegmentLayout.defaultBottomMargin;
|
params.bottomMargin = fullScreen ? newSegmentLayout.ctaBottomMargin : newSegmentLayout.defaultBottomMargin;
|
||||||
@ -136,7 +133,7 @@ public class SponsorBlockView {
|
|||||||
private static void newSegmentLayoutVisibility(boolean visible) {
|
private static void newSegmentLayoutVisibility(boolean visible) {
|
||||||
NewSegmentLayout newSegmentLayout = _newSegmentLayout.get();
|
NewSegmentLayout newSegmentLayout = _newSegmentLayout.get();
|
||||||
if (newSegmentLayout == null) {
|
if (newSegmentLayout == null) {
|
||||||
Log.e(TAG, "Unable to newSegmentLayoutVisibility");
|
LogHelper.printException("SponsorblockView", "Unable to newSegmentLayoutVisibility");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -155,18 +152,15 @@ public class SponsorBlockView {
|
|||||||
|
|
||||||
private static void checkLayout() {
|
private static void checkLayout() {
|
||||||
if (inlineSponsorOverlay.getHeight() == 0) {
|
if (inlineSponsorOverlay.getHeight() == 0) {
|
||||||
View layout = XSwipeHelper.nextGenWatchLayout.findViewById(getIdentifier("player_overlays", "id"));
|
View layout = SwipeHelper.nextGenWatchLayout.findViewById(getIdentifier("player_overlays", "id"));
|
||||||
if (layout != null) {
|
|
||||||
|
if (layout == null) {
|
||||||
|
LogHelper.debug("Settings", "player_overlays was not found for SB");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
initialize(layout);
|
initialize(layout);
|
||||||
|
LogHelper.debug("Settings", "player_overlays refreshed for SB");
|
||||||
if (debug){
|
|
||||||
Log.d("XGlobals", "player_overlays refreshed for SB");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else if (debug){
|
|
||||||
Log.d("XGlobals", "player_overlays was not found for SB");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -1,4 +1,4 @@
|
|||||||
package fi.vanced.libraries.youtube.ui;
|
package app.revanced.integrations.sponsorblock.player.ui;
|
||||||
|
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
@ -7,7 +7,7 @@ import android.widget.Toast;
|
|||||||
|
|
||||||
import com.google.android.apps.youtube.app.YouTubeTikTokRoot_Application;
|
import com.google.android.apps.youtube.app.YouTubeTikTokRoot_Application;
|
||||||
|
|
||||||
import fi.vanced.utils.VancedUtils;
|
import app.revanced.integrations.utils.ReVancedUtils;
|
||||||
|
|
||||||
public class SponsorBlockVoting extends SlimButton {
|
public class SponsorBlockVoting extends SlimButton {
|
||||||
public SponsorBlockVoting(Context context, ViewGroup container) {
|
public SponsorBlockVoting(Context context, ViewGroup container) {
|
||||||
@ -17,7 +17,7 @@ public class SponsorBlockVoting extends SlimButton {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void initialize() {
|
private void initialize() {
|
||||||
this.button_icon.setImageResource(VancedUtils.getIdentifier("vanced_sb_voting", "drawable"));
|
this.button_icon.setImageResource(ReVancedUtils.getIdentifier("vanced_sb_voting", "drawable"));
|
||||||
this.button_text.setText("SB Voting");
|
this.button_text.setText("SB Voting");
|
||||||
}
|
}
|
||||||
|
|
@ -1,4 +1,4 @@
|
|||||||
package fi.vanced.libraries.youtube.ui;
|
package app.revanced.integrations.sponsorblock.player.ui;
|
||||||
|
|
||||||
public enum Visibility {
|
public enum Visibility {
|
||||||
NONE,
|
NONE,
|
@ -1,10 +1,10 @@
|
|||||||
package pl.jakubweg.requests;
|
package app.revanced.integrations.sponsorblock.requests;
|
||||||
|
|
||||||
import static android.text.Html.fromHtml;
|
import static android.text.Html.fromHtml;
|
||||||
import static fi.vanced.utils.VancedUtils.runOnMainThread;
|
import static app.revanced.integrations.utils.ReVancedUtils.runOnMainThread;
|
||||||
import static pl.jakubweg.SponsorBlockUtils.timeWithoutSegments;
|
import static app.revanced.integrations.sponsorblock.SponsorBlockUtils.timeWithoutSegments;
|
||||||
import static pl.jakubweg.SponsorBlockUtils.videoHasSegments;
|
import static app.revanced.integrations.sponsorblock.SponsorBlockUtils.videoHasSegments;
|
||||||
import static pl.jakubweg.StringRef.str;
|
import static app.revanced.integrations.sponsorblock.StringRef.str;
|
||||||
|
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.content.SharedPreferences;
|
import android.content.SharedPreferences;
|
||||||
@ -25,19 +25,21 @@ import java.util.List;
|
|||||||
import java.util.Locale;
|
import java.util.Locale;
|
||||||
import java.util.concurrent.TimeUnit;
|
import java.util.concurrent.TimeUnit;
|
||||||
|
|
||||||
import fi.vanced.utils.requests.Requester;
|
import app.revanced.integrations.adremover.whitelist.requests.Requester;
|
||||||
import fi.vanced.utils.requests.Route;
|
import app.revanced.integrations.adremover.whitelist.requests.Route;
|
||||||
import pl.jakubweg.PlayerController;
|
import app.revanced.integrations.sponsorblock.PlayerController;
|
||||||
import pl.jakubweg.SponsorBlockSettings;
|
import app.revanced.integrations.sponsorblock.SponsorBlockSettings;
|
||||||
import pl.jakubweg.SponsorBlockUtils;
|
import app.revanced.integrations.sponsorblock.SponsorBlockUtils;
|
||||||
import pl.jakubweg.SponsorBlockUtils.VoteOption;
|
import app.revanced.integrations.sponsorblock.SponsorBlockUtils.VoteOption;
|
||||||
import pl.jakubweg.objects.SponsorSegment;
|
import app.revanced.integrations.sponsorblock.objects.SponsorSegment;
|
||||||
import pl.jakubweg.objects.UserStats;
|
import app.revanced.integrations.sponsorblock.objects.UserStats;
|
||||||
|
import app.revanced.integrations.utils.SharedPrefHelper;
|
||||||
|
|
||||||
public class SBRequester {
|
public class SBRequester {
|
||||||
private static final String TIME_TEMPLATE = "%.3f";
|
private static final String TIME_TEMPLATE = "%.3f";
|
||||||
|
|
||||||
private SBRequester() {}
|
private SBRequester() {
|
||||||
|
}
|
||||||
|
|
||||||
public static synchronized SponsorSegment[] getSegments(String videoId) {
|
public static synchronized SponsorSegment[] getSegments(String videoId) {
|
||||||
List<SponsorSegment> segments = new ArrayList<>();
|
List<SponsorSegment> segments = new ArrayList<>();
|
||||||
@ -75,8 +77,7 @@ public class SBRequester {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
connection.disconnect();
|
connection.disconnect();
|
||||||
}
|
} catch (Exception ex) {
|
||||||
catch (Exception ex) {
|
|
||||||
ex.printStackTrace();
|
ex.printStackTrace();
|
||||||
}
|
}
|
||||||
return segments.toArray(new SponsorSegment[0]);
|
return segments.toArray(new SponsorSegment[0]);
|
||||||
@ -109,8 +110,7 @@ public class SBRequester {
|
|||||||
}
|
}
|
||||||
runOnMainThread(toastRunnable);
|
runOnMainThread(toastRunnable);
|
||||||
connection.disconnect();
|
connection.disconnect();
|
||||||
}
|
} catch (Exception ex) {
|
||||||
catch (Exception ex) {
|
|
||||||
ex.printStackTrace();
|
ex.printStackTrace();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -119,8 +119,7 @@ public class SBRequester {
|
|||||||
try {
|
try {
|
||||||
HttpURLConnection connection = getConnectionFromRoute(SBRoutes.VIEWED_SEGMENT, segment.UUID);
|
HttpURLConnection connection = getConnectionFromRoute(SBRoutes.VIEWED_SEGMENT, segment.UUID);
|
||||||
connection.disconnect();
|
connection.disconnect();
|
||||||
}
|
} catch (Exception ex) {
|
||||||
catch (Exception ex) {
|
|
||||||
ex.printStackTrace();
|
ex.printStackTrace();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -152,8 +151,7 @@ public class SBRequester {
|
|||||||
}
|
}
|
||||||
runOnMainThread(() -> Toast.makeText(context, SponsorBlockUtils.messageToToast, Toast.LENGTH_LONG).show());
|
runOnMainThread(() -> Toast.makeText(context, SponsorBlockUtils.messageToToast, Toast.LENGTH_LONG).show());
|
||||||
connection.disconnect();
|
connection.disconnect();
|
||||||
}
|
} catch (Exception ex) {
|
||||||
catch (Exception ex) {
|
|
||||||
ex.printStackTrace();
|
ex.printStackTrace();
|
||||||
}
|
}
|
||||||
}).start();
|
}).start();
|
||||||
@ -171,8 +169,7 @@ public class SBRequester {
|
|||||||
UserStats stats = new UserStats(json.getString("userName"), json.getDouble("minutesSaved"), json.getInt("segmentCount"),
|
UserStats stats = new UserStats(json.getString("userName"), json.getDouble("minutesSaved"), json.getInt("segmentCount"),
|
||||||
json.getInt("viewCount"));
|
json.getInt("viewCount"));
|
||||||
SponsorBlockUtils.addUserStats(category, loadingPreference, stats);
|
SponsorBlockUtils.addUserStats(category, loadingPreference, stats);
|
||||||
}
|
} catch (Exception ex) {
|
||||||
catch (Exception ex) {
|
|
||||||
ex.printStackTrace();
|
ex.printStackTrace();
|
||||||
}
|
}
|
||||||
}).start();
|
}).start();
|
||||||
@ -190,14 +187,12 @@ public class SBRequester {
|
|||||||
preference.setTitle(fromHtml(str("stats_username", username)));
|
preference.setTitle(fromHtml(str("stats_username", username)));
|
||||||
preference.setText(username);
|
preference.setText(username);
|
||||||
});
|
});
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
SponsorBlockUtils.messageToToast = str("stats_username_change_unknown_error", responseCode, connection.getResponseMessage());
|
SponsorBlockUtils.messageToToast = str("stats_username_change_unknown_error", responseCode, connection.getResponseMessage());
|
||||||
}
|
}
|
||||||
runOnMainThread(toastRunnable);
|
runOnMainThread(toastRunnable);
|
||||||
connection.disconnect();
|
connection.disconnect();
|
||||||
}
|
} catch (Exception ex) {
|
||||||
catch (Exception ex) {
|
|
||||||
ex.printStackTrace();
|
ex.printStackTrace();
|
||||||
}
|
}
|
||||||
}).start();
|
}).start();
|
||||||
@ -214,12 +209,11 @@ public class SBRequester {
|
|||||||
SponsorBlockSettings.vip = vip;
|
SponsorBlockSettings.vip = vip;
|
||||||
SponsorBlockSettings.lastVipCheck = now;
|
SponsorBlockSettings.lastVipCheck = now;
|
||||||
|
|
||||||
SharedPreferences.Editor edit = SponsorBlockSettings.getPreferences(YouTubeTikTokRoot_Application.getAppContext()).edit();
|
SharedPreferences.Editor edit = SharedPrefHelper.getPreferences(YouTubeTikTokRoot_Application.getAppContext(), SharedPrefHelper.SharedPrefNames.SPONSOR_BLOCK).edit();
|
||||||
edit.putString(SponsorBlockSettings.PREFERENCES_KEY_LAST_VIP_CHECK, String.valueOf(now));
|
edit.putString(SponsorBlockSettings.PREFERENCES_KEY_LAST_VIP_CHECK, String.valueOf(now));
|
||||||
edit.putBoolean(SponsorBlockSettings.PREFERENCES_KEY_IS_VIP, vip);
|
edit.putBoolean(SponsorBlockSettings.PREFERENCES_KEY_IS_VIP, vip);
|
||||||
edit.apply();
|
edit.apply();
|
||||||
}
|
} catch (Exception ex) {
|
||||||
catch (Exception ex) {
|
|
||||||
ex.printStackTrace();
|
ex.printStackTrace();
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -0,0 +1,20 @@
|
|||||||
|
package app.revanced.integrations.sponsorblock.requests;
|
||||||
|
|
||||||
|
import static app.revanced.integrations.adremover.whitelist.requests.Route.Method.GET;
|
||||||
|
import static app.revanced.integrations.adremover.whitelist.requests.Route.Method.POST;
|
||||||
|
|
||||||
|
import app.revanced.integrations.adremover.whitelist.requests.Route;
|
||||||
|
|
||||||
|
public class SBRoutes {
|
||||||
|
public static final Route IS_USER_VIP = new Route(GET, "isUserVIP?userID={user_id}");
|
||||||
|
public static final Route GET_SEGMENTS = new Route(GET, "skipSegments?videoID={video_id}&categories={categories}");
|
||||||
|
public static final Route VIEWED_SEGMENT = new Route(POST, "viewedVideoSponsorTime?UUID={segment_id}");
|
||||||
|
public static final Route GET_USER_STATS = new Route(GET, "userInfo?userID={user_id}&values=[\"userName\", \"minutesSaved\", \"segmentCount\", \"viewCount\"]");
|
||||||
|
public static final Route CHANGE_USERNAME = new Route(POST, "setUsername?userID={user_id}&username={username}");
|
||||||
|
public static final Route SUBMIT_SEGMENTS = new Route(POST, "skipSegments?videoID={video_id}&userID={user_id}&startTime={start_time}&endTime={end_time}&category={category}&videoDuration={duration}");
|
||||||
|
public static final Route VOTE_ON_SEGMENT_QUALITY = new Route(POST, "voteOnSponsorTime?UUID={segment_id}&userID={user_id}&type={type}");
|
||||||
|
public static final Route VOTE_ON_SEGMENT_CATEGORY = new Route(POST, "voteOnSponsorTime?UUID={segment_id}&userID={user_id}&category={category}");
|
||||||
|
|
||||||
|
private SBRoutes() {
|
||||||
|
}
|
||||||
|
}
|
@ -1,33 +1,36 @@
|
|||||||
package fi.razerman.youtube;
|
package app.revanced.integrations.theme;
|
||||||
|
|
||||||
import android.app.Activity;
|
import android.app.Activity;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.util.Log;
|
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.view.ViewGroup;
|
import android.view.ViewGroup;
|
||||||
import android.widget.ImageButton;
|
import android.widget.ImageButton;
|
||||||
import android.widget.TextView;
|
import android.widget.TextView;
|
||||||
|
|
||||||
import com.google.android.apps.youtube.app.YouTubeTikTokRoot_Application;
|
import com.google.android.apps.youtube.app.YouTubeTikTokRoot_Application;
|
||||||
import fi.razerman.youtube.Helpers.XThemeHelpers;
|
|
||||||
import fi.vanced.libraries.youtube.ryd.RYDFragment;
|
import app.revanced.integrations.utils.LogHelper;
|
||||||
import pl.jakubweg.SponsorBlockPreferenceFragment;
|
import app.revanced.integrations.settings.XSettingsFragment;
|
||||||
|
import app.revanced.integrations.ryd.RYDFragment;
|
||||||
|
import app.revanced.integrations.sponsorblock.SponsorBlockPreferenceFragment;
|
||||||
|
import app.revanced.integrations.utils.ThemeHelper;
|
||||||
|
|
||||||
/* loaded from: classes6.dex */
|
/* loaded from: classes6.dex */
|
||||||
public class XSettingActivity extends Activity {
|
public class XSettingActivity extends Activity {
|
||||||
static String TAG = "XSettingsActivity";
|
|
||||||
private static Context context;
|
private static Context context;
|
||||||
boolean currentTheme;
|
boolean currentTheme;
|
||||||
|
|
||||||
@Override // android.app.Activity
|
@Override // android.app.Activity
|
||||||
protected void onCreate(Bundle bundle) {
|
protected void onCreate(Bundle bundle) {
|
||||||
boolean isDarkTheme = XThemeHelpers.isDarkTheme();
|
boolean isDarkTheme = ThemeHelper.isDarkTheme();
|
||||||
this.currentTheme = isDarkTheme;
|
this.currentTheme = isDarkTheme;
|
||||||
if (isDarkTheme) {
|
if (isDarkTheme) {
|
||||||
Log.d("XSettingsActivity", "set Theme.YouTube.Settings.Dark");
|
LogHelper.debug("XSettingsActivity", "set Theme.YouTube.Settings.Dark");
|
||||||
setTheme(getIdentifier("Theme.YouTube.Settings.Dark", "style"));
|
setTheme(getIdentifier("Theme.YouTube.Settings.Dark", "style"));
|
||||||
} else {
|
} else {
|
||||||
Log.d("XSettingsActivity", "set Theme.YouTube.Settings");
|
LogHelper.debug("XSettingsActivity", "set Theme.YouTube.Settings");
|
||||||
setTheme(getIdentifier("Theme.YouTube.Settings", "style"));
|
setTheme(getIdentifier("Theme.YouTube.Settings", "style"));
|
||||||
}
|
}
|
||||||
super.onCreate(bundle);
|
super.onCreate(bundle);
|
||||||
@ -51,7 +54,7 @@ public class XSettingActivity extends Activity {
|
|||||||
try {
|
try {
|
||||||
getTextView((ViewGroup) findViewById(getIdentifier("toolbar", "id"))).setText(i);
|
getTextView((ViewGroup) findViewById(getIdentifier("toolbar", "id"))).setText(i);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
Log.e(TAG, "Couldn't set Toolbar title", e);
|
LogHelper.printException("XSettingsActivity", "Couldn't set Toolbar title", e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -59,14 +62,14 @@ public class XSettingActivity extends Activity {
|
|||||||
try {
|
try {
|
||||||
getTextView((ViewGroup) findViewById(getIdentifier("toolbar", "id"))).setText(str);
|
getTextView((ViewGroup) findViewById(getIdentifier("toolbar", "id"))).setText(str);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
Log.e(TAG, "Couldn't set Toolbar title", e);
|
LogHelper.printException("XSettingsActivity", "Couldn't set Toolbar title", e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void initImageButton(boolean z) {
|
private void initImageButton(boolean z) {
|
||||||
try {
|
try {
|
||||||
ImageButton imageButton = getImageButton((ViewGroup) findViewById(getIdentifier("toolbar", "id")));
|
ImageButton imageButton = getImageButton((ViewGroup) findViewById(getIdentifier("toolbar", "id")));
|
||||||
imageButton.setOnClickListener(new View.OnClickListener() { // from class: fi.razerman.youtube.XSettingActivity.1
|
imageButton.setOnClickListener(new View.OnClickListener() { // from class: app.revanced.integrations.theme.XSettingActivity.1
|
||||||
@Override // android.view.View.OnClickListener
|
@Override // android.view.View.OnClickListener
|
||||||
public void onClick(View view) {
|
public void onClick(View view) {
|
||||||
XSettingActivity.this.onBackPressed();
|
XSettingActivity.this.onBackPressed();
|
||||||
@ -74,7 +77,7 @@ public class XSettingActivity extends Activity {
|
|||||||
});
|
});
|
||||||
imageButton.setImageDrawable(getResources().getDrawable(getIdentifier(z ? "quantum_ic_arrow_back_white_24" : "quantum_ic_arrow_back_grey600_24", "drawable")));
|
imageButton.setImageDrawable(getResources().getDrawable(getIdentifier(z ? "quantum_ic_arrow_back_white_24" : "quantum_ic_arrow_back_grey600_24", "drawable")));
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
Log.e(TAG, "Couldn't set Toolbar click handler", e);
|
LogHelper.printException("XSettingsActivity", "Couldn't set Toolbar click handler", e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -116,7 +119,7 @@ public class XSettingActivity extends Activity {
|
|||||||
if (context2 != null) {
|
if (context2 != null) {
|
||||||
return context2;
|
return context2;
|
||||||
}
|
}
|
||||||
Log.e("WatchWhileActivity", "Context is null!");
|
LogHelper.printException("WatchWhileActivity", "Context is null!");
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -1,7 +1,9 @@
|
|||||||
package app.revanced.integrations;
|
package app.revanced.integrations.utils;
|
||||||
|
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.util.Log;
|
|
||||||
|
import app.revanced.integrations.utils.LogHelper;
|
||||||
|
|
||||||
|
|
||||||
public class Globals {
|
public class Globals {
|
||||||
public static Context context;
|
public static Context context;
|
||||||
@ -10,7 +12,7 @@ public class Globals {
|
|||||||
if (context != null) {
|
if (context != null) {
|
||||||
return context;
|
return context;
|
||||||
}
|
}
|
||||||
Log.e("Globals", "Context is null!");
|
LogHelper.printException("Globals", "Context is null!");
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -0,0 +1,31 @@
|
|||||||
|
package app.revanced.integrations.utils;
|
||||||
|
|
||||||
|
import android.util.Log;
|
||||||
|
|
||||||
|
import app.revanced.integrations.settings.Settings;
|
||||||
|
import app.revanced.integrations.settings.SettingsEnum;
|
||||||
|
|
||||||
|
public class LogHelper {
|
||||||
|
|
||||||
|
public static void debug(String tag, String message) {
|
||||||
|
if (SettingsEnum.DEBUG_BOOLEAN.getBoolean()) {
|
||||||
|
Log.d(tag, message);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void printException(String tag, String message, Throwable ex) {
|
||||||
|
Log.e(tag, message, ex);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void printException(String tag, String message) {
|
||||||
|
Log.e(tag, message);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void info(String tag, String message) {
|
||||||
|
Log.i(tag, message);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void info(String message) {
|
||||||
|
info("ReVanced", message);
|
||||||
|
}
|
||||||
|
}
|
@ -1,26 +1,4 @@
|
|||||||
package fi.vanced.utils;
|
package app.revanced.integrations.utils;
|
||||||
|
|
||||||
/*
|
|
||||||
* Licensed to the Apache Software Foundation (ASF) under one
|
|
||||||
* or more contributor license agreements. See the NOTICE file
|
|
||||||
* distributed with this work for additional information
|
|
||||||
* regarding copyright ownership. The ASF licenses this file
|
|
||||||
* to you under the Apache License, Version 2.0 (the
|
|
||||||
* "License"); you may not use this file except in compliance
|
|
||||||
* with the License. You may obtain a copy of the License at
|
|
||||||
*
|
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
*
|
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
* See the License for the specific language governing permissions and
|
|
||||||
* limitations under the License.
|
|
||||||
*
|
|
||||||
* Modifications copyright (C) 2022 Vanced
|
|
||||||
*/
|
|
||||||
|
|
||||||
import android.util.Log;
|
|
||||||
|
|
||||||
import java.io.ByteArrayInputStream;
|
import java.io.ByteArrayInputStream;
|
||||||
import java.io.ByteArrayOutputStream;
|
import java.io.ByteArrayOutputStream;
|
||||||
@ -29,9 +7,9 @@ import java.io.ObjectInputStream;
|
|||||||
import java.io.ObjectOutputStream;
|
import java.io.ObjectOutputStream;
|
||||||
import java.io.Serializable;
|
import java.io.Serializable;
|
||||||
|
|
||||||
public class ObjectSerializer {
|
import app.revanced.integrations.utils.LogHelper;
|
||||||
private static final String TAG = "VI - ObjectSerializer";
|
|
||||||
|
|
||||||
|
public class ObjectSerializer {
|
||||||
public static String serialize(Serializable obj) throws IOException {
|
public static String serialize(Serializable obj) throws IOException {
|
||||||
if (obj == null) return "";
|
if (obj == null) return "";
|
||||||
try {
|
try {
|
||||||
@ -41,7 +19,7 @@ public class ObjectSerializer {
|
|||||||
objStream.close();
|
objStream.close();
|
||||||
return encodeBytes(serialObj.toByteArray());
|
return encodeBytes(serialObj.toByteArray());
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
Log.e(TAG, "Serialization error: " + e.getMessage(), e);
|
LogHelper.printException("ObjectSerializer", "Serialization error: " + e.getMessage(), e);
|
||||||
throw new IOException(e);
|
throw new IOException(e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -53,12 +31,12 @@ public class ObjectSerializer {
|
|||||||
ObjectInputStream objStream = new ObjectInputStream(serialObj);
|
ObjectInputStream objStream = new ObjectInputStream(serialObj);
|
||||||
return objStream.readObject();
|
return objStream.readObject();
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
Log.e(TAG, "Deserialization error: " + e.getMessage(), e);
|
LogHelper.printException("ObjectSerializer", "Deserialization error: " + e.getMessage(), e);
|
||||||
throw new IOException(e);
|
throw new IOException(e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static String encodeBytes(byte[] bytes) {
|
private static String encodeBytes(byte[] bytes) {
|
||||||
StringBuffer strBuf = new StringBuffer();
|
StringBuffer strBuf = new StringBuffer();
|
||||||
|
|
||||||
for (int i = 0; i < bytes.length; i++) {
|
for (int i = 0; i < bytes.length; i++) {
|
||||||
@ -69,13 +47,13 @@ public class ObjectSerializer {
|
|||||||
return strBuf.toString();
|
return strBuf.toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static byte[] decodeBytes(String str) {
|
private static byte[] decodeBytes(String str) {
|
||||||
byte[] bytes = new byte[str.length() / 2];
|
byte[] bytes = new byte[str.length() / 2];
|
||||||
for (int i = 0; i < str.length(); i+=2) {
|
for (int i = 0; i < str.length(); i += 2) {
|
||||||
char c = str.charAt(i);
|
char c = str.charAt(i);
|
||||||
bytes[i/2] = (byte) ((c - 'a') << 4);
|
bytes[i / 2] = (byte) ((c - 'a') << 4);
|
||||||
c = str.charAt(i+1);
|
c = str.charAt(i + 1);
|
||||||
bytes[i/2] += (c - 'a');
|
bytes[i / 2] += (c - 'a');
|
||||||
}
|
}
|
||||||
return bytes;
|
return bytes;
|
||||||
}
|
}
|
@ -0,0 +1,24 @@
|
|||||||
|
package app.revanced.integrations.utils;
|
||||||
|
|
||||||
|
import android.content.Context;
|
||||||
|
import android.content.SharedPreferences;
|
||||||
|
import android.content.pm.PackageInfo;
|
||||||
|
import android.content.pm.PackageManager;
|
||||||
|
import android.os.Handler;
|
||||||
|
import android.os.Looper;
|
||||||
|
|
||||||
|
import com.google.android.apps.youtube.app.YouTubeTikTokRoot_Application;
|
||||||
|
|
||||||
|
import java.security.SecureRandom;
|
||||||
|
|
||||||
|
public class ReVancedUtils {
|
||||||
|
|
||||||
|
public static int getIdentifier(String name, String defType) {
|
||||||
|
Context context = YouTubeTikTokRoot_Application.getAppContext();
|
||||||
|
return context.getResources().getIdentifier(name, defType, context.getPackageName());
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void runOnMainThread(Runnable runnable) {
|
||||||
|
new Handler(Looper.getMainLooper()).post(runnable);
|
||||||
|
}
|
||||||
|
}
|
@ -1,9 +1,9 @@
|
|||||||
package fi.razerman.youtube.Helpers;
|
package app.revanced.integrations.utils;
|
||||||
|
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
|
|
||||||
/* loaded from: classes6.dex */
|
/* loaded from: classes6.dex */
|
||||||
public class XScreenSizeHelpers {
|
public class ScreenSizeHelper {
|
||||||
public static boolean isTablet(Context context) {
|
public static boolean isTablet(Context context) {
|
||||||
return smallestWidthDp(context) >= 600;
|
return smallestWidthDp(context) >= 600;
|
||||||
}
|
}
|
@ -0,0 +1,108 @@
|
|||||||
|
package app.revanced.integrations.utils;
|
||||||
|
|
||||||
|
import android.content.Context;
|
||||||
|
import android.content.SharedPreferences;
|
||||||
|
|
||||||
|
public class SharedPrefHelper {
|
||||||
|
public static void saveString(Context context, SharedPrefNames prefName, String key, String value) {
|
||||||
|
SharedPreferences sharedPreferences = getPreferences(context, prefName);
|
||||||
|
sharedPreferences.edit().putString(key, value).apply();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void saveBoolean(Context context, SharedPrefNames prefName, String key, Boolean value) {
|
||||||
|
SharedPreferences sharedPreferences = getPreferences(context, prefName);
|
||||||
|
sharedPreferences.edit().putBoolean(key, value).apply();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void saveInt(Context context, SharedPrefNames prefName, String key, Integer value) {
|
||||||
|
SharedPreferences sharedPreferences = getPreferences(context, prefName);
|
||||||
|
sharedPreferences.edit().putInt(key, value).apply();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void saveLong(Context context, SharedPrefNames prefName, String key, Long value) {
|
||||||
|
SharedPreferences sharedPreferences = getPreferences(context, prefName);
|
||||||
|
sharedPreferences.edit().putLong(key, value).apply();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void saveFloat(Context context, SharedPrefNames prefName, String key, Float value) {
|
||||||
|
SharedPreferences sharedPreferences = getPreferences(context, prefName);
|
||||||
|
sharedPreferences.edit().putFloat(key, value).apply();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static String getString(Context context, SharedPrefNames prefName, String key) {
|
||||||
|
return getString(context, prefName, key, null);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static String getString(Context context, SharedPrefNames prefName, String key, String _default) {
|
||||||
|
SharedPreferences sharedPreferences = getPreferences(context, prefName);
|
||||||
|
return (sharedPreferences.getString(key, _default));
|
||||||
|
}
|
||||||
|
|
||||||
|
public static Boolean getBoolean(Context context, SharedPrefNames prefName, String key) {
|
||||||
|
return getBoolean(context, prefName, key, false);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static Boolean getBoolean(Context context, SharedPrefNames prefName, String key, Boolean _default) {
|
||||||
|
SharedPreferences sharedPreferences = getPreferences(context, prefName);
|
||||||
|
return (sharedPreferences.getBoolean(key, _default));
|
||||||
|
}
|
||||||
|
|
||||||
|
public static Long getLong(Context context, SharedPrefNames prefName, String key) {
|
||||||
|
return getLong(context, prefName, key, -1L);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static Long getLong(Context context, SharedPrefNames prefName, String key, Long _default) {
|
||||||
|
SharedPreferences sharedPreferences = getPreferences(context, prefName);
|
||||||
|
return sharedPreferences.getLong(key, _default);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static Float getFloat(Context context, SharedPrefNames prefName, String key) {
|
||||||
|
return getFloat(context, prefName, key, -1.0F);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static Float getFloat(Context context, SharedPrefNames prefName, String key, Float _default) {
|
||||||
|
SharedPreferences sharedPreferences = getPreferences(context, prefName);
|
||||||
|
return sharedPreferences.getFloat(key, _default);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static Integer getInt(Context context, SharedPrefNames prefName, String key) {
|
||||||
|
return getInt(context, prefName, key, -1);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static Integer getInt(Context context, SharedPrefNames prefName, String key, Integer _default) {
|
||||||
|
SharedPreferences sharedPreferences = getPreferences(context, prefName);
|
||||||
|
return sharedPreferences.getInt(key, _default);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static SharedPreferences getPreferences(Context context, SharedPrefNames name) {
|
||||||
|
if (context == null) return null;
|
||||||
|
return context.getSharedPreferences(name.getName(), Context.MODE_PRIVATE);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static SharedPreferences getPreferences(Context context, String name) {
|
||||||
|
if (context == null) return null;
|
||||||
|
return context.getSharedPreferences(name, Context.MODE_PRIVATE);
|
||||||
|
}
|
||||||
|
|
||||||
|
public enum SharedPrefNames {
|
||||||
|
|
||||||
|
YOUTUBE("youtube"),
|
||||||
|
RYD("ryd"),
|
||||||
|
SPONSOR_BLOCK("sponsor-block");
|
||||||
|
|
||||||
|
private final String name;
|
||||||
|
|
||||||
|
SharedPrefNames(String name) {
|
||||||
|
this.name = name;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getName() {
|
||||||
|
return name;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toString() {
|
||||||
|
return name;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -1,16 +1,18 @@
|
|||||||
package fi.razerman.youtube.Helpers;
|
package app.revanced.integrations.utils;
|
||||||
|
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.content.res.Resources;
|
import android.content.res.Resources;
|
||||||
import android.util.Log;
|
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.view.ViewGroup;
|
import android.view.ViewGroup;
|
||||||
import android.widget.FrameLayout;
|
import android.widget.FrameLayout;
|
||||||
|
|
||||||
import com.google.android.apps.youtube.app.YouTubeTikTokRoot_Application;
|
import com.google.android.apps.youtube.app.YouTubeTikTokRoot_Application;
|
||||||
import fi.razerman.youtube.XGlobals;
|
|
||||||
|
import app.revanced.integrations.settings.Settings;
|
||||||
|
|
||||||
/* loaded from: classes6.dex */
|
/* loaded from: classes6.dex */
|
||||||
public class XSwipeHelper {
|
public class SwipeHelper {
|
||||||
static FrameLayout _frameLayout;
|
static FrameLayout _frameLayout;
|
||||||
public static boolean isTabletMode;
|
public static boolean isTabletMode;
|
||||||
public static ViewGroup nextGenWatchLayout;
|
public static ViewGroup nextGenWatchLayout;
|
||||||
@ -19,11 +21,11 @@ public class XSwipeHelper {
|
|||||||
try {
|
try {
|
||||||
_frameLayout = (FrameLayout) obj;
|
_frameLayout = (FrameLayout) obj;
|
||||||
Context appContext = YouTubeTikTokRoot_Application.getAppContext();
|
Context appContext = YouTubeTikTokRoot_Application.getAppContext();
|
||||||
if (XScreenSizeHelpers.isTablet(appContext) || XSharedPrefs.getBoolean(appContext, "pref_xfenster_tablet", false)) {
|
if (ScreenSizeHelper.isTablet(appContext) || SharedPrefHelper.getBoolean(appContext, SharedPrefHelper.SharedPrefNames.YOUTUBE,"pref_xfenster_tablet", false)) {
|
||||||
isTabletMode = true;
|
isTabletMode = true;
|
||||||
}
|
}
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
Log.e("XError", "Unable to set FrameLayout", e);
|
LogHelper.printException("XError", "Unable to set FrameLayout", e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -31,7 +33,7 @@ public class XSwipeHelper {
|
|||||||
try {
|
try {
|
||||||
nextGenWatchLayout = (ViewGroup) obj;
|
nextGenWatchLayout = (ViewGroup) obj;
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
Log.e("XError", "Unable to set _nextGenWatchLayout", e);
|
LogHelper.printException("XError", "Unable to set _nextGenWatchLayout", e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -42,7 +44,7 @@ public class XSwipeHelper {
|
|||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
Log.e("XError", "Unable to get related_endscreen_results visibility", e);
|
LogHelper.printException("XError", "Unable to get related_endscreen_results visibility", e);
|
||||||
}
|
}
|
||||||
if (_frameLayout.getChildCount() > 0) {
|
if (_frameLayout.getChildCount() > 0) {
|
||||||
return _frameLayout.getChildAt(0).getVisibility() == View.VISIBLE;
|
return _frameLayout.getChildAt(0).getVisibility() == View.VISIBLE;
|
||||||
@ -54,14 +56,12 @@ public class XSwipeHelper {
|
|||||||
private static void refreshLayout() {
|
private static void refreshLayout() {
|
||||||
View findViewById;
|
View findViewById;
|
||||||
try {
|
try {
|
||||||
if (XGlobals.isWatchWhileFullScreen() && (findViewById = nextGenWatchLayout.findViewById(getIdentifier())) != null) {
|
if (Settings.isWatchWhileFullScreen() && (findViewById = nextGenWatchLayout.findViewById(getIdentifier())) != null) {
|
||||||
_frameLayout = (FrameLayout) findViewById.getParent();
|
_frameLayout = (FrameLayout) findViewById.getParent();
|
||||||
if (XGlobals.debug) {
|
LogHelper.debug("Settings", "related_endscreen_results refreshed");
|
||||||
Log.d("XGlobals", "related_endscreen_results refreshed");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
Log.e("XError", "Unable to refresh related_endscreen_results layout", e);
|
LogHelper.printException("XError", "Unable to refresh related_endscreen_results layout", e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -1,32 +1,25 @@
|
|||||||
package fi.razerman.youtube.Helpers;
|
package app.revanced.integrations.utils;
|
||||||
|
|
||||||
import android.os.Build;
|
import android.os.Build;
|
||||||
import android.util.Log;
|
|
||||||
import com.google.android.apps.youtube.app.YouTubeTikTokRoot_Application;
|
import com.google.android.apps.youtube.app.YouTubeTikTokRoot_Application;
|
||||||
|
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
|
|
||||||
import fi.razerman.youtube.XGlobals;
|
import app.revanced.integrations.utils.LogHelper;
|
||||||
|
|
||||||
/* loaded from: classes6.dex */
|
/* loaded from: classes6.dex */
|
||||||
public class XThemeHelpers {
|
public class ThemeHelper {
|
||||||
static String TAG = "XTheme";
|
|
||||||
static int themeValue;
|
static int themeValue;
|
||||||
|
|
||||||
public static void setTheme(int value) {
|
public static void setTheme(int value) {
|
||||||
themeValue = value;
|
themeValue = value;
|
||||||
if (XGlobals.debug) {
|
LogHelper.debug("XTheme", "Theme value: " + themeValue);
|
||||||
String str = TAG;
|
|
||||||
Log.d(str, "Theme value: " + themeValue);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void setTheme(Object value) {
|
public static void setTheme(Object value) {
|
||||||
themeValue = ((Enum) value).ordinal();
|
themeValue = ((Enum) value).ordinal();
|
||||||
if (XGlobals.debug) {
|
LogHelper.debug("XTheme", "Theme value: " + themeValue);
|
||||||
String str = TAG;
|
|
||||||
Log.d(str, "Theme value: " + themeValue);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static boolean isDarkTheme() {
|
public static boolean isDarkTheme() {
|
@ -1,8 +1,7 @@
|
|||||||
package fi.razerman.youtube.Autorepeat;
|
package app.revanced.integrations.videoplayer.autorepeat;
|
||||||
|
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.content.SharedPreferences;
|
|
||||||
import android.util.Log;
|
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.view.animation.Animation;
|
import android.view.animation.Animation;
|
||||||
import android.view.animation.AnimationUtils;
|
import android.view.animation.AnimationUtils;
|
||||||
@ -11,9 +10,13 @@ import android.widget.ImageView;
|
|||||||
import androidx.constraintlayout.widget.ConstraintLayout;
|
import androidx.constraintlayout.widget.ConstraintLayout;
|
||||||
|
|
||||||
import com.google.android.apps.youtube.app.YouTubeTikTokRoot_Application;
|
import com.google.android.apps.youtube.app.YouTubeTikTokRoot_Application;
|
||||||
import fi.razerman.youtube.VideoUrl.Copy;
|
|
||||||
import fi.razerman.youtube.VideoUrl.CopyWithTimeStamp;
|
import app.revanced.integrations.settings.SettingsEnum;
|
||||||
import fi.razerman.youtube.XGlobals;
|
import app.revanced.integrations.utils.LogHelper;
|
||||||
|
import app.revanced.integrations.utils.SharedPrefHelper;
|
||||||
|
import app.revanced.integrations.videoplayer.videourl.Copy;
|
||||||
|
import app.revanced.integrations.videoplayer.videourl.CopyWithTimeStamp;
|
||||||
|
|
||||||
import java.lang.ref.WeakReference;
|
import java.lang.ref.WeakReference;
|
||||||
|
|
||||||
/* loaded from: classes6.dex */
|
/* loaded from: classes6.dex */
|
||||||
@ -29,25 +32,21 @@ public class AutoRepeat {
|
|||||||
|
|
||||||
public static void initializeAutoRepeat(Object constraintLayout) {
|
public static void initializeAutoRepeat(Object constraintLayout) {
|
||||||
try {
|
try {
|
||||||
if (XGlobals.debug) {
|
LogHelper.debug("AutoRepeat", "initializing auto repeat");
|
||||||
Log.d("AutoRepeat", "initializing auto repeat");
|
|
||||||
}
|
|
||||||
CopyWithTimeStamp.initializeCopyButtonWithTimeStamp(constraintLayout);
|
CopyWithTimeStamp.initializeCopyButtonWithTimeStamp(constraintLayout);
|
||||||
Copy.initializeCopyButton(constraintLayout);
|
Copy.initializeCopyButton(constraintLayout);
|
||||||
_constraintLayout = (ConstraintLayout) constraintLayout;
|
_constraintLayout = (ConstraintLayout) constraintLayout;
|
||||||
isAutoRepeatBtnEnabled = shouldBeShown();
|
isAutoRepeatBtnEnabled = shouldBeShown();
|
||||||
ImageView imageView = _constraintLayout.findViewById(getIdentifier("autoreplay_button", "id"));
|
ImageView imageView = _constraintLayout.findViewById(getIdentifier("autoreplay_button", "id"));
|
||||||
if (XGlobals.debug && imageView == null) {
|
if (imageView == null) {
|
||||||
Log.d("AutoRepeat", "Couldn't find imageView with tag \"autoreplay_button\"");
|
LogHelper.debug("AutoRepeat", "Couldn't find imageView with tag \"autoreplay_button\"");
|
||||||
}
|
}
|
||||||
if (imageView != null) {
|
if (imageView != null) {
|
||||||
imageView.setSelected(shouldBeSelected());
|
imageView.setSelected(shouldBeSelected());
|
||||||
imageView.setOnClickListener(new View.OnClickListener() { // from class: fi.razerman.youtube.Autorepeat.AutoRepeat.1
|
imageView.setOnClickListener(new View.OnClickListener() { // from class: app.revanced.integrations.videoplayer.Autorepeat.AutoRepeat.1
|
||||||
@Override // android.view.View.OnClickListener
|
@Override // android.view.View.OnClickListener
|
||||||
public void onClick(View v) {
|
public void onClick(View v) {
|
||||||
if (XGlobals.debug) {
|
LogHelper.debug("AutoRepeat", "Auto repeat button clicked");
|
||||||
Log.d("AutoRepeat", "Auto repeat button clicked");
|
|
||||||
}
|
|
||||||
AutoRepeat.changeSelected(!v.isSelected());
|
AutoRepeat.changeSelected(!v.isSelected());
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@ -62,7 +61,7 @@ public class AutoRepeat {
|
|||||||
changeVisibility(false);
|
changeVisibility(false);
|
||||||
}
|
}
|
||||||
} catch (Exception ex) {
|
} catch (Exception ex) {
|
||||||
Log.e("XError", "Unable to set FrameLayout", ex);
|
LogHelper.printException("XError", "Unable to set FrameLayout", ex);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -74,15 +73,11 @@ public class AutoRepeat {
|
|||||||
ImageView iView = _autoRepeatBtn.get();
|
ImageView iView = _autoRepeatBtn.get();
|
||||||
if (_constraintLayout != null && iView != null) {
|
if (_constraintLayout != null && iView != null) {
|
||||||
if (visible && isAutoRepeatBtnEnabled) {
|
if (visible && isAutoRepeatBtnEnabled) {
|
||||||
if (XGlobals.debug) {
|
LogHelper.debug("AutoRepeat", "Fading in");
|
||||||
Log.d("AutoRepeat", "Fading in");
|
|
||||||
}
|
|
||||||
iView.setVisibility(View.VISIBLE);
|
iView.setVisibility(View.VISIBLE);
|
||||||
iView.startAnimation(fadeIn);
|
iView.startAnimation(fadeIn);
|
||||||
} else if (iView.getVisibility() == View.VISIBLE) {
|
} else if (iView.getVisibility() == View.VISIBLE) {
|
||||||
if (XGlobals.debug) {
|
LogHelper.debug("AutoRepeat", "Fading out");
|
||||||
Log.d("AutoRepeat", "Fading out");
|
|
||||||
}
|
|
||||||
iView.startAnimation(fadeOut);
|
iView.startAnimation(fadeOut);
|
||||||
iView.setVisibility(View.GONE);
|
iView.setVisibility(View.GONE);
|
||||||
}
|
}
|
||||||
@ -97,11 +92,11 @@ public class AutoRepeat {
|
|||||||
public static void changeSelected(boolean selected, boolean onlyView) {
|
public static void changeSelected(boolean selected, boolean onlyView) {
|
||||||
ImageView iView = _autoRepeatBtn.get();
|
ImageView iView = _autoRepeatBtn.get();
|
||||||
if (_constraintLayout != null && iView != null) {
|
if (_constraintLayout != null && iView != null) {
|
||||||
if (XGlobals.debug) {
|
if (SettingsEnum.DEBUG_BOOLEAN.getBoolean()) {
|
||||||
StringBuilder sb = new StringBuilder();
|
StringBuilder sb = new StringBuilder();
|
||||||
sb.append("Changing selected state to: ");
|
sb.append("Changing selected state to: ");
|
||||||
sb.append(selected ? "SELECTED" : "NONE");
|
sb.append(selected ? "SELECTED" : "NONE");
|
||||||
Log.d("AutoRepeat", sb.toString());
|
LogHelper.debug("AutoRepeat", sb.toString());
|
||||||
}
|
}
|
||||||
iView.setSelected(selected);
|
iView.setSelected(selected);
|
||||||
if (!onlyView) {
|
if (!onlyView) {
|
||||||
@ -113,34 +108,24 @@ public class AutoRepeat {
|
|||||||
private static boolean shouldBeSelected() {
|
private static boolean shouldBeSelected() {
|
||||||
Context context = YouTubeTikTokRoot_Application.getAppContext();
|
Context context = YouTubeTikTokRoot_Application.getAppContext();
|
||||||
if (context == null) {
|
if (context == null) {
|
||||||
Log.e("AutoRepeat", "ChangeSelected - context is null!");
|
LogHelper.printException("AutoRepeat", "ChangeSelected - context is null!");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
SharedPreferences sharedPreferences = context.getSharedPreferences("youtube", 0);
|
return SharedPrefHelper.getBoolean(context, SharedPrefHelper.SharedPrefNames.YOUTUBE, "pref_auto_repeat", false);
|
||||||
return sharedPreferences.getBoolean("pref_auto_repeat", false);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void setSelected(boolean selected) {
|
private static void setSelected(boolean selected) {
|
||||||
try {
|
|
||||||
Context context = YouTubeTikTokRoot_Application.getAppContext();
|
Context context = YouTubeTikTokRoot_Application.getAppContext();
|
||||||
if (context == null) {
|
SharedPrefHelper.saveBoolean(context, SharedPrefHelper.SharedPrefNames.YOUTUBE, "pref_auto_repeat", selected);
|
||||||
Log.e("AutoRepeat", "ChangeSelected - context is null!");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
SharedPreferences sharedPreferences = context.getSharedPreferences("youtube", 0);
|
|
||||||
sharedPreferences.edit().putBoolean("pref_auto_repeat", selected).apply();
|
|
||||||
} catch (Exception ignored) {
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private static boolean shouldBeShown() {
|
private static boolean shouldBeShown() {
|
||||||
Context context = YouTubeTikTokRoot_Application.getAppContext();
|
Context context = YouTubeTikTokRoot_Application.getAppContext();
|
||||||
if (context == null) {
|
if (context == null) {
|
||||||
Log.e("AutoRepeat", "ChangeSelected - context is null!");
|
LogHelper.printException("AutoRepeat", "ChangeSelected - context is null!");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
SharedPreferences sharedPreferences = context.getSharedPreferences("youtube", 0);
|
return SharedPrefHelper.getBoolean(context, SharedPrefHelper.SharedPrefNames.YOUTUBE, "pref_auto_repeat_button", false);
|
||||||
return sharedPreferences.getBoolean("pref_auto_repeat_button", false);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private static int getIdentifier(String name, String defType) {
|
private static int getIdentifier(String name, String defType) {
|
@ -1,4 +1,4 @@
|
|||||||
package fi.razerman.youtube;
|
package app.revanced.integrations.videoplayer.settings;
|
||||||
|
|
||||||
import android.app.Activity;
|
import android.app.Activity;
|
||||||
import android.app.AlarmManager;
|
import android.app.AlarmManager;
|
||||||
@ -8,6 +8,9 @@ import android.content.Context;
|
|||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
import android.os.Process;
|
import android.os.Process;
|
||||||
|
|
||||||
|
import app.revanced.integrations.settings.Settings;
|
||||||
|
import app.revanced.integrations.settings.XSettingsFragment;
|
||||||
|
|
||||||
/* loaded from: classes6.dex */
|
/* loaded from: classes6.dex */
|
||||||
public class XReboot {
|
public class XReboot {
|
||||||
|
|
||||||
@ -23,8 +26,8 @@ public class XReboot {
|
|||||||
|
|
||||||
/* JADX INFO: Access modifiers changed from: package-private */
|
/* JADX INFO: Access modifiers changed from: package-private */
|
||||||
public static void RebootDialog(final Activity activity) {
|
public static void RebootDialog(final Activity activity) {
|
||||||
// from class: fi.razerman.youtube.XReboot.1
|
// from class: app.revanced.integrations.videoplayer.settings.XReboot.1
|
||||||
// android.content.DialogInterface.OnClickListenerXSettingsFragment.homeActivityClass
|
// android.content.DialogInterface.OnClickListenerXSettingsFragment.homeActivityClass
|
||||||
new AlertDialog.Builder(activity).setMessage(XGlobals.getStringByName(activity, "pref_refresh_config")).setPositiveButton(XGlobals.getStringByName(activity, "in_app_update_restart_button"), (dialog, id) -> XReboot.Reboot(activity, XSettingsFragment.homeActivityClass)).setNegativeButton(XGlobals.getStringByName(activity, "sign_in_cancel"), null).show();
|
new AlertDialog.Builder(activity).setMessage(Settings.getStringByName(activity, "pref_refresh_config")).setPositiveButton(Settings.getStringByName(activity, "in_app_update_restart_button"), (dialog, id) -> XReboot.Reboot(activity, XSettingsFragment.homeActivityClass)).setNegativeButton(Settings.getStringByName(activity, "sign_in_cancel"), null).show();
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -1,4 +1,4 @@
|
|||||||
package fi.razerman.youtube;
|
package app.revanced.integrations.videoplayer.videosettings;
|
||||||
|
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.net.ConnectivityManager;
|
import android.net.ConnectivityManager;
|
@ -1,10 +1,14 @@
|
|||||||
package fi.razerman.youtube.videosettings;
|
package app.revanced.integrations.videoplayer.videosettings;
|
||||||
|
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.util.Log;
|
|
||||||
|
|
||||||
import com.google.android.apps.youtube.app.YouTubeTikTokRoot_Application;
|
import com.google.android.apps.youtube.app.YouTubeTikTokRoot_Application;
|
||||||
import fi.razerman.youtube.Connectivity;
|
|
||||||
import fi.razerman.youtube.XGlobals;
|
import app.revanced.integrations.settings.SettingsEnum;
|
||||||
|
import app.revanced.integrations.utils.LogHelper;
|
||||||
|
import app.revanced.integrations.settings.Settings;
|
||||||
|
|
||||||
import java.lang.reflect.Field;
|
import java.lang.reflect.Field;
|
||||||
import java.lang.reflect.Method;
|
import java.lang.reflect.Method;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
@ -15,43 +19,35 @@ public class VideoQuality {
|
|||||||
static final int[] videoResolutions = {0, 144, 240, 360, 480, 720, 1080, 1440, 2160};
|
static final int[] videoResolutions = {0, 144, 240, 360, 480, 720, 1080, 1440, 2160};
|
||||||
|
|
||||||
public static void userChangedQuality() {
|
public static void userChangedQuality() {
|
||||||
XGlobals.userChangedQuality = true;
|
Settings.userChangedQuality = true;
|
||||||
XGlobals.newVideo = false;
|
Settings.newVideo = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static int setVideoQuality(Object[] qualities, int quality, Object qInterface) {
|
public static int setVideoQuality(Object[] qualities, int quality, Object qInterface) {
|
||||||
int preferredQuality;
|
int preferredQuality;
|
||||||
Field[] fields;
|
Field[] fields;
|
||||||
if (!XGlobals.newVideo || XGlobals.userChangedQuality || qInterface == null) {
|
if (!Settings.newVideo || Settings.userChangedQuality || qInterface == null) {
|
||||||
if (XGlobals.debug && XGlobals.userChangedQuality) {
|
if (SettingsEnum.DEBUG_BOOLEAN.getBoolean() && Settings.userChangedQuality) {
|
||||||
Log.d("XGlobals - quality", "Skipping quality change because user changed it: " + quality);
|
LogHelper.debug("Settings - quality", "Skipping quality change because user changed it: " + quality);
|
||||||
}
|
}
|
||||||
XGlobals.userChangedQuality = false;
|
Settings.userChangedQuality = false;
|
||||||
return quality;
|
return quality;
|
||||||
}
|
}
|
||||||
XGlobals.newVideo = false;
|
Settings.newVideo = false;
|
||||||
if (XGlobals.debug) {
|
LogHelper.debug("Settings - quality", "Quality: " + quality);
|
||||||
Log.d("XGlobals - quality", "Quality: " + quality);
|
|
||||||
}
|
|
||||||
Context context = YouTubeTikTokRoot_Application.getAppContext();
|
Context context = YouTubeTikTokRoot_Application.getAppContext();
|
||||||
if (context == null) {
|
if (context == null) {
|
||||||
Log.e("XGlobals", "Context is null or settings not initialized, returning quality: " + quality);
|
LogHelper.printException("Settings", "Context is null or settings not initialized, returning quality: " + quality);
|
||||||
return quality;
|
return quality;
|
||||||
}
|
}
|
||||||
if (Connectivity.isConnectedWifi(context)) {
|
if (Connectivity.isConnectedWifi(context)) {
|
||||||
preferredQuality = XGlobals.prefResolutionWIFI;
|
preferredQuality = SettingsEnum.PREFERRED_RESOLUTION_WIFI_INTEGER.getInt();
|
||||||
if (XGlobals.debug) {
|
LogHelper.debug("Settings", "Wi-Fi connection detected, preferred quality: " + preferredQuality);
|
||||||
Log.d("XGlobals", "Wi-Fi connection detected, preferred quality: " + preferredQuality);
|
|
||||||
}
|
|
||||||
} else if (Connectivity.isConnectedMobile(context)) {
|
} else if (Connectivity.isConnectedMobile(context)) {
|
||||||
preferredQuality = XGlobals.prefResolutionMobile;
|
preferredQuality = SettingsEnum.PREFERRED_RESOLUTION_MOBILE_INTEGER.getInt();
|
||||||
if (XGlobals.debug) {
|
LogHelper.debug("Settings", "Mobile data connection detected, preferred quality: " + preferredQuality);
|
||||||
Log.d("XGlobals", "Mobile data connection detected, preferred quality: " + preferredQuality);
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
if (XGlobals.debug) {
|
LogHelper.debug("Settings", "No Internet connection!");
|
||||||
Log.d("XGlobals", "No Internet connection!");
|
|
||||||
}
|
|
||||||
return quality;
|
return quality;
|
||||||
}
|
}
|
||||||
if (preferredQuality == -2) {
|
if (preferredQuality == -2) {
|
||||||
@ -70,13 +66,12 @@ public class VideoQuality {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} catch (Exception ignored) {}
|
} catch (Exception ignored) {
|
||||||
|
}
|
||||||
Collections.sort(iStreamQualities);
|
Collections.sort(iStreamQualities);
|
||||||
int index = 0;
|
int index = 0;
|
||||||
for (int streamQuality2 : iStreamQualities) {
|
for (int streamQuality2 : iStreamQualities) {
|
||||||
if (XGlobals.debug) {
|
LogHelper.debug("Settings - qualities", "Quality at index " + index + ": " + streamQuality2);
|
||||||
Log.d("XGlobals - qualities", "Quality at index " + index + ": " + streamQuality2);
|
|
||||||
}
|
|
||||||
index++;
|
index++;
|
||||||
}
|
}
|
||||||
for (Integer iStreamQuality : iStreamQualities) {
|
for (Integer iStreamQuality : iStreamQualities) {
|
||||||
@ -89,19 +84,15 @@ public class VideoQuality {
|
|||||||
return quality;
|
return quality;
|
||||||
}
|
}
|
||||||
int qualityIndex = iStreamQualities.indexOf(quality);
|
int qualityIndex = iStreamQualities.indexOf(quality);
|
||||||
if (XGlobals.debug) {
|
LogHelper.debug("Settings", "Index of quality " + quality + " is " + qualityIndex);
|
||||||
Log.d("XGlobals", "Index of quality " + quality + " is " + qualityIndex);
|
|
||||||
}
|
|
||||||
try {
|
try {
|
||||||
Class<?> cl = qInterface.getClass();
|
Class<?> cl = qInterface.getClass();
|
||||||
Method m = cl.getMethod("x", Integer.TYPE);
|
Method m = cl.getMethod("x", Integer.TYPE);
|
||||||
m.invoke(qInterface, iStreamQualities.get(qualityIndex));
|
m.invoke(qInterface, iStreamQualities.get(qualityIndex));
|
||||||
if (XGlobals.debug) {
|
LogHelper.debug("Settings", "Quality changed to: " + qualityIndex);
|
||||||
Log.d("XGlobals", "Quality changed to: " + qualityIndex);
|
|
||||||
}
|
|
||||||
return qualityIndex;
|
return qualityIndex;
|
||||||
} catch (Exception ex) {
|
} catch (Exception ex) {
|
||||||
Log.e("XGlobals", "Failed to set quality", ex);
|
LogHelper.printException("Settings", "Failed to set quality", ex);
|
||||||
return qualityIndex;
|
return qualityIndex;
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -1,7 +1,10 @@
|
|||||||
package fi.razerman.youtube.videosettings;
|
package app.revanced.integrations.videoplayer.videosettings;
|
||||||
|
|
||||||
|
|
||||||
|
import app.revanced.integrations.settings.SettingsEnum;
|
||||||
|
import app.revanced.integrations.utils.LogHelper;
|
||||||
|
import app.revanced.integrations.settings.Settings;
|
||||||
|
|
||||||
import android.util.Log;
|
|
||||||
import fi.razerman.youtube.XGlobals;
|
|
||||||
import java.lang.reflect.Field;
|
import java.lang.reflect.Field;
|
||||||
import java.lang.reflect.InvocationTargetException;
|
import java.lang.reflect.InvocationTargetException;
|
||||||
import java.lang.reflect.Method;
|
import java.lang.reflect.Method;
|
||||||
@ -15,17 +18,13 @@ public class VideoSpeed {
|
|||||||
public static int DefaultSpeed(Object[] speeds, int speed, Object qInterface) {
|
public static int DefaultSpeed(Object[] speeds, int speed, Object qInterface) {
|
||||||
int speed2;
|
int speed2;
|
||||||
Exception e;
|
Exception e;
|
||||||
if (!XGlobals.newVideoSpeed) {
|
if (!Settings.newVideoSpeed) {
|
||||||
return speed;
|
return speed;
|
||||||
}
|
}
|
||||||
XGlobals.newVideoSpeed = false;
|
Settings.newVideoSpeed = false;
|
||||||
if (XGlobals.debug) {
|
LogHelper.debug("Settings - speeds", "Speed: " + speed);
|
||||||
Log.d("XGlobals - speeds", "Speed: " + speed);
|
float preferredSpeed = SettingsEnum.PREFERRED_VIDEO_SPEED_FLOAT.getFloat();
|
||||||
}
|
LogHelper.debug("Settings", "Preferred speed: " + preferredSpeed);
|
||||||
float preferredSpeed = XGlobals.prefVideoSpeed;
|
|
||||||
if (XGlobals.debug) {
|
|
||||||
Log.d("XGlobals", "Preferred speed: " + preferredSpeed);
|
|
||||||
}
|
|
||||||
if (preferredSpeed == -2.0f) {
|
if (preferredSpeed == -2.0f) {
|
||||||
return speed;
|
return speed;
|
||||||
}
|
}
|
||||||
@ -49,24 +48,18 @@ public class VideoSpeed {
|
|||||||
int index = 0;
|
int index = 0;
|
||||||
while (it.hasNext()) {
|
while (it.hasNext()) {
|
||||||
float streamSpeed2 = it.next();
|
float streamSpeed2 = it.next();
|
||||||
if (XGlobals.debug) {
|
LogHelper.debug("Settings - speeds", "Speed at index " + index + ": " + streamSpeed2);
|
||||||
Log.d("XGlobals - speeds", "Speed at index " + index + ": " + streamSpeed2);
|
|
||||||
}
|
|
||||||
index++;
|
index++;
|
||||||
}
|
}
|
||||||
int speed3 = -1;
|
int speed3 = -1;
|
||||||
for (float streamSpeed3 : iStreamSpeeds) {
|
for (float streamSpeed3 : iStreamSpeeds) {
|
||||||
if (streamSpeed3 <= preferredSpeed) {
|
if (streamSpeed3 <= preferredSpeed) {
|
||||||
speed3++;
|
speed3++;
|
||||||
if (XGlobals.debug) {
|
LogHelper.debug("Settings - speeds", "Speed loop at index " + speed3 + ": " + streamSpeed3);
|
||||||
Log.d("XGlobals - speeds", "Speed loop at index " + speed3 + ": " + streamSpeed3);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (speed3 == -1) {
|
if (speed3 == -1) {
|
||||||
if (XGlobals.debug) {
|
LogHelper.debug("Settings - speeds", "Speed was not found");
|
||||||
Log.d("XGlobals - speeds", "Speed was not found");
|
|
||||||
}
|
|
||||||
speed2 = 3;
|
speed2 = 3;
|
||||||
} else {
|
} else {
|
||||||
speed2 = speed3;
|
speed2 = speed3;
|
||||||
@ -75,16 +68,14 @@ public class VideoSpeed {
|
|||||||
Method[] declaredMethods = qInterface.getClass().getDeclaredMethods();
|
Method[] declaredMethods = qInterface.getClass().getDeclaredMethods();
|
||||||
for (Method method : declaredMethods) {
|
for (Method method : declaredMethods) {
|
||||||
if (method.getName().length() <= 2) {
|
if (method.getName().length() <= 2) {
|
||||||
if (XGlobals.debug) {
|
LogHelper.debug("SPEED - Method", "Method name: " + method.getName());
|
||||||
Log.d("SPEED - Method", "Method name: " + method.getName());
|
|
||||||
}
|
|
||||||
try {
|
try {
|
||||||
try {
|
try {
|
||||||
method.invoke(qInterface, videoSpeeds[speed2]);
|
method.invoke(qInterface, videoSpeeds[speed2]);
|
||||||
} catch (IllegalAccessException | IllegalArgumentException | InvocationTargetException ignored) {
|
} catch (IllegalAccessException | IllegalArgumentException | InvocationTargetException ignored) {
|
||||||
} catch (Exception e6) {
|
} catch (Exception e6) {
|
||||||
e = e6;
|
e = e6;
|
||||||
Log.e("XDebug", e.getMessage());
|
LogHelper.printException("XDebug", e.getMessage());
|
||||||
return speed2;
|
return speed2;
|
||||||
}
|
}
|
||||||
} catch (Exception ignored) {
|
} catch (Exception ignored) {
|
||||||
@ -94,15 +85,13 @@ public class VideoSpeed {
|
|||||||
} catch (Exception e10) {
|
} catch (Exception e10) {
|
||||||
e = e10;
|
e = e10;
|
||||||
}
|
}
|
||||||
if (XGlobals.debug) {
|
LogHelper.debug("Settings", "Speed changed to: " + speed2);
|
||||||
Log.d("XGlobals", "Speed changed to: " + speed2);
|
|
||||||
}
|
|
||||||
return speed2;
|
return speed2;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void userChangedSpeed() {
|
public static void userChangedSpeed() {
|
||||||
XGlobals.userChangedSpeed = true;
|
Settings.userChangedSpeed = true;
|
||||||
XGlobals.newVideoSpeed = false;
|
Settings.newVideoSpeed = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static float getSpeedByIndex(int index) {
|
private static float getSpeedByIndex(int index) {
|
||||||
@ -118,21 +107,17 @@ public class VideoSpeed {
|
|||||||
|
|
||||||
public static float getSpeedValue(Object[] speeds, int speed) {
|
public static float getSpeedValue(Object[] speeds, int speed) {
|
||||||
int i = 0;
|
int i = 0;
|
||||||
if (!XGlobals.newVideoSpeed || XGlobals.userChangedSpeed) {
|
if (!Settings.newVideoSpeed || Settings.userChangedSpeed) {
|
||||||
if (XGlobals.debug && XGlobals.userChangedSpeed) {
|
if (SettingsEnum.DEBUG_BOOLEAN.getBoolean() && Settings.userChangedSpeed) {
|
||||||
Log.d("XGlobals - speeds", "Skipping speed change because user changed it: " + speed);
|
LogHelper.debug("Settings - speeds", "Skipping speed change because user changed it: " + speed);
|
||||||
}
|
}
|
||||||
XGlobals.userChangedSpeed = false;
|
Settings.userChangedSpeed = false;
|
||||||
return -1.0f;
|
return -1.0f;
|
||||||
}
|
}
|
||||||
XGlobals.newVideoSpeed = false;
|
Settings.newVideoSpeed = false;
|
||||||
if (XGlobals.debug) {
|
LogHelper.debug("Settings - speeds", "Speed: " + speed);
|
||||||
Log.d("XGlobals - speeds", "Speed: " + speed);
|
float preferredSpeed = SettingsEnum.PREFERRED_VIDEO_SPEED_FLOAT.getFloat();
|
||||||
}
|
LogHelper.debug("Settings", "Preferred speed: " + preferredSpeed);
|
||||||
float preferredSpeed = XGlobals.prefVideoSpeed;
|
|
||||||
if (XGlobals.debug) {
|
|
||||||
Log.d("XGlobals", "Preferred speed: " + preferredSpeed);
|
|
||||||
}
|
|
||||||
if (preferredSpeed == -2.0f) {
|
if (preferredSpeed == -2.0f) {
|
||||||
return -1.0f;
|
return -1.0f;
|
||||||
}
|
}
|
||||||
@ -163,9 +148,7 @@ public class VideoSpeed {
|
|||||||
int index = 0;
|
int index = 0;
|
||||||
for (Float iStreamSpeed : iStreamSpeeds) {
|
for (Float iStreamSpeed : iStreamSpeeds) {
|
||||||
float streamSpeed2 = iStreamSpeed;
|
float streamSpeed2 = iStreamSpeed;
|
||||||
if (XGlobals.debug) {
|
LogHelper.debug("Settings - speeds", "Speed at index " + index + ": " + streamSpeed2);
|
||||||
Log.d("XGlobals - speeds", "Speed at index " + index + ": " + streamSpeed2);
|
|
||||||
}
|
|
||||||
index++;
|
index++;
|
||||||
}
|
}
|
||||||
int newSpeedIndex = -1;
|
int newSpeedIndex = -1;
|
||||||
@ -173,26 +156,18 @@ public class VideoSpeed {
|
|||||||
float streamSpeed3 = iStreamSpeed;
|
float streamSpeed3 = iStreamSpeed;
|
||||||
if (streamSpeed3 <= preferredSpeed) {
|
if (streamSpeed3 <= preferredSpeed) {
|
||||||
newSpeedIndex++;
|
newSpeedIndex++;
|
||||||
if (XGlobals.debug) {
|
LogHelper.debug("Settings - speeds", "Speed loop at index " + newSpeedIndex + ": " + streamSpeed3);
|
||||||
Log.d("XGlobals - speeds", "Speed loop at index " + newSpeedIndex + ": " + streamSpeed3);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (newSpeedIndex == -1) {
|
if (newSpeedIndex == -1) {
|
||||||
if (XGlobals.debug) {
|
LogHelper.debug("Settings - speeds", "Speed was not found");
|
||||||
Log.d("XGlobals - speeds", "Speed was not found");
|
|
||||||
}
|
|
||||||
newSpeedIndex = 3;
|
newSpeedIndex = 3;
|
||||||
}
|
}
|
||||||
if (newSpeedIndex == speed) {
|
if (newSpeedIndex == speed) {
|
||||||
if (XGlobals.debug) {
|
LogHelper.debug("Settings", "Trying to set speed to what it already is, skipping...: " + newSpeedIndex);
|
||||||
Log.d("XGlobals", "Trying to set speed to what it already is, skipping...: " + newSpeedIndex);
|
|
||||||
}
|
|
||||||
return -1.0f;
|
return -1.0f;
|
||||||
}
|
}
|
||||||
if (XGlobals.debug) {
|
LogHelper.debug("Settings", "Speed changed to: " + newSpeedIndex);
|
||||||
Log.d("XGlobals", "Speed changed to: " + newSpeedIndex);
|
|
||||||
}
|
|
||||||
return getSpeedByIndex(newSpeedIndex);
|
return getSpeedByIndex(newSpeedIndex);
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -1,7 +1,6 @@
|
|||||||
package fi.razerman.youtube.VideoUrl;
|
package app.revanced.integrations.videoplayer.videourl;
|
||||||
|
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.util.Log;
|
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.view.animation.Animation;
|
import android.view.animation.Animation;
|
||||||
import android.view.animation.AnimationUtils;
|
import android.view.animation.AnimationUtils;
|
||||||
@ -10,13 +9,15 @@ import android.widget.ImageView;
|
|||||||
import androidx.constraintlayout.widget.ConstraintLayout;
|
import androidx.constraintlayout.widget.ConstraintLayout;
|
||||||
|
|
||||||
import com.google.android.apps.youtube.app.YouTubeTikTokRoot_Application;
|
import com.google.android.apps.youtube.app.YouTubeTikTokRoot_Application;
|
||||||
import fi.razerman.youtube.XGlobals;
|
|
||||||
import fi.vanced.libraries.youtube.player.VideoHelpers;
|
import app.revanced.integrations.utils.LogHelper;
|
||||||
|
import app.revanced.integrations.sponsorblock.player.VideoHelpers;
|
||||||
|
import app.revanced.integrations.utils.SharedPrefHelper;
|
||||||
|
|
||||||
import java.lang.ref.WeakReference;
|
import java.lang.ref.WeakReference;
|
||||||
|
|
||||||
/* loaded from: classes6.dex */
|
/* loaded from: classes6.dex */
|
||||||
public class Copy {
|
public class Copy {
|
||||||
static String TAG = "CopyButton";
|
|
||||||
static WeakReference<ImageView> _button = new WeakReference<>(null);
|
static WeakReference<ImageView> _button = new WeakReference<>(null);
|
||||||
static ConstraintLayout _constraintLayout;
|
static ConstraintLayout _constraintLayout;
|
||||||
static int fadeDurationFast;
|
static int fadeDurationFast;
|
||||||
@ -28,22 +29,17 @@ public class Copy {
|
|||||||
|
|
||||||
public static void initializeCopyButton(Object obj) {
|
public static void initializeCopyButton(Object obj) {
|
||||||
try {
|
try {
|
||||||
if (XGlobals.debug) {
|
LogHelper.debug("CopyButton", "initializing");
|
||||||
Log.d(TAG, "initializing");
|
|
||||||
}
|
|
||||||
_constraintLayout = (ConstraintLayout) obj;
|
_constraintLayout = (ConstraintLayout) obj;
|
||||||
isCopyButtonEnabled = shouldBeShown();
|
isCopyButtonEnabled = shouldBeShown();
|
||||||
ImageView imageView = _constraintLayout.findViewById(getIdentifier("copy_button", "id"));
|
ImageView imageView = _constraintLayout.findViewById(getIdentifier("copy_button", "id"));
|
||||||
if (XGlobals.debug && imageView == null) {
|
if (imageView == null) {
|
||||||
Log.d(TAG, "Couldn't find imageView with id \"copy_button\"");
|
LogHelper.debug("CopyButton", "Couldn't find imageView with id \"copy_button\"");
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
if (imageView != null) {
|
|
||||||
// from class: fi.razerman.youtube.VideoUrl.Copy.1
|
|
||||||
// android.view.View.OnClickListener
|
|
||||||
imageView.setOnClickListener(view -> {
|
imageView.setOnClickListener(view -> {
|
||||||
if (XGlobals.debug) {
|
LogHelper.debug("CopyButton", "Button clicked");
|
||||||
Log.d(Copy.TAG, "Button clicked");
|
|
||||||
}
|
|
||||||
VideoHelpers.copyVideoUrlToClipboard();
|
VideoHelpers.copyVideoUrlToClipboard();
|
||||||
});
|
});
|
||||||
_button = new WeakReference<>(imageView);
|
_button = new WeakReference<>(imageView);
|
||||||
@ -57,9 +53,9 @@ public class Copy {
|
|||||||
animation2.setDuration(fadeDurationScheduled);
|
animation2.setDuration(fadeDurationScheduled);
|
||||||
isShowing = true;
|
isShowing = true;
|
||||||
changeVisibility(false);
|
changeVisibility(false);
|
||||||
}
|
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
Log.e(TAG, "Unable to set FrameLayout", e);
|
LogHelper.printException("CopyButton", "Unable to set FrameLayout", e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -69,15 +65,11 @@ public class Copy {
|
|||||||
ImageView imageView = _button.get();
|
ImageView imageView = _button.get();
|
||||||
if (_constraintLayout != null && imageView != null) {
|
if (_constraintLayout != null && imageView != null) {
|
||||||
if (z && isCopyButtonEnabled) {
|
if (z && isCopyButtonEnabled) {
|
||||||
if (XGlobals.debug) {
|
LogHelper.debug("CopyButton", "Fading in");
|
||||||
Log.d(TAG, "Fading in");
|
|
||||||
}
|
|
||||||
imageView.setVisibility(View.VISIBLE);
|
imageView.setVisibility(View.VISIBLE);
|
||||||
imageView.startAnimation(fadeIn);
|
imageView.startAnimation(fadeIn);
|
||||||
} else if (imageView.getVisibility() == View.VISIBLE) {
|
} else if (imageView.getVisibility() == View.VISIBLE) {
|
||||||
if (XGlobals.debug) {
|
LogHelper.debug("CopyButton", "Fading out");
|
||||||
Log.d(TAG, "Fading out");
|
|
||||||
}
|
|
||||||
imageView.startAnimation(fadeOut);
|
imageView.startAnimation(fadeOut);
|
||||||
imageView.setVisibility(View.GONE);
|
imageView.setVisibility(View.GONE);
|
||||||
}
|
}
|
||||||
@ -92,10 +84,10 @@ public class Copy {
|
|||||||
private static boolean shouldBeShown() {
|
private static boolean shouldBeShown() {
|
||||||
Context appContext = YouTubeTikTokRoot_Application.getAppContext();
|
Context appContext = YouTubeTikTokRoot_Application.getAppContext();
|
||||||
if (appContext == null) {
|
if (appContext == null) {
|
||||||
Log.e(TAG, "shouldBeShown - context is null!");
|
LogHelper.printException("CopyButton", "shouldBeShown - context is null!");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
String string = appContext.getSharedPreferences("youtube", 0).getString("pref_copy_video_url_button_list", null);
|
String string = SharedPrefHelper.getString(appContext, SharedPrefHelper.SharedPrefNames.YOUTUBE, "pref_copy_video_url_button_list", null);
|
||||||
if (string == null || string.isEmpty()) {
|
if (string == null || string.isEmpty()) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
@ -1,7 +1,7 @@
|
|||||||
package fi.razerman.youtube.VideoUrl;
|
package app.revanced.integrations.videoplayer.videourl;
|
||||||
|
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.util.Log;
|
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.view.animation.Animation;
|
import android.view.animation.Animation;
|
||||||
import android.view.animation.AnimationUtils;
|
import android.view.animation.AnimationUtils;
|
||||||
@ -10,13 +10,15 @@ import android.widget.ImageView;
|
|||||||
import androidx.constraintlayout.widget.ConstraintLayout;
|
import androidx.constraintlayout.widget.ConstraintLayout;
|
||||||
|
|
||||||
import com.google.android.apps.youtube.app.YouTubeTikTokRoot_Application;
|
import com.google.android.apps.youtube.app.YouTubeTikTokRoot_Application;
|
||||||
import fi.razerman.youtube.XGlobals;
|
|
||||||
import fi.vanced.libraries.youtube.player.VideoHelpers;
|
import app.revanced.integrations.utils.LogHelper;
|
||||||
|
import app.revanced.integrations.sponsorblock.player.VideoHelpers;
|
||||||
|
import app.revanced.integrations.utils.SharedPrefHelper;
|
||||||
|
|
||||||
import java.lang.ref.WeakReference;
|
import java.lang.ref.WeakReference;
|
||||||
|
|
||||||
/* loaded from: classes6.dex */
|
/* loaded from: classes6.dex */
|
||||||
public class CopyWithTimeStamp {
|
public class CopyWithTimeStamp {
|
||||||
static String TAG = "CopyButtonWithTimeStamp";
|
|
||||||
static WeakReference<ImageView> _button = new WeakReference<>(null);
|
static WeakReference<ImageView> _button = new WeakReference<>(null);
|
||||||
static ConstraintLayout _constraintLayout;
|
static ConstraintLayout _constraintLayout;
|
||||||
static int fadeDurationFast;
|
static int fadeDurationFast;
|
||||||
@ -28,22 +30,18 @@ public class CopyWithTimeStamp {
|
|||||||
|
|
||||||
public static void initializeCopyButtonWithTimeStamp(Object obj) {
|
public static void initializeCopyButtonWithTimeStamp(Object obj) {
|
||||||
try {
|
try {
|
||||||
if (XGlobals.debug) {
|
LogHelper.debug("CopyButtonWithTimeStamp", "initializing");
|
||||||
Log.d(TAG, "initializing");
|
|
||||||
}
|
|
||||||
_constraintLayout = (ConstraintLayout) obj;
|
_constraintLayout = (ConstraintLayout) obj;
|
||||||
isCopyButtonWithTimeStampEnabled = shouldBeShown();
|
isCopyButtonWithTimeStampEnabled = shouldBeShown();
|
||||||
ImageView imageView = (ImageView) _constraintLayout.findViewById(getIdentifier("copy_with_timestamp_button", "id"));
|
ImageView imageView = (ImageView) _constraintLayout.findViewById(getIdentifier("copy_with_timestamp_button", "id"));
|
||||||
if (XGlobals.debug && imageView == null) {
|
if (imageView == null) {
|
||||||
Log.d(TAG, "Couldn't find imageView with id \"copy_with_timestamp_button\"");
|
LogHelper.debug("CopyButtonWithTimeStamp", "Couldn't find imageView with id \"copy_with_timestamp_button\"");
|
||||||
}
|
}
|
||||||
if (imageView != null) {
|
if (imageView != null) {
|
||||||
imageView.setOnClickListener(new View.OnClickListener() { // from class: fi.razerman.youtube.VideoUrl.CopyWithTimeStamp.1
|
imageView.setOnClickListener(new View.OnClickListener() { // from class: app.revanced.integrations.videoplayer.VideoUrl.CopyWithTimeStamp.1
|
||||||
@Override // android.view.View.OnClickListener
|
@Override // android.view.View.OnClickListener
|
||||||
public void onClick(View view) {
|
public void onClick(View view) {
|
||||||
if (XGlobals.debug) {
|
LogHelper.debug("CopyButtonWithTimeStamp", "Button clicked");
|
||||||
Log.d(CopyWithTimeStamp.TAG, "Button clicked");
|
|
||||||
}
|
|
||||||
VideoHelpers.copyVideoUrlWithTimeStampToClipboard();
|
VideoHelpers.copyVideoUrlWithTimeStampToClipboard();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@ -60,7 +58,7 @@ public class CopyWithTimeStamp {
|
|||||||
changeVisibility(false);
|
changeVisibility(false);
|
||||||
}
|
}
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
Log.e(TAG, "Unable to set FrameLayout", e);
|
LogHelper.printException("CopyButtonWithTimeStamp", "Unable to set FrameLayout", e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -70,15 +68,11 @@ public class CopyWithTimeStamp {
|
|||||||
ImageView imageView = _button.get();
|
ImageView imageView = _button.get();
|
||||||
if (_constraintLayout != null && imageView != null) {
|
if (_constraintLayout != null && imageView != null) {
|
||||||
if (z && isCopyButtonWithTimeStampEnabled) {
|
if (z && isCopyButtonWithTimeStampEnabled) {
|
||||||
if (XGlobals.debug) {
|
LogHelper.debug("CopyButtonWithTimeStamp", "Fading in");
|
||||||
Log.d(TAG, "Fading in");
|
|
||||||
}
|
|
||||||
imageView.setVisibility(View.VISIBLE);
|
imageView.setVisibility(View.VISIBLE);
|
||||||
imageView.startAnimation(fadeIn);
|
imageView.startAnimation(fadeIn);
|
||||||
} else if (imageView.getVisibility() == View.VISIBLE) {
|
} else if (imageView.getVisibility() == View.VISIBLE) {
|
||||||
if (XGlobals.debug) {
|
LogHelper.debug("CopyButtonWithTimeStamp", "Fading out");
|
||||||
Log.d(TAG, "Fading out");
|
|
||||||
}
|
|
||||||
imageView.startAnimation(fadeOut);
|
imageView.startAnimation(fadeOut);
|
||||||
imageView.setVisibility(View.GONE);
|
imageView.setVisibility(View.GONE);
|
||||||
}
|
}
|
||||||
@ -93,10 +87,11 @@ public class CopyWithTimeStamp {
|
|||||||
private static boolean shouldBeShown() {
|
private static boolean shouldBeShown() {
|
||||||
Context appContext = YouTubeTikTokRoot_Application.getAppContext();
|
Context appContext = YouTubeTikTokRoot_Application.getAppContext();
|
||||||
if (appContext == null) {
|
if (appContext == null) {
|
||||||
Log.e(TAG, "shouldBeShown - context is null!");
|
LogHelper.printException("CopyButtonWithTimeStamp", "shouldBeShown - context is null!");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
String string = appContext.getSharedPreferences("youtube", 0).getString("pref_copy_video_url_timestamp_button_list", null);
|
|
||||||
|
String string = SharedPrefHelper.getString(appContext, SharedPrefHelper.SharedPrefNames.YOUTUBE, "pref_copy_video_url_timestamp_button_list", null);
|
||||||
if (string == null || string.isEmpty()) {
|
if (string == null || string.isEmpty()) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
@ -1,4 +1,4 @@
|
|||||||
package fi.razerman.youtube.Fenster;
|
package app.revanced.integrations.videoswipecontrols;
|
||||||
|
|
||||||
/* loaded from: classes6.dex */
|
/* loaded from: classes6.dex */
|
||||||
public enum Coverage {
|
public enum Coverage {
|
@ -1,4 +1,4 @@
|
|||||||
package fi.razerman.youtube.Fenster;
|
package app.revanced.integrations.videoswipecontrols;
|
||||||
|
|
||||||
import android.view.MotionEvent;
|
import android.view.MotionEvent;
|
||||||
|
|
@ -1,11 +1,11 @@
|
|||||||
package fi.razerman.youtube.Fenster;
|
package app.revanced.integrations.videoswipecontrols;
|
||||||
|
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.util.Log;
|
|
||||||
import android.view.GestureDetector;
|
import android.view.GestureDetector;
|
||||||
import android.view.MotionEvent;
|
import android.view.MotionEvent;
|
||||||
import android.view.ViewConfiguration;
|
import android.view.ViewConfiguration;
|
||||||
import fi.razerman.youtube.XGlobals;
|
|
||||||
|
import app.revanced.integrations.utils.LogHelper;
|
||||||
|
|
||||||
/* loaded from: classes6.dex */
|
/* loaded from: classes6.dex */
|
||||||
public class FensterGestureController {
|
public class FensterGestureController {
|
||||||
@ -19,9 +19,7 @@ public class FensterGestureController {
|
|||||||
}
|
}
|
||||||
if (event.getAction() == 1) {
|
if (event.getAction() == 1) {
|
||||||
this.listener.onUp();
|
this.listener.onUp();
|
||||||
if (XGlobals.debug) {
|
LogHelper.debug("TouchTest", "Touch up");
|
||||||
Log.i("TouchTest", "Touch up");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
return this.gestureDetector.onTouchEvent(event);
|
return this.gestureDetector.onTouchEvent(event);
|
||||||
}
|
}
|
@ -1,14 +1,13 @@
|
|||||||
package fi.razerman.youtube.Fenster;
|
package app.revanced.integrations.videoswipecontrols;
|
||||||
|
|
||||||
import android.util.Log;
|
|
||||||
import android.view.GestureDetector;
|
import android.view.GestureDetector;
|
||||||
import android.view.MotionEvent;
|
import android.view.MotionEvent;
|
||||||
import android.view.ViewConfiguration;
|
import android.view.ViewConfiguration;
|
||||||
import fi.razerman.youtube.XGlobals;
|
|
||||||
|
import app.revanced.integrations.utils.LogHelper;
|
||||||
|
|
||||||
/* loaded from: classes6.dex */
|
/* loaded from: classes6.dex */
|
||||||
public class FensterGestureListener implements GestureDetector.OnGestureListener {
|
public class FensterGestureListener implements GestureDetector.OnGestureListener {
|
||||||
public static final String TAG = "FensterGestureListener";
|
|
||||||
private boolean ignoreScroll = false;
|
private boolean ignoreScroll = false;
|
||||||
private final FensterEventsListener listener;
|
private final FensterEventsListener listener;
|
||||||
private final int minFlingVelocity;
|
private final int minFlingVelocity;
|
||||||
@ -28,28 +27,22 @@ public class FensterGestureListener implements GestureDetector.OnGestureListener
|
|||||||
|
|
||||||
@Override // android.view.GestureDetector.OnGestureListener
|
@Override // android.view.GestureDetector.OnGestureListener
|
||||||
public void onLongPress(MotionEvent e) {
|
public void onLongPress(MotionEvent e) {
|
||||||
if (XGlobals.debug) {
|
LogHelper.debug("FensterGestureListener", "Long Press");
|
||||||
Log.i(TAG, "Long Press");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override // android.view.GestureDetector.OnGestureListener
|
@Override // android.view.GestureDetector.OnGestureListener
|
||||||
public boolean onScroll(MotionEvent e1, MotionEvent e2, float distanceX, float distanceY) {
|
public boolean onScroll(MotionEvent e1, MotionEvent e2, float distanceX, float distanceY) {
|
||||||
if (XGlobals.debug) {
|
LogHelper.debug("FensterGestureListener", "Scroll");
|
||||||
Log.i(TAG, "Scroll");
|
|
||||||
}
|
|
||||||
if (e1 == null || e2 == null) {
|
if (e1 == null || e2 == null) {
|
||||||
if (e1 == null && XGlobals.debug) {
|
if (e1 == null) {
|
||||||
Log.d("XDebug", "e1 is null");
|
LogHelper.debug("XDebug", "e1 is null");
|
||||||
}
|
}
|
||||||
if (e2 == null && XGlobals.debug) {
|
if (e2 == null) {
|
||||||
Log.d("XDebug", "e2 is null");
|
LogHelper.debug("XDebug", "e2 is null");
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
} else if (this.ignoreScroll) {
|
} else if (this.ignoreScroll) {
|
||||||
if (XGlobals.debug) {
|
LogHelper.debug("FensterGestureListener", "Scroll ignored");
|
||||||
Log.i(TAG, "Scroll ignored");
|
|
||||||
}
|
|
||||||
return false;
|
return false;
|
||||||
} else {
|
} else {
|
||||||
float deltaY = e2.getY() - e1.getY();
|
float deltaY = e2.getY() - e1.getY();
|
||||||
@ -57,23 +50,13 @@ public class FensterGestureListener implements GestureDetector.OnGestureListener
|
|||||||
if (Math.abs(deltaX) > Math.abs(deltaY)) {
|
if (Math.abs(deltaX) > Math.abs(deltaY)) {
|
||||||
if (Math.abs(deltaX) > SWIPE_THRESHOLD) {
|
if (Math.abs(deltaX) > SWIPE_THRESHOLD) {
|
||||||
this.listener.onHorizontalScroll(e2, deltaX);
|
this.listener.onHorizontalScroll(e2, deltaX);
|
||||||
if (deltaX > 0.0f) {
|
String message = deltaX > 0.0f ? "Slide right" : "Slide left";
|
||||||
if (XGlobals.debug) {
|
LogHelper.debug("FensterGestureListener", message);
|
||||||
Log.i(TAG, "Slide right");
|
|
||||||
}
|
|
||||||
} else if (XGlobals.debug) {
|
|
||||||
Log.i(TAG, "Slide left");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
} else if (Math.abs(deltaY) > SWIPE_THRESHOLD) {
|
} else if (Math.abs(deltaY) > SWIPE_THRESHOLD) {
|
||||||
this.listener.onVerticalScroll(e2, deltaY);
|
this.listener.onVerticalScroll(e2, deltaY);
|
||||||
if (deltaY > 0.0f) {
|
String message = deltaY > 0.0f ? "Slide down" : "Slide up";
|
||||||
if (XGlobals.debug) {
|
LogHelper.debug("FensterGestureListener", message);
|
||||||
Log.i(TAG, "Slide down");
|
|
||||||
}
|
|
||||||
} else if (XGlobals.debug) {
|
|
||||||
Log.i(TAG, "Slide up");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -81,9 +64,7 @@ public class FensterGestureListener implements GestureDetector.OnGestureListener
|
|||||||
|
|
||||||
@Override // android.view.GestureDetector.OnGestureListener
|
@Override // android.view.GestureDetector.OnGestureListener
|
||||||
public boolean onFling(MotionEvent e1, MotionEvent e2, float velocityX, float velocityY) {
|
public boolean onFling(MotionEvent e1, MotionEvent e2, float velocityX, float velocityY) {
|
||||||
if (XGlobals.debug) {
|
LogHelper.debug("FensterGestureListener", "Fling");
|
||||||
Log.i(TAG, "Fling");
|
|
||||||
}
|
|
||||||
try {
|
try {
|
||||||
float diffY = e2.getY() - e1.getY();
|
float diffY = e2.getY() - e1.getY();
|
||||||
float diffX = e2.getX() - e1.getX();
|
float diffX = e2.getX() - e1.getX();
|
||||||
@ -111,16 +92,12 @@ public class FensterGestureListener implements GestureDetector.OnGestureListener
|
|||||||
|
|
||||||
@Override // android.view.GestureDetector.OnGestureListener
|
@Override // android.view.GestureDetector.OnGestureListener
|
||||||
public void onShowPress(MotionEvent e) {
|
public void onShowPress(MotionEvent e) {
|
||||||
if (XGlobals.debug) {
|
LogHelper.debug("FensterGestureListener", "Show Press");
|
||||||
Log.i(TAG, "Show Press");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override // android.view.GestureDetector.OnGestureListener
|
@Override // android.view.GestureDetector.OnGestureListener
|
||||||
public boolean onDown(MotionEvent e) {
|
public boolean onDown(MotionEvent e) {
|
||||||
if (XGlobals.debug) {
|
LogHelper.debug("FensterGestureListener", "Down - x: " + e.getX() + " y: " + e.getY());
|
||||||
Log.i(TAG, "Down - x: " + e.getX() + " y: " + e.getY());
|
|
||||||
}
|
|
||||||
this.ignoreScroll = e.getY() <= TOP_PADDING;
|
this.ignoreScroll = e.getY() <= TOP_PADDING;
|
||||||
this.listener.onDown(e);
|
this.listener.onDown(e);
|
||||||
return false;
|
return false;
|
@ -1,4 +1,4 @@
|
|||||||
package fi.razerman.youtube.Fenster;
|
package app.revanced.integrations.videoswipecontrols;
|
||||||
|
|
||||||
/* loaded from: classes6.dex */
|
/* loaded from: classes6.dex */
|
||||||
public enum Orientation {
|
public enum Orientation {
|
@ -1,22 +1,23 @@
|
|||||||
package fi.razerman.youtube.Fenster;
|
package app.revanced.integrations.videoswipecontrols;
|
||||||
|
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.os.Handler;
|
import android.os.Handler;
|
||||||
import android.util.Log;
|
|
||||||
import android.view.MotionEvent;
|
import android.view.MotionEvent;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.view.ViewGroup;
|
import android.view.ViewGroup;
|
||||||
|
|
||||||
import com.google.android.apps.youtube.app.YouTubeTikTokRoot_Application;
|
import com.google.android.apps.youtube.app.YouTubeTikTokRoot_Application;
|
||||||
import fi.razerman.youtube.Fenster.Seekbar.BrightnessSeekBar;
|
|
||||||
import fi.razerman.youtube.Fenster.Seekbar.VolumeSeekBar;
|
import app.revanced.integrations.utils.LogHelper;
|
||||||
import fi.razerman.youtube.Helpers.XSwipeHelper;
|
import app.revanced.integrations.videoswipecontrols.seekbar.BrightnessSeekBar;
|
||||||
import fi.razerman.youtube.XGlobals;
|
import app.revanced.integrations.videoswipecontrols.seekbar.VolumeSeekBar;
|
||||||
import fi.razerman.youtube.XSettingsFragment;
|
import app.revanced.integrations.utils.SwipeHelper;
|
||||||
|
import app.revanced.integrations.settings.XSettingsFragment;
|
||||||
|
|
||||||
/* loaded from: classes6.dex */
|
/* loaded from: classes6.dex */
|
||||||
public class XFenster implements FensterEventsListener {
|
public class XFenster implements FensterEventsListener {
|
||||||
public static final int ONE_FINGER = 1;
|
public static final int ONE_FINGER = 1;
|
||||||
public static final String TAG = "XDebug";
|
|
||||||
Handler handler;
|
Handler handler;
|
||||||
float mBrightnessDownPos;
|
float mBrightnessDownPos;
|
||||||
int mBrightnessDownProgress;
|
int mBrightnessDownProgress;
|
||||||
@ -41,18 +42,14 @@ public class XFenster implements FensterEventsListener {
|
|||||||
this.mVolume.initialise(context, viewGroup);
|
this.mVolume.initialise(context, viewGroup);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override // fi.razerman.youtube.Fenster.FensterEventsListener
|
@Override // app.revanced.integrations.videoplayer.Fenster.FensterEventsListener
|
||||||
public void onTap() {
|
public void onTap() {
|
||||||
if (XGlobals.debug) {
|
LogHelper.debug("XDebug", "onTap");
|
||||||
Log.d("XDebug", "onTap");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override // fi.razerman.youtube.Fenster.FensterEventsListener
|
@Override // app.revanced.integrations.videoplayer.Fenster.FensterEventsListener
|
||||||
public void onHorizontalScroll(MotionEvent event, float delta) {
|
public void onHorizontalScroll(MotionEvent event, float delta) {
|
||||||
if (XGlobals.debug) {
|
LogHelper.debug("XDebug", "onHorizontalScroll - y: " + ((int) event.getY()) + " x: " + ((int) event.getX()));
|
||||||
Log.d("XDebug", "onHorizontalScroll - y: " + ((int) event.getY()) + " x: " + ((int) event.getX()));
|
|
||||||
}
|
|
||||||
if (event.getPointerCount() == 1) {
|
if (event.getPointerCount() == 1) {
|
||||||
if (this.brightnessOrientation == Orientation.HORIZONTAL && (this.brightnessCoverage == Coverage.FULL || getCoverageHorizontal(event) == this.brightnessCoverage)) {
|
if (this.brightnessOrientation == Orientation.HORIZONTAL && (this.brightnessCoverage == Coverage.FULL || getCoverageHorizontal(event) == this.brightnessCoverage)) {
|
||||||
updateBrightnessProgressBarHorizontal(event);
|
updateBrightnessProgressBarHorizontal(event);
|
||||||
@ -66,11 +63,9 @@ public class XFenster implements FensterEventsListener {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override // fi.razerman.youtube.Fenster.FensterEventsListener
|
@Override // app.revanced.integrations.videoplayer.Fenster.FensterEventsListener
|
||||||
public void onVerticalScroll(MotionEvent event, float delta) {
|
public void onVerticalScroll(MotionEvent event, float delta) {
|
||||||
if (XGlobals.debug) {
|
LogHelper.debug("XDebug", "onVerticalScroll - y: " + ((int) event.getY()) + " x: " + ((int) event.getX()));
|
||||||
Log.d("XDebug", "onVerticalScroll - y: " + ((int) event.getY()) + " x: " + ((int) event.getX()));
|
|
||||||
}
|
|
||||||
if (event.getPointerCount() == 1) {
|
if (event.getPointerCount() == 1) {
|
||||||
if (this.brightnessOrientation == Orientation.VERTICAL && (this.brightnessCoverage == Coverage.FULL || getCoverageVertical(event) == this.brightnessCoverage)) {
|
if (this.brightnessOrientation == Orientation.VERTICAL && (this.brightnessCoverage == Coverage.FULL || getCoverageVertical(event) == this.brightnessCoverage)) {
|
||||||
updateBrightnessProgressBarVertical(event);
|
updateBrightnessProgressBarVertical(event);
|
||||||
@ -84,39 +79,29 @@ public class XFenster implements FensterEventsListener {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override // fi.razerman.youtube.Fenster.FensterEventsListener
|
@Override // app.revanced.integrations.videoplayer.Fenster.FensterEventsListener
|
||||||
public void onSwipeRight() {
|
public void onSwipeRight() {
|
||||||
if (XGlobals.debug) {
|
LogHelper.debug("XDebug", "onSwipeRight");
|
||||||
Log.d("XDebug", "onSwipeRight");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override // fi.razerman.youtube.Fenster.FensterEventsListener
|
@Override // app.revanced.integrations.videoplayer.Fenster.FensterEventsListener
|
||||||
public void onSwipeLeft() {
|
public void onSwipeLeft() {
|
||||||
if (XGlobals.debug) {
|
LogHelper.debug("XDebug", "onSwipeLeft");
|
||||||
Log.d("XDebug", "onSwipeLeft");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override // fi.razerman.youtube.Fenster.FensterEventsListener
|
@Override // app.revanced.integrations.videoplayer.Fenster.FensterEventsListener
|
||||||
public void onSwipeBottom() {
|
public void onSwipeBottom() {
|
||||||
if (XGlobals.debug) {
|
LogHelper.debug("XDebug", "onSwipeBottom");
|
||||||
Log.d("XDebug", "onSwipeBottom");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override // fi.razerman.youtube.Fenster.FensterEventsListener
|
@Override // app.revanced.integrations.videoplayer.Fenster.FensterEventsListener
|
||||||
public void onSwipeTop() {
|
public void onSwipeTop() {
|
||||||
if (XGlobals.debug) {
|
LogHelper.debug("XDebug", "onSwipeTop");
|
||||||
Log.d("XDebug", "onSwipeTop");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override // fi.razerman.youtube.Fenster.FensterEventsListener
|
@Override // app.revanced.integrations.videoplayer.Fenster.FensterEventsListener
|
||||||
public void onDown(MotionEvent event) {
|
public void onDown(MotionEvent event) {
|
||||||
if (XGlobals.debug) {
|
LogHelper.debug("XDebug", "onDown");
|
||||||
Log.d("XDebug", "onDown");
|
|
||||||
}
|
|
||||||
if (event.getPointerCount() == 1) {
|
if (event.getPointerCount() == 1) {
|
||||||
if (this.brightnessOrientation == Orientation.VERTICAL && (this.brightnessCoverage == Coverage.FULL || getCoverageVertical(event) == this.brightnessCoverage)) {
|
if (this.brightnessOrientation == Orientation.VERTICAL && (this.brightnessCoverage == Coverage.FULL || getCoverageVertical(event) == this.brightnessCoverage)) {
|
||||||
this.mBrightnessDownPos = getProgressVertical(event, this.mBrightness.Max);
|
this.mBrightnessDownPos = getProgressVertical(event, this.mBrightness.Max);
|
||||||
@ -135,9 +120,9 @@ public class XFenster implements FensterEventsListener {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override // fi.razerman.youtube.Fenster.FensterEventsListener
|
@Override // app.revanced.integrations.videoplayer.Fenster.FensterEventsListener
|
||||||
public void onUp() {
|
public void onUp() {
|
||||||
Log.d("XDebug", "onUp");
|
LogHelper.debug("XDebug", "onUp");
|
||||||
hideNotifications();
|
hideNotifications();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -165,7 +150,7 @@ public class XFenster implements FensterEventsListener {
|
|||||||
if (this.handler == null) {
|
if (this.handler == null) {
|
||||||
this.handler = new Handler();
|
this.handler = new Handler();
|
||||||
}
|
}
|
||||||
// from class: fi.razerman.youtube.Fenster.XFenster.1
|
// from class: app.revanced.integrations.videoplayer.Fenster.XFenster.1
|
||||||
// java.lang.Runnable
|
// java.lang.Runnable
|
||||||
this.handler.postDelayed(() -> {
|
this.handler.postDelayed(() -> {
|
||||||
XFenster.this.mVolume.hide();
|
XFenster.this.mVolume.hide();
|
||||||
@ -217,26 +202,20 @@ public class XFenster implements FensterEventsListener {
|
|||||||
|
|
||||||
private float getProgressVertical(MotionEvent event, int maxSteps) {
|
private float getProgressVertical(MotionEvent event, int maxSteps) {
|
||||||
float progress = calculateProgressVertical(event, maxSteps);
|
float progress = calculateProgressVertical(event, maxSteps);
|
||||||
if (XGlobals.debug) {
|
LogHelper.debug("XDebug", "Progress vertical: " + progress);
|
||||||
Log.d("XDebug", "Progress vertical: " + progress);
|
|
||||||
}
|
|
||||||
return progress;
|
return progress;
|
||||||
}
|
}
|
||||||
|
|
||||||
private float getProgressHorizontal(MotionEvent event, int maxSteps) {
|
private float getProgressHorizontal(MotionEvent event, int maxSteps) {
|
||||||
float progress = calculateProgressHorizontal(event, maxSteps);
|
float progress = calculateProgressHorizontal(event, maxSteps);
|
||||||
if (XGlobals.debug) {
|
LogHelper.debug("XDebug", "Progress horizontal: " + progress);
|
||||||
Log.d("XDebug", "Progress horizontal: " + progress);
|
|
||||||
}
|
|
||||||
return progress;
|
return progress;
|
||||||
}
|
}
|
||||||
|
|
||||||
private float calculateProgressVertical(MotionEvent event, int maxSteps) {
|
private float calculateProgressVertical(MotionEvent event, int maxSteps) {
|
||||||
float scale;
|
float scale;
|
||||||
int height = this.mViewGroup.getHeight();
|
int height = this.mViewGroup.getHeight();
|
||||||
if (XGlobals.debug) {
|
LogHelper.debug("XDebug", "calculateProgressVertical - height: " + height);
|
||||||
Log.d("XDebug", "calculateProgressVertical - height: " + height);
|
|
||||||
}
|
|
||||||
int available = (height - this.mPaddingTop) - this.mPaddingBottom;
|
int available = (height - this.mPaddingTop) - this.mPaddingBottom;
|
||||||
int y = height - ((int) event.getY());
|
int y = height - ((int) event.getY());
|
||||||
float progress = 0.0f;
|
float progress = 0.0f;
|
||||||
@ -282,21 +261,19 @@ public class XFenster implements FensterEventsListener {
|
|||||||
|
|
||||||
private void checkPlayerOverlaysView() {
|
private void checkPlayerOverlaysView() {
|
||||||
try {
|
try {
|
||||||
if ((this.mViewGroup.getHeight() == 0 || this.mViewGroup.getWidth() == 0) && XSwipeHelper.nextGenWatchLayout != null) {
|
if ((this.mViewGroup.getHeight() == 0 || this.mViewGroup.getWidth() == 0) && SwipeHelper.nextGenWatchLayout != null) {
|
||||||
View layout = XSwipeHelper.nextGenWatchLayout.findViewById(getIdentifier());
|
View layout = SwipeHelper.nextGenWatchLayout.findViewById(getIdentifier());
|
||||||
if (layout != null) {
|
if (layout != null) {
|
||||||
this.mViewGroup = (ViewGroup) layout;
|
this.mViewGroup = (ViewGroup) layout;
|
||||||
this.mBrightness.refreshViewGroup(this.mViewGroup, XSettingsFragment.overlayContext);
|
this.mBrightness.refreshViewGroup(this.mViewGroup, XSettingsFragment.overlayContext);
|
||||||
this.mVolume.refreshViewGroup(this.mViewGroup);
|
this.mVolume.refreshViewGroup(this.mViewGroup);
|
||||||
if (XGlobals.debug) {
|
LogHelper.debug("Settings", "player_overlays refreshed");
|
||||||
Log.d("XGlobals", "player_overlays refreshed");
|
} else {
|
||||||
}
|
LogHelper.debug("Settings", "player_overlays was not found");
|
||||||
} else if (XGlobals.debug) {
|
|
||||||
Log.d("XGlobals", "player_overlays was not found");
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} catch (Exception ex) {
|
} catch (Exception ex) {
|
||||||
Log.e("XError", "Unable to refresh player_overlays layout", ex);
|
LogHelper.printException("XError", "Unable to refresh player_overlays layout", ex);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -1,12 +1,12 @@
|
|||||||
package fi.razerman.youtube.Fenster.Helpers;
|
package app.revanced.integrations.videoswipecontrols.helpers;
|
||||||
|
|
||||||
import android.app.Activity;
|
import android.app.Activity;
|
||||||
import android.content.ContentResolver;
|
import android.content.ContentResolver;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.provider.Settings;
|
|
||||||
import android.util.Log;
|
|
||||||
import android.view.WindowManager;
|
import android.view.WindowManager;
|
||||||
import fi.razerman.youtube.XGlobals;
|
|
||||||
|
import app.revanced.integrations.utils.LogHelper;
|
||||||
|
|
||||||
/* loaded from: classes6.dex */
|
/* loaded from: classes6.dex */
|
||||||
public class BrightnessHelper {
|
public class BrightnessHelper {
|
||||||
@ -26,9 +26,7 @@ public class BrightnessHelper {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static void setBrightness(Context context, int brightness) {
|
public static void setBrightness(Context context, int brightness) {
|
||||||
if (XGlobals.debug) {
|
LogHelper.debug("XDebug", "Setting brightness: " + brightness);
|
||||||
Log.d("XDebug", "Setting brightness: " + brightness);
|
|
||||||
}
|
|
||||||
float bright = brightness / 100.0f;
|
float bright = brightness / 100.0f;
|
||||||
WindowManager.LayoutParams lp = ((Activity) context).getWindow().getAttributes();
|
WindowManager.LayoutParams lp = ((Activity) context).getWindow().getAttributes();
|
||||||
lp.screenBrightness = bright;
|
lp.screenBrightness = bright;
|
||||||
@ -36,18 +34,16 @@ public class BrightnessHelper {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static void setBrightness2(Context context, int brightness) {
|
public static void setBrightness2(Context context, int brightness) {
|
||||||
if (XGlobals.debug) {
|
LogHelper.debug("XDebug", "Setting brightness: " + brightness);
|
||||||
Log.d("XDebug", "Setting brightness: " + brightness);
|
|
||||||
}
|
|
||||||
ContentResolver cResolver = context.getContentResolver();
|
ContentResolver cResolver = context.getContentResolver();
|
||||||
Settings.System.putInt(cResolver, "screen_brightness", brightness);
|
android.provider.Settings.System.putInt(cResolver, "screen_brightness", brightness);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static int getBrightness2(Context context) {
|
public static int getBrightness2(Context context) {
|
||||||
ContentResolver cResolver = context.getContentResolver();
|
ContentResolver cResolver = context.getContentResolver();
|
||||||
try {
|
try {
|
||||||
return Settings.System.getInt(cResolver, "screen_brightness");
|
return android.provider.Settings.System.getInt(cResolver, "screen_brightness");
|
||||||
} catch (Settings.SettingNotFoundException e) {
|
} catch (android.provider.Settings.SettingNotFoundException e) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -1,21 +1,20 @@
|
|||||||
package fi.razerman.youtube.Fenster.Seekbar;
|
package app.revanced.integrations.videoswipecontrols.seekbar;
|
||||||
|
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.os.Handler;
|
import android.os.Handler;
|
||||||
import android.provider.Settings;
|
|
||||||
import android.util.Log;
|
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.view.ViewGroup;
|
import android.view.ViewGroup;
|
||||||
import android.widget.TextView;
|
import android.widget.TextView;
|
||||||
import fi.razerman.youtube.Fenster.Helpers.BrightnessHelper;
|
|
||||||
import fi.razerman.youtube.Helpers.SharedPrefs;
|
import app.revanced.integrations.utils.LogHelper;
|
||||||
import fi.razerman.youtube.XGlobals;
|
import app.revanced.integrations.utils.SharedPrefHelper;
|
||||||
|
import app.revanced.integrations.videoswipecontrols.helpers.BrightnessHelper;
|
||||||
|
|
||||||
/* loaded from: classes6.dex */
|
/* loaded from: classes6.dex */
|
||||||
public class BrightnessSeekBar {
|
public class BrightnessSeekBar {
|
||||||
public static final int MAX_BRIGHTNESS = 100;
|
public static final int MAX_BRIGHTNESS = 100;
|
||||||
public static final int MIN_BRIGHTNESS = 0;
|
public static final int MIN_BRIGHTNESS = 0;
|
||||||
public static final String TAG = "XDebug";
|
|
||||||
public int Max;
|
public int Max;
|
||||||
public int Progress;
|
public int Progress;
|
||||||
private boolean enabled;
|
private boolean enabled;
|
||||||
@ -29,9 +28,9 @@ public class BrightnessSeekBar {
|
|||||||
this.enabled = false;
|
this.enabled = false;
|
||||||
this.mViewGroup = viewGroup;
|
this.mViewGroup = viewGroup;
|
||||||
this.mContext = context;
|
this.mContext = context;
|
||||||
float systemBrightness = Settings.System.getFloat(this.mContext.getContentResolver(), "screen_brightness", -1.0f);
|
float systemBrightness = android.provider.Settings.System.getFloat(this.mContext.getContentResolver(), "screen_brightness", -1.0f);
|
||||||
int _systemBrightness = (int) ((systemBrightness / 255.0f) * 100.0f);
|
int _systemBrightness = (int) ((systemBrightness / 255.0f) * 100.0f);
|
||||||
this.Progress = SharedPrefs.getInt(this.mContext, "xfile_brightness_value", Integer.valueOf(_systemBrightness)).intValue();
|
this.Progress = SharedPrefHelper.getInt(this.mContext, SharedPrefHelper.SharedPrefNames.YOUTUBE, "xfile_brightness_value", Integer.valueOf(_systemBrightness)).intValue();
|
||||||
this.Max = 100;
|
this.Max = 100;
|
||||||
this.mTextView = new TextView(context);
|
this.mTextView = new TextView(context);
|
||||||
this.mTextView.setTextSize(24.0f);
|
this.mTextView.setTextSize(24.0f);
|
||||||
@ -60,9 +59,7 @@ public class BrightnessSeekBar {
|
|||||||
this.mTextView.setVisibility(View.VISIBLE);
|
this.mTextView.setVisibility(View.VISIBLE);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (XGlobals.debug) {
|
LogHelper.debug("XDebug", "updateBrightnessProgress: " + this.Progress);
|
||||||
Log.d("XDebug", "updateBrightnessProgress: " + this.Progress);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void disableBrightness() {
|
private void disableBrightness() {
|
||||||
@ -97,7 +94,7 @@ public class BrightnessSeekBar {
|
|||||||
if (this.handler == null) {
|
if (this.handler == null) {
|
||||||
this.handler = new Handler();
|
this.handler = new Handler();
|
||||||
}
|
}
|
||||||
this.handler.postDelayed(new Runnable() { // from class: fi.razerman.youtube.Fenster.Seekbar.BrightnessSeekBar.1
|
this.handler.postDelayed(new Runnable() { // from class: app.revanced.integrations.videoplayer.Fenster.Seekbar.BrightnessSeekBar.1
|
||||||
@Override // java.lang.Runnable
|
@Override // java.lang.Runnable
|
||||||
public void run() {
|
public void run() {
|
||||||
BrightnessSeekBar.this.hide();
|
BrightnessSeekBar.this.hide();
|
||||||
@ -114,22 +111,22 @@ public class BrightnessSeekBar {
|
|||||||
|
|
||||||
public void disable() {
|
public void disable() {
|
||||||
this.enabled = false;
|
this.enabled = false;
|
||||||
SharedPrefs.saveInt(this.mContext, "xfile_brightness_value", Integer.valueOf(this.Progress));
|
SharedPrefHelper.saveInt(this.mContext, SharedPrefHelper.SharedPrefNames.YOUTUBE,"xfile_brightness_value", Integer.valueOf(this.Progress));
|
||||||
disableBrightness();
|
disableBrightness();
|
||||||
Log.d("XDebug", "Brightness swipe disabled");
|
LogHelper.debug("XDebug", "Brightness swipe disabled");
|
||||||
}
|
}
|
||||||
|
|
||||||
public void enable() {
|
public void enable() {
|
||||||
this.enabled = true;
|
this.enabled = true;
|
||||||
float systemBrightness = Settings.System.getFloat(this.mContext.getContentResolver(), "screen_brightness", -1.0f);
|
float systemBrightness = android.provider.Settings.System.getFloat(this.mContext.getContentResolver(), "screen_brightness", -1.0f);
|
||||||
int _systemBrightness = (int) ((systemBrightness / 255.0f) * 100.0f);
|
int _systemBrightness = (int) ((systemBrightness / 255.0f) * 100.0f);
|
||||||
int brightness = SharedPrefs.getInt(this.mContext, "xfile_brightness_value", Integer.valueOf(_systemBrightness)).intValue();
|
int brightness = SharedPrefHelper.getInt(this.mContext, SharedPrefHelper.SharedPrefNames.YOUTUBE,"xfile_brightness_value", Integer.valueOf(_systemBrightness)).intValue();
|
||||||
if (brightness < 0) {
|
if (brightness < 0) {
|
||||||
brightness = 0;
|
brightness = 0;
|
||||||
} else if (brightness > 100) {
|
} else if (brightness > 100) {
|
||||||
brightness = 100;
|
brightness = 100;
|
||||||
}
|
}
|
||||||
BrightnessHelper.setBrightness(this.mContext, brightness);
|
BrightnessHelper.setBrightness(this.mContext, brightness);
|
||||||
Log.d("XDebug", "Brightness swipe enabled");
|
LogHelper.debug("XDebug", "Brightness swipe enabled");
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -1,4 +1,4 @@
|
|||||||
package fi.razerman.youtube.Fenster.Seekbar;
|
package app.revanced.integrations.videoswipecontrols.seekbar;
|
||||||
|
|
||||||
import android.content.BroadcastReceiver;
|
import android.content.BroadcastReceiver;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
@ -6,11 +6,12 @@ import android.content.Intent;
|
|||||||
import android.content.IntentFilter;
|
import android.content.IntentFilter;
|
||||||
import android.media.AudioManager;
|
import android.media.AudioManager;
|
||||||
import android.os.Handler;
|
import android.os.Handler;
|
||||||
import android.util.Log;
|
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.view.ViewGroup;
|
import android.view.ViewGroup;
|
||||||
import android.widget.TextView;
|
import android.widget.TextView;
|
||||||
import fi.razerman.youtube.XGlobals;
|
|
||||||
|
import app.revanced.integrations.utils.LogHelper;
|
||||||
|
|
||||||
/* loaded from: classes6.dex */
|
/* loaded from: classes6.dex */
|
||||||
public class VolumeSeekBar {
|
public class VolumeSeekBar {
|
||||||
@ -23,7 +24,7 @@ public class VolumeSeekBar {
|
|||||||
private Context mContext;
|
private Context mContext;
|
||||||
TextView mTextView;
|
TextView mTextView;
|
||||||
ViewGroup mViewGroup;
|
ViewGroup mViewGroup;
|
||||||
private final BroadcastReceiver volumeReceiver = new BroadcastReceiver() { // from class: fi.razerman.youtube.Fenster.Seekbar.VolumeSeekBar.1
|
private final BroadcastReceiver volumeReceiver = new BroadcastReceiver() { // from class: app.revanced.integrations.videoplayer.Fenster.Seekbar.VolumeSeekBar.1
|
||||||
@Override // android.content.BroadcastReceiver
|
@Override // android.content.BroadcastReceiver
|
||||||
public void onReceive(Context context, Intent intent) {
|
public void onReceive(Context context, Intent intent) {
|
||||||
VolumeSeekBar.this.updateVolumeProgress();
|
VolumeSeekBar.this.updateVolumeProgress();
|
||||||
@ -62,9 +63,7 @@ public class VolumeSeekBar {
|
|||||||
this.mTextView.setVisibility(View.VISIBLE);
|
this.mTextView.setVisibility(View.VISIBLE);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (XGlobals.debug) {
|
LogHelper.debug("XDebug", "updateVolumeProgress: " + this.Progress);
|
||||||
Log.d("XDebug", "updateVolumeProgress: " + this.Progress);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void setVolume(int volume) {
|
private void setVolume(int volume) {
|
||||||
@ -98,7 +97,7 @@ public class VolumeSeekBar {
|
|||||||
if (this.handler == null) {
|
if (this.handler == null) {
|
||||||
this.handler = new Handler();
|
this.handler = new Handler();
|
||||||
}
|
}
|
||||||
// from class: fi.razerman.youtube.Fenster.Seekbar.VolumeSeekBar.2
|
// from class: app.revanced.integrations.videoplayer.Fenster.Seekbar.VolumeSeekBar.2
|
||||||
// java.lang.Runnable
|
// java.lang.Runnable
|
||||||
this.handler.postDelayed(VolumeSeekBar.this::hide, 2000L);
|
this.handler.postDelayed(VolumeSeekBar.this::hide, 2000L);
|
||||||
}
|
}
|
@ -1,67 +0,0 @@
|
|||||||
package fi.razerman.youtube.Helpers;
|
|
||||||
|
|
||||||
import android.content.Context;
|
|
||||||
import android.content.res.Resources;
|
|
||||||
import android.util.Log;
|
|
||||||
|
|
||||||
import androidx.annotation.NonNull;
|
|
||||||
|
|
||||||
import java.util.HashMap;
|
|
||||||
|
|
||||||
/* loaded from: classes6.dex */
|
|
||||||
public class ColorRef {
|
|
||||||
public static final String CREDITS = "Converted from jakubweg's StringRef https://github.com/YTVanced/SponsorBlock/blob/master/app/src/main/java/pl/jakubweg/StringRef.java";
|
|
||||||
public static final String TAG = "ColorRef";
|
|
||||||
private static final HashMap<String, ColorRef> colors = new HashMap<>();
|
|
||||||
private static String packageName;
|
|
||||||
private static Resources resources;
|
|
||||||
@NonNull
|
|
||||||
private final String colorName;
|
|
||||||
private boolean resolved;
|
|
||||||
private Integer value;
|
|
||||||
|
|
||||||
public static void setContext(Context context) {
|
|
||||||
if (context != null) {
|
|
||||||
resources = context.getApplicationContext().getResources();
|
|
||||||
packageName = context.getPackageName();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@NonNull
|
|
||||||
/* renamed from: cf */
|
|
||||||
public static ColorRef m32591cf(@NonNull String resName, @NonNull Integer defaultValue) {
|
|
||||||
ColorRef ref = colors.get(resName);
|
|
||||||
if (ref != null) {
|
|
||||||
return ref;
|
|
||||||
}
|
|
||||||
ColorRef ref2 = new ColorRef(resName, defaultValue);
|
|
||||||
colors.put(resName, ref2);
|
|
||||||
return ref2;
|
|
||||||
}
|
|
||||||
|
|
||||||
@NonNull
|
|
||||||
public static Integer color(@NonNull String resName, @NonNull Integer defaultValue) {
|
|
||||||
return m32591cf(resName, defaultValue).resolve();
|
|
||||||
}
|
|
||||||
|
|
||||||
public ColorRef(@NonNull String resName, @NonNull Integer defaultValue) {
|
|
||||||
this.colorName = resName;
|
|
||||||
this.value = defaultValue;
|
|
||||||
}
|
|
||||||
|
|
||||||
@NonNull
|
|
||||||
public Integer resolve() {
|
|
||||||
if (!this.resolved) {
|
|
||||||
this.resolved = true;
|
|
||||||
Resources resources2 = resources;
|
|
||||||
if (resources2 != null) {
|
|
||||||
try {
|
|
||||||
this.value = resources2.getColor(resources2.getIdentifier(this.colorName, "color", packageName));
|
|
||||||
} catch (Resources.NotFoundException e) {
|
|
||||||
Log.e(TAG, "Resource not found: " + this.value);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return this.value;
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,10 +0,0 @@
|
|||||||
package fi.razerman.youtube.Helpers;
|
|
||||||
|
|
||||||
import android.text.TextUtils;
|
|
||||||
|
|
||||||
/* loaded from: classes6.dex */
|
|
||||||
public class NullCheck {
|
|
||||||
public static String ensureHasFragment(String fragmentName) {
|
|
||||||
return TextUtils.isEmpty(fragmentName) ? "placeholder" : fragmentName;
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,49 +0,0 @@
|
|||||||
package fi.razerman.youtube.Helpers;
|
|
||||||
|
|
||||||
import android.content.Context;
|
|
||||||
import android.content.SharedPreferences;
|
|
||||||
|
|
||||||
/* loaded from: classes6.dex */
|
|
||||||
public class SharedPrefs {
|
|
||||||
public static void saveString(Context context, String key, String value) {
|
|
||||||
SharedPreferences sharedPreferences = context.getSharedPreferences("youtube", 0);
|
|
||||||
sharedPreferences.edit().putString(key, value).apply();
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void saveBoolean(Context context, String key, Boolean value) {
|
|
||||||
SharedPreferences sharedPreferences = context.getSharedPreferences("youtube", 0);
|
|
||||||
sharedPreferences.edit().putBoolean(key, value).apply();
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void saveInt(Context context, String key, Integer value) {
|
|
||||||
SharedPreferences sharedPreferences = context.getSharedPreferences("youtube", 0);
|
|
||||||
sharedPreferences.edit().putInt(key, value).apply();
|
|
||||||
}
|
|
||||||
|
|
||||||
public static String getString(Context context, String key) {
|
|
||||||
return getString(context, key, null);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static String getString(Context context, String key, String _default) {
|
|
||||||
SharedPreferences sharedPreferences = context.getSharedPreferences("youtube", 0);
|
|
||||||
return sharedPreferences.getString(key, _default);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static Boolean getBoolean(Context context, String key) {
|
|
||||||
return getBoolean(context, key, false);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static Boolean getBoolean(Context context, String key, Boolean _default) {
|
|
||||||
SharedPreferences sharedPreferences = context.getSharedPreferences("youtube", 0);
|
|
||||||
return sharedPreferences.getBoolean(key, _default);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static Integer getInt(Context context, String key) {
|
|
||||||
return getInt(context, key, -1);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static Integer getInt(Context context, String key, Integer _default) {
|
|
||||||
SharedPreferences sharedPreferences = context.getSharedPreferences("youtube", 0);
|
|
||||||
return sharedPreferences.getInt(key, _default);
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,22 +0,0 @@
|
|||||||
package fi.razerman.youtube.Helpers;
|
|
||||||
|
|
||||||
import android.content.Context;
|
|
||||||
import android.content.SharedPreferences;
|
|
||||||
import android.util.Log;
|
|
||||||
|
|
||||||
/* loaded from: classes6.dex */
|
|
||||||
public class XSharedPrefs {
|
|
||||||
public static boolean getBoolean(Context context, String key, boolean defValue) {
|
|
||||||
try {
|
|
||||||
if (context == null) {
|
|
||||||
Log.e("XSharedPrefs", "context is null");
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
SharedPreferences sharedPreferences = context.getSharedPreferences("youtube", 0);
|
|
||||||
return sharedPreferences.getBoolean(key, defValue);
|
|
||||||
} catch (Exception ex) {
|
|
||||||
Log.e("XSharedPrefs", "Error getting boolean", ex);
|
|
||||||
return defValue;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,247 +0,0 @@
|
|||||||
package fi.razerman.youtube;
|
|
||||||
|
|
||||||
import android.util.Log;
|
|
||||||
import android.view.View;
|
|
||||||
import android.view.ViewGroup;
|
|
||||||
import android.widget.FrameLayout;
|
|
||||||
import android.widget.LinearLayout;
|
|
||||||
import android.widget.RelativeLayout;
|
|
||||||
import android.widget.Toolbar;
|
|
||||||
import fi.razerman.youtube.preferences.BooleanPreferences;
|
|
||||||
|
|
||||||
/* loaded from: classes6.dex */
|
|
||||||
public class XAdRemover {
|
|
||||||
public static Object RemoveInfoCardSuggestions(Object InfoCardOverlayPresenter) {
|
|
||||||
XGlobals.ReadSettings();
|
|
||||||
if (!XGlobals.suggestionsShown) {
|
|
||||||
InfoCardOverlayPresenter = null;
|
|
||||||
}
|
|
||||||
if (XGlobals.debug) {
|
|
||||||
if (InfoCardOverlayPresenter == null) {
|
|
||||||
Log.d("XAdRemover", "RemoveInfoCardSuggestions: true");
|
|
||||||
} else {
|
|
||||||
Log.d("XAdRemover", "RemoveInfoCardSuggestions: false");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return InfoCardOverlayPresenter;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static Boolean RemoveSuggestions(Boolean showSuggestions) {
|
|
||||||
XGlobals.ReadSettings();
|
|
||||||
if (showSuggestions && !XGlobals.suggestionsShown) {
|
|
||||||
if (XGlobals.debug) {
|
|
||||||
Log.d("XAdRemover", "RemoveSuggestions: Removed");
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
} else if (XGlobals.debug && showSuggestions) {
|
|
||||||
Log.d("XAdRemover", "RemoveSuggestions: Not removed");
|
|
||||||
return true;
|
|
||||||
} else if (!XGlobals.debug) {
|
|
||||||
return showSuggestions;
|
|
||||||
} else {
|
|
||||||
Log.d("XAdRemover", "RemoveSuggestions: Already not shown");
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public static FrameLayout CheckInfoCardsStatus(FrameLayout frameLayout) {
|
|
||||||
XGlobals.ReadSettings();
|
|
||||||
frameLayout.setVisibility(XGlobals.infoCardsShown ? View.VISIBLE : View.GONE);
|
|
||||||
if (XGlobals.debug) {
|
|
||||||
Log.d("XAdRemover", "CheckInfoCardsStatus - Set visibility to: " + XGlobals.infoCardsShown);
|
|
||||||
}
|
|
||||||
return frameLayout;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static boolean isBrandingWatermarkShown(boolean defaultValue) {
|
|
||||||
XGlobals.ReadSettings();
|
|
||||||
if (defaultValue && !XGlobals.brandingShown) {
|
|
||||||
if (XGlobals.debug) {
|
|
||||||
Log.d("XAdRemover", "BrandingWatermark: Removed");
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
} else if (XGlobals.debug && defaultValue) {
|
|
||||||
Log.d("XAdRemover", "BrandingWatermark: Not removed");
|
|
||||||
return true;
|
|
||||||
} else if (!XGlobals.debug) {
|
|
||||||
return defaultValue;
|
|
||||||
} else {
|
|
||||||
Log.d("XAdRemover", "BrandingWatermark: Already not shown");
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public static int BrandingWatermark(int defaultValue) {
|
|
||||||
XGlobals.ReadSettings();
|
|
||||||
if (defaultValue == 0 && !XGlobals.brandingShown) {
|
|
||||||
if (XGlobals.debug) {
|
|
||||||
Log.d("XAdRemover", "BrandingWatermark: Removed");
|
|
||||||
}
|
|
||||||
return 8;
|
|
||||||
} else if (XGlobals.debug && defaultValue == 0) {
|
|
||||||
Log.d("XAdRemover", "BrandingWatermark: Not removed");
|
|
||||||
return defaultValue;
|
|
||||||
} else if (!XGlobals.debug) {
|
|
||||||
return defaultValue;
|
|
||||||
} else {
|
|
||||||
Log.d("XAdRemover", "BrandingWatermark: Already not shown");
|
|
||||||
return defaultValue;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private static void recursiveLoopChildren(ViewGroup parent) {
|
|
||||||
for (int i = 0; i < parent.getChildCount(); i++) {
|
|
||||||
View child = parent.getChildAt(i);
|
|
||||||
if (child instanceof ViewGroup) {
|
|
||||||
recursiveLoopChildren((ViewGroup) child);
|
|
||||||
child.setVisibility(View.GONE);
|
|
||||||
} else if (child != null) {
|
|
||||||
child.setVisibility(View.GONE);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void HideViewV2(View view) {
|
|
||||||
XGlobals.ReadSettings();
|
|
||||||
if (!XGlobals.homeAdsShown) {
|
|
||||||
recursiveLoopChildren((ViewGroup) view);
|
|
||||||
RelativeLayout relativeLayout = new RelativeLayout(XGlobals.getContext());
|
|
||||||
RelativeLayout.LayoutParams rlp = new RelativeLayout.LayoutParams(1, 1);
|
|
||||||
((ViewGroup) view).addView(relativeLayout, rlp);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void HideReel(View view) {
|
|
||||||
XGlobals.ReadSettings();
|
|
||||||
if (!XGlobals.reelShown) {
|
|
||||||
if (XGlobals.debug) {
|
|
||||||
Log.d("XAdRemover", "HideReel: " + view.getId());
|
|
||||||
}
|
|
||||||
HideViewWithLayout1dp(view);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void HideView(View view) {
|
|
||||||
XGlobals.ReadSettings();
|
|
||||||
if (!XGlobals.homeAdsShown) {
|
|
||||||
if (XGlobals.debug) {
|
|
||||||
Log.d("XAdRemover", "HideView: " + view.getId());
|
|
||||||
}
|
|
||||||
HideViewWithLayout1dp(view);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private static void HideViewWithLayout1dp(View view) {
|
|
||||||
if (view instanceof LinearLayout) {
|
|
||||||
LinearLayout.LayoutParams layoutParams = new LinearLayout.LayoutParams(1, 1);
|
|
||||||
view.setLayoutParams(layoutParams);
|
|
||||||
} else if (view instanceof FrameLayout) {
|
|
||||||
FrameLayout.LayoutParams layoutParams2 = new FrameLayout.LayoutParams(1, 1);
|
|
||||||
view.setLayoutParams(layoutParams2);
|
|
||||||
} else if (view instanceof RelativeLayout) {
|
|
||||||
RelativeLayout.LayoutParams layoutParams3 = new RelativeLayout.LayoutParams(1, 1);
|
|
||||||
view.setLayoutParams(layoutParams3);
|
|
||||||
} else if (view instanceof Toolbar) {
|
|
||||||
Toolbar.LayoutParams layoutParams4 = new Toolbar.LayoutParams(1, 1);
|
|
||||||
view.setLayoutParams(layoutParams4);
|
|
||||||
} else if (view instanceof ViewGroup) {
|
|
||||||
ViewGroup.LayoutParams layoutParams5 = new ViewGroup.LayoutParams(1, 1);
|
|
||||||
view.setLayoutParams(layoutParams5);
|
|
||||||
} else if (XGlobals.debug) {
|
|
||||||
Log.d("XAdRemover", "HideViewWithLayout1dp - Id: " + view.getId() + " Type: " + view.getClass().getName());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public static boolean VideoAdsEnabled(boolean input) {
|
|
||||||
XGlobals.ReadSettings();
|
|
||||||
if (XGlobals.videoAdsShown) {
|
|
||||||
if (XGlobals.debug) {
|
|
||||||
Log.d("XAdRemover", "Videoads: shown - " + input);
|
|
||||||
}
|
|
||||||
return input;
|
|
||||||
} else if (!XGlobals.debug) {
|
|
||||||
return false;
|
|
||||||
} else {
|
|
||||||
Log.d("XAdRemover", "Videoads: hidden");
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void hideCreateButton(View view) {
|
|
||||||
if (BooleanPreferences.isCreateButtonHidden()) {
|
|
||||||
if (XGlobals.debug) {
|
|
||||||
Log.d("XAdRemover", "Create button: shown");
|
|
||||||
}
|
|
||||||
view.setVisibility(View.GONE);
|
|
||||||
} else if (XGlobals.debug) {
|
|
||||||
Log.d("XAdRemover", "Create button: hidden");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void hideShortsButton(View view) {
|
|
||||||
if (XGlobals.lastPivotTab != null && XGlobals.lastPivotTab.name() == "TAB_SHORTS") {
|
|
||||||
if (BooleanPreferences.isShortsButtonHidden()) {
|
|
||||||
if (XGlobals.debug) {
|
|
||||||
Log.d("XAdRemover", "Shorts button: shown");
|
|
||||||
}
|
|
||||||
view.setVisibility(View.GONE);
|
|
||||||
} else if (XGlobals.debug) {
|
|
||||||
Log.d("XAdRemover", "Shorts button: hidden");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void inspectComponentHost(Object item) {
|
|
||||||
StackTraceElement[] stackTraceElements = Thread.currentThread().getStackTrace();
|
|
||||||
if (stackTraceElements.length <= 3) {
|
|
||||||
Log.d("Litho", "Couldn't locate the method called from.");
|
|
||||||
} else {
|
|
||||||
String sb = "Called from method: " +
|
|
||||||
stackTraceElements[3].toString() + "\n";
|
|
||||||
Log.d("Litho", sb);
|
|
||||||
}
|
|
||||||
if (item == null) {
|
|
||||||
Log.d("Litho", "Item is null.");
|
|
||||||
} else if (item.getClass().getSimpleName().contains("cwl")) {
|
|
||||||
Log.d("Litho", "Item is a cwl item.");
|
|
||||||
Log.i("Litho", getViewHierarchy((ViewGroup) item));
|
|
||||||
} else {
|
|
||||||
Log.d("Litho", "Item is not a cwl item.");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public static String getViewHierarchy(ViewGroup v) {
|
|
||||||
StringBuffer buf = new StringBuffer();
|
|
||||||
printViews(v, buf, 0);
|
|
||||||
return buf.toString();
|
|
||||||
}
|
|
||||||
|
|
||||||
private static String printViews(ViewGroup v, StringBuffer buf, int level) {
|
|
||||||
int childCount = v.getChildCount();
|
|
||||||
v.getId();
|
|
||||||
indent(buf, level);
|
|
||||||
buf.append(v.getClass().getName());
|
|
||||||
buf.append(" children:");
|
|
||||||
buf.append(childCount);
|
|
||||||
buf.append(" id:").append(v.getId());
|
|
||||||
buf.append("\n");
|
|
||||||
for (int i = 0; i < childCount; i++) {
|
|
||||||
View child = v.getChildAt(i);
|
|
||||||
if (child instanceof ViewGroup) {
|
|
||||||
printViews((ViewGroup) child, buf, level + 1);
|
|
||||||
} else {
|
|
||||||
indent(buf, level + 1);
|
|
||||||
buf.append(child.getClass().getName());
|
|
||||||
buf.append(" id:").append(child.getId());
|
|
||||||
buf.append("\n");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return buf.toString();
|
|
||||||
}
|
|
||||||
|
|
||||||
private static void indent(StringBuffer buf, int level) {
|
|
||||||
for (int i = 0; i < level; i++) {
|
|
||||||
buf.append(" ");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,431 +0,0 @@
|
|||||||
package fi.razerman.youtube;
|
|
||||||
|
|
||||||
import android.content.Context;
|
|
||||||
import android.content.SharedPreferences;
|
|
||||||
import android.content.res.ColorStateList;
|
|
||||||
import android.content.res.Resources;
|
|
||||||
import android.graphics.Point;
|
|
||||||
import android.graphics.Rect;
|
|
||||||
import android.media.MediaCodec;
|
|
||||||
import android.os.Build;
|
|
||||||
import android.util.Base64;
|
|
||||||
import android.util.DisplayMetrics;
|
|
||||||
import android.util.Log;
|
|
||||||
import android.view.View;
|
|
||||||
import android.view.ViewGroup;
|
|
||||||
import android.widget.TextView;
|
|
||||||
import androidx.annotation.NonNull;
|
|
||||||
|
|
||||||
import com.google.android.apps.youtube.app.YouTubeTikTokRoot_Application;
|
|
||||||
import java.nio.ByteBuffer;
|
|
||||||
import java.nio.charset.StandardCharsets;
|
|
||||||
|
|
||||||
/* loaded from: classes6.dex */
|
|
||||||
public class XDebug {
|
|
||||||
private static final char[] hexArray = "0123456789ABCDEF".toCharArray();
|
|
||||||
|
|
||||||
public static void printBooleanWithMethod(boolean bool) {
|
|
||||||
StackTraceElement[] stackTraceElements = Thread.currentThread().getStackTrace();
|
|
||||||
if (stackTraceElements.length <= 3) {
|
|
||||||
Log.d("XBoolean", "Couldn't locate the method called from.");
|
|
||||||
Log.d("XBoolean", "" + bool);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
Log.d("XBoolean", "Called from method: " + stackTraceElements[3].toString() + "\n");
|
|
||||||
Log.d("XBoolean", "" + bool);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void printColorStateListWithMethod(ColorStateList colorStateList) {
|
|
||||||
StackTraceElement[] stackTraceElements = Thread.currentThread().getStackTrace();
|
|
||||||
if (stackTraceElements.length <= 3) {
|
|
||||||
Log.d("XColorStateList", "Couldn't locate the method called from.");
|
|
||||||
} else {
|
|
||||||
Log.d("XColorStateList", "Called from method: " + stackTraceElements[3].toString() + "\n");
|
|
||||||
}
|
|
||||||
if (colorStateList == null) {
|
|
||||||
Log.d("XColorStateList", "<Null>");
|
|
||||||
} else {
|
|
||||||
Log.d("XColorStateList", "" + colorStateList);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void printIntIntWithMethod(int integer, int integer2) {
|
|
||||||
StackTraceElement[] stackTraceElements = Thread.currentThread().getStackTrace();
|
|
||||||
if (stackTraceElements.length <= 3) {
|
|
||||||
Log.d("XIntInt", "Couldn't locate the method called from.");
|
|
||||||
Log.d("XIntInt", "" + integer + " | " + integer2);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
Log.d("XIntInt", "Called from method: " + stackTraceElements[3].toString() + "\n");
|
|
||||||
Log.d("XIntInt", "" + integer + " | " + integer2);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void printIntWithMethod(int integer) {
|
|
||||||
StackTraceElement[] stackTraceElements = Thread.currentThread().getStackTrace();
|
|
||||||
if (stackTraceElements.length <= 3) {
|
|
||||||
Log.d("XInt", "Couldn't locate the method called from.");
|
|
||||||
Log.d("XInt", "" + integer);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
Log.d("XInt", "Called from method: " + stackTraceElements[3].toString() + "\n");
|
|
||||||
Log.d("XInt", "" + integer);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void printStringWithMethod(String string) {
|
|
||||||
if (string == null || string.isEmpty()) {
|
|
||||||
string = "-- null --";
|
|
||||||
}
|
|
||||||
StackTraceElement[] stackTraceElements = Thread.currentThread().getStackTrace();
|
|
||||||
if (stackTraceElements.length <= 3) {
|
|
||||||
Log.d("XString", "Couldn't locate the method called from.");
|
|
||||||
Log.d("XString", string);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
Log.d("XString", "Called from method: " + stackTraceElements[3].toString() + "\n");
|
|
||||||
Log.d("XString", string);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void printCharSequenceBooleanWithMethod(CharSequence charSequence, boolean bool) {
|
|
||||||
StackTraceElement[] stackTraceElements = Thread.currentThread().getStackTrace();
|
|
||||||
if (stackTraceElements.length <= 3) {
|
|
||||||
Log.d("XCharSequenceB", "Couldn't locate the method called from.");
|
|
||||||
} else {
|
|
||||||
Log.d("XCharSequenceB", "Called from method: " + stackTraceElements[3].toString() + "\n");
|
|
||||||
}
|
|
||||||
if (charSequence == null) {
|
|
||||||
Log.d("XCharSequenceB", "<Null>");
|
|
||||||
} else {
|
|
||||||
Log.d("XCharSequenceB", charSequence + " | " + (bool ? "true" : "false"));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void printCharSequenceWithMethod(CharSequence charSequence) {
|
|
||||||
StackTraceElement[] stackTraceElements = Thread.currentThread().getStackTrace();
|
|
||||||
if (stackTraceElements.length <= 3) {
|
|
||||||
Log.d("XCharSequence", "Couldn't locate the method called from.");
|
|
||||||
} else {
|
|
||||||
Log.d("XCharSequence", "Called from method: " + stackTraceElements[3].toString() + "\n");
|
|
||||||
}
|
|
||||||
if (charSequence == null) {
|
|
||||||
Log.d("XCharSequence", "<Null>");
|
|
||||||
} else {
|
|
||||||
Log.d("XCharSequence", charSequence.toString());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void printCharSequenceAndBufferTypeWithMethod(CharSequence charSequence, TextView.BufferType bufferType) {
|
|
||||||
StackTraceElement[] stackTraceElements = Thread.currentThread().getStackTrace();
|
|
||||||
if (stackTraceElements.length <= 3) {
|
|
||||||
Log.d("XCharSequenceBT", "Couldn't locate the method called from.");
|
|
||||||
if (charSequence == null) {
|
|
||||||
if (bufferType == null) {
|
|
||||||
Log.d("XCharSequenceBT", "<Null>");
|
|
||||||
} else {
|
|
||||||
Log.d("XCharSequenceBT", "<Null> | " + bufferType);
|
|
||||||
}
|
|
||||||
} else if (bufferType == null) {
|
|
||||||
Log.d("XCharSequenceBT", charSequence.toString());
|
|
||||||
} else {
|
|
||||||
Log.d("XCharSequenceBT", charSequence.toString() + " | " + bufferType);
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
Log.d("XCharSequenceBT", "Called from method: " + stackTraceElements[3].toString() + "\n");
|
|
||||||
if (charSequence == null) {
|
|
||||||
Log.d("XCharSequenceBT", "<Null>");
|
|
||||||
} else {
|
|
||||||
Log.d("XCharSequenceBT", charSequence.toString());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void printStringBuilder(StringBuilder stringBuilder) {
|
|
||||||
StackTraceElement[] stackTraceElements = Thread.currentThread().getStackTrace();
|
|
||||||
if (stackTraceElements.length <= 3) {
|
|
||||||
Log.d("XStringBuilder", "Couldn't locate the method called from.");
|
|
||||||
Log.d("XStringBuilder", stringBuilder.toString());
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
Log.d("XStringBuilder", "Called from method: " + stackTraceElements[3].toString() + "\n");
|
|
||||||
Log.d("XStringBuilder", stringBuilder.toString());
|
|
||||||
Log.d("StackWithMethod", stringBuilder.toString());
|
|
||||||
printStackTrace("StackWithMethod");
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void printMethod() {
|
|
||||||
StackTraceElement[] stackTraceElements = Thread.currentThread().getStackTrace();
|
|
||||||
if (stackTraceElements.length > 3) {
|
|
||||||
Log.d("XStack", stackTraceElements[3].toString() + "\n");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void printStackTraces() {
|
|
||||||
StackTraceElement[] stackTraceElements = Thread.currentThread().getStackTrace();
|
|
||||||
for (StackTraceElement element : stackTraceElements) {
|
|
||||||
System.out.println("Class name :: " + element.getClassName() + " || method name :: " + element.getMethodName());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void printStackTrace() {
|
|
||||||
StackTraceElement[] stackTraceElements = Thread.currentThread().getStackTrace();
|
|
||||||
StringBuilder stringBuilder = new StringBuilder();
|
|
||||||
for (StackTraceElement element : stackTraceElements) {
|
|
||||||
stringBuilder.append(element.toString()).append("\n");
|
|
||||||
}
|
|
||||||
Log.d("xfileSTACK", stringBuilder.toString());
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void printStackTrace(String tag) {
|
|
||||||
StackTraceElement[] stackTraceElements = Thread.currentThread().getStackTrace();
|
|
||||||
StringBuilder stringBuilder = new StringBuilder();
|
|
||||||
for (StackTraceElement element : stackTraceElements) {
|
|
||||||
stringBuilder.append(element.toString()).append("\n");
|
|
||||||
}
|
|
||||||
Log.d(tag, stringBuilder.toString());
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void printDebugBoolean(boolean val) {
|
|
||||||
Log.d("XDebug", "" + val);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void printDebugInteger(int value) {
|
|
||||||
Log.d("XDebug", "" + value);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void printDebugFloat(float value) {
|
|
||||||
Log.d("XDebug", "" + value);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void printDebugLong(long value) {
|
|
||||||
Log.d("XDebug", "" + value);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void printDebugString(String value) {
|
|
||||||
if (value != null) {
|
|
||||||
Log.d("XDebug", value);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void printDebugStringWithMethodName(String value) {
|
|
||||||
StackTraceElement[] stackTraceElements;
|
|
||||||
if (value != null && (stackTraceElements = Thread.currentThread().getStackTrace()) != null && stackTraceElements.length > 3) {
|
|
||||||
Log.d("XDebug", value + " | " + stackTraceElements[3].toString() + "\n");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void printDebugStringWithStack(String value) {
|
|
||||||
StackTraceElement[] stackTraceElements;
|
|
||||||
if (!(value == null || (stackTraceElements = Thread.currentThread().getStackTrace()) == null)) {
|
|
||||||
StringBuilder stringBuilder = new StringBuilder();
|
|
||||||
for (StackTraceElement element : stackTraceElements) {
|
|
||||||
stringBuilder.append(element.toString()).append("\n");
|
|
||||||
}
|
|
||||||
Log.d("XDebug", value + " | " + stringBuilder.toString());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void printDebugByteArray(byte[] value) {
|
|
||||||
Log.d("XDebug", bytesToHex(value));
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void printByteBufferWithMethod(ByteBuffer buf) {
|
|
||||||
String string;
|
|
||||||
if (buf == null) {
|
|
||||||
string = "-- null --";
|
|
||||||
} else {
|
|
||||||
string = new String(buf.array(), StandardCharsets.UTF_8);
|
|
||||||
if (string.isEmpty()) {
|
|
||||||
string = "-- null --";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
StackTraceElement[] stackTraceElements = Thread.currentThread().getStackTrace();
|
|
||||||
if (stackTraceElements.length <= 3) {
|
|
||||||
Log.d("XByteBuffer", "Couldn't locate the method called from.");
|
|
||||||
Log.d("XByteBuffer", string);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
Log.d("XByteBuffer", "Called from method: " + stackTraceElements[3].toString() + "\n");
|
|
||||||
Log.d("XByteBuffer", string);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void printDebugByteBuffer(ByteBuffer buf) {
|
|
||||||
byte[] bytes = new byte[buf.remaining()];
|
|
||||||
buf.get(bytes, 0, bytes.length);
|
|
||||||
buf.clear();
|
|
||||||
byte[] bytes2 = new byte[buf.capacity()];
|
|
||||||
buf.get(bytes2, 0, bytes2.length);
|
|
||||||
Log.d("XDebug", bytesToHex(bytes2));
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void printDebugByteBuffer(ByteBuffer[] buffers) {
|
|
||||||
int length = buffers.length;
|
|
||||||
int i = 0;
|
|
||||||
int index = 0;
|
|
||||||
while (i < length) {
|
|
||||||
ByteBuffer buf = buffers[i];
|
|
||||||
byte[] bytes = new byte[buf.remaining()];
|
|
||||||
buf.get(bytes, 0, bytes.length);
|
|
||||||
buf.clear();
|
|
||||||
byte[] bytes2 = new byte[buf.capacity()];
|
|
||||||
buf.get(bytes2, 0, bytes2.length);
|
|
||||||
Log.d("XDebug - Index: " + index, bytesToHex(bytes2));
|
|
||||||
i++;
|
|
||||||
index++;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void printDebugMediaCodec(MediaCodec mediaCodec) {
|
|
||||||
Exception e;
|
|
||||||
int i = 0;
|
|
||||||
try {
|
|
||||||
ByteBuffer[] outputBuffers = mediaCodec.getOutputBuffers();
|
|
||||||
int length = outputBuffers.length;
|
|
||||||
int index = 0;
|
|
||||||
while (i < length) {
|
|
||||||
try {
|
|
||||||
ByteBuffer buf = outputBuffers[i];
|
|
||||||
byte[] bytes = new byte[buf.remaining()];
|
|
||||||
buf.get(bytes, 0, bytes.length);
|
|
||||||
buf.clear();
|
|
||||||
byte[] bytes2 = new byte[buf.capacity()];
|
|
||||||
buf.get(bytes2, 0, bytes2.length);
|
|
||||||
int index2 = index + 1;
|
|
||||||
Log.d("XDebug - Index: " + index, bytesToHex(bytes2));
|
|
||||||
i++;
|
|
||||||
index = index2;
|
|
||||||
} catch (Exception e2) {
|
|
||||||
e = e2;
|
|
||||||
Log.d("XDebug abc", "Error: " + e.getMessage());
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} catch (Exception ignored) {
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void printDebugMediaCodec(MediaCodec mediaCodec, int i) {
|
|
||||||
try {
|
|
||||||
ByteBuffer buf = mediaCodec.getOutputBuffer(i);
|
|
||||||
byte[] bytes = getByteArrayFromByteBuffer(buf);
|
|
||||||
Log.d("XDebug - decrypt: " + i, bytesToHex(bytes));
|
|
||||||
} catch (Exception e) {
|
|
||||||
Log.d("XDebug - buffer: " + i, "Error: " + i + " | " + e.getMessage());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private static byte[] getByteArrayFromByteBuffer(ByteBuffer byteBuffer) {
|
|
||||||
byte[] bytesArray = new byte[byteBuffer.capacity()];
|
|
||||||
byteBuffer.get(bytesArray, 0, bytesArray.length);
|
|
||||||
return bytesArray;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void printDebugRect(Rect value) {
|
|
||||||
Log.d("XDebug", "Rectangle| Left:" + value.left + " - Top: " + value.top + " - Right: " + value.right + " - Bottom: " + value.bottom);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static DisplayMetrics getMetrics() {
|
|
||||||
return new DisplayMetrics();
|
|
||||||
}
|
|
||||||
|
|
||||||
public static Point getRealSize() {
|
|
||||||
return new Point(3840, 2160);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static Point getSize() {
|
|
||||||
return new Point(3840, 2160);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static Point getPhysicalSize() {
|
|
||||||
return new Point(3840, 2160);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static int getDisplayWidth() {
|
|
||||||
return 2160;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static int getDisplayHeight() {
|
|
||||||
return 3840;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static String CheckYTRed(String input, String original) {
|
|
||||||
if (input.equals("has_unlimited_entitlement") || input.equals("has_unlimited_ncc_free_trial")) {
|
|
||||||
return "True";
|
|
||||||
}
|
|
||||||
if (input.equals("e")) {
|
|
||||||
return "11202604,23700636,23701019,9415293,9422596,9431754,9435797,9444109,9444635,9449243,9456940,9461315,9463829,9464088,9466234,9467503,9474594,9476327,9477602,9478523,9479785,9480475,9480495,9482942,9484378,9484706,9488038,9489706";
|
|
||||||
}
|
|
||||||
return original;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static String DecodeColdConfig() {
|
|
||||||
Context context = YouTubeTikTokRoot_Application.getAppContext();
|
|
||||||
if (XGlobals.XFILEDEBUG && context == null) {
|
|
||||||
context = XSettingActivity.getAppContext();
|
|
||||||
}
|
|
||||||
if (context == null) {
|
|
||||||
Log.e("XDebug", "Context is null, ignoring to decode");
|
|
||||||
return Build.MANUFACTURER;
|
|
||||||
}
|
|
||||||
SharedPreferences sharedPreferences = context.getSharedPreferences("youtube", 0);
|
|
||||||
String config_group = sharedPreferences.getString("com.google.android.libraries.youtube.innertube.cold_config_group", null);
|
|
||||||
String decoded = "";
|
|
||||||
if (config_group == null) {
|
|
||||||
return decoded;
|
|
||||||
}
|
|
||||||
try {
|
|
||||||
if (config_group.isEmpty()) {
|
|
||||||
return decoded;
|
|
||||||
}
|
|
||||||
decoded = bytesToHex(Base64.decode(config_group, 8));
|
|
||||||
sharedPreferences.edit().putString("com.google.android.libraries.youtube.innertube.cold_config_group.decoded", decoded).apply();
|
|
||||||
return decoded;
|
|
||||||
} catch (Exception e) {
|
|
||||||
return decoded;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public static String bytesToHex(byte[] bytes) {
|
|
||||||
char[] hexChars = new char[bytes.length * 2];
|
|
||||||
for (int j = 0; j < bytes.length; j++) {
|
|
||||||
int v = bytes[j] & 255;
|
|
||||||
hexChars[j * 2] = hexArray[v >>> 4];
|
|
||||||
hexChars[(j * 2) + 1] = hexArray[v & 15];
|
|
||||||
}
|
|
||||||
return new String(hexChars);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static long ConvertDoubleToLong(double value) {
|
|
||||||
return (long) value;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void getViewHierarchy(@NonNull View v) {
|
|
||||||
StringBuilder desc = new StringBuilder();
|
|
||||||
getViewHierarchy(v, desc, 0);
|
|
||||||
Log.d("XDebug", desc.toString());
|
|
||||||
}
|
|
||||||
|
|
||||||
private static void getViewHierarchy(View v, StringBuilder desc, int margin) {
|
|
||||||
desc.append(getViewMessage(v, margin));
|
|
||||||
if (v instanceof ViewGroup) {
|
|
||||||
int margin2 = margin + 1;
|
|
||||||
ViewGroup vg = (ViewGroup) v;
|
|
||||||
for (int i = 0; i < vg.getChildCount(); i++) {
|
|
||||||
getViewHierarchy(vg.getChildAt(i), desc, margin2);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private static String getViewMessage(View v, int marginOffset) {
|
|
||||||
String resourceId;
|
|
||||||
String repeated = new String(new char[marginOffset]).replace("\u0000", " ");
|
|
||||||
try {
|
|
||||||
if (v.getResources() != null) {
|
|
||||||
resourceId = v.getId() != 0 ? v.getResources().getResourceName(v.getId()) : "no_id";
|
|
||||||
} else {
|
|
||||||
resourceId = "no_resources";
|
|
||||||
}
|
|
||||||
return repeated + "[" + v.getClass().getSimpleName() + "] " + resourceId + "\n";
|
|
||||||
} catch (Resources.NotFoundException e) {
|
|
||||||
return repeated + "[" + v.getClass().getSimpleName() + "] name_not_found\n";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
File diff suppressed because it is too large
Load Diff
@ -1,65 +0,0 @@
|
|||||||
package fi.razerman.youtube;
|
|
||||||
|
|
||||||
import android.text.format.Time;
|
|
||||||
import android.util.Log;
|
|
||||||
import java.io.BufferedReader;
|
|
||||||
import java.io.InputStreamReader;
|
|
||||||
import java.net.URL;
|
|
||||||
import org.json.JSONObject;
|
|
||||||
|
|
||||||
/* loaded from: classes6.dex */
|
|
||||||
public class XJson {
|
|
||||||
public static String[] getVersion(String versionName) {
|
|
||||||
try {
|
|
||||||
final String[] results = new String[4];
|
|
||||||
final String vName = versionName.replace('.', '_');
|
|
||||||
Thread t = new Thread() { // from class: fi.razerman.youtube.XJson.1
|
|
||||||
@Override // java.lang.Thread, java.lang.Runnable
|
|
||||||
public void run() {
|
|
||||||
try {
|
|
||||||
Time now = new Time();
|
|
||||||
now.setToNow();
|
|
||||||
String time = "" + now.hour + now.minute + now.second;
|
|
||||||
int time_int = Integer.parseInt(time);
|
|
||||||
URL url = new URL("https://github.com/YTVanced/VancedBackend/releases/download/changelogs/" + vName + "?searchTime=" + time_int); // TODO change to ReVanced changelog URL.
|
|
||||||
url.openConnection().setReadTimeout(2000);
|
|
||||||
url.openConnection().setConnectTimeout(2000);
|
|
||||||
BufferedReader reader = new BufferedReader(new InputStreamReader(url.openStream()));
|
|
||||||
StringBuilder sb = new StringBuilder();
|
|
||||||
while (true) {
|
|
||||||
String line = reader.readLine();
|
|
||||||
if (line != null) {
|
|
||||||
sb.append(line).append("\n");
|
|
||||||
} else {
|
|
||||||
String json = sb.toString();
|
|
||||||
reader.close();
|
|
||||||
JSONObject jsonObject = new JSONObject(json);
|
|
||||||
String title = jsonObject.getString("title");
|
|
||||||
String message = jsonObject.getString("message");
|
|
||||||
String buttonpositive = jsonObject.getString("buttonpositive");
|
|
||||||
results[0] = title;
|
|
||||||
results[1] = message;
|
|
||||||
results[2] = buttonpositive;
|
|
||||||
try {
|
|
||||||
String buttonnegative = jsonObject.getString("buttonnegative");
|
|
||||||
results[3] = buttonnegative;
|
|
||||||
return;
|
|
||||||
} catch (Exception e) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} catch (Exception e2) {
|
|
||||||
Log.e("XError", "exception", e2);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
};
|
|
||||||
t.start();
|
|
||||||
t.join();
|
|
||||||
return results;
|
|
||||||
} catch (Exception e) {
|
|
||||||
Log.e("XError", "exception", e);
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,18 +0,0 @@
|
|||||||
package fi.razerman.youtube;
|
|
||||||
|
|
||||||
import android.app.Activity;
|
|
||||||
|
|
||||||
/* loaded from: classes6.dex */
|
|
||||||
final class XRecreate implements Runnable {
|
|
||||||
private final Activity activity;
|
|
||||||
|
|
||||||
/* JADX INFO: Access modifiers changed from: package-private */
|
|
||||||
public XRecreate(Activity activity) {
|
|
||||||
this.activity = activity;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override // java.lang.Runnable
|
|
||||||
public final void run() {
|
|
||||||
this.activity.recreate();
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,25 +0,0 @@
|
|||||||
package fi.razerman.youtube;
|
|
||||||
|
|
||||||
import android.app.Activity;
|
|
||||||
import android.os.Handler;
|
|
||||||
import android.os.Looper;
|
|
||||||
import android.preference.Preference;
|
|
||||||
|
|
||||||
/* loaded from: classes6.dex */
|
|
||||||
public final class XRefresher implements Preference.OnPreferenceClickListener {
|
|
||||||
private final XSettingsFragment fragment;
|
|
||||||
|
|
||||||
public XRefresher(XSettingsFragment xSettingsFragment) {
|
|
||||||
this.fragment = xSettingsFragment;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override // android.preference.Preference.OnPreferenceClickListener
|
|
||||||
public final boolean onPreferenceClick(Preference preference) {
|
|
||||||
XSettingsFragment fragment = this.fragment;
|
|
||||||
Handler handler = new Handler(Looper.getMainLooper());
|
|
||||||
Activity activity = fragment.getActivity();
|
|
||||||
activity.getClass();
|
|
||||||
handler.postAtFrontOfQueue(new XRecreate(activity));
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user