am fa545133: Tweaking folder cling to support large folders.

* commit 'fa54513308ef60ffcd7eec8e1ce92120a643b88e':
  Tweaking folder cling to support large folders.
This commit is contained in:
Winson Chung
2013-09-26 18:31:08 -07:00
committed by Android Git Automerger
9 changed files with 130 additions and 101 deletions
+18 -28
View File
@@ -20,39 +20,29 @@
<FrameLayout <FrameLayout
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent" android:layout_height="match_parent"
android:layout_marginStart="10dp" android:layout_marginStart="15dp"
android:layout_marginEnd="10dp" android:layout_marginEnd="15dp"
android:layout_marginTop="40dp" android:layout_marginTop="10dp"
android:layout_marginBottom="20dp"> android:layout_marginBottom="10dp">
<LinearLayout <LinearLayout
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:orientation="vertical"> android:paddingLeft="20dp"
<LinearLayout android:paddingRight="20dp"
android:paddingTop="20dp"
android:paddingBottom="20dp"
android:orientation="vertical"
android:background="@drawable/cling">
<TextView
style="@style/ClingTitleText"
android:id="@+id/folder_cling_title"
android:text="@string/folder_cling_title" />
<TextView
style="@style/ClingText"
android:id="@+id/folder_cling_create_folder"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:paddingLeft="20dp" android:text="@string/folder_cling_create_folder" />
android:paddingRight="20dp"
android:paddingTop="20dp"
android:paddingBottom="20dp"
android:orientation="vertical"
android:background="@drawable/cling">
<TextView
style="@style/ClingTitleText"
android:id="@+id/folder_cling_title"
android:text="@string/folder_cling_title" />
<TextView
style="@style/ClingText"
android:id="@+id/folder_cling_create_folder"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@string/folder_cling_create_folder" />
</LinearLayout>
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:src="@drawable/cling_arrow_down" />
</LinearLayout> </LinearLayout>
</FrameLayout> </FrameLayout>
<Button <Button
+5
View File
@@ -57,6 +57,11 @@
<!-- The Workspace cling must appear under the AppsCustomizePagedView below to ensure <!-- The Workspace cling must appear under the AppsCustomizePagedView below to ensure
that it is still visible during the transition to AllApps and doesn't overlay on that it is still visible during the transition to AllApps and doesn't overlay on
top of that view. --> top of that view. -->
<FrameLayout
android:id="@+id/cling_scrim"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:visibility="gone" />
<include layout="@layout/first_run_cling" <include layout="@layout/first_run_cling"
android:id="@+id/first_run_cling" android:id="@+id/first_run_cling"
android:layout_width="match_parent" android:layout_width="match_parent"
+16 -26
View File
@@ -20,39 +20,29 @@
<FrameLayout <FrameLayout
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent" android:layout_height="match_parent"
android:layout_marginStart="20dp" android:layout_marginStart="15dp"
android:layout_marginEnd="20dp" android:layout_marginEnd="15dp"
android:layout_marginTop="10dp" android:layout_marginTop="10dp"
android:layout_marginBottom="10dp"> android:layout_marginBottom="10dp">
<LinearLayout <LinearLayout
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:orientation="vertical"> android:paddingLeft="20dp"
<LinearLayout android:paddingRight="20dp"
android:paddingTop="20dp"
android:paddingBottom="20dp"
android:orientation="vertical"
android:background="@drawable/cling">
<TextView
style="@style/ClingTitleText"
android:id="@+id/folder_cling_title"
android:text="@string/folder_cling_title" />
<TextView
style="@style/ClingText"
android:id="@+id/folder_cling_create_folder"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:paddingLeft="20dp" android:text="@string/folder_cling_create_folder" />
android:paddingRight="20dp"
android:paddingTop="20dp"
android:paddingBottom="20dp"
android:orientation="vertical"
android:background="@drawable/cling">
<TextView
style="@style/ClingTitleText"
android:id="@+id/folder_cling_title"
android:text="@string/folder_cling_title" />
<TextView
style="@style/ClingText"
android:id="@+id/folder_cling_create_folder"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@string/folder_cling_create_folder" />
</LinearLayout>
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:src="@drawable/cling_arrow_down" />
</LinearLayout> </LinearLayout>
</FrameLayout> </FrameLayout>
<Button <Button
+5 -1
View File
@@ -64,6 +64,11 @@
<!-- The Workspace cling must appear under the AppsCustomizePagedView below to ensure <!-- The Workspace cling must appear under the AppsCustomizePagedView below to ensure
that it is still visible during the transition to AllApps and doesn't overlay on that it is still visible during the transition to AllApps and doesn't overlay on
top of that view. --> top of that view. -->
<FrameLayout
android:id="@+id/cling_scrim"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:visibility="gone" />
<include layout="@layout/first_run_cling" <include layout="@layout/first_run_cling"
android:id="@+id/first_run_cling" android:id="@+id/first_run_cling"
android:layout_width="match_parent" android:layout_width="match_parent"
@@ -74,7 +79,6 @@
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent" android:layout_height="match_parent"
android:visibility="gone" /> android:visibility="gone" />
<include layout="@layout/folder_cling" <include layout="@layout/folder_cling"
android:id="@+id/folder_cling" android:id="@+id/folder_cling"
android:layout_width="match_parent" android:layout_width="match_parent"
+1 -1
View File
@@ -36,5 +36,5 @@
<color name="folder_items_text_color">#FF333333</color> <color name="folder_items_text_color">#FF333333</color>
<color name="outline_color">#FFFFFFFF</color> <color name="outline_color">#FFFFFFFF</color>
<color name="first_run_cling_circle_background_color">#FF83AEE8</color> <color name="first_run_cling_circle_background_color">#FF8BB4E9</color>
</resources> </resources>
+4 -4
View File
@@ -228,7 +228,7 @@ s -->
<!-- The title text for the workspace cling [CHAR_LIMIT=none] --> <!-- The title text for the workspace cling [CHAR_LIMIT=none] -->
<string name="first_run_cling_title">Welcome!</string> <string name="first_run_cling_title">Welcome!</string>
<!-- The description of how to use the workspace [CHAR_LIMIT=none] --> <!-- The description of how to use the workspace [CHAR_LIMIT=none] -->
<string name="first_run_cling_description">Make yourself at Home</string> <string name="first_run_cling_description">Make yourself at Home.</string>
<!-- The description of how to use the workspace [CHAR_LIMIT=none] --> <!-- The description of how to use the workspace [CHAR_LIMIT=none] -->
<string name="first_run_cling_custom_content_hint"></string> <string name="first_run_cling_custom_content_hint"></string>
<!-- The description of how to use the workspace [CHAR_LIMIT=none] --> <!-- The description of how to use the workspace [CHAR_LIMIT=none] -->
@@ -238,15 +238,15 @@ s -->
<!-- The title text for the workspace cling [CHAR_LIMIT=none] --> <!-- The title text for the workspace cling [CHAR_LIMIT=none] -->
<string name="workspace_cling_title">Organize your space</string> <string name="workspace_cling_title">Organize your space</string>
<!-- The description of how to use the workspace [CHAR_LIMIT=none] --> <!-- The description of how to use the workspace [CHAR_LIMIT=none] -->
<string name="workspace_cling_move_item">Touch &amp; hold background to manage wallpaper, widgets and settings</string> <string name="workspace_cling_move_item">Touch &amp; hold background to manage wallpaper, widgets and settings.</string>
<!-- The title text for the All Apps cling [CHAR_LIMIT=none] --> <!-- The title text for the All Apps cling [CHAR_LIMIT=none] -->
<string name="all_apps_cling_title">Choose some apps</string> <string name="all_apps_cling_title">Choose some apps</string>
<!-- The description of how to pick up and add an item to the workspace [CHAR_LIMIT=none] --> <!-- The description of how to pick up and add an item to the workspace [CHAR_LIMIT=none] -->
<string name="all_apps_cling_add_item">To add an app to your Home screen, touch &amp; hold it.</string> <string name="all_apps_cling_add_item">To add an app to your Home screen, touch &amp; hold it.</string>
<!-- The title text for the Folder cling [CHAR_LIMIT=none] --> <!-- The title text for the Folder cling [CHAR_LIMIT=none] -->
<string name="folder_cling_title">Create new folders for your apps</string> <string name="folder_cling_title">Here\'s a folder</string>
<!-- The description of how to create a folder [CHAR_LIMIT=none] --> <!-- The description of how to create a folder [CHAR_LIMIT=none] -->
<string name="folder_cling_create_folder">Touch &amp; hold an app, then move it on top of another app icon</string> <string name="folder_cling_create_folder">To create one like this, touch &amp; hold an app, then move it over another.</string>
<!-- The text on the button to dismiss a cling [CHAR_LIMIT=none] --> <!-- The text on the button to dismiss a cling [CHAR_LIMIT=none] -->
<string name="cling_dismiss">OK</string> <string name="cling_dismiss">OK</string>
<!-- Error message on dummy custom cling layout [DO NOT TRANSLATE] --> <!-- Error message on dummy custom cling layout [DO NOT TRANSLATE] -->
+67 -31
View File
@@ -70,6 +70,9 @@ public class Cling extends FrameLayout implements Insettable, View.OnLongClickLi
private Paint mBubblePaint; private Paint mBubblePaint;
private Paint mDotPaint; private Paint mDotPaint;
private View mScrimView;
private int mBackgroundColor;
private final Rect mInsets = new Rect(); private final Rect mInsets = new Rect();
public Cling(Context context) { 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) { if (!mIsInitialized) {
mLauncher = l; mLauncher = l;
mScrimView = scrim;
mBackgroundColor = 0xdd000000;
setOnLongClickListener(this); setOnLongClickListener(this);
mErasePaint = new Paint(); mErasePaint = new Paint();
@@ -128,10 +133,7 @@ public class Cling extends FrameLayout implements Insettable, View.OnLongClickLi
content.animate() content.animate()
.alpha(1f) .alpha(1f)
.setDuration(duration) .setDuration(duration)
.setListener(new AnimatorListenerAdapter() { .setListener(null)
public void onAnimationEnd(Animator animation) {
};
})
.start(); .start();
setAlpha(1f); setAlpha(1f);
} else { } else {
@@ -142,11 +144,24 @@ public class Cling extends FrameLayout implements Insettable, View.OnLongClickLi
.alpha(1f) .alpha(1f)
.setInterpolator(new AccelerateInterpolator()) .setInterpolator(new AccelerateInterpolator())
.setDuration(duration) .setDuration(duration)
.setListener(null)
.start(); .start();
} else { } else {
setAlpha(1f); 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); setFocusableInTouchMode(true);
post(new Runnable() { post(new Runnable() {
public void run() { public void run() {
@@ -160,26 +175,42 @@ public class Cling extends FrameLayout implements Insettable, View.OnLongClickLi
if (mDrawIdentifier.equals(FIRST_RUN_PORTRAIT) || if (mDrawIdentifier.equals(FIRST_RUN_PORTRAIT) ||
mDrawIdentifier.equals(FIRST_RUN_LANDSCAPE)) { mDrawIdentifier.equals(FIRST_RUN_LANDSCAPE)) {
View content = getContent(); View content = getContent();
ObjectAnimator anim = LauncherAnimUtils.ofFloat(content, "alpha", 0f); content.animate()
anim.setDuration(duration); .alpha(0f)
anim.addListener(new AnimatorListenerAdapter() { .setDuration(duration)
public void onAnimationEnd(Animator animation) { .setListener(new AnimatorListenerAdapter() {
// We are about to trigger the workspace cling, so don't do anything else public void onAnimationEnd(Animator animation) {
setVisibility(View.GONE); // We are about to trigger the workspace cling, so don't do anything else
postCb.run(); setVisibility(View.GONE);
}; postCb.run();
}); };
anim.start(); })
.start();
} else { } else {
ObjectAnimator anim = LauncherAnimUtils.ofFloat(this, "alpha", 0f); animate()
anim.setDuration(duration); .alpha(0f)
anim.addListener(new AnimatorListenerAdapter() { .setDuration(duration)
public void onAnimationEnd(Animator animation) { .setListener(new AnimatorListenerAdapter() {
setVisibility(View.GONE); public void onAnimationEnd(Animator animation) {
postCb.run(); // We are about to trigger the workspace cling, so don't do anything else
}; setVisibility(View.GONE);
}); postCb.run();
anim.start(); };
})
.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; mIsInitialized = false;
} }
void bringScrimToFront() {
if (mScrimView != null) {
mScrimView.bringToFront();
}
}
@Override @Override
public void setInsets(Rect insets) { public void setInsets(Rect insets) {
mInsets.set(insets); mInsets.set(insets);
@@ -262,13 +299,12 @@ public class Cling extends FrameLayout implements Insettable, View.OnLongClickLi
// Draw the background // Draw the background
Bitmap eraseBg = null; Bitmap eraseBg = null;
Canvas eraseCanvas = 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.setBounds(0, 0, getMeasuredWidth(), getMeasuredHeight());
mBackground.draw(canvas); 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) || } else if (mDrawIdentifier.equals(WORKSPACE_PORTRAIT) ||
mDrawIdentifier.equals(WORKSPACE_LANDSCAPE) || mDrawIdentifier.equals(WORKSPACE_LANDSCAPE) ||
mDrawIdentifier.equals(WORKSPACE_LARGE)) { mDrawIdentifier.equals(WORKSPACE_LARGE)) {
@@ -276,9 +312,9 @@ public class Cling extends FrameLayout implements Insettable, View.OnLongClickLi
eraseBg = Bitmap.createBitmap(getMeasuredWidth(), getMeasuredHeight(), eraseBg = Bitmap.createBitmap(getMeasuredWidth(), getMeasuredHeight(),
Bitmap.Config.ARGB_8888); Bitmap.Config.ARGB_8888);
eraseCanvas = new Canvas(eraseBg); eraseCanvas = new Canvas(eraseBg);
eraseCanvas.drawColor(0xdd000000); eraseCanvas.drawColor(mBackgroundColor);
} else { } else {
canvas.drawColor(0xdd000000); canvas.drawColor(mBackgroundColor);
} }
// Draw everything else // 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); setLayerType(LAYER_TYPE_NONE, null);
Cling cling = mLauncher.showFirstRunFoldersCling(); Cling cling = mLauncher.showFirstRunFoldersCling();
if (cling != null) { if (cling != null) {
cling.bringToFront(); cling.bringScrimToFront();
bringToFront(); bringToFront();
cling.bringToFront();
} }
setFocusOnFirstChild(); setFocusOnFirstChild();
} }
+12 -9
View File
@@ -274,7 +274,7 @@ public class Launcher extends Activity
private boolean mUserPresent = true; private boolean mUserPresent = true;
private boolean mVisible = false; private boolean mVisible = false;
private boolean mAttached = 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 final boolean DISABLE_CUSTOM_CLINGS = true;
private static LocaleConfiguration sLocaleConfiguration = null; private static LocaleConfiguration sLocaleConfiguration = null;
@@ -4064,11 +4064,15 @@ public class Launcher extends Activity
return true; return true;
} }
private Cling initCling(int clingId, int[] positionData, boolean animate, private Cling initCling(int clingId, int scrimId, boolean animate,
boolean dimNavBarVisibilty) { 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) { if (cling != null) {
cling.init(this, positionData); cling.init(this, scrim);
cling.show(animate, SHOW_CLING_DURATION); cling.show(animate, SHOW_CLING_DURATION);
if (dimNavBarVisibilty) { if (dimNavBarVisibilty) {
@@ -4087,7 +4091,6 @@ public class Launcher extends Activity
final Runnable cleanUpClingCb = new Runnable() { final Runnable cleanUpClingCb = new Runnable() {
public void run() { public void run() {
cling.cleanup(); cling.cleanup();
/*
// We should update the shared preferences on a background thread // We should update the shared preferences on a background thread
new Thread("dismissClingThread") { new Thread("dismissClingThread") {
public void run() { public void run() {
@@ -4096,7 +4099,6 @@ public class Launcher extends Activity
editor.commit(); editor.commit();
} }
}.start(); }.start();
*/
if (postAnimationCb != null) { if (postAnimationCb != null) {
postAnimationCb.run(); postAnimationCb.run();
} }
@@ -4177,7 +4179,7 @@ public class Launcher extends Activity
ccHint.setVisibility(View.VISIBLE); ccHint.setVisibility(View.VISIBLE);
} }
} }
initCling(R.id.first_run_cling, null, false, true); initCling(R.id.first_run_cling, 0, false, true);
} else { } else {
removeCling(R.id.first_run_cling); 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 // Enable the clings only if they have not been dismissed before
if (isClingsEnabled() && if (isClingsEnabled() &&
!mSharedPrefs.getBoolean(Cling.WORKSPACE_CLING_DISMISSED_KEY, false)) { !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 { } else {
removeCling(R.id.workspace_cling); 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 // Enable the clings only if they have not been dismissed before
if (isClingsEnabled() && if (isClingsEnabled() &&
!mSharedPrefs.getBoolean(Cling.FOLDER_CLING_DISMISSED_KEY, false)) { !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; return cling;
} else { } else {
removeCling(R.id.folder_cling); removeCling(R.id.folder_cling);