Skip to content

Commit

Permalink
CHANGELOG: Added the ability to hide Lockscreen Affordance
Browse files Browse the repository at this point in the history
  • Loading branch information
DHD2280 committed Apr 25, 2024
1 parent ac6400e commit f1d6ea0
Show file tree
Hide file tree
Showing 4 changed files with 131 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -367,6 +367,13 @@ public static class Lockscreen {
public static final String LOCKSCREEN_CUSTOM_FINGERPRINT = "lockscreen_fp_custom_icon";
public static final String LOCKSCREEN_FINGERPRINT_STYLE = "lockscreen_fp_icon_custom";
public static final String LOCKSCREEN_FINGERPRINT_SCALING = "lockscreen_fp_icon_scaling";
public static final String LOCKSCREEN_REMOVE_LOCK = "lockscreen_hide_lock_icon";
public static final String LOCKSCREEN_REMOVE_LEFT_AFFORDANCE = "lockscreen_affordance_remove_left";
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 class LockscreenClock {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,14 @@
import static de.robv.android.xposed.XposedHelpers.getObjectField;
import static de.robv.android.xposed.XposedHelpers.setObjectField;
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_FINGERPRINT;
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.XPrefs.Xprefs;
import static it.dhd.oxygencustomizer.xposed.utils.DrawableConverter.scaleDrawable;
Expand All @@ -23,7 +28,11 @@
import android.graphics.drawable.Drawable;
import android.os.Build;
import android.os.Environment;
import android.view.View;
import android.widget.FrameLayout;
import android.widget.ImageView;

import androidx.annotation.NonNull;
import androidx.core.content.res.ResourcesCompat;

import java.io.File;
Expand Down Expand Up @@ -51,6 +60,10 @@ public class Lockscreen extends XposedMods {
private Object mFpIcon;
private float mFpScale = 1.0f;
private Drawable mFpDrawable = null;
private boolean removeLeftAffordance = false, removeRightAffordance = false;
private boolean removeLockIcon = false;
private View mStartButton = null, mEndButton = null;
private ImageView mLockIcon = null;

public Lockscreen(Context context) {
super(context);
Expand All @@ -64,13 +77,19 @@ public void updatePrefs(String... Key) {
customFingerprint = Xprefs.getBoolean(LOCKSCREEN_CUSTOM_FINGERPRINT, false);
fingerprintStyle = Integer.parseInt(Xprefs.getString(LOCKSCREEN_FINGERPRINT_STYLE, "0"));
mFpScale = Xprefs.getSliderFloat(LOCKSCREEN_FINGERPRINT_SCALING, 1.0f);
removeLockIcon = Xprefs.getBoolean(LOCKSCREEN_REMOVE_LOCK, false);
removeLeftAffordance = Xprefs.getBoolean(LOCKSCREEN_REMOVE_LEFT_AFFORDANCE, false);
removeRightAffordance = Xprefs.getBoolean(LOCKSCREEN_REMOVE_RIGHT_AFFORDANCE, false);

if (Key.length > 0) {
if (Key[0].equals(LOCKSCREEN_FINGERPRINT_STYLE)
|| Key[0].equals(LOCKSCREEN_CUSTOM_FINGERPRINT)
|| Key[0].equals(LOCKSCREEN_HIDE_FINGERPRINT)
|| Key[0].equals(LOCKSCREEN_FINGERPRINT_SCALING)) {
updateDrawable();
} else if (Key[0].equals(LOCKSCREEN_REMOVE_LEFT_AFFORDANCE)
|| Key[0].equals(LOCKSCREEN_REMOVE_RIGHT_AFFORDANCE)) {
updateAffordance();
}
}
}
Expand Down Expand Up @@ -157,6 +176,12 @@ protected void beforeHookedMethod(MethodHookParam param) throws Throwable {
log(TAG + "startFadeInAnimation not found");
}

// Affordance Section
hookAffordance(lpparam);

// Lock Icon
hookLockIcon(lpparam);

}

private void updateFingerprintIcon(XC_MethodHook.MethodHookParam param, boolean isStartMethod) {
Expand Down Expand Up @@ -202,6 +227,71 @@ private void updateDrawable() {
mFpDrawable = scaleDrawable(mContext, mFpDrawable, mFpScale);
}

private void updateAffordance() {
if (removeLeftAffordance || removeRightAffordance) {
if (mStartButton != null) mStartButton.setVisibility(removeLeftAffordance ? View.GONE : View.VISIBLE);
if (mEndButton != null) mEndButton.setVisibility(removeRightAffordance ? View.GONE : View.VISIBLE);
}
}

private void hookAffordance(XC_LoadPackage.LoadPackageParam lpparam) {
Class<?> KeyguardBottomAreaView = findClass("com.android.systemui.keyguard.ui.binder.KeyguardBottomAreaViewBinder", lpparam.classLoader);
hookAllMethods(KeyguardBottomAreaView, "updateButton", new XC_MethodHook() {
@Override
protected void afterHookedMethod(MethodHookParam param) throws Throwable {
if (!(removeLeftAffordance || removeRightAffordance)) return;
ImageView view = (ImageView) param.args[0];
if (view != null && view.getId() == mContext.getResources().getIdentifier("start_button", "id", listenPackage)) {
mStartButton = view;
if (removeLeftAffordance) {
view.setVisibility(View.GONE);
}
} else if (view != null && view.getId() == mContext.getResources().getIdentifier("end_button", "id", listenPackage))
mEndButton = view;
if (removeRightAffordance) {
view.setVisibility(View.GONE);
}
}
});
/*
"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) {
Class<?> OplusAuthBiometricFingerprintView = findClass("com.oplus.systemui.biometrics.OplusAuthBiometricFingerprintView", lpparam.classLoader);
findAndHookMethod(OplusAuthBiometricFingerprintView, "updateIcon",
int.class,
int.class,
new XC_MethodHook() {
@Override
protected void beforeHookedMethod(MethodHookParam param) throws Throwable {
if (removeLockIcon) {
mLockIcon.setImageDrawable(null);
param.setResult(null);
}
}
});
}

@Override
public boolean listensTo(String packageName) {
return listenPackage.equals(packageName);
Expand Down
5 changes: 4 additions & 1 deletion app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -488,7 +488,6 @@
<string name="volbtn_music_controls_title">Volume button music controls</string>
<string name="volbtn_music_controls_summary">Control music playback with volume buttons</string>


<!-- Lockscreen Strings -->
<string name="lockscreen_title">Lockscreen</string>
<string name="lockscreen_scramble_pin">Scramble PIN</string>
Expand All @@ -503,6 +502,10 @@
<string name="lockscreen_fp_icon_picker_title">Pick Custom Icon</string>
<string name="lockscreen_fp_icon_picker_summary">Pick your custom icon.\nThe recommended image resolution is around 216 x 216.</string>
<string name="lockscreen_fp_icon_scale">Fingerprint Icon Scaling</string>
<string name="lockscreen_affordance">Lockscreen Affordance</string>
<string name="lockscreen_affordance_remove_left">Remove Left Affordance</string>
<string name="lockscreen_affordance_remove_right">Remove Right Affordance</string>
<string name="lockscreen_hide_lock_icon">Hide lock icon</string>

<!-- Lockscreen Clock Strings -->
<string name="lockscreen_clock">Lockscreen Clock</string>
Expand Down
30 changes: 30 additions & 0 deletions app/src/main/res/xml/lockscreen_prefs.xml
Original file line number Diff line number Diff line change
Expand Up @@ -69,11 +69,41 @@

</PreferenceCategory>

<PreferenceCategory
android:title="@string/lockscreen_affordance"
app:iconSpaceReserved="false">

<SwitchPreferenceCompat
android:defaultValue="false"
android:key="lockscreen_affordance_remove_left"
android:title="@string/lockscreen_affordance_remove_left"
android:summaryOn="@string/general_on"
android:summaryOff="@string/general_off"
app:iconSpaceReserved="false" />

<SwitchPreferenceCompat
android:defaultValue="false"
android:key="lockscreen_affordance_remove_right"
android:title="@string/lockscreen_affordance_remove_right"
android:summaryOn="@string/general_on"
android:summaryOff="@string/general_off"
app:iconSpaceReserved="false" />

</PreferenceCategory>

<PreferenceCategory
android:key="lockscreen_misc_category"
android:title="@string/misc"
app:iconSpaceReserved="false">

<!-- <SwitchPreferenceCompat
android:defaultValue="false"
android:key="lockscreen_hide_lock_icon"
android:title="@string/lockscreen_hide_lock_icon"
android:summaryOn="@string/general_on"
android:summaryOff="@string/general_off"
app:iconSpaceReserved="false" /> -->

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

0 comments on commit f1d6ea0

Please sign in to comment.