diff options
author | Svetoslav Ganov <svetoslavganov@google.com> | 2011-09-07 16:38:40 -0700 |
---|---|---|
committer | Svetoslav Ganov <svetoslavganov@google.com> | 2011-09-08 18:19:13 -0700 |
commit | f2e754002166b8126e6faf8c494da5835432d572 (patch) | |
tree | 6336b979a274ff8fa7f4608ec8ad11af673fa9ec | |
parent | 5e8752595f7a3d3dd1e0d469ac275295e38bcfe1 (diff) | |
download | frameworks_base-f2e754002166b8126e6faf8c494da5835432d572.zip frameworks_base-f2e754002166b8126e6faf8c494da5835432d572.tar.gz frameworks_base-f2e754002166b8126e6faf8c494da5835432d572.tar.bz2 |
Update the sharing UI according to latest UX specs.
bug:3362473
Change-Id: Ic302c289e28061f53446f98e5b97573d57d9cfb8
18 files changed, 86 insertions, 33 deletions
diff --git a/core/java/android/widget/ActivityChooserModel.java b/core/java/android/widget/ActivityChooserModel.java index 9fea506..bc44521 100644 --- a/core/java/android/widget/ActivityChooserModel.java +++ b/core/java/android/widget/ActivityChooserModel.java @@ -663,6 +663,17 @@ public class ActivityChooserModel extends DataSetObservable { } } + /** + * Gets the history size. + * + * @return The history size. + */ + public int getHistorySize() { + synchronized (mInstanceLock) { + return mHistoricalRecords.size(); + } + } + @Override protected void finalize() throws Throwable { super.finalize(); diff --git a/core/java/android/widget/ActivityChooserView.java b/core/java/android/widget/ActivityChooserView.java index fcc7938..312303d 100644 --- a/core/java/android/widget/ActivityChooserView.java +++ b/core/java/android/widget/ActivityChooserView.java @@ -28,6 +28,7 @@ import android.graphics.drawable.Drawable; import android.util.AttributeSet; import android.view.LayoutInflater; import android.view.View; +import android.view.View.MeasureSpec; import android.view.ViewGroup; import android.view.ViewTreeObserver; import android.view.ViewTreeObserver.OnGlobalLayoutListener; @@ -76,6 +77,11 @@ public class ActivityChooserView extends ViewGroup implements ActivityChooserMod private final LinearLayout mActivityChooserContent; /** + * Stores the background drawable to allow hiding and latter showing. + */ + private final Drawable mActivityChooserContentBackground; + + /** * The expand activities action button; */ private final FrameLayout mExpandActivityOverflowButton; @@ -194,12 +200,15 @@ public class ActivityChooserView extends ViewGroup implements ActivityChooserMod Drawable expandActivityOverflowButtonDrawable = attributesArray.getDrawable( R.styleable.ActivityChooserView_expandActivityOverflowButtonDrawable); + attributesArray.recycle(); + LayoutInflater inflater = LayoutInflater.from(mContext); inflater.inflate(R.layout.activity_chooser_view, this, true); mCallbacks = new Callbacks(); mActivityChooserContent = (LinearLayout) findViewById(R.id.activity_chooser_view_content); + mActivityChooserContentBackground = mActivityChooserContent.getBackground(); mDefaultActivityButton = (FrameLayout) findViewById(R.id.default_activity_button); mDefaultActivityButton.setOnClickListener(mCallbacks); @@ -217,7 +226,7 @@ public class ActivityChooserView extends ViewGroup implements ActivityChooserMod @Override public void onChanged() { super.onChanged(); - updateButtons(); + updateAppearance(); } }); @@ -352,9 +361,16 @@ public class ActivityChooserView extends ViewGroup implements ActivityChooserMod @Override protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) { - mActivityChooserContent.measure(widthMeasureSpec, heightMeasureSpec); - setMeasuredDimension(mActivityChooserContent.getMeasuredWidth(), - mActivityChooserContent.getMeasuredHeight()); + View child = mActivityChooserContent; + // If the default action is not visible we want to be as tall as the + // ActionBar so if this widget is used in the latter it will look as + // a normal action button. + if (mDefaultActivityButton.getVisibility() != VISIBLE) { + heightMeasureSpec = MeasureSpec.makeMeasureSpec(MeasureSpec.getSize(heightMeasureSpec), + MeasureSpec.EXACTLY); + } + measureChild(child, widthMeasureSpec, heightMeasureSpec); + setMeasuredDimension(child.getMeasuredWidth(), child.getMeasuredHeight()); } @Override @@ -367,11 +383,6 @@ public class ActivityChooserView extends ViewGroup implements ActivityChooserMod } } - @Override - protected void onDraw(Canvas canvas) { - mActivityChooserContent.onDraw(canvas); - } - public ActivityChooserModel getDataModel() { return mAdapter.getDataModel(); } @@ -417,21 +428,29 @@ public class ActivityChooserView extends ViewGroup implements ActivityChooserMod /** * Updates the buttons state. */ - private void updateButtons() { + private void updateAppearance() { + // Expand overflow button. + if (mAdapter.getCount() > 0) { + mExpandActivityOverflowButton.setEnabled(true); + } else { + mExpandActivityOverflowButton.setEnabled(false); + } + // Default activity button. final int activityCount = mAdapter.getActivityCount(); - if (activityCount > 0) { + final int historySize = mAdapter.getHistorySize(); + if (activityCount > 0 && historySize > 0) { mDefaultActivityButton.setVisibility(VISIBLE); - if (mAdapter.getCount() > 0) { - mExpandActivityOverflowButton.setEnabled(true); - } else { - mExpandActivityOverflowButton.setEnabled(false); - } ResolveInfo activity = mAdapter.getDefaultActivity(); PackageManager packageManager = mContext.getPackageManager(); mDefaultActivityButtonImage.setImageDrawable(activity.loadIcon(packageManager)); } else { - mDefaultActivityButton.setVisibility(View.INVISIBLE); - mExpandActivityOverflowButton.setEnabled(false); + mDefaultActivityButton.setVisibility(View.GONE); + } + // Activity chooser content. + if (mDefaultActivityButton.getVisibility() == VISIBLE) { + mActivityChooserContent.setBackgroundDrawable(mActivityChooserContentBackground); + } else { + mActivityChooserContent.setBackgroundDrawable(null); } } @@ -678,6 +697,10 @@ public class ActivityChooserView extends ViewGroup implements ActivityChooserMod return mDataModel.getActivityCount(); } + public int getHistorySize() { + return mDataModel.getHistorySize(); + } + public int getMaxActivityCount() { return mMaxActivityCount; } diff --git a/core/res/res/drawable-hdpi/ab_share_pack_holo_dark.9.png b/core/res/res/drawable-hdpi/ab_share_pack_holo_dark.9.png Binary files differnew file mode 100644 index 0000000..6c14157 --- /dev/null +++ b/core/res/res/drawable-hdpi/ab_share_pack_holo_dark.9.png diff --git a/core/res/res/drawable-hdpi/ab_share_pack_holo_light.9.png b/core/res/res/drawable-hdpi/ab_share_pack_holo_light.9.png Binary files differnew file mode 100644 index 0000000..f4ff16b --- /dev/null +++ b/core/res/res/drawable-hdpi/ab_share_pack_holo_light.9.png diff --git a/core/res/res/drawable-hdpi/ic_menu_share_holo_dark.png b/core/res/res/drawable-hdpi/ic_menu_share_holo_dark.png Binary files differindex db011be..6f747c8 100644 --- a/core/res/res/drawable-hdpi/ic_menu_share_holo_dark.png +++ b/core/res/res/drawable-hdpi/ic_menu_share_holo_dark.png diff --git a/core/res/res/drawable-hdpi/ic_menu_share_holo_light.png b/core/res/res/drawable-hdpi/ic_menu_share_holo_light.png Binary files differindex d9a9a73..682b2fd 100644 --- a/core/res/res/drawable-hdpi/ic_menu_share_holo_light.png +++ b/core/res/res/drawable-hdpi/ic_menu_share_holo_light.png diff --git a/core/res/res/drawable-mdpi/ab_share_pack_holo_dark.9.png b/core/res/res/drawable-mdpi/ab_share_pack_holo_dark.9.png Binary files differnew file mode 100644 index 0000000..ed4ba34 --- /dev/null +++ b/core/res/res/drawable-mdpi/ab_share_pack_holo_dark.9.png diff --git a/core/res/res/drawable-mdpi/ab_share_pack_holo_light.9.png b/core/res/res/drawable-mdpi/ab_share_pack_holo_light.9.png Binary files differnew file mode 100644 index 0000000..1983c68 --- /dev/null +++ b/core/res/res/drawable-mdpi/ab_share_pack_holo_light.9.png diff --git a/core/res/res/drawable-mdpi/ic_menu_share_holo_dark.png b/core/res/res/drawable-mdpi/ic_menu_share_holo_dark.png Binary files differindex 306cac8..6bf21e3 100644 --- a/core/res/res/drawable-mdpi/ic_menu_share_holo_dark.png +++ b/core/res/res/drawable-mdpi/ic_menu_share_holo_dark.png diff --git a/core/res/res/drawable-mdpi/ic_menu_share_holo_light.png b/core/res/res/drawable-mdpi/ic_menu_share_holo_light.png Binary files differindex cc081ad..70fe31a 100644 --- a/core/res/res/drawable-mdpi/ic_menu_share_holo_light.png +++ b/core/res/res/drawable-mdpi/ic_menu_share_holo_light.png diff --git a/core/res/res/drawable-xhdpi/ab_share_pack_holo_dark.9.png b/core/res/res/drawable-xhdpi/ab_share_pack_holo_dark.9.png Binary files differnew file mode 100644 index 0000000..55099d4 --- /dev/null +++ b/core/res/res/drawable-xhdpi/ab_share_pack_holo_dark.9.png diff --git a/core/res/res/drawable-xhdpi/ab_share_pack_holo_light.9.png b/core/res/res/drawable-xhdpi/ab_share_pack_holo_light.9.png Binary files differnew file mode 100644 index 0000000..3c4701f --- /dev/null +++ b/core/res/res/drawable-xhdpi/ab_share_pack_holo_light.9.png diff --git a/core/res/res/drawable-xhdpi/ic_menu_share_holo_dark.png b/core/res/res/drawable-xhdpi/ic_menu_share_holo_dark.png Binary files differindex af72732..45a0f1d 100644 --- a/core/res/res/drawable-xhdpi/ic_menu_share_holo_dark.png +++ b/core/res/res/drawable-xhdpi/ic_menu_share_holo_dark.png diff --git a/core/res/res/drawable-xhdpi/ic_menu_share_holo_light.png b/core/res/res/drawable-xhdpi/ic_menu_share_holo_light.png Binary files differindex 79c162f..528e554 100644 --- a/core/res/res/drawable-xhdpi/ic_menu_share_holo_light.png +++ b/core/res/res/drawable-xhdpi/ic_menu_share_holo_light.png diff --git a/core/res/res/layout/activity_chooser_view.xml b/core/res/res/layout/activity_chooser_view.xml index 82e1f83..4057441 100644 --- a/core/res/res/layout/activity_chooser_view.xml +++ b/core/res/res/layout/activity_chooser_view.xml @@ -19,14 +19,12 @@ <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:id="@+id/activity_chooser_view_content" android:layout_width="wrap_content" - android:layout_height="wrap_content" + android:layout_height="match_parent" android:layout_gravity="center" - android:gravity="center" - style="?android:attr/actionButtonStyle" - android:padding="0dip"> + style="?android:attr/activityChooserViewStyle"> <FrameLayout - android:id="@+id/default_activity_button" + android:id="@+id/expand_activities_button" android:layout_width="wrap_content" android:layout_height="match_parent" android:layout_gravity="center" @@ -38,17 +36,17 @@ android:layout_width="32dip" android:layout_height="32dip" android:layout_gravity="center" - android:layout_marginTop="4dip" - android:layout_marginBottom="4dip" - android:layout_marginLeft="8dip" - android:layout_marginRight="8dip" + android:layout_marginTop="2dip" + android:layout_marginBottom="2dip" + android:layout_marginLeft="12dip" + android:layout_marginRight="12dip" android:scaleType="fitCenter" android:adjustViewBounds="true" /> </FrameLayout> <FrameLayout - android:id="@+id/expand_activities_button" + android:id="@+id/default_activity_button" android:layout_width="wrap_content" android:layout_height="match_parent" android:layout_gravity="center" @@ -60,10 +58,10 @@ android:layout_width="32dip" android:layout_height="32dip" android:layout_gravity="center" - android:layout_marginTop="4dip" - android:layout_marginBottom="4dip" - android:layout_marginLeft="8dip" - android:layout_marginRight="8dip" + android:layout_marginTop="2dip" + android:layout_marginBottom="2dip" + android:layout_marginLeft="12dip" + android:layout_marginRight="12dip" android:scaleType="fitCenter" android:adjustViewBounds="true" /> diff --git a/core/res/res/values/attrs.xml b/core/res/res/values/attrs.xml index 0bf5b0a..bc14ade 100755 --- a/core/res/res/values/attrs.xml +++ b/core/res/res/values/attrs.xml @@ -597,6 +597,9 @@ <!-- The DatePicker style. --> <attr name="datePickerStyle" format="reference" /> + <!-- Default ActivityChooserView style. --> + <attr name="activityChooserViewStyle" format="reference" /> + <!-- Fast scroller styles --> <eat-comment /> diff --git a/core/res/res/values/styles.xml b/core/res/res/values/styles.xml index 1a6a523..5033611 100644 --- a/core/res/res/values/styles.xml +++ b/core/res/res/values/styles.xml @@ -890,6 +890,14 @@ please see styles_device_defaults.xml. <item name="android:textSize">30sp</item> </style> + <style name="Widget.ActivityChooserView"> + <item name="android:gravity">center</item> + <item name="android:background">@android:drawable/ab_share_pack_holo_dark</item> + <item name="android:divider">?android:attr/dividerVertical</item> + <item name="android:showDividers">middle</item> + <item name="android:dividerPadding">6dip</item> + </style> + <style name="TextAppearance.SuggestionHighlight"> <item name="android:textSize">18sp</item> <item name="android:textColor">@android:color/suggestion_highlight_text</item> @@ -1651,6 +1659,9 @@ please see styles_device_defaults.xml. <item name="android:background">@null</item> </style> + <style name="Widget.Holo.ActivityChooserView" parent="Widget.ActivityChooserView"> + </style> + <style name="Widget.Holo.ImageWell" parent="Widget.ImageWell"> </style> @@ -2071,6 +2082,10 @@ please see styles_device_defaults.xml. <style name="Widget.Holo.Light.EditText.NumberPickerInputText" parent="Widget.Holo.EditText.NumberPickerInputText"> </style> + <style name="Widget.Holo.Light.ActivityChooserView" parent="Widget.Holo.ActivityChooserView"> + <item name="android:background">@android:drawable/ab_share_pack_holo_light</item> + </style> + <style name="Widget.Holo.Light.ImageWell" parent="Widget.ImageWell"> </style> diff --git a/core/res/res/values/themes.xml b/core/res/res/values/themes.xml index 6f98e02..cc79006 100644 --- a/core/res/res/values/themes.xml +++ b/core/res/res/values/themes.xml @@ -269,7 +269,8 @@ please see themes_device_defaults.xml. <item name="quickContactBadgeStyleSmallWindowLarge">@android:style/Widget.QuickContactBadgeSmall.WindowLarge</item> <item name="listPopupWindowStyle">@android:style/Widget.ListPopupWindow</item> <item name="popupMenuStyle">@android:style/Widget.PopupMenu</item> - + <item name="activityChooserViewStyle">@android:style/Widget.ActivityChooserView</item> + <!-- Preference styles --> <item name="preferenceScreenStyle">@android:style/Preference.PreferenceScreen</item> <item name="preferenceCategoryStyle">@android:style/Preference.Category</item> @@ -1062,6 +1063,7 @@ please see themes_device_defaults.xml. <item name="listPopupWindowStyle">@android:style/Widget.Holo.ListPopupWindow</item> <item name="popupMenuStyle">@android:style/Widget.Holo.PopupMenu</item> <item name="stackViewStyle">@android:style/Widget.Holo.StackView</item> + <item name="activityChooserViewStyle">@android:style/Widget.Holo.ActivityChooserView</item> <!-- Preference styles --> <item name="preferenceScreenStyle">@android:style/Preference.Holo.PreferenceScreen</item> @@ -1366,6 +1368,7 @@ please see themes_device_defaults.xml. <item name="listPopupWindowStyle">@android:style/Widget.Holo.Light.ListPopupWindow</item> <item name="popupMenuStyle">@android:style/Widget.Holo.Light.PopupMenu</item> <item name="stackViewStyle">@android:style/Widget.Holo.StackView</item> + <item name="activityChooserViewStyle">@android:style/Widget.Holo.Light.ActivityChooserView</item> <!-- Preference styles --> <item name="preferenceScreenStyle">@android:style/Preference.Holo.PreferenceScreen</item> |