Skip to content

Commit 1aef86e

Browse files
committed
see 12/12 log
1 parent a6242fa commit 1aef86e

File tree

4 files changed

+98
-7
lines changed

4 files changed

+98
-7
lines changed

launcher/app/__bus__.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
{
22
"SubUtilActivity#start": "void com.blankj.subutil.pkg.feature.SubUtilActivity.start(android.content.Context)",
3-
"CoreUtilActivity#start": "void com.blankj.utilcode.pkg.feature.CoreUtilActivity.start(android.content.Context)"
3+
"CoreUtilActivity#start": "void com.blankj.utilcode.pkg.feature.CoreUtilActivity.start(android.content.Context)",
4+
"showDialog": "void com.blankj.launcher.app.UtilsApp.showDialog()"
45
}

launcher/app/src/main/java/com/blankj/launcher/app/UtilsApp.java

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,21 @@
11
package com.blankj.launcher.app;
22

3+
import android.app.Activity;
34
import android.content.Context;
5+
import android.graphics.Bitmap;
6+
import android.graphics.Canvas;
7+
import android.view.View;
8+
import android.view.WindowManager;
9+
import android.widget.ImageView;
410

511
import com.blankj.base.BaseApplication;
12+
import com.blankj.subutil.pkg.helper.DialogHelper;
13+
import com.blankj.utilcode.util.ActivityUtils;
14+
import com.blankj.utilcode.util.AppUtils;
15+
import com.blankj.utilcode.util.BusUtils;
16+
import com.blankj.utilcode.util.ImageUtils;
17+
import com.blankj.utilcode.util.LogUtils;
18+
import com.blankj.utilcode.util.Utils;
619

720
/**
821
* <pre>
@@ -29,6 +42,54 @@ protected void attachBaseContext(Context base) {
2942
public void onCreate() {
3043
super.onCreate();
3144
sInstance = this;
45+
AppUtils.registerAppStatusChangedListener(this, new Utils.OnAppStatusChangedListener() {
46+
@Override
47+
public void onForeground() {
48+
49+
LogUtils.i();
50+
}
51+
52+
@Override
53+
public void onBackground() {
54+
Activity topActivity = ActivityUtils.getTopActivity();
55+
if (topActivity == null) return;
56+
View decorView = topActivity.getWindow().getDecorView();
57+
Bitmap bitmapForView = getBitmapForView(decorView);
58+
Bitmap bitmap = ImageUtils.fastBlur(bitmapForView, 0.125f, 2, true);
59+
60+
61+
WindowManager windowManager = topActivity.getWindowManager();
62+
WindowManager.LayoutParams mParams = new WindowManager.LayoutParams();
63+
64+
mParams.type = WindowManager.LayoutParams.TYPE_APPLICATION_PANEL;
65+
mParams.height = WindowManager.LayoutParams.MATCH_PARENT;
66+
mParams.width = WindowManager.LayoutParams.MATCH_PARENT;
67+
ImageView view = new ImageView(topActivity);
68+
view.setImageBitmap(bitmap);
69+
windowManager.addView(view, mParams);
70+
LogUtils.i();
71+
}
72+
});
73+
}
74+
75+
76+
77+
private Bitmap getBitmapForView(View src) {
78+
Bitmap bitmap = Bitmap.createBitmap(
79+
src.getWidth(),
80+
src.getHeight(),
81+
Bitmap.Config.ARGB_8888
82+
);
83+
84+
Canvas canvas = new Canvas(bitmap);
85+
src.draw(canvas);
86+
87+
return bitmap;
88+
}
89+
90+
@BusUtils.Subscribe(name = "showDialog")
91+
public static void showDialog(){
92+
DialogHelper.showOpenAppSettingDialog();
3293
}
3394
}
3495

launcher/pkg/src/main/java/com/blankj/launcher/pkg/MainActivity.kt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,8 @@ class MainActivity : BaseDrawerActivity() {
5151
launcherMainSubUtilBtn.setOnClickListener {
5252
BusUtils.post<Any>("SubUtilActivity#start", this)
5353
}
54+
55+
BusUtils.post<Any>("showDialog")
5456
}
5557

5658
override fun doBusiness() {

utilcode/lib/src/main/java/com/blankj/utilcode/util/ImageUtils.java

Lines changed: 33 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1108,17 +1108,16 @@ public static Bitmap fastBlur(final Bitmap src,
11081108
@FloatRange(
11091109
from = 0, to = 25, fromInclusive = false
11101110
) final float radius) {
1111-
return fastBlur(src, scale, radius, false);
1111+
return fastBlur(src, scale, radius, false, false);
11121112
}
11131113

11141114
/**
11151115
* Return the blur bitmap fast.
11161116
* <p>zoom out, blur, zoom in</p>
11171117
*
1118-
* @param src The source of bitmap.
1119-
* @param scale The scale(0...1).
1120-
* @param radius The radius(0...25).
1121-
* @param recycle True to recycle the source of bitmap, false otherwise.
1118+
* @param src The source of bitmap.
1119+
* @param scale The scale(0...1).
1120+
* @param radius The radius(0...25).
11221121
* @return the blur bitmap
11231122
*/
11241123
public static Bitmap fastBlur(final Bitmap src,
@@ -1129,6 +1128,29 @@ public static Bitmap fastBlur(final Bitmap src,
11291128
from = 0, to = 25, fromInclusive = false
11301129
) final float radius,
11311130
final boolean recycle) {
1131+
return fastBlur(src, scale, radius, recycle, false);
1132+
}
1133+
1134+
/**
1135+
* Return the blur bitmap fast.
1136+
* <p>zoom out, blur, zoom in</p>
1137+
*
1138+
* @param src The source of bitmap.
1139+
* @param scale The scale(0...1).
1140+
* @param radius The radius(0...25).
1141+
* @param recycle True to recycle the source of bitmap, false otherwise.
1142+
* @param isReturnScale True to return the scale blur bitmap, false otherwise.
1143+
* @return the blur bitmap
1144+
*/
1145+
public static Bitmap fastBlur(final Bitmap src,
1146+
@FloatRange(
1147+
from = 0, to = 1, fromInclusive = false
1148+
) final float scale,
1149+
@FloatRange(
1150+
from = 0, to = 25, fromInclusive = false
1151+
) final float radius,
1152+
final boolean recycle,
1153+
final boolean isReturnScale) {
11321154
if (isEmptyBitmap(src)) return null;
11331155
int width = src.getWidth();
11341156
int height = src.getHeight();
@@ -1152,7 +1174,12 @@ public static Bitmap fastBlur(final Bitmap src,
11521174
if (recycle && !src.isRecycled()) src.recycle();
11531175
return scaleBitmap;
11541176
}
1155-
Bitmap ret = Bitmap.createScaledBitmap(scaleBitmap, width, height, true);
1177+
Bitmap ret;
1178+
if (isReturnScale) {
1179+
ret = scaleBitmap;
1180+
} else {
1181+
ret = Bitmap.createScaledBitmap(scaleBitmap, width, height, true);
1182+
}
11561183
if (!scaleBitmap.isRecycled()) scaleBitmap.recycle();
11571184
if (recycle && !src.isRecycled()) src.recycle();
11581185
return ret;

0 commit comments

Comments
 (0)