-
Notifications
You must be signed in to change notification settings - Fork 16
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(YouTube & YouTube Music - Hide settings menu): Add switch prefere…
…nces for each setting entry
- Loading branch information
Showing
10 changed files
with
151 additions
and
70 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
41 changes: 41 additions & 0 deletions
41
app/src/main/java/app/revanced/integrations/music/patches/general/SettingsMenuPatch.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
package app.revanced.integrations.music.patches.general; | ||
|
||
import androidx.preference.PreferenceScreen; | ||
|
||
import app.revanced.integrations.music.settings.Settings; | ||
import app.revanced.integrations.shared.patches.BaseSettingsMenuPatch; | ||
|
||
@SuppressWarnings("unused") | ||
public final class SettingsMenuPatch extends BaseSettingsMenuPatch { | ||
|
||
public static void hideSettingsMenu(PreferenceScreen mPreferenceScreen) { | ||
if (mPreferenceScreen == null) return; | ||
for (SettingsMenuComponent component : SettingsMenuComponent.values()) | ||
if (component.enabled) | ||
removePreference(mPreferenceScreen, component.key); | ||
} | ||
|
||
public static boolean hideParentToolsMenu(boolean original) { | ||
return !Settings.HIDE_SETTINGS_MENU_PARENT_TOOLS.get() && original; | ||
} | ||
|
||
private enum SettingsMenuComponent { | ||
GENERAL("settings_header_general", Settings.HIDE_SETTINGS_MENU_GENERAL.get()), | ||
PLAYBACK("settings_header_playback", Settings.HIDE_SETTINGS_MENU_PLAYBACK.get()), | ||
DATA_SAVING("settings_header_data_saving", Settings.HIDE_SETTINGS_MENU_DATA_SAVING.get()), | ||
DOWNLOADS_AND_STORAGE("settings_header_downloads_and_storage", Settings.HIDE_SETTINGS_MENU_DOWNLOADS_AND_STORAGE.get()), | ||
NOTIFICATIONS("settings_header_notifications", Settings.HIDE_SETTINGS_MENU_NOTIFICATIONS.get()), | ||
PRIVACY_AND_LOCATION("settings_header_privacy_and_location", Settings.HIDE_SETTINGS_MENU_PRIVACY_AND_LOCATION.get()), | ||
RECOMMENDATIONS("settings_header_recommendations", Settings.HIDE_SETTINGS_MENU_RECOMMENDATIONS.get()), | ||
PAID_MEMBERSHIPS("settings_header_paid_memberships", Settings.HIDE_SETTINGS_MENU_PAID_MEMBERSHIPS.get()), | ||
ABOUT("settings_header_about_youtube_music", Settings.HIDE_SETTINGS_MENU_ABOUT.get()); | ||
|
||
private final String key; | ||
private final boolean enabled; | ||
|
||
SettingsMenuComponent(String key, boolean enabled) { | ||
this.key = key; | ||
this.enabled = enabled; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
16 changes: 16 additions & 0 deletions
16
app/src/main/java/app/revanced/integrations/shared/patches/BaseSettingsMenuPatch.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
package app.revanced.integrations.shared.patches; | ||
|
||
import android.util.Log; | ||
|
||
import androidx.preference.PreferenceScreen; | ||
|
||
@SuppressWarnings("unused") | ||
public class BaseSettingsMenuPatch { | ||
|
||
/** | ||
* Rest of the implementation added by patch. | ||
*/ | ||
public static void removePreference(PreferenceScreen mPreferenceScreen, String key) { | ||
Log.d("Extended: SettingsMenuPatch", "key: " + key); | ||
} | ||
} |
63 changes: 0 additions & 63 deletions
63
app/src/main/java/app/revanced/integrations/shared/patches/SettingsMenuPatch.java
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
52 changes: 52 additions & 0 deletions
52
app/src/main/java/app/revanced/integrations/youtube/patches/general/SettingsMenuPatch.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
package app.revanced.integrations.youtube.patches.general; | ||
|
||
import androidx.preference.PreferenceScreen; | ||
|
||
import app.revanced.integrations.shared.patches.BaseSettingsMenuPatch; | ||
import app.revanced.integrations.youtube.settings.Settings; | ||
|
||
@SuppressWarnings("unused") | ||
public final class SettingsMenuPatch extends BaseSettingsMenuPatch { | ||
|
||
public static void hideSettingsMenu(PreferenceScreen mPreferenceScreen) { | ||
if (mPreferenceScreen == null) return; | ||
for (SettingsMenuComponent component : SettingsMenuComponent.values()) | ||
if (component.enabled) | ||
removePreference(mPreferenceScreen, component.key); | ||
} | ||
|
||
private enum SettingsMenuComponent { | ||
YOUTUBE_TV("yt_unplugged_pref_key", Settings.HIDE_SETTINGS_MENU_YOUTUBE_TV.get()), | ||
PARENT_TOOLS("parent_tools_key", Settings.HIDE_SETTINGS_MENU_PARENT_TOOLS.get()), | ||
PRE_PURCHASE("yt_unlimited_pre_purchase_key", Settings.HIDE_SETTINGS_MENU_PRE_PURCHASE.get()), | ||
GENERAL("general_key", Settings.HIDE_SETTINGS_MENU_GENERAL.get()), | ||
ACCOUNT("account_switcher_key", Settings.HIDE_SETTINGS_MENU_ACCOUNT.get()), | ||
DATA_SAVING("data_saving_settings_key", Settings.HIDE_SETTINGS_MENU_DATA_SAVING.get()), | ||
AUTOPLAY("auto_play_key", Settings.HIDE_SETTINGS_MENU_AUTOPLAY.get()), | ||
VIDEO_QUALITY_PREFERENCES("video_quality_settings_key", Settings.HIDE_SETTINGS_MENU_VIDEO_QUALITY_PREFERENCES.get()), | ||
POST_PURCHASE("yt_unlimited_post_purchase_key", Settings.HIDE_SETTINGS_MENU_POST_PURCHASE.get()), | ||
OFFLINE("offline_key", Settings.HIDE_SETTINGS_MENU_OFFLINE.get()), | ||
WATCH_ON_TV("pair_with_tv_key", Settings.HIDE_SETTINGS_MENU_WATCH_ON_TV.get()), | ||
MANAGE_ALL_HISTORY("history_key", Settings.HIDE_SETTINGS_MENU_MANAGE_ALL_HISTORY.get()), | ||
YOUR_DATA_IN_YOUTUBE("your_data_key", Settings.HIDE_SETTINGS_MENU_YOUR_DATA_IN_YOUTUBE.get()), | ||
PRIVACY("privacy_key", Settings.HIDE_SETTINGS_MENU_PRIVACY.get()), | ||
TRY_EXPERIMENTAL_NEW_FEATURES("premium_early_access_browse_page_key", Settings.HIDE_SETTINGS_MENU_TRY_EXPERIMENTAL_NEW_FEATURES.get()), | ||
PURCHASES_AND_MEMBERSHIPS("subscription_product_setting_key", Settings.HIDE_SETTINGS_MENU_PURCHASES_AND_MEMBERSHIPS.get()), | ||
BILLING_AND_PAYMENTS("billing_and_payment_key", Settings.HIDE_SETTINGS_MENU_BILLING_AND_PAYMENTS.get()), | ||
NOTIFICATIONS("notification_key", Settings.HIDE_SETTINGS_MENU_NOTIFICATIONS.get()), | ||
THIRD_PARTY("third_party_key", Settings.HIDE_SETTINGS_MENU_THIRD_PARTY.get()), | ||
CONNECTED_APPS("connected_accounts_browse_page_key", Settings.HIDE_SETTINGS_MENU_CONNECTED_APPS.get()), | ||
LIVE_CHAT("live_chat_key", Settings.HIDE_SETTINGS_MENU_LIVE_CHAT.get()), | ||
CAPTIONS("captions_key", Settings.HIDE_SETTINGS_MENU_CAPTIONS.get()), | ||
ACCESSIBILITY("accessibility_settings_key", Settings.HIDE_SETTINGS_MENU_ACCESSIBILITY.get()), | ||
ABOUT("about_key", Settings.HIDE_SETTINGS_MENU_ABOUT.get()); | ||
|
||
private final String key; | ||
private final boolean enabled; | ||
|
||
SettingsMenuComponent(String key, boolean enabled) { | ||
this.key = key; | ||
this.enabled = enabled; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters