mirror of
https://github.com/LawnchairLauncher/lawnchair.git
synced 2026-02-11 06:44:00 +00:00
enhancement blur wallpaper and fixes
- closes : #4999 - closes : #4885 - closes : #4827 - closes : #4187 - closes : #4614 - closes : #4308 - closes : #4757
This commit is contained in:
@@ -447,7 +447,7 @@ dependencies {
|
||||
exclude group: "com.github.skydoves", module: "balloon"
|
||||
}
|
||||
|
||||
implementation("com.github.android:renderscript-intrinsics-replacement-toolkit:b6363490c3")
|
||||
implementation 'io.github.hokofly:hoko-blur:1.5.3'
|
||||
}
|
||||
|
||||
ksp {
|
||||
|
||||
@@ -103,7 +103,7 @@ class PreferenceManager private constructor(private val context: Context) : Base
|
||||
val hotseatQsbStrokeWidth = FloatPref("pref_searchStrokeWidth", 0F, recreate)
|
||||
val enableWallpaperBlur = BoolPref("pref_enableWallpaperBlur", false, recreate)
|
||||
val wallpaperBlur = IntPref("pref_wallpaperBlur", 25, recreate)
|
||||
val wallpaperBlurFactorThreshold = IntPref("pref_wallpaperBlurFactor", 25, recreate)
|
||||
val wallpaperBlurFactorThreshold = FloatPref("pref_wallpaperBlurFactor", 3.0F, recreate)
|
||||
|
||||
val recentsActionScreenshot = BoolPref("pref_recentsActionScreenshot", !isOnePlusStock)
|
||||
val recentsActionShare = BoolPref("pref_recentsActionShare", isOnePlusStock)
|
||||
|
||||
@@ -66,9 +66,8 @@ fun ExperimentalFeaturesPreferences(
|
||||
SliderPreference(
|
||||
label = stringResource(id = R.string.wallpaper_background_blur_factor),
|
||||
adapter = prefs.wallpaperBlurFactorThreshold.getAdapter(),
|
||||
step = 5,
|
||||
valueRange = 0..100,
|
||||
showUnit = "%",
|
||||
step = 1F,
|
||||
valueRange = 0F..10F,
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -38,7 +38,6 @@ import android.net.Uri
|
||||
import android.os.Build
|
||||
import android.os.Looper
|
||||
import android.provider.OpenableColumns
|
||||
import android.util.Log
|
||||
import android.util.Size
|
||||
import android.view.View
|
||||
import android.widget.TextView
|
||||
@@ -52,7 +51,6 @@ import com.android.launcher3.Utilities
|
||||
import com.android.launcher3.util.Executors.MAIN_EXECUTOR
|
||||
import com.android.launcher3.util.Themes
|
||||
import com.android.systemui.shared.system.QuickStepContract
|
||||
import com.google.android.renderscript.Toolkit
|
||||
import com.patrykmichalik.opto.core.firstBlocking
|
||||
import java.util.concurrent.Callable
|
||||
import java.util.concurrent.ExecutionException
|
||||
@@ -287,16 +285,6 @@ fun createRoundedBitmap(color: Int, cornerRadius: Float): Bitmap {
|
||||
return bitmap
|
||||
}
|
||||
|
||||
fun blurBitmap(source: Bitmap, percent: Int, factorThreshold: Int = 25): Bitmap {
|
||||
try {
|
||||
val factor = percent.toFloat().div(100f) * factorThreshold
|
||||
return Toolkit.blur(source, factor.toInt())
|
||||
} catch (e: Exception) {
|
||||
Log.e("LawnchairUtil", "Error bluring bitmap: $e")
|
||||
return source
|
||||
}
|
||||
}
|
||||
|
||||
fun getSignatureHash(context: Context, packageName: String): Long? {
|
||||
return try {
|
||||
val packageInfo = if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.P) {
|
||||
|
||||
10
proguard.pro
vendored
10
proguard.pro
vendored
@@ -22,6 +22,16 @@
|
||||
-dontwarn dalvik.system.CloseGuard
|
||||
-dontwarn lineageos.providers.LineageSettings$System
|
||||
-dontwarn androidx.compose.runtime.PrimitiveSnapshotStateKt
|
||||
-dontwarn androidx.renderscript.Allocation
|
||||
-dontwarn androidx.renderscript.BaseObj
|
||||
-dontwarn androidx.renderscript.Element
|
||||
-dontwarn androidx.renderscript.FieldPacker
|
||||
-dontwarn androidx.renderscript.RSRuntimeException
|
||||
-dontwarn androidx.renderscript.RenderScript
|
||||
-dontwarn androidx.renderscript.Script$LaunchOptions
|
||||
-dontwarn androidx.renderscript.ScriptC
|
||||
-dontwarn androidx.renderscript.ScriptIntrinsicBlur
|
||||
-dontwarn androidx.renderscript.Type
|
||||
|
||||
|
||||
# Common rules.
|
||||
|
||||
@@ -2,23 +2,29 @@ package com.android.launcher3;
|
||||
|
||||
import static com.android.launcher3.config.FeatureFlags.SEPARATE_RECENTS_ACTIVITY;
|
||||
|
||||
import android.app.WallpaperManager;
|
||||
import android.content.Context;
|
||||
import android.graphics.Bitmap;
|
||||
import android.graphics.Canvas;
|
||||
import android.graphics.Color;
|
||||
import android.graphics.Paint;
|
||||
import android.graphics.Rect;
|
||||
import android.graphics.drawable.BitmapDrawable;
|
||||
import android.graphics.drawable.Drawable;
|
||||
import android.util.AttributeSet;
|
||||
import android.view.ViewDebug;
|
||||
import android.view.WindowInsets;
|
||||
|
||||
import com.android.launcher3.graphics.SysUiScrim;
|
||||
import com.android.launcher3.statemanager.StatefulActivity;
|
||||
import com.android.launcher3.uioverrides.ApiWrapper;
|
||||
import com.hoko.blur.HokoBlur;
|
||||
import com.patrykmichalik.opto.core.PreferenceExtensionsKt;
|
||||
import com.android.launcher3.util.window.WindowManagerProxy;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
import app.lawnchair.LawnchairApp;
|
||||
import app.lawnchair.preferences.PreferenceManager;
|
||||
import app.lawnchair.preferences2.PreferenceManager2;
|
||||
|
||||
public class LauncherRootView extends InsettableFrameLayout {
|
||||
@@ -39,12 +45,69 @@ public class LauncherRootView extends InsettableFrameLayout {
|
||||
private final SysUiScrim mSysUiScrim;
|
||||
private final boolean mEnableTaskbarOnPhone;
|
||||
|
||||
private final PreferenceManager pref;
|
||||
|
||||
public LauncherRootView(Context context, AttributeSet attrs) {
|
||||
super(context, attrs);
|
||||
mActivity = StatefulActivity.fromContext(context);
|
||||
mSysUiScrim = new SysUiScrim(this);
|
||||
PreferenceManager2 prefs2 = PreferenceManager2.getInstance(getContext());
|
||||
mEnableTaskbarOnPhone = PreferenceExtensionsKt.firstBlocking(prefs2.getEnableTaskbarOnPhone());
|
||||
|
||||
pref = PreferenceManager.getInstance(getContext());
|
||||
|
||||
if (pref.getEnableWallpaperBlur().get()){
|
||||
setUpBlur(context);
|
||||
}
|
||||
}
|
||||
|
||||
private void setUpBlur(Context context) {
|
||||
var display = mActivity.getDeviceProfile();
|
||||
int width = display.widthPx;
|
||||
int height = display.heightPx;
|
||||
|
||||
var wallpaper = getScaledWallpaperDrawable(width, height);
|
||||
if (wallpaper == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
Bitmap originalBitmap = Bitmap.createBitmap(width, height, Bitmap.Config.ARGB_8888);
|
||||
Canvas canvas = new Canvas(originalBitmap);
|
||||
|
||||
wallpaper.setBounds(0, 0, width, height);
|
||||
wallpaper.draw(canvas);
|
||||
|
||||
Paint paint = new Paint();
|
||||
paint.setColor(Color.WHITE);
|
||||
paint.setAlpha((int) (0.2 * 255));
|
||||
canvas.drawRect(0, 0, width, height, paint);
|
||||
|
||||
Bitmap blurredBitmap = HokoBlur.with(context)
|
||||
.forceCopy(true)
|
||||
.scheme(HokoBlur.SCHEME_OPENGL)
|
||||
.sampleFactor(pref.getWallpaperBlurFactorThreshold().get())
|
||||
.radius(pref.getWallpaperBlur().get())
|
||||
.blur(originalBitmap);
|
||||
|
||||
setBackground(new BitmapDrawable(getContext().getResources(), blurredBitmap));
|
||||
}
|
||||
|
||||
private Drawable getScaledWallpaperDrawable(int width, int height) {
|
||||
WallpaperManager wallpaperManager = WallpaperManager.getInstance(getContext());
|
||||
Drawable wallpaperDrawable = wallpaperManager.getDrawable();
|
||||
|
||||
if (wallpaperDrawable != null) {
|
||||
Bitmap originalBitmap = Bitmap.createBitmap(
|
||||
width, height, Bitmap.Config.ARGB_8888
|
||||
);
|
||||
Canvas canvas = new Canvas(originalBitmap);
|
||||
|
||||
wallpaperDrawable.setBounds(0, 0, width, height);
|
||||
wallpaperDrawable.draw(canvas);
|
||||
|
||||
return new BitmapDrawable(getContext().getResources(), originalBitmap);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
private void handleSystemWindowInsets(Rect insets) {
|
||||
@@ -65,7 +128,6 @@ public class LauncherRootView extends InsettableFrameLayout {
|
||||
insets = WindowManagerProxy.INSTANCE.get(getContext())
|
||||
.normalizeWindowInsets(getContext(), insets, mTempRect);
|
||||
handleSystemWindowInsets(mTempRect);
|
||||
// computeGestureExclusionRect();
|
||||
return insets;
|
||||
}
|
||||
|
||||
@@ -114,7 +176,6 @@ public class LauncherRootView extends InsettableFrameLayout {
|
||||
@Override
|
||||
protected void onLayout(boolean changed, int l, int t, int r, int b) {
|
||||
super.onLayout(changed, l, t, r, b);
|
||||
// computeGestureExclusionRect();
|
||||
mSysUiScrim.setSize(r - l, b - t);
|
||||
}
|
||||
|
||||
|
||||
@@ -149,6 +149,7 @@ import app.lawnchair.preferences2.PreferenceManager2;
|
||||
import app.lawnchair.smartspace.SmartspaceAppWidgetProvider;
|
||||
import app.lawnchair.smartspace.model.LawnchairSmartspace;
|
||||
import app.lawnchair.smartspace.model.SmartspaceMode;
|
||||
import app.lawnchair.theme.drawable.DrawableTokens;
|
||||
import app.lawnchair.util.LawnchairUtilsKt;
|
||||
|
||||
/**
|
||||
@@ -351,20 +352,6 @@ public class Workspace<T extends View & PageIndicator> extends PagedView<T>
|
||||
setMotionEventSplittingEnabled(true);
|
||||
setOnTouchListener(new WorkspaceTouchListener(mLauncher, this));
|
||||
mStatsLogManager = StatsLogManager.newInstance(context);
|
||||
|
||||
if (mPreferenceManger.getEnableWallpaperBlur().get() && mWallpaperManager.getDrawable() != null) {
|
||||
var blurWallpaper = mPreferenceManger.getWallpaperBlur().get();
|
||||
var blurThreshold = mPreferenceManger.getWallpaperBlurFactorThreshold().get();
|
||||
var wallpaperBitmap = mWallpaperManager.getDrawable();
|
||||
try {
|
||||
mWallpaperManager.setBitmap(
|
||||
LawnchairUtilsKt.blurBitmap(toBitmap(wallpaperBitmap), blurWallpaper, blurThreshold), null,
|
||||
true, WallpaperManager.FLAG_SYSTEM);
|
||||
mWallpaperManager.forgetLoadedWallpaper();
|
||||
} catch (Exception ex) {
|
||||
Log.e(TAG, "error failed bluring wallpaper");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -681,10 +668,6 @@ public class Workspace<T extends View & PageIndicator> extends PagedView<T>
|
||||
* Initializes and binds the first page
|
||||
*/
|
||||
public void bindAndInitFirstWorkspaceScreen() {
|
||||
if (!FeatureFlags.topQsbOnFirstScreenEnabled(mLauncher)) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Add the first page
|
||||
CellLayout firstPage = insertNewWorkspaceScreen(Workspace.FIRST_SCREEN_ID, getChildCount());
|
||||
// Always add a QSB on the first screen.
|
||||
|
||||
@@ -21,6 +21,8 @@ import static android.view.CrossWindowBlurListeners.CROSS_WINDOW_BLUR_SUPPORTED;
|
||||
import android.app.ActivityManager;
|
||||
import android.os.SystemProperties;
|
||||
|
||||
import app.lawnchair.compat.LawnchairQuickstepCompat;
|
||||
|
||||
public abstract class BlurUtils {
|
||||
|
||||
/**
|
||||
@@ -29,7 +31,7 @@ public abstract class BlurUtils {
|
||||
* @return {@code true} when supported.
|
||||
*/
|
||||
public static boolean supportsBlursOnWindows() {
|
||||
return CROSS_WINDOW_BLUR_SUPPORTED && ActivityManager.isHighEndGfx()
|
||||
return LawnchairQuickstepCompat.ATLEAST_R && CROSS_WINDOW_BLUR_SUPPORTED && ActivityManager.isHighEndGfx()
|
||||
&& !SystemProperties.getBoolean("persist.sysui.disableBlur", false);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user