Skip to content

Commit

Permalink
Merge pull request #49 from swakwork/dev
Browse files Browse the repository at this point in the history
feat(Twitter): Added `Customize Navigation Bar items` patch
  • Loading branch information
crimera authored May 13, 2024
2 parents 8e32a5c + 133d316 commit bde296f
Show file tree
Hide file tree
Showing 6 changed files with 63 additions and 1 deletion.
12 changes: 12 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 @@ -225,5 +225,17 @@ public static ArrayList customSidebar() {
return arrayList;
}

public static ArrayList customNavbar() {
ArrayList<String> arrayList = new ArrayList<String>();
try{
String key =Settings.CUSTOM_NAVBAR_TABS.key;
Set<String> ch = Utils.getSetPerf(key,null);
if(!ch.isEmpty()) {
arrayList = new ArrayList<String>(ch);
}
}catch (Exception e){}
return arrayList;
}

//end
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
package app.revanced.integrations.twitter.patches.customise;

import android.util.*;
import java.util.*;
import java.lang.reflect.Field;
import app.revanced.integrations.twitter.Pref;

public class NavBar {

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


public static List navBar(List inp){
try{
ArrayList choices = Pref.customNavbar();
List list2 = new ArrayList<>(inp);
Iterator itr = list2.iterator();

while (itr.hasNext()) {
Object obj = itr.next();
String itemStr = obj.toString();
if(choices.contains(itemStr)){
inp.remove(obj);
}
}

}catch (Exception e){
logger(e);
}
return inp;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,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_SIDEBAR_TABS = new StringSetting("customisation_sidebar_tabs", "");
public static final StringSetting CUSTOM_NAVBAR_TABS = new StringSetting("customisation_navbar_tabs", "");

public static final StringSetting EXPORT_PREF = new StringSetting("export_pref", "");
public static final StringSetting EXPORT_FLAGS = new StringSetting("export_flags", "");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ public void onCreate(@org.jetbrains.annotations.Nullable Bundle savedInstanceSta
flags.put("piko_pref_feature_flags",SettingsStatus.featureFlagsEnabled);
flags.put("piko_pref_customisation_profiletabs",SettingsStatus.profileTabCustomisation);
flags.put("piko_pref_customisation_timelinetabs",SettingsStatus.timelineTabCustomisation);
flags.put("piko_pref_customisation_navbartabs",SettingsStatus.navBarCustomisation);
flags.put("piko_pref_customisation_sidebartabs",SettingsStatus.sideBarCustomisation);
flags.put("piko_pref_disable_auto_timeline_scroll",SettingsStatus.disableAutoTimelineScroll);
flags.put("piko_pref_hide_live_threads",SettingsStatus.hideLiveThreads);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -305,6 +305,16 @@ public void onCreate(@Nullable Bundle savedInstanceState) {
)
);
}

if (SettingsStatus.navBarCustomisation) {
customisationPrefs.addPreference(
multiSelectListPreference(
strRes("piko_pref_customisation_navbartabs"),
"",
Settings.CUSTOM_NAVBAR_TABS
)
);
}
}

//Timeline Section
Expand Down Expand Up @@ -516,6 +526,9 @@ private Preference multiSelectListPreference(String title, String summary, Strin
}else if (key == Settings.CUSTOM_SIDEBAR_TABS.key) {
entries = Utils.getResourceStringArray("piko_array_sidebar");
entriesValues = new CharSequence[]{"Profile","TwitterBlueNonSubscriber", "Grok","DMs","Communities","Bookmarks","Lists","TopArticles","BirdwatchNotes","Spaces","PendingFollowers","Monetization","ProfessionalToolsGroup","MediaTransparency","Imprint"};
}else if (key == Settings.CUSTOM_NAVBAR_TABS.key) {
entries = Utils.getResourceStringArray("piko_array_navbar");
entriesValues = new CharSequence[]{"HOME","GUIDE", "SPACES","COMMUNITIES","NOTIFICATIONS","CONNECT","COMMUNITY_NOTES","BOOKMARKS","DMS","GROK","MEDIA_TAB"};
}
preference.setEntries(entries);
preference.setEntryValues(entriesValues);
Expand All @@ -538,7 +551,6 @@ public boolean onPreferenceClick(Preference preference) {
} else if (key.equals(Settings.PREMIUM_ICONS.key)) {
app.revanced.integrations.twitter.Utils.startAppIconNNavIconActivity();
} else if (key.equals(Settings.MISC_FEATURE_FLAGS.key)) {
// getFragmentManager().beginTransaction().replace(Utils.getResourceIdentifier("fragment_container", "id"), new FeatureFlagsFragment()).addToBackStack(null).commit();
startFragment(new FeatureFlagsFragment());
} else if (key.equals(Settings.EXPORT_PREF.key)) {
startBackupFragment(new BackupPrefFragment(), false);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ public class SettingsStatus {
public static boolean profileTabCustomisation = false;
public static boolean timelineTabCustomisation = false;
public static boolean sideBarCustomisation = false;
public static boolean navBarCustomisation = false;
public static boolean mediaLinkHandle = false;

public static boolean selectableText = false;
Expand Down Expand Up @@ -90,6 +91,7 @@ public class SettingsStatus {
public static void profileTabCustomisation() { profileTabCustomisation = true; }
public static void timelineTabCustomisation() { timelineTabCustomisation = true; }
public static void sideBarCustomisation() { sideBarCustomisation = true; }
public static void navBarCustomisation() { navBarCustomisation = true; }

public static boolean enableTimelineSection(){ return (disableAutoTimelineScroll || forceTranslate || hidePromoteButton || hideCommunityNote|| hideLiveThreads || hideBanner || hideInlineBmk || showPollResultsEnabled || hideImmersivePlayer); }
public static boolean enableMiscSection() { return (enableFontMod || hideRecommendedUsers || hideFAB || hideViewCount || customSharingDomainEnabled || hideFABBtns); }
Expand Down

0 comments on commit bde296f

Please sign in to comment.