Skip to content

Commit de91c4c

Browse files
author
zhangqinghua.wanjian
committed
no message
1 parent 8ce3649 commit de91c4c

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

53 files changed

+2282
-3409
lines changed

app/src/main/AndroidManifest.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
android:testOnly="false"
1313
android:theme="@style/AppTheme">
1414
<activity android:name=".MainActivity"
15-
android:hardwareAccelerated="false">
15+
android:hardwareAccelerated="true">
1616
<intent-filter>
1717
<action android:name="android.intent.action.MAIN" />
1818

saklib/src/main/java/com/wanjian/sak/SAK.java

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,16 @@
99

1010
import com.wanjian.sak.config.Config;
1111
import com.wanjian.sak.layer.impl.ActivityNameLayerView;
12+
import com.wanjian.sak.layer.impl.BackgroundColorLayer;
13+
import com.wanjian.sak.layer.impl.BitmapWidthHeightLayer;
1214
import com.wanjian.sak.layer.impl.BorderLayer;
1315
import com.wanjian.sak.layer.impl.FragmentNameLayer;
1416
import com.wanjian.sak.layer.impl.GridLayer;
1517
import com.wanjian.sak.layer.impl.HorizontalMeasureView;
1618
import com.wanjian.sak.layer.impl.MarginLayer;
1719
import com.wanjian.sak.layer.impl.PaddingLayer;
1820
import com.wanjian.sak.layer.impl.RelativeLayerView;
21+
import com.wanjian.sak.layer.impl.ScalpelFrameLayout;
1922
import com.wanjian.sak.layer.impl.TakeColorLayer;
2023
import com.wanjian.sak.layer.impl.TextColorLayer;
2124
import com.wanjian.sak.layer.impl.TextSizeLayer;
@@ -38,7 +41,7 @@ public static void init(Application application, Config config) {
3841
return;
3942
}
4043

41-
if (application.getApplicationInfo().targetSdkVersion >= Build.VERSION_CODES.M && !Settings.canDrawOverlays(application)) {
44+
if (application.getApplicationInfo().targetSdkVersion >= Build.VERSION_CODES.M&&Build.VERSION.SDK_INT>=Build.VERSION_CODES.M && !Settings.canDrawOverlays(application)) {
4245
// if (ContextCompat.checkSelfPermission(application, Manifest.permission.SYSTEM_ALERT_WINDOW) != PackageManager.PERMISSION_GRANTED) {
4346
Toast.makeText(application, "需要悬浮窗权限才能使用SwissArmyKnife", Toast.LENGTH_LONG).show();
4447
Intent intent = new Intent(Settings.ACTION_MANAGE_OVERLAY_PERMISSION);
@@ -62,6 +65,7 @@ public static void init(Application application, Config config) {
6265
.addLayer(WidthHeightLayer.class, application.getDrawable(R.drawable.sak_width_height_icon), application.getString(R.string.sak_width_height))
6366
.addLayer(TextColorLayer.class, application.getDrawable(R.drawable.sak_text_color_icon), application.getString(R.string.sak_txt_color))
6467
.addLayer(TextSizeLayer.class, application.getDrawable(R.drawable.sak_text_size_icon), application.getString(R.string.sak_txt_size))
68+
.addLayer(BackgroundColorLayer.class, application.getDrawable(R.drawable.sak_background_color_icon), application.getString(R.string.sak_bag_color))
6569
.addLayer(ActivityNameLayerView.class, application.getDrawable(R.drawable.sak_page_name_icon), application.getString(R.string.sak_activity_name))
6670
.addLayer(FragmentNameLayer.class, application.getDrawable(R.drawable.sak_page_name_icon), application.getString(R.string.sak_fragment_name))
6771
.addLayer(HorizontalMeasureView.class, application.getDrawable(R.drawable.sak_hori_measure_icon), application.getString(R.string.sak_horizontal_measure))
@@ -71,6 +75,9 @@ public static void init(Application application, Config config) {
7175
.addLayer(TreeView.class, application.getDrawable(R.drawable.sak_layout_tree_icon), application.getString(R.string.sak_layout_tree))
7276
.addLayer(RelativeLayerView.class, application.getDrawable(R.drawable.sak_relative_distance_icon), application.getString(R.string.sak_relative_distance))
7377
.addLayer(TranslationLayerView.class, application.getDrawable(R.drawable.sak_drag_icon), application.getString(R.string.sak_translation_view))
78+
.addLayer(ScalpelFrameLayout.class, application.getDrawable(R.drawable.sak_layer_icon), "Scalpel")
79+
// .addLayer(ViewDrawPerformLayer.class, application.getDrawable(R.drawable.sak_performance_icon),application.getString(R.string.sak_performance) )
80+
.addLayer(BitmapWidthHeightLayer.class, application.getDrawable(R.drawable.sak_img_size),application.getString(R.string.sak_image_w_h) )
7481
.build();
7582
}
7683
sScaffold.install(application, config);

saklib/src/main/java/com/wanjian/sak/config/Config.java

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88
import com.wanjian.sak.converter.Px2DpSizeConverter;
99
import com.wanjian.sak.converter.Px2SpSizeConverter;
1010
import com.wanjian.sak.filter.ViewFilter;
11-
import com.wanjian.sak.layer.AbsLayer;
1211
import com.wanjian.sak.layer.Layer;
1312
import com.wanjian.sak.utils.Check;
1413

@@ -116,12 +115,12 @@ public Build addSizeConverter(ISizeConverter sizeConverter) {
116115
return this;
117116
}
118117

119-
public Build addLayerView(AbsLayer layerView) {
120-
Check.isNull(layerView, "layerView");
121-
// mDefaultLayerViews.clear();
122-
// mCustomerLayerViews.add(layerView);
123-
return this;
124-
}
118+
// public Build addLayerView(AbsLayer layerView) {
119+
// Check.isNull(layerView, "layerView");
120+
//// mDefaultLayerViews.clear();
121+
//// mCustomerLayerViews.add(layerView);
122+
// return this;
123+
// }
125124

126125
public Build viewFilter(ViewFilter viewFilter) {
127126
Check.isNull(viewFilter, "viewFilter");

saklib/src/main/java/com/wanjian/sak/filter/ViewFilter.java

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22

33
import android.view.View;
44

5-
import com.wanjian.sak.view.RootContainerView;
65

76
/**
87
* Created by wanjian on 2017/2/20.
@@ -18,9 +17,6 @@ protected boolean apply(View view) {
1817

1918

2019
public final boolean filter(View view) {
21-
if (view instanceof RootContainerView) {
22-
return false;
23-
}
2420
return apply(view);
2521
}
2622

Lines changed: 147 additions & 147 deletions
Original file line numberDiff line numberDiff line change
@@ -1,147 +1,147 @@
1-
package com.wanjian.sak.layer;
2-
3-
import android.content.Context;
4-
import android.graphics.Canvas;
5-
import android.graphics.drawable.Drawable;
6-
import android.view.View;
7-
import android.view.ViewGroup;
8-
import android.view.WindowManager;
9-
import android.widget.FrameLayout;
10-
11-
import com.wanjian.sak.config.Config;
12-
import com.wanjian.sak.converter.ISizeConverter;
13-
import com.wanjian.sak.filter.ViewFilter;
14-
15-
/**
16-
* Created by wanjian on 2017/3/9.
17-
*/
18-
19-
public abstract class AbsLayer extends FrameLayout {
20-
private boolean mEnable;
21-
private Config config;
22-
23-
public AbsLayer(Context context) {
24-
super(context);
25-
}
26-
27-
public void attachConfig(Config config) {
28-
this.config = config;
29-
}
30-
31-
public String description(){
32-
return null;
33-
}
34-
35-
public Drawable icon(){
36-
return null;
37-
}
38-
39-
public final void enable(boolean enable) {
40-
this.mEnable = enable;
41-
onStateChange(enable);
42-
}
43-
44-
protected void onStateChange(boolean isEnable) {
45-
46-
}
47-
48-
protected Config getConfig() {
49-
return config;
50-
}
51-
52-
public final boolean isEnable() {
53-
return mEnable;
54-
}
55-
56-
protected boolean isClipDraw() {
57-
return config.isClipDraw();
58-
}
59-
60-
protected int getStartRange() {
61-
return config.getStartRange();
62-
}
63-
64-
protected int getEndRange() {
65-
return config.getEndRange();
66-
}
67-
68-
public final void uiUpdate(Canvas canvas, View view) {
69-
if (!isEnable()) {
70-
return;
71-
}
72-
int count = canvas.save();
73-
onUiUpdate(canvas, view);
74-
canvas.restoreToCount(count);
75-
}
76-
77-
protected void onUiUpdate(Canvas canvas, View rootView) {
78-
79-
}
80-
81-
@Override
82-
protected final void onAttachedToWindow() {
83-
super.onAttachedToWindow();
84-
onAttached(getRootView());
85-
}
86-
87-
protected void onAttached(View rootView) {
88-
}
89-
90-
@Override
91-
protected final void onDetachedFromWindow() {
92-
onDetached(getRootView());
93-
super.onDetachedFromWindow();
94-
}
95-
96-
protected void onDetached(View rootView) {
97-
}
98-
99-
/**
100-
* @param view view
101-
* @return x, y, width,height
102-
*/
103-
protected int[] getLocationAndSize(View view) {
104-
int[] locations = new int[2];
105-
view.getLocationInWindow(locations);
106-
View decorView = view.getRootView();// dialog 内边距
107-
return new int[]{locations[0] - decorView.getPaddingLeft(), locations[1] - decorView.getPaddingTop(), view.getWidth(), view.getHeight()};
108-
}
109-
110-
protected int dp2px(int dip) {
111-
float density = getRootView().getResources().getDisplayMetrics().density;
112-
return (int) (dip * density + 0.5);
113-
}
114-
115-
protected int px2dp(float pxValue) {
116-
final float scale = getRootView().getResources().getDisplayMetrics().density;
117-
return (int) (pxValue / scale + 0.5f);
118-
}
119-
120-
protected ISizeConverter getSizeConverter() {
121-
return ISizeConverter.CONVERTER;
122-
}
123-
124-
protected ViewFilter getViewFilter() {
125-
return ViewFilter.FILTER;
126-
}
127-
128-
protected void showWindow(View view, WindowManager.LayoutParams params) {
129-
WindowManager manager = (WindowManager) getRootView().getContext().getSystemService(Context.WINDOW_SERVICE);
130-
manager.addView(view, params);
131-
}
132-
133-
protected void updateWindow(View view, WindowManager.LayoutParams params) {
134-
WindowManager manager = (WindowManager) getRootView().getContext().getSystemService(Context.WINDOW_SERVICE);
135-
manager.updateViewLayout(view, params);
136-
}
137-
138-
protected void removeWindow(View view) {
139-
WindowManager manager = (WindowManager) getRootView().getContext().getSystemService(Context.WINDOW_SERVICE);
140-
manager.removeViewImmediate(view);
141-
}
142-
143-
public ViewGroup.LayoutParams getLayoutParams(FrameLayout.LayoutParams params) {
144-
return params;
145-
}
146-
147-
}
1+
//package com.wanjian.sak.layer;
2+
//
3+
//import android.content.Context;
4+
//import android.graphics.Canvas;
5+
//import android.graphics.drawable.Drawable;
6+
//import android.view.View;
7+
//import android.view.ViewGroup;
8+
//import android.view.WindowManager;
9+
//import android.widget.FrameLayout;
10+
//
11+
//import com.wanjian.sak.config.Config;
12+
//import com.wanjian.sak.converter.ISizeConverter;
13+
//import com.wanjian.sak.filter.ViewFilter;
14+
//
15+
///**
16+
// * Created by wanjian on 2017/3/9.
17+
// */
18+
//
19+
//public abstract class AbsLayer extends FrameLayout {
20+
// private boolean mEnable;
21+
// private Config config;
22+
//
23+
// public AbsLayer(Context context) {
24+
// super(context);
25+
// }
26+
//
27+
// public void attachConfig(Config config) {
28+
// this.config = config;
29+
// }
30+
//
31+
// public String description(){
32+
// return null;
33+
// }
34+
//
35+
// public Drawable icon(){
36+
// return null;
37+
// }
38+
//
39+
// public final void enable(boolean enable) {
40+
// this.mEnable = enable;
41+
// onStateChange(enable);
42+
// }
43+
//
44+
// protected void onStateChange(boolean isEnable) {
45+
//
46+
// }
47+
//
48+
// protected Config getConfig() {
49+
// return config;
50+
// }
51+
//
52+
// public final boolean isEnable() {
53+
// return mEnable;
54+
// }
55+
//
56+
// protected boolean isClipDraw() {
57+
// return config.isClipDraw();
58+
// }
59+
//
60+
// protected int getStartRange() {
61+
// return config.getStartRange();
62+
// }
63+
//
64+
// protected int getEndRange() {
65+
// return config.getEndRange();
66+
// }
67+
//
68+
// public final void uiUpdate(Canvas canvas, View view) {
69+
// if (!isEnable()) {
70+
// return;
71+
// }
72+
// int count = canvas.save();
73+
// onUiUpdate(canvas, view);
74+
// canvas.restoreToCount(count);
75+
// }
76+
//
77+
// protected void onUiUpdate(Canvas canvas, View rootView) {
78+
//
79+
// }
80+
//
81+
// @Override
82+
// protected final void onAttachedToWindow() {
83+
// super.onAttachedToWindow();
84+
// onAttached(getRootView());
85+
// }
86+
//
87+
// protected void onAttached(View rootView) {
88+
// }
89+
//
90+
// @Override
91+
// protected final void onDetachedFromWindow() {
92+
// onDetached(getRootView());
93+
// super.onDetachedFromWindow();
94+
// }
95+
//
96+
// protected void onDetached(View rootView) {
97+
// }
98+
//
99+
// /**
100+
// * @param view view
101+
// * @return x, y, width,height
102+
// */
103+
// protected int[] getLocationAndSize(View view) {
104+
// int[] locations = new int[2];
105+
// view.getLocationInWindow(locations);
106+
// View decorView = view.getRootView();// dialog 内边距
107+
// return new int[]{locations[0] - decorView.getPaddingLeft(), locations[1] - decorView.getPaddingTop(), view.getWidth(), view.getHeight()};
108+
// }
109+
//
110+
// protected int dp2px(int dip) {
111+
// float density = getRootView().getResources().getDisplayMetrics().density;
112+
// return (int) (dip * density + 0.5);
113+
// }
114+
//
115+
// protected int px2dp(float pxValue) {
116+
// final float scale = getRootView().getResources().getDisplayMetrics().density;
117+
// return (int) (pxValue / scale + 0.5f);
118+
// }
119+
//
120+
// protected ISizeConverter getSizeConverter() {
121+
// return ISizeConverter.CONVERTER;
122+
// }
123+
//
124+
// protected ViewFilter getViewFilter() {
125+
// return ViewFilter.FILTER;
126+
// }
127+
//
128+
// protected void showWindow(View view, WindowManager.LayoutParams params) {
129+
// WindowManager manager = (WindowManager) getRootView().getContext().getSystemService(Context.WINDOW_SERVICE);
130+
// manager.addView(view, params);
131+
// }
132+
//
133+
// protected void updateWindow(View view, WindowManager.LayoutParams params) {
134+
// WindowManager manager = (WindowManager) getRootView().getContext().getSystemService(Context.WINDOW_SERVICE);
135+
// manager.updateViewLayout(view, params);
136+
// }
137+
//
138+
// protected void removeWindow(View view) {
139+
// WindowManager manager = (WindowManager) getRootView().getContext().getSystemService(Context.WINDOW_SERVICE);
140+
// manager.removeViewImmediate(view);
141+
// }
142+
//
143+
// public ViewGroup.LayoutParams getLayoutParams(FrameLayout.LayoutParams params) {
144+
// return params;
145+
// }
146+
//
147+
//}
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
package com.wanjian.sak.layer;
2+
3+
public interface IClip {
4+
void onClipChange(boolean clip);
5+
}

0 commit comments

Comments
 (0)