Tweaking folder cling to support large folders.

Change-Id: I3c500463fba8db71807ad4fc27c6923f3e1d0770
This commit is contained in:
Winson Chung
2013-09-26 17:45:32 -07:00
parent a709954065
commit fa54513308
9 changed files with 130 additions and 101 deletions
+67 -31
View File
@@ -70,6 +70,9 @@ public class Cling extends FrameLayout implements Insettable, View.OnLongClickLi
private Paint mBubblePaint;
private Paint mDotPaint;
private View mScrimView;
private int mBackgroundColor;
private final Rect mInsets = new Rect();
public Cling(Context context) {
@@ -91,9 +94,11 @@ public class Cling extends FrameLayout implements Insettable, View.OnLongClickLi
}
void init(Launcher l, int[] positionData) {
void init(Launcher l, View scrim) {
if (!mIsInitialized) {
mLauncher = l;
mScrimView = scrim;
mBackgroundColor = 0xdd000000;
setOnLongClickListener(this);
mErasePaint = new Paint();
@@ -128,10 +133,7 @@ public class Cling extends FrameLayout implements Insettable, View.OnLongClickLi
content.animate()
.alpha(1f)
.setDuration(duration)
.setListener(new AnimatorListenerAdapter() {
public void onAnimationEnd(Animator animation) {
};
})
.setListener(null)
.start();
setAlpha(1f);
} else {
@@ -142,11 +144,24 @@ public class Cling extends FrameLayout implements Insettable, View.OnLongClickLi
.alpha(1f)
.setInterpolator(new AccelerateInterpolator())
.setDuration(duration)
.setListener(null)
.start();
} else {
setAlpha(1f);
}
}
// Show the scrim if necessary
if (mScrimView != null) {
mScrimView.setVisibility(View.VISIBLE);
mScrimView.setAlpha(0f);
mScrimView.animate()
.alpha(1f)
.setDuration(duration)
.setListener(null)
.start();
}
setFocusableInTouchMode(true);
post(new Runnable() {
public void run() {
@@ -160,26 +175,42 @@ public class Cling extends FrameLayout implements Insettable, View.OnLongClickLi
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();
content.animate()
.alpha(0f)
.setDuration(duration)
.setListener(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();
};
})
.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();
animate()
.alpha(0f)
.setDuration(duration)
.setListener(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();
};
})
.start();
}
// Show the scrim if necessary
if (mScrimView != null) {
mScrimView.animate()
.alpha(0f)
.setDuration(duration)
.setListener(new AnimatorListenerAdapter() {
public void onAnimationEnd(Animator animation) {
mScrimView.setVisibility(View.GONE);
};
})
.start();
}
}
@@ -188,6 +219,12 @@ public class Cling extends FrameLayout implements Insettable, View.OnLongClickLi
mIsInitialized = false;
}
void bringScrimToFront() {
if (mScrimView != null) {
mScrimView.bringToFront();
}
}
@Override
public void setInsets(Rect insets) {
mInsets.set(insets);
@@ -262,13 +299,12 @@ public class Cling extends FrameLayout implements Insettable, View.OnLongClickLi
// Draw the background
Bitmap eraseBg = null;
Canvas eraseCanvas = null;
if (mBackground != null) {
if (mScrimView != null) {
// Skip drawing the background
mScrimView.setBackgroundColor(mBackgroundColor);
} else if (mBackground != null) {
mBackground.setBounds(0, 0, getMeasuredWidth(), getMeasuredHeight());
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)) {
@@ -276,9 +312,9 @@ public class Cling extends FrameLayout implements Insettable, View.OnLongClickLi
eraseBg = Bitmap.createBitmap(getMeasuredWidth(), getMeasuredHeight(),
Bitmap.Config.ARGB_8888);
eraseCanvas = new Canvas(eraseBg);
eraseCanvas.drawColor(0xdd000000);
eraseCanvas.drawColor(mBackgroundColor);
} else {
canvas.drawColor(0xdd000000);
canvas.drawColor(mBackgroundColor);
}
// Draw everything else
+2 -1
View File
@@ -453,8 +453,9 @@ public class Folder extends LinearLayout implements DragSource, View.OnClickList
setLayerType(LAYER_TYPE_NONE, null);
Cling cling = mLauncher.showFirstRunFoldersCling();
if (cling != null) {
cling.bringToFront();
cling.bringScrimToFront();
bringToFront();
cling.bringToFront();
}
setFocusOnFirstChild();
}
+12 -9
View File
@@ -274,7 +274,7 @@ public class Launcher extends Activity
private boolean mUserPresent = true;
private boolean mVisible = false;
private boolean mAttached = false;
private static final boolean DISABLE_CLINGS = true;
private static final boolean DISABLE_CLINGS = false;
private static final boolean DISABLE_CUSTOM_CLINGS = true;
private static LocaleConfiguration sLocaleConfiguration = null;
@@ -4064,11 +4064,15 @@ public class Launcher extends Activity
return true;
}
private Cling initCling(int clingId, int[] positionData, boolean animate,
private Cling initCling(int clingId, int scrimId, boolean animate,
boolean dimNavBarVisibilty) {
final Cling cling = (Cling) findViewById(clingId);
Cling cling = (Cling) findViewById(clingId);
View scrim = null;
if (scrimId > 0) {
scrim = findViewById(R.id.scrim);
}
if (cling != null) {
cling.init(this, positionData);
cling.init(this, scrim);
cling.show(animate, SHOW_CLING_DURATION);
if (dimNavBarVisibilty) {
@@ -4087,7 +4091,6 @@ public class Launcher extends Activity
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() {
@@ -4096,7 +4099,6 @@ public class Launcher extends Activity
editor.commit();
}
}.start();
*/
if (postAnimationCb != null) {
postAnimationCb.run();
}
@@ -4177,7 +4179,7 @@ public class Launcher extends Activity
ccHint.setVisibility(View.VISIBLE);
}
}
initCling(R.id.first_run_cling, null, false, true);
initCling(R.id.first_run_cling, 0, false, true);
} else {
removeCling(R.id.first_run_cling);
}
@@ -4194,7 +4196,7 @@ public class Launcher extends Activity
// Enable the clings only if they have not been dismissed before
if (isClingsEnabled() &&
!mSharedPrefs.getBoolean(Cling.WORKSPACE_CLING_DISMISSED_KEY, false)) {
initCling(R.id.workspace_cling, null, false, true);
initCling(R.id.workspace_cling, 0, false, true);
} else {
removeCling(R.id.workspace_cling);
}
@@ -4203,7 +4205,8 @@ public class Launcher extends Activity
// Enable the clings only if they have not been dismissed before
if (isClingsEnabled() &&
!mSharedPrefs.getBoolean(Cling.FOLDER_CLING_DISMISSED_KEY, false)) {
Cling cling = initCling(R.id.folder_cling, null, true, true);
Cling cling = initCling(R.id.folder_cling, R.id.cling_scrim,
true, true);
return cling;
} else {
removeCling(R.id.folder_cling);