mirror of
https://github.com/revanced/revanced-integrations.git
synced 2024-11-17 17:39:36 +01:00
add basic support
This commit is contained in:
parent
a47bdb3a2b
commit
2f40fe6985
@ -18,7 +18,6 @@ import android.preference.SwitchPreference;
|
||||
import android.text.InputType;
|
||||
import android.widget.Toast;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.ArrayList;
|
||||
|
||||
import static pl.jakubweg.SponsorBlockSettings.DefaultBehaviour;
|
||||
@ -31,10 +30,10 @@ import static pl.jakubweg.SponsorBlockSettings.PREFERENCES_KEY_UUID;
|
||||
import static pl.jakubweg.SponsorBlockSettings.PREFERENCES_NAME;
|
||||
import static pl.jakubweg.SponsorBlockSettings.adjustNewSegmentMillis;
|
||||
import static pl.jakubweg.SponsorBlockSettings.countSkips;
|
||||
import static pl.jakubweg.SponsorBlockSettings.getPreferences;
|
||||
import static pl.jakubweg.SponsorBlockSettings.setSeenGuidelines;
|
||||
import static pl.jakubweg.SponsorBlockSettings.showToastWhenSkippedAutomatically;
|
||||
import static pl.jakubweg.SponsorBlockSettings.uuid;
|
||||
import static pl.jakubweg.StringRef.sf;
|
||||
import static pl.jakubweg.StringRef.str;
|
||||
|
||||
|
||||
@ -155,7 +154,16 @@ public class SponsorBlockPreferenceFragment extends PreferenceFragment implement
|
||||
preference.setDefaultValue(defaultValue);
|
||||
preference.setEntries(entries);
|
||||
preference.setEntryValues(entryValues);
|
||||
|
||||
EditTextPreference colorPreference = new EditTextPreference(context);
|
||||
colorPreference.setTitle("Set " + segmentInfo.title + " color");
|
||||
colorPreference.getEditText().setInputType(InputType.TYPE_CLASS_NUMBER);
|
||||
colorPreference.setKey(segmentInfo.key + "_color");
|
||||
colorPreference.setDefaultValue(segmentInfo.color);
|
||||
preferencesToDisableWhenSBDisabled.add(colorPreference);
|
||||
|
||||
category.addPreference(preference);
|
||||
category.addPreference(colorPreference);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -7,7 +7,6 @@ import android.text.Html;
|
||||
import android.text.TextUtils;
|
||||
import android.util.Log;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
@ -108,6 +107,9 @@ public class SponsorBlockSettings {
|
||||
segment.behaviour = behaviour;
|
||||
if (behaviour.showOnTimeBar)
|
||||
enabledCategories.add(segment.key);
|
||||
|
||||
String tmp = preferences.getString(segment.key + "_color", String.valueOf(segment.color));
|
||||
segment.setColor(Integer.parseInt(tmp));
|
||||
}
|
||||
|
||||
//"[%22sponsor%22,%22outro%22,%22music_offtopic%22,%22intro%22,%22selfpromo%22,%22interaction%22]";
|
||||
@ -183,8 +185,8 @@ public class SponsorBlockSettings {
|
||||
public final StringRef title;
|
||||
public final StringRef skipMessage;
|
||||
public final StringRef description;
|
||||
public final int color;
|
||||
public final Paint paint;
|
||||
public int color;
|
||||
public SegmentBehaviour behaviour;
|
||||
private CharSequence lazyTitleWithDot;
|
||||
|
||||
@ -201,8 +203,7 @@ public class SponsorBlockSettings {
|
||||
this.description = description;
|
||||
this.behaviour = behaviour;
|
||||
this.color = color & 0xFFFFFF;
|
||||
paint = new Paint();
|
||||
paint.setColor(color);
|
||||
this.paint = new Paint();
|
||||
}
|
||||
|
||||
public static SegmentInfo[] valuesWithoutPreview() {
|
||||
@ -213,9 +214,15 @@ public class SponsorBlockSettings {
|
||||
return mValuesMap.get(key);
|
||||
}
|
||||
|
||||
public void setColor(int color) {
|
||||
this.color = color;
|
||||
paint.setColor(color);
|
||||
paint.setAlpha(255);
|
||||
}
|
||||
|
||||
public CharSequence getTitleWithDot() {
|
||||
return (lazyTitleWithDot == null) ?
|
||||
lazyTitleWithDot = Html.fromHtml(String.format("<font color=\"#%06X\">⬤</font> %s", color, title))
|
||||
lazyTitleWithDot = Html.fromHtml(String.format("<font color=\"#%06X\">⬤</font> %s", this.color, title))
|
||||
: lazyTitleWithDot;
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user