Merge "Update the sharing UI according to latest UX specs."
@@ -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();
|
||||
|
||||
@@ -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;
|
||||
@@ -75,6 +76,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;
|
||||
*/
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
BIN
core/res/res/drawable-hdpi/ab_share_pack_holo_dark.9.png
Normal file
|
After Width: | Height: | Size: 2.8 KiB |
BIN
core/res/res/drawable-hdpi/ab_share_pack_holo_light.9.png
Normal file
|
After Width: | Height: | Size: 2.8 KiB |
|
Before Width: | Height: | Size: 1.1 KiB After Width: | Height: | Size: 467 B |
|
Before Width: | Height: | Size: 999 B After Width: | Height: | Size: 505 B |
BIN
core/res/res/drawable-mdpi/ab_share_pack_holo_dark.9.png
Normal file
|
After Width: | Height: | Size: 2.8 KiB |
BIN
core/res/res/drawable-mdpi/ab_share_pack_holo_light.9.png
Normal file
|
After Width: | Height: | Size: 2.8 KiB |
|
Before Width: | Height: | Size: 874 B After Width: | Height: | Size: 332 B |
|
Before Width: | Height: | Size: 763 B After Width: | Height: | Size: 355 B |
BIN
core/res/res/drawable-xhdpi/ab_share_pack_holo_dark.9.png
Normal file
|
After Width: | Height: | Size: 2.8 KiB |
BIN
core/res/res/drawable-xhdpi/ab_share_pack_holo_light.9.png
Normal file
|
After Width: | Height: | Size: 2.8 KiB |
|
Before Width: | Height: | Size: 1.5 KiB After Width: | Height: | Size: 699 B |
|
Before Width: | Height: | Size: 1.3 KiB After Width: | Height: | Size: 935 B |
@@ -19,33 +19,9 @@
|
||||
<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">
|
||||
|
||||
<FrameLayout
|
||||
android:id="@+id/default_activity_button"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_gravity="center"
|
||||
android:focusable="true"
|
||||
android:addStatesFromChildren="true"
|
||||
android:background="?android:attr/actionBarItemBackground">
|
||||
|
||||
<ImageView android:id="@+id/image"
|
||||
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:scaleType="fitCenter"
|
||||
android:adjustViewBounds="true" />
|
||||
|
||||
</FrameLayout>
|
||||
style="?android:attr/activityChooserViewStyle">
|
||||
|
||||
<FrameLayout
|
||||
android:id="@+id/expand_activities_button"
|
||||
@@ -60,10 +36,32 @@
|
||||
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/default_activity_button"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_gravity="center"
|
||||
android:focusable="true"
|
||||
android:addStatesFromChildren="true"
|
||||
android:background="?android:attr/actionBarItemBackground">
|
||||
|
||||
<ImageView android:id="@+id/image"
|
||||
android:layout_width="32dip"
|
||||
android:layout_height="32dip"
|
||||
android:layout_gravity="center"
|
||||
android:layout_marginTop="2dip"
|
||||
android:layout_marginBottom="2dip"
|
||||
android:layout_marginLeft="12dip"
|
||||
android:layout_marginRight="12dip"
|
||||
android:scaleType="fitCenter"
|
||||
android:adjustViewBounds="true" />
|
||||
|
||||
|
||||
@@ -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 />
|
||||
|
||||
|
||||
@@ -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>
|
||||
|
||||
|
||||
@@ -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>
|
||||
|
||||