mirror of
https://github.com/revanced/revanced-patches.git
synced 2025-06-12 05:07:45 +02:00
fix(YouTube - Wide search bar): Do not force phone layout for tablet devices (#4827)
This commit is contained in:

committed by
GitHub

parent
3e64a4c18f
commit
0cb38f9f36
@ -1,11 +1,48 @@
|
||||
package app.revanced.extension.youtube.patches;
|
||||
|
||||
import android.content.res.Resources;
|
||||
import android.util.TypedValue;
|
||||
import android.view.View;
|
||||
|
||||
import app.revanced.extension.shared.Logger;
|
||||
import app.revanced.extension.shared.Utils;
|
||||
import app.revanced.extension.youtube.settings.Settings;
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
public final class WideSearchbarPatch {
|
||||
|
||||
private static final Boolean WIDE_SEARCHBAR_ENABLED = Settings.WIDE_SEARCHBAR.get();
|
||||
|
||||
/**
|
||||
* Injection point.
|
||||
*/
|
||||
public static boolean enableWideSearchbar(boolean original) {
|
||||
return Settings.WIDE_SEARCHBAR.get() || original;
|
||||
return WIDE_SEARCHBAR_ENABLED || original;
|
||||
}
|
||||
|
||||
/**
|
||||
* Injection point.
|
||||
*/
|
||||
public static void setActionBar(View view) {
|
||||
try {
|
||||
if (!WIDE_SEARCHBAR_ENABLED) return;
|
||||
|
||||
View searchBarView = Utils.getChildViewByResourceName(view, "search_bar");
|
||||
|
||||
final int paddingLeft = searchBarView.getPaddingLeft();
|
||||
final int paddingRight = searchBarView.getPaddingRight();
|
||||
final int paddingTop = searchBarView.getPaddingTop();
|
||||
final int paddingBottom = searchBarView.getPaddingBottom();
|
||||
final int paddingStart = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP,
|
||||
8, Resources.getSystem().getDisplayMetrics());
|
||||
|
||||
if (Utils.isRightToLeftTextLayout()) {
|
||||
searchBarView.setPadding(paddingLeft, paddingTop, paddingStart, paddingBottom);
|
||||
} else {
|
||||
searchBarView.setPadding(paddingStart, paddingTop, paddingRight, paddingBottom);
|
||||
}
|
||||
} catch (Exception ex) {
|
||||
Logger.printException(() -> "setActionBar failure", ex);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user