summaryrefslogtreecommitdiffstats
path: root/src/com/android/launcher3/PendingAppWidgetHostView.java
diff options
context:
space:
mode:
authorAdam Cohen <adamcohen@google.com>2015-05-06 11:42:25 -0700
committerAdam Cohen <adamcohen@google.com>2015-05-21 16:16:40 -0700
commit2e6da1539bc7286336b3c24d96ab76434939ce4d (patch)
tree38c7387dc9a5f6f084c4998aac88495189423d3b /src/com/android/launcher3/PendingAppWidgetHostView.java
parenta9d012c6e67b644498e07c63f36617c1b8915e02 (diff)
downloadandroid_packages_apps_Trebuchet-2e6da1539bc7286336b3c24d96ab76434939ce4d.tar.gz
android_packages_apps_Trebuchet-2e6da1539bc7286336b3c24d96ab76434939ce4d.tar.bz2
android_packages_apps_Trebuchet-2e6da1539bc7286336b3c24d96ab76434939ce4d.zip
Refactoring DeviceProfile
-> Pulling out the parts of device profile which can (and need to be) initialized and accessed without access to an Activity context, ie. the invariant bits. -> The invariant bits are stored in InvariantDeviceProfile which is initialized statically from LauncherAppState. -> The DeviceProfile contains the Activity context-dependent bits, and we will create one of these for each Activity instance, and this instance is accessed through the Launcher activity. -> It's possible that we can continue to refactor this such that all appropriate dimensions can be computed without an Activity context (by only specifying orientation). This would be an extension of this CL and allow us to know exactly how launcher will look in both orientations from any context. Sets the stage for some improvements around b/19514688 Change-Id: Ia7daccf14d8ca2b9cb340b8780b684769e9f1892
Diffstat (limited to 'src/com/android/launcher3/PendingAppWidgetHostView.java')
-rw-r--r--src/com/android/launcher3/PendingAppWidgetHostView.java14
1 files changed, 6 insertions, 8 deletions
diff --git a/src/com/android/launcher3/PendingAppWidgetHostView.java b/src/com/android/launcher3/PendingAppWidgetHostView.java
index 179c60a98..c8b27efd3 100644
--- a/src/com/android/launcher3/PendingAppWidgetHostView.java
+++ b/src/com/android/launcher3/PendingAppWidgetHostView.java
@@ -42,6 +42,7 @@ public class PendingAppWidgetHostView extends LauncherAppWidgetHostView implemen
private final int mStartState;
private final Intent mIconLookupIntent;
private final boolean mDisabledForSafeMode;
+ private Launcher mLauncher;
private Bitmap mIcon;
@@ -56,6 +57,8 @@ public class PendingAppWidgetHostView extends LauncherAppWidgetHostView implemen
public PendingAppWidgetHostView(Context context, LauncherAppWidgetInfo info,
boolean disabledForSafeMode) {
super(context);
+
+ mLauncher = (Launcher) context;
mInfo = info;
mStartState = info.restoreStatus;
mIconLookupIntent = new Intent().setComponent(info.providerName);
@@ -64,7 +67,7 @@ public class PendingAppWidgetHostView extends LauncherAppWidgetHostView implemen
mPaint = new TextPaint();
mPaint.setColor(0xFFFFFFFF);
mPaint.setTextSize(TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_PX,
- getDeviceProfile().iconTextSizePx, getResources().getDisplayMetrics()));
+ mLauncher.getDeviceProfile().iconTextSizePx, getResources().getDisplayMetrics()));
setBackgroundResource(R.drawable.quantum_panel_dark);
setWillNotDraw(false);
}
@@ -173,12 +176,12 @@ public class PendingAppWidgetHostView extends LauncherAppWidgetHostView implemen
return;
}
+ DeviceProfile grid = mLauncher.getDeviceProfile();
if (mTopCornerDrawable == null) {
if (mDrawableSizeChanged) {
int outset = (mCenterDrawable instanceof PreloadIconDrawable) ?
((PreloadIconDrawable) mCenterDrawable).getOutset() : 0;
- int maxSize = LauncherAppState.getInstance().getDynamicGrid()
- .getDeviceProfile().iconSizePx + 2 * outset;
+ int maxSize = grid.iconSizePx + 2 * outset;
int size = Math.min(maxSize, Math.min(
getWidth() - getPaddingLeft() - getPaddingRight(),
getHeight() - getPaddingTop() - getPaddingBottom()));
@@ -193,7 +196,6 @@ public class PendingAppWidgetHostView extends LauncherAppWidgetHostView implemen
} else {
// Draw the top corner icon and "Setup" text is possible
if (mDrawableSizeChanged) {
- DeviceProfile grid = getDeviceProfile();
int iconSize = grid.iconSizePx;
int paddingTop = getPaddingTop();
int paddingBottom = getPaddingBottom();
@@ -251,8 +253,4 @@ public class PendingAppWidgetHostView extends LauncherAppWidgetHostView implemen
}
}
}
-
- private DeviceProfile getDeviceProfile() {
- return LauncherAppState.getInstance().getDynamicGrid().getDeviceProfile();
- }
}