Skip to content

Commit

Permalink
Depth Wallpaper: Fix issues for A12L
Browse files Browse the repository at this point in the history
  • Loading branch information
Mahmud0808 committed Sep 26, 2023
1 parent 951aa03 commit a9c6fbe
Showing 1 changed file with 43 additions and 35 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import static com.drdisagree.iconify.config.XPrefs.Xprefs;
import static de.robv.android.xposed.XposedBridge.hookAllMethods;
import static de.robv.android.xposed.XposedHelpers.findClass;
import static de.robv.android.xposed.XposedHelpers.findClassIfExists;
import static de.robv.android.xposed.XposedHelpers.getObjectField;

import android.annotation.SuppressLint;
Expand All @@ -16,6 +17,8 @@
import android.graphics.drawable.Drawable;
import android.os.Build;
import android.os.Environment;
import android.os.Handler;
import android.os.Looper;
import android.view.Gravity;
import android.view.View;
import android.view.ViewGroup;
Expand Down Expand Up @@ -91,10 +94,8 @@ protected void afterHookedMethod(MethodHookParam param) {
TextView mTopIndicationView = mIndicationArea.findViewById(mContext.getResources().getIdentifier("keyguard_indication_text", "id", mContext.getPackageName()));
TextView mLockScreenIndicationView = mIndicationArea.findViewById(mContext.getResources().getIdentifier("keyguard_indication_text_bottom", "id", mContext.getPackageName()));

/*
We added a blank view to the top of the layout to push the indication text views to the bottom
The reason we did this is because gravity is not working properly on the indication text views
*/
// We added a blank view to the top of the layout to push the indication text views to the bottom
// The reason we did this is because gravity is not working properly on the indication text views
View blankView = new View(mContext);
blankView.setLayoutParams(new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, 0, 1.0f));

Expand Down Expand Up @@ -133,13 +134,16 @@ protected void afterHookedMethod(MethodHookParam param) {
mDepthWallpaperLayout.addView(mDepthWallpaperForeground, -1);

// Fix the bottom shortcuts pushing the wallpaper
ImageView startButton = view.findViewById(mContext.getResources().getIdentifier("start_button", "id", mContext.getPackageName()));
ImageView endButton = view.findViewById(mContext.getResources().getIdentifier("end_button", "id", mContext.getPackageName()));
int offset = mContext.getResources().getDimensionPixelSize(mContext.getResources().getIdentifier("keyguard_affordance_fixed_height", "dimen", mContext.getPackageName()))
+ mContext.getResources().getDimensionPixelSize(mContext.getResources().getIdentifier("keyguard_affordance_horizontal_offset", "dimen", mContext.getPackageName()));

startButton.getViewTreeObserver().addOnGlobalLayoutListener(() -> ((ViewGroup.MarginLayoutParams) mIndicationTextView.getLayoutParams()).setMarginStart(startButton.getVisibility() == View.VISIBLE ? offset : 0));
endButton.getViewTreeObserver().addOnGlobalLayoutListener(() -> ((ViewGroup.MarginLayoutParams) mIndicationTextView.getLayoutParams()).setMarginEnd(endButton.getVisibility() == View.VISIBLE ? offset : 0));
try {
ImageView startButton = view.findViewById(mContext.getResources().getIdentifier("start_button", "id", mContext.getPackageName()));
ImageView endButton = view.findViewById(mContext.getResources().getIdentifier("end_button", "id", mContext.getPackageName()));
int offset = mContext.getResources().getDimensionPixelSize(mContext.getResources().getIdentifier("keyguard_affordance_fixed_height", "dimen", mContext.getPackageName()))
+ mContext.getResources().getDimensionPixelSize(mContext.getResources().getIdentifier("keyguard_affordance_horizontal_offset", "dimen", mContext.getPackageName()));

startButton.getViewTreeObserver().addOnGlobalLayoutListener(() -> ((ViewGroup.MarginLayoutParams) mIndicationTextView.getLayoutParams()).setMarginStart(startButton.getVisibility() == View.VISIBLE ? offset : 0));
endButton.getViewTreeObserver().addOnGlobalLayoutListener(() -> ((ViewGroup.MarginLayoutParams) mIndicationTextView.getLayoutParams()).setMarginEnd(endButton.getVisibility() == View.VISIBLE ? offset : 0));
} catch (Throwable ignored) {
}

updateWallpaper();
}
Expand All @@ -152,7 +156,9 @@ protected void afterHookedMethod(MethodHookParam param) {
}
});

Class<?> NotificationPanelViewControllerClass = findClass(SYSTEMUI_PACKAGE + ".shade.NotificationPanelViewController", lpparam.classLoader);
Class<?> NotificationPanelViewControllerClass = findClassIfExists(SYSTEMUI_PACKAGE + ".shade.NotificationPanelViewController", lpparam.classLoader);
if (NotificationPanelViewControllerClass == null)
NotificationPanelViewControllerClass = findClass(SYSTEMUI_PACKAGE + ".statusbar.phone.NotificationPanelViewController", lpparam.classLoader);

hookAllMethods(NotificationPanelViewControllerClass, "onFinishInflate", new XC_MethodHook() {
@Override
Expand Down Expand Up @@ -213,36 +219,38 @@ private void updateWallpaper() {
File Android = new File(Environment.getExternalStorageDirectory() + "/Android");

if (Android.isDirectory()) {
try {
ImageDecoder.Source backgroundImg = ImageDecoder.createSource(new File(Environment.getExternalStorageDirectory() + "/.iconify_files/depth_wallpaper_bg.png"));
ImageDecoder.Source foregroundImg = ImageDecoder.createSource(new File(Environment.getExternalStorageDirectory() + "/.iconify_files/depth_wallpaper_fg.png"));
new Handler(Looper.getMainLooper()).post(() -> {
try {
ImageDecoder.Source backgroundImg = ImageDecoder.createSource(new File(Environment.getExternalStorageDirectory() + "/.iconify_files/depth_wallpaper_bg.png"));
ImageDecoder.Source foregroundImg = ImageDecoder.createSource(new File(Environment.getExternalStorageDirectory() + "/.iconify_files/depth_wallpaper_fg.png"));

Drawable backgroundDrawable = ImageDecoder.decodeDrawable(backgroundImg);
Drawable foregroundDrawable = ImageDecoder.decodeDrawable(foregroundImg);
Drawable backgroundDrawable = ImageDecoder.decodeDrawable(backgroundImg);
Drawable foregroundDrawable = ImageDecoder.decodeDrawable(foregroundImg);

mDepthWallpaperBackground.setImageDrawable(backgroundDrawable);
mDepthWallpaperBackground.setClipToOutline(true);
mDepthWallpaperBackground.setScaleType(ImageView.ScaleType.CENTER_CROP);
mDepthWallpaperBackground.setImageDrawable(backgroundDrawable);
mDepthWallpaperBackground.setClipToOutline(true);
mDepthWallpaperBackground.setScaleType(ImageView.ScaleType.CENTER_CROP);

boolean zoomWallpaper = !Xprefs.getBoolean(UNZOOM_DEPTH_WALLPAPER, false);
boolean zoomWallpaper = !Xprefs.getBoolean(UNZOOM_DEPTH_WALLPAPER, false);

if (zoomWallpaper) {
mDepthWallpaperBackground.setScaleX(1.1f);
mDepthWallpaperBackground.setScaleY(1.1f);
}
if (zoomWallpaper) {
mDepthWallpaperBackground.setScaleX(1.1f);
mDepthWallpaperBackground.setScaleY(1.1f);
}

mDepthWallpaperForeground.setImageDrawable(foregroundDrawable);
mDepthWallpaperForeground.setClipToOutline(true);
mDepthWallpaperForeground.setScaleType(ImageView.ScaleType.CENTER_CROP);
mDepthWallpaperForeground.setImageDrawable(foregroundDrawable);
mDepthWallpaperForeground.setClipToOutline(true);
mDepthWallpaperForeground.setScaleType(ImageView.ScaleType.CENTER_CROP);

if (zoomWallpaper) {
mDepthWallpaperForeground.setScaleX(1.1f);
mDepthWallpaperForeground.setScaleY(1.1f);
}
if (zoomWallpaper) {
mDepthWallpaperForeground.setScaleX(1.1f);
mDepthWallpaperForeground.setScaleY(1.1f);
}

mDepthWallpaperLayout.setVisibility(View.VISIBLE);
} catch (Throwable ignored) {
}
mDepthWallpaperLayout.setVisibility(View.VISIBLE);
} catch (Throwable ignored) {
}
});

executor.shutdown();
executor.shutdownNow();
Expand Down

0 comments on commit a9c6fbe

Please sign in to comment.