summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/com/android/launcher2/AppWidgetResizeFrame.java6
-rw-r--r--src/com/android/launcher2/Cling.java6
-rw-r--r--src/com/android/launcher2/HolographicLinearLayout.java31
-rw-r--r--src/com/android/launcher2/HolographicViewHelper.java19
-rw-r--r--src/com/android/launcher2/Launcher.java41
-rw-r--r--src/com/android/launcher2/LauncherAppWidgetHostView.java1
-rw-r--r--src/com/android/launcher2/LauncherModel.java13
-rw-r--r--src/com/android/launcher2/Utilities.java2
8 files changed, 60 insertions, 59 deletions
diff --git a/src/com/android/launcher2/AppWidgetResizeFrame.java b/src/com/android/launcher2/AppWidgetResizeFrame.java
index b7943eccc..6d132ebf0 100644
--- a/src/com/android/launcher2/AppWidgetResizeFrame.java
+++ b/src/com/android/launcher2/AppWidgetResizeFrame.java
@@ -5,9 +5,10 @@ import android.animation.ObjectAnimator;
import android.animation.PropertyValuesHolder;
import android.animation.ValueAnimator;
import android.animation.ValueAnimator.AnimatorUpdateListener;
+import android.appwidget.AppWidgetHostView;
import android.appwidget.AppWidgetProviderInfo;
import android.content.Context;
-import android.content.res.Resources;
+import android.graphics.Rect;
import android.view.Gravity;
import android.widget.FrameLayout;
import android.widget.ImageView;
@@ -111,7 +112,8 @@ public class AppWidgetResizeFrame extends FrameLayout {
Gravity.CENTER_HORIZONTAL | Gravity.BOTTOM);
addView(mBottomHandle, lp);
- Launcher.Padding p = mLauncher.getPaddingForWidget(widgetView.getAppWidgetInfo().provider);
+ Rect p = AppWidgetHostView.getDefaultPaddingForWidget(context,
+ widgetView.getAppWidgetInfo().provider, null);
mWidgetPaddingLeft = p.left;
mWidgetPaddingTop = p.top;
mWidgetPaddingRight = p.right;
diff --git a/src/com/android/launcher2/Cling.java b/src/com/android/launcher2/Cling.java
index 9f2758679..32b1de4ed 100644
--- a/src/com/android/launcher2/Cling.java
+++ b/src/com/android/launcher2/Cling.java
@@ -28,7 +28,6 @@ import android.graphics.Rect;
import android.graphics.drawable.Drawable;
import android.util.AttributeSet;
import android.util.DisplayMetrics;
-import android.view.View;
import android.widget.FrameLayout;
import com.android.launcher.R;
@@ -54,8 +53,6 @@ public class Cling extends FrameLayout {
private Drawable mHandTouchGraphic;
private int mPunchThroughGraphicCenterRadius;
private int mAppIconSize;
- private int mTabBarHeight;
- private int mTabBarHorizontalPadding;
private int mButtonBarHeight;
private float mRevealRadius;
private int[] mPositionData;
@@ -89,9 +86,6 @@ public class Cling extends FrameLayout {
r.getDimensionPixelSize(R.dimen.clingPunchThroughGraphicCenterRadius);
mAppIconSize = r.getDimensionPixelSize(R.dimen.app_icon_size);
mRevealRadius = mAppIconSize * 1f;
- mTabBarHeight = r.getDimensionPixelSize(R.dimen.apps_customize_tab_bar_height);
- mTabBarHorizontalPadding =
- r.getDimensionPixelSize(R.dimen.toolbar_button_horizontal_padding);
mButtonBarHeight = r.getDimensionPixelSize(R.dimen.button_bar_height);
mErasePaint = new Paint();
diff --git a/src/com/android/launcher2/HolographicLinearLayout.java b/src/com/android/launcher2/HolographicLinearLayout.java
index 986a063e5..c6a8d6aff 100644
--- a/src/com/android/launcher2/HolographicLinearLayout.java
+++ b/src/com/android/launcher2/HolographicLinearLayout.java
@@ -17,13 +17,21 @@
package com.android.launcher2;
import android.content.Context;
+import android.content.res.TypedArray;
import android.graphics.Canvas;
+import android.graphics.drawable.Drawable;
+import android.graphics.drawable.StateListDrawable;
import android.util.AttributeSet;
+import android.widget.ImageView;
import android.widget.LinearLayout;
+import com.android.launcher.R;
+
public class HolographicLinearLayout extends LinearLayout {
private final HolographicViewHelper mHolographicHelper;
+ private ImageView mImageView;
+ private int mImageViewId;
public HolographicLinearLayout(Context context) {
this(context, null);
@@ -36,16 +44,37 @@ public class HolographicLinearLayout extends LinearLayout {
public HolographicLinearLayout(Context context, AttributeSet attrs, int defStyle) {
super(context, attrs, defStyle);
+ TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.HolographicLinearLayout,
+ defStyle, 0);
+ mImageViewId = a.getResourceId(R.styleable.HolographicLinearLayout_sourceImageViewId, -1);
+ a.recycle();
+
setWillNotDraw(false);
mHolographicHelper = new HolographicViewHelper(context);
}
@Override
+ protected void drawableStateChanged() {
+ super.drawableStateChanged();
+
+ if (mImageView != null) {
+ Drawable d = mImageView.getDrawable();
+ if (d instanceof StateListDrawable) {
+ StateListDrawable sld = (StateListDrawable) d;
+ sld.setState(getDrawableState());
+ }
+ }
+ }
+
+ @Override
protected void onDraw(Canvas canvas) {
super.onDraw(canvas);
// One time call to generate the pressed/focused state -- must be called after
// measure/layout
- mHolographicHelper.generatePressedFocusedStates(this);
+ if (mImageView == null) {
+ mImageView = (ImageView) findViewById(mImageViewId);
+ }
+ mHolographicHelper.generatePressedFocusedStates(mImageView);
}
}
diff --git a/src/com/android/launcher2/HolographicViewHelper.java b/src/com/android/launcher2/HolographicViewHelper.java
index c68a5eaad..11e81b4d3 100644
--- a/src/com/android/launcher2/HolographicViewHelper.java
+++ b/src/com/android/launcher2/HolographicViewHelper.java
@@ -20,12 +20,12 @@ import android.content.Context;
import android.content.res.Resources;
import android.graphics.Bitmap;
import android.graphics.Canvas;
+import android.graphics.PorterDuff;
import android.graphics.drawable.StateListDrawable;
-import android.view.View;
+import android.widget.ImageView;
public class HolographicViewHelper {
- private final HolographicOutlineHelper mOutlineHelper = new HolographicOutlineHelper();
private final Canvas mTempCanvas = new Canvas();
private boolean mStatesUpdated;
@@ -39,16 +39,17 @@ public class HolographicViewHelper {
/**
* Generate the pressed/focused states if necessary.
*/
- void generatePressedFocusedStates(View v) {
- if (!mStatesUpdated) {
+ void generatePressedFocusedStates(ImageView v) {
+ if (!mStatesUpdated && v != null) {
mStatesUpdated = true;
- Bitmap outline = createGlowingOutline(v, mTempCanvas, mHighlightColor, mHighlightColor);
+ Bitmap outline = createGlowingOutline(v, mTempCanvas);
FastBitmapDrawable d = new FastBitmapDrawable(outline);
StateListDrawable states = new StateListDrawable();
states.addState(new int[] {android.R.attr.state_pressed}, d);
states.addState(new int[] {android.R.attr.state_focused}, d);
- v.setBackgroundDrawable(states);
+ states.addState(new int[] {}, v.getDrawable());
+ v.setImageDrawable(states);
}
}
@@ -56,16 +57,16 @@ public class HolographicViewHelper {
* Returns a new bitmap to be used as the object outline, e.g. to visualize the drop location.
* Responsibility for the bitmap is transferred to the caller.
*/
- private Bitmap createGlowingOutline(View v, Canvas canvas, int outlineColor, int glowColor) {
+ private Bitmap createGlowingOutline(ImageView v, Canvas canvas) {
final int padding = HolographicOutlineHelper.MAX_OUTER_BLUR_RADIUS;
final Bitmap b = Bitmap.createBitmap(
v.getWidth() + padding, v.getHeight() + padding, Bitmap.Config.ARGB_8888);
canvas.setBitmap(b);
canvas.save();
- v.draw(canvas);
+ v.getDrawable().draw(canvas);
canvas.restore();
- mOutlineHelper.applyOuterBlur(b, canvas, outlineColor);
+ canvas.drawColor(mHighlightColor, PorterDuff.Mode.SRC_IN);
canvas.setBitmap(null);
return b;
diff --git a/src/com/android/launcher2/Launcher.java b/src/com/android/launcher2/Launcher.java
index 0e91cd3af..a62dfa6f7 100644
--- a/src/com/android/launcher2/Launcher.java
+++ b/src/com/android/launcher2/Launcher.java
@@ -29,6 +29,7 @@ import android.app.AlertDialog;
import android.app.Dialog;
import android.app.SearchManager;
import android.app.StatusBarManager;
+import android.appwidget.AppWidgetHostView;
import android.appwidget.AppWidgetManager;
import android.appwidget.AppWidgetProviderInfo;
import android.content.ActivityNotFoundException;
@@ -75,9 +76,9 @@ import android.view.MenuItem;
import android.view.MotionEvent;
import android.view.Surface;
import android.view.View;
+import android.view.View.OnLongClickListener;
import android.view.ViewGroup;
import android.view.WindowManager;
-import android.view.View.OnLongClickListener;
import android.view.accessibility.AccessibilityEvent;
import android.view.animation.AccelerateDecelerateInterpolator;
import android.view.animation.AccelerateInterpolator;
@@ -888,48 +889,12 @@ public final class Launcher extends Activity
}
}
- class Padding {
- int left = 0;
- int right = 0;
- int top = 0;
- int bottom = 0;
- }
-
- Padding getPaddingForWidget(ComponentName component) {
- PackageManager packageManager = getPackageManager();
- Padding p = new Padding();
- android.content.pm.ApplicationInfo appInfo;
-
- try {
- appInfo = packageManager.getApplicationInfo(component.getPackageName(), 0);
- } catch (Exception e) {
- // if we can't find the package, return 0 padding
- return p;
- }
-
- if (appInfo.targetSdkVersion >= Build.VERSION_CODES.ICE_CREAM_SANDWICH) {
- Resources r = getResources();
- // The default padding values are private API currently, but will be added in
- // API level 15. The current values are (8, 8, 8, 8).
- p.left = r.getDimensionPixelSize(com.android.internal.
- R.dimen.default_app_widget_padding_left);
- p.right = r.getDimensionPixelSize(com.android.internal.
- R.dimen.default_app_widget_padding_right);
- p.top = r.getDimensionPixelSize(com.android.internal.
- R.dimen.default_app_widget_padding_top);
- p.bottom = r.getDimensionPixelSize(com.android.internal.
- R.dimen.default_app_widget_padding_bottom);
- }
-
- return p;
- }
-
int[] getSpanForWidget(ComponentName component, int minWidth, int minHeight, int[] spanXY) {
if (spanXY == null) {
spanXY = new int[2];
}
- Padding padding = getPaddingForWidget(component);
+ Rect padding = AppWidgetHostView.getDefaultPaddingForWidget(this, component, null);
// We want to account for the extra amount of padding that we are adding to the widget
// to ensure that it gets the full amount of space that it has requested
int requiredWidth = minWidth + padding.left + padding.right;
diff --git a/src/com/android/launcher2/LauncherAppWidgetHostView.java b/src/com/android/launcher2/LauncherAppWidgetHostView.java
index 1a4a45e5e..71860f362 100644
--- a/src/com/android/launcher2/LauncherAppWidgetHostView.java
+++ b/src/com/android/launcher2/LauncherAppWidgetHostView.java
@@ -27,7 +27,6 @@ import android.view.ViewConfiguration;
import android.view.ViewGroup;
import com.android.launcher.R;
-import com.android.launcher2.Launcher.Padding;
/**
* {@inheritDoc}
diff --git a/src/com/android/launcher2/LauncherModel.java b/src/com/android/launcher2/LauncherModel.java
index c06bc0c31..1755903ec 100644
--- a/src/com/android/launcher2/LauncherModel.java
+++ b/src/com/android/launcher2/LauncherModel.java
@@ -28,7 +28,9 @@ import android.content.Context;
import android.content.Intent;
import android.content.Intent.ShortcutIconResource;
import android.content.pm.ActivityInfo;
+import android.content.pm.PackageInfo;
import android.content.pm.PackageManager;
+import android.content.pm.PackageManager.NameNotFoundException;
import android.content.pm.ResolveInfo;
import android.content.res.Configuration;
import android.content.res.Resources;
@@ -1629,6 +1631,17 @@ public class LauncherModel extends BroadcastReceiver {
return null;
}
+ try {
+ PackageInfo pi = manager.getPackageInfo(componentName.getPackageName(), 0);
+ if (!pi.applicationInfo.enabled) {
+ // If we return null here, the corresponding item will be removed from the launcher
+ // db and will not appear in the workspace.
+ return null;
+ }
+ } catch (NameNotFoundException e) {
+ Log.d(TAG, "getPackInfo failed for package " + componentName.getPackageName());
+ }
+
// TODO: See if the PackageManager knows about this case. If it doesn't
// then return null & delete this.
diff --git a/src/com/android/launcher2/Utilities.java b/src/com/android/launcher2/Utilities.java
index e5169a206..d7562a947 100644
--- a/src/com/android/launcher2/Utilities.java
+++ b/src/com/android/launcher2/Utilities.java
@@ -43,8 +43,6 @@ import com.android.launcher.R;
final class Utilities {
private static final String TAG = "Launcher.Utilities";
- private static final boolean TEXT_BURN = false;
-
private static int sIconWidth = -1;
private static int sIconHeight = -1;
private static int sIconTextureWidth = -1;