mirror of
https://github.com/ReVanced/revanced-patches.git
synced 2026-01-28 21:21:02 +00:00
fix(YouTube - Settings): Use an overlay to show search results (#5806)
Co-authored-by: LisoUseInAIKyrios <118716522+LisoUseInAIKyrios@users.noreply.github.com>
This commit is contained in:
@@ -1,11 +1,16 @@
|
||||
package app.revanced.extension.twitch.settings;
|
||||
|
||||
import static app.revanced.extension.twitch.Utils.getStringId;
|
||||
|
||||
import android.content.Intent;
|
||||
import android.os.Bundle;
|
||||
import androidx.appcompat.app.ActionBar;
|
||||
import androidx.appcompat.app.AppCompatActivity;
|
||||
|
||||
import app.revanced.extension.shared.Logger;
|
||||
import app.revanced.extension.shared.Utils;
|
||||
import app.revanced.extension.twitch.settings.preference.ReVancedPreferenceFragment;
|
||||
import app.revanced.extension.twitch.settings.preference.TwitchPreferenceFragment;
|
||||
|
||||
import tv.twitch.android.feature.settings.menu.SettingsMenuGroup;
|
||||
import tv.twitch.android.settings.SettingsActivity;
|
||||
|
||||
@@ -13,17 +18,15 @@ import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Hooks AppCompatActivity.
|
||||
* <p>
|
||||
* This class is responsible for injecting our own fragment by replacing the AppCompatActivity.
|
||||
* @noinspection unused
|
||||
* Hooks AppCompatActivity to inject a custom {@link TwitchPreferenceFragment}.
|
||||
*/
|
||||
public class AppCompatActivityHook {
|
||||
@SuppressWarnings({"deprecation", "NewApi", "unused"})
|
||||
public class TwitchActivityHook {
|
||||
private static final int REVANCED_SETTINGS_MENU_ITEM_ID = 0x7;
|
||||
private static final String EXTRA_REVANCED_SETTINGS = "app.revanced.twitch.settings";
|
||||
|
||||
/**
|
||||
* Launches SettingsActivity and show ReVanced settings
|
||||
* Launches SettingsActivity and show ReVanced settings.
|
||||
*/
|
||||
public static void startSettingsActivity() {
|
||||
Logger.printDebug(() -> "Launching ReVanced settings");
|
||||
@@ -41,27 +44,27 @@ public class AppCompatActivityHook {
|
||||
}
|
||||
|
||||
/**
|
||||
* Helper for easy access in smali
|
||||
* @return Returns string resource id
|
||||
* Helper for easy access in smali.
|
||||
* @return Returns string resource id.
|
||||
*/
|
||||
public static int getReVancedSettingsString() {
|
||||
return app.revanced.extension.twitch.Utils.getStringId("revanced_settings");
|
||||
return getStringId("revanced_settings");
|
||||
}
|
||||
|
||||
/**
|
||||
* Intercepts settings menu group list creation in SettingsMenuPresenter$Event.MenuGroupsUpdated
|
||||
* @return Returns a modified list of menu groups
|
||||
* Intercepts settings menu group list creation in SettingsMenuPresenter$Event.MenuGroupsUpdated.
|
||||
* @return Returns a modified list of menu groups.
|
||||
*/
|
||||
public static List<SettingsMenuGroup> handleSettingMenuCreation(List<SettingsMenuGroup> settingGroups, Object revancedEntry) {
|
||||
List<SettingsMenuGroup> groups = new ArrayList<>(settingGroups);
|
||||
|
||||
if (groups.isEmpty()) {
|
||||
// Create new menu group if none exist yet
|
||||
// Create new menu group if none exist yet.
|
||||
List<Object> items = new ArrayList<>();
|
||||
items.add(revancedEntry);
|
||||
groups.add(new SettingsMenuGroup(items));
|
||||
} else {
|
||||
// Add to last menu group
|
||||
// Add to last menu group.
|
||||
int groupIdx = groups.size() - 1;
|
||||
List<Object> items = new ArrayList<>(groups.remove(groupIdx).getSettingsMenuItems());
|
||||
items.add(revancedEntry);
|
||||
@@ -73,8 +76,8 @@ public class AppCompatActivityHook {
|
||||
}
|
||||
|
||||
/**
|
||||
* Intercepts settings menu group onclick events
|
||||
* @return Returns true if handled, otherwise false
|
||||
* Intercepts settings menu group onclick events.
|
||||
* @return Returns true if handled, otherwise false.
|
||||
*/
|
||||
@SuppressWarnings("rawtypes")
|
||||
public static boolean handleSettingMenuOnClick(Enum item) {
|
||||
@@ -88,20 +91,20 @@ public class AppCompatActivityHook {
|
||||
}
|
||||
|
||||
/**
|
||||
* Intercepts fragment loading in SettingsActivity.onCreate
|
||||
* @return Returns true if the revanced settings have been requested by the user, otherwise false
|
||||
* Intercepts fragment loading in SettingsActivity.onCreate.
|
||||
* @return Returns true if the ReVanced settings have been requested by the user, otherwise false.
|
||||
*/
|
||||
public static boolean handleSettingsCreation(androidx.appcompat.app.AppCompatActivity base) {
|
||||
public static boolean handleSettingsCreation(AppCompatActivity base) {
|
||||
if (!base.getIntent().getBooleanExtra(EXTRA_REVANCED_SETTINGS, false)) {
|
||||
Logger.printDebug(() -> "Revanced settings not requested");
|
||||
return false; // User wants to enter another settings fragment
|
||||
return false; // User wants to enter another settings fragment.
|
||||
}
|
||||
Logger.printDebug(() -> "ReVanced settings requested");
|
||||
|
||||
ReVancedPreferenceFragment fragment = new ReVancedPreferenceFragment();
|
||||
TwitchPreferenceFragment fragment = new TwitchPreferenceFragment();
|
||||
ActionBar supportActionBar = base.getSupportActionBar();
|
||||
if (supportActionBar != null)
|
||||
supportActionBar.setTitle(app.revanced.extension.twitch.Utils.getStringId("revanced_settings"));
|
||||
supportActionBar.setTitle(getStringId("revanced_settings"));
|
||||
|
||||
base.getFragmentManager()
|
||||
.beginTransaction()
|
||||
@@ -7,6 +7,7 @@ import android.util.AttributeSet;
|
||||
import android.view.View;
|
||||
import android.widget.TextView;
|
||||
|
||||
@SuppressWarnings({"deprecation", "unused"})
|
||||
public class CustomPreferenceCategory extends PreferenceCategory {
|
||||
public CustomPreferenceCategory(Context context, AttributeSet attrs) {
|
||||
super(context, attrs);
|
||||
|
||||
@@ -5,9 +5,9 @@ import app.revanced.extension.shared.settings.preference.AbstractPreferenceFragm
|
||||
import app.revanced.extension.twitch.settings.Settings;
|
||||
|
||||
/**
|
||||
* Preference fragment for ReVanced settings
|
||||
* Preference fragment for ReVanced settings.
|
||||
*/
|
||||
public class ReVancedPreferenceFragment extends AbstractPreferenceFragment {
|
||||
public class TwitchPreferenceFragment extends AbstractPreferenceFragment {
|
||||
|
||||
@Override
|
||||
protected void initialize() {
|
||||
Reference in New Issue
Block a user