Skip to content

Commit

Permalink
add scalpel
Browse files Browse the repository at this point in the history
  • Loading branch information
yuwei.wang committed Feb 27, 2019
1 parent 6f3074c commit 5fc5981
Show file tree
Hide file tree
Showing 6 changed files with 30 additions and 6 deletions.
1 change: 1 addition & 0 deletions uetool/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ dependencies {
api project(':uetool-base')
// api "me.ele:uetool-base:${versions.release}"
implementation "com.android.support:recyclerview-v7:${versions.supportLibrary}"
implementation 'com.jakewharton.scalpel:scalpel:1.1.2'
}

publish {
Expand Down
32 changes: 26 additions & 6 deletions uetool/src/main/java/me/ele/uetool/UETMenu.java
Original file line number Diff line number Diff line change
Expand Up @@ -10,16 +10,12 @@
import android.content.res.Resources;
import android.graphics.PixelFormat;
import android.os.Build;
import android.view.Gravity;
import android.view.MotionEvent;
import android.view.View;
import android.view.ViewConfiguration;
import android.view.ViewGroup;
import android.view.WindowManager;
import android.view.*;
import android.view.animation.AccelerateDecelerateInterpolator;
import android.view.animation.Interpolator;
import android.widget.FrameLayout;
import android.widget.LinearLayout;
import com.jakewharton.scalpel.ScalpelFrameLayout;

import java.lang.reflect.Field;
import java.util.ArrayList;
Expand Down Expand Up @@ -73,6 +69,30 @@ public void onClick(View v) {
}
}));

subMenus.add(new UETSubMenu.SubMenu(resources.getString(R.string.uet_scalpel), R.drawable.uet_scalpel, new OnClickListener() {
@Override
public void onClick(View view) {
ViewGroup decorView = (ViewGroup) Util.getCurrentActivity().getWindow().getDecorView();
ViewGroup content = decorView.findViewById(android.R.id.content);
View contentChild = content.getChildAt(0);
if (contentChild != null) {
if (contentChild instanceof ScalpelFrameLayout) {
content.removeAllViews();
View originContent = ((ScalpelFrameLayout) contentChild).getChildAt(0);
((ScalpelFrameLayout) contentChild).removeAllViews();
content.addView(originContent);
} else {
content.removeAllViews();
ScalpelFrameLayout frameLayout = new ScalpelFrameLayout(getContext());
frameLayout.setLayerInteractionEnabled(true);
frameLayout.setDrawIds(true);
frameLayout.addView(contentChild);
content.addView(frameLayout);
}
}
}
}));

for (UETSubMenu.SubMenu subMenu : subMenus) {
UETSubMenu uetSubMenu = new UETSubMenu(getContext());
uetSubMenu.update(subMenu);
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions uetool/src/main/res/values-en/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,5 @@
<string name="uet_catch_view">catch</string>
<string name="uet_relative_location">location</string>
<string name="uet_grid">gridding</string>
<string name="uet_scalpel">scalpel</string>
</resources>
1 change: 1 addition & 0 deletions uetool/src/main/res/values-zh/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,5 @@
<string name="uet_catch_view">捕捉控件</string>
<string name="uet_relative_location">相对位置</string>
<string name="uet_grid">网格栅栏</string>
<string name="uet_scalpel">手术刀</string>
</resources>
1 change: 1 addition & 0 deletions uetool/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,5 @@
<string name="uet_catch_view">catch</string>
<string name="uet_relative_location">location</string>
<string name="uet_grid">gridding</string>
<string name="uet_scalpel">scalpel</string>
</resources>

0 comments on commit 5fc5981

Please sign in to comment.