diff --git a/extensions/shared/library/src/main/java/app/revanced/extension/shared/settings/search/BaseSearchViewController.java b/extensions/shared/library/src/main/java/app/revanced/extension/shared/settings/search/BaseSearchViewController.java index 814ae29c3..0a8df925b 100644 --- a/extensions/shared/library/src/main/java/app/revanced/extension/shared/settings/search/BaseSearchViewController.java +++ b/extensions/shared/library/src/main/java/app/revanced/extension/shared/settings/search/BaseSearchViewController.java @@ -5,12 +5,15 @@ import static app.revanced.extension.shared.Utils.getResourceIdentifierOrThrow; import android.app.Activity; import android.content.Context; +import android.graphics.Color; import android.graphics.drawable.GradientDrawable; +import android.os.Build; import android.preference.Preference; import android.preference.PreferenceCategory; import android.preference.PreferenceGroup; import android.preference.PreferenceScreen; import android.text.TextUtils; +import android.util.TypedValue; import android.view.Gravity; import android.view.View; import android.view.WindowManager; @@ -23,6 +26,7 @@ import android.widget.SearchView; import android.widget.Toolbar; import androidx.annotation.ColorInt; +import androidx.annotation.RequiresApi; import java.util.ArrayList; import java.util.Collections; @@ -118,6 +122,14 @@ public abstract class BaseSearchViewController { searchView.setBackground(createBackgroundDrawable()); searchView.setQueryHint(str("revanced_settings_search_hint")); + // Set text size. + searchEditText.setTextSize(TypedValue.COMPLEX_UNIT_SP, 16); + + // Set cursor color. + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q) { + setCursorColor(searchEditText); + } + // Configure RTL support based on app language. AppLanguage appLanguage = BaseSettings.REVANCED_LANGUAGE.get(); if (Utils.isRightToLeftLocale(appLanguage.getLocale())) { @@ -126,6 +138,24 @@ public abstract class BaseSearchViewController { } } + /** + * Sets the cursor color (for Android 10+ devices). + */ + @RequiresApi(api = Build.VERSION_CODES.Q) + private void setCursorColor(EditText editText) { + // Get the cursor color based on the current theme. + final int cursorColor = Utils.isDarkModeEnabled() ? Color.WHITE : Color.BLACK; + + // Create cursor drawable. + GradientDrawable cursorDrawable = new GradientDrawable(); + cursorDrawable.setShape(GradientDrawable.RECTANGLE); + cursorDrawable.setSize(Utils.dipToPixels(2), -1); // Width: 2dp, Height: match text height. + cursorDrawable.setColor(cursorColor); + + // Set cursor drawable. + editText.setTextCursorDrawable(cursorDrawable); + } + /** * Initializes the overlay container for displaying search results and history. */ diff --git a/patches/src/main/kotlin/app/revanced/patches/music/misc/settings/SettingsPatch.kt b/patches/src/main/kotlin/app/revanced/patches/music/misc/settings/SettingsPatch.kt index 2a8ac5db4..9108d56b2 100644 --- a/patches/src/main/kotlin/app/revanced/patches/music/misc/settings/SettingsPatch.kt +++ b/patches/src/main/kotlin/app/revanced/patches/music/misc/settings/SettingsPatch.kt @@ -42,6 +42,8 @@ private val settingsResourcePatch = resourcePatch { execute { + // Set the style for the ReVanced settings to follow the style of the music settings, + // namely: action bar height, menu item padding and remove horizontal dividers. val targetResource = "values/styles.xml" inputStreamFromBundledResource( "settings/music", @@ -53,7 +55,7 @@ private val settingsResourcePatch = resourcePatch { ).close() } - // Remove horizontal divider from the settings Preferences. + // Remove horizontal dividers from the music settings. val styleFile = get("res/values/styles.xml") styleFile.writeText( styleFile.readText() diff --git a/patches/src/main/kotlin/app/revanced/patches/shared/misc/settings/SettingsPatch.kt b/patches/src/main/kotlin/app/revanced/patches/shared/misc/settings/SettingsPatch.kt index 4bf870175..b2800bf4a 100644 --- a/patches/src/main/kotlin/app/revanced/patches/shared/misc/settings/SettingsPatch.kt +++ b/patches/src/main/kotlin/app/revanced/patches/shared/misc/settings/SettingsPatch.kt @@ -18,7 +18,9 @@ import app.revanced.util.returnEarly import org.w3c.dom.Node // TODO: Delete this on next major version bump. -@Deprecated("Use non deprecated settings patch function") +@Deprecated("Use non deprecated settings patch function", + ReplaceWith("settingsPatch(listOf(rootPreference), preferences)") +) fun settingsPatch ( rootPreference: Pair, preferences: Set, @@ -69,8 +71,8 @@ fun settingsPatch ( ResourceGroup("drawable", // CustomListPreference resources. "revanced_ic_dialog_alert.xml", + // Search resources. "revanced_settings_arrow_time.xml", - "revanced_settings_cursor.xml", "revanced_settings_custom_checkmark.xml", "revanced_settings_search_icon.xml", "revanced_settings_search_remove.xml", diff --git a/patches/src/main/kotlin/app/revanced/patches/youtube/misc/settings/SettingsPatch.kt b/patches/src/main/kotlin/app/revanced/patches/youtube/misc/settings/SettingsPatch.kt index 04135c995..735d7df99 100644 --- a/patches/src/main/kotlin/app/revanced/patches/youtube/misc/settings/SettingsPatch.kt +++ b/patches/src/main/kotlin/app/revanced/patches/youtube/misc/settings/SettingsPatch.kt @@ -95,20 +95,6 @@ private val settingsResourcePatch = resourcePatch { ) ) - // Copy style properties used to fix over-sized copy menu that appear in EditTextPreference. - // For a full explanation of how this fixes the issue, see the comments in this style file - // and the comments in the extension code. - val targetResource = "values/styles.xml" - inputStreamFromBundledResource( - "settings/youtube", - targetResource, - )!!.let { inputStream -> - "resources".copyXmlNode( - document(inputStream), - document("res/$targetResource"), - ).close() - } - // Remove horizontal divider from the settings Preferences // To better match the appearance of the stock YouTube settings. document("res/values/styles.xml").use { document -> diff --git a/patches/src/main/resources/settings/drawable/revanced_settings_cursor.xml b/patches/src/main/resources/settings/drawable/revanced_settings_cursor.xml deleted file mode 100644 index b1c03e954..000000000 --- a/patches/src/main/resources/settings/drawable/revanced_settings_cursor.xml +++ /dev/null @@ -1,7 +0,0 @@ - - - - - \ No newline at end of file diff --git a/patches/src/main/resources/settings/layout/revanced_settings_with_toolbar.xml b/patches/src/main/resources/settings/layout/revanced_settings_with_toolbar.xml index 948093312..ec5532c1f 100644 --- a/patches/src/main/resources/settings/layout/revanced_settings_with_toolbar.xml +++ b/patches/src/main/resources/settings/layout/revanced_settings_with_toolbar.xml @@ -46,7 +46,6 @@ android:iconifiedByDefault="false" android:searchIcon="@null" android:queryBackground="@null" - android:theme="@style/revanced_searchbar_cursor" android:padding="2dp" /> diff --git a/patches/src/main/resources/settings/music/values/styles.xml b/patches/src/main/resources/settings/music/values/styles.xml index 663f9c373..8000140ed 100644 --- a/patches/src/main/resources/settings/music/values/styles.xml +++ b/patches/src/main/resources/settings/music/values/styles.xml @@ -5,8 +5,4 @@ @dimen/item_extra_extra_large_spacing @null - diff --git a/patches/src/main/resources/settings/youtube/values/styles.xml b/patches/src/main/resources/settings/youtube/values/styles.xml deleted file mode 100644 index d2188fb43..000000000 --- a/patches/src/main/resources/settings/youtube/values/styles.xml +++ /dev/null @@ -1,7 +0,0 @@ - - - -