Updated deps + fixed player buttons and dislike formatting

This commit is contained in:
KevinX8
2022-02-16 01:05:23 +00:00
parent 1e115e1d69
commit dfb25653b2
6 changed files with 21 additions and 22 deletions

View File

@ -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;
}

View File

@ -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();