0

I've implemented a custom ActionProvider, not unlike the ShareActionProvider. It is however a bit wider because I included a text label that is not present in the ShareActionProvider.

I've noticed that regular action items (with SHOW_AS_ACTION_IF_ROOM and SHOW_AS_ACTION_WITH_TEXT) are displayed as just icons when in portrait configuration, and as icons with a label in landscape configuration in the action bar of my Galaxy Nexus phone. I presume that on different configurations this situation may differ. The intention of my custom added label is the same.

How can I check in code if my ActionProvider, more specifically my equivalent of the ActivityChooserView, should display the label or not? What future-proof way is there to get to this knowledge that is probably mostly in ActionMenuPresenter? Are there any safe shortcuts I can take, such as just checking portrait or landscape? Or can it be notified somehow?


As a bonus question, the SHOW_AS_ACTION_IF_ROOM seems to base itself on the number of action items, rather than their widths. As any ActionProvider view is already very wide, it leaves no room for a title, and yet the other action item (with SHOW_AS_ACTION_IF_ROOM) is not moved to the overflow menu. My custom ActionProvider will be slightly larger than 50% of the width even on some devices, yet I thought this was a rule in ActionMenuPresenter? How can I get better, yet still dynamic, control over this (at a high level)?

pjv
  • 10,658
  • 6
  • 43
  • 60

1 Answers1

0

Hmm, seems I might be able to use mAllowTextWithIcon in ActionMenuItemView (https://github.com/android/platform_frameworks_base/blob/master/core/java/com/android/internal/view/menu/ActionMenuItemView.java) and copy the AOSP's config resource structure for it.

pjv
  • 10,658
  • 6
  • 43
  • 60