mirror of
https://github.com/revanced/revanced-patches.git
synced 2025-06-12 21:27:38 +02:00
chore: Separate extensions by app (#3905)
This commit is contained in:
5
extensions/tiktok/build.gradle.kts
Normal file
5
extensions/tiktok/build.gradle.kts
Normal file
@ -0,0 +1,5 @@
|
||||
dependencies {
|
||||
compileOnly(project(":extensions:shared:library"))
|
||||
compileOnly(project(":extensions:tiktok:stub"))
|
||||
compileOnly(libs.annotation)
|
||||
}
|
1
extensions/tiktok/src/main/AndroidManifest.xml
Normal file
1
extensions/tiktok/src/main/AndroidManifest.xml
Normal file
@ -0,0 +1 @@
|
||||
<manifest/>
|
@ -0,0 +1,25 @@
|
||||
package app.revanced.extension.tiktok;
|
||||
|
||||
import app.revanced.extension.shared.settings.StringSetting;
|
||||
|
||||
public class Utils {
|
||||
|
||||
// Edit: This could be handled using a custom Setting<Long[]> class
|
||||
// that saves its value to preferences and JSON using the formatted String created here.
|
||||
public static long[] parseMinMax(StringSetting setting) {
|
||||
final String[] minMax = setting.get().split("-");
|
||||
if (minMax.length == 2) {
|
||||
try {
|
||||
final long min = Long.parseLong(minMax[0]);
|
||||
final long max = Long.parseLong(minMax[1]);
|
||||
|
||||
if (min <= max && min >= 0) return new long[]{min, max};
|
||||
|
||||
} catch (NumberFormatException ignored) {
|
||||
}
|
||||
}
|
||||
|
||||
setting.save("0-" + Long.MAX_VALUE);
|
||||
return new long[]{0L, Long.MAX_VALUE};
|
||||
}
|
||||
}
|
@ -0,0 +1,13 @@
|
||||
package app.revanced.extension.tiktok.cleardisplay;
|
||||
|
||||
import app.revanced.extension.tiktok.settings.Settings;
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
public class RememberClearDisplayPatch {
|
||||
public static boolean getClearDisplayState() {
|
||||
return Settings.CLEAR_DISPLAY.get();
|
||||
}
|
||||
public static void rememberClearDisplayState(boolean newState) {
|
||||
Settings.CLEAR_DISPLAY.save(newState);
|
||||
}
|
||||
}
|
@ -0,0 +1,14 @@
|
||||
package app.revanced.extension.tiktok.download;
|
||||
|
||||
import app.revanced.extension.tiktok.settings.Settings;
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
public class DownloadsPatch {
|
||||
public static String getDownloadPath() {
|
||||
return Settings.DOWNLOAD_PATH.get();
|
||||
}
|
||||
|
||||
public static boolean shouldRemoveWatermark() {
|
||||
return Settings.DOWNLOAD_WATERMARK.get();
|
||||
}
|
||||
}
|
@ -0,0 +1,16 @@
|
||||
package app.revanced.extension.tiktok.feedfilter;
|
||||
|
||||
import app.revanced.extension.tiktok.settings.Settings;
|
||||
import com.ss.android.ugc.aweme.feed.model.Aweme;
|
||||
|
||||
public class AdsFilter implements IFilter {
|
||||
@Override
|
||||
public boolean getEnabled() {
|
||||
return Settings.REMOVE_ADS.get();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean getFiltered(Aweme item) {
|
||||
return item.isAd() || item.isWithPromotionalMusic();
|
||||
}
|
||||
}
|
@ -0,0 +1,34 @@
|
||||
package app.revanced.extension.tiktok.feedfilter;
|
||||
|
||||
import com.ss.android.ugc.aweme.feed.model.Aweme;
|
||||
import com.ss.android.ugc.aweme.feed.model.FeedItemList;
|
||||
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
|
||||
public final class FeedItemsFilter {
|
||||
private static final List<IFilter> FILTERS = List.of(
|
||||
new AdsFilter(),
|
||||
new LiveFilter(),
|
||||
new StoryFilter(),
|
||||
new ImageVideoFilter(),
|
||||
new ViewCountFilter(),
|
||||
new LikeCountFilter()
|
||||
);
|
||||
|
||||
public static void filter(FeedItemList feedItemList) {
|
||||
Iterator<Aweme> feedItemListIterator = feedItemList.items.iterator();
|
||||
while (feedItemListIterator.hasNext()) {
|
||||
Aweme item = feedItemListIterator.next();
|
||||
if (item == null) continue;
|
||||
|
||||
for (IFilter filter : FILTERS) {
|
||||
boolean enabled = filter.getEnabled();
|
||||
if (enabled && filter.getFiltered(item)) {
|
||||
feedItemListIterator.remove();
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,9 @@
|
||||
package app.revanced.extension.tiktok.feedfilter;
|
||||
|
||||
import com.ss.android.ugc.aweme.feed.model.Aweme;
|
||||
|
||||
public interface IFilter {
|
||||
boolean getEnabled();
|
||||
|
||||
boolean getFiltered(Aweme item);
|
||||
}
|
@ -0,0 +1,16 @@
|
||||
package app.revanced.extension.tiktok.feedfilter;
|
||||
|
||||
import app.revanced.extension.tiktok.settings.Settings;
|
||||
import com.ss.android.ugc.aweme.feed.model.Aweme;
|
||||
|
||||
public class ImageVideoFilter implements IFilter {
|
||||
@Override
|
||||
public boolean getEnabled() {
|
||||
return Settings.HIDE_IMAGE.get();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean getFiltered(Aweme item) {
|
||||
return item.isImage() || item.isPhotoMode();
|
||||
}
|
||||
}
|
@ -0,0 +1,32 @@
|
||||
package app.revanced.extension.tiktok.feedfilter;
|
||||
|
||||
import app.revanced.extension.tiktok.settings.Settings;
|
||||
import com.ss.android.ugc.aweme.feed.model.Aweme;
|
||||
import com.ss.android.ugc.aweme.feed.model.AwemeStatistics;
|
||||
|
||||
import static app.revanced.extension.tiktok.Utils.parseMinMax;
|
||||
|
||||
public final class LikeCountFilter implements IFilter {
|
||||
final long minLike;
|
||||
final long maxLike;
|
||||
|
||||
LikeCountFilter() {
|
||||
long[] minMax = parseMinMax(Settings.MIN_MAX_LIKES);
|
||||
minLike = minMax[0];
|
||||
maxLike = minMax[1];
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean getEnabled() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean getFiltered(Aweme item) {
|
||||
AwemeStatistics statistics = item.getStatistics();
|
||||
if (statistics == null) return false;
|
||||
|
||||
long likeCount = statistics.getDiggCount();
|
||||
return likeCount < minLike || likeCount > maxLike;
|
||||
}
|
||||
}
|
@ -0,0 +1,16 @@
|
||||
package app.revanced.extension.tiktok.feedfilter;
|
||||
|
||||
import app.revanced.extension.tiktok.settings.Settings;
|
||||
import com.ss.android.ugc.aweme.feed.model.Aweme;
|
||||
|
||||
public class LiveFilter implements IFilter {
|
||||
@Override
|
||||
public boolean getEnabled() {
|
||||
return Settings.HIDE_LIVE.get();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean getFiltered(Aweme item) {
|
||||
return item.isLive() || item.isLiveReplay();
|
||||
}
|
||||
}
|
@ -0,0 +1,16 @@
|
||||
package app.revanced.extension.tiktok.feedfilter;
|
||||
|
||||
import app.revanced.extension.tiktok.settings.Settings;
|
||||
import com.ss.android.ugc.aweme.feed.model.Aweme;
|
||||
|
||||
public class StoryFilter implements IFilter {
|
||||
@Override
|
||||
public boolean getEnabled() {
|
||||
return Settings.HIDE_STORY.get();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean getFiltered(Aweme item) {
|
||||
return item.getIsTikTokStory();
|
||||
}
|
||||
}
|
@ -0,0 +1,32 @@
|
||||
package app.revanced.extension.tiktok.feedfilter;
|
||||
|
||||
import app.revanced.extension.tiktok.settings.Settings;
|
||||
import com.ss.android.ugc.aweme.feed.model.Aweme;
|
||||
import com.ss.android.ugc.aweme.feed.model.AwemeStatistics;
|
||||
|
||||
import static app.revanced.extension.tiktok.Utils.parseMinMax;
|
||||
|
||||
public class ViewCountFilter implements IFilter {
|
||||
final long minView;
|
||||
final long maxView;
|
||||
|
||||
ViewCountFilter() {
|
||||
long[] minMax = parseMinMax(Settings.MIN_MAX_VIEWS);
|
||||
minView = minMax[0];
|
||||
maxView = minMax[1];
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean getEnabled() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean getFiltered(Aweme item) {
|
||||
AwemeStatistics statistics = item.getStatistics();
|
||||
if (statistics == null) return false;
|
||||
|
||||
long playCount = statistics.getPlayCount();
|
||||
return playCount < minView || playCount > maxView;
|
||||
}
|
||||
}
|
@ -0,0 +1,82 @@
|
||||
package app.revanced.extension.tiktok.settings;
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.os.Bundle;
|
||||
import android.preference.PreferenceFragment;
|
||||
import android.view.View;
|
||||
import android.widget.FrameLayout;
|
||||
import android.widget.LinearLayout;
|
||||
import app.revanced.extension.shared.Logger;
|
||||
import app.revanced.extension.shared.Utils;
|
||||
import app.revanced.extension.tiktok.settings.preference.ReVancedPreferenceFragment;
|
||||
import com.bytedance.ies.ugc.aweme.commercialize.compliance.personalization.AdPersonalizationActivity;
|
||||
|
||||
import java.lang.reflect.Constructor;
|
||||
import java.lang.reflect.InvocationTargetException;
|
||||
|
||||
/**
|
||||
* Hooks AdPersonalizationActivity.
|
||||
* <p>
|
||||
* This class is responsible for injecting our own fragment by replacing the AdPersonalizationActivity.
|
||||
*
|
||||
* @noinspection unused
|
||||
*/
|
||||
public class AdPersonalizationActivityHook {
|
||||
public static Object createSettingsEntry(String entryClazzName, String entryInfoClazzName) {
|
||||
try {
|
||||
Class<?> entryClazz = Class.forName(entryClazzName);
|
||||
Class<?> entryInfoClazz = Class.forName(entryInfoClazzName);
|
||||
Constructor<?> entryConstructor = entryClazz.getConstructor(entryInfoClazz);
|
||||
Constructor<?> entryInfoConstructor = entryInfoClazz.getDeclaredConstructors()[0];
|
||||
Object buttonInfo = entryInfoConstructor.newInstance("ReVanced settings", null, (View.OnClickListener) view -> startSettingsActivity(), "revanced");
|
||||
return entryConstructor.newInstance(buttonInfo);
|
||||
} catch (ClassNotFoundException | NoSuchMethodException | InvocationTargetException | IllegalAccessException |
|
||||
InstantiationException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
|
||||
/***
|
||||
* Initialize the settings menu.
|
||||
* @param base The activity to initialize the settings menu on.
|
||||
* @return Whether the settings menu should be initialized.
|
||||
*/
|
||||
public static boolean initialize(AdPersonalizationActivity base) {
|
||||
Bundle extras = base.getIntent().getExtras();
|
||||
if (extras != null && !extras.getBoolean("revanced", false)) return false;
|
||||
|
||||
SettingsStatus.load();
|
||||
|
||||
LinearLayout linearLayout = new LinearLayout(base);
|
||||
linearLayout.setLayoutParams(new LinearLayout.LayoutParams(-1, -1));
|
||||
linearLayout.setOrientation(LinearLayout.VERTICAL);
|
||||
linearLayout.setFitsSystemWindows(true);
|
||||
linearLayout.setTransitionGroup(true);
|
||||
|
||||
FrameLayout fragment = new FrameLayout(base);
|
||||
fragment.setLayoutParams(new FrameLayout.LayoutParams(-1, -1));
|
||||
int fragmentId = View.generateViewId();
|
||||
fragment.setId(fragmentId);
|
||||
|
||||
linearLayout.addView(fragment);
|
||||
base.setContentView(linearLayout);
|
||||
|
||||
PreferenceFragment preferenceFragment = new ReVancedPreferenceFragment();
|
||||
base.getFragmentManager().beginTransaction().replace(fragmentId, preferenceFragment).commit();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
private static void startSettingsActivity() {
|
||||
Context appContext = Utils.getContext();
|
||||
if (appContext != null) {
|
||||
Intent intent = new Intent(appContext, AdPersonalizationActivity.class);
|
||||
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
|
||||
intent.putExtra("revanced", true);
|
||||
appContext.startActivity(intent);
|
||||
} else {
|
||||
Logger.printDebug(() -> "Utils.getContext() return null");
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,26 @@
|
||||
package app.revanced.extension.tiktok.settings;
|
||||
|
||||
import static java.lang.Boolean.FALSE;
|
||||
import static java.lang.Boolean.TRUE;
|
||||
|
||||
import app.revanced.extension.shared.settings.BaseSettings;
|
||||
import app.revanced.extension.shared.settings.BooleanSetting;
|
||||
import app.revanced.extension.shared.settings.FloatSetting;
|
||||
import app.revanced.extension.shared.settings.StringSetting;
|
||||
|
||||
public class Settings extends BaseSettings {
|
||||
public static final BooleanSetting REMOVE_ADS = new BooleanSetting("remove_ads", TRUE, true);
|
||||
public static final BooleanSetting HIDE_LIVE = new BooleanSetting("hide_live", FALSE, true);
|
||||
public static final BooleanSetting HIDE_STORY = new BooleanSetting("hide_story", FALSE, true);
|
||||
public static final BooleanSetting HIDE_IMAGE = new BooleanSetting("hide_image", FALSE, true);
|
||||
public static final StringSetting MIN_MAX_VIEWS = new StringSetting("min_max_views", "0-" + Long.MAX_VALUE, true);
|
||||
public static final StringSetting MIN_MAX_LIKES = new StringSetting("min_max_likes", "0-" + Long.MAX_VALUE, true);
|
||||
public static final StringSetting DOWNLOAD_PATH = new StringSetting("down_path", "DCIM/TikTok");
|
||||
public static final BooleanSetting DOWNLOAD_WATERMARK = new BooleanSetting("down_watermark", TRUE);
|
||||
public static final BooleanSetting CLEAR_DISPLAY = new BooleanSetting("clear_display", FALSE);
|
||||
public static final FloatSetting REMEMBERED_SPEED = new FloatSetting("REMEMBERED_SPEED", 1.0f);
|
||||
public static final BooleanSetting SIM_SPOOF = new BooleanSetting("simspoof", TRUE, true);
|
||||
public static final StringSetting SIM_SPOOF_ISO = new StringSetting("simspoof_iso", "us");
|
||||
public static final StringSetting SIMSPOOF_MCCMNC = new StringSetting("simspoof_mccmnc", "310160");
|
||||
public static final StringSetting SIMSPOOF_OP_NAME = new StringSetting("simspoof_op_name", "T-Mobile");
|
||||
}
|
@ -0,0 +1,23 @@
|
||||
package app.revanced.extension.tiktok.settings;
|
||||
|
||||
public class SettingsStatus {
|
||||
public static boolean feedFilterEnabled = false;
|
||||
public static boolean downloadEnabled = false;
|
||||
public static boolean simSpoofEnabled = false;
|
||||
|
||||
public static void enableFeedFilter() {
|
||||
feedFilterEnabled = true;
|
||||
}
|
||||
|
||||
public static void enableDownload() {
|
||||
downloadEnabled = true;
|
||||
}
|
||||
|
||||
public static void enableSimSpoof() {
|
||||
simSpoofEnabled = true;
|
||||
}
|
||||
|
||||
public static void load() {
|
||||
|
||||
}
|
||||
}
|
@ -0,0 +1,124 @@
|
||||
package app.revanced.extension.tiktok.settings.preference;
|
||||
|
||||
import android.app.AlertDialog;
|
||||
import android.content.Context;
|
||||
import android.content.DialogInterface;
|
||||
import android.os.Environment;
|
||||
import android.preference.DialogPreference;
|
||||
import android.text.Editable;
|
||||
import android.text.InputType;
|
||||
import android.text.TextUtils;
|
||||
import android.text.TextWatcher;
|
||||
import android.view.View;
|
||||
import android.widget.EditText;
|
||||
import android.widget.LinearLayout;
|
||||
import android.widget.RadioButton;
|
||||
import android.widget.RadioGroup;
|
||||
|
||||
import app.revanced.extension.shared.settings.StringSetting;
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
public class DownloadPathPreference extends DialogPreference {
|
||||
private final Context context;
|
||||
private final String[] entryValues = {"DCIM", "Movies", "Pictures"};
|
||||
private String mValue;
|
||||
|
||||
private boolean mValueSet;
|
||||
private int mediaPathIndex;
|
||||
private String childDownloadPath;
|
||||
|
||||
public DownloadPathPreference(Context context, String title, StringSetting setting) {
|
||||
super(context);
|
||||
this.context = context;
|
||||
this.setTitle(title);
|
||||
this.setSummary(Environment.getExternalStorageDirectory().getPath() + "/" + setting.get());
|
||||
this.setKey(setting.key);
|
||||
this.setValue(setting.get());
|
||||
}
|
||||
|
||||
public String getValue() {
|
||||
return this.mValue;
|
||||
}
|
||||
|
||||
public void setValue(String value) {
|
||||
final boolean changed = !TextUtils.equals(mValue, value);
|
||||
if (changed || !mValueSet) {
|
||||
mValue = value;
|
||||
mValueSet = true;
|
||||
persistString(value);
|
||||
if (changed) {
|
||||
notifyDependencyChange(shouldDisableDependents());
|
||||
notifyChanged();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected View onCreateDialogView() {
|
||||
String currentMedia = getValue().split("/")[0];
|
||||
childDownloadPath = getValue().substring(getValue().indexOf("/") + 1);
|
||||
mediaPathIndex = findIndexOf(currentMedia);
|
||||
|
||||
LinearLayout dialogView = new LinearLayout(context);
|
||||
RadioGroup mediaPath = new RadioGroup(context);
|
||||
mediaPath.setLayoutParams(new RadioGroup.LayoutParams(-1, -2));
|
||||
for (String entryValue : entryValues) {
|
||||
RadioButton radioButton = new RadioButton(context);
|
||||
radioButton.setText(entryValue);
|
||||
radioButton.setId(View.generateViewId());
|
||||
mediaPath.addView(radioButton);
|
||||
}
|
||||
mediaPath.setOnCheckedChangeListener((radioGroup, id) -> {
|
||||
RadioButton radioButton = radioGroup.findViewById(id);
|
||||
mediaPathIndex = findIndexOf(radioButton.getText().toString());
|
||||
});
|
||||
mediaPath.check(mediaPath.getChildAt(mediaPathIndex).getId());
|
||||
EditText downloadPath = new EditText(context);
|
||||
downloadPath.setInputType(InputType.TYPE_CLASS_TEXT);
|
||||
downloadPath.setText(childDownloadPath);
|
||||
downloadPath.addTextChangedListener(new TextWatcher() {
|
||||
@Override
|
||||
public void beforeTextChanged(CharSequence charSequence, int i, int i1, int i2) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onTextChanged(CharSequence charSequence, int i, int i1, int i2) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void afterTextChanged(Editable editable) {
|
||||
childDownloadPath = editable.toString();
|
||||
}
|
||||
});
|
||||
dialogView.setLayoutParams(new LinearLayout.LayoutParams(-1, -1));
|
||||
dialogView.setOrientation(LinearLayout.VERTICAL);
|
||||
dialogView.addView(mediaPath);
|
||||
dialogView.addView(downloadPath);
|
||||
return dialogView;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onPrepareDialogBuilder(AlertDialog.Builder builder) {
|
||||
builder.setTitle("Download Path");
|
||||
builder.setPositiveButton(android.R.string.ok, (dialog, which) -> this.onClick(dialog, DialogInterface.BUTTON_POSITIVE));
|
||||
builder.setNegativeButton(android.R.string.cancel, null);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onDialogClosed(boolean positiveResult) {
|
||||
if (positiveResult && mediaPathIndex >= 0) {
|
||||
String newValue = entryValues[mediaPathIndex] + "/" + childDownloadPath;
|
||||
setSummary(Environment.getExternalStorageDirectory().getPath() + "/" + newValue);
|
||||
setValue(newValue);
|
||||
}
|
||||
}
|
||||
|
||||
private int findIndexOf(String str) {
|
||||
for (int i = 0; i < entryValues.length; i++) {
|
||||
if (str.equals(entryValues[i])) return i;
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
}
|
@ -0,0 +1,17 @@
|
||||
package app.revanced.extension.tiktok.settings.preference;
|
||||
|
||||
import android.content.Context;
|
||||
import android.preference.EditTextPreference;
|
||||
|
||||
import app.revanced.extension.shared.settings.StringSetting;
|
||||
|
||||
public class InputTextPreference extends EditTextPreference {
|
||||
|
||||
public InputTextPreference(Context context, String title, String summary, StringSetting setting) {
|
||||
super(context);
|
||||
this.setTitle(title);
|
||||
this.setSummary(summary);
|
||||
this.setKey(setting.key);
|
||||
this.setText(setting.get());
|
||||
}
|
||||
}
|
@ -0,0 +1,130 @@
|
||||
package app.revanced.extension.tiktok.settings.preference;
|
||||
|
||||
import android.app.AlertDialog;
|
||||
import android.content.Context;
|
||||
import android.content.DialogInterface;
|
||||
import android.preference.DialogPreference;
|
||||
import android.text.Editable;
|
||||
import android.text.InputType;
|
||||
import android.text.TextUtils;
|
||||
import android.text.TextWatcher;
|
||||
import android.view.View;
|
||||
import android.widget.EditText;
|
||||
import android.widget.LinearLayout;
|
||||
import android.widget.TextView;
|
||||
|
||||
import app.revanced.extension.shared.settings.StringSetting;
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
public class RangeValuePreference extends DialogPreference {
|
||||
private final Context context;
|
||||
|
||||
private String minValue;
|
||||
|
||||
private String maxValue;
|
||||
|
||||
private String mValue;
|
||||
|
||||
private boolean mValueSet;
|
||||
|
||||
public RangeValuePreference(Context context, String title, String summary, StringSetting setting) {
|
||||
super(context);
|
||||
this.context = context;
|
||||
setTitle(title);
|
||||
setSummary(summary);
|
||||
setKey(setting.key);
|
||||
setValue(setting.get());
|
||||
}
|
||||
|
||||
public void setValue(String value) {
|
||||
final boolean changed = !TextUtils.equals(mValue, value);
|
||||
if (changed || !mValueSet) {
|
||||
mValue = value;
|
||||
mValueSet = true;
|
||||
persistString(value);
|
||||
if (changed) {
|
||||
notifyDependencyChange(shouldDisableDependents());
|
||||
notifyChanged();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public String getValue() {
|
||||
return mValue;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected View onCreateDialogView() {
|
||||
minValue = getValue().split("-")[0];
|
||||
maxValue = getValue().split("-")[1];
|
||||
LinearLayout dialogView = new LinearLayout(context);
|
||||
dialogView.setOrientation(LinearLayout.VERTICAL);
|
||||
LinearLayout minView = new LinearLayout(context);
|
||||
minView.setOrientation(LinearLayout.HORIZONTAL);
|
||||
TextView min = new TextView(context);
|
||||
min.setText("Min: ");
|
||||
minView.addView(min);
|
||||
EditText minEditText = new EditText(context);
|
||||
minEditText.setInputType(InputType.TYPE_CLASS_NUMBER);
|
||||
minEditText.setText(minValue);
|
||||
minView.addView(minEditText);
|
||||
dialogView.addView(minView);
|
||||
LinearLayout maxView = new LinearLayout(context);
|
||||
maxView.setOrientation(LinearLayout.HORIZONTAL);
|
||||
TextView max = new TextView(context);
|
||||
max.setText("Max: ");
|
||||
maxView.addView(max);
|
||||
EditText maxEditText = new EditText(context);
|
||||
maxEditText.setInputType(InputType.TYPE_CLASS_NUMBER);
|
||||
maxEditText.setText(maxValue);
|
||||
maxView.addView(maxEditText);
|
||||
dialogView.addView(maxView);
|
||||
minEditText.addTextChangedListener(new TextWatcher() {
|
||||
@Override
|
||||
public void beforeTextChanged(CharSequence charSequence, int i, int i1, int i2) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onTextChanged(CharSequence charSequence, int i, int i1, int i2) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void afterTextChanged(Editable editable) {
|
||||
minValue = editable.toString();
|
||||
}
|
||||
});
|
||||
maxEditText.addTextChangedListener(new TextWatcher() {
|
||||
@Override
|
||||
public void beforeTextChanged(CharSequence charSequence, int i, int i1, int i2) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onTextChanged(CharSequence charSequence, int i, int i1, int i2) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void afterTextChanged(Editable editable) {
|
||||
maxValue = editable.toString();
|
||||
}
|
||||
});
|
||||
return dialogView;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onPrepareDialogBuilder(AlertDialog.Builder builder) {
|
||||
builder.setPositiveButton(android.R.string.ok, (dialog, which) -> this.onClick(dialog, DialogInterface.BUTTON_POSITIVE));
|
||||
builder.setNegativeButton(android.R.string.cancel, null);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onDialogClosed(boolean positiveResult) {
|
||||
if (positiveResult) {
|
||||
String newValue = minValue + "-" + maxValue;
|
||||
setValue(newValue);
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,54 @@
|
||||
package app.revanced.extension.tiktok.settings.preference;
|
||||
|
||||
import android.preference.Preference;
|
||||
import android.preference.PreferenceScreen;
|
||||
import androidx.annotation.NonNull;
|
||||
import app.revanced.extension.shared.settings.Setting;
|
||||
import app.revanced.extension.shared.settings.preference.AbstractPreferenceFragment;
|
||||
import app.revanced.extension.tiktok.settings.preference.categories.DownloadsPreferenceCategory;
|
||||
import app.revanced.extension.tiktok.settings.preference.categories.FeedFilterPreferenceCategory;
|
||||
import app.revanced.extension.tiktok.settings.preference.categories.ExtensionPreferenceCategory;
|
||||
import app.revanced.extension.tiktok.settings.preference.categories.SimSpoofPreferenceCategory;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
/**
|
||||
* Preference fragment for ReVanced settings
|
||||
*/
|
||||
@SuppressWarnings("deprecation")
|
||||
public class ReVancedPreferenceFragment extends AbstractPreferenceFragment {
|
||||
|
||||
@Override
|
||||
protected void syncSettingWithPreference(@NonNull @NotNull Preference pref,
|
||||
@NonNull @NotNull Setting<?> setting,
|
||||
boolean applySettingToPreference) {
|
||||
if (pref instanceof RangeValuePreference) {
|
||||
RangeValuePreference rangeValuePref = (RangeValuePreference) pref;
|
||||
Setting.privateSetValueFromString(setting, rangeValuePref.getValue());
|
||||
} else if (pref instanceof DownloadPathPreference) {
|
||||
DownloadPathPreference downloadPathPref = (DownloadPathPreference) pref;
|
||||
Setting.privateSetValueFromString(setting, downloadPathPref.getValue());
|
||||
} else {
|
||||
super.syncSettingWithPreference(pref, setting, applySettingToPreference);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void initialize() {
|
||||
final var context = getContext();
|
||||
|
||||
// Currently no resources can be compiled for TikTok (fails with aapt error).
|
||||
// So all TikTok Strings are hard coded in the extension.
|
||||
restartDialogTitle = "Refresh and restart";
|
||||
restartDialogButtonText = "Restart";
|
||||
confirmDialogTitle = "Do you wish to proceed?";
|
||||
|
||||
PreferenceScreen preferenceScreen = getPreferenceManager().createPreferenceScreen(context);
|
||||
setPreferenceScreen(preferenceScreen);
|
||||
|
||||
// Custom categories reference app specific Settings class.
|
||||
new FeedFilterPreferenceCategory(context, preferenceScreen);
|
||||
new DownloadsPreferenceCategory(context, preferenceScreen);
|
||||
new SimSpoofPreferenceCategory(context, preferenceScreen);
|
||||
new ExtensionPreferenceCategory(context, preferenceScreen);
|
||||
}
|
||||
}
|
@ -0,0 +1,55 @@
|
||||
package app.revanced.extension.tiktok.settings.preference;
|
||||
|
||||
import android.content.Context;
|
||||
import android.util.AttributeSet;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
import app.revanced.extension.shared.Logger;
|
||||
import app.revanced.extension.shared.settings.preference.ReVancedAboutPreference;
|
||||
|
||||
public class ReVancedTikTokAboutPreference extends ReVancedAboutPreference {
|
||||
|
||||
/**
|
||||
* Because resources cannot be added to TikTok,
|
||||
* these strings are copied from the shared strings.xml file.
|
||||
*
|
||||
* Changes here must also be made in strings.xml
|
||||
*/
|
||||
private final Map<String, String> aboutStrings = Map.of(
|
||||
"revanced_settings_about_links_body", "You are using ReVanced Patches version <i>%s</i>",
|
||||
"revanced_settings_about_links_dev_header", "Note",
|
||||
"revanced_settings_about_links_dev_body", "This version is a pre-release and you may experience unexpected issues",
|
||||
"revanced_settings_about_links_header", "Official links"
|
||||
);
|
||||
|
||||
{
|
||||
//noinspection deprecation
|
||||
setTitle("About");
|
||||
}
|
||||
|
||||
public ReVancedTikTokAboutPreference(Context context, AttributeSet attrs, int defStyleAttr, int defStyleRes) {
|
||||
super(context, attrs, defStyleAttr, defStyleRes);
|
||||
}
|
||||
public ReVancedTikTokAboutPreference(Context context, AttributeSet attrs, int defStyleAttr) {
|
||||
super(context, attrs, defStyleAttr);
|
||||
}
|
||||
public ReVancedTikTokAboutPreference(Context context, AttributeSet attrs) {
|
||||
super(context, attrs);
|
||||
}
|
||||
public ReVancedTikTokAboutPreference(Context context) {
|
||||
super(context);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String getString(String key, Object ... args) {
|
||||
String format = aboutStrings.get(key);
|
||||
|
||||
if (format == null) {
|
||||
Logger.printException(() -> "Unknown key: " + key);
|
||||
return "";
|
||||
}
|
||||
|
||||
return String.format(format, args);
|
||||
}
|
||||
}
|
@ -0,0 +1,17 @@
|
||||
package app.revanced.extension.tiktok.settings.preference;
|
||||
|
||||
import android.content.Context;
|
||||
import android.preference.SwitchPreference;
|
||||
|
||||
import app.revanced.extension.shared.settings.BooleanSetting;
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
public class TogglePreference extends SwitchPreference {
|
||||
public TogglePreference(Context context, String title, String summary, BooleanSetting setting) {
|
||||
super(context);
|
||||
this.setTitle(title);
|
||||
this.setSummary(summary);
|
||||
this.setKey(setting.key);
|
||||
this.setChecked(setting.get());
|
||||
}
|
||||
}
|
@ -0,0 +1,22 @@
|
||||
package app.revanced.extension.tiktok.settings.preference.categories;
|
||||
|
||||
import android.content.Context;
|
||||
import android.preference.PreferenceCategory;
|
||||
import android.preference.PreferenceScreen;
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
public abstract class ConditionalPreferenceCategory extends PreferenceCategory {
|
||||
public ConditionalPreferenceCategory(Context context, PreferenceScreen screen) {
|
||||
super(context);
|
||||
|
||||
if (getSettingsStatus()) {
|
||||
screen.addPreference(this);
|
||||
addPreferences(context);
|
||||
}
|
||||
}
|
||||
|
||||
public abstract boolean getSettingsStatus();
|
||||
|
||||
public abstract void addPreferences(Context context);
|
||||
}
|
||||
|
@ -0,0 +1,35 @@
|
||||
package app.revanced.extension.tiktok.settings.preference.categories;
|
||||
|
||||
import android.content.Context;
|
||||
import android.preference.PreferenceScreen;
|
||||
import app.revanced.extension.tiktok.settings.Settings;
|
||||
import app.revanced.extension.tiktok.settings.SettingsStatus;
|
||||
import app.revanced.extension.tiktok.settings.preference.DownloadPathPreference;
|
||||
import app.revanced.extension.tiktok.settings.preference.TogglePreference;
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
public class DownloadsPreferenceCategory extends ConditionalPreferenceCategory {
|
||||
public DownloadsPreferenceCategory(Context context, PreferenceScreen screen) {
|
||||
super(context, screen);
|
||||
setTitle("Downloads");
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean getSettingsStatus() {
|
||||
return SettingsStatus.downloadEnabled;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addPreferences(Context context) {
|
||||
addPreference(new DownloadPathPreference(
|
||||
context,
|
||||
"Download path",
|
||||
Settings.DOWNLOAD_PATH
|
||||
));
|
||||
addPreference(new TogglePreference(
|
||||
context,
|
||||
"Remove watermark", "",
|
||||
Settings.DOWNLOAD_WATERMARK
|
||||
));
|
||||
}
|
||||
}
|
@ -0,0 +1,32 @@
|
||||
package app.revanced.extension.tiktok.settings.preference.categories;
|
||||
|
||||
import android.content.Context;
|
||||
import android.preference.PreferenceScreen;
|
||||
|
||||
import app.revanced.extension.shared.settings.BaseSettings;
|
||||
import app.revanced.extension.tiktok.settings.preference.ReVancedTikTokAboutPreference;
|
||||
import app.revanced.extension.tiktok.settings.preference.TogglePreference;
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
public class ExtensionPreferenceCategory extends ConditionalPreferenceCategory {
|
||||
public ExtensionPreferenceCategory(Context context, PreferenceScreen screen) {
|
||||
super(context, screen);
|
||||
setTitle("Miscellaneous");
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean getSettingsStatus() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addPreferences(Context context) {
|
||||
addPreference(new ReVancedTikTokAboutPreference(context));
|
||||
|
||||
addPreference(new TogglePreference(context,
|
||||
"Enable debug log",
|
||||
"Show extension debug log.",
|
||||
BaseSettings.DEBUG
|
||||
));
|
||||
}
|
||||
}
|
@ -0,0 +1,55 @@
|
||||
package app.revanced.extension.tiktok.settings.preference.categories;
|
||||
|
||||
import android.content.Context;
|
||||
import android.preference.PreferenceScreen;
|
||||
import app.revanced.extension.tiktok.settings.preference.RangeValuePreference;
|
||||
import app.revanced.extension.tiktok.settings.Settings;
|
||||
import app.revanced.extension.tiktok.settings.SettingsStatus;
|
||||
import app.revanced.extension.tiktok.settings.preference.TogglePreference;
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
public class FeedFilterPreferenceCategory extends ConditionalPreferenceCategory {
|
||||
public FeedFilterPreferenceCategory(Context context, PreferenceScreen screen) {
|
||||
super(context, screen);
|
||||
setTitle("Feed filter");
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean getSettingsStatus() {
|
||||
return SettingsStatus.feedFilterEnabled;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addPreferences(Context context) {
|
||||
addPreference(new TogglePreference(
|
||||
context,
|
||||
"Remove feed ads", "Remove ads from feed.",
|
||||
Settings.REMOVE_ADS
|
||||
));
|
||||
addPreference(new TogglePreference(
|
||||
context,
|
||||
"Hide livestreams", "Hide livestreams from feed.",
|
||||
Settings.HIDE_LIVE
|
||||
));
|
||||
addPreference(new TogglePreference(
|
||||
context,
|
||||
"Hide story", "Hide story from feed.",
|
||||
Settings.HIDE_STORY
|
||||
));
|
||||
addPreference(new TogglePreference(
|
||||
context,
|
||||
"Hide image video", "Hide image video from feed.",
|
||||
Settings.HIDE_IMAGE
|
||||
));
|
||||
addPreference(new RangeValuePreference(
|
||||
context,
|
||||
"Min/Max views", "The minimum or maximum views of a video to show.",
|
||||
Settings.MIN_MAX_VIEWS
|
||||
));
|
||||
addPreference(new RangeValuePreference(
|
||||
context,
|
||||
"Min/Max likes", "The minimum or maximum likes of a video to show.",
|
||||
Settings.MIN_MAX_LIKES
|
||||
));
|
||||
}
|
||||
}
|
@ -0,0 +1,47 @@
|
||||
package app.revanced.extension.tiktok.settings.preference.categories;
|
||||
|
||||
import android.content.Context;
|
||||
import android.preference.PreferenceScreen;
|
||||
import app.revanced.extension.tiktok.settings.Settings;
|
||||
import app.revanced.extension.tiktok.settings.SettingsStatus;
|
||||
import app.revanced.extension.tiktok.settings.preference.InputTextPreference;
|
||||
import app.revanced.extension.tiktok.settings.preference.TogglePreference;
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
public class SimSpoofPreferenceCategory extends ConditionalPreferenceCategory {
|
||||
public SimSpoofPreferenceCategory(Context context, PreferenceScreen screen) {
|
||||
super(context, screen);
|
||||
setTitle("Bypass regional restriction");
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean getSettingsStatus() {
|
||||
return SettingsStatus.simSpoofEnabled;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addPreferences(Context context) {
|
||||
addPreference(new TogglePreference(
|
||||
context,
|
||||
"Fake sim card info",
|
||||
"Bypass regional restriction by fake sim card information.",
|
||||
Settings.SIM_SPOOF
|
||||
));
|
||||
addPreference(new InputTextPreference(
|
||||
context,
|
||||
"Country ISO", "us, uk, jp, ...",
|
||||
Settings.SIM_SPOOF_ISO
|
||||
));
|
||||
addPreference(new InputTextPreference(
|
||||
context,
|
||||
"Operator mcc+mnc", "mcc+mnc",
|
||||
Settings.SIMSPOOF_MCCMNC
|
||||
));
|
||||
addPreference(new InputTextPreference(
|
||||
context,
|
||||
"Operator name", "Name of the operator.",
|
||||
Settings.SIMSPOOF_OP_NAME
|
||||
));
|
||||
}
|
||||
}
|
@ -0,0 +1,13 @@
|
||||
package app.revanced.extension.tiktok.speed;
|
||||
|
||||
import app.revanced.extension.tiktok.settings.Settings;
|
||||
|
||||
public class PlaybackSpeedPatch {
|
||||
public static void rememberPlaybackSpeed(float newSpeed) {
|
||||
Settings.REMEMBERED_SPEED.save(newSpeed);
|
||||
}
|
||||
|
||||
public static float getPlaybackSpeed() {
|
||||
return Settings.REMEMBERED_SPEED.get();
|
||||
}
|
||||
}
|
@ -0,0 +1,37 @@
|
||||
package app.revanced.extension.tiktok.spoof.sim;
|
||||
|
||||
import app.revanced.extension.shared.Logger;
|
||||
import app.revanced.extension.tiktok.settings.Settings;
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
public class SpoofSimPatch {
|
||||
|
||||
private static final boolean ENABLED = Settings.SIM_SPOOF.get();
|
||||
|
||||
public static String getCountryIso(String value) {
|
||||
if (ENABLED) {
|
||||
String iso = Settings.SIM_SPOOF_ISO.get();
|
||||
Logger.printDebug(() -> "Spoofing sim ISO from: " + value + " to: " + iso);
|
||||
return iso;
|
||||
}
|
||||
return value;
|
||||
}
|
||||
|
||||
public static String getOperator(String value) {
|
||||
if (ENABLED) {
|
||||
String mcc_mnc = Settings.SIMSPOOF_MCCMNC.get();
|
||||
Logger.printDebug(() -> "Spoofing sim MCC-MNC from: " + value + " to: " + mcc_mnc);
|
||||
return mcc_mnc;
|
||||
}
|
||||
return value;
|
||||
}
|
||||
|
||||
public static String getOperatorName(String value) {
|
||||
if (ENABLED) {
|
||||
String operator = Settings.SIMSPOOF_OP_NAME.get();
|
||||
Logger.printDebug(() -> "Spoofing sim operator from: " + value + " to: " + operator);
|
||||
return operator;
|
||||
}
|
||||
return value;
|
||||
}
|
||||
}
|
17
extensions/tiktok/stub/build.gradle.kts
Normal file
17
extensions/tiktok/stub/build.gradle.kts
Normal file
@ -0,0 +1,17 @@
|
||||
plugins {
|
||||
id(libs.plugins.android.library.get().pluginId)
|
||||
}
|
||||
|
||||
android {
|
||||
namespace = "app.revanced.extension"
|
||||
compileSdk = 33
|
||||
|
||||
defaultConfig {
|
||||
minSdk = 24
|
||||
}
|
||||
|
||||
compileOptions {
|
||||
sourceCompatibility = JavaVersion.VERSION_11
|
||||
targetCompatibility = JavaVersion.VERSION_11
|
||||
}
|
||||
}
|
1
extensions/tiktok/stub/src/main/AndroidManifest.xml
Normal file
1
extensions/tiktok/stub/src/main/AndroidManifest.xml
Normal file
@ -0,0 +1 @@
|
||||
<manifest/>
|
@ -0,0 +1,6 @@
|
||||
package com.bytedance.ies.ugc.aweme.commercialize.compliance.personalization;
|
||||
|
||||
import android.app.Activity;
|
||||
|
||||
//Dummy class
|
||||
public class AdPersonalizationActivity extends Activity { }
|
@ -0,0 +1,36 @@
|
||||
package com.ss.android.ugc.aweme.feed.model;
|
||||
|
||||
//Dummy class
|
||||
public class Aweme {
|
||||
public boolean isAd() {
|
||||
throw new UnsupportedOperationException("Stub");
|
||||
}
|
||||
|
||||
public boolean isLive() {
|
||||
throw new UnsupportedOperationException("Stub");
|
||||
}
|
||||
|
||||
public boolean isLiveReplay() {
|
||||
throw new UnsupportedOperationException("Stub");
|
||||
}
|
||||
|
||||
public boolean isWithPromotionalMusic() {
|
||||
throw new UnsupportedOperationException("Stub");
|
||||
}
|
||||
|
||||
public boolean getIsTikTokStory() {
|
||||
throw new UnsupportedOperationException("Stub");
|
||||
}
|
||||
|
||||
public boolean isImage() {
|
||||
throw new UnsupportedOperationException("Stub");
|
||||
}
|
||||
|
||||
public boolean isPhotoMode() {
|
||||
throw new UnsupportedOperationException("Stub");
|
||||
}
|
||||
|
||||
public AwemeStatistics getStatistics() {
|
||||
throw new UnsupportedOperationException("Stub");
|
||||
}
|
||||
}
|
@ -0,0 +1,10 @@
|
||||
package com.ss.android.ugc.aweme.feed.model;
|
||||
|
||||
public class AwemeStatistics {
|
||||
public long getPlayCount() {
|
||||
throw new UnsupportedOperationException("Stub");
|
||||
}
|
||||
public long getDiggCount() {
|
||||
throw new UnsupportedOperationException("Stub");
|
||||
}
|
||||
}
|
@ -0,0 +1,8 @@
|
||||
package com.ss.android.ugc.aweme.feed.model;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
//Dummy class
|
||||
public class FeedItemList {
|
||||
public List<Aweme> items;
|
||||
}
|
Reference in New Issue
Block a user