diff --git a/app/build.gradle b/app/build.gradle index f6f39a8..f13687c 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -1,13 +1,12 @@ apply plugin: 'com.android.application' android { - compileSdkVersion 30 - buildToolsVersion "30.0.2" + compileSdkVersion 32 defaultConfig { applicationId "vanced.integrations" minSdkVersion 21 - targetSdkVersion 30 + targetSdkVersion 31 versionCode 1 versionName "1.0" multiDexEnabled false @@ -33,6 +32,6 @@ android { } dependencies { - implementation 'androidx.annotation:annotation:1.2.0' + implementation 'androidx.annotation:annotation:1.3.0' } diff --git a/app/src/main/java/fi/vanced/libraries/youtube/player/VideoInformation.java b/app/src/main/java/fi/vanced/libraries/youtube/player/VideoInformation.java index e11d541..b4ee013 100644 --- a/app/src/main/java/fi/vanced/libraries/youtube/player/VideoInformation.java +++ b/app/src/main/java/fi/vanced/libraries/youtube/player/VideoInformation.java @@ -24,7 +24,7 @@ public class VideoInformation { if (debug) { Log.d(TAG, "setCurrentVideoId - new id was null - currentVideoId was" + currentVideoId); } - clearInformation(); + clearInformation(true); return; } @@ -53,15 +53,17 @@ public class VideoInformation { // Call hook in the YT code when the video ends public static void videoEnded() { saveTempInformation(); - clearInformation(); + clearInformation(false); } // Information is cleared once a video ends // It's cleared because the setCurrentVideoId isn't called for Shorts // so Shorts would otherwise use the information from the last watched video - private static void clearInformation() { - currentVideoId = null; - dislikeCount = null; + private static void clearInformation(boolean full) { + if (full) { + currentVideoId = null; + dislikeCount = null; + } channelName = null; } diff --git a/app/src/main/java/fi/vanced/libraries/youtube/ryd/ReturnYouTubeDislikes.java b/app/src/main/java/fi/vanced/libraries/youtube/ryd/ReturnYouTubeDislikes.java index d8f2a1e..31724b0 100644 --- a/app/src/main/java/fi/vanced/libraries/youtube/ryd/ReturnYouTubeDislikes.java +++ b/app/src/main/java/fi/vanced/libraries/youtube/ryd/ReturnYouTubeDislikes.java @@ -17,6 +17,7 @@ import android.widget.TextView; import com.google.android.apps.youtube.app.YouTubeTikTokRoot_Application; import java.util.Locale; +import java.util.Objects; import fi.vanced.libraries.youtube.ryd.requests.RYDRequester; import fi.vanced.utils.SharedPrefUtils; @@ -36,7 +37,7 @@ public class ReturnYouTubeDislikes { static { Context context = YouTubeTikTokRoot_Application.getAppContext(); - isEnabled = SharedPrefUtils.getBoolean(context, PREFERENCES_NAME, PREFERENCES_KEY_RYD_ENABLED, false); + isEnabled = SharedPrefUtils.getBoolean(Objects.requireNonNull(context), PREFERENCES_NAME, PREFERENCES_KEY_RYD_ENABLED, false); if (isEnabled) { registration = new Registration(context); voting = new Voting(context, registration); @@ -51,9 +52,6 @@ public class ReturnYouTubeDislikes { locale, CompactDecimalFormat.CompactStyle.SHORT ); - compactNumberFormatter.setMaximumIntegerDigits(3); - compactNumberFormatter.setMaximumFractionDigits(1); - compactNumberFormatter.setSignificantDigitsUsed(false); } } @@ -199,7 +197,8 @@ public class ReturnYouTubeDislikes { } private static void handleOnClick(View view, boolean previousState) { - if (!isEnabled) return; + Context context = YouTubeTikTokRoot_Application.getAppContext(); + if (!isEnabled || SharedPrefUtils.getBoolean(Objects.requireNonNull(context),"youtube","user_signed_out",true)) return; try { String tag = (String) view.getTag(); @@ -210,7 +209,7 @@ public class ReturnYouTubeDislikes { // If active status was removed, vote should be none if (previousState) { votingValue = 0; } - if (tag == "like") { + if (tag.equals("like")) { dislikeActive = false; // Like was activated @@ -218,9 +217,9 @@ public class ReturnYouTubeDislikes { else { likeActive = false; } // Like was activated and dislike was previously activated - if (!previousState && dislikeActive) { dislikeCount--; trySetDislikes(formatDislikes(dislikeCount)); } + if (!previousState) { dislikeCount--; trySetDislikes(formatDislikes(dislikeCount)); } } - else if (tag == "dislike") { + else if (tag.equals("dislike")) { likeActive = false; // Dislike was activated @@ -274,7 +273,6 @@ public class ReturnYouTubeDislikes { } catch (Exception ex) { Log.e(TAG, "Failed to send vote", ex); - return; } }); _votingThread.start(); diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index c6e5eda..4c8a11c 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -369,11 +369,11 @@ Failed to retrieve channel details, received code %d Hidden In player - Under player + Under player (ALPHA) Both Return YouTube Dislike settings Uses the RYD API - Enable RYD + Enable RYD (ALPHA) Switch this on to see the dislike counts again Return YouTube Dislike Integration This integration uses the RYD API from https://returnyoutubedislike.com. Tap to learn more diff --git a/build.gradle b/build.gradle index 4a22cbf..6983356 100644 --- a/build.gradle +++ b/build.gradle @@ -5,7 +5,7 @@ buildscript { mavenCentral() } dependencies { - classpath 'com.android.tools.build:gradle:7.0.4' + classpath 'com.android.tools.build:gradle:7.1.1' // NOTE: Do not place your application dependencies here; they belong // in the individual module build.gradle files diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index e7c8788..25999d5 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,6 +1,6 @@ #Mon Jun 07 19:51:48 CEST 2021 distributionBase=GRADLE_USER_HOME -distributionUrl=https\://services.gradle.org/distributions/gradle-7.0.2-bin.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-7.2-bin.zip distributionPath=wrapper/dists zipStorePath=wrapper/dists zipStoreBase=GRADLE_USER_HOME