mirror of
https://github.com/revanced/revanced-patches
synced 2024-11-30 11:12:54 +01:00
fix(YouTube - Settings): Use multiline preference title for localized languages (#3821)
This commit is contained in:
parent
bc6700119f
commit
ff85d49088
@ -722,6 +722,35 @@ public class Utils {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set all preferences to multiline titles if the device is not using an English variant.
|
||||||
|
* The English strings are heavily scrutinized and all titles fit on screen
|
||||||
|
* except 2 or 3 preference strings and those do not affect readability.
|
||||||
|
*
|
||||||
|
* Allowing multiline for those 2 or 3 English preferences looks weird and out of place,
|
||||||
|
* and visually it looks better to clip the text and keep all titles 1 line.
|
||||||
|
*/
|
||||||
|
@SuppressWarnings("deprecation")
|
||||||
|
public static void setPreferenceTitlesToMultiLineIfNeeded(PreferenceGroup group) {
|
||||||
|
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.O) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
String deviceLanguage = Utils.getContext().getResources().getConfiguration().locale.getLanguage();
|
||||||
|
if (deviceLanguage.equals("en")) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
for (int i = 0, prefCount = group.getPreferenceCount(); i < prefCount; i++) {
|
||||||
|
Preference pref = group.getPreference(i);
|
||||||
|
pref.setSingleLineTitle(false);
|
||||||
|
|
||||||
|
if (pref instanceof PreferenceGroup) {
|
||||||
|
setPreferenceTitlesToMultiLineIfNeeded((PreferenceGroup) pref);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* If {@link Fragment} uses [Android library] rather than [AndroidX library],
|
* If {@link Fragment} uses [Android library] rather than [AndroidX library],
|
||||||
* the Dialog theme corresponding to [Android library] should be used.
|
* the Dialog theme corresponding to [Android library] should be used.
|
||||||
|
@ -17,7 +17,7 @@ import app.revanced.extension.shared.settings.Setting;
|
|||||||
|
|
||||||
import static app.revanced.extension.shared.StringRef.str;
|
import static app.revanced.extension.shared.StringRef.str;
|
||||||
|
|
||||||
@SuppressWarnings({"unused", "deprecation"})
|
@SuppressWarnings("deprecation")
|
||||||
public abstract class AbstractPreferenceFragment extends PreferenceFragment {
|
public abstract class AbstractPreferenceFragment extends PreferenceFragment {
|
||||||
/**
|
/**
|
||||||
* Indicates that if a preference changes,
|
* Indicates that if a preference changes,
|
||||||
@ -80,10 +80,12 @@ public abstract class AbstractPreferenceFragment extends PreferenceFragment {
|
|||||||
*/
|
*/
|
||||||
protected void initialize() {
|
protected void initialize() {
|
||||||
final var identifier = Utils.getResourceIdentifier("revanced_prefs", "xml");
|
final var identifier = Utils.getResourceIdentifier("revanced_prefs", "xml");
|
||||||
|
|
||||||
if (identifier == 0) return;
|
if (identifier == 0) return;
|
||||||
addPreferencesFromResource(identifier);
|
addPreferencesFromResource(identifier);
|
||||||
Utils.sortPreferenceGroups(getPreferenceScreen());
|
|
||||||
|
PreferenceScreen screen = getPreferenceScreen();
|
||||||
|
Utils.sortPreferenceGroups(screen);
|
||||||
|
Utils.setPreferenceTitlesToMultiLineIfNeeded(screen);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void showSettingUserDialogConfirmation(SwitchPreference switchPref, BooleanSetting setting) {
|
private void showSettingUserDialogConfirmation(SwitchPreference switchPref, BooleanSetting setting) {
|
||||||
|
@ -196,8 +196,6 @@ public final class MiniplayerPatch {
|
|||||||
* Injection point.
|
* Injection point.
|
||||||
*/
|
*/
|
||||||
public static boolean getModernFeatureFlagsActiveOverride(boolean original) {
|
public static boolean getModernFeatureFlagsActiveOverride(boolean original) {
|
||||||
if (original) Logger.printDebug(() -> "getModernFeatureFlagsActiveOverride original: " + original);
|
|
||||||
|
|
||||||
if (CURRENT_TYPE == ORIGINAL) {
|
if (CURRENT_TYPE == ORIGINAL) {
|
||||||
return original;
|
return original;
|
||||||
}
|
}
|
||||||
@ -209,8 +207,6 @@ public final class MiniplayerPatch {
|
|||||||
* Injection point.
|
* Injection point.
|
||||||
*/
|
*/
|
||||||
public static boolean enableMiniplayerDoubleTapAction(boolean original) {
|
public static boolean enableMiniplayerDoubleTapAction(boolean original) {
|
||||||
if (original) Logger.printDebug(() -> "enableMiniplayerDoubleTapAction original: " + true);
|
|
||||||
|
|
||||||
if (CURRENT_TYPE == ORIGINAL) {
|
if (CURRENT_TYPE == ORIGINAL) {
|
||||||
return original;
|
return original;
|
||||||
}
|
}
|
||||||
@ -222,8 +218,6 @@ public final class MiniplayerPatch {
|
|||||||
* Injection point.
|
* Injection point.
|
||||||
*/
|
*/
|
||||||
public static boolean enableMiniplayerDragAndDrop(boolean original) {
|
public static boolean enableMiniplayerDragAndDrop(boolean original) {
|
||||||
if (original) Logger.printDebug(() -> "enableMiniplayerDragAndDrop original: " + true);
|
|
||||||
|
|
||||||
if (CURRENT_TYPE == ORIGINAL) {
|
if (CURRENT_TYPE == ORIGINAL) {
|
||||||
return original;
|
return original;
|
||||||
}
|
}
|
||||||
@ -236,8 +230,6 @@ public final class MiniplayerPatch {
|
|||||||
* Injection point.
|
* Injection point.
|
||||||
*/
|
*/
|
||||||
public static boolean setRoundedCorners(boolean original) {
|
public static boolean setRoundedCorners(boolean original) {
|
||||||
if (original) Logger.printDebug(() -> "setRoundedCorners original: " + true);
|
|
||||||
|
|
||||||
if (CURRENT_TYPE.isModern()) {
|
if (CURRENT_TYPE.isModern()) {
|
||||||
return MINIPLAYER_ROUNDED_CORNERS_ENABLED;
|
return MINIPLAYER_ROUNDED_CORNERS_ENABLED;
|
||||||
}
|
}
|
||||||
@ -271,8 +263,6 @@ public final class MiniplayerPatch {
|
|||||||
* Injection point.
|
* Injection point.
|
||||||
*/
|
*/
|
||||||
public static boolean setDropShadow(boolean original) {
|
public static boolean setDropShadow(boolean original) {
|
||||||
if (original) Logger.printDebug(() -> "setViewElevation original: " + true);
|
|
||||||
|
|
||||||
return original;
|
return original;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -155,7 +155,6 @@ public final class LithoFilterPatch {
|
|||||||
// Potentially the buffer may have been null or never set up until now.
|
// Potentially the buffer may have been null or never set up until now.
|
||||||
// Use an empty buffer so the litho id/path filters still work correctly.
|
// Use an empty buffer so the litho id/path filters still work correctly.
|
||||||
if (protobufBuffer == null) {
|
if (protobufBuffer == null) {
|
||||||
Logger.printDebug(() -> "Proto buffer is null, using an empty buffer array");
|
|
||||||
bufferArray = EMPTY_BYTE_ARRAY;
|
bufferArray = EMPTY_BYTE_ARRAY;
|
||||||
} else if (!protobufBuffer.hasArray()) {
|
} else if (!protobufBuffer.hasArray()) {
|
||||||
Logger.printDebug(() -> "Proto buffer does not have an array, using an empty buffer array");
|
Logger.printDebug(() -> "Proto buffer does not have an array, using an empty buffer array");
|
||||||
|
Loading…
Reference in New Issue
Block a user