Merge branch 'master' into feature/show-stats

# Conflicts:
#	app/src/main/java/pl/jakubweg/SponsorBlockSettings.java
#	app/src/main/java/pl/jakubweg/SponsorBlockUtils.java
This commit is contained in:
caneleex 2021-07-23 23:43:59 +02:00
commit d29fbe4c2b
6 changed files with 30 additions and 2 deletions

View File

@ -1,9 +1,11 @@
package fi.vanced.libraries.youtube.player;
import fi.vanced.libraries.youtube.sponsors.player.ui.SponsorBlockView;
import pl.jakubweg.SponsorBlockUtils;
public class PlayerType {
public static void playerTypeChanged(String playerType) {
SponsorBlockView.playerTypeChanged(playerType);
SponsorBlockUtils.playerTypeChanged(playerType);
}
}

View File

@ -59,7 +59,8 @@ public class PlayerController {
public static void setCurrentVideoId(final String videoId) {
if (videoId == null) {
Log.d(TAG, "setCurrentVideoId: videoId is null");
currentVideoId = null;
sponsorSegmentsOfCurrentVideo = null;
return;
}

View File

@ -26,6 +26,7 @@ import static pl.jakubweg.SponsorBlockSettings.DefaultBehaviour;
import static pl.jakubweg.SponsorBlockSettings.PREFERENCES_KEY_ADJUST_NEW_SEGMENT_STEP;
import static pl.jakubweg.SponsorBlockSettings.PREFERENCES_KEY_COUNT_SKIPS;
import static pl.jakubweg.SponsorBlockSettings.PREFERENCES_KEY_NEW_SEGMENT_ENABLED;
import static pl.jakubweg.SponsorBlockSettings.PREFERENCES_KEY_SHOW_TIME_WITHOUT_SEGMENTS;
import static pl.jakubweg.SponsorBlockSettings.PREFERENCES_KEY_SHOW_TOAST_WHEN_SKIP;
import static pl.jakubweg.SponsorBlockSettings.PREFERENCES_KEY_SPONSOR_BLOCK_ENABLED;
import static pl.jakubweg.SponsorBlockSettings.PREFERENCES_KEY_UUID;
@ -34,6 +35,7 @@ import static pl.jakubweg.SponsorBlockSettings.PREFERENCES_NAME;
import static pl.jakubweg.SponsorBlockSettings.adjustNewSegmentMillis;
import static pl.jakubweg.SponsorBlockSettings.countSkips;
import static pl.jakubweg.SponsorBlockSettings.setSeenGuidelines;
import static pl.jakubweg.SponsorBlockSettings.showTimeWithoutSegments;
import static pl.jakubweg.SponsorBlockSettings.showToastWhenSkippedAutomatically;
import static pl.jakubweg.SponsorBlockSettings.uuid;
import static pl.jakubweg.StringRef.str;
@ -246,6 +248,16 @@ public class SponsorBlockPreferenceFragment extends PreferenceFragment implement
screen.addPreference(preference);
}
{
Preference preference = new SwitchPreference(context);
preference.setTitle(str("general_time_without_sb"));
preference.setSummary(str("general_time_without_sb_sum"));
preference.setKey(PREFERENCES_KEY_SHOW_TIME_WITHOUT_SEGMENTS);
preference.setDefaultValue(showTimeWithoutSegments);
preferencesToDisableWhenSBDisabled.add(preference);
screen.addPreference(preference);
}
{
EditTextPreference preference = new EditTextPreference(context);
preference.getEditText().setInputType(InputType.TYPE_CLASS_NUMBER | InputType.TYPE_NUMBER_FLAG_SIGNED);

View File

@ -27,6 +27,7 @@ public class SponsorBlockSettings {
public static final String PREFERENCES_KEY_VOTING_ENABLED = "sb-voting-enabled";
public static final String PREFERENCES_KEY_SKIPPED_SEGMENTS = "sb-skipped-segments";
public static final String PREFERENCES_KEY_SKIPPED_SEGMENTS_TIME = "sb-skipped-segments-time";
public static final String PREFERENCES_KEY_SHOW_TIME_WITHOUT_SEGMENTS = "sb-length-without-segments";
public static final SegmentBehaviour DefaultBehaviour = SegmentBehaviour.SKIP_AUTOMATICALLY;
@ -36,6 +37,7 @@ public class SponsorBlockSettings {
public static boolean isVotingEnabled = true;
public static boolean showToastWhenSkippedAutomatically = true;
public static boolean countSkips = true;
public static boolean showTimeWithoutSegments = true;
public static int adjustNewSegmentMillis = 150;
public static String uuid = "<invalid>";
public static String sponsorBlockUrlCategories = "[]";
@ -112,7 +114,7 @@ public class SponsorBlockSettings {
}
//"[%22sponsor%22,%22outro%22,%22music_offtopic%22,%22intro%22,%22selfpromo%22,%22interaction%22,%22preview%22]";
if (enabledCategories.isEmpty())
if (enabledCategories.size() == 0)
sponsorBlockUrlCategories = "[]";
else
sponsorBlockUrlCategories = "[%22" + TextUtils.join("%22,%22", enabledCategories) + "%22]";
@ -126,6 +128,7 @@ public class SponsorBlockSettings {
adjustNewSegmentMillis = Integer.parseInt(tmp1);
countSkips = preferences.getBoolean(PREFERENCES_KEY_COUNT_SKIPS, countSkips);
showTimeWithoutSegments = preferences.getBoolean(PREFERENCES_KEY_SHOW_TIME_WITHOUT_SEGMENTS, showTimeWithoutSegments);
uuid = preferences.getString(PREFERENCES_KEY_UUID, null);
if (uuid == null) {

View File

@ -10,10 +10,12 @@ import android.preference.EditTextPreference;
import android.preference.Preference;
import android.preference.PreferenceCategory;
import android.text.Html;
import android.text.TextUtils;
import android.util.Log;
import android.view.View;
import android.widget.EditText;
import android.widget.ImageView;
import android.widget.TextView;
import android.widget.Toast;
import java.lang.ref.WeakReference;
@ -48,8 +50,14 @@ import static pl.jakubweg.requests.Requester.voteForSegment;
public abstract class SponsorBlockUtils {
public static final String TAG = "jakubweg.SponsorBlockUtils";
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")
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 boolean videoHasSegments = false;
private static String timeWithoutSegments = "";
private static final int sponsorBtnId = 1234;
public static final View.OnClickListener sponsorBlockBtnListener = v -> {
if (debug) {

View File

@ -151,6 +151,8 @@
<string name="general_skiptoast_sum">Click to see an example toast</string>
<string name="general_skipcount">Skip count tracking</string>
<string name="general_skipcount_sum">This lets SponsorBlock leaderboard system know how much time people have saved. The extension sends a message to the server each time you skip a segment.</string>
<string name="general_time_without_sb">Show time without segments</string>
<string name="general_time_without_sb_sum">This time appears in brackets next to the current time. This shows the total video duration minus any segments.</string>
<string name="general_adjusting">Adjusting new segment step</string>
<string name="general_adjusting_sum">This is the number of milliseconds you can move when you use the time adjustment buttons while adding new segment</string>
<string name="general_uuid">Your unique user id</string>