Skip to content

Commit

Permalink
CHANGELOG: Added Lockscreen Statusbar customizations
Browse files Browse the repository at this point in the history
  • Loading branch information
DHD2280 committed Apr 26, 2024
1 parent 7125e92 commit 89cc3a2
Show file tree
Hide file tree
Showing 5 changed files with 165 additions and 17 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,12 @@
import static it.dhd.oxygencustomizer.utils.Constants.LOCKSCREEN_CLOCK_LAYOUT;
import static it.dhd.oxygencustomizer.utils.Constants.LOCKSCREEN_FINGERPRINT_FILE;
import static it.dhd.oxygencustomizer.utils.Constants.LOCKSCREEN_USER_IMAGE;
import static it.dhd.oxygencustomizer.utils.Constants.Packages.SYSTEM_UI;
import static it.dhd.oxygencustomizer.utils.Constants.Preferences.Lockscreen.LOCKSCREEN_CUSTOM_FINGERPRINT;
import static it.dhd.oxygencustomizer.utils.Constants.Preferences.Lockscreen.LOCKSCREEN_FINGERPRINT_STYLE;
import static it.dhd.oxygencustomizer.utils.Constants.Preferences.Lockscreen.LOCKSCREEN_HIDE_CAPSULE;
import static it.dhd.oxygencustomizer.utils.Constants.Preferences.Lockscreen.LOCKSCREEN_HIDE_CARRIER;
import static it.dhd.oxygencustomizer.utils.Constants.Preferences.Lockscreen.LOCKSCREEN_HIDE_STATUSBAR;
import static it.dhd.oxygencustomizer.utils.Constants.Preferences.LockscreenClock.LOCKSCREEN_CLOCK_CUSTOM_FONT;
import static it.dhd.oxygencustomizer.utils.Constants.Preferences.LockscreenClock.LOCKSCREEN_CLOCK_STYLE;
import static it.dhd.oxygencustomizer.utils.Constants.Preferences.LockscreenClock.LOCKSCREEN_CLOCK_SWITCH;
Expand Down Expand Up @@ -111,7 +115,7 @@ public boolean hasMenu() {

@Override
public String[] getScopes() {
return new String[]{Constants.Packages.SYSTEM_UI};
return new String[]{SYSTEM_UI};
}

@Override
Expand Down Expand Up @@ -163,6 +167,24 @@ public void onCreatePreferences(Bundle savedInstanceState, String rootKey) {
return true;
});
}

SwitchPreferenceCompat hideCarrier, hideCapsule, hideStatusbar;
hideCarrier = findPreference(LOCKSCREEN_HIDE_CARRIER);
hideCapsule = findPreference(LOCKSCREEN_HIDE_CAPSULE);
hideStatusbar = findPreference(LOCKSCREEN_HIDE_STATUSBAR);
OnPreferenceChangeListener listener = (preference, newValue) -> {
AppUtils.restartScope(SYSTEM_UI);
return true;
};
if (hideCarrier != null) {
hideCarrier.setOnPreferenceChangeListener(listener);
}
if (hideCapsule != null) {
hideCapsule.setOnPreferenceChangeListener(listener);
}
if (hideStatusbar != null) {
hideStatusbar.setOnPreferenceChangeListener(listener);
}
}

ActivityResultLauncher<Intent> startActivityIntent = registerForActivityResult(
Expand Down Expand Up @@ -203,7 +225,7 @@ public boolean hasMenu() {

@Override
public String[] getScopes() {
return new String[]{Constants.Packages.SYSTEM_UI};
return new String[]{SYSTEM_UI};
}

private int type = 0;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -362,8 +362,10 @@ public static class Lockscreen {
public static final String LOCKSCREEN_REMOVE_RIGHT_AFFORDANCE = "lockscreen_affordance_remove_right";
public static final String LOCKSCREEN_CUSTOM_LEFT_AFFORDANCE = "lockscreen_affordance_custom_left";
public static final String LOCKSCREEN_CUSTOM_RIGHT_AFFORDANCE = "lockscreen_affordance_custom_left";
public static final String LOCKSCREEN_AFFORDANCE_LEFT = "lockscreen_affordance_left";
public static final String LOCKSCREEN_AFFORDANCE_RIGHT = "lockscreen_affordance_right";
public static final String LOCKSCREEN_HIDE_CARRIER = "lockscreen_hide_carrier";
public static final String LOCKSCREEN_HIDE_STATUSBAR = "lockscreen_hide_statusbar";
public static final String LOCKSCREEN_HIDE_CAPSULE = "lockscreen_hide_capsule";
public static final String LOCKSCREEN_CARRIER_REPLACEMENT = "lockscreen_carrier_replacement";
}

public static class LockscreenClock {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,16 +8,22 @@
import static de.robv.android.xposed.XposedHelpers.findClass;
import static de.robv.android.xposed.XposedHelpers.getObjectField;
import static de.robv.android.xposed.XposedHelpers.setObjectField;
import static it.dhd.oxygencustomizer.utils.Constants.Packages.SYSTEM_UI;
import static it.dhd.oxygencustomizer.utils.Constants.Preferences.Lockscreen.LOCKSCREEN_CARRIER_REPLACEMENT;
import static it.dhd.oxygencustomizer.utils.Constants.Preferences.Lockscreen.LOCKSCREEN_CUSTOM_FINGERPRINT;
import static it.dhd.oxygencustomizer.utils.Constants.Preferences.Lockscreen.LOCKSCREEN_CUSTOM_LEFT_AFFORDANCE;
import static it.dhd.oxygencustomizer.utils.Constants.Preferences.Lockscreen.LOCKSCREEN_CUSTOM_RIGHT_AFFORDANCE;
import static it.dhd.oxygencustomizer.utils.Constants.Preferences.Lockscreen.LOCKSCREEN_FINGERPRINT_SCALING;
import static it.dhd.oxygencustomizer.utils.Constants.Preferences.Lockscreen.LOCKSCREEN_FINGERPRINT_STYLE;
import static it.dhd.oxygencustomizer.utils.Constants.Preferences.Lockscreen.LOCKSCREEN_HIDE_CAPSULE;
import static it.dhd.oxygencustomizer.utils.Constants.Preferences.Lockscreen.LOCKSCREEN_HIDE_CARRIER;
import static it.dhd.oxygencustomizer.utils.Constants.Preferences.Lockscreen.LOCKSCREEN_HIDE_FINGERPRINT;
import static it.dhd.oxygencustomizer.utils.Constants.Preferences.Lockscreen.LOCKSCREEN_HIDE_STATUSBAR;
import static it.dhd.oxygencustomizer.utils.Constants.Preferences.Lockscreen.LOCKSCREEN_REMOVE_LEFT_AFFORDANCE;
import static it.dhd.oxygencustomizer.utils.Constants.Preferences.Lockscreen.LOCKSCREEN_REMOVE_LOCK;
import static it.dhd.oxygencustomizer.utils.Constants.Preferences.Lockscreen.LOCKSCREEN_REMOVE_RIGHT_AFFORDANCE;
import static it.dhd.oxygencustomizer.utils.Constants.Preferences.Lockscreen.LOCKSCREEN_REMOVE_SOS;
import static it.dhd.oxygencustomizer.xposed.ResourceManager.resparams;
import static it.dhd.oxygencustomizer.xposed.XPrefs.Xprefs;
import static it.dhd.oxygencustomizer.xposed.utils.DrawableConverter.scaleDrawable;

Expand All @@ -31,9 +37,12 @@
import android.view.View;
import android.widget.FrameLayout;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.TextView;

import androidx.annotation.NonNull;
import androidx.core.content.res.ResourcesCompat;
import androidx.databinding.adapters.ViewBindingAdapter;

import java.io.File;
import java.util.concurrent.Executors;
Expand All @@ -42,6 +51,8 @@
import java.util.concurrent.atomic.AtomicReference;

import de.robv.android.xposed.XC_MethodHook;
import de.robv.android.xposed.callbacks.XC_InitPackageResources;
import de.robv.android.xposed.callbacks.XC_LayoutInflated;
import de.robv.android.xposed.callbacks.XC_LoadPackage;
import it.dhd.oxygencustomizer.BuildConfig;
import it.dhd.oxygencustomizer.utils.Constants;
Expand All @@ -50,7 +61,7 @@

public class Lockscreen extends XposedMods {

private final static String listenPackage = Constants.Packages.SYSTEM_UI;
private final static String listenPackage = SYSTEM_UI;
private final String TAG = "Oxygen Customizer - Lockscreen: ";
private Class<?> KeyguardHelper = null;
private Object OSF = null;
Expand All @@ -64,6 +75,9 @@ public class Lockscreen extends XposedMods {
private boolean removeLockIcon = false;
private View mStartButton = null, mEndButton = null;
private ImageView mLockIcon = null;
private boolean hideLockscreenCarrier = false, hideLockscreenStatusbar = false, hideLockscreenCapsule = false;
private String lockscreenCarrierReplacement = "";
private static Object carrierTextController;

public Lockscreen(Context context) {
super(context);
Expand All @@ -80,6 +94,10 @@ public void updatePrefs(String... Key) {
removeLockIcon = Xprefs.getBoolean(LOCKSCREEN_REMOVE_LOCK, false);
removeLeftAffordance = Xprefs.getBoolean(LOCKSCREEN_REMOVE_LEFT_AFFORDANCE, false);
removeRightAffordance = Xprefs.getBoolean(LOCKSCREEN_REMOVE_RIGHT_AFFORDANCE, false);
hideLockscreenCarrier = Xprefs.getBoolean(LOCKSCREEN_HIDE_CARRIER, false);
hideLockscreenStatusbar = Xprefs.getBoolean(LOCKSCREEN_HIDE_STATUSBAR, false);
hideLockscreenCapsule = Xprefs.getBoolean(LOCKSCREEN_HIDE_CAPSULE, false);
lockscreenCarrierReplacement = Xprefs.getString(LOCKSCREEN_CARRIER_REPLACEMENT, "");

updateDrawable();

Expand All @@ -88,7 +106,14 @@ public void updatePrefs(String... Key) {
|| Key[0].equals(LOCKSCREEN_REMOVE_RIGHT_AFFORDANCE)) {
updateAffordance();
}
if (Key[0].equals(LOCKSCREEN_HIDE_CARRIER) ||
Key[0].equals(LOCKSCREEN_HIDE_STATUSBAR) ||
Key[0].equals(LOCKSCREEN_HIDE_CAPSULE)
) {
hideLockscreenStuff();
}
}

}

private boolean isMethodSecure() {
Expand All @@ -103,6 +128,12 @@ private boolean isMethodSecure() {
public void handleLoadPackage(XC_LoadPackage.LoadPackageParam lpparam) throws Throwable {
if (!lpparam.packageName.equals(listenPackage)) return;

try {
hideLockscreenStuff();
} catch (Throwable t) {
log(TAG + "hideLockscreenStuff failed " + t.getMessage());
}

try {
Class<?> OplusEmergencyButtonExImpl = findClass("com.oplus.keyguard.OplusEmergencyButtonExImpl", lpparam.classLoader);
findAndHookMethod(OplusEmergencyButtonExImpl, "disableShowEmergencyButton", new XC_MethodHook() {
Expand Down Expand Up @@ -135,7 +166,7 @@ protected void afterHookedMethod(MethodHookParam param) throws Throwable {
}
});
} catch (Throwable t) {
log(TAG + "onAttachedToWindow not found");
log(TAG + "loadAnimDrawables not found");
}

try {
Expand Down Expand Up @@ -179,6 +210,9 @@ protected void beforeHookedMethod(MethodHookParam param) throws Throwable {
// Lock Icon
hookLockIcon(lpparam);

// Custom Carrier
hookCarrier(lpparam);

}

private void updateFingerprintIcon(XC_MethodHook.MethodHookParam param, boolean isStartMethod) {
Expand Down Expand Up @@ -282,29 +316,86 @@ protected void afterHookedMethod(MethodHookParam param) throws Throwable {
}
});
}
}

private void hookLockIcon(XC_LoadPackage.LoadPackageParam lpparam) {

/*
*/
}

private void hookLockIcon(XC_LoadPackage.LoadPackageParam lpparam) {
Class<?> OplusAuthBiometricFingerprintView = findClass("com.oplus.systemui.biometrics.OplusAuthBiometricFingerprintView", lpparam.classLoader);
findAndHookMethod(OplusAuthBiometricFingerprintView, "updateIcon",
int.class,
int.class,
new XC_MethodHook() {
private void hookCarrier(XC_LoadPackage.LoadPackageParam lpparam) {

Class<?> OplusStatCarrierTextController = findClass("com.oplus.systemui.statusbar.widget.OplusStatCarrierTextController", lpparam.classLoader);
hookAllMethods(OplusStatCarrierTextController, "updateCarrierInfo", new XC_MethodHook() {
@Override
protected void beforeHookedMethod(MethodHookParam param) throws Throwable {
if (removeLockIcon) {
mLockIcon.setImageDrawable(null);
TextView mView = (TextView) getObjectField(param.thisObject, "mView");
if (mView.getId() == mContext.getResources().getIdentifier("keyguard_carrier_text", "id", listenPackage) &&
!lockscreenCarrierReplacement.isEmpty()
) {
mView.post(() -> mView.setText(lockscreenCarrierReplacement));
param.setResult(null);
}
}
});
}

private void hideLockscreenStuff() {
XC_InitPackageResources.InitPackageResourcesParam ourResparam = resparams.get(SYSTEM_UI);
if (ourResparam == null) return;

try {
ourResparam.res.hookLayout(SYSTEM_UI, "layout", "keyguard_status_bar", new XC_LayoutInflated() {
@SuppressLint("DiscouragedApi")
@Override
public void handleLayoutInflated(XC_LayoutInflated.LayoutInflatedParam liparam) {
if (hideLockscreenCarrier) {
try {
@SuppressLint("DiscouragedApi") TextView keyguard_carrier_text = liparam.view.findViewById(liparam.res.getIdentifier("keyguard_carrier_text", "id", mContext.getPackageName()));
keyguard_carrier_text.getLayoutParams().height = 0;
keyguard_carrier_text.setVisibility(View.INVISIBLE);
keyguard_carrier_text.requestLayout();
} catch (Throwable ignored) {
}
}
if (hideLockscreenCapsule) {
try {
@SuppressLint("DiscouragedApi") LinearLayout keyguard_seeding_card_container = liparam.view.findViewById(liparam.res.getIdentifier("keyguard_seeding_card_container", "id", mContext.getPackageName()));
keyguard_seeding_card_container.getLayoutParams().height = 0;
keyguard_seeding_card_container.setVisibility(View.INVISIBLE);
keyguard_seeding_card_container.requestLayout();
} catch (Throwable ignored) {
}
}
if (hideLockscreenStatusbar) {
try {
@SuppressLint("DiscouragedApi") LinearLayout status_icon_area = liparam.view.findViewById(liparam.res.getIdentifier("status_icon_area", "id", mContext.getPackageName()));
status_icon_area.getLayoutParams().height = 0;
status_icon_area.setVisibility(View.INVISIBLE);
status_icon_area.requestLayout();
} catch (Throwable ignored) {
}

try {
@SuppressLint("DiscouragedApi") TextView keyguard_carrier_text = liparam.view.findViewById(liparam.res.getIdentifier("keyguard_carrier_text", "id", mContext.getPackageName()));
keyguard_carrier_text.getLayoutParams().height = 0;
keyguard_carrier_text.setVisibility(View.INVISIBLE);
keyguard_carrier_text.requestLayout();
} catch (Throwable ignored) {
}
try {
@SuppressLint("DiscouragedApi") LinearLayout keyguard_seeding_card_container = liparam.view.findViewById(liparam.res.getIdentifier("keyguard_seeding_card_container", "id", mContext.getPackageName()));
keyguard_seeding_card_container.getLayoutParams().height = 0;
keyguard_seeding_card_container.setVisibility(View.INVISIBLE);
keyguard_seeding_card_container.requestLayout();
} catch (Throwable ignored) {
}
}
}
});
} catch (Throwable ignored) {
}
}

@Override
public boolean listensTo(String packageName) {
return listenPackage.equals(packageName);
Expand Down
8 changes: 8 additions & 0 deletions app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -492,6 +492,14 @@

<!-- Lockscreen Strings -->
<string name="lockscreen_title">Lockscreen</string>
<string name="lockscreen_hide_carrier">Hide Carrier</string>
<string name="lockscreen_hide_carrier_summary">Hide carrier name on lockscreen</string>
<string name="lockscreen_carrier_replacement">LS carrier replacement</string>
<string name="lockscreen_carrier_replacement_summary">Replace carrier name on lockscreen.\nKeep blank to disable</string>
<string name="lockscreen_hide_statusbar">Hide Statusbar</string>
<string name="lockscreen_hide_statusbar_summary">Hide statusbar on lockscreen</string>
<string name="lockscreen_hide_capsule">Hide Capsule</string>
<string name="lockscreen_hide_capsule_summary">Hide capsule on lockscreen (Call/Hotspot/etc)</string>
<string name="lockscreen_hide_power_menu">Hide power menu</string>
<string name="lockscreen_hide_power_menu_summary">Hide power menu on secure lockscreen</string>
<string name="lockscreen_remove_sos_title">Hide SOS button</string>
Expand Down
25 changes: 25 additions & 0 deletions app/src/main/res/xml/lockscreen_prefs.xml
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,31 @@
android:summaryOff="@string/general_off"
app:iconSpaceReserved="false" /> -->

<SwitchPreferenceCompat
android:defaultValue="false"
android:key="lockscreen_hide_carrier"
android:title="@string/lockscreen_hide_carrier"
android:summary="@string/lockscreen_hide_carrier_summary"
app:iconSpaceReserved="false" />
<EditTextPreference
android:defaultValue=""
android:key="lockscreen_carrier_replacement"
android:title="@string/lockscreen_carrier_replacement"
android:summary="@string/lockscreen_carrier_replacement_summary"
app:iconSpaceReserved="false" />
<SwitchPreferenceCompat
android:defaultValue="false"
android:key="lockscreen_hide_capsule"
android:title="@string/lockscreen_hide_capsule"
android:summary="@string/lockscreen_hide_capsule_summary"
app:iconSpaceReserved="false" />
<SwitchPreferenceCompat
android:defaultValue="false"
android:key="lockscreen_hide_statusbar"
android:title="@string/lockscreen_hide_statusbar"
android:summary="@string/lockscreen_hide_statusbar_summary"
app:iconSpaceReserved="false" />

<SwitchPreferenceCompat
android:defaultValue="false"
android:key="disable_power_on_lockscreen"
Expand Down

0 comments on commit 89cc3a2

Please sign in to comment.