Skip to content

Commit 8c22995

Browse files
authored
fix(Twitch - Settings): Fix missing style resources (#5970)
1 parent c5eb88b commit 8c22995

File tree

8 files changed

+37
-36
lines changed

8 files changed

+37
-36
lines changed

extensions/shared/library/src/main/java/app/revanced/extension/shared/settings/search/BaseSearchViewController.java

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,15 @@
55

66
import android.app.Activity;
77
import android.content.Context;
8+
import android.graphics.Color;
89
import android.graphics.drawable.GradientDrawable;
10+
import android.os.Build;
911
import android.preference.Preference;
1012
import android.preference.PreferenceCategory;
1113
import android.preference.PreferenceGroup;
1214
import android.preference.PreferenceScreen;
1315
import android.text.TextUtils;
16+
import android.util.TypedValue;
1417
import android.view.Gravity;
1518
import android.view.View;
1619
import android.view.WindowManager;
@@ -23,6 +26,7 @@
2326
import android.widget.Toolbar;
2427

2528
import androidx.annotation.ColorInt;
29+
import androidx.annotation.RequiresApi;
2630

2731
import java.util.ArrayList;
2832
import java.util.Collections;
@@ -118,6 +122,14 @@ private void initializeSearchView() {
118122
searchView.setBackground(createBackgroundDrawable());
119123
searchView.setQueryHint(str("revanced_settings_search_hint"));
120124

125+
// Set text size.
126+
searchEditText.setTextSize(TypedValue.COMPLEX_UNIT_SP, 16);
127+
128+
// Set cursor color.
129+
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q) {
130+
setCursorColor(searchEditText);
131+
}
132+
121133
// Configure RTL support based on app language.
122134
AppLanguage appLanguage = BaseSettings.REVANCED_LANGUAGE.get();
123135
if (Utils.isRightToLeftLocale(appLanguage.getLocale())) {
@@ -126,6 +138,24 @@ private void initializeSearchView() {
126138
}
127139
}
128140

141+
/**
142+
* Sets the cursor color (for Android 10+ devices).
143+
*/
144+
@RequiresApi(api = Build.VERSION_CODES.Q)
145+
private void setCursorColor(EditText editText) {
146+
// Get the cursor color based on the current theme.
147+
final int cursorColor = Utils.isDarkModeEnabled() ? Color.WHITE : Color.BLACK;
148+
149+
// Create cursor drawable.
150+
GradientDrawable cursorDrawable = new GradientDrawable();
151+
cursorDrawable.setShape(GradientDrawable.RECTANGLE);
152+
cursorDrawable.setSize(Utils.dipToPixels(2), -1); // Width: 2dp, Height: match text height.
153+
cursorDrawable.setColor(cursorColor);
154+
155+
// Set cursor drawable.
156+
editText.setTextCursorDrawable(cursorDrawable);
157+
}
158+
129159
/**
130160
* Initializes the overlay container for displaying search results and history.
131161
*/

patches/src/main/kotlin/app/revanced/patches/music/misc/settings/SettingsPatch.kt

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,8 @@ private val settingsResourcePatch = resourcePatch {
4242

4343
execute {
4444

45+
// Set the style for the ReVanced settings to follow the style of the music settings,
46+
// namely: action bar height, menu item padding and remove horizontal dividers.
4547
val targetResource = "values/styles.xml"
4648
inputStreamFromBundledResource(
4749
"settings/music",
@@ -53,7 +55,7 @@ private val settingsResourcePatch = resourcePatch {
5355
).close()
5456
}
5557

56-
// Remove horizontal divider from the settings Preferences.
58+
// Remove horizontal dividers from the music settings.
5759
val styleFile = get("res/values/styles.xml")
5860
styleFile.writeText(
5961
styleFile.readText()

patches/src/main/kotlin/app/revanced/patches/shared/misc/settings/SettingsPatch.kt

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,9 @@ import app.revanced.util.returnEarly
1818
import org.w3c.dom.Node
1919

2020
// TODO: Delete this on next major version bump.
21-
@Deprecated("Use non deprecated settings patch function")
21+
@Deprecated("Use non deprecated settings patch function",
22+
ReplaceWith("settingsPatch(listOf(rootPreference), preferences)")
23+
)
2224
fun settingsPatch (
2325
rootPreference: Pair<IntentPreference, String>,
2426
preferences: Set<BasePreference>,
@@ -69,8 +71,8 @@ fun settingsPatch (
6971
ResourceGroup("drawable",
7072
// CustomListPreference resources.
7173
"revanced_ic_dialog_alert.xml",
74+
// Search resources.
7275
"revanced_settings_arrow_time.xml",
73-
"revanced_settings_cursor.xml",
7476
"revanced_settings_custom_checkmark.xml",
7577
"revanced_settings_search_icon.xml",
7678
"revanced_settings_search_remove.xml",

patches/src/main/kotlin/app/revanced/patches/youtube/misc/settings/SettingsPatch.kt

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -95,20 +95,6 @@ private val settingsResourcePatch = resourcePatch {
9595
)
9696
)
9797

98-
// Copy style properties used to fix over-sized copy menu that appear in EditTextPreference.
99-
// For a full explanation of how this fixes the issue, see the comments in this style file
100-
// and the comments in the extension code.
101-
val targetResource = "values/styles.xml"
102-
inputStreamFromBundledResource(
103-
"settings/youtube",
104-
targetResource,
105-
)!!.let { inputStream ->
106-
"resources".copyXmlNode(
107-
document(inputStream),
108-
document("res/$targetResource"),
109-
).close()
110-
}
111-
11298
// Remove horizontal divider from the settings Preferences
11399
// To better match the appearance of the stock YouTube settings.
114100
document("res/values/styles.xml").use { document ->

patches/src/main/resources/settings/drawable/revanced_settings_cursor.xml

Lines changed: 0 additions & 7 deletions
This file was deleted.

patches/src/main/resources/settings/layout/revanced_settings_with_toolbar.xml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,6 @@
4646
android:iconifiedByDefault="false"
4747
android:searchIcon="@null"
4848
android:queryBackground="@null"
49-
android:theme="@style/revanced_searchbar_cursor"
5049
android:padding="2dp" />
5150

5251
</FrameLayout>

patches/src/main/resources/settings/music/values/styles.xml

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,4 @@
55
<item name="android:listPreferredItemPaddingStart">@dimen/item_extra_extra_large_spacing</item>
66
<item name="android:listDivider">@null</item>
77
</style>
8-
<style name="revanced_searchbar_cursor">
9-
<item name="android:textCursorDrawable">@drawable/revanced_settings_cursor</item>
10-
<item name="android:textSize">16sp</item>
11-
</style>
128
</resources>

patches/src/main/resources/settings/youtube/values/styles.xml

Lines changed: 0 additions & 7 deletions
This file was deleted.

0 commit comments

Comments
 (0)