Repository navigation
[Android] fix focus on elements #4321
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
Merged
almedina-ms
merged 9 commits into
feature/inputEvolution
from
user/almedina-ms/IE_Android_FixFocusOnElements
Jul 13, 2020
Merged
Changes from 4 commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
0ae4a73
Add custom input element to verify correct label rendering
almedina-ms b9daad4
Fix Focus Visibility on choiceset elements
almedina-ms dd4994e
Add missing file change
almedina-ms e3185f6
Merge branch 'feature/inputEvolution' into user/almedina-ms/IE_Androi…
a88cd56
Merge branch 'feature/inputEvolution' into user/almedina-ms/IE_Androi…
almedina-ms 96b1ec2
Fix build error
almedina-ms 73f3d8c
Merge branch 'feature/inputEvolution' into user/almedina-ms/IE_Androi…
64aeec6
Merge branch 'feature/inputEvolution' into user/almedina-ms/IE_Androi…
almedina-ms a2d634e
Merge branch 'feature/inputEvolution' into user/almedina-ms/IE_Androi…
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -10,4 +10,5 @@ public interface IInputHandler | |
| void setInput(String input); | ||
|
|
||
| boolean isValid(); | ||
| void setFocusToView(); | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
131 changes: 131 additions & 0 deletions
131
...ain/java/io/adaptivecards/adaptivecardssample/CustomObjects/CardElements/CustomInput.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,131 @@ | ||
| package io.adaptivecards.adaptivecardssample.CustomObjects.CardElements; | ||
|
|
||
| import android.content.Context; | ||
| import android.graphics.Color; | ||
| import android.support.v4.app.FragmentManager; | ||
| import android.view.View; | ||
| import android.view.ViewGroup; | ||
| import android.widget.EditText; | ||
| import android.widget.LinearLayout; | ||
|
|
||
| import org.json.JSONException; | ||
| import org.json.JSONObject; | ||
|
|
||
| import io.adaptivecards.objectmodel.BaseCardElement; | ||
| import io.adaptivecards.objectmodel.BaseCardElementParser; | ||
| import io.adaptivecards.objectmodel.BaseInputElement; | ||
| import io.adaptivecards.objectmodel.CardElementType; | ||
| import io.adaptivecards.objectmodel.HostConfig; | ||
| import io.adaptivecards.objectmodel.JsonValue; | ||
| import io.adaptivecards.objectmodel.ParseContext; | ||
| import io.adaptivecards.renderer.BaseCardElementRenderer; | ||
| import io.adaptivecards.renderer.RenderArgs; | ||
| import io.adaptivecards.renderer.RenderedAdaptiveCard; | ||
| import io.adaptivecards.renderer.TagContent; | ||
| import io.adaptivecards.renderer.Util; | ||
| import io.adaptivecards.renderer.actionhandler.ICardActionHandler; | ||
| import io.adaptivecards.renderer.inputhandler.BaseInputHandler; | ||
| import io.adaptivecards.renderer.inputhandler.IInputHandler; | ||
|
|
||
| public class CustomInput extends BaseInputElement | ||
| { | ||
| public CustomInput(CardElementType cardElementType) | ||
| { | ||
| super(cardElementType); | ||
| } | ||
|
|
||
| public static class CustomInputHandler extends BaseInputHandler | ||
| { | ||
| public CustomInputHandler(BaseInputElement baseInputElement, EditText editText) | ||
| { | ||
| super(baseInputElement); | ||
| m_view = editText; | ||
| } | ||
|
|
||
| @Override | ||
| public String getInput() | ||
| { | ||
| return ((EditText)m_view).getText().toString(); | ||
| } | ||
|
|
||
| @Override | ||
| public void setInput(String input) | ||
| { | ||
| ((EditText)m_view).setText(input); | ||
| } | ||
|
|
||
| @Override | ||
| public void setFocusToView() | ||
| { | ||
| m_view.requestFocus(); | ||
| } | ||
| } | ||
|
|
||
| public static class CustomInputRenderer extends BaseCardElementRenderer | ||
| { | ||
| @Override | ||
| public View render(RenderedAdaptiveCard renderedCard, | ||
| Context context, | ||
| FragmentManager fragmentManager, | ||
| ViewGroup viewGroup, | ||
| BaseCardElement baseCardElement, | ||
| ICardActionHandler cardActionHandler, | ||
| HostConfig hostConfig, | ||
| RenderArgs renderArgs) throws Exception | ||
| { | ||
| EditText renderedInput = new EditText(context); | ||
| renderedInput.setLayoutParams(new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.WRAP_CONTENT)); | ||
|
|
||
| renderedInput.setBackgroundColor(Color.GREEN); | ||
| renderedInput.setTag(new TagContent(baseCardElement)); | ||
| viewGroup.addView(renderedInput); | ||
|
|
||
| BaseInputElement inputElement = Util.castTo(baseCardElement, BaseInputElement.class); | ||
| renderedCard.registerInputHandler(new CustomInputHandler(inputElement, renderedInput), renderArgs.getContainerCardId()); | ||
| return renderedInput; | ||
| } | ||
| } | ||
|
|
||
|
|
||
| public static class CustomInputParser extends BaseCardElementParser | ||
| { | ||
| @Override | ||
| public BaseCardElement Deserialize(ParseContext context, JsonValue value) | ||
| { | ||
| CustomInput element = new CustomInput(CardElementType.Custom); | ||
| element.SetElementTypeString(customInputTypeString); | ||
| String val = value.getString(); | ||
| try | ||
| { | ||
| JSONObject obj = new JSONObject(val); | ||
| element.SetId(obj.getString("id")); | ||
| element.SetLabel(obj.getString("label")); | ||
| } | ||
| catch (JSONException e) | ||
| { | ||
| e.printStackTrace(); | ||
| } | ||
| return element; | ||
| } | ||
|
|
||
| @Override | ||
| public BaseCardElement DeserializeFromString(ParseContext context, String jsonString) | ||
| { | ||
| CustomInput element = new CustomInput(CardElementType.Custom); | ||
| element.SetElementTypeString(customInputTypeString); | ||
| try | ||
| { | ||
| JSONObject obj = new JSONObject(jsonString); | ||
| element.SetId(obj.getString("id")); | ||
| element.SetLabel(obj.getString("label")); | ||
| } | ||
| catch (JSONException e) | ||
| { | ||
| e.printStackTrace(); | ||
| } | ||
| return element; | ||
| } | ||
| } | ||
|
|
||
| public final static String customInputTypeString = "customInput"; | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit: additional newline creeped in