mirror of
https://github.com/revanced/revanced-patches.git
synced 2025-12-11 20:03:55 +01:00
fix(Twitch - Settings): Fix missing style resources (#5970)
This commit is contained in:
@@ -5,12 +5,15 @@ import static app.revanced.extension.shared.Utils.getResourceIdentifierOrThrow;
|
|||||||
|
|
||||||
import android.app.Activity;
|
import android.app.Activity;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
|
import android.graphics.Color;
|
||||||
import android.graphics.drawable.GradientDrawable;
|
import android.graphics.drawable.GradientDrawable;
|
||||||
|
import android.os.Build;
|
||||||
import android.preference.Preference;
|
import android.preference.Preference;
|
||||||
import android.preference.PreferenceCategory;
|
import android.preference.PreferenceCategory;
|
||||||
import android.preference.PreferenceGroup;
|
import android.preference.PreferenceGroup;
|
||||||
import android.preference.PreferenceScreen;
|
import android.preference.PreferenceScreen;
|
||||||
import android.text.TextUtils;
|
import android.text.TextUtils;
|
||||||
|
import android.util.TypedValue;
|
||||||
import android.view.Gravity;
|
import android.view.Gravity;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.view.WindowManager;
|
import android.view.WindowManager;
|
||||||
@@ -23,6 +26,7 @@ import android.widget.SearchView;
|
|||||||
import android.widget.Toolbar;
|
import android.widget.Toolbar;
|
||||||
|
|
||||||
import androidx.annotation.ColorInt;
|
import androidx.annotation.ColorInt;
|
||||||
|
import androidx.annotation.RequiresApi;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
@@ -118,6 +122,14 @@ public abstract class BaseSearchViewController {
|
|||||||
searchView.setBackground(createBackgroundDrawable());
|
searchView.setBackground(createBackgroundDrawable());
|
||||||
searchView.setQueryHint(str("revanced_settings_search_hint"));
|
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.
|
// Configure RTL support based on app language.
|
||||||
AppLanguage appLanguage = BaseSettings.REVANCED_LANGUAGE.get();
|
AppLanguage appLanguage = BaseSettings.REVANCED_LANGUAGE.get();
|
||||||
if (Utils.isRightToLeftLocale(appLanguage.getLocale())) {
|
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.
|
* Initializes the overlay container for displaying search results and history.
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -42,6 +42,8 @@ private val settingsResourcePatch = resourcePatch {
|
|||||||
|
|
||||||
execute {
|
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"
|
val targetResource = "values/styles.xml"
|
||||||
inputStreamFromBundledResource(
|
inputStreamFromBundledResource(
|
||||||
"settings/music",
|
"settings/music",
|
||||||
@@ -53,7 +55,7 @@ private val settingsResourcePatch = resourcePatch {
|
|||||||
).close()
|
).close()
|
||||||
}
|
}
|
||||||
|
|
||||||
// Remove horizontal divider from the settings Preferences.
|
// Remove horizontal dividers from the music settings.
|
||||||
val styleFile = get("res/values/styles.xml")
|
val styleFile = get("res/values/styles.xml")
|
||||||
styleFile.writeText(
|
styleFile.writeText(
|
||||||
styleFile.readText()
|
styleFile.readText()
|
||||||
|
|||||||
@@ -18,7 +18,9 @@ import app.revanced.util.returnEarly
|
|||||||
import org.w3c.dom.Node
|
import org.w3c.dom.Node
|
||||||
|
|
||||||
// TODO: Delete this on next major version bump.
|
// 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 (
|
fun settingsPatch (
|
||||||
rootPreference: Pair<IntentPreference, String>,
|
rootPreference: Pair<IntentPreference, String>,
|
||||||
preferences: Set<BasePreference>,
|
preferences: Set<BasePreference>,
|
||||||
@@ -69,8 +71,8 @@ fun settingsPatch (
|
|||||||
ResourceGroup("drawable",
|
ResourceGroup("drawable",
|
||||||
// CustomListPreference resources.
|
// CustomListPreference resources.
|
||||||
"revanced_ic_dialog_alert.xml",
|
"revanced_ic_dialog_alert.xml",
|
||||||
|
// Search resources.
|
||||||
"revanced_settings_arrow_time.xml",
|
"revanced_settings_arrow_time.xml",
|
||||||
"revanced_settings_cursor.xml",
|
|
||||||
"revanced_settings_custom_checkmark.xml",
|
"revanced_settings_custom_checkmark.xml",
|
||||||
"revanced_settings_search_icon.xml",
|
"revanced_settings_search_icon.xml",
|
||||||
"revanced_settings_search_remove.xml",
|
"revanced_settings_search_remove.xml",
|
||||||
|
|||||||
@@ -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
|
// Remove horizontal divider from the settings Preferences
|
||||||
// To better match the appearance of the stock YouTube settings.
|
// To better match the appearance of the stock YouTube settings.
|
||||||
document("res/values/styles.xml").use { document ->
|
document("res/values/styles.xml").use { document ->
|
||||||
|
|||||||
@@ -1,7 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
|
||||||
<shape xmlns:android="http://schemas.android.com/apk/res/android"
|
|
||||||
android:shape="rectangle"
|
|
||||||
android:id="@+id/revanced_settings_cursor">
|
|
||||||
<solid android:color="?android:attr/textColorPrimary" />
|
|
||||||
<size android:width="1dp" />
|
|
||||||
</shape>
|
|
||||||
@@ -46,7 +46,6 @@
|
|||||||
android:iconifiedByDefault="false"
|
android:iconifiedByDefault="false"
|
||||||
android:searchIcon="@null"
|
android:searchIcon="@null"
|
||||||
android:queryBackground="@null"
|
android:queryBackground="@null"
|
||||||
android:theme="@style/revanced_searchbar_cursor"
|
|
||||||
android:padding="2dp" />
|
android:padding="2dp" />
|
||||||
|
|
||||||
</FrameLayout>
|
</FrameLayout>
|
||||||
|
|||||||
@@ -5,8 +5,4 @@
|
|||||||
<item name="android:listPreferredItemPaddingStart">@dimen/item_extra_extra_large_spacing</item>
|
<item name="android:listPreferredItemPaddingStart">@dimen/item_extra_extra_large_spacing</item>
|
||||||
<item name="android:listDivider">@null</item>
|
<item name="android:listDivider">@null</item>
|
||||||
</style>
|
</style>
|
||||||
<style name="revanced_searchbar_cursor">
|
|
||||||
<item name="android:textCursorDrawable">@drawable/revanced_settings_cursor</item>
|
|
||||||
<item name="android:textSize">16sp</item>
|
|
||||||
</style>
|
|
||||||
</resources>
|
</resources>
|
||||||
|
|||||||
@@ -1,7 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
|
||||||
<resources>
|
|
||||||
<style name="revanced_searchbar_cursor">
|
|
||||||
<item name="android:textCursorDrawable">@drawable/revanced_settings_cursor</item>
|
|
||||||
<item name="android:textSize">16sp</item>
|
|
||||||
</style>
|
|
||||||
</resources>
|
|
||||||
Reference in New Issue
Block a user