Loading core/java/android/widget/ActivityChooserModel.java +10 −0 Original line number Diff line number Diff line Loading @@ -760,6 +760,16 @@ public class ActivityChooserModel extends DataSetObservable { } } /** * Gets whether the given observer is already registered. * * @param observer The observer. * @return True if already registered. */ public boolean isRegisteredObserver(DataSetObserver observer) { return mObservers.contains(observer); } /** * Represents a record in the history. */ Loading core/java/android/widget/ActivityChooserView.java +37 −9 Original line number Diff line number Diff line Loading @@ -20,8 +20,10 @@ import com.android.internal.R; import android.content.Context; import android.content.Intent; import android.content.pm.ActivityInfo; import android.content.pm.PackageManager; import android.content.pm.ResolveInfo; import android.content.res.Configuration; import android.content.res.Resources; import android.content.res.TypedArray; import android.database.DataSetObserver; Loading Loading @@ -173,6 +175,11 @@ public class ActivityChooserView extends ViewGroup implements ActivityChooserMod */ private int mDefaultActionButtonContentDescription; /** * Whether this view has a default activity affordance. */ private boolean mHasDefaultActivity; /** * Create a new instance. * Loading Loading @@ -245,6 +252,8 @@ public class ActivityChooserView extends ViewGroup implements ActivityChooserMod Resources resources = context.getResources(); mListPopupMaxWidth = Math.max(resources.getDisplayMetrics().widthPixels / 2, resources.getDimensionPixelSize(com.android.internal.R.dimen.config_prefDialogWidth)); updateHasDefaultActivity(); } /** Loading @@ -258,6 +267,21 @@ public class ActivityChooserView extends ViewGroup implements ActivityChooserMod } } @Override protected void onConfigurationChanged(Configuration newConfig) { Configuration oldConfig = mContext.getResources().getConfiguration(); final int changed = oldConfig.diff(newConfig); if ((changed & ActivityInfo.CONFIG_SCREEN_SIZE) != 0 || (changed & ActivityInfo.CONFIG_ORIENTATION) != 0) { updateHasDefaultActivity(); } } private void updateHasDefaultActivity() { mHasDefaultActivity = mContext.getResources().getBoolean( R.bool.activity_chooser_view_has_default_activity); } /** * Sets the background for the button that expands the activity * overflow list. Loading Loading @@ -383,7 +407,8 @@ public class ActivityChooserView extends ViewGroup implements ActivityChooserMod protected void onAttachedToWindow() { super.onAttachedToWindow(); ActivityChooserModel dataModel = mAdapter.getDataModel(); if (dataModel != null) { if (dataModel != null && !dataModel.isRegisteredObserver(mModelDataSetOberver)) { dataModel.registerObserver(mModelDataSetOberver); } mIsAttachedToWindow = true; Loading @@ -393,7 +418,8 @@ public class ActivityChooserView extends ViewGroup implements ActivityChooserMod protected void onDetachedFromWindow() { super.onDetachedFromWindow(); ActivityChooserModel dataModel = mAdapter.getDataModel(); if (dataModel != null) { if (dataModel != null && dataModel.isRegisteredObserver(mModelDataSetOberver)) { dataModel.unregisterObserver(mModelDataSetOberver); } ViewTreeObserver viewTreeObserver = getViewTreeObserver(); Loading Loading @@ -496,7 +522,7 @@ public class ActivityChooserView extends ViewGroup implements ActivityChooserMod // Default activity button. final int activityCount = mAdapter.getActivityCount(); final int historySize = mAdapter.getHistorySize(); if (activityCount > 0 && historySize > 0) { if (mHasDefaultActivity && activityCount > 0 && historySize > 0) { mDefaultActivityButton.setVisibility(VISIBLE); ResolveInfo activity = mAdapter.getDefaultActivity(); PackageManager packageManager = mContext.getPackageManager(); Loading @@ -512,9 +538,9 @@ public class ActivityChooserView extends ViewGroup implements ActivityChooserMod } // Activity chooser content. if (mDefaultActivityButton.getVisibility() == VISIBLE) { mActivityChooserContent.setBackgroundDrawable(mActivityChooserContentBackground); mActivityChooserContent.setBackground(mActivityChooserContentBackground); } else { mActivityChooserContent.setBackgroundDrawable(null); mActivityChooserContent.setBackground(null); } } Loading Loading @@ -577,7 +603,7 @@ public class ActivityChooserView extends ViewGroup implements ActivityChooserMod // OnLongClickListener#onLongClick @Override public boolean onLongClick(View view) { if (view == mDefaultActivityButton) { if (mHasDefaultActivity && view == mDefaultActivityButton) { if (mAdapter.getCount() > 0) { mIsSelectingDefaultActivity = true; showPopupUnchecked(mInitialActivityCount); Loading Loading @@ -630,14 +656,16 @@ public class ActivityChooserView extends ViewGroup implements ActivityChooserMod public void setDataModel(ActivityChooserModel dataModel) { ActivityChooserModel oldDataModel = mAdapter.getDataModel(); if (oldDataModel != null && isShown()) { if (oldDataModel != null) { oldDataModel.unregisterObserver(mModelDataSetOberver); } mDataModel = dataModel; if (dataModel != null && isShown()) { if (dataModel != null) { dataModel.registerObserver(mModelDataSetOberver); } notifyDataSetChanged(); } else { notifyDataSetInvalidated(); } } @Override Loading core/java/android/widget/ShareActionProvider.java +6 −1 Original line number Diff line number Diff line Loading @@ -44,6 +44,7 @@ import com.android.internal.R; * <code> * // In Activity#onCreateOptionsMenu * public boolean onCreateOptionsMenu(Menu menu) { * getManuInflater().inflate(R.menu.my_menu, menu); * // Get the menu item. * MenuItem menuItem = menu.findItem(R.id.my_menu_item); * // Get the provider and hold onto it to set/change the share intent. Loading Loading @@ -239,7 +240,11 @@ public class ShareActionProvider extends ActionProvider { * <p> * <strong>Note:</strong> The history file name can be set any time, however * only the action views created by {@link #onCreateActionView()} after setting * the file name will be backed by the provided file. * the file name will be backed by the provided file. Hence, if you are using * a share action provider on a menu item and want to change the history file * based on the type of the currently selected item, you need to call * {@link android.app.Activity#invalidateOptionsMenu()} to force the system * to recreate the menu UI. * <p> * * @param shareHistoryFile The share history file name. Loading core/res/res/values-w500dp/bools.xml 0 → 100644 +19 −0 Original line number Diff line number Diff line <?xml version="1.0" encoding="utf-8"?> <!-- Copyright (C) 2012 The Android Open Source Project Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. --> <resources> <bool name="activity_chooser_view_has_default_activity">true</bool> </resources> No newline at end of file core/res/res/values/bools.xml +1 −0 Original line number Diff line number Diff line Loading @@ -22,4 +22,5 @@ <bool name="show_ongoing_ime_switcher">true</bool> <bool name="action_bar_expanded_action_views_exclusive">true</bool> <bool name="target_honeycomb_needs_options_menu">true</bool> <bool name="activity_chooser_view_has_default_activity">false</bool> </resources> Loading
core/java/android/widget/ActivityChooserModel.java +10 −0 Original line number Diff line number Diff line Loading @@ -760,6 +760,16 @@ public class ActivityChooserModel extends DataSetObservable { } } /** * Gets whether the given observer is already registered. * * @param observer The observer. * @return True if already registered. */ public boolean isRegisteredObserver(DataSetObserver observer) { return mObservers.contains(observer); } /** * Represents a record in the history. */ Loading
core/java/android/widget/ActivityChooserView.java +37 −9 Original line number Diff line number Diff line Loading @@ -20,8 +20,10 @@ import com.android.internal.R; import android.content.Context; import android.content.Intent; import android.content.pm.ActivityInfo; import android.content.pm.PackageManager; import android.content.pm.ResolveInfo; import android.content.res.Configuration; import android.content.res.Resources; import android.content.res.TypedArray; import android.database.DataSetObserver; Loading Loading @@ -173,6 +175,11 @@ public class ActivityChooserView extends ViewGroup implements ActivityChooserMod */ private int mDefaultActionButtonContentDescription; /** * Whether this view has a default activity affordance. */ private boolean mHasDefaultActivity; /** * Create a new instance. * Loading Loading @@ -245,6 +252,8 @@ public class ActivityChooserView extends ViewGroup implements ActivityChooserMod Resources resources = context.getResources(); mListPopupMaxWidth = Math.max(resources.getDisplayMetrics().widthPixels / 2, resources.getDimensionPixelSize(com.android.internal.R.dimen.config_prefDialogWidth)); updateHasDefaultActivity(); } /** Loading @@ -258,6 +267,21 @@ public class ActivityChooserView extends ViewGroup implements ActivityChooserMod } } @Override protected void onConfigurationChanged(Configuration newConfig) { Configuration oldConfig = mContext.getResources().getConfiguration(); final int changed = oldConfig.diff(newConfig); if ((changed & ActivityInfo.CONFIG_SCREEN_SIZE) != 0 || (changed & ActivityInfo.CONFIG_ORIENTATION) != 0) { updateHasDefaultActivity(); } } private void updateHasDefaultActivity() { mHasDefaultActivity = mContext.getResources().getBoolean( R.bool.activity_chooser_view_has_default_activity); } /** * Sets the background for the button that expands the activity * overflow list. Loading Loading @@ -383,7 +407,8 @@ public class ActivityChooserView extends ViewGroup implements ActivityChooserMod protected void onAttachedToWindow() { super.onAttachedToWindow(); ActivityChooserModel dataModel = mAdapter.getDataModel(); if (dataModel != null) { if (dataModel != null && !dataModel.isRegisteredObserver(mModelDataSetOberver)) { dataModel.registerObserver(mModelDataSetOberver); } mIsAttachedToWindow = true; Loading @@ -393,7 +418,8 @@ public class ActivityChooserView extends ViewGroup implements ActivityChooserMod protected void onDetachedFromWindow() { super.onDetachedFromWindow(); ActivityChooserModel dataModel = mAdapter.getDataModel(); if (dataModel != null) { if (dataModel != null && dataModel.isRegisteredObserver(mModelDataSetOberver)) { dataModel.unregisterObserver(mModelDataSetOberver); } ViewTreeObserver viewTreeObserver = getViewTreeObserver(); Loading Loading @@ -496,7 +522,7 @@ public class ActivityChooserView extends ViewGroup implements ActivityChooserMod // Default activity button. final int activityCount = mAdapter.getActivityCount(); final int historySize = mAdapter.getHistorySize(); if (activityCount > 0 && historySize > 0) { if (mHasDefaultActivity && activityCount > 0 && historySize > 0) { mDefaultActivityButton.setVisibility(VISIBLE); ResolveInfo activity = mAdapter.getDefaultActivity(); PackageManager packageManager = mContext.getPackageManager(); Loading @@ -512,9 +538,9 @@ public class ActivityChooserView extends ViewGroup implements ActivityChooserMod } // Activity chooser content. if (mDefaultActivityButton.getVisibility() == VISIBLE) { mActivityChooserContent.setBackgroundDrawable(mActivityChooserContentBackground); mActivityChooserContent.setBackground(mActivityChooserContentBackground); } else { mActivityChooserContent.setBackgroundDrawable(null); mActivityChooserContent.setBackground(null); } } Loading Loading @@ -577,7 +603,7 @@ public class ActivityChooserView extends ViewGroup implements ActivityChooserMod // OnLongClickListener#onLongClick @Override public boolean onLongClick(View view) { if (view == mDefaultActivityButton) { if (mHasDefaultActivity && view == mDefaultActivityButton) { if (mAdapter.getCount() > 0) { mIsSelectingDefaultActivity = true; showPopupUnchecked(mInitialActivityCount); Loading Loading @@ -630,14 +656,16 @@ public class ActivityChooserView extends ViewGroup implements ActivityChooserMod public void setDataModel(ActivityChooserModel dataModel) { ActivityChooserModel oldDataModel = mAdapter.getDataModel(); if (oldDataModel != null && isShown()) { if (oldDataModel != null) { oldDataModel.unregisterObserver(mModelDataSetOberver); } mDataModel = dataModel; if (dataModel != null && isShown()) { if (dataModel != null) { dataModel.registerObserver(mModelDataSetOberver); } notifyDataSetChanged(); } else { notifyDataSetInvalidated(); } } @Override Loading
core/java/android/widget/ShareActionProvider.java +6 −1 Original line number Diff line number Diff line Loading @@ -44,6 +44,7 @@ import com.android.internal.R; * <code> * // In Activity#onCreateOptionsMenu * public boolean onCreateOptionsMenu(Menu menu) { * getManuInflater().inflate(R.menu.my_menu, menu); * // Get the menu item. * MenuItem menuItem = menu.findItem(R.id.my_menu_item); * // Get the provider and hold onto it to set/change the share intent. Loading Loading @@ -239,7 +240,11 @@ public class ShareActionProvider extends ActionProvider { * <p> * <strong>Note:</strong> The history file name can be set any time, however * only the action views created by {@link #onCreateActionView()} after setting * the file name will be backed by the provided file. * the file name will be backed by the provided file. Hence, if you are using * a share action provider on a menu item and want to change the history file * based on the type of the currently selected item, you need to call * {@link android.app.Activity#invalidateOptionsMenu()} to force the system * to recreate the menu UI. * <p> * * @param shareHistoryFile The share history file name. Loading
core/res/res/values-w500dp/bools.xml 0 → 100644 +19 −0 Original line number Diff line number Diff line <?xml version="1.0" encoding="utf-8"?> <!-- Copyright (C) 2012 The Android Open Source Project Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. --> <resources> <bool name="activity_chooser_view_has_default_activity">true</bool> </resources> No newline at end of file
core/res/res/values/bools.xml +1 −0 Original line number Diff line number Diff line Loading @@ -22,4 +22,5 @@ <bool name="show_ongoing_ime_switcher">true</bool> <bool name="action_bar_expanded_action_views_exclusive">true</bool> <bool name="target_honeycomb_needs_options_menu">true</bool> <bool name="activity_chooser_view_has_default_activity">false</bool> </resources>