1616
1717package android .widget ;
1818
19+ import com .android .internal .R ;
20+
1921import android .content .Context ;
2022import android .content .Intent ;
2123import android .content .pm .PackageManager ;
2527import android .database .DataSetObserver ;
2628import android .graphics .drawable .Drawable ;
2729import android .util .AttributeSet ;
30+ import android .view .ActionProvider ;
2831import android .view .LayoutInflater ;
2932import android .view .View ;
3033import android .view .ViewGroup ;
3134import android .view .ViewTreeObserver ;
3235import android .view .ViewTreeObserver .OnGlobalLayoutListener ;
3336import android .widget .ActivityChooserModel .ActivityChooserModelClient ;
3437
35- import com .android .internal .R ;
36-
3738/**
3839 * This class is a view for choosing an activity for handling a given {@link Intent}.
3940 * <p>
@@ -104,6 +105,11 @@ public class ActivityChooserView extends ViewGroup implements ActivityChooserMod
104105 */
105106 private final int mListPopupMaxWidth ;
106107
108+ /**
109+ * The ActionProvider hosting this view, if applicable.
110+ */
111+ ActionProvider mProvider ;
112+
107113 /**
108114 * Observer for the model data.
109115 */
@@ -129,6 +135,9 @@ public void onGlobalLayout() {
129135 getListPopupWindow ().dismiss ();
130136 } else {
131137 getListPopupWindow ().show ();
138+ if (mProvider != null ) {
139+ mProvider .subUiVisibilityChanged (true );
140+ }
132141 }
133142 }
134143 }
@@ -259,6 +268,14 @@ public void setExpandActivityOverflowButtonDrawable(Drawable drawable) {
259268 mExpandActivityOverflowButtonImage .setImageDrawable (drawable );
260269 }
261270
271+ /**
272+ * Set the provider hosting this view, if applicable.
273+ * @hide Internal use only
274+ */
275+ public void setProvider (ActionProvider provider ) {
276+ mProvider = provider ;
277+ }
278+
262279 /**
263280 * Shows the popup window with activities.
264281 *
@@ -307,6 +324,9 @@ private void showPopupUnchecked(int maxActivityCount) {
307324 final int contentWidth = Math .min (mAdapter .measureContentWidth (), mListPopupMaxWidth );
308325 popupWindow .setContentWidth (contentWidth );
309326 popupWindow .show ();
327+ if (mProvider != null ) {
328+ mProvider .subUiVisibilityChanged (true );
329+ }
310330 }
311331 }
312332
@@ -525,6 +545,9 @@ public boolean onLongClick(View view) {
525545 // PopUpWindow.OnDismissListener#onDismiss
526546 public void onDismiss () {
527547 notifyOnDismissListener ();
548+ if (mProvider != null ) {
549+ mProvider .subUiVisibilityChanged (false );
550+ }
528551 }
529552
530553 private void notifyOnDismissListener () {
0 commit comments