文件夹打开全屏透明加上背景
This commit is contained in:
@@ -24,15 +24,24 @@ import android.animation.Animator;
|
||||
import android.animation.AnimatorListenerAdapter;
|
||||
import android.animation.AnimatorSet;
|
||||
import android.annotation.SuppressLint;
|
||||
import android.app.WallpaperManager;
|
||||
import android.appwidget.AppWidgetHostView;
|
||||
import android.content.Context;
|
||||
import android.content.res.Resources;
|
||||
import android.graphics.Bitmap;
|
||||
import android.graphics.Canvas;
|
||||
import android.graphics.Path;
|
||||
import android.graphics.Rect;
|
||||
import android.graphics.drawable.BitmapDrawable;
|
||||
import android.graphics.drawable.Drawable;
|
||||
import android.renderscript.Allocation;
|
||||
import android.renderscript.Element;
|
||||
import android.renderscript.RenderScript;
|
||||
import android.renderscript.ScriptIntrinsicBlur;
|
||||
import android.text.InputType;
|
||||
import android.text.Selection;
|
||||
import android.util.AttributeSet;
|
||||
import android.util.DisplayMetrics;
|
||||
import android.util.Log;
|
||||
import android.util.Pair;
|
||||
import android.view.FocusFinder;
|
||||
@@ -40,6 +49,7 @@ import android.view.KeyEvent;
|
||||
import android.view.MotionEvent;
|
||||
import android.view.View;
|
||||
import android.view.ViewDebug;
|
||||
import android.view.WindowManager;
|
||||
import android.view.accessibility.AccessibilityEvent;
|
||||
import android.view.animation.AnimationUtils;
|
||||
import android.view.inputmethod.EditorInfo;
|
||||
@@ -471,6 +481,56 @@ public class Folder extends AbstractFloatingView implements ClipPathView, DragSo
|
||||
}
|
||||
return folderCount >= MIN_FOLDERS_FOR_HARDWARE_OPTIMIZATION;
|
||||
}
|
||||
public Bitmap blur(Bitmap image) {
|
||||
int width = Math.round(image.getWidth() * 0.4f);
|
||||
int height = Math.round(image.getHeight() * 0.4f);
|
||||
Bitmap inputBitmap = Bitmap.createScaledBitmap(image, width, height, false);
|
||||
Bitmap outputBitmap = Bitmap.createBitmap(inputBitmap);
|
||||
RenderScript rs = RenderScript.create(getContext());
|
||||
ScriptIntrinsicBlur blurScript = ScriptIntrinsicBlur.create(rs, Element.U8_4(rs));
|
||||
Allocation tmpIn = Allocation.createFromBitmap(rs, inputBitmap);
|
||||
Allocation tmpOut = Allocation.createFromBitmap(rs, outputBitmap);
|
||||
blurScript.setRadius(25f);
|
||||
blurScript.setInput(tmpIn);
|
||||
blurScript.forEach(tmpOut);
|
||||
tmpOut.copyTo(outputBitmap);
|
||||
return outputBitmap;
|
||||
}
|
||||
|
||||
public Bitmap getWallpaperBg() {
|
||||
WallpaperManager wallpaperManager = WallpaperManager.getInstance(getContext());
|
||||
Drawable wallpaperDrawable = wallpaperManager.getDrawable();
|
||||
Bitmap bm = ((BitmapDrawable) wallpaperDrawable).getBitmap();
|
||||
Bitmap bitmap = cropImage(bm);
|
||||
return bitmap;
|
||||
}
|
||||
|
||||
private Bitmap cropImage(Bitmap oldBitmap){
|
||||
WindowManager wm = (WindowManager) getContext().getSystemService(Context.WINDOW_SERVICE);
|
||||
DisplayMetrics dm = new DisplayMetrics();
|
||||
wm.getDefaultDisplay().getRealMetrics(dm);
|
||||
int width = dm.widthPixels; // 屏幕宽度(像素)1200
|
||||
int height = dm.heightPixels; // 屏幕高度(像素)1920
|
||||
int picWidth = oldBitmap.getWidth();
|
||||
int picHeight = oldBitmap.getHeight();
|
||||
float wScala = (float) height/width;
|
||||
float bScala = (float) picHeight/picWidth;
|
||||
int newPicWidth;
|
||||
int newpicHeight;
|
||||
Bitmap bitmap = null;
|
||||
if (wScala>bScala){
|
||||
newPicWidth = (int) (picWidth / wScala);
|
||||
newpicHeight = picHeight;
|
||||
bitmap =Bitmap.createBitmap(oldBitmap,(newPicWidth - width)/2 ,0 , newPicWidth , newpicHeight);
|
||||
}else {
|
||||
newPicWidth = picWidth;
|
||||
newpicHeight =(int) (picHeight * wScala);
|
||||
bitmap =Bitmap.createBitmap(oldBitmap,0,(picHeight - newpicHeight) / 2 , newPicWidth , newpicHeight);
|
||||
}
|
||||
return bitmap;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Opens the user folder described by the specified tag. The opening of the folder
|
||||
@@ -478,6 +538,7 @@ public class Folder extends AbstractFloatingView implements ClipPathView, DragSo
|
||||
* is played.
|
||||
*/
|
||||
public void animateOpen() {
|
||||
Bitmap bm = blur(getWallpaperBg());
|
||||
Folder openFolder = getOpen(mLauncher);
|
||||
if (openFolder != null && openFolder != this) {
|
||||
// Close any open folder before opening a folder.
|
||||
@@ -487,6 +548,7 @@ public class Folder extends AbstractFloatingView implements ClipPathView, DragSo
|
||||
mIsOpen = true;
|
||||
|
||||
DragLayer dragLayer = mLauncher.getDragLayer();
|
||||
dragLayer.setBackground(new BitmapDrawable(bm));
|
||||
// Just verify that the folder hasn't already been added to the DragLayer.
|
||||
// There was a one-off crash where the folder had a parent already.
|
||||
if (getParent() == null) {
|
||||
@@ -572,6 +634,11 @@ public class Folder extends AbstractFloatingView implements ClipPathView, DragSo
|
||||
}
|
||||
|
||||
mContent.verifyVisibleHighResIcons(mContent.getNextPage());
|
||||
/* 隐藏workspace和HotSeat begin */
|
||||
mLauncher.getWorkspace().setVisibility(View.GONE);
|
||||
mLauncher.getHotseat().setVisibility(View.GONE);
|
||||
mLauncher.getIndicatorDots().setVisibility(View.GONE);
|
||||
/* 隐藏workspace和HotSeat 0000009 end */
|
||||
}
|
||||
|
||||
public void beginExternalDrag() {
|
||||
@@ -616,6 +683,9 @@ public class Folder extends AbstractFloatingView implements ClipPathView, DragSo
|
||||
// longer occludes the workspace items
|
||||
mLauncher.getDragLayer().sendAccessibilityEvent(
|
||||
AccessibilityEvent.TYPE_WINDOW_STATE_CHANGED);
|
||||
mLauncher.getWorkspace().setVisibility(View.VISIBLE);
|
||||
mLauncher.getHotseat().setVisibility(View.VISIBLE);
|
||||
mLauncher.getIndicatorDots().setVisibility(View.VISIBLE);
|
||||
}
|
||||
|
||||
private void animateClosed() {
|
||||
@@ -641,6 +711,7 @@ public class Folder extends AbstractFloatingView implements ClipPathView, DragSo
|
||||
DragLayer parent = (DragLayer) getParent();
|
||||
if (parent != null) {
|
||||
parent.removeView(this);
|
||||
parent.setBackground(null);
|
||||
}
|
||||
mDragController.removeDropTarget(this);
|
||||
clearFocus();
|
||||
@@ -955,8 +1026,10 @@ public class Folder extends AbstractFloatingView implements ClipPathView, DragSo
|
||||
|
||||
lp.width = width;
|
||||
lp.height = height;
|
||||
lp.x = left;
|
||||
lp.y = top;
|
||||
// lp.x = left;
|
||||
// lp.y = top;
|
||||
lp.x = (grid.availableWidthPx - getFolderWidth()) / 2;
|
||||
lp.y = (grid.availableHeightPx - getFolderHeight()) / 2;
|
||||
}
|
||||
|
||||
public float getPivotXForIconAnimation() {
|
||||
|
||||
@@ -85,7 +85,7 @@ public class FolderAnimationManager {
|
||||
mFolder = folder;
|
||||
mContent = folder.mContent;
|
||||
mFolderBackground = (GradientDrawable) mFolder.getBackground();
|
||||
|
||||
mFolderBackground.setAlpha(64);
|
||||
mFolderIcon = folder.mFolderIcon;
|
||||
mPreviewBackground = mFolderIcon.mBackground;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user