You've already forked revanced-integrations
mirror of
https://github.com/revanced/revanced-integrations
synced 2025-11-19 03:23:27 +01:00
Compare commits
50 Commits
v0.89.1-de
...
v0.93.0-de
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
803130a693 | ||
|
|
8032a3f46a | ||
|
|
d72937c2fd | ||
|
|
fd818a35f5 | ||
|
|
a80fab7070 | ||
|
|
c3eff913dd | ||
|
|
2a16da15d9 | ||
|
|
d076fe0dce | ||
|
|
e833d16bb8 | ||
|
|
bcd93db9b8 | ||
|
|
212d3a72d8 | ||
|
|
758b645913 | ||
|
|
e9fd05f4c6 | ||
|
|
31df68d2c3 | ||
|
|
56c1a3c03c | ||
|
|
915b8d371a | ||
|
|
eea37a9bad | ||
|
|
05cca001ac | ||
|
|
a45a354d19 | ||
|
|
070e1666b7 | ||
|
|
b5c0c843a5 | ||
|
|
2e74fc55eb | ||
|
|
114a1c4004 | ||
|
|
f5c5fcb5e4 | ||
|
|
954e60191e | ||
|
|
499a4deab3 | ||
|
|
01f79a3398 | ||
|
|
8f8e8ea87e | ||
|
|
0fc94e2305 | ||
|
|
25604cec0a | ||
|
|
dd11c6e062 | ||
|
|
64c31b84e7 | ||
|
|
843dd9de9e | ||
|
|
bc635a79c5 | ||
|
|
4c18633c36 | ||
|
|
4a3d20e1f0 | ||
|
|
8de014583e | ||
|
|
993aadd4df | ||
|
|
89f866d739 | ||
|
|
6fd81770bf | ||
|
|
a600239bbf | ||
|
|
cb560ff097 | ||
|
|
a9f55d7512 | ||
|
|
fcc5337d76 | ||
|
|
76c36daee0 | ||
|
|
f6335267f2 | ||
|
|
e856d9dccd | ||
|
|
1f74ccf800 | ||
|
|
240c3888cb | ||
|
|
b839600728 |
6
.github/workflows/release.yml
vendored
6
.github/workflows/release.yml
vendored
@@ -29,11 +29,9 @@ jobs:
|
||||
with:
|
||||
node-version: "latest"
|
||||
cache: 'npm'
|
||||
- name: Build with Gradle
|
||||
run: ./gradlew build --no-daemon
|
||||
- name: Setup semantic-release
|
||||
run: npm install semantic-release @saithodev/semantic-release-backmerge @semantic-release/git @semantic-release/changelog gradle-semantic-release-plugin -D
|
||||
run: npm install semantic-release@19.0.5 @saithodev/semantic-release-backmerge @semantic-release/git @semantic-release/changelog gradle-semantic-release-plugin@1.7.4 -D
|
||||
- name: Release
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
GITHUB_TOKEN: ${{ secrets.REPOSITORY_PUSH_ACCESS }}
|
||||
run: npx semantic-release
|
||||
|
||||
@@ -27,7 +27,8 @@
|
||||
{
|
||||
"path": "app/build/outputs/apk/release/*.apk"
|
||||
}
|
||||
]
|
||||
],
|
||||
successComment: false
|
||||
}
|
||||
],
|
||||
[
|
||||
|
||||
124
CHANGELOG.md
124
CHANGELOG.md
@@ -1,3 +1,127 @@
|
||||
# [0.93.0-dev.1](https://github.com/revanced/revanced-integrations/compare/v0.92.2...v0.93.0-dev.1) (2023-01-10)
|
||||
|
||||
|
||||
### Features
|
||||
|
||||
* `remove-screenshot-restriction` patch ([#285](https://github.com/revanced/revanced-integrations/issues/285)) ([c3eff91](https://github.com/revanced/revanced-integrations/commit/c3eff913ddb076dc86efd0398e34d04336a655ec))
|
||||
* **youtube/return-youtube-dislike:** better matching color for separators ([#281](https://github.com/revanced/revanced-integrations/issues/281)) ([2a16da1](https://github.com/revanced/revanced-integrations/commit/2a16da15d9a8d37ca65973671f0b4edff0078b47))
|
||||
* **youtube/return-youtube-dislike:** style for minimum width ([#284](https://github.com/revanced/revanced-integrations/issues/284)) ([a80fab7](https://github.com/revanced/revanced-integrations/commit/a80fab7070be203aa8aaf4c8422ea8e998843e67))
|
||||
* **youtube:** `spoof-app-version` patch ([#282](https://github.com/revanced/revanced-integrations/issues/282)) ([fd818a3](https://github.com/revanced/revanced-integrations/commit/fd818a35f5252fc0a37e12b528e020cdfac0ab53))
|
||||
|
||||
## [0.92.2](https://github.com/revanced/revanced-integrations/compare/v0.92.1...v0.92.2) (2023-01-07)
|
||||
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
* load numeric preferences as type String ([212d3a7](https://github.com/revanced/revanced-integrations/commit/212d3a72d879189c061fb77805cda81ca0519495))
|
||||
|
||||
## [0.92.2-dev.1](https://github.com/revanced/revanced-integrations/compare/v0.92.1...v0.92.2-dev.1) (2023-01-07)
|
||||
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
* load numeric preferences as type String ([212d3a7](https://github.com/revanced/revanced-integrations/commit/212d3a72d879189c061fb77805cda81ca0519495))
|
||||
|
||||
## [0.92.1](https://github.com/revanced/revanced-integrations/compare/v0.92.0...v0.92.1) (2023-01-07)
|
||||
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
* save preferences with correct type ([56c1a3c](https://github.com/revanced/revanced-integrations/commit/56c1a3c03c67393285a7499e9d3e92eb710691f0))
|
||||
|
||||
## [0.92.1](https://github.com/revanced/revanced-integrations/compare/v0.92.0...v0.92.1) (2023-01-07)
|
||||
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
* save preferences with correct type ([56c1a3c](https://github.com/revanced/revanced-integrations/commit/56c1a3c03c67393285a7499e9d3e92eb710691f0))
|
||||
|
||||
## [0.92.1-dev.1](https://github.com/revanced/revanced-integrations/compare/v0.92.0...v0.92.1-dev.1) (2023-01-07)
|
||||
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
* save preferences with correct type ([56c1a3c](https://github.com/revanced/revanced-integrations/commit/56c1a3c03c67393285a7499e9d3e92eb710691f0))
|
||||
|
||||
# [0.92.0](https://github.com/revanced/revanced-integrations/compare/v0.91.2...v0.92.0) (2023-01-07)
|
||||
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
* ensure thread safety for class `StringRef` ([#273](https://github.com/revanced/revanced-integrations/issues/273)) ([f5c5fcb](https://github.com/revanced/revanced-integrations/commit/f5c5fcb5e46f43b2e5abbbc4f55a1cf1c52e0549))
|
||||
|
||||
|
||||
### Features
|
||||
|
||||
* **youtube:** `remember-playback-rate` patch ([b5c0c84](https://github.com/revanced/revanced-integrations/commit/b5c0c843a502a7f4938053d136e826fbf7399e7b))
|
||||
|
||||
# [0.92.0-dev.1](https://github.com/revanced/revanced-integrations/compare/v0.91.3-dev.1...v0.92.0-dev.1) (2023-01-07)
|
||||
|
||||
|
||||
### Features
|
||||
|
||||
* **youtube:** `remember-playback-rate` patch ([b5c0c84](https://github.com/revanced/revanced-integrations/commit/b5c0c843a502a7f4938053d136e826fbf7399e7b))
|
||||
|
||||
## [0.91.3-dev.1](https://github.com/revanced/revanced-integrations/compare/v0.91.2...v0.91.3-dev.1) (2023-01-05)
|
||||
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
* ensure thread safety for class `StringRef` ([#273](https://github.com/revanced/revanced-integrations/issues/273)) ([f5c5fcb](https://github.com/revanced/revanced-integrations/commit/f5c5fcb5e46f43b2e5abbbc4f55a1cf1c52e0549))
|
||||
|
||||
## [0.91.2](https://github.com/revanced/revanced-integrations/compare/v0.91.1...v0.91.2) (2023-01-04)
|
||||
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
* **youtube/return-youtube-dislike:** use manufacturer specific span styles ([#265](https://github.com/revanced/revanced-integrations/issues/265)) ([8f8e8ea](https://github.com/revanced/revanced-integrations/commit/8f8e8ea87edccfabb7e02608dd9765fb8a48e092))
|
||||
|
||||
## [0.91.1](https://github.com/revanced/revanced-integrations/compare/v0.91.0...v0.91.1) (2023-01-02)
|
||||
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
* revert removing workaround task `publish` ([64c31b8](https://github.com/revanced/revanced-integrations/commit/64c31b84e76a270513efb4ae111afae507cacad4))
|
||||
* **twitch/block-embedded-ads:** rewrite Kotlin classes to Java ([#270](https://github.com/revanced/revanced-integrations/issues/270)) ([843dd9d](https://github.com/revanced/revanced-integrations/commit/843dd9de9e7fcd0b2b609e8af9a705faa1e23bc6))
|
||||
|
||||
# [0.91.0](https://github.com/revanced/revanced-integrations/compare/v0.90.0...v0.91.0) (2022-12-31)
|
||||
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
* **youtube/general-ads:** restore swipe back to exit gesture ([#264](https://github.com/revanced/revanced-integrations/issues/264)) ([76c36da](https://github.com/revanced/revanced-integrations/commit/76c36daee09be00d36477ea21c8b97f11444b7d2))
|
||||
|
||||
|
||||
### Features
|
||||
|
||||
* **youtube:** `copy-video-url` patch ([#263](https://github.com/revanced/revanced-integrations/issues/263)) ([e856d9d](https://github.com/revanced/revanced-integrations/commit/e856d9dccdf11888005e757e84a06523ad2c8dc5))
|
||||
|
||||
# [0.91.0-dev.2](https://github.com/revanced/revanced-integrations/compare/v0.91.0-dev.1...v0.91.0-dev.2) (2022-12-31)
|
||||
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
* **youtube/general-ads:** restore swipe back to exit gesture ([#264](https://github.com/revanced/revanced-integrations/issues/264)) ([76c36da](https://github.com/revanced/revanced-integrations/commit/76c36daee09be00d36477ea21c8b97f11444b7d2))
|
||||
|
||||
# [0.91.0-dev.1](https://github.com/revanced/revanced-integrations/compare/v0.90.0...v0.91.0-dev.1) (2022-12-31)
|
||||
|
||||
|
||||
### Features
|
||||
|
||||
* **youtube:** `copy-video-url` patch ([#263](https://github.com/revanced/revanced-integrations/issues/263)) ([e856d9d](https://github.com/revanced/revanced-integrations/commit/e856d9dccdf11888005e757e84a06523ad2c8dc5))
|
||||
|
||||
# [0.90.0](https://github.com/revanced/revanced-integrations/compare/v0.89.0...v0.90.0) (2022-12-31)
|
||||
|
||||
|
||||
### Features
|
||||
|
||||
* **youtube/return-youtube-dislike:** better formatting and LTR support ([#252](https://github.com/revanced/revanced-integrations/issues/252)) ([b839600](https://github.com/revanced/revanced-integrations/commit/b83960072831b4097fcca91afafb9111f55d8e10))
|
||||
|
||||
|
||||
### Performance Improvements
|
||||
|
||||
* **youtube/general-ads-patch:** reduce list of ignored component names ([#261](https://github.com/revanced/revanced-integrations/issues/261)) ([8d233a2](https://github.com/revanced/revanced-integrations/commit/8d233a2f82f49b93adb90e2b11c9fa46836dd9b0))
|
||||
|
||||
## [0.89.1-dev.1](https://github.com/revanced/revanced-integrations/compare/v0.89.0...v0.89.1-dev.1) (2022-12-30)
|
||||
|
||||
|
||||
|
||||
@@ -8,29 +8,31 @@ plugins {
|
||||
|
||||
android {
|
||||
compileSdk = 33
|
||||
buildToolsVersion = "33.0.0"
|
||||
buildToolsVersion = "33.0.1"
|
||||
namespace = "app.revanced.integrations"
|
||||
|
||||
defaultConfig {
|
||||
applicationId = "app.revanced.integrations"
|
||||
minSdk = 23
|
||||
targetSdk = 33
|
||||
versionCode = 1
|
||||
versionName = "1.0"
|
||||
multiDexEnabled = false
|
||||
|
||||
val properties = Properties()
|
||||
if (rootProject.file("local.properties").exists()) {
|
||||
properties.load(FileInputStream(rootProject.file("local.properties")))
|
||||
}
|
||||
|
||||
buildConfigField("String", "YT_API_KEY", "\"${properties.getProperty("youtubeAPIKey", "")}\"")
|
||||
versionName = project.version as String
|
||||
}
|
||||
|
||||
buildTypes {
|
||||
release {
|
||||
isMinifyEnabled = true
|
||||
proguardFiles(getDefaultProguardFile("proguard-android-optimize.txt"), "proguard-rules.pro")
|
||||
proguardFiles(
|
||||
getDefaultProguardFile("proguard-android-optimize.txt"),
|
||||
"proguard-rules.pro"
|
||||
)
|
||||
}
|
||||
applicationVariants.all {
|
||||
outputs.all {
|
||||
this as com.android.build.gradle.internal.api.ApkVariantOutputImpl
|
||||
|
||||
outputFileName = "${rootProject.name}-$versionName.apk"
|
||||
}
|
||||
}
|
||||
}
|
||||
compileOptions {
|
||||
@@ -46,6 +48,8 @@ dependencies {
|
||||
compileOnly(project(mapOf("path" to ":dummy")))
|
||||
compileOnly("androidx.annotation:annotation:1.5.0")
|
||||
compileOnly("androidx.appcompat:appcompat:1.5.1")
|
||||
compileOnly("com.squareup.okhttp3:okhttp:4.10.0")
|
||||
compileOnly("com.squareup.okhttp3:okhttp:5.0.0-alpha.11")
|
||||
compileOnly("com.squareup.retrofit2:retrofit:2.9.0")
|
||||
}
|
||||
|
||||
tasks.register("publish") { dependsOn("build") }
|
||||
|
||||
@@ -0,0 +1,11 @@
|
||||
package app.revanced.all.screenshot.removerestriction;
|
||||
|
||||
import android.view.Window;
|
||||
import android.view.WindowManager;
|
||||
|
||||
public class RemoveScreenshotRestrictionPatch {
|
||||
|
||||
public static void setFlags(Window window, int flags, int mask) {
|
||||
window.setFlags(flags & ~WindowManager.LayoutParams.FLAG_SECURE, mask & ~WindowManager.LayoutParams.FLAG_SECURE);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,27 @@
|
||||
package app.revanced.integrations.patches;
|
||||
|
||||
import android.content.Context;
|
||||
import android.widget.Toast;
|
||||
|
||||
import app.revanced.integrations.sponsorblock.StringRef;
|
||||
import app.revanced.integrations.utils.LogHelper;
|
||||
import app.revanced.integrations.utils.ReVancedUtils;
|
||||
|
||||
public class CopyVideoUrlPatch {
|
||||
public static void copyUrl(Boolean withTimestamp) {
|
||||
try {
|
||||
String url = String.format("https://youtu.be/%s", VideoInformation.getCurrentVideoId());
|
||||
if (withTimestamp) {
|
||||
long seconds = VideoInformation.getVideoTime() / 1000;
|
||||
url += String.format("?t=%s", seconds);
|
||||
}
|
||||
|
||||
Context context = ReVancedUtils.getContext();
|
||||
|
||||
ReVancedUtils.setClipboard(url);
|
||||
if (context != null) Toast.makeText(context, StringRef.str("share_copy_url_success"), Toast.LENGTH_SHORT).show();
|
||||
} catch (Exception e) {
|
||||
LogHelper.printException(() -> "Failed to generate video url", e);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,42 @@
|
||||
package app.revanced.integrations.patches;
|
||||
|
||||
import com.google.android.apps.youtube.app.watchwhile.WatchWhileActivity;
|
||||
import app.revanced.integrations.utils.LogHelper;
|
||||
|
||||
public class FixBackToExitGesturePatch {
|
||||
/**
|
||||
* State whether the scroll position reaches the top.
|
||||
*/
|
||||
public static boolean isTopView = false;
|
||||
|
||||
/**
|
||||
* Handle the event after clicking the back button.
|
||||
*
|
||||
* @param activity The activity, the app is launched with to finish.
|
||||
*/
|
||||
public static void onBackPressed(WatchWhileActivity activity) {
|
||||
if (!isTopView) return;
|
||||
|
||||
LogHelper.printDebug(() -> "Activity is closed");
|
||||
|
||||
activity.finish();
|
||||
}
|
||||
|
||||
/**
|
||||
* Handle the event when the homepage list of views is being scrolled.
|
||||
*/
|
||||
public static void onScrollingViews() {
|
||||
LogHelper.printDebug(() -> "Views are scrolling");
|
||||
|
||||
isTopView = false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Handle the event when the homepage list of views reached the top.
|
||||
*/
|
||||
public static void onTopView() {
|
||||
LogHelper.printDebug(() -> "Scrolling reached the top");
|
||||
|
||||
isTopView = true;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
package app.revanced.integrations.patches;
|
||||
|
||||
import app.revanced.integrations.settings.SettingsEnum;
|
||||
|
||||
public class SpoofAppVersionPatch {
|
||||
|
||||
public static String getYouTubeVersionOverride(String version) {
|
||||
if (SettingsEnum.SPOOF_APP_VERSION.getBoolean()){
|
||||
// Override with the most recent version that does not show the new UI player layout.
|
||||
// If the new UI shows up for some users, then change this to an older version (such as 17.29.34).
|
||||
return "17.30.34";
|
||||
}
|
||||
return version;
|
||||
}
|
||||
}
|
||||
@@ -17,6 +17,7 @@ public final class VideoInformation {
|
||||
private static WeakReference<Object> playerController;
|
||||
private static Method seekMethod;
|
||||
|
||||
private static String videoId = "";
|
||||
private static long videoLength = 1;
|
||||
private static long videoTime = -1;
|
||||
|
||||
@@ -39,6 +40,17 @@ public final class VideoInformation {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the video id.
|
||||
*
|
||||
* @param videoId The id of the video.
|
||||
*/
|
||||
public static void setVideoId(String videoId) {
|
||||
LogHelper.printDebug(() -> "Setting current video id to: " + videoId);
|
||||
|
||||
VideoInformation.videoId = videoId;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the video length.
|
||||
*
|
||||
@@ -80,6 +92,15 @@ public final class VideoInformation {
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the id of the current video playing.
|
||||
*
|
||||
* @return The id of the video. Empty string if not set yet.
|
||||
*/
|
||||
public static String getCurrentVideoId() {
|
||||
return videoId;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the length of the current video playing.
|
||||
*
|
||||
|
||||
@@ -1,177 +0,0 @@
|
||||
package app.revanced.integrations.patches;
|
||||
|
||||
import java.lang.reflect.Field;
|
||||
import java.lang.reflect.InvocationTargetException;
|
||||
import java.lang.reflect.Method;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Iterator;
|
||||
|
||||
import app.revanced.integrations.settings.SettingsEnum;
|
||||
import app.revanced.integrations.utils.LogHelper;
|
||||
import app.revanced.integrations.utils.ReVancedUtils;
|
||||
|
||||
public class VideoSpeedPatch {
|
||||
|
||||
public static final float[] videoSpeeds = { 0, 0 }; // Values are useless as they are being overridden by the respective patch
|
||||
private static Boolean userChangedSpeed = false;
|
||||
|
||||
public static int getDefaultSpeed(Object[] speeds, int speed, Object qInterface) {
|
||||
int speed2;
|
||||
Exception e;
|
||||
if (!ReVancedUtils.isNewVideoStarted()) {
|
||||
return speed;
|
||||
}
|
||||
ReVancedUtils.setNewVideo(false);
|
||||
LogHelper.printDebug(() -> "Speed: " + speed);
|
||||
float preferredSpeed = SettingsEnum.PREFERRED_VIDEO_SPEED.getFloat();
|
||||
LogHelper.printDebug(() -> "Preferred speed: " + preferredSpeed);
|
||||
if (preferredSpeed == -2.0f) {
|
||||
return speed;
|
||||
}
|
||||
Class<?> floatType = Float.TYPE;
|
||||
ArrayList<Float> iStreamSpeeds = new ArrayList<>();
|
||||
try {
|
||||
for (Object streamSpeed : speeds) {
|
||||
Field[] fields = streamSpeed.getClass().getFields();
|
||||
for (Field field : fields) {
|
||||
if (field.getType().isAssignableFrom(floatType)) {
|
||||
float value = field.getFloat(streamSpeed);
|
||||
if (field.getName().length() <= 2) {
|
||||
iStreamSpeeds.add(value);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch (Exception ignored) {
|
||||
}
|
||||
Iterator<Float> it = iStreamSpeeds.iterator();
|
||||
int index = 0;
|
||||
while (it.hasNext()) {
|
||||
float streamSpeed2 = it.next();
|
||||
final int logIndex = index;
|
||||
LogHelper.printDebug(() -> "Speed at index " + logIndex + ": " + streamSpeed2);
|
||||
index++;
|
||||
}
|
||||
int speed3 = -1;
|
||||
for (float streamSpeed3 : iStreamSpeeds) {
|
||||
if (streamSpeed3 <= preferredSpeed) {
|
||||
speed3++;
|
||||
final int speed3ToLog = speed3;
|
||||
LogHelper.printDebug(() -> "Speed loop at index " + speed3ToLog + ": " + streamSpeed3);
|
||||
}
|
||||
}
|
||||
if (speed3 == -1) {
|
||||
LogHelper.printDebug(() -> "Speed was not found");
|
||||
speed2 = 3;
|
||||
} else {
|
||||
speed2 = speed3;
|
||||
}
|
||||
try {
|
||||
Method[] declaredMethods = qInterface.getClass().getDeclaredMethods();
|
||||
for (Method method : declaredMethods) {
|
||||
if (method.getName().length() <= 2) {
|
||||
LogHelper.printDebug(() -> "Method name: " + method.getName());
|
||||
try {
|
||||
try {
|
||||
method.invoke(qInterface, videoSpeeds[speed2]);
|
||||
} catch (IllegalAccessException | IllegalArgumentException | InvocationTargetException ignored) {
|
||||
} catch (final Exception e6) {
|
||||
LogHelper.printException(() -> (e6.getMessage()));
|
||||
return speed2;
|
||||
}
|
||||
} catch (Exception ignored) {
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch (Exception e10) {
|
||||
e = e10;
|
||||
}
|
||||
LogHelper.printDebug(() -> "Speed changed to: " + speed2);
|
||||
return speed2;
|
||||
}
|
||||
|
||||
public static void userChangedSpeed() {
|
||||
userChangedSpeed = true;
|
||||
}
|
||||
|
||||
public static float getSpeedValue(Object[] speeds, int speed) {
|
||||
int i = 0;
|
||||
if (!ReVancedUtils.isNewVideoStarted() || userChangedSpeed) {
|
||||
if (SettingsEnum.DEBUG.getBoolean() && userChangedSpeed) {
|
||||
LogHelper.printDebug(() -> "Skipping speed change because user changed it: " + speed);
|
||||
}
|
||||
userChangedSpeed = false;
|
||||
return -1.0f;
|
||||
}
|
||||
ReVancedUtils.setNewVideo(false);
|
||||
LogHelper.printDebug(() -> "Speed: " + speed);
|
||||
float preferredSpeed = SettingsEnum.PREFERRED_VIDEO_SPEED.getFloat();
|
||||
LogHelper.printDebug(() -> "Preferred speed: " + preferredSpeed);
|
||||
if (preferredSpeed == -2.0f) {
|
||||
return -1.0f;
|
||||
}
|
||||
Class<?> floatType = Float.TYPE;
|
||||
ArrayList<Float> iStreamSpeeds = new ArrayList<>();
|
||||
try {
|
||||
int length = speeds.length;
|
||||
int i2 = 0;
|
||||
while (i2 < length) {
|
||||
Object streamSpeed = speeds[i2];
|
||||
Field[] fields = streamSpeed.getClass().getFields();
|
||||
int length2 = fields.length;
|
||||
while (i < length2) {
|
||||
Field field = fields[i];
|
||||
if (field.getType().isAssignableFrom(floatType)) {
|
||||
float value = field.getFloat(streamSpeed);
|
||||
if (field.getName().length() <= 2) {
|
||||
iStreamSpeeds.add(value);
|
||||
}
|
||||
}
|
||||
i++;
|
||||
}
|
||||
i2++;
|
||||
i = 0;
|
||||
}
|
||||
} catch (Exception ignored) {
|
||||
}
|
||||
int index = 0;
|
||||
for (Float iStreamSpeed : iStreamSpeeds) {
|
||||
float streamSpeed2 = iStreamSpeed;
|
||||
final int indexToLog = index;
|
||||
LogHelper.printDebug(() -> "Speed at index " + indexToLog + ": " + streamSpeed2);
|
||||
index++;
|
||||
}
|
||||
int newSpeedIndex = -1;
|
||||
for (Float iStreamSpeed : iStreamSpeeds) {
|
||||
float streamSpeed3 = iStreamSpeed;
|
||||
if (streamSpeed3 <= preferredSpeed) {
|
||||
newSpeedIndex++;
|
||||
final int newSpeedIndexToLog = newSpeedIndex;
|
||||
LogHelper.printDebug(() -> "Speed loop at index " + newSpeedIndexToLog + ": " + streamSpeed3);
|
||||
}
|
||||
}
|
||||
if (newSpeedIndex == -1) {
|
||||
LogHelper.printDebug(() -> "Speed was not found");
|
||||
newSpeedIndex = 3;
|
||||
}
|
||||
if (newSpeedIndex == speed) {
|
||||
final int newSpeedIndexToLog = newSpeedIndex;
|
||||
LogHelper.printDebug(() -> "Trying to set speed to what it already is, skipping...: " + newSpeedIndexToLog);
|
||||
return -1.0f;
|
||||
}
|
||||
final int newSpeedIndexToLog = newSpeedIndex;
|
||||
LogHelper.printDebug(() -> "Speed changed to: " + newSpeedIndexToLog);
|
||||
return getSpeedByIndex(newSpeedIndex);
|
||||
}
|
||||
|
||||
private static float getSpeedByIndex(int index) {
|
||||
if (index == -2) {
|
||||
return 1.0f;
|
||||
}
|
||||
try {
|
||||
return videoSpeeds[index];
|
||||
} catch (Exception e) {
|
||||
return 1.0f;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,27 +0,0 @@
|
||||
package app.revanced.integrations.patches.downloads;
|
||||
|
||||
import app.revanced.integrations.utils.LogHelper;
|
||||
|
||||
/**
|
||||
* Used by app.revanced.patches.youtube.interaction.downloads.bytecode.patch.DownloadsBytecodePatch
|
||||
*/
|
||||
public class DownloadsPatch {
|
||||
private static String videoId;
|
||||
|
||||
/**
|
||||
* Called when the video changes
|
||||
* @param videoId The current video id
|
||||
*/
|
||||
public static void setVideoId(String videoId) {
|
||||
LogHelper.printDebug(() -> "newVideoLoaded - " + videoId);
|
||||
|
||||
DownloadsPatch.videoId = videoId;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return The current video id
|
||||
*/
|
||||
public static String getCurrentVideoId() {
|
||||
return videoId;
|
||||
}
|
||||
}
|
||||
@@ -25,7 +25,7 @@ public class RememberVideoQualityPatch {
|
||||
Context context = ReVancedUtils.getContext();
|
||||
if (isConnectedWifi(context)) {
|
||||
try {
|
||||
SharedPrefHelper.saveString(context, SharedPrefHelper.SharedPrefNames.REVANCED_PREFS, "wifi_quality", defaultQuality + "");
|
||||
SharedPrefHelper.saveString(SharedPrefHelper.SharedPrefNames.REVANCED_PREFS, "wifi_quality", defaultQuality + "");
|
||||
} catch (Exception ex) {
|
||||
LogHelper.printException(() -> ("Failed to change default WI-FI quality:" + ex));
|
||||
Toast.makeText(context, "Failed to change default WI-FI quality:", Toast.LENGTH_SHORT).show();
|
||||
@@ -34,7 +34,7 @@ public class RememberVideoQualityPatch {
|
||||
Toast.makeText(context, "Changing default Wi-Fi quality to: " + defaultQuality, Toast.LENGTH_SHORT).show();
|
||||
} else if (isConnectedMobile(context)) {
|
||||
try {
|
||||
SharedPrefHelper.saveString(context, SharedPrefHelper.SharedPrefNames.REVANCED_PREFS, "mobile_quality", defaultQuality + "");
|
||||
SharedPrefHelper.saveString(SharedPrefHelper.SharedPrefNames.REVANCED_PREFS, "mobile_quality", defaultQuality + "");
|
||||
} catch (Exception ex) {
|
||||
LogHelper.printDebug(() -> "Failed to change default mobile data quality" + ex);
|
||||
Toast.makeText(context, "Failed to change default mobile data quality", Toast.LENGTH_SHORT).show();
|
||||
@@ -92,10 +92,10 @@ public class RememberVideoQualityPatch {
|
||||
return quality;
|
||||
}
|
||||
if (isConnectedWifi(context)) {
|
||||
preferredQuality = SharedPrefHelper.getInt(context, SharedPrefHelper.SharedPrefNames.REVANCED_PREFS, "wifi_quality", -2);
|
||||
preferredQuality = SharedPrefHelper.getInt(SharedPrefHelper.SharedPrefNames.REVANCED_PREFS, "wifi_quality", -2);
|
||||
LogHelper.printDebug(() -> "Wi-Fi connection detected, preferred quality: " + preferredQuality);
|
||||
} else if (isConnectedMobile(context)) {
|
||||
preferredQuality = SharedPrefHelper.getInt(context, SharedPrefHelper.SharedPrefNames.REVANCED_PREFS, "mobile_quality", -2);
|
||||
preferredQuality = SharedPrefHelper.getInt(SharedPrefHelper.SharedPrefNames.REVANCED_PREFS, "mobile_quality", -2);
|
||||
LogHelper.printDebug(() -> "Mobile data connection detected, preferred quality: " + preferredQuality);
|
||||
} else {
|
||||
LogHelper.printDebug(() -> "No Internet connection!");
|
||||
@@ -137,7 +137,7 @@ public class RememberVideoQualityPatch {
|
||||
|
||||
public static void userChangedQuality(int selectedQuality) {
|
||||
// Do not remember a **new** quality if REMEMBER_VIDEO_QUALITY is false
|
||||
if (SettingsEnum.REMEMBER_VIDEO_QUALITY_LAST_SELECTED.getBoolean() == false) return;
|
||||
if (!SettingsEnum.REMEMBER_VIDEO_QUALITY_LAST_SELECTED.getBoolean()) return;
|
||||
|
||||
selectedQuality1 = selectedQuality;
|
||||
userChangedQuality = true;
|
||||
|
||||
@@ -1,5 +1,9 @@
|
||||
package app.revanced.integrations.patches.playback.speed;
|
||||
|
||||
public class CustomVideoSpeedPatch {
|
||||
public static final float[] videoSpeeds = { 0, 0 }; // Values are useless as they are being overridden by the respective patch
|
||||
// Values are useless as they are being overridden by the respective patch.
|
||||
// This generates a .array segment in Dalvik bytecode
|
||||
// which the patch utilizes to store the video speeds in, only
|
||||
// if it has two or more default values.
|
||||
public static final float[] videoSpeeds = { 0, 0 };
|
||||
}
|
||||
|
||||
@@ -0,0 +1,32 @@
|
||||
package app.revanced.integrations.patches.playback.speed;
|
||||
|
||||
import static app.revanced.integrations.utils.SharedPrefHelper.SharedPrefNames.REVANCED_PREFS;
|
||||
import static app.revanced.integrations.utils.SharedPrefHelper.getFloat;
|
||||
import static app.revanced.integrations.utils.SharedPrefHelper.saveFloat;
|
||||
|
||||
import android.widget.Toast;
|
||||
|
||||
import app.revanced.integrations.settings.SettingsEnum;
|
||||
import app.revanced.integrations.utils.LogHelper;
|
||||
import app.revanced.integrations.utils.ReVancedUtils;
|
||||
|
||||
|
||||
public final class RememberPlaybackRatePatch {
|
||||
private static final String REMEMBERED_PLAYBACK_RATE_PREFERENCE_KEY = "revanced_remember_playback_rate_last_value";
|
||||
|
||||
public static void rememberPlaybackRate(final float selectedPlaybackRate) {
|
||||
if (!SettingsEnum.REMEMBER_PLAYBACK_RATE_SELECTED.getBoolean()) return;
|
||||
|
||||
Toast.makeText(ReVancedUtils.getContext(), "Playback rate will be remembered", Toast.LENGTH_SHORT).show();
|
||||
|
||||
LogHelper.printDebug(() -> "Remembering playback rate: " + selectedPlaybackRate);
|
||||
saveFloat(REVANCED_PREFS, REMEMBERED_PLAYBACK_RATE_PREFERENCE_KEY, selectedPlaybackRate);
|
||||
}
|
||||
|
||||
public static float getRememberedPlaybackRate() {
|
||||
final var playbackRateOverride = getFloat(REVANCED_PREFS, REMEMBERED_PLAYBACK_RATE_PREFERENCE_KEY, -2f);
|
||||
|
||||
LogHelper.printDebug(() -> "Overriding playback rate: " + playbackRateOverride);
|
||||
return playbackRateOverride;
|
||||
}
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
@@ -97,7 +97,7 @@ public class ReturnYouTubeDislikeApi {
|
||||
private static volatile long fetchCallResponseTimeMin;
|
||||
private static volatile long fetchCallResponseTimeMax;
|
||||
|
||||
public static final int FETCH_CALL_RESPONSE_TIME_VALUE_RATE_LIMIT = -2;
|
||||
public static final int FETCH_CALL_RESPONSE_TIME_VALUE_RATE_LIMIT = -1;
|
||||
|
||||
/**
|
||||
* If rate limit was hit, this returns {@link #FETCH_CALL_RESPONSE_TIME_VALUE_RATE_LIMIT}
|
||||
@@ -128,8 +128,8 @@ public class ReturnYouTubeDislikeApi {
|
||||
} // utility class
|
||||
|
||||
/**
|
||||
* Only to simulate a slow api call, for debugging the app UI with slow url calls.
|
||||
* Simulates a slow response by doing meaningless calculations.
|
||||
* Used to debug the app UI and verify UI timeout logic works
|
||||
*
|
||||
* @param maximumTimeToWait maximum time to wait
|
||||
*/
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
package app.revanced.integrations.settings;
|
||||
|
||||
import android.content.Context;
|
||||
import android.util.Log;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
@@ -16,10 +15,15 @@ public enum SettingsEnum {
|
||||
DOWNLOADS_BUTTON_SHOWN("revanced_downloads", true, ReturnType.BOOLEAN, true),
|
||||
DOWNLOADS_PACKAGE_NAME("revanced_downloads_package_name", "org.schabi.newpipe" /* NewPipe */, ReturnType.STRING),
|
||||
|
||||
// Copy video URL settings
|
||||
COPY_VIDEO_URL_BUTTON_SHOWN("revanced_copy_video_url", true, ReturnType.BOOLEAN, true),
|
||||
COPY_VIDEO_URL_TIMESTAMP_BUTTON_SHOWN("revanced_copy_video_url_timestamp", true, ReturnType.BOOLEAN, true),
|
||||
|
||||
// Video settings
|
||||
OLD_STYLE_VIDEO_QUALITY_PLAYER_SETTINGS("revanced_use_old_style_quality_settings", true, ReturnType.BOOLEAN),
|
||||
PREFERRED_VIDEO_SPEED("revanced_pref_video_speed", -2.0f, ReturnType.FLOAT),
|
||||
REMEMBER_VIDEO_QUALITY_LAST_SELECTED("revanced_remember_video_quality_last_selected", true, ReturnType.BOOLEAN),
|
||||
REMEMBER_PLAYBACK_RATE_SELECTED("revanced_remember_playback_rate_selected", true, ReturnType.BOOLEAN),
|
||||
|
||||
|
||||
// Whitelist settings
|
||||
//ToDo: Not used atm, Patch missing
|
||||
@@ -63,6 +67,7 @@ public enum SettingsEnum {
|
||||
DISABLE_STARTUP_SHORTS_PLAYER("revanced_startup_shorts_player_enabled", false, ReturnType.BOOLEAN),
|
||||
PLAYER_POPUP_PANELS("revanced_player_popup_panels_enabled", false, ReturnType.BOOLEAN),
|
||||
USE_TABLET_MINIPLAYER("revanced_tablet_miniplayer", false, ReturnType.BOOLEAN, true),
|
||||
SPOOF_APP_VERSION("revanced_spoof_app_version", false, ReturnType.BOOLEAN, true),
|
||||
WIDE_SEARCHBAR("revanced_wide_searchbar", false, ReturnType.BOOLEAN, true),
|
||||
HIDE_ALBUM_CARDS("revanced_hide_album_cards", false, ReturnType.BOOLEAN, true),
|
||||
HIDE_ARTIST_CARD("revanced_hide_artist_card", false, ReturnType.BOOLEAN),
|
||||
@@ -121,6 +126,7 @@ public enum SettingsEnum {
|
||||
RYD_USER_ID("ryd_userId", null, SharedPrefHelper.SharedPrefNames.RYD, ReturnType.STRING),
|
||||
RYD_ENABLED("ryd_enabled", true, SharedPrefHelper.SharedPrefNames.RYD, ReturnType.BOOLEAN),
|
||||
RYD_SHOW_DISLIKE_PERCENTAGE("ryd_show_dislike_percentage", false, SharedPrefHelper.SharedPrefNames.RYD, ReturnType.BOOLEAN),
|
||||
RYD_USE_COMPACT_LAYOUT("ryd_use_compact_layout", false, SharedPrefHelper.SharedPrefNames.RYD, ReturnType.BOOLEAN),
|
||||
|
||||
// SponsorBlock settings
|
||||
SB_ENABLED("sb-enabled", true, SharedPrefHelper.SharedPrefNames.SPONSOR_BLOCK, ReturnType.BOOLEAN),
|
||||
@@ -275,43 +281,33 @@ public enum SettingsEnum {
|
||||
private static void load() {
|
||||
Context context = ReVancedUtils.getContext();
|
||||
if (context == null) {
|
||||
Log.e("revanced: SettingsEnum", "Context returned null! Setings NOT initialized");
|
||||
} else {
|
||||
try {
|
||||
for (SettingsEnum setting : values()) {
|
||||
Object value = setting.getDefaultValue();
|
||||
|
||||
//LogHelper is not initialized here
|
||||
Log.d("revanced: SettingsEnum", "Loading Setting: " + setting.name());
|
||||
|
||||
switch (setting.getReturnType()) {
|
||||
case FLOAT:
|
||||
value = SharedPrefHelper.getFloat(context, setting.sharedPref, setting.getPath(), (float) setting.getDefaultValue());
|
||||
break;
|
||||
case LONG:
|
||||
value = SharedPrefHelper.getLong(context, setting.sharedPref, setting.getPath(), (long) setting.getDefaultValue());
|
||||
break;
|
||||
case BOOLEAN:
|
||||
value = SharedPrefHelper.getBoolean(context, setting.sharedPref, setting.getPath(), (boolean) setting.getDefaultValue());
|
||||
break;
|
||||
case INTEGER:
|
||||
value = SharedPrefHelper.getInt(context, setting.sharedPref, setting.getPath(), (int) setting.getDefaultValue());
|
||||
break;
|
||||
case STRING:
|
||||
value = SharedPrefHelper.getString(context, setting.sharedPref, setting.getPath(), (String) setting.getDefaultValue());
|
||||
break;
|
||||
default:
|
||||
LogHelper.printException(() -> ("Setting does not have a valid Type. Name is: " + setting.name()));
|
||||
break;
|
||||
}
|
||||
setting.setValue(value);
|
||||
|
||||
//LogHelper is not initialized here
|
||||
Log.d("revanced: SettingsEnum", "Loaded Setting: " + setting.name() + " Value: " + value);
|
||||
}
|
||||
} catch (Throwable th) {
|
||||
LogHelper.printException(() -> ("Error during load()!"), th);
|
||||
LogHelper.printException(() -> "SettingsEnum.load() called before ReVancedUtils.init()");
|
||||
return;
|
||||
}
|
||||
for (SettingsEnum setting : values()) {
|
||||
var path = setting.getPath();
|
||||
var defaultValue = setting.getDefaultValue();
|
||||
switch (setting.getReturnType()) {
|
||||
case FLOAT:
|
||||
defaultValue = SharedPrefHelper.getFloat(setting.sharedPref, path, (float) defaultValue);
|
||||
break;
|
||||
case LONG:
|
||||
defaultValue = SharedPrefHelper.getLong(setting.sharedPref, path, (long) defaultValue);
|
||||
break;
|
||||
case BOOLEAN:
|
||||
defaultValue = SharedPrefHelper.getBoolean(setting.sharedPref, path, (boolean) defaultValue);
|
||||
break;
|
||||
case INTEGER:
|
||||
defaultValue = SharedPrefHelper.getInt(setting.sharedPref, path, (int) defaultValue);
|
||||
break;
|
||||
case STRING:
|
||||
defaultValue = SharedPrefHelper.getString(setting.sharedPref, path, (String) defaultValue);
|
||||
break;
|
||||
default:
|
||||
LogHelper.printException(() -> ("Setting does not have a valid Type. Name is: " + setting.name()));
|
||||
break;
|
||||
}
|
||||
setting.setValue(defaultValue);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -339,16 +335,34 @@ public enum SettingsEnum {
|
||||
*/
|
||||
public void saveValue(Object newValue) {
|
||||
Context context = ReVancedUtils.getContext();
|
||||
if (context != null) {
|
||||
if (returnType == ReturnType.BOOLEAN) {
|
||||
SharedPrefHelper.saveBoolean(context, sharedPref, path, (Boolean) newValue);
|
||||
} else {
|
||||
SharedPrefHelper.saveString(context, sharedPref, path, newValue + "");
|
||||
}
|
||||
value = newValue;
|
||||
} else {
|
||||
|
||||
if (context == null) {
|
||||
LogHelper.printException(() -> ("Context on SaveValue is null!"));
|
||||
return;
|
||||
}
|
||||
|
||||
switch (getReturnType()) {
|
||||
case FLOAT:
|
||||
SharedPrefHelper.saveFloat(sharedPref, path, (float) defaultValue);
|
||||
break;
|
||||
case LONG:
|
||||
SharedPrefHelper.saveLong(sharedPref, path, (long) defaultValue);
|
||||
break;
|
||||
case BOOLEAN:
|
||||
SharedPrefHelper.saveBoolean(sharedPref, path, (boolean) newValue);
|
||||
break;
|
||||
case INTEGER:
|
||||
SharedPrefHelper.saveInt(sharedPref, path, (int) defaultValue);
|
||||
break;
|
||||
case STRING:
|
||||
SharedPrefHelper.saveString(sharedPref, path, (String) defaultValue);
|
||||
break;
|
||||
default:
|
||||
LogHelper.printException(() -> ("Setting does not have a valid Type. Name is: " + name()));
|
||||
break;
|
||||
}
|
||||
|
||||
value = newValue;
|
||||
}
|
||||
|
||||
public int getInt() {
|
||||
|
||||
@@ -26,7 +26,6 @@ import app.revanced.integrations.settings.SettingsEnum;
|
||||
import app.revanced.integrations.utils.LogHelper;
|
||||
import app.revanced.integrations.utils.ReVancedUtils;
|
||||
import app.revanced.integrations.utils.SharedPrefHelper;
|
||||
import app.revanced.integrations.videoplayer.DownloadButton;
|
||||
|
||||
public class ReVancedSettingsFragment extends PreferenceFragment {
|
||||
|
||||
@@ -71,24 +70,6 @@ public class ReVancedSettingsFragment extends PreferenceFragment {
|
||||
break;
|
||||
}
|
||||
setting.setValue(value);
|
||||
} else if (pref instanceof ListPreference) {
|
||||
ListPreference listPref = (ListPreference) pref;
|
||||
if (setting == SettingsEnum.PREFERRED_VIDEO_SPEED) {
|
||||
try {
|
||||
String value = sharedPreferences.getString(setting.getPath(), setting.getDefaultValue() + "");
|
||||
listPref.setDefaultValue(value);
|
||||
listPref.setSummary(videoSpeedEntries[listPref.findIndexOfValue(value)]);
|
||||
SettingsEnum.PREFERRED_VIDEO_SPEED.saveValue(value);
|
||||
} catch (Throwable th) {
|
||||
LogHelper.printException(() -> ("Error setting value of speed" + th));
|
||||
}
|
||||
} else {
|
||||
LogHelper.printException(() -> ("No valid setting found: " + setting.toString()));
|
||||
}
|
||||
|
||||
if ("pref_download_button_list".equals(str)) {
|
||||
DownloadButton.refreshShouldBeShown();
|
||||
}
|
||||
} else {
|
||||
LogHelper.printException(() -> ("Setting cannot be handled! " + pref.toString()));
|
||||
}
|
||||
|
||||
@@ -29,18 +29,27 @@ public class ReturnYouTubeDislikeSettingsFragment extends PreferenceFragment {
|
||||
*/
|
||||
private SwitchPreference percentagePreference;
|
||||
|
||||
/**
|
||||
* If segmented like/dislike button uses smaller compact layout
|
||||
*/
|
||||
private SwitchPreference compactLayoutPreference;
|
||||
|
||||
private void updateUIState() {
|
||||
final boolean rydIsEnabled = SettingsEnum.RYD_ENABLED.getBoolean();
|
||||
final boolean dislikePercentageEnabled = SettingsEnum.RYD_SHOW_DISLIKE_PERCENTAGE.getBoolean();
|
||||
|
||||
enabledPreference.setSummary(rydIsEnabled
|
||||
? str("revanced_ryd_enable_summary_on")
|
||||
: str("revanced_ryd_enable_summary_off"));
|
||||
|
||||
percentagePreference.setSummary(dislikePercentageEnabled
|
||||
percentagePreference.setSummary(SettingsEnum.RYD_SHOW_DISLIKE_PERCENTAGE.getBoolean()
|
||||
? str("revanced_ryd_dislike_percentage_summary_on")
|
||||
: str("revanced_ryd_dislike_percentage_summary_off"));
|
||||
percentagePreference.setEnabled(rydIsEnabled);
|
||||
|
||||
compactLayoutPreference.setSummary(SettingsEnum.RYD_USE_COMPACT_LAYOUT.getBoolean()
|
||||
? str("revanced_ryd_compact_layout_summary_on")
|
||||
: str("revanced_ryd_compact_layout_summary_off"));
|
||||
compactLayoutPreference.setEnabled(rydIsEnabled);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -80,6 +89,19 @@ public class ReturnYouTubeDislikeSettingsFragment extends PreferenceFragment {
|
||||
});
|
||||
preferenceScreen.addPreference(percentagePreference);
|
||||
|
||||
compactLayoutPreference = new SwitchPreference(context);
|
||||
compactLayoutPreference.setKey(SettingsEnum.RYD_USE_COMPACT_LAYOUT.getPath());
|
||||
compactLayoutPreference.setDefaultValue(SettingsEnum.RYD_USE_COMPACT_LAYOUT.getDefaultValue());
|
||||
compactLayoutPreference.setChecked(SettingsEnum.RYD_USE_COMPACT_LAYOUT.getBoolean());
|
||||
compactLayoutPreference.setTitle(str("revanced_ryd_compact_layout_title"));
|
||||
compactLayoutPreference.setOnPreferenceChangeListener((pref, newValue) -> {
|
||||
SettingsEnum.RYD_USE_COMPACT_LAYOUT.saveValue((Boolean)newValue);
|
||||
|
||||
updateUIState();
|
||||
return true;
|
||||
});
|
||||
preferenceScreen.addPreference(compactLayoutPreference);
|
||||
|
||||
updateUIState();
|
||||
|
||||
|
||||
|
||||
@@ -52,7 +52,7 @@ public class SponsorBlockSettingsFragment extends PreferenceFragment implements
|
||||
PreferenceScreen preferenceScreen = getPreferenceManager().createPreferenceScreen(context);
|
||||
setPreferenceScreen(preferenceScreen);
|
||||
|
||||
SponsorBlockSettings.update(context);
|
||||
SponsorBlockSettings.update(getActivity());
|
||||
|
||||
{
|
||||
SwitchPreference preference = new SwitchPreference(context);
|
||||
@@ -349,7 +349,6 @@ public class SponsorBlockSettingsFragment extends PreferenceFragment implements
|
||||
return;
|
||||
Context context = ((AlertDialog) dialog).getContext();
|
||||
Context applicationContext = context.getApplicationContext();
|
||||
SharedPreferences preferences = SharedPrefHelper.getPreferences(context, SharedPrefHelper.SharedPrefNames.SPONSOR_BLOCK);
|
||||
|
||||
switch (which) {
|
||||
case DialogInterface.BUTTON_NEUTRAL:
|
||||
|
||||
@@ -56,8 +56,7 @@ public class PlayerController {
|
||||
return;
|
||||
}
|
||||
|
||||
Context context = ReVancedUtils.getContext();
|
||||
SponsorBlockSettings.update(context);
|
||||
SponsorBlockSettings.update(null);
|
||||
|
||||
if (!SettingsEnum.SB_ENABLED.getBoolean()) {
|
||||
currentVideoId = null;
|
||||
|
||||
@@ -2,7 +2,7 @@ package app.revanced.integrations.sponsorblock;
|
||||
|
||||
import static app.revanced.integrations.sponsorblock.StringRef.sf;
|
||||
|
||||
import android.content.Context;
|
||||
import android.app.Activity;
|
||||
import android.content.SharedPreferences;
|
||||
import android.graphics.Color;
|
||||
import android.graphics.Paint;
|
||||
@@ -16,7 +16,6 @@ import java.util.Map;
|
||||
import java.util.UUID;
|
||||
|
||||
import app.revanced.integrations.settings.SettingsEnum;
|
||||
import app.revanced.integrations.utils.LogHelper;
|
||||
import app.revanced.integrations.utils.SharedPrefHelper;
|
||||
|
||||
public class SponsorBlockSettings {
|
||||
@@ -25,10 +24,8 @@ public class SponsorBlockSettings {
|
||||
public static final SegmentBehaviour DefaultBehaviour = SegmentBehaviour.IGNORE;
|
||||
public static String sponsorBlockUrlCategories = "[]";
|
||||
|
||||
public static void update(Context context) {
|
||||
if (context == null) return;
|
||||
|
||||
SharedPreferences preferences = SharedPrefHelper.getPreferences(context, SharedPrefHelper.SharedPrefNames.SPONSOR_BLOCK);
|
||||
public static void update(Activity _activity) {
|
||||
SharedPreferences preferences = SharedPrefHelper.getPreferences(SharedPrefHelper.SharedPrefNames.SPONSOR_BLOCK);
|
||||
|
||||
if (!SettingsEnum.SB_ENABLED.getBoolean()) {
|
||||
SkipSegmentView.hide();
|
||||
|
||||
@@ -514,7 +514,7 @@ public abstract class SponsorBlockUtils {
|
||||
JSONArray categorySelectionsArray = settingsJson.getJSONArray("categorySelections");
|
||||
|
||||
|
||||
SharedPreferences.Editor editor = SharedPrefHelper.getPreferences(context, SharedPrefHelper.SharedPrefNames.SPONSOR_BLOCK).edit();
|
||||
SharedPreferences.Editor editor = SharedPrefHelper.getPreferences(SharedPrefHelper.SharedPrefNames.SPONSOR_BLOCK).edit();
|
||||
|
||||
SponsorBlockSettings.SegmentInfo[] categories = SponsorBlockSettings.SegmentInfo.valuesWithoutUnsubmitted();
|
||||
for (SponsorBlockSettings.SegmentInfo category : categories) {
|
||||
@@ -605,7 +605,7 @@ public abstract class SponsorBlockUtils {
|
||||
}
|
||||
|
||||
public static boolean isSBButtonEnabled(Context context, String key) {
|
||||
return SettingsEnum.SB_ENABLED.getBoolean() && SharedPrefHelper.getBoolean(context, SharedPrefHelper.SharedPrefNames.SPONSOR_BLOCK, key, false);
|
||||
return SettingsEnum.SB_ENABLED.getBoolean() && SharedPrefHelper.getBoolean(SharedPrefHelper.SharedPrefNames.SPONSOR_BLOCK, key, false);
|
||||
}
|
||||
|
||||
public enum VoteOption {
|
||||
|
||||
@@ -5,16 +5,20 @@ import android.content.res.Resources;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import app.revanced.integrations.utils.LogHelper;
|
||||
import app.revanced.integrations.utils.ReVancedUtils;
|
||||
|
||||
// should probably move this class into utils package
|
||||
public class StringRef {
|
||||
private static Resources resources;
|
||||
private static String packageName;
|
||||
|
||||
private static final HashMap<String, StringRef> strings = new HashMap<>();
|
||||
// must use a thread safe map, as this class is used both on and off the main thread
|
||||
private static final Map<String, StringRef> strings = Collections.synchronizedMap(new HashMap());
|
||||
|
||||
/**
|
||||
* Gets strings reference from shared collection or creates if not exists yet,
|
||||
@@ -90,9 +94,11 @@ public class StringRef {
|
||||
@NonNull
|
||||
public String toString() {
|
||||
if (!resolved) {
|
||||
Context context = ReVancedUtils.getContext();
|
||||
resources = context.getResources();
|
||||
packageName = context.getPackageName();
|
||||
if (resources == null || packageName == null) {
|
||||
Context context = ReVancedUtils.getContext();
|
||||
resources = context.getResources();
|
||||
packageName = context.getPackageName();
|
||||
}
|
||||
resolved = true;
|
||||
if (resources != null) {
|
||||
final int identifier = resources.getIdentifier(value, "string", packageName);
|
||||
|
||||
@@ -21,7 +21,7 @@ public class SwipeHelper {
|
||||
try {
|
||||
_frameLayout = (FrameLayout) obj;
|
||||
Context appContext = ReVancedUtils.getContext();
|
||||
if (ReVancedUtils.isTablet(appContext) || SharedPrefHelper.getBoolean(appContext, SharedPrefHelper.SharedPrefNames.YOUTUBE,"pref_swipe_tablet", false)) {
|
||||
if (ReVancedUtils.isTablet(appContext) || SharedPrefHelper.getBoolean(SharedPrefHelper.SharedPrefNames.YOUTUBE, "pref_swipe_tablet", false)) {
|
||||
isTabletMode = true;
|
||||
}
|
||||
} catch (Exception e) {
|
||||
|
||||
@@ -5,12 +5,12 @@ import android.content.Context;
|
||||
import app.revanced.integrations.utils.SharedPrefHelper;
|
||||
|
||||
public class ButtonVisibility {
|
||||
public static Visibility getButtonVisibility(Context context, String key) {
|
||||
return getButtonVisibility(context, key, SharedPrefHelper.SharedPrefNames.YOUTUBE);
|
||||
public static Visibility getButtonVisibility(String key) {
|
||||
return getButtonVisibility(key, SharedPrefHelper.SharedPrefNames.YOUTUBE);
|
||||
}
|
||||
|
||||
public static Visibility getButtonVisibility(Context context, String key, SharedPrefHelper.SharedPrefNames name) {
|
||||
String value = SharedPrefHelper.getString(context, name, key, null);
|
||||
public static Visibility getButtonVisibility(String key, SharedPrefHelper.SharedPrefNames name) {
|
||||
String value = SharedPrefHelper.getString(name, key, null);
|
||||
|
||||
if (value == null || value.isEmpty()) return Visibility.NONE;
|
||||
|
||||
@@ -26,12 +26,12 @@ public class ButtonVisibility {
|
||||
}
|
||||
}
|
||||
|
||||
public static boolean isVisibleInContainer(Context context, String key) {
|
||||
return isVisibleInContainer(getButtonVisibility(context, key));
|
||||
public static boolean isVisibleInContainer(String key) {
|
||||
return isVisibleInContainer(getButtonVisibility(key));
|
||||
}
|
||||
|
||||
public static boolean isVisibleInContainer(Context context, String key, SharedPrefHelper.SharedPrefNames name) {
|
||||
return isVisibleInContainer(getButtonVisibility(context, key, name));
|
||||
public static boolean isVisibleInContainer(String key, SharedPrefHelper.SharedPrefNames name) {
|
||||
return isVisibleInContainer(getButtonVisibility(key, name));
|
||||
}
|
||||
|
||||
public static boolean isVisibleInContainer(Visibility visibility) {
|
||||
|
||||
@@ -6,6 +6,8 @@ import android.content.res.Resources;
|
||||
import android.os.Handler;
|
||||
import android.os.Looper;
|
||||
|
||||
import java.text.Bidi;
|
||||
import java.util.Locale;
|
||||
import java.util.concurrent.Callable;
|
||||
import java.util.concurrent.Future;
|
||||
import java.util.concurrent.LinkedBlockingQueue;
|
||||
@@ -121,10 +123,28 @@ public class ReVancedUtils {
|
||||
}
|
||||
}
|
||||
|
||||
public static void setClipboard(String text) {
|
||||
android.content.ClipboardManager clipboard = (android.content.ClipboardManager) context.getSystemService(Context.CLIPBOARD_SERVICE);
|
||||
android.content.ClipData clip = android.content.ClipData.newPlainText("ReVanced", text);
|
||||
clipboard.setPrimaryClip(clip);
|
||||
}
|
||||
|
||||
public static boolean isTablet(Context context) {
|
||||
return context.getResources().getConfiguration().smallestScreenWidthDp >= 600;
|
||||
}
|
||||
|
||||
private static Boolean isRightToLeftTextLayout;
|
||||
/**
|
||||
* If the device language uses right to left text layout (hebrew, arabic, etc)
|
||||
*/
|
||||
public static boolean isRightToLeftTextLayout() {
|
||||
if (isRightToLeftTextLayout == null) {
|
||||
String displayLanguage = Locale.getDefault().getDisplayLanguage();
|
||||
isRightToLeftTextLayout = new Bidi(displayLanguage, Bidi.DIRECTION_DEFAULT_LEFT_TO_RIGHT).isRightToLeft();
|
||||
}
|
||||
return isRightToLeftTextLayout;
|
||||
}
|
||||
|
||||
/**
|
||||
* Automatically logs any exceptions the runnable throws
|
||||
*/
|
||||
|
||||
@@ -3,29 +3,41 @@ package app.revanced.integrations.utils;
|
||||
import android.content.Context;
|
||||
import android.content.SharedPreferences;
|
||||
|
||||
import java.util.Objects;
|
||||
|
||||
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 saveString(SharedPrefNames prefName, String key, String value) {
|
||||
getPreferences(prefName).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 saveBoolean(SharedPrefNames prefName, String key, boolean value) {
|
||||
getPreferences(prefName).edit().putBoolean(key, value).apply();
|
||||
}
|
||||
|
||||
public static String getString(Context context, SharedPrefNames prefName, String key, String _default) {
|
||||
SharedPreferences sharedPreferences = getPreferences(context, prefName);
|
||||
return (sharedPreferences.getString(key, _default));
|
||||
public static void saveFloat(SharedPrefNames prefName, String key, float value) {
|
||||
getPreferences(prefName).edit().putFloat(key, value).apply();
|
||||
}
|
||||
|
||||
public static Boolean getBoolean(Context context, SharedPrefNames prefName, String key, Boolean _default) {
|
||||
SharedPreferences sharedPreferences = getPreferences(context, prefName);
|
||||
return (sharedPreferences.getBoolean(key, _default));
|
||||
public static void saveInt(SharedPrefNames prefName, String key, int value) {
|
||||
getPreferences(prefName).edit().putInt(key, value).apply();
|
||||
}
|
||||
|
||||
public static Long getLong(Context context, SharedPrefNames prefName, String key, Long _default) {
|
||||
SharedPreferences sharedPreferences = getPreferences(context, prefName);
|
||||
public static void saveLong(SharedPrefNames prefName, String key, long value) {
|
||||
getPreferences(prefName).edit().putLong(key, value).apply();
|
||||
}
|
||||
|
||||
public static String getString(SharedPrefNames prefName, String key, String _default) {
|
||||
return getPreferences(prefName).getString(key, _default);
|
||||
}
|
||||
|
||||
public static boolean getBoolean(SharedPrefNames prefName, String key, boolean _default) {
|
||||
return getPreferences(prefName).getBoolean(key, _default);
|
||||
}
|
||||
|
||||
// region Hack, unknown why required
|
||||
|
||||
public static Long getLong(SharedPrefNames prefName, String key, Long _default) {
|
||||
SharedPreferences sharedPreferences = getPreferences(prefName);
|
||||
try {
|
||||
return Long.valueOf(sharedPreferences.getString(key, _default + ""));
|
||||
} catch (ClassCastException ex) {
|
||||
@@ -33,8 +45,8 @@ public class SharedPrefHelper {
|
||||
}
|
||||
}
|
||||
|
||||
public static Float getFloat(Context context, SharedPrefNames prefName, String key, Float _default) {
|
||||
SharedPreferences sharedPreferences = getPreferences(context, prefName);
|
||||
public static Float getFloat(SharedPrefNames prefName, String key, Float _default) {
|
||||
SharedPreferences sharedPreferences = getPreferences(prefName);
|
||||
try {
|
||||
return Float.valueOf(sharedPreferences.getString(key, _default + ""));
|
||||
} catch (ClassCastException ex) {
|
||||
@@ -42,8 +54,8 @@ public class SharedPrefHelper {
|
||||
}
|
||||
}
|
||||
|
||||
public static Integer getInt(Context context, SharedPrefNames prefName, String key, Integer _default) {
|
||||
SharedPreferences sharedPreferences = getPreferences(context, prefName);
|
||||
public static Integer getInt(SharedPrefNames prefName, String key, Integer _default) {
|
||||
SharedPreferences sharedPreferences = getPreferences(prefName);
|
||||
try {
|
||||
return Integer.valueOf(sharedPreferences.getString(key, _default + ""));
|
||||
} catch (ClassCastException ex) {
|
||||
@@ -51,14 +63,10 @@ public class SharedPrefHelper {
|
||||
}
|
||||
}
|
||||
|
||||
public static SharedPreferences getPreferences(Context context, SharedPrefNames name) {
|
||||
if (context == null) return null;
|
||||
return context.getSharedPreferences(name.getName(), Context.MODE_PRIVATE);
|
||||
}
|
||||
// endregion
|
||||
|
||||
public static SharedPreferences getPreferences(Context context, String name) {
|
||||
if (context == null) return null;
|
||||
return context.getSharedPreferences(name, Context.MODE_PRIVATE);
|
||||
public static SharedPreferences getPreferences(SharedPrefNames name) {
|
||||
return Objects.requireNonNull(ReVancedUtils.getContext()).getSharedPreferences(name.getName(), Context.MODE_PRIVATE);
|
||||
}
|
||||
|
||||
public enum SharedPrefNames {
|
||||
|
||||
@@ -0,0 +1,79 @@
|
||||
package app.revanced.integrations.videoplayer;
|
||||
|
||||
import android.support.constraint.ConstraintLayout;
|
||||
import android.view.View;
|
||||
import android.view.animation.Animation;
|
||||
import android.view.animation.AnimationUtils;
|
||||
import android.widget.ImageView;
|
||||
|
||||
import java.lang.ref.WeakReference;
|
||||
|
||||
import app.revanced.integrations.utils.LogHelper;
|
||||
import app.revanced.integrations.utils.ReVancedUtils;
|
||||
|
||||
public abstract class BottomControlButton {
|
||||
WeakReference<ImageView> button = new WeakReference<>(null);
|
||||
ConstraintLayout constraintLayout;
|
||||
Boolean isButtonEnabled;
|
||||
Boolean isShowing;
|
||||
|
||||
private Animation fadeIn;
|
||||
private Animation fadeOut;
|
||||
|
||||
public BottomControlButton(Object obj, String viewId, Boolean isEnabled, View.OnClickListener onClickListener) {
|
||||
try {
|
||||
LogHelper.printDebug(() -> "Initializing button with id: " + viewId);
|
||||
constraintLayout = (ConstraintLayout) obj;
|
||||
isButtonEnabled = isEnabled;
|
||||
|
||||
ImageView imageView = constraintLayout.findViewById(ReVancedUtils.getIdentifier(viewId, "id"));
|
||||
if (imageView == null) {
|
||||
LogHelper.printDebug(() -> "Couldn't find ImageView with id: " + viewId);
|
||||
return;
|
||||
}
|
||||
|
||||
imageView.setOnClickListener(onClickListener);
|
||||
|
||||
button = new WeakReference<>(imageView);
|
||||
fadeIn = getAnimation("fade_in");
|
||||
fadeOut = getAnimation("fade_out");
|
||||
|
||||
int fadeDurationFast = getInteger("fade_duration_fast");
|
||||
int fadeDurationScheduled = getInteger("fade_duration_scheduled");
|
||||
fadeIn.setDuration(fadeDurationFast);
|
||||
fadeOut.setDuration(fadeDurationScheduled);
|
||||
isShowing = true;
|
||||
setVisibility(false);
|
||||
} catch (Exception e) {
|
||||
LogHelper.printException(() -> "Failed to initialize button with id: " + viewId, e);
|
||||
}
|
||||
}
|
||||
|
||||
public void setVisibility(boolean showing) {
|
||||
if (isShowing == showing) return;
|
||||
|
||||
isShowing = showing;
|
||||
ImageView imageView = button.get();
|
||||
|
||||
if (constraintLayout == null || imageView == null)
|
||||
return;
|
||||
|
||||
if (showing && isButtonEnabled) {
|
||||
LogHelper.printDebug(() -> "Fading in");
|
||||
imageView.setVisibility(View.VISIBLE);
|
||||
imageView.startAnimation(fadeIn);
|
||||
}
|
||||
else if (imageView.getVisibility() == View.VISIBLE) {
|
||||
LogHelper.printDebug(() -> "Fading out");
|
||||
imageView.startAnimation(fadeOut);
|
||||
imageView.setVisibility(View.GONE);
|
||||
}
|
||||
}
|
||||
private static int getInteger(String str) {
|
||||
return ReVancedUtils.getContext().getResources().getInteger(ReVancedUtils.getIdentifier(str, "integer"));
|
||||
}
|
||||
|
||||
private static Animation getAnimation(String str) {
|
||||
return AnimationUtils.loadAnimation(ReVancedUtils.getContext(), ReVancedUtils.getIdentifier(str, "anim"));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,26 @@
|
||||
package app.revanced.integrations.videoplayer;
|
||||
|
||||
|
||||
import app.revanced.integrations.patches.CopyVideoUrlPatch;
|
||||
import app.revanced.integrations.settings.SettingsEnum;
|
||||
|
||||
public class CopyVideoUrlButton extends BottomControlButton {
|
||||
public static CopyVideoUrlButton instance;
|
||||
|
||||
public CopyVideoUrlButton(Object obj) {
|
||||
super(
|
||||
obj,
|
||||
"copy_video_url_button",
|
||||
SettingsEnum.COPY_VIDEO_URL_BUTTON_SHOWN.getBoolean(),
|
||||
view -> CopyVideoUrlPatch.copyUrl(false)
|
||||
);
|
||||
}
|
||||
|
||||
public static void initializeButton(Object obj) {
|
||||
instance = new CopyVideoUrlButton(obj);
|
||||
}
|
||||
|
||||
public static void changeVisibility(boolean showing) {
|
||||
if (instance != null) instance.setVisibility(showing);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,26 @@
|
||||
package app.revanced.integrations.videoplayer;
|
||||
|
||||
import app.revanced.integrations.patches.CopyVideoUrlPatch;
|
||||
import app.revanced.integrations.settings.SettingsEnum;
|
||||
|
||||
public class CopyVideoUrlTimestampButton extends BottomControlButton {
|
||||
public static CopyVideoUrlTimestampButton instance;
|
||||
|
||||
public CopyVideoUrlTimestampButton(Object obj) {
|
||||
super(
|
||||
obj,
|
||||
"copy_video_url_timestamp_button",
|
||||
SettingsEnum.COPY_VIDEO_URL_TIMESTAMP_BUTTON_SHOWN.getBoolean(),
|
||||
view -> CopyVideoUrlPatch.copyUrl(true)
|
||||
);
|
||||
}
|
||||
|
||||
public static void initializeButton(Object obj) {
|
||||
instance = new CopyVideoUrlTimestampButton(obj);
|
||||
}
|
||||
|
||||
public static void changeVisibility(boolean showing) {
|
||||
if (instance != null) instance.setVisibility(showing);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,161 +1,69 @@
|
||||
package app.revanced.integrations.videoplayer;
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.content.pm.PackageManager;
|
||||
import android.support.constraint.ConstraintLayout;
|
||||
import android.view.View;
|
||||
import android.view.animation.Animation;
|
||||
import android.view.animation.AnimationUtils;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.Toast;
|
||||
|
||||
|
||||
import java.lang.ref.WeakReference;
|
||||
|
||||
import app.revanced.integrations.patches.downloads.DownloadsPatch;
|
||||
import app.revanced.integrations.patches.VideoInformation;
|
||||
import app.revanced.integrations.settings.SettingsEnum;
|
||||
import app.revanced.integrations.sponsorblock.StringRef;
|
||||
import app.revanced.integrations.utils.LogHelper;
|
||||
import app.revanced.integrations.utils.ReVancedUtils;
|
||||
import app.revanced.integrations.utils.SharedPrefHelper;
|
||||
|
||||
/* loaded from: classes6.dex */
|
||||
//ToDo: Refactor
|
||||
public class DownloadButton {
|
||||
static WeakReference<ImageView> _button = new WeakReference<>(null);
|
||||
static ConstraintLayout _constraintLayout;
|
||||
static int fadeDurationFast;
|
||||
static int fadeDurationScheduled;
|
||||
static Animation fadeIn;
|
||||
static Animation fadeOut;
|
||||
public static boolean isDownloadButtonEnabled;
|
||||
static boolean isShowing;
|
||||
public class DownloadButton extends BottomControlButton {
|
||||
public static DownloadButton instance;
|
||||
|
||||
public static void initializeDownloadButton(Object obj) {
|
||||
public DownloadButton(Object obj) {
|
||||
super(
|
||||
obj,
|
||||
"download_button",
|
||||
SettingsEnum.DOWNLOADS_BUTTON_SHOWN.getBoolean(),
|
||||
DownloadButton::onDownloadClick
|
||||
);
|
||||
}
|
||||
|
||||
public static void initializeButton(Object obj) {
|
||||
instance = new DownloadButton(obj);
|
||||
}
|
||||
|
||||
public static void changeVisibility(boolean showing) {
|
||||
if (instance != null) instance.setVisibility(showing);
|
||||
}
|
||||
|
||||
private static void onDownloadClick(View view) {
|
||||
LogHelper.printDebug(() -> "Download button clicked");
|
||||
|
||||
final var context = view.getContext();
|
||||
var downloaderPackageName = SettingsEnum.DOWNLOADS_PACKAGE_NAME.getString();
|
||||
|
||||
boolean packageEnabled = false;
|
||||
try {
|
||||
LogHelper.printDebug(() -> "initializing");
|
||||
_constraintLayout = (ConstraintLayout) obj;
|
||||
isDownloadButtonEnabled = shouldBeShown();
|
||||
ImageView imageView = _constraintLayout.findViewById(getIdentifier("download_button", "id"));
|
||||
if (imageView == null) {
|
||||
LogHelper.printDebug(() -> "Couldn't find imageView with id \"download_button\"");
|
||||
return;
|
||||
}
|
||||
|
||||
imageView.setOnClickListener(view -> {
|
||||
LogHelper.printDebug(() -> "Download button clicked");
|
||||
|
||||
final var context = view.getContext();
|
||||
var downloaderPackageName = SettingsEnum.DOWNLOADS_PACKAGE_NAME.getString();
|
||||
|
||||
boolean packageEnabled = false;
|
||||
try {
|
||||
assert context != null;
|
||||
packageEnabled = context.getPackageManager().getApplicationInfo(downloaderPackageName, 0).enabled;
|
||||
} catch (PackageManager.NameNotFoundException error) {
|
||||
LogHelper.printDebug(() -> "Downloader could not be found: " + error);
|
||||
}
|
||||
|
||||
// If the package is not installed, show the toast
|
||||
if (!packageEnabled) {
|
||||
Toast.makeText(context, downloaderPackageName + " " + StringRef.str("downloader_not_installed_warning"), Toast.LENGTH_LONG).show();
|
||||
return;
|
||||
}
|
||||
|
||||
// Launch PowerTube intent
|
||||
try {
|
||||
String content = String.format("https://youtu.be/%s", DownloadsPatch.getCurrentVideoId());
|
||||
|
||||
Intent intent = new Intent("android.intent.action.SEND");
|
||||
intent.setType("text/plain");
|
||||
intent.setPackage(downloaderPackageName);
|
||||
intent.putExtra("android.intent.extra.TEXT", content);
|
||||
context.startActivity(intent);
|
||||
|
||||
LogHelper.printDebug(() -> "Launched the intent with the content: " + content);
|
||||
} catch (Exception error) {
|
||||
LogHelper.printDebug(() -> "Failed to launch the intent: " + error);
|
||||
}
|
||||
|
||||
//var options = Arrays.asList("Video", "Audio").toArray(new CharSequence[0]);
|
||||
//
|
||||
//new AlertDialog.Builder(view.getContext())
|
||||
// .setItems(options, (dialog, which) -> {
|
||||
// LogHelper.debug(DownloadButton.class, String.valueOf(options[which]));
|
||||
// })
|
||||
// .show();
|
||||
// TODO: show popup and download via newpipe
|
||||
});
|
||||
_button = new WeakReference<>(imageView);
|
||||
fadeDurationFast = getInteger("fade_duration_fast");
|
||||
fadeDurationScheduled = getInteger("fade_duration_scheduled");
|
||||
Animation animation = getAnimation("fade_in");
|
||||
fadeIn = animation;
|
||||
animation.setDuration(fadeDurationFast);
|
||||
Animation animation2 = getAnimation("fade_out");
|
||||
fadeOut = animation2;
|
||||
animation2.setDuration(fadeDurationScheduled);
|
||||
isShowing = true;
|
||||
changeVisibility(false);
|
||||
|
||||
} catch (Exception e) {
|
||||
LogHelper.printException(() -> ("Unable to set FrameLayout"), e);
|
||||
assert context != null;
|
||||
packageEnabled = context.getPackageManager().getApplicationInfo(downloaderPackageName, 0).enabled;
|
||||
} catch (PackageManager.NameNotFoundException error) {
|
||||
LogHelper.printDebug(() -> "Downloader could not be found: " + error);
|
||||
}
|
||||
}
|
||||
|
||||
public static void changeVisibility(boolean z) {
|
||||
if (isShowing == z) return;
|
||||
|
||||
isShowing = z;
|
||||
ImageView imageView = _button.get();
|
||||
|
||||
if (_constraintLayout == null || imageView == null)
|
||||
// If the package is not installed, show the toast
|
||||
if (!packageEnabled) {
|
||||
Toast.makeText(context, downloaderPackageName + " " + StringRef.str("downloader_not_installed_warning"), Toast.LENGTH_LONG).show();
|
||||
return;
|
||||
|
||||
if (z && isDownloadButtonEnabled) {
|
||||
LogHelper.printDebug(() -> "Fading in");
|
||||
imageView.setVisibility(View.VISIBLE);
|
||||
imageView.startAnimation(fadeIn);
|
||||
}
|
||||
else if (imageView.getVisibility() == View.VISIBLE) {
|
||||
LogHelper.printDebug(() -> "Fading out");
|
||||
imageView.startAnimation(fadeOut);
|
||||
imageView.setVisibility(View.GONE);
|
||||
}
|
||||
}
|
||||
|
||||
public static void refreshShouldBeShown() {
|
||||
isDownloadButtonEnabled = shouldBeShown();
|
||||
}
|
||||
|
||||
private static boolean shouldBeShown() {
|
||||
if (!SettingsEnum.DOWNLOADS_BUTTON_SHOWN.getBoolean()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
Context appContext = ReVancedUtils.getContext();
|
||||
if (appContext == null) {
|
||||
LogHelper.printException(() -> ("shouldBeShown - context is null!"));
|
||||
return false;
|
||||
}
|
||||
String string = SharedPrefHelper.getString(appContext, SharedPrefHelper.SharedPrefNames.YOUTUBE, "pref_download_button_list", "PLAYER" /* TODO: set the default to null, as this will be set by the settings page later */);
|
||||
if (string == null || string.isEmpty()) {
|
||||
return false;
|
||||
}
|
||||
return string.equalsIgnoreCase("PLAYER");
|
||||
}
|
||||
// Launch PowerTube intent
|
||||
try {
|
||||
String content = String.format("https://youtu.be/%s", VideoInformation.getCurrentVideoId());
|
||||
|
||||
private static int getIdentifier(String str, String str2) {
|
||||
Context appContext = ReVancedUtils.getContext();
|
||||
return appContext.getResources().getIdentifier(str, str2, appContext.getPackageName());
|
||||
}
|
||||
Intent intent = new Intent("android.intent.action.SEND");
|
||||
intent.setType("text/plain");
|
||||
intent.setPackage(downloaderPackageName);
|
||||
intent.putExtra("android.intent.extra.TEXT", content);
|
||||
context.startActivity(intent);
|
||||
|
||||
private static int getInteger(String str) {
|
||||
return ReVancedUtils.getContext().getResources().getInteger(getIdentifier(str, "integer"));
|
||||
}
|
||||
private static Animation getAnimation(String str) {
|
||||
return AnimationUtils.loadAnimation(ReVancedUtils.getContext(), getIdentifier(str, "anim"));
|
||||
LogHelper.printDebug(() -> "Launched the intent with the content: " + content);
|
||||
} catch (Exception error) {
|
||||
LogHelper.printDebug(() -> "Failed to launch the intent: " + error);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user