mirror of
https://github.com/inotia00/revanced-patches.git
synced 2025-05-20 00:07:18 +02:00
fix(YouTube - Settings): Misaligned icons and titles in RVX settings toolbar on Android 15 https://github.com/inotia00/ReVanced_Extended/issues/2602
This commit is contained in:
parent
f5834ab742
commit
574cd8410e
@ -1,5 +1,6 @@
|
||||
package app.revanced.extension.youtube.settings.preference;
|
||||
|
||||
import static com.google.android.apps.youtube.app.settings.videoquality.VideoQualitySettingsActivity.setToolbarLayoutParams;
|
||||
import static app.revanced.extension.shared.settings.preference.AbstractPreferenceFragment.showRestartDialog;
|
||||
import static app.revanced.extension.shared.settings.preference.AbstractPreferenceFragment.updateListPreferenceSummary;
|
||||
import static app.revanced.extension.shared.utils.ResourceUtils.getXmlIdentifier;
|
||||
@ -18,6 +19,7 @@ import android.app.Dialog;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.content.SharedPreferences;
|
||||
import android.graphics.Insets;
|
||||
import android.net.Uri;
|
||||
import android.os.Bundle;
|
||||
import android.preference.EditTextPreference;
|
||||
@ -31,6 +33,7 @@ import android.preference.PreferenceScreen;
|
||||
import android.preference.SwitchPreference;
|
||||
import android.util.TypedValue;
|
||||
import android.view.ViewGroup;
|
||||
import android.view.WindowInsets;
|
||||
import android.widget.TextView;
|
||||
import android.widget.Toolbar;
|
||||
|
||||
@ -202,6 +205,15 @@ public class ReVancedPreferenceFragment extends PreferenceFragment {
|
||||
.findViewById(android.R.id.content)
|
||||
.getParent();
|
||||
|
||||
// Fix required for Android 15
|
||||
if (isSDKAbove(35)) {
|
||||
rootView.setOnApplyWindowInsetsListener((v, insets) -> {
|
||||
Insets statusInsets = insets.getInsets(WindowInsets.Type.statusBars());
|
||||
v.setPadding(0, statusInsets.top, 0, 0);
|
||||
return insets;
|
||||
});
|
||||
}
|
||||
|
||||
Toolbar toolbar = new Toolbar(preferenceScreen.getContext());
|
||||
|
||||
toolbar.setTitle(preferenceScreen.getTitle());
|
||||
@ -219,6 +231,8 @@ public class ReVancedPreferenceFragment extends PreferenceFragment {
|
||||
toolbarTextView.setTextColor(ThemeUtils.getForegroundColor());
|
||||
}
|
||||
|
||||
setToolbarLayoutParams(toolbar);
|
||||
|
||||
rootView.addView(toolbar, 0);
|
||||
return false;
|
||||
}
|
||||
|
@ -88,17 +88,21 @@ public class VideoQualitySettingsActivity extends Activity {
|
||||
fragment.filterPreferences(query);
|
||||
}
|
||||
|
||||
private static ViewGroup.LayoutParams lp;
|
||||
|
||||
public static void setToolbarLayoutParams(Toolbar toolbar) {
|
||||
if (lp != null) {
|
||||
toolbar.setLayoutParams(lp);
|
||||
}
|
||||
}
|
||||
|
||||
private void setToolbar() {
|
||||
if (!(findViewById(ResourceUtils.getIdIdentifier("revanced_toolbar_parent")) instanceof ViewGroup toolBarParent))
|
||||
return;
|
||||
ViewGroup toolBarParent = findViewById(ResourceUtils.getIdIdentifier("revanced_toolbar_parent"));
|
||||
|
||||
// Remove dummy toolbar.
|
||||
for (int i = 0; i < toolBarParent.getChildCount(); i++) {
|
||||
View view = toolBarParent.getChildAt(i);
|
||||
if (view != null) {
|
||||
toolBarParent.removeView(view);
|
||||
}
|
||||
}
|
||||
ViewGroup dummyToolbar = toolBarParent.findViewById(ResourceUtils.getIdIdentifier("revanced_toolbar"));
|
||||
lp = dummyToolbar.getLayoutParams();
|
||||
toolBarParent.removeView(dummyToolbar);
|
||||
|
||||
Toolbar toolbar = new Toolbar(toolBarParent.getContext());
|
||||
toolbar.setBackgroundColor(ThemeUtils.getToolbarBackgroundColor());
|
||||
@ -112,6 +116,7 @@ public class VideoQualitySettingsActivity extends Activity {
|
||||
if (toolbarTextView != null) {
|
||||
toolbarTextView.setTextColor(ThemeUtils.getForegroundColor());
|
||||
}
|
||||
setToolbarLayoutParams(toolbar);
|
||||
toolBarParent.addView(toolbar, 0);
|
||||
}
|
||||
|
||||
|
@ -16,10 +16,10 @@
|
||||
android:background="@color/yt_white1"
|
||||
android:elevation="0dp">
|
||||
|
||||
<android.widget.Toolbar
|
||||
<android.support.v7.widget.Toolbar
|
||||
android:id="@+id/revanced_toolbar"
|
||||
android:layout_width="0.0dip"
|
||||
android:layout_height="0.0dip"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="?attr/actionBarSize"
|
||||
android:background="?attr/ytBrandBackgroundSolid"
|
||||
app:navigationIcon="@drawable/yt_outline_arrow_left_black_24"
|
||||
app:title="@string/revanced_extended_settings_title" />
|
||||
|
Loading…
x
Reference in New Issue
Block a user