Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 414051b8 authored by Svetoslav Ganov's avatar Svetoslav Ganov
Browse files

Update the style of the action bar share UI

1. Made the background of the default and expand buttons change when pressed.

2. When the share UI is shown on the overflow the "Show all" menu item was
   present event if all items are shown.

3. The width of the popup for picking an item was different for the action
   view and overflow case.

bug:5039747

Change-Id: I72afbcf86c93596c7eba4d70c002eab060ff31f8
parent 4a49d9fe
Loading
Loading
Loading
Loading
+0 −1
Original line number Diff line number Diff line
@@ -431,7 +431,6 @@ public class ActivityChooserModel extends DataSetObservable {
     */
    public Intent chooseActivity(int index) {
        ActivityResolveInfo chosenActivity = mActivites.get(index);
        ActivityResolveInfo defaultActivity = mActivites.get(0);

        ComponentName chosenName = new ComponentName(
                chosenActivity.resolveInfo.activityInfo.packageName,
+16 −5
Original line number Diff line number Diff line
@@ -20,6 +20,7 @@ import android.content.Context;
import android.content.Intent;
import android.content.pm.PackageManager;
import android.content.pm.ResolveInfo;
import android.content.res.Resources;
import android.content.res.TypedArray;
import android.database.DataSetObserver;
import android.graphics.Canvas;
@@ -91,6 +92,11 @@ public class ActivityChooserView extends ViewGroup implements ActivityChooserMod
     */
    private final ImageButton mDefaultActionButton;

    /**
     * The maximal width of the list popup.
     */
    private final int mListPopupMaxWidth;

    /**
     * Observer for the model data.
     */
@@ -185,7 +191,7 @@ public class ActivityChooserView extends ViewGroup implements ActivityChooserMod

        mExpandActivityOverflowButton = (ImageButton) findViewById(R.id.expand_activities_button);
        mExpandActivityOverflowButton.setOnClickListener(mCallbacks);
        mExpandActivityOverflowButton.setBackgroundDrawable(expandActivityOverflowButtonDrawable);
        mExpandActivityOverflowButton.setImageDrawable(expandActivityOverflowButtonDrawable);

        mAdapter = new ActivityChooserViewAdapter();
        mAdapter.registerDataSetObserver(new DataSetObserver() {
@@ -195,6 +201,10 @@ public class ActivityChooserView extends ViewGroup implements ActivityChooserMod
                updateButtons();
            }
        });

        Resources resources = context.getResources();
        mListPopupMaxWidth = Math.max(resources.getDisplayMetrics().widthPixels / 2,
              resources.getDimensionPixelSize(com.android.internal.R.dimen.config_prefDialogWidth));
    }

    /**
@@ -220,7 +230,7 @@ public class ActivityChooserView extends ViewGroup implements ActivityChooserMod
     * @param drawable The drawable.
     */
    public void setExpandActivityOverflowButtonDrawable(Drawable drawable) {
        mExpandActivityOverflowButton.setBackgroundDrawable(drawable);
        mExpandActivityOverflowButton.setImageDrawable(drawable);
    }

    /**
@@ -264,7 +274,8 @@ public class ActivityChooserView extends ViewGroup implements ActivityChooserMod
            } else {
                mAdapter.setShowDefaultActivity(false);
            }
            popupWindow.setContentWidth(mAdapter.measureContentWidth());
            final int contentWidth = Math.min(mAdapter.measureContentWidth(), mListPopupMaxWidth);
            popupWindow.setContentWidth(contentWidth);
            popupWindow.show();
        }
    }
@@ -390,7 +401,7 @@ public class ActivityChooserView extends ViewGroup implements ActivityChooserMod
            }
            ResolveInfo activity = mAdapter.getDefaultActivity();
            PackageManager packageManager = mContext.getPackageManager();
            mDefaultActionButton.setBackgroundDrawable(activity.loadIcon(packageManager));
            mDefaultActionButton.setImageDrawable(activity.loadIcon(packageManager));
        } else {
            mDefaultActionButton.setVisibility(View.INVISIBLE);
            mExpandActivityOverflowButton.setEnabled(false);
@@ -574,7 +585,7 @@ public class ActivityChooserView extends ViewGroup implements ActivityChooserMod
                    // Set the icon
                    ImageView iconView = (ImageView) convertView.findViewById(R.id.icon);
                    ResolveInfo activity = (ResolveInfo) getItem(position);
                    iconView.setBackgroundDrawable(activity.loadIcon(packageManager));
                    iconView.setImageDrawable(activity.loadIcon(packageManager));
                    // Set the title.
                    TextView titleView = (TextView) convertView.findViewById(R.id.title);
                    titleView.setText(activity.loadLabel(packageManager));
+11 −8
Original line number Diff line number Diff line
@@ -162,9 +162,11 @@ public class ShareActionProvider extends ActionProvider {
                .setOnMenuItemClickListener(mOnMenuItemClickListener);
        }

        if (collapsedActivityCount < expandedActivityCount) {
            // Add a sub-menu for showing all activities as a list item.
            SubMenu expandedSubMenu = subMenu.addSubMenu(Menu.NONE, collapsedActivityCount,
                collapsedActivityCount, mContext.getString(R.string.activity_chooser_view_see_all));
                    collapsedActivityCount,
                    mContext.getString(R.string.activity_chooser_view_see_all));
            for (int i = 0; i < expandedActivityCount; i++) {
                ResolveInfo activity = dataModel.getActivity(i);
                expandedSubMenu.add(0, i, i, activity.loadLabel(packageManager))
@@ -172,6 +174,7 @@ public class ShareActionProvider extends ActionProvider {
                    .setOnMenuItemClickListener(mOnMenuItemClickListener);
            }
        }
    }

    /**
     * Sets the file name of a file for persisting the share history which
+2 −6
Original line number Diff line number Diff line
@@ -23,13 +23,9 @@
    style="?android:attr/actionButtonStyle">

    <ImageButton android:id="@+id/default_activity_button"
        android:layout_width="32dip"
        android:layout_height="32dip"
        android:layout_marginRight="8dip" />
        style="@style/Widget.ActivityChooserViewButton" />

    <ImageButton android:id="@+id/expand_activities_button"
        android:layout_width="32dip"
        android:layout_height="32dip"
        android:layout_marginLeft="8dip" />
        style="@style/Widget.ActivityChooserViewButton" />

</LinearLayout>
+1 −0
Original line number Diff line number Diff line
@@ -20,6 +20,7 @@
    android:layout_height="?android:attr/dropdownListPreferredItemHeight"
    android:paddingLeft="16dip"
    android:paddingRight="16dip"
    android:minWidth="196dip"
    android:background="?android:attr/activatedBackgroundIndicator"
    android:orientation="vertical" >

Loading