diff options
Diffstat (limited to 'src/com')
-rw-r--r-- | src/com/android/launcher2/AppWidgetResizeFrame.java | 6 | ||||
-rw-r--r-- | src/com/android/launcher2/Launcher.java | 41 | ||||
-rw-r--r-- | src/com/android/launcher2/LauncherAppWidgetHostView.java | 1 |
3 files changed, 7 insertions, 41 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/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} |