summaryrefslogtreecommitdiffstats
path: root/src/com/android
diff options
context:
space:
mode:
Diffstat (limited to 'src/com/android')
-rw-r--r--src/com/android/launcher3/AppsCustomizePagedView.java4
-rw-r--r--src/com/android/launcher3/AppsCustomizeTabHost.java5
-rw-r--r--src/com/android/launcher3/Cling.java302
-rw-r--r--src/com/android/launcher3/DynamicGrid.java4
-rw-r--r--src/com/android/launcher3/Folder.java12
-rw-r--r--src/com/android/launcher3/Launcher.java117
6 files changed, 260 insertions, 184 deletions
diff --git a/src/com/android/launcher3/AppsCustomizePagedView.java b/src/com/android/launcher3/AppsCustomizePagedView.java
index a36f44459..213e50a67 100644
--- a/src/com/android/launcher3/AppsCustomizePagedView.java
+++ b/src/com/android/launcher3/AppsCustomizePagedView.java
@@ -411,7 +411,6 @@ public class AppsCustomizePagedView extends PagedViewWithDraggableItems implemen
pos[0] += (getMeasuredWidth() - mWidgetSpacingLayout.getMeasuredWidth()) / 2 +
offset[0];
pos[1] += offset[1] - mLauncher.getDragLayer().getPaddingTop();
- mLauncher.showFirstRunAllAppsCling(pos);
}
}
@@ -792,9 +791,6 @@ public class AppsCustomizePagedView extends PagedViewWithDraggableItems implemen
public void run() {
// We don't enter spring-loaded mode if the drag has been cancelled
if (mLauncher.getDragController().isDragging()) {
- // Dismiss the cling
- mLauncher.dismissAllAppsCling(null);
-
// Reset the alpha on the dragged icon before we drag
resetDrawableState();
diff --git a/src/com/android/launcher3/AppsCustomizeTabHost.java b/src/com/android/launcher3/AppsCustomizeTabHost.java
index 8aef864b4..89e74b218 100644
--- a/src/com/android/launcher3/AppsCustomizeTabHost.java
+++ b/src/com/android/launcher3/AppsCustomizeTabHost.java
@@ -403,6 +403,9 @@ public class AppsCustomizeTabHost extends TabHost implements LauncherTransitiona
if (animated) {
enableAndBuildHardwareLayer();
}
+
+ // Dismiss the workspace cling
+ l.dismissWorkspaceCling(null);
}
@Override
@@ -419,8 +422,6 @@ public class AppsCustomizeTabHost extends TabHost implements LauncherTransitiona
}
if (!toWorkspace) {
- // Dismiss the workspace cling
- l.dismissWorkspaceCling(null);
// Show the all apps cling (if not already shown)
mAppsCustomizePane.showAllAppsCling();
// Make sure adjacent pages are loaded (we wait until after the transition to
diff --git a/src/com/android/launcher3/Cling.java b/src/com/android/launcher3/Cling.java
index add6da51d..963702ae2 100644
--- a/src/com/android/launcher3/Cling.java
+++ b/src/com/android/launcher3/Cling.java
@@ -16,6 +16,9 @@
package com.android.launcher3;
+import android.animation.Animator;
+import android.animation.AnimatorListenerAdapter;
+import android.animation.ObjectAnimator;
import android.content.Context;
import android.content.res.Resources;
import android.content.res.TypedArray;
@@ -31,40 +34,42 @@ import android.util.DisplayMetrics;
import android.view.FocusFinder;
import android.view.MotionEvent;
import android.view.View;
+import android.view.animation.AccelerateInterpolator;
import android.widget.FrameLayout;
-public class Cling extends FrameLayout {
+public class Cling extends FrameLayout implements Insettable, View.OnLongClickListener {
- static final String WORKSPACE_CLING_DISMISSED_KEY = "cling.workspace.dismissed";
- static final String ALLAPPS_CLING_DISMISSED_KEY = "cling.allapps.dismissed";
- static final String FOLDER_CLING_DISMISSED_KEY = "cling.folder.dismissed";
+ static final String FIRST_RUN_CLING_DISMISSED_KEY = "cling_gel.first_run.dismissed";
+ static final String WORKSPACE_CLING_DISMISSED_KEY = "cling_gel.workspace.dismissed";
+ static final String FOLDER_CLING_DISMISSED_KEY = "cling_gel.folder.dismissed";
+
+ private static String FIRST_RUN_PORTRAIT = "first_run_portrait";
+ private static String FIRST_RUN_LANDSCAPE = "first_run_landscape";
private static String WORKSPACE_PORTRAIT = "workspace_portrait";
private static String WORKSPACE_LANDSCAPE = "workspace_landscape";
private static String WORKSPACE_LARGE = "workspace_large";
private static String WORKSPACE_CUSTOM = "workspace_custom";
- private static String ALLAPPS_PORTRAIT = "all_apps_portrait";
- private static String ALLAPPS_LANDSCAPE = "all_apps_landscape";
- private static String ALLAPPS_LARGE = "all_apps_large";
-
private static String FOLDER_PORTRAIT = "folder_portrait";
private static String FOLDER_LANDSCAPE = "folder_landscape";
private static String FOLDER_LARGE = "folder_large";
+ private static float FIRST_RUN_CIRCLE_BUFFER_DPS = 40;
+ private static float WORKSPACE_INNER_CIRCLE_RADIUS_DPS = 50;
+ private static float WORKSPACE_OUTER_CIRCLE_RADIUS_DPS = 60;
+ private static float WORKSPACE_CIRCLE_Y_OFFSET_DPS = 30;
+
private Launcher mLauncher;
private boolean mIsInitialized;
private String mDrawIdentifier;
private Drawable mBackground;
- private Drawable mPunchThroughGraphic;
- private Drawable mHandTouchGraphic;
- private int mPunchThroughGraphicCenterRadius;
- private int mAppIconSize;
- private int mButtonBarHeight;
- private float mRevealRadius;
- private int[] mPositionData;
private Paint mErasePaint;
+ private Paint mBubblePaint;
+ private Paint mDotPaint;
+
+ private final Rect mInsets = new Rect();
public Cling(Context context) {
this(context, null, 0);
@@ -82,60 +87,116 @@ public class Cling extends FrameLayout {
a.recycle();
setClickable(true);
+
}
void init(Launcher l, int[] positionData) {
if (!mIsInitialized) {
mLauncher = l;
- mPositionData = positionData;
-
- Resources r = getContext().getResources();
- LauncherAppState app = LauncherAppState.getInstance();
- DeviceProfile grid = app.getDynamicGrid().getDeviceProfile();
-
- mPunchThroughGraphic = r.getDrawable(R.drawable.cling);
- mPunchThroughGraphicCenterRadius =
- r.getDimensionPixelSize(R.dimen.clingPunchThroughGraphicCenterRadius);
- mAppIconSize = grid.iconSizePx;
- mRevealRadius = grid.iconSizePx * 1f;
- mButtonBarHeight = grid.hotseatBarHeightPx;
+ setOnLongClickListener(this);
mErasePaint = new Paint();
mErasePaint.setXfermode(new PorterDuffXfermode(PorterDuff.Mode.MULTIPLY));
mErasePaint.setColor(0xFFFFFF);
mErasePaint.setAlpha(0);
+ mErasePaint.setAntiAlias(true);
+
+ mBubblePaint = new Paint();
+ mBubblePaint.setColor(0xFFFFFF);
+ mBubblePaint.setAntiAlias(true);
+
+ mDotPaint = new Paint();
+ mDotPaint.setColor(0x72BBED);
+ mDotPaint.setAntiAlias(true);
mIsInitialized = true;
}
}
+ void show(boolean animate, int duration) {
+ setVisibility(View.VISIBLE);
+ setLayerType(View.LAYER_TYPE_HARDWARE, null);
+ if (mDrawIdentifier.equals(WORKSPACE_PORTRAIT) ||
+ mDrawIdentifier.equals(WORKSPACE_LANDSCAPE) ||
+ mDrawIdentifier.equals(WORKSPACE_LARGE) ||
+ mDrawIdentifier.equals(WORKSPACE_CUSTOM)) {
+ View content = getContent();
+ content.setAlpha(0f);
+ content.animate()
+ .alpha(1f)
+ .setDuration(duration)
+ .setListener(new AnimatorListenerAdapter() {
+ public void onAnimationEnd(Animator animation) {
+ };
+ })
+ .start();
+ setAlpha(1f);
+ } else {
+ if (animate) {
+ buildLayer();
+ setAlpha(0f);
+ animate()
+ .alpha(1f)
+ .setInterpolator(new AccelerateInterpolator())
+ .setDuration(duration)
+ .start();
+ } else {
+ setAlpha(1f);
+ }
+ }
+ setFocusableInTouchMode(true);
+ post(new Runnable() {
+ public void run() {
+ setFocusable(true);
+ requestFocus();
+ }
+ });
+ }
+
+ void hide(final int duration, final Runnable postCb) {
+ if (mDrawIdentifier.equals(FIRST_RUN_PORTRAIT) ||
+ mDrawIdentifier.equals(FIRST_RUN_LANDSCAPE)) {
+ View content = getContent();
+ ObjectAnimator anim = LauncherAnimUtils.ofFloat(content, "alpha", 0f);
+ anim.setDuration(duration);
+ anim.addListener(new AnimatorListenerAdapter() {
+ public void onAnimationEnd(Animator animation) {
+ // We are about to trigger the workspace cling, so don't do anything else
+ setVisibility(View.GONE);
+ postCb.run();
+ };
+ });
+ anim.start();
+ } else {
+ ObjectAnimator anim = LauncherAnimUtils.ofFloat(this, "alpha", 0f);
+ anim.setDuration(duration);
+ anim.addListener(new AnimatorListenerAdapter() {
+ public void onAnimationEnd(Animator animation) {
+ setVisibility(View.GONE);
+ postCb.run();
+ };
+ });
+ anim.start();
+ }
+ }
+
void cleanup() {
mBackground = null;
- mPunchThroughGraphic = null;
- mHandTouchGraphic = null;
mIsInitialized = false;
}
- public String getDrawIdentifier() {
- return mDrawIdentifier;
+ @Override
+ public void setInsets(Rect insets) {
+ mInsets.set(insets);
+ setPadding(insets.left, insets.top, insets.right, insets.bottom);
}
- private int[] getPunchThroughPositions() {
- if (mDrawIdentifier.equals(WORKSPACE_PORTRAIT)) {
- return new int[]{getMeasuredWidth() / 2, getMeasuredHeight() - (mButtonBarHeight / 2)};
- } else if (mDrawIdentifier.equals(WORKSPACE_LANDSCAPE)) {
- return new int[]{getMeasuredWidth() - (mButtonBarHeight / 2), getMeasuredHeight() / 2};
- } else if (mDrawIdentifier.equals(WORKSPACE_LARGE)) {
- final float scale = LauncherAppState.getInstance().getScreenDensity();
- final int cornerXOffset = (int) (scale * 15);
- final int cornerYOffset = (int) (scale * 10);
- return new int[]{getMeasuredWidth() - cornerXOffset, cornerYOffset};
- } else if (mDrawIdentifier.equals(ALLAPPS_PORTRAIT) ||
- mDrawIdentifier.equals(ALLAPPS_LANDSCAPE) ||
- mDrawIdentifier.equals(ALLAPPS_LARGE)) {
- return mPositionData;
- }
- return new int[]{-1, -1};
+ View getContent() {
+ return findViewById(R.id.content);
+ }
+
+ String getDrawIdentifier() {
+ return mDrawIdentifier;
}
@Override
@@ -153,30 +214,12 @@ public class Cling extends FrameLayout {
return (mDrawIdentifier.equals(WORKSPACE_PORTRAIT)
|| mDrawIdentifier.equals(WORKSPACE_LANDSCAPE)
|| mDrawIdentifier.equals(WORKSPACE_LARGE)
- || mDrawIdentifier.equals(ALLAPPS_PORTRAIT)
- || mDrawIdentifier.equals(ALLAPPS_LANDSCAPE)
- || mDrawIdentifier.equals(ALLAPPS_LARGE)
|| mDrawIdentifier.equals(WORKSPACE_CUSTOM));
}
@Override
public boolean onTouchEvent(android.view.MotionEvent event) {
- if (mDrawIdentifier.equals(WORKSPACE_PORTRAIT) ||
- mDrawIdentifier.equals(WORKSPACE_LANDSCAPE) ||
- mDrawIdentifier.equals(WORKSPACE_LARGE) ||
- mDrawIdentifier.equals(ALLAPPS_PORTRAIT) ||
- mDrawIdentifier.equals(ALLAPPS_LANDSCAPE) ||
- mDrawIdentifier.equals(ALLAPPS_LARGE)) {
-
- int[] positions = getPunchThroughPositions();
- for (int i = 0; i < positions.length; i += 2) {
- double diff = Math.sqrt(Math.pow(event.getX() - positions[i], 2) +
- Math.pow(event.getY() - positions[i + 1], 2));
- if (diff < mRevealRadius) {
- return false;
- }
- }
- } else if (mDrawIdentifier.equals(FOLDER_PORTRAIT) ||
+ if (mDrawIdentifier.equals(FOLDER_PORTRAIT) ||
mDrawIdentifier.equals(FOLDER_LANDSCAPE) ||
mDrawIdentifier.equals(FOLDER_LARGE)) {
Folder f = mLauncher.getWorkspace().getOpenFolder();
@@ -188,81 +231,94 @@ public class Cling extends FrameLayout {
}
}
}
- return true;
+ return super.onTouchEvent(event);
};
@Override
+ public boolean onLongClick(View v) {
+ if (mDrawIdentifier.equals(WORKSPACE_PORTRAIT) ||
+ mDrawIdentifier.equals(WORKSPACE_LANDSCAPE) ||
+ mDrawIdentifier.equals(WORKSPACE_LARGE)) {
+ mLauncher.dismissWorkspaceCling(null);
+ return true;
+ }
+ return false;
+ }
+
+ @Override
protected void dispatchDraw(Canvas canvas) {
if (mIsInitialized) {
- DisplayMetrics metrics = new DisplayMetrics();
- mLauncher.getWindowManager().getDefaultDisplay().getMetrics(metrics);
-
- // Initialize the draw buffer (to allow punching through)
- Bitmap b = Bitmap.createBitmap(getMeasuredWidth(), getMeasuredHeight(),
- Bitmap.Config.ARGB_8888);
- Canvas c = new Canvas(b);
+ canvas.save();
- // Draw the background
+ // Get the background override if there is one
if (mBackground == null) {
- if (mDrawIdentifier.equals(WORKSPACE_PORTRAIT) ||
- mDrawIdentifier.equals(WORKSPACE_LANDSCAPE) ||
- mDrawIdentifier.equals(WORKSPACE_LARGE)) {
- mBackground = getResources().getDrawable(R.drawable.bg_cling1);
- } else if (mDrawIdentifier.equals(ALLAPPS_PORTRAIT) ||
- mDrawIdentifier.equals(ALLAPPS_LANDSCAPE) ||
- mDrawIdentifier.equals(ALLAPPS_LARGE)) {
- mBackground = getResources().getDrawable(R.drawable.bg_cling2);
- } else if (mDrawIdentifier.equals(FOLDER_PORTRAIT) ||
- mDrawIdentifier.equals(FOLDER_LANDSCAPE)) {
- mBackground = getResources().getDrawable(R.drawable.bg_cling3);
- } else if (mDrawIdentifier.equals(FOLDER_LARGE)) {
- mBackground = getResources().getDrawable(R.drawable.bg_cling4);
- } else if (mDrawIdentifier.equals(WORKSPACE_CUSTOM)) {
+ if (mDrawIdentifier.equals(WORKSPACE_CUSTOM)) {
mBackground = getResources().getDrawable(R.drawable.bg_cling5);
}
}
+ // Draw the background
+ Bitmap eraseBg = null;
+ Canvas eraseCanvas = null;
if (mBackground != null) {
mBackground.setBounds(0, 0, getMeasuredWidth(), getMeasuredHeight());
- mBackground.draw(c);
+ mBackground.draw(canvas);
+ } else if (mDrawIdentifier.equals(FOLDER_PORTRAIT) ||
+ mDrawIdentifier.equals(FOLDER_LANDSCAPE) ||
+ mDrawIdentifier.equals(FOLDER_LARGE)) {
+ canvas.drawColor(0xcc000000);
+ } else if (mDrawIdentifier.equals(WORKSPACE_PORTRAIT) ||
+ mDrawIdentifier.equals(WORKSPACE_LANDSCAPE) ||
+ mDrawIdentifier.equals(WORKSPACE_LARGE)) {
+ // Initialize the draw buffer (to allow punching through)
+ eraseBg = Bitmap.createBitmap(getMeasuredWidth(), getMeasuredHeight(),
+ Bitmap.Config.ARGB_8888);
+ eraseCanvas = new Canvas(eraseBg);
+ eraseCanvas.drawColor(0xdd000000);
} else {
- c.drawColor(0x99000000);
+ canvas.drawColor(0xdd000000);
}
- int cx = -1;
- int cy = -1;
- float scale = mRevealRadius / mPunchThroughGraphicCenterRadius;
- int dw = (int) (scale * mPunchThroughGraphic.getIntrinsicWidth());
- int dh = (int) (scale * mPunchThroughGraphic.getIntrinsicHeight());
-
- // Determine where to draw the punch through graphic
- int[] positions = getPunchThroughPositions();
- for (int i = 0; i < positions.length; i += 2) {
- cx = positions[i];
- cy = positions[i + 1];
- if (cx > -1 && cy > -1) {
- c.drawCircle(cx, cy, mRevealRadius, mErasePaint);
- mPunchThroughGraphic.setBounds(cx - dw/2, cy - dh/2, cx + dw/2, cy + dh/2);
- mPunchThroughGraphic.draw(c);
- }
+ // Draw everything else
+ DisplayMetrics metrics = new DisplayMetrics();
+ mLauncher.getWindowManager().getDefaultDisplay().getMetrics(metrics);
+ float alpha = getAlpha();
+ View content = getContent();
+ if (content != null) {
+ alpha *= content.getAlpha();
}
-
- // Draw the hand graphic in All Apps
- if (mDrawIdentifier.equals(ALLAPPS_PORTRAIT) ||
- mDrawIdentifier.equals(ALLAPPS_LANDSCAPE) ||
- mDrawIdentifier.equals(ALLAPPS_LARGE)) {
- if (mHandTouchGraphic == null) {
- mHandTouchGraphic = getResources().getDrawable(R.drawable.hand);
- }
- int offset = mAppIconSize / 4;
- mHandTouchGraphic.setBounds(cx + offset, cy + offset,
- cx + mHandTouchGraphic.getIntrinsicWidth() + offset,
- cy + mHandTouchGraphic.getIntrinsicHeight() + offset);
- mHandTouchGraphic.draw(c);
+ if (mDrawIdentifier.equals(FIRST_RUN_PORTRAIT) ||
+ mDrawIdentifier.equals(FIRST_RUN_LANDSCAPE)) {
+ // Draw the white circle
+ View bubbleContent = findViewById(R.id.bubble_content);
+ Rect bubbleRect = new Rect();
+ bubbleContent.getGlobalVisibleRect(bubbleRect);
+ mBubblePaint.setAlpha((int) (255 * alpha));
+ float buffer = DynamicGrid.pxFromDp(FIRST_RUN_CIRCLE_BUFFER_DPS, metrics);
+ canvas.drawCircle(metrics.widthPixels / 2,
+ bubbleRect.centerY(),
+ (bubbleContent.getMeasuredWidth() + buffer) / 2,
+ mBubblePaint);
+ } else if (mDrawIdentifier.equals(WORKSPACE_PORTRAIT) ||
+ mDrawIdentifier.equals(WORKSPACE_LANDSCAPE) ||
+ mDrawIdentifier.equals(WORKSPACE_LARGE)) {
+ int offset = DynamicGrid.pxFromDp(WORKSPACE_CIRCLE_Y_OFFSET_DPS, metrics);
+ mErasePaint.setAlpha((int) (128));
+ eraseCanvas.drawCircle(metrics.widthPixels / 2,
+ metrics.heightPixels / 2 - offset,
+ DynamicGrid.pxFromDp(WORKSPACE_OUTER_CIRCLE_RADIUS_DPS, metrics),
+ mErasePaint);
+ mErasePaint.setAlpha(0);
+ eraseCanvas.drawCircle(metrics.widthPixels / 2,
+ metrics.heightPixels / 2 - offset,
+ DynamicGrid.pxFromDp(WORKSPACE_INNER_CIRCLE_RADIUS_DPS, metrics),
+ mErasePaint);
+ canvas.drawBitmap(eraseBg, 0, 0, null);
+ eraseCanvas.setBitmap(null);
+ eraseBg = null;
}
- canvas.drawBitmap(b, 0, 0, null);
- c.setBitmap(null);
- b = null;
+
+ canvas.restore();
}
// Draw the rest of the cling
diff --git a/src/com/android/launcher3/DynamicGrid.java b/src/com/android/launcher3/DynamicGrid.java
index 6e101750f..664a99cd0 100644
--- a/src/com/android/launcher3/DynamicGrid.java
+++ b/src/com/android/launcher3/DynamicGrid.java
@@ -328,10 +328,12 @@ class DeviceProfile {
return height / countY;
}
+ boolean isPhone() {
+ return !isTablet && !isLargeTablet;
+ }
boolean isTablet() {
return isTablet;
}
-
boolean isLargeTablet() {
return isLargeTablet;
}
diff --git a/src/com/android/launcher3/Folder.java b/src/com/android/launcher3/Folder.java
index 47fc6c3f4..9ee3f6454 100644
--- a/src/com/android/launcher3/Folder.java
+++ b/src/com/android/launcher3/Folder.java
@@ -453,6 +453,7 @@ public class Folder extends LinearLayout implements DragSource, View.OnClickList
Cling cling = mLauncher.showFirstRunFoldersCling();
if (cling != null) {
cling.bringToFront();
+ bringToFront();
}
setFocusOnFirstChild();
}
@@ -878,11 +879,13 @@ public class Folder extends LinearLayout implements DragSource, View.OnClickList
float scale = parent.getDescendantRectRelativeToSelf(mFolderIcon, mTempRect);
+ LauncherAppState app = LauncherAppState.getInstance();
+ DeviceProfile grid = app.getDynamicGrid().getDeviceProfile();
+
int centerX = (int) (mTempRect.left + mTempRect.width() * scale / 2);
int centerY = (int) (mTempRect.top + mTempRect.height() * scale / 2);
int centeredLeft = centerX - width / 2;
int centeredTop = centerY - height / 2;
-
int currentPage = mLauncher.getWorkspace().getCurrentPage();
// In case the workspace is scrolling, we need to use the final scroll to compute
// the folders bounds.
@@ -900,8 +903,11 @@ public class Folder extends LinearLayout implements DragSource, View.OnClickList
bounds.left + bounds.width() - width);
int top = Math.min(Math.max(bounds.top, centeredTop),
bounds.top + bounds.height() - height);
- // If the folder doesn't fit within the bounds, center it about the desired bounds
- if (width >= bounds.width()) {
+ if (grid.isPhone() && (grid.availableWidthPx - width) < grid.iconSizePx) {
+ // Center the folder if it is full (on phones only)
+ left = (grid.availableWidthPx - width) / 2;
+ } else if (width >= bounds.width()) {
+ // If the folder doesn't fit within the bounds, center it about the desired bounds
left = bounds.left + (bounds.width() - width) / 2;
}
if (height >= bounds.height()) {
diff --git a/src/com/android/launcher3/Launcher.java b/src/com/android/launcher3/Launcher.java
index 89d4cb379..3bbb39ee3 100644
--- a/src/com/android/launcher3/Launcher.java
+++ b/src/com/android/launcher3/Launcher.java
@@ -202,8 +202,8 @@ public class Launcher extends Activity
static final int APPWIDGET_HOST_ID = 1024;
private static final int EXIT_SPRINGLOADED_MODE_SHORT_TIMEOUT = 300;
private static final int EXIT_SPRINGLOADED_MODE_LONG_TIMEOUT = 600;
- private static final int SHOW_CLING_DURATION = 550;
- private static final int DISMISS_CLING_DURATION = 250;
+ private static final int SHOW_CLING_DURATION = 250;
+ private static final int DISMISS_CLING_DURATION = 200;
private static final Object sLock = new Object();
private static int sScreen = DEFAULT_SCREEN;
@@ -422,7 +422,6 @@ public class Launcher extends Activity
setContentView(R.layout.launcher);
setupViews();
grid.layout(this);
- showFirstRunWorkspaceCling();
registerContentObservers();
@@ -464,6 +463,8 @@ public class Launcher extends Activity
// On large interfaces, we want the screen to auto-rotate based on the current orientation
unlockScreenOrientation(true);
+
+ showFirstRunCling();
}
protected void onUserLeaveHint() {
@@ -4080,47 +4081,30 @@ public class Launcher extends Activity
return true;
}
- private Cling initCling(int clingId, int[] positionData, boolean animate, int delay) {
+ private Cling initCling(int clingId, int[] positionData, boolean animate,
+ boolean dimNavBarVisibilty) {
final Cling cling = (Cling) findViewById(clingId);
if (cling != null) {
cling.init(this, positionData);
- cling.setVisibility(View.VISIBLE);
- cling.setLayerType(View.LAYER_TYPE_HARDWARE, null);
- if (animate) {
- cling.buildLayer();
- cling.setAlpha(0f);
- cling.animate()
- .alpha(1f)
- .setInterpolator(new AccelerateInterpolator())
- .setDuration(SHOW_CLING_DURATION)
- .setStartDelay(delay)
- .start();
- } else {
- cling.setAlpha(1f);
+ cling.show(animate, SHOW_CLING_DURATION);
+
+ if (dimNavBarVisibilty) {
+ cling.setSystemUiVisibility(cling.getSystemUiVisibility() |
+ View.SYSTEM_UI_FLAG_LOW_PROFILE);
}
- cling.setFocusableInTouchMode(true);
- cling.post(new Runnable() {
- public void run() {
- cling.setFocusable(true);
- cling.requestFocus();
- }
- });
- mHideFromAccessibilityHelper.setImportantForAccessibilityToNo(
- mDragLayer, clingId == R.id.all_apps_cling);
}
return cling;
}
- private void dismissCling(final Cling cling, final String flag, int duration) {
+ private void dismissCling(final Cling cling, final Runnable postAnimationCb,
+ final String flag, int duration, boolean restoreNavBarVisibilty) {
// To catch cases where siblings of top-level views are made invisible, just check whether
// the cling is directly set to GONE before dismissing it.
if (cling != null && cling.getVisibility() != View.GONE) {
- ObjectAnimator anim = LauncherAnimUtils.ofFloat(cling, "alpha", 0f);
- anim.setDuration(duration);
- anim.addListener(new AnimatorListenerAdapter() {
- public void onAnimationEnd(Animator animation) {
- cling.setVisibility(View.GONE);
+ final Runnable cleanUpClingCb = new Runnable() {
+ public void run() {
cling.cleanup();
+ /*
// We should update the shared preferences on a background thread
new Thread("dismissClingThread") {
public void run() {
@@ -4129,10 +4113,23 @@ public class Launcher extends Activity
editor.commit();
}
}.start();
- };
- });
- anim.start();
+ */
+ if (postAnimationCb != null) {
+ postAnimationCb.run();
+ }
+ }
+ };
+ if (duration <= 0) {
+ cleanUpClingCb.run();
+ } else {
+ cling.hide(duration, cleanUpClingCb);
+ }
mHideFromAccessibilityHelper.restoreImportantForAccessibility(mDragLayer);
+
+ if (restoreNavBarVisibilty) {
+ cling.setSystemUiVisibility(cling.getSystemUiVisibility() &
+ ~View.SYSTEM_UI_FLAG_LOW_PROFILE);
+ }
}
}
@@ -4162,10 +4159,9 @@ public class Launcher extends Activity
return false;
}
- public void showFirstRunWorkspaceCling() {
- // Enable the clings only if they have not been dismissed before
+ public void showFirstRunCling() {
if (isClingsEnabled() &&
- !mSharedPrefs.getBoolean(Cling.WORKSPACE_CLING_DISMISSED_KEY, false) &&
+ !mSharedPrefs.getBoolean(Cling.FIRST_RUN_CLING_DISMISSED_KEY, false) &&
!skipCustomClingIfNoAccounts() ) {
// If we're not using the default workspace layout, replace workspace cling
// with a custom workspace cling (usually specified in an overlay)
@@ -4181,25 +4177,27 @@ public class Launcher extends Activity
clingParent.addView(customCling, clingIndex);
customCling.setId(R.id.workspace_cling);
}
- initCling(R.id.workspace_cling, null, false, 0);
+ initCling(R.id.first_run_cling, null, false, true);
} else {
- removeCling(R.id.workspace_cling);
+ removeCling(R.id.first_run_cling);
}
}
- public void showFirstRunAllAppsCling(int[] position) {
+
+ public void showFirstRunWorkspaceCling() {
// Enable the clings only if they have not been dismissed before
if (isClingsEnabled() &&
- !mSharedPrefs.getBoolean(Cling.ALLAPPS_CLING_DISMISSED_KEY, false)) {
- initCling(R.id.all_apps_cling, position, true, 0);
+ !mSharedPrefs.getBoolean(Cling.WORKSPACE_CLING_DISMISSED_KEY, false)) {
+ initCling(R.id.workspace_cling, null, false, true);
} else {
- removeCling(R.id.all_apps_cling);
+ removeCling(R.id.workspace_cling);
}
}
public Cling showFirstRunFoldersCling() {
// Enable the clings only if they have not been dismissed before
if (isClingsEnabled() &&
!mSharedPrefs.getBoolean(Cling.FOLDER_CLING_DISMISSED_KEY, false)) {
- return initCling(R.id.folder_cling, null, true, 0);
+ Cling cling = initCling(R.id.folder_cling, null, true, true);
+ return cling;
} else {
removeCling(R.id.folder_cling);
return null;
@@ -4215,17 +4213,34 @@ public class Launcher extends Activity
}
return false;
}
+ public void dismissFirstRunCling(View v) {
+ Cling cling = (Cling) findViewById(R.id.first_run_cling);
+ Runnable cb = new Runnable() {
+ public void run() {
+ // Show the workspace cling next
+ showFirstRunWorkspaceCling();
+ }
+ };
+ dismissCling(cling, cb, Cling.FIRST_RUN_CLING_DISMISSED_KEY,
+ DISMISS_CLING_DURATION, false);
+ }
public void dismissWorkspaceCling(View v) {
Cling cling = (Cling) findViewById(R.id.workspace_cling);
- dismissCling(cling, Cling.WORKSPACE_CLING_DISMISSED_KEY, DISMISS_CLING_DURATION);
- }
- public void dismissAllAppsCling(View v) {
- Cling cling = (Cling) findViewById(R.id.all_apps_cling);
- dismissCling(cling, Cling.ALLAPPS_CLING_DISMISSED_KEY, DISMISS_CLING_DURATION);
+ Runnable cb = null;
+ if (v == null) {
+ cb = new Runnable() {
+ public void run() {
+ mWorkspace.enterOverviewMode();
+ }
+ };
+ }
+ dismissCling(cling, cb, Cling.WORKSPACE_CLING_DISMISSED_KEY,
+ DISMISS_CLING_DURATION, true);
}
public void dismissFolderCling(View v) {
Cling cling = (Cling) findViewById(R.id.folder_cling);
- dismissCling(cling, Cling.FOLDER_CLING_DISMISSED_KEY, DISMISS_CLING_DURATION);
+ dismissCling(cling, null, Cling.FOLDER_CLING_DISMISSED_KEY,
+ DISMISS_CLING_DURATION, true);
}
/**