Making CellLayout inflatable without LauncherActivtiy
This will allow creating cellLayout with a different device profile
or a different activtiy which can be used when displaying multiple
activities in multi-display or generating a preview for changing
display properties.
Change-Id: I386731d95e33c48bdef270ce9c0d3e9feefb6262
diff --git a/src/com/android/launcher3/folder/PreviewBackground.java b/src/com/android/launcher3/folder/PreviewBackground.java
index f2683a5..3c9e2dc 100644
--- a/src/com/android/launcher3/folder/PreviewBackground.java
+++ b/src/com/android/launcher3/folder/PreviewBackground.java
@@ -23,6 +23,7 @@
import android.animation.AnimatorListenerAdapter;
import android.animation.ObjectAnimator;
import android.animation.ValueAnimator;
+import android.content.Context;
import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.Matrix;
@@ -41,6 +42,7 @@
import com.android.launcher3.Launcher;
import com.android.launcher3.R;
import com.android.launcher3.util.Themes;
+import com.android.launcher3.views.ActivityContext;
/**
* This object represents a FolderIcon preview background. It stores drawing / measurement
@@ -121,20 +123,20 @@
}
};
- public void setup(Launcher launcher, View invalidateDelegate,
+ public void setup(Context context, ActivityContext activity, View invalidateDelegate,
int availableSpaceX, int topPadding) {
mInvalidateDelegate = invalidateDelegate;
- mBgColor = Themes.getAttrColor(launcher, android.R.attr.colorPrimary);
- mBadgeColor = Themes.getAttrColor(launcher, R.attr.folderBadgeColor);
+ mBgColor = Themes.getAttrColor(context, android.R.attr.colorPrimary);
+ mBadgeColor = Themes.getAttrColor(context, R.attr.folderBadgeColor);
- DeviceProfile grid = launcher.getDeviceProfile();
+ DeviceProfile grid = activity.getDeviceProfile();
previewSize = grid.folderIconSizePx;
basePreviewOffsetX = (availableSpaceX - previewSize) / 2;
basePreviewOffsetY = topPadding + grid.folderIconOffsetYPx;
// Stroke width is 1dp
- mStrokeWidth = launcher.getResources().getDisplayMetrics().density;
+ mStrokeWidth = context.getResources().getDisplayMetrics().density;
float radius = getScaledRadius();
float shadowRadius = radius + mStrokeWidth;