Skip to content

Commit

Permalink
Extract view tags for better understanding
Browse files Browse the repository at this point in the history
  • Loading branch information
Mahmud0808 committed Sep 23, 2023
1 parent 248ecc5 commit c63f567
Show file tree
Hide file tree
Showing 4 changed files with 51 additions and 27 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,11 @@ public class Preferences {
public static final String HIDE_DATA_DISABLED_ICON = "xposed_hideDataDisabledIcon";
public static final String DEPTH_WALLPAPER_SWITCH = "xposed_depthwallpaper";

// Xposed view tags
public static final String ICONIFY_HEADER_CLOCK_TAG = "iconify_header_clock";
public static final String ICONIFY_LOCKSCREEN_CLOCK_TAG = "iconify_lockscreen_clock";
public static final String ICONIFY_DEPTH_WALLPAPER_TAG = "iconify_depth_wallpaper";

// Battery styles
public static final int BATTERY_STYLE_DEFAULT = 0;
public static final int BATTERY_STYLE_DEFAULT_RLANDSCAPE = 1;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import static com.drdisagree.iconify.common.Const.SYSTEMUI_PACKAGE;
import static com.drdisagree.iconify.common.Preferences.DEPTH_WALLPAPER_SWITCH;
import static com.drdisagree.iconify.common.Preferences.ICONIFY_DEPTH_WALLPAPER_TAG;
import static com.drdisagree.iconify.config.XPrefs.Xprefs;
import static de.robv.android.xposed.XposedBridge.hookAllMethods;
import static de.robv.android.xposed.XposedHelpers.findClass;
Expand Down Expand Up @@ -89,8 +90,19 @@ 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
*/
View blankView = new View(mContext);
blankView.setLayoutParams(new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, 0, 1.0f));

// Remove the existing indication text views from the indication area
((ViewGroup) mTopIndicationView.getParent()).removeView(mTopIndicationView);
((ViewGroup) mLockScreenIndicationView.getParent()).removeView(mLockScreenIndicationView);

// Add the indication text views to the new layout
mIndicationTextView.addView(blankView);
mIndicationTextView.addView(mTopIndicationView);
mIndicationTextView.addView(mLockScreenIndicationView);

Expand All @@ -100,14 +112,13 @@ protected void afterHookedMethod(MethodHookParam param) {
mIndicationArea.addView(mIndicationAreaDupe);

// Get the depth wallpaper layout
String depth_wall_tag = "iconify_depth_wallpaper";
mDepthWallpaperLayout = mIndicationArea.findViewWithTag(depth_wall_tag);
mDepthWallpaperLayout = mIndicationArea.findViewWithTag(ICONIFY_DEPTH_WALLPAPER_TAG);

// Create the depth wallpaper layout if it doesn't exist
if (mDepthWallpaperLayout == null) {
mDepthWallpaperLayout = new FrameLayout(mContext);
mDepthWallpaperLayout.setLayoutParams(new FrameLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT));
mDepthWallpaperLayout.setTag(depth_wall_tag);
mDepthWallpaperLayout.setTag(ICONIFY_DEPTH_WALLPAPER_TAG);
mIndicationAreaDupe.addView(mDepthWallpaperLayout, 0);
}

Expand All @@ -118,7 +129,7 @@ protected void afterHookedMethod(MethodHookParam param) {
mDepthWallpaperForeground.setLayoutParams(new FrameLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT));

mDepthWallpaperLayout.addView(mDepthWallpaperBackground, 0);
mDepthWallpaperLayout.addView(mDepthWallpaperForeground);
mDepthWallpaperLayout.addView(mDepthWallpaperForeground, -1);

// Fix the bottom shortcuts pushing the wallpaper
ImageView startButton = view.findViewById(mContext.getResources().getIdentifier("start_button", "id", mContext.getPackageName()));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
import static com.drdisagree.iconify.common.Preferences.HEADER_CLOCK_SWITCH;
import static com.drdisagree.iconify.common.Preferences.HEADER_CLOCK_TEXT_WHITE;
import static com.drdisagree.iconify.common.Preferences.HEADER_CLOCK_TOPMARGIN;
import static com.drdisagree.iconify.common.Preferences.ICONIFY_HEADER_CLOCK_TAG;
import static com.drdisagree.iconify.config.XPrefs.Xprefs;
import static com.drdisagree.iconify.xposed.HookRes.resparams;
import static de.robv.android.xposed.XposedBridge.hookAllMethods;
Expand Down Expand Up @@ -272,17 +273,16 @@ private void updateClockView() {
}

ViewGroup clockView = HeaderClockStyles.getClock(mContext);
String clock_tag = "iconify_header_clock";
if (mQsClockContainer.findViewWithTag(clock_tag) != null) {
mQsClockContainer.removeView(mQsClockContainer.findViewWithTag(clock_tag));
if (mQsClockContainer.findViewWithTag(ICONIFY_HEADER_CLOCK_TAG) != null) {
mQsClockContainer.removeView(mQsClockContainer.findViewWithTag(ICONIFY_HEADER_CLOCK_TAG));
}
if (clockView != null) {
if (centeredClockView) {
mQsClockContainer.setGravity(Gravity.CENTER);
} else {
mQsClockContainer.setGravity(Gravity.START);
}
clockView.setTag(clock_tag);
clockView.setTag(ICONIFY_HEADER_CLOCK_TAG);
mQsClockContainer.addView(clockView);
mQsClockContainer.requestLayout();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

import static com.drdisagree.iconify.common.Const.SYSTEMUI_PACKAGE;
import static com.drdisagree.iconify.common.Preferences.DEPTH_WALLPAPER_SWITCH;
import static com.drdisagree.iconify.common.Preferences.ICONIFY_DEPTH_WALLPAPER_TAG;
import static com.drdisagree.iconify.common.Preferences.ICONIFY_LOCKSCREEN_CLOCK_TAG;
import static com.drdisagree.iconify.common.Preferences.LSCLOCK_BOTTOMMARGIN;
import static com.drdisagree.iconify.common.Preferences.LSCLOCK_COLOR_CODE;
import static com.drdisagree.iconify.common.Preferences.LSCLOCK_COLOR_SWITCH;
Expand Down Expand Up @@ -146,8 +148,19 @@ 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
*/
View blankView = new View(mContext);
blankView.setLayoutParams(new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, 0, 1.0f));

// Remove the existing indication text views from the indication area
((ViewGroup) mTopIndicationView.getParent()).removeView(mTopIndicationView);
((ViewGroup) mLockScreenIndicationView.getParent()).removeView(mLockScreenIndicationView);

// Add the indication text views to the new layout
mIndicationTextView.addView(blankView);
mIndicationTextView.addView(mTopIndicationView);
mIndicationTextView.addView(mLockScreenIndicationView);

Expand All @@ -157,14 +170,13 @@ protected void afterHookedMethod(MethodHookParam param) {
mIndicationArea.addView(mIndicationAreaDupe);

// Get the depth wallpaper layout
String depth_wall_tag = "iconify_depth_wallpaper";
mClockViewContainer = mIndicationArea.findViewWithTag(depth_wall_tag);
mClockViewContainer = mIndicationArea.findViewWithTag(ICONIFY_DEPTH_WALLPAPER_TAG);

// Create the depth wallpaper layout if it doesn't exist
if (mClockViewContainer == null) {
mClockViewContainer = new FrameLayout(mContext);
mClockViewContainer.setLayoutParams(new FrameLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT));
mClockViewContainer.setTag(depth_wall_tag);
mClockViewContainer.setTag(ICONIFY_DEPTH_WALLPAPER_TAG);
mIndicationAreaDupe.addView(mClockViewContainer, 0);
}

Expand Down Expand Up @@ -214,30 +226,28 @@ public void onReceive(Context context, Intent intent) {
private void updateClockView() {
if (mClockViewContainer == null) return;

ViewGroup clockView = LockscreenClockStyles.getClock(mContext);
String clock_tag = "iconify_lockscreen_clock";
View clockView = LockscreenClockStyles.getClock(mContext);

// Remove existing clock view
if (mClockViewContainer.findViewWithTag(clock_tag) != null) {
mClockViewContainer.removeView(mClockViewContainer.findViewWithTag(clock_tag));
if (mClockViewContainer.findViewWithTag(ICONIFY_LOCKSCREEN_CLOCK_TAG) != null) {
mClockViewContainer.removeView(mClockViewContainer.findViewWithTag(ICONIFY_LOCKSCREEN_CLOCK_TAG));
}

if (clockView != null) {
clockView.setTag(clock_tag);
clockView.setTag(ICONIFY_LOCKSCREEN_CLOCK_TAG);

int idx = 0;
String depth_wall_tag = "iconify_depth_wallpaper";

if (mClockViewContainer.getTag() == depth_wall_tag) {
if (mClockViewContainer.getTag() == ICONIFY_DEPTH_WALLPAPER_TAG) {
/*
If the clock view container is the depth wallpaper container, we need to
add the clock view to the middle of foreground and background images
*/
if (mClockViewContainer.getChildCount() == 2) {
if (mClockViewContainer.getChildCount() > 0) {
idx = 1;
}

// Add a dummy layout to the status view container so that we can move notifications
// Add a dummy layout to the status view container so that we can still move notifications
if (mStatusViewContainer != null) {
String dummy_tag = "dummy_layout";
LinearLayout dummyLayout = mStatusViewContainer.findViewWithTag(dummy_tag);
Expand All @@ -250,22 +260,20 @@ private void updateClockView() {
}

dummyLayout.setLayoutParams(new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, 300));
ViewGroup.MarginLayoutParams clockParams = (ViewGroup.MarginLayoutParams) clockView.getLayoutParams();
((LinearLayout.LayoutParams) clockView.getLayoutParams()).gravity = Gravity.CENTER_VERTICAL;
ViewGroup.MarginLayoutParams params = (ViewGroup.MarginLayoutParams) dummyLayout.getLayoutParams();
params.topMargin = clockParams.topMargin;
params.bottomMargin = clockParams.bottomMargin;
dummyLayout.setLayoutParams(params);

mStatusViewContainer.requestLayout();
ViewGroup.MarginLayoutParams dummyParams = (ViewGroup.MarginLayoutParams) dummyLayout.getLayoutParams();
ViewGroup.MarginLayoutParams clockParams = (ViewGroup.MarginLayoutParams) clockView.getLayoutParams();
dummyParams.topMargin = clockParams.topMargin;
dummyParams.bottomMargin = clockParams.bottomMargin;
dummyLayout.setLayoutParams(dummyParams);
}
}

if (clockView.getParent() != null) {
((ViewGroup) clockView.getParent()).removeView(clockView);
}
mClockViewContainer.addView(clockView, idx);
mClockViewContainer.requestLayout();
}
}
}

0 comments on commit c63f567

Please sign in to comment.