Skip to content

Commit 8b4d73b

Browse files
sganovAndroid (Google) Code Review
authored andcommitted
Merge "Revert "Showing default activity in activity chooser view only if enough space."" into jb-dev
2 parents 0e29ac9 + b9f286e commit 8b4d73b

File tree

6 files changed

+10
-70
lines changed

6 files changed

+10
-70
lines changed

core/java/android/widget/ActivityChooserModel.java

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -764,16 +764,6 @@ private void pruneExcessiveHistoricalRecordsIfNeeded() {
764764
}
765765
}
766766

767-
/**
768-
* Gets whether the given observer is already registered.
769-
*
770-
* @param observer The observer.
771-
* @return True if already registered.
772-
*/
773-
public boolean isRegisteredObserver(DataSetObserver observer) {
774-
return mObservers.contains(observer);
775-
}
776-
777767
/**
778768
* Represents a record in the history.
779769
*/

core/java/android/widget/ActivityChooserView.java

Lines changed: 9 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,8 @@
2020

2121
import android.content.Context;
2222
import android.content.Intent;
23-
import android.content.pm.ActivityInfo;
2423
import android.content.pm.PackageManager;
2524
import android.content.pm.ResolveInfo;
26-
import android.content.res.Configuration;
2725
import android.content.res.Resources;
2826
import android.content.res.TypedArray;
2927
import android.database.DataSetObserver;
@@ -175,11 +173,6 @@ public void onGlobalLayout() {
175173
*/
176174
private int mDefaultActionButtonContentDescription;
177175

178-
/**
179-
* Whether this view has a default activity affordance.
180-
*/
181-
private boolean mHasDefaultActivity;
182-
183176
/**
184177
* Create a new instance.
185178
*
@@ -252,8 +245,6 @@ public void onChanged() {
252245
Resources resources = context.getResources();
253246
mListPopupMaxWidth = Math.max(resources.getDisplayMetrics().widthPixels / 2,
254247
resources.getDimensionPixelSize(com.android.internal.R.dimen.config_prefDialogWidth));
255-
256-
updateHasDefaultActivity();
257248
}
258249

259250
/**
@@ -267,21 +258,6 @@ public void setActivityChooserModel(ActivityChooserModel dataModel) {
267258
}
268259
}
269260

270-
@Override
271-
protected void onConfigurationChanged(Configuration newConfig) {
272-
Configuration oldConfig = mContext.getResources().getConfiguration();
273-
final int changed = oldConfig.diff(newConfig);
274-
if ((changed & ActivityInfo.CONFIG_SCREEN_SIZE) != 0
275-
|| (changed & ActivityInfo.CONFIG_ORIENTATION) != 0) {
276-
updateHasDefaultActivity();
277-
}
278-
}
279-
280-
private void updateHasDefaultActivity() {
281-
mHasDefaultActivity = mContext.getResources().getBoolean(
282-
R.bool.activity_chooser_view_has_default_activity);
283-
}
284-
285261
/**
286262
* Sets the background for the button that expands the activity
287263
* overflow list.
@@ -407,8 +383,7 @@ public boolean isShowingPopup() {
407383
protected void onAttachedToWindow() {
408384
super.onAttachedToWindow();
409385
ActivityChooserModel dataModel = mAdapter.getDataModel();
410-
if (dataModel != null
411-
&& !dataModel.isRegisteredObserver(mModelDataSetOberver)) {
386+
if (dataModel != null) {
412387
dataModel.registerObserver(mModelDataSetOberver);
413388
}
414389
mIsAttachedToWindow = true;
@@ -418,8 +393,7 @@ protected void onAttachedToWindow() {
418393
protected void onDetachedFromWindow() {
419394
super.onDetachedFromWindow();
420395
ActivityChooserModel dataModel = mAdapter.getDataModel();
421-
if (dataModel != null
422-
&& dataModel.isRegisteredObserver(mModelDataSetOberver)) {
396+
if (dataModel != null) {
423397
dataModel.unregisterObserver(mModelDataSetOberver);
424398
}
425399
ViewTreeObserver viewTreeObserver = getViewTreeObserver();
@@ -522,7 +496,7 @@ private void updateAppearance() {
522496
// Default activity button.
523497
final int activityCount = mAdapter.getActivityCount();
524498
final int historySize = mAdapter.getHistorySize();
525-
if (mHasDefaultActivity && activityCount > 0 && historySize > 0) {
499+
if (activityCount > 0 && historySize > 0) {
526500
mDefaultActivityButton.setVisibility(VISIBLE);
527501
ResolveInfo activity = mAdapter.getDefaultActivity();
528502
PackageManager packageManager = mContext.getPackageManager();
@@ -538,9 +512,9 @@ private void updateAppearance() {
538512
}
539513
// Activity chooser content.
540514
if (mDefaultActivityButton.getVisibility() == VISIBLE) {
541-
mActivityChooserContent.setBackground(mActivityChooserContentBackground);
515+
mActivityChooserContent.setBackgroundDrawable(mActivityChooserContentBackground);
542516
} else {
543-
mActivityChooserContent.setBackground(null);
517+
mActivityChooserContent.setBackgroundDrawable(null);
544518
}
545519
}
546520

@@ -603,7 +577,7 @@ public void onClick(View view) {
603577
// OnLongClickListener#onLongClick
604578
@Override
605579
public boolean onLongClick(View view) {
606-
if (mHasDefaultActivity && view == mDefaultActivityButton) {
580+
if (view == mDefaultActivityButton) {
607581
if (mAdapter.getCount() > 0) {
608582
mIsSelectingDefaultActivity = true;
609583
showPopupUnchecked(mInitialActivityCount);
@@ -656,16 +630,14 @@ private class ActivityChooserViewAdapter extends BaseAdapter {
656630

657631
public void setDataModel(ActivityChooserModel dataModel) {
658632
ActivityChooserModel oldDataModel = mAdapter.getDataModel();
659-
if (oldDataModel != null) {
633+
if (oldDataModel != null && isShown()) {
660634
oldDataModel.unregisterObserver(mModelDataSetOberver);
661635
}
662636
mDataModel = dataModel;
663-
if (dataModel != null) {
637+
if (dataModel != null && isShown()) {
664638
dataModel.registerObserver(mModelDataSetOberver);
665-
notifyDataSetChanged();
666-
} else {
667-
notifyDataSetInvalidated();
668639
}
640+
notifyDataSetChanged();
669641
}
670642

671643
@Override

core/java/android/widget/ShareActionProvider.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,6 @@
4444
* <code>
4545
* // In Activity#onCreateOptionsMenu
4646
* public boolean onCreateOptionsMenu(Menu menu) {
47-
* getManuInflater().inflate(R.menu.my_menu, menu);
4847
* // Get the menu item.
4948
* MenuItem menuItem = menu.findItem(R.id.my_menu_item);
5049
* // Get the provider and hold onto it to set/change the share intent.
@@ -246,7 +245,7 @@ public void onPrepareSubMenu(SubMenu subMenu) {
246245
* call {@link android.app.Activity#invalidateOptionsMenu()} to recreate the
247246
* action view. You should <strong>not</strong> call
248247
* {@link android.app.Activity#invalidateOptionsMenu()} from
249-
* {@link android.app.Activity#onCreateOptionsMenu(Menu)}.
248+
* {@link android.app.Activity#onCreateOptionsMenu(Menu)}."
250249
* <p>
251250
* <code>
252251
* private void doShare(Intent intent) {

core/res/res/values-w500dp/bools.xml

Lines changed: 0 additions & 19 deletions
This file was deleted.

core/res/res/values/bools.xml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,5 +22,4 @@
2222
<bool name="show_ongoing_ime_switcher">true</bool>
2323
<bool name="action_bar_expanded_action_views_exclusive">true</bool>
2424
<bool name="target_honeycomb_needs_options_menu">true</bool>
25-
<bool name="activity_chooser_view_has_default_activity">false</bool>
2625
</resources>

core/res/res/values/public.xml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1380,7 +1380,6 @@
13801380
<java-symbol type="bool" name="config_wifi_dual_band_support" />
13811381
<java-symbol type="bool" name="config_wimaxEnabled" />
13821382
<java-symbol type="bool" name="show_ongoing_ime_switcher" />
1383-
<java-symbol type="bool" name="activity_chooser_view_has_default_activity" />
13841383
<java-symbol type="color" name="config_defaultNotificationColor" />
13851384
<java-symbol type="drawable" name="ic_notification_ime_default" />
13861385
<java-symbol type="drawable" name="stat_notify_car_mode" />

0 commit comments

Comments
 (0)