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

Commit

Permalink
feat(YouTube - Searchbar): Add RVXSettingsMenuName in the searchbar hint
Browse files Browse the repository at this point in the history
  • Loading branch information
Francesco146 committed Jun 29, 2024
1 parent c43f623 commit b1a1dd9
Showing 1 changed file with 36 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@
import java.lang.ref.WeakReference;
import java.util.Objects;

import static app.revanced.integrations.shared.utils.StringRef.str;

@SuppressWarnings("deprecation")
public class VideoQualitySettingsActivity extends Activity {

Expand Down Expand Up @@ -76,9 +78,24 @@ protected void onCreate(Bundle bundle) {
.commit();

// Set search view

SearchView searchView = findViewById(ResourceUtils.getIdIdentifier("search_view"));

// region compose search hint

String revancedSettingsName = str("revanced_extended_settings_title");
String searchHint = str("revanced_extended_settings_search_title");

// if the translation is missing the %s, then it
// will use the default search hint for that language
String finalSearchHint = String.format(searchHint, revancedSettingsName);

searchView.setQueryHint(finalSearchHint);

// endregion

// region SearchView dimensions

// Get the current layout parameters of the SearchView
ViewGroup.MarginLayoutParams layoutParams = (ViewGroup.MarginLayoutParams) searchView.getLayoutParams();

Expand Down Expand Up @@ -118,14 +135,29 @@ protected void onCreate(Bundle bundle) {
shape.setCornerRadius(30 * getResources().getDisplayMetrics().density);
searchView.setBackground(shape);

/*
* in order to match the original app's search bar, we'd need to change the searchbar cursor color
* to white (#FFFFFF) if ThemeUtils.isDarkTheme(), and black (#000000) if not.
/* TODO:
in order to match the original app's search bar, we'd need to change the searchbar cursor color
to white (#FFFFFF) if ThemeUtils.isDarkTheme(), and black (#000000) if not.
Currently it's always blue.
*/

// endregion

searchView.setPadding(20, 15, 20, 15);
int leftPaddingDp = 5;
int topPaddingDp = 5;
int rightPaddingDp = 5;
int bottomPaddingDp = 5;

int leftPaddingPx = (int) TypedValue.applyDimension(
TypedValue.COMPLEX_UNIT_DIP, leftPaddingDp, getResources().getDisplayMetrics());
int topPaddingPx = (int) TypedValue.applyDimension(
TypedValue.COMPLEX_UNIT_DIP, topPaddingDp, getResources().getDisplayMetrics());
int rightPaddingPx = (int) TypedValue.applyDimension(
TypedValue.COMPLEX_UNIT_DIP, rightPaddingDp, getResources().getDisplayMetrics());
int bottomPaddingPx = (int) TypedValue.applyDimension(
TypedValue.COMPLEX_UNIT_DIP, bottomPaddingDp, getResources().getDisplayMetrics());

searchView.setPadding(leftPaddingPx, topPaddingPx, rightPaddingPx, bottomPaddingPx);

searchView.setOnQueryTextListener(onQueryTextListener);
searchViewRef = new WeakReference<>(searchView);
Expand Down

0 comments on commit b1a1dd9

Please sign in to comment.