Skip to content
This repository was archived by the owner on Dec 11, 2024. It is now read-only.

Commit

Permalink
feat(YouTube - Settings): Add category to main menu entries while sea…
Browse files Browse the repository at this point in the history
…rching
  • Loading branch information
anddea committed Sep 3, 2024
1 parent 90f91cd commit 120d894
Showing 1 changed file with 16 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@
import app.revanced.integrations.shared.settings.BooleanSetting;
import app.revanced.integrations.shared.settings.Setting;
import app.revanced.integrations.shared.utils.Logger;
import app.revanced.integrations.shared.utils.ResourceUtils;
import app.revanced.integrations.shared.utils.Utils;
import app.revanced.integrations.youtube.patches.video.CustomPlaybackSpeedPatch;
import app.revanced.integrations.youtube.utils.ExtendedUtils;
Expand Down Expand Up @@ -326,16 +327,29 @@ public void onDestroy() {
private void storeAllPreferences(PreferenceGroup preferenceGroup) {
Logger.printDebug(() -> "SearchFragmentPrefGroup: " + preferenceGroup);

// Check if this is the root PreferenceScreen
boolean isRootScreen = preferenceGroup == getPreferenceScreen();

// Use the special top-level group only for the root PreferenceScreen
PreferenceGroup groupKey = isRootScreen
? new PreferenceCategory(preferenceGroup.getContext())
: preferenceGroup;

if (isRootScreen) {
groupKey.setTitle(ResourceUtils.getString("revanced_extended_settings_title"));
}

// Initialize a list to hold preferences of the current group
List<Preference> currentGroupPreferences = groupedPreferences.computeIfAbsent(preferenceGroup, k -> new ArrayList<>());
List<Preference> currentGroupPreferences = groupedPreferences.computeIfAbsent(groupKey, k -> new ArrayList<>());

for (int i = 0; i < preferenceGroup.getPreferenceCount(); i++) {
Preference preference = preferenceGroup.getPreference(i);

// Add preference to the current group if not already added
if (!currentGroupPreferences.contains(preference)) {
currentGroupPreferences.add(preference);
Logger.printDebug(() -> "SearchFragment: Stored preference with key: " + preference.getKey());
Logger.printDebug(() -> "SearchFragment: Stored preference with key: " + preference.getKey() +
" in group: " + (isRootScreen ? "Top Level" : preferenceGroup.getTitle()));
}

// Store dependencies
Expand Down

0 comments on commit 120d894

Please sign in to comment.