Skip to content

Commit

Permalink
fix(YouTube - Searchbar): Hide searchbar in RYD and Sponsorblock sect…
Browse files Browse the repository at this point in the history
…ions (anddea#13)
  • Loading branch information
Francesco146 authored May 21, 2024
1 parent 9592bd5 commit ed60bea
Show file tree
Hide file tree
Showing 2 changed files with 55 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
import android.preference.PreferenceManager;
import android.preference.PreferenceScreen;
import android.preference.SwitchPreference;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;
import android.widget.Toolbar;
Expand All @@ -29,6 +30,7 @@
import app.revanced.integrations.youtube.settings.Settings;

/** @noinspection deprecation*/
@SuppressWarnings("deprecation")
public class ReturnYouTubeDislikePreferenceFragment extends PreferenceFragment {

/**
Expand Down Expand Up @@ -163,6 +165,12 @@ public void onCreate(Bundle savedInstanceState) {
return false;
});
aboutCategory.addPreference(aboutWebsitePreference);

// remove the search bar
View searchBar = getActivity().findViewById(getIdIdentifier("search_view"));
if (searchBar != null) {
searchBar.setVisibility(View.GONE);
}
} catch (Exception ex) {
Logger.printException(() -> "onCreate failure", ex);
}
Expand All @@ -177,4 +185,23 @@ public void onDetach() {
toolbarTextView.setText(ResourceUtils.getString("revanced_extended_settings_title"));
}

@Override
public void onResume() {
super.onResume();
// Hide the search bar
View searchBar = getActivity().findViewById(getIdIdentifier("search_view"));
if (searchBar != null) {
searchBar.setVisibility(View.GONE);
}
}

@Override
public void onPause() {
super.onPause();
// Show the search bar
View searchBar = getActivity().findViewById(getIdIdentifier("search_view"));
if (searchBar != null) {
searchBar.setVisibility(View.VISIBLE);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
import android.text.Html;
import android.text.InputType;
import android.util.TypedValue;
import android.view.View;
import android.view.ViewGroup;
import android.widget.EditText;
import android.widget.TextView;
Expand All @@ -35,6 +36,7 @@

import java.util.Objects;

import app.revanced.integrations.R;
import app.revanced.integrations.shared.settings.Setting;
import app.revanced.integrations.shared.settings.preference.ResettableEditTextPreference;
import app.revanced.integrations.shared.utils.Logger;
Expand Down Expand Up @@ -177,11 +179,37 @@ public void onCreate(Bundle savedInstanceState) {
addAboutCategory(context, preferenceScreen);

updateUI();

// remove the search bar
View searchBar = getActivity().findViewById(getIdIdentifier("search_view"));
if (searchBar != null) {
searchBar.setVisibility(View.GONE);
}
} catch (Exception ex) {
Logger.printException(() -> "onCreate failure", ex);
}
}

@Override
public void onResume() {
super.onResume();
// Hide the search bar
View searchBar = getActivity().findViewById(getIdIdentifier("search_view"));
if (searchBar != null) {
searchBar.setVisibility(View.GONE);
}
}

@Override
public void onPause() {
super.onPause();
// Show the search bar
View searchBar = getActivity().findViewById(getIdIdentifier("search_view"));
if (searchBar != null) {
searchBar.setVisibility(View.VISIBLE);
}
}

@Override
public void onDetach() {
super.onDetach();
Expand Down

0 comments on commit ed60bea

Please sign in to comment.