Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Android] Overflow Actions (onto main branch) #5668

Merged
merged 21 commits into from
Apr 14, 2021

Conversation

robin-liao
Copy link
Contributor

@robin-liao robin-liao commented Apr 14, 2021

Related Issue

ActionSet overflow flyout (... actions menu) 4715

Description

To introduce a new feature of overflow actions, the implementation follows the spec:

  1. This new feature will bring as part of Schema version 1.5

  2. Introduce a new property field mode to all Action type. Its value can be primary (default) or secondary. For all secondary action instances in the same actions array (either the root level actions section or ActionSet inside card elements) they'll group as overflow actions, wrap up within a "..." button and display flyout context menu when user clicks "..." button.

  3. hostConfig.actions.maxActions doesn't count "..." button itself.

  4. Client callbacks are added to control overflow button "..." and flyout menu actions rendering:

    • View onRenderOverflowAction(@NonNull ViewGroup viewGroup, boolean isRootLevelActions)

      • It will be called when “…” overflow button will be rendered. viewGroup is the container view to which client can optionally attach the Overflow view, and isRootLevelActions indicates if the current "..." overflow action belongs to root level actions array. If it's false then it indicates it's ActionSet as body elements.
      • Client callback requires to return a View instance. Returning null means let SDK continue to render "..." button, while View informs SDK don't render the current "..." button.
    • boolean onDisplayOverflowActionMenu(@NonNull List<View> actionViewList, @NonNull View view)

      • It will be called when overflow context menu will be shown. The first argument actionViewList are those rendered secondary actions views , and view is the element that triggered the context menu, which usually is the “…” button. It can be used by client to position the context menu if client wants to render flyout actions itself.
      • Client callback requires to return a boolean value. Returning false means let SDK continue to render flyout context menu, while true informs SDK don't render flyout (which implies client code might render context menu by itself via onDisplayOverflowActionMenu callback)
    • boolean shouldAllowMoreThanMaxActionsInOverflowMenu()

      • Client callback requires to return a boolean value. Returning true indicates that the actions exceeding the number defined in hostConfig.actions.maxActions will be auto wrapped up as overflow actions and "..." button for context menu will be displayed and false indicates excess action elements will be left out.

Sample Card

{
  "$schema": "http://adaptivecards.io/schemas/adaptive-card.json",
  "type": "AdaptiveCard",
  "version": "1.2",
  "body": [
	{
	  "type": "Image",
	  "url": "https://adaptivecards.io/content/adaptive-card-50.png"
	},
	{
	  "type": "TextBlock",
	  "text": "Hello **Adaptive Cards!**"
	},
	{
	  "type": "ActionSet",
	  "actions": [
		{
		  "type": "Action.Submit",
		  "title": "Action Submit",
		  "data": {
			"key": "Submit from overflow menu"
		  }
		},
		{
		  "type": "Action.Submit",
		  "title": "Edit",
		  "data": {
			"key": "Edit from overflow menu"
		  },
		  "mode": "secondary"
		}
	  ]
	}
  ],
  "actions": [

	{
	  "type": "Action.Submit",
	  "title": "Submit"
	},
	{
	  "type": "Action.Submit",
	  "title": "Edit"
	},
	{
	  "type": "Action.Submit",
	  "title": "Delete",
	  "data": {
		"key": "Submit from overflow menu"
	  },
	  "mode": "Secondary"
	},
	{
	  "type": "Action.OpenUrl",
	  "iconUrl": "https://adaptivecards.io/content/cats/2.png",
	  "url": "https://adaptivecards.io",
	  "title": "Open Url",
	  "mode": "Secondary"
	},{
	  "type": "Action.ShowCard",
	  "title": "Action.ShowCard",
	  "card": {
		"type": "AdaptiveCard",
		"body": [
		  {
			"type": "TextBlock",
			"text": "What do you think?"
		  }
		],
		"actions": [
		  {
			"type": "Action.Submit",
			"title": "Neat!"
		  }
		]
	  },
	  "mode": "Secondary"
	}

  ]
}

How Verified

Added Unit Test "SecondaryAcrionsPropertiesSet.Java" to test the different scenarios.

Overflow Displaying Menu
Screenshot_1618332440 Screenshot_1618332323

robin-liao and others added 20 commits March 1, 2021 12:56
* [JS] Overflow actions #4715

* use global setting to control exceeding actions

* address PR comments

* fix PR build

* fix PR build

* fix PR build

* fix pr build

* address PR comments

* address PR comments

Co-authored-by: David Claux <dclaux@users.noreply.github.com>

Ignoring unrelated Android check failures
…ry on execute (#5449)

* Action.mode designer support
Promote secondary action to primary on execute

* Slight change in behavior for action promotion

* Slight refactor
Enum created for "Mode" with  "Primary" & " Secondary"  constants.
"Mode" is parsed  from the json string.
If allowMoreThanMaxActionsInOverflowMenu  is set, excess buttons will be moved to Overflow,
BottomSheetDoalog is Integrated and DropdownElement is created.
Resource files added for Overflow view & BottomSheetDialog's background.
Scheme keys added.
IOverllowActionRenderer interface created for customizing the Overflow rendering behavior.
Method added for custom context menu .
Version 1.5 introduced and sample json files added.
Additional method added to AdaptiveCardRenderer for customizing OverflowActionRenderer.
OnclickListener added to custom overflow view.
- getRootLevelAction(), shouldDisplayCustomActionMenu() methods removed.
shouldDisplayCustomOverflowActionMenu() added to IOverflowActionRenderer.java
rootLevelFlags added to RenderArgs.
Added Java 8 support.
IoverflowActionRenderer Callbacks refactored.
Swig java object models files committed.
PR comments resolved.
@ghost
Copy link

ghost commented Apr 14, 2021

Hi @robin-liao. Thanks for helping make the AdaptiveCards JS renderer + tooling better. As additional verification, once the JS build succeeds, please go to the test site to test out your website/designer changes.

@robin-liao robin-liao changed the title [Android] Overflow Actions [Android] Overflow Actions (onto main branch) Apr 14, 2021
@karthikgopal36 karthikgopal36 merged commit a0c2950 into main Apr 14, 2021
@golddove
Copy link
Member

Just commenting here for future reference: original PR was #5606 which has review comments / approvals.

@golddove golddove deleted the feature/Mobile/ActionOverflow branch April 23, 2021 19:30
michaelfarnsworth pushed a commit to michaelfarnsworth/AdaptiveCards that referenced this pull request Nov 10, 2022
* [JS] Overflow actions (flyout menu) microsoft#4715 (Pre-Release) (microsoft#5446)

* [JS] Overflow actions microsoft#4715

* use global setting to control exceeding actions

* address PR comments

* fix PR build

* fix PR build

* fix PR build

* fix pr build

* address PR comments

* address PR comments

Co-authored-by: David Claux <dclaux@users.noreply.github.com>

Ignoring unrelated Android check failures

* [JS] Action.mode designer support + promote secondary action to primary on execute (microsoft#5449)

* Action.mode designer support
Promote secondary action to primary on execute

* Slight change in behavior for action promotion

* Slight refactor

* "Mode" property added to AdaptiveCardSchemaKey.
Enum created for "Mode" with  "Primary" & " Secondary"  constants.
"Mode" is parsed  from the json string.

* allowMoreThanMaxActionsInOverflowMenu flag  added to HostConfig.

If allowMoreThanMaxActionsInOverflowMenu  is set, excess buttons will be moved to Overflow,

* OverflowAction view is rendered for secondary action elements.
BottomSheetDoalog is Integrated and DropdownElement is created.
Resource files added for Overflow view & BottomSheetDialog's background.
Scheme keys added.
IOverllowActionRenderer interface created for customizing the Overflow rendering behavior.

* Unit Test "ActionModePropertiesTest.java" added.
Method added for custom context menu .
Version 1.5 introduced and sample json files added.
Additional method added to AdaptiveCardRenderer for customizing OverflowActionRenderer.

* IOverflowLayout onRenderOverflowAction callback refactored.
OnclickListener added to custom overflow view.

* Addressed PR comments. Code formatted.

* Addressed PR comments.

* Addressed review comments.

* rootLevelAction implementation logic is refactored.

* IOverflowActionRenderer callback methods refactored.

- getRootLevelAction(), shouldDisplayCustomActionMenu() methods removed.

* SplitActionMode code moved to AdaptiveCardRenderer.
shouldDisplayCustomOverflowActionMenu() added to IOverflowActionRenderer.java
rootLevelFlags added to RenderArgs.

* PopupWindow is integrated and BottomSheetDialog dependency is removed.
Added Java 8 support.
IoverflowActionRenderer Callbacks refactored.
Swig java object models files committed.
PR comments resolved.

* Swig files committed.

* Addressed PR comments.

* Unused files removed.

* Java 8 support added to mobileChatApp

* Androidx annotation updated.

Co-authored-by: David Claux <dclaux@users.noreply.github.com>
Co-authored-by: REDMOND\kargopal <kargopal@microsoft.com>
rankush pushed a commit to rankush/AdaptiveCards that referenced this pull request May 8, 2024
* [JS] Overflow actions (flyout menu) microsoft#4715 (Pre-Release) (microsoft#5446)

* [JS] Overflow actions microsoft#4715

* use global setting to control exceeding actions

* address PR comments

* fix PR build

* fix PR build

* fix PR build

* fix pr build

* address PR comments

* address PR comments

Co-authored-by: David Claux <dclaux@users.noreply.github.com>

Ignoring unrelated Android check failures

* [JS] Action.mode designer support + promote secondary action to primary on execute (microsoft#5449)

* Action.mode designer support
Promote secondary action to primary on execute

* Slight change in behavior for action promotion

* Slight refactor

* "Mode" property added to AdaptiveCardSchemaKey.
Enum created for "Mode" with  "Primary" & " Secondary"  constants.
"Mode" is parsed  from the json string.

* allowMoreThanMaxActionsInOverflowMenu flag  added to HostConfig.

If allowMoreThanMaxActionsInOverflowMenu  is set, excess buttons will be moved to Overflow,

* OverflowAction view is rendered for secondary action elements.
BottomSheetDoalog is Integrated and DropdownElement is created.
Resource files added for Overflow view & BottomSheetDialog's background.
Scheme keys added.
IOverllowActionRenderer interface created for customizing the Overflow rendering behavior.

* Unit Test "ActionModePropertiesTest.java" added.
Method added for custom context menu .
Version 1.5 introduced and sample json files added.
Additional method added to AdaptiveCardRenderer for customizing OverflowActionRenderer.

* IOverflowLayout onRenderOverflowAction callback refactored.
OnclickListener added to custom overflow view.

* Addressed PR comments. Code formatted.

* Addressed PR comments.

* Addressed review comments.

* rootLevelAction implementation logic is refactored.

* IOverflowActionRenderer callback methods refactored.

- getRootLevelAction(), shouldDisplayCustomActionMenu() methods removed.

* SplitActionMode code moved to AdaptiveCardRenderer.
shouldDisplayCustomOverflowActionMenu() added to IOverflowActionRenderer.java
rootLevelFlags added to RenderArgs.

* PopupWindow is integrated and BottomSheetDialog dependency is removed.
Added Java 8 support.
IoverflowActionRenderer Callbacks refactored.
Swig java object models files committed.
PR comments resolved.

* Swig files committed.

* Addressed PR comments.

* Unused files removed.

* Java 8 support added to mobileChatApp

* Androidx annotation updated.

Co-authored-by: David Claux <dclaux@users.noreply.github.com>
Co-authored-by: REDMOND\kargopal <kargopal@microsoft.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants