Skip to content

Commit

Permalink
Misc fixes for OOS13
Browse files Browse the repository at this point in the history
  • Loading branch information
DHD2280 committed Apr 25, 2024
1 parent f1d6ea0 commit 48f383f
Show file tree
Hide file tree
Showing 4 changed files with 86 additions and 63 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -253,27 +253,6 @@ protected void afterHookedMethod(MethodHookParam param) throws Throwable {
}
}
});
/*
"com.android.systemui.keyguard.ui.binder.KeyguardBottomAreaViewBinder".toClass().apply {
method { name = "updateButton" }.hook {
before {
if ((leftButton || rightButton).not()) return@before
val view = args().first().cast<View>() ?: return@before
when (safeOfNull { view.resources.getResourceEntryName(view.id) }) {
"start_button" -> if (leftButton) {
view.isVisible = false
resultNull()
}
"end_button" -> if (rightButton) {
view.isVisible = false
resultNull()
}
}
}
}
}
*/
}

private void hookLockIcon(XC_LoadPackage.LoadPackageParam lpparam) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -131,8 +131,8 @@ public class HeaderClock extends XposedMods {

private int stockClockDateBackgroundChipStyle;
private int mAccent;
private GradientDrawable mClockChipDrawale = new GradientDrawable();
private GradientDrawable mDateChipDrawale = new GradientDrawable();
private GradientDrawable mClockChipDrawale;
private GradientDrawable mDateChipDrawale;
private Typeface mStockClockTypeface, mStockDateTypeface;
private Object OQC = null;
private Object mActivityStarter = null;
Expand Down Expand Up @@ -217,7 +217,7 @@ public void updatePrefs(String... Key) {
}
for (String k : QS_HEADER_CHIP_PREFS) {
if (Key[0].equals(k)) {
updateChips();
setupChips();
}
}
}
Expand Down Expand Up @@ -271,21 +271,32 @@ protected void afterHookedMethod(MethodHookParam param) {
try {
mOplusDate = (TextView) getObjectField(param.thisObject, "mQsDateView");
mStockDateTypeface = mOplusDate.getTypeface();
} catch (Throwable ignored) {
} catch (Throwable t) {
try {
mOplusDate = (TextView) mQuickStatusBarHeader.findViewById(mContext.getResources().getIdentifier("oplus_date", "id", listenPackage));
} catch (Throwable ignored) {}
}

try {
mOplusClock = (TextView) getObjectField(param.thisObject, "mClockView");
mStockClockTypeface = mOplusClock.getTypeface();
} catch (Throwable ignored) {
} catch (Throwable t) {
try {
mOplusClock = (TextView) mQuickStatusBarHeader.findViewById(mContext.getResources().getIdentifier("qs_footer_clock", "id", listenPackage));
} catch (Throwable ignored) {}
}

try {
mOplusCarrier = (TextView) getObjectField(param.thisObject, "mOplusQSCarrier");
} catch (Throwable ignored) {
} catch (Throwable t) {
try {
mOplusCarrier = (TextView) mQuickStatusBarHeader.findViewById(mContext.getResources().getIdentifier("qs_footer_carrier_text", "id", listenPackage));
} catch (Throwable ignored) {}
}

updateStockPrefs();
setupChips();
updateChips();
updateClockView();
}
});
Expand Down Expand Up @@ -360,6 +371,7 @@ protected void beforeHookedMethod(MethodHookParam param) {
@Override
protected void afterHookedMethod(MethodHookParam param) {
updateClockView();
updateChips();
}
});

Expand Down Expand Up @@ -431,7 +443,12 @@ public boolean listensTo(String packageName) {
return listenPackage.equals(packageName);
}

private void updateChips() {
private void setupChips() {

mClockChipDrawale = new GradientDrawable();
mDateChipDrawale = new GradientDrawable();

log(TAG + "updateChips: " + stockClockTimeBackgroundChip + " " + stockClockDateBackgroundChip);

mAccent = getPrimaryColor(mContext);
mClockChipDrawale.setShape(GradientDrawable.RECTANGLE);
Expand Down Expand Up @@ -496,6 +513,20 @@ else if (stockClockDateChipGradient)
mDateChipDrawale.setStroke(stockDateStrokeWidth, stockClockDateUseAccent ? mAccent : stockClockDateChipGradient1);
}
mDateChipDrawale.invalidateSelf();

}

private void updateChips() {
if (stockClockTimeBackgroundChip) {
applyChip(mOplusClock);
} else {
removeChip(mOplusClock);
}
if (!stockClockHideDate && stockClockDateBackgroundChip) {
applyChip(mOplusDate);
} else {
removeChip(mOplusDate);
}
}

private void hideView(TextView textView) {
Expand All @@ -504,7 +535,8 @@ private void hideView(TextView textView) {
if (textView.getVisibility() != View.VISIBLE) return;
textView.setVisibility(View.INVISIBLE);
textView.setTextColor(Color.TRANSPARENT);
} catch (Throwable ignored) {
} catch (Throwable t) {
log(TAG + "hideView: " + t.getMessage());
}
}

Expand Down Expand Up @@ -546,13 +578,13 @@ private void updateStockPrefs() {
}

// Stock clock hide date
if (stockClockHideDate) {
if (showHeaderClock || stockClockHideDate) {
hideView(mOplusDate);
} else {
showView(mOplusDate);
}

if (stockClockHideCarrier || showHeaderClock) {
if (showHeaderClock || stockClockHideCarrier) {
hideView(mOplusCarrier);
} else {
showView(mOplusCarrier);
Expand All @@ -563,37 +595,39 @@ private void updateStockPrefs() {
}

private void setupStockColors() {
if (stockClockTimeBackgroundChip) {
mOplusClock.setBackground(mClockChipDrawale);
} else {
removeChip(mOplusClock);
}
if (!stockClockHideDate && stockClockDateBackgroundChip) {
mOplusDate.setBackground(mDateChipDrawale);
} else {
removeChip(mOplusDate);
}
boolean nightMode = mContext.getResources().getConfiguration().isNightModeActive();
int textColor = nightMode ? Color.WHITE : Color.BLACK;
if (stockClockTimeColorSwitch) {
mOplusClock.setTextColor(stockClockTimeColor);
} else {
mOplusClock.setTextColor(Color.WHITE);
mOplusClock.setTextColor(textColor);
}
if (!stockClockHideDate && stockClockDateColorSwitch) {
mOplusDate.setTextColor(stockClockDateColor);
} else if (!stockClockHideDate && !stockClockDateColorSwitch) {
mOplusDate.setTextColor(Color.WHITE);
} else if (!stockClockHideDate) {
mOplusDate.setTextColor(textColor);
}

}

private void removeChip(TextView textView) {
if (textView == null || textView.getVisibility() != View.VISIBLE) return;
try {
textView.setBackground(null);
} catch (Throwable t) {
log(TAG + "removeChip: " + t.getMessage());
}
}

private void applyChip(TextView textView) {
if (textView == null || textView.getVisibility() != View.VISIBLE) return;
try {
textView.setBackground(textView == mOplusClock ? mClockChipDrawale : mDateChipDrawale);
} catch (Throwable t) {
log(TAG + "applyChip: " + t.getMessage());
}
}

private void updateClockView() {
if (mQsClockContainer == null) return;

Expand Down Expand Up @@ -667,11 +701,8 @@ private void modifyClockView(View clockView) {
String customFont = Environment.getExternalStorageDirectory() + "/.oxygencustomizer_files/headerclock_font.ttf";
int mAccent = getPrimaryColor(mContext);
boolean customColor = Xprefs.getBoolean(QS_HEADER_CLOCK_CUSTOM_COLOR_SWITCH, false);
int textColor = Color.BLACK;
try {
textColor = mContext.getColor(mContext.getResources().getIdentifier("status_bar_qs_footer_clock", "color", listenPackage));
} catch (Throwable ignored) {
}
boolean nightMode = mContext.getResources().getConfiguration().isNightModeActive();
int textColor = nightMode ? Color.WHITE : Color.BLACK;

int accent1 = Xprefs.getInt(
QS_HEADER_CLOCK_COLOR_CODE_ACCENT1,
Expand All @@ -695,20 +726,15 @@ private void modifyClockView(View clockView) {
);

Typeface typeface = null;
log(TAG + "modifyClockView" + " customFont: " + customFont + " customFontEnabled: " + customFontEnabled);
if (customFontEnabled && (new File(customFont).exists()))
typeface = Typeface.createFromFile(new File(customFont));

log(TAG + "modifyClockView" + " typeface: " + typeface + " clockScale: " + clockScale + " sideMargin: " + sideMargin + " topMargin: " + topMargin);

if (TextUtilsCompat.getLayoutDirectionFromLocale(Locale.getDefault()) == View.LAYOUT_DIRECTION_RTL) {
ViewHelper.setMargins(clockView, mContext, 0, topMargin, sideMargin, 0);
} else {
ViewHelper.setMargins(clockView, mContext, sideMargin, topMargin, 0, 0);
}

log(TAG + "setColors");

ViewHelper.findViewWithTagAndChangeColor(clockView, "accent1", customColor ? accent1 : mAccent);
ViewHelper.findViewWithTagAndChangeColor(clockView, "accent2", customColor ? accent2 : mAccent);
ViewHelper.findViewWithTagAndChangeColor(clockView, "accent3", customColor ? accent3 : mAccent);
Expand All @@ -717,7 +743,6 @@ private void modifyClockView(View clockView) {
ViewHelper.findViewWithTagAndChangeColor(clockView, "backgroundAccent", customColor ? accent1 : mAccent);

if (typeface != null) {
log(TAG + "modifyClockView" + " applyFont");
ViewHelper.applyFontRecursively((ViewGroup) clockView, typeface);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
import android.content.pm.ResolveInfo;
import android.graphics.Color;
import android.graphics.drawable.GradientDrawable;
import android.os.Build;
import android.os.Bundle;
import android.os.Handler;
import android.text.Spannable;
Expand Down Expand Up @@ -123,7 +124,7 @@ public class StatusbarClock extends XposedMods {
private int chipTopSxRound, chipTopDxRound, chipBottomSxRound,chipBottomDxRound;
private int mAccent;
private final GradientDrawable mClockChipDrawale = new GradientDrawable();
private int mClockSize = 14;
private int mClockSize = 12;


public StatusbarClock(Context context) {
Expand Down Expand Up @@ -234,6 +235,21 @@ protected void afterHookedMethod(MethodHookParam param) throws Throwable {
}
});

if (Build.VERSION.SDK_INT == 33) {
try {
Class<?> PhoneStatusBarView = findClass("com.android.systemui.statusbar.phone.PhoneStatusBarView", lpparam.classLoader);
hookAllMethods(PhoneStatusBarView, "onFinishInflate", new XC_MethodHook() {
@Override
protected void afterHookedMethod(MethodHookParam param) throws Throwable {
FrameLayout mStatusBar = (FrameLayout) param.thisObject;
mStatusbarStartSide = mStatusBar.findViewById(mContext.getResources().getIdentifier("status_bar_left_side", "id", mContext.getPackageName()));
}
});
} catch (Throwable ignored) {}
} else {
mStatusbarStartSide = null;
}

findAndHookMethod(CollapsedStatusBarFragmentClass,
"onViewCreated", View.class, Bundle.class, new XC_MethodHook() {
@SuppressLint("DiscouragedApi")
Expand All @@ -246,11 +262,7 @@ protected void afterHookedMethod(MethodHookParam param) throws Throwable {
}

ViewGroup mStatusBar = (ViewGroup) getObjectField(mCollapsedStatusBarFragment, "mStatusBar");
try {
mStatusbarStartSide = mStatusBar.findViewById(mContext.getResources().getIdentifier("status_bar_start_side_except_heads_up", "id", mContext.getPackageName()));
} catch (Throwable t) {
mStatusbarStartSide = mStatusBar.findViewById(mContext.getResources().getIdentifier("status_bar_left_side", "id", mContext.getPackageName())); // OOS 13
}
if (mStatusbarStartSide == null) mStatusbarStartSide = mStatusBar.findViewById(mContext.getResources().getIdentifier("status_bar_start_side_except_heads_up", "id", mContext.getPackageName()));

try {
mSystemIconArea = mStatusBar.findViewById(mContext.getResources().getIdentifier("statusIcons", "id", mContext.getPackageName()));
Expand Down Expand Up @@ -278,6 +290,8 @@ protected void afterHookedMethod(MethodHookParam param) throws Throwable {
}
});



hookAllMethods(ClockClass, "updateClockVisibility", new XC_MethodHook() {
@Override
protected void beforeHookedMethod(MethodHookParam param) throws Throwable {
Expand Down Expand Up @@ -540,7 +554,7 @@ else if (chipUseGradient)

private void setupChip() {
if (clockChip) {
mClockView.setPadding(dp2px(mContext, 4), 0, dp2px(mContext, 4), 0);
mClockView.setPadding(dp2px(mContext, 2), 0, dp2px(mContext, 2), 0);
mClockView.setBackground(mClockChipDrawale);
} else {
mClockView.setPadding(0, 0, 0, 0);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,12 @@ protected void beforeHookedMethod(MethodHookParam param) throws Throwable {
}
});

Class<?> SystemPromptController = findClass("com.oplus.systemui.statusbar.controller.SystemPromptController", lpparam.classLoader);
Class<?> SystemPromptController;
try {
SystemPromptController = findClass("com.oplus.systemui.statusbar.controller.SystemPromptController", lpparam.classLoader);
} catch (Throwable t) {
SystemPromptController = findClass("com.oplusos.systemui.controller.SystemPromptController", lpparam.classLoader); // OOS 13
}
findAndHookMethod(SystemPromptController, "updateDeveloperMode", new XC_MethodHook() {
@Override
protected void beforeHookedMethod(MethodHookParam param) throws Throwable {
Expand Down

0 comments on commit 48f383f

Please sign in to comment.