Skip to content

Commit

Permalink
Merge pull request #109 from swakwork/dev
Browse files Browse the repository at this point in the history
feat(Twitter): Added `Customize explore tabs` patch
  • Loading branch information
crimera authored Nov 27, 2024
2 parents 2c1260a + d21ac32 commit b5e7e72
Show file tree
Hide file tree
Showing 7 changed files with 52 additions and 2 deletions.
3 changes: 3 additions & 0 deletions app/src/main/java/app/revanced/integrations/twitter/Pref.java
Original file line number Diff line number Diff line change
Expand Up @@ -312,6 +312,9 @@ public static ArrayList customProfileTabs() {
public static ArrayList customSidebar() {
return getList(Settings.CUSTOM_SIDEBAR_TABS.key);
}
public static ArrayList customExploreTabs() {
return getList(Settings.CUSTOM_EXPLORE_TABS.key);
}

public static ArrayList customNavbar() {
return getList(Settings.CUSTOM_NAVBAR_TABS.key);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,12 @@
import java.util.*;
import java.lang.reflect.Field;
import app.revanced.integrations.twitter.Pref;
import app.revanced.integrations.twitter.Utils;

public class Customise {

private static void logger(Object j){
Log.d("piko", j.toString());
Utils.logger(j);
}

public static List navBar(List inp){
Expand Down Expand Up @@ -58,6 +59,33 @@ public static ArrayList profiletabs(ArrayList inp){
return inp;
}

public static ArrayList exploretabs(ArrayList inp){
try{
ArrayList choices = Pref.customExploreTabs();
Object inpObj = inp.clone();
ArrayList<?> arr = (ArrayList<?>) inpObj;
Iterator itr = inp.iterator();

while (itr.hasNext()) {

Object obj = itr.next();
Class<?> clazz = obj.getClass();
Field field = clazz.getDeclaredField("a");
String id = (String) field.get(obj);

if (id!=null && choices.contains(id)){
arr.remove(obj);
}
}
return arr;


}catch (Exception e){
logger(e);
}
return inp;
}

public static List inlineBar(List inp){
try{
ArrayList choices = Pref.inlineBar();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -505,6 +505,15 @@ public void buildCustomiseSection(boolean buildCategory){
)
);
}
if (SettingsStatus.exploreTabCustomisation) {
addPreference(category,
helper.multiSelectListPref(
strRes("piko_pref_customisation_exploretabs"),
strRes("piko_pref_app_restart_rec"),
Settings.CUSTOM_EXPLORE_TABS
)
);
}
if (SettingsStatus.sideBarCustomisation) {
addPreference(category,
helper.multiSelectListPref(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ public class Settings extends BaseSettings {

public static final StringSetting CUSTOM_PROFILE_TABS = new StringSetting("customisation_profile_tabs", "");
public static final StringSetting CUSTOM_TIMELINE_TABS = new StringSetting("customisation_timeline_tabs", "show_both");
public static final StringSetting CUSTOM_EXPLORE_TABS = new StringSetting("customisation_explore_tabs", "");
public static final StringSetting CUSTOM_SIDEBAR_TABS = new StringSetting("customisation_sidebar_tabs", "");
public static final StringSetting CUSTOM_NAVBAR_TABS = new StringSetting("customisation_navbar_tabs", "");
public static final StringSetting CUSTOM_INLINE_TABS = new StringSetting("customisation_inlinebar_tabs", "");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ public class SettingsStatus {

public static boolean profileTabCustomisation = false;
public static boolean timelineTabCustomisation = false;
public static boolean exploreTabCustomisation = false;
public static boolean sideBarCustomisation = false;
public static boolean navBarCustomisation = false;
public static boolean inlineBarCustomisation = false;
Expand Down Expand Up @@ -286,6 +287,10 @@ public static void timelineTabCustomisation() {
timelineTabCustomisation = true;
}

public static void exploreTabCustomisation() {
exploreTabCustomisation = true;
}

public static void sideBarCustomisation() {
sideBarCustomisation = true;
}
Expand Down Expand Up @@ -323,7 +328,7 @@ public static boolean enablePremiumSection() {
}

public static boolean enableCustomisationSection() {
return (customPostFontSize || inlineBarCustomisation || navBarCustomisation || sideBarCustomisation || profileTabCustomisation || timelineTabCustomisation || defaultReplySortFilter);
return (exploreTabCustomisation || customPostFontSize || inlineBarCustomisation || navBarCustomisation || sideBarCustomisation || profileTabCustomisation || timelineTabCustomisation || defaultReplySortFilter);
}

public static void load() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@ public void onCreate(@org.jetbrains.annotations.Nullable Bundle savedInstanceSta
flags.put(strRes("piko_pref_feature_flags"),SettingsStatus.featureFlagsEnabled);
flags.put(strRes("piko_pref_customisation_profiletabs"),SettingsStatus.profileTabCustomisation);
flags.put(strRes("piko_pref_customisation_timelinetabs"),SettingsStatus.timelineTabCustomisation);
flags.put(strRes("piko_pref_customisation_exploretabs"),SettingsStatus.exploreTabCustomisation);
flags.put(strRes("piko_pref_customisation_navbartabs"),SettingsStatus.navBarCustomisation);
flags.put(strRes("piko_pref_customisation_sidebartabs"),SettingsStatus.sideBarCustomisation);
flags.put(strRes("piko_pref_disable_auto_timeline_scroll"),SettingsStatus.disableAutoTimelineScroll);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,9 @@ public void setInitialValue(String key) {
}else if (key == Settings.CUSTOM_INLINE_TABS.key) {
entries = Utils.getResourceStringArray("piko_array_inlinetabs");
entriesValues = new CharSequence[]{"Reply","Retweet", "Favorite","ViewCount","AddRemoveBookmarks", "TwitterShare"};
}else if (key == Settings.CUSTOM_EXPLORE_TABS.key) {
entries = Utils.getResourceStringArray("piko_array_exploretabs");
entriesValues = Utils.getResourceStringArray("piko_array_exploretabs_val");
}
setEntries(entries);
setEntryValues(entriesValues);
Expand Down

0 comments on commit b5e7e72

Please sign in to comment.