mirror of
https://github.com/revanced/revanced-integrations.git
synced 2025-05-01 07:04:27 +02:00
add length of the video without segments to the time bar
This commit is contained in:
parent
b9e454e329
commit
dce63e76e2
@ -9,10 +9,14 @@ import android.os.Looper;
|
|||||||
import android.text.Html;
|
import android.text.Html;
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
|
import android.view.ViewGroup;
|
||||||
import android.widget.EditText;
|
import android.widget.EditText;
|
||||||
import android.widget.ImageView;
|
import android.widget.ImageView;
|
||||||
|
import android.widget.TextView;
|
||||||
import android.widget.Toast;
|
import android.widget.Toast;
|
||||||
|
|
||||||
|
import com.google.android.apps.youtube.app.YouTubeTikTokRoot_Application;
|
||||||
|
|
||||||
import org.json.JSONArray;
|
import org.json.JSONArray;
|
||||||
import org.json.JSONObject;
|
import org.json.JSONObject;
|
||||||
|
|
||||||
@ -32,6 +36,8 @@ import java.util.Locale;
|
|||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
import java.util.TimeZone;
|
import java.util.TimeZone;
|
||||||
|
|
||||||
|
import fi.razerman.youtube.Helpers.XSwipeHelper;
|
||||||
|
|
||||||
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 fi.razerman.youtube.XGlobals.debug;
|
||||||
@ -48,8 +54,12 @@ import static pl.jakubweg.StringRef.str;
|
|||||||
public abstract class SponsorBlockUtils {
|
public abstract class SponsorBlockUtils {
|
||||||
public static final String TAG = "jakubweg.SponsorBlockUtils";
|
public static final String TAG = "jakubweg.SponsorBlockUtils";
|
||||||
public static final String DATE_FORMAT = "HH:mm:ss.SSS";
|
public static final String DATE_FORMAT = "HH:mm:ss.SSS";
|
||||||
|
public static final String WITHOUT_SEGMENTS_FORMAT = " (m:ss)";
|
||||||
|
public static final String WITHOUT_SEGMENTS_FORMAT_H = " (H:m:ss)";
|
||||||
@SuppressLint("SimpleDateFormat")
|
@SuppressLint("SimpleDateFormat")
|
||||||
public static final SimpleDateFormat dateFormatter = new SimpleDateFormat(DATE_FORMAT);
|
public static final SimpleDateFormat dateFormatter = new SimpleDateFormat(DATE_FORMAT);
|
||||||
|
public static final SimpleDateFormat withoutSegmentsFormatter = new SimpleDateFormat(WITHOUT_SEGMENTS_FORMAT);
|
||||||
|
public static final SimpleDateFormat withoutSegmentsFormatterH = new SimpleDateFormat(WITHOUT_SEGMENTS_FORMAT_H);
|
||||||
private static final int sponsorBtnId = 1234;
|
private static final int sponsorBtnId = 1234;
|
||||||
public static final View.OnClickListener sponsorBlockBtnListener = new View.OnClickListener() {
|
public static final View.OnClickListener sponsorBlockBtnListener = new View.OnClickListener() {
|
||||||
@Override
|
@Override
|
||||||
@ -507,9 +517,19 @@ public abstract class SponsorBlockUtils {
|
|||||||
Log.e(TAG, "download segments failed", e);
|
Log.e(TAG, "download segments failed", e);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
View layout = XSwipeHelper.nextGenWatchLayout.findViewById(getIdentifier("player_overlays", "id"));
|
||||||
|
View bar = layout.findViewById(getIdentifier("time_bar_total_time", "id"));
|
||||||
|
|
||||||
|
((TextView) bar).append(getTimeWithoutSegments());
|
||||||
|
|
||||||
return sponsorSegments.toArray(new SponsorSegment[0]);
|
return sponsorSegments.toArray(new SponsorSegment[0]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static int getIdentifier(String name, String defType) {
|
||||||
|
Context context = YouTubeTikTokRoot_Application.getAppContext();
|
||||||
|
return context.getResources().getIdentifier(name, defType, context.getPackageName());
|
||||||
|
}
|
||||||
|
|
||||||
public static void sendViewCountRequest(SponsorSegment segment) {
|
public static void sendViewCountRequest(SponsorSegment segment) {
|
||||||
try {
|
try {
|
||||||
URL url = new URL(SponsorBlockSettings.getSponsorBlockViewedUrl(segment.UUID));
|
URL url = new URL(SponsorBlockSettings.getSponsorBlockViewedUrl(segment.UUID));
|
||||||
@ -562,6 +582,18 @@ public abstract class SponsorBlockUtils {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static String getTimeWithoutSegments() {
|
||||||
|
if (!SponsorBlockSettings.isSponsorBlockEnabled || sponsorSegmentsOfCurrentVideo == null) {
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
long timeWithoutSegments = PlayerController.getCurrentVideoLength();
|
||||||
|
for (SponsorSegment segment : sponsorSegmentsOfCurrentVideo) {
|
||||||
|
timeWithoutSegments -= segment.end - segment.start;
|
||||||
|
}
|
||||||
|
Date date = new Date(timeWithoutSegments);
|
||||||
|
return timeWithoutSegments >= 3600000 ? withoutSegmentsFormatterH.format(date) : withoutSegmentsFormatter.format(date);
|
||||||
|
}
|
||||||
|
|
||||||
private enum VoteOption {
|
private enum VoteOption {
|
||||||
UPVOTE(str("vote_upvote")),
|
UPVOTE(str("vote_upvote")),
|
||||||
DOWNVOTE(str("vote_downvote")),
|
DOWNVOTE(str("vote_downvote")),
|
||||||
|
Loading…
x
Reference in New Issue
Block a user