Skip to content

Commit

Permalink
[Android] Refocus when a show card changes visibility (microsoft#1651)
Browse files Browse the repository at this point in the history
* Refocus on show card

* Set focus for cards instead of input fields
  • Loading branch information
almedina-ms committed Jun 27, 2018
1 parent b084d70 commit f2a899a
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
Expand Up @@ -116,6 +116,8 @@ public View internalRender(RenderedAdaptiveCard renderedCard,
LinearLayout rootLayout = new LinearLayout(context);
rootLayout.setLayoutParams(new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT));
rootLayout.setOrientation(LinearLayout.VERTICAL);
rootLayout.setFocusable(true);
rootLayout.setFocusableInTouchMode(true);

LinearLayout layout = new LinearLayout(context);
layout.setTag(adaptiveCard);
Expand Down
@@ -1,5 +1,6 @@
package io.adaptivecards.renderer.action;

import android.app.Activity;
import android.content.Context;
import android.graphics.Bitmap;
import android.graphics.Paint;
Expand Down Expand Up @@ -111,6 +112,14 @@ public ShowCardInlineClickListener(View invisibleCard, ViewGroup hiddenCardsLayo
@Override
public void onClick(View v)
{
Activity hostingActivity = (Activity)v.getContext();

View currentFocusedView = hostingActivity.getCurrentFocus();
if (currentFocusedView != null)
{
currentFocusedView.clearFocus();
}

v.setPressed(m_invisibleCard.getVisibility() != View.VISIBLE);
for(int i = 0; i < m_hiddenCardsLayout.getChildCount(); ++i)
{
Expand All @@ -130,6 +139,7 @@ public void onClick(View v)
if (m_invisibleCard.getVisibility() == View.VISIBLE)
{
mainCardView.setPadding(padding, padding, padding, 0);
m_invisibleCard.requestFocus();
}
else
{
Expand Down

0 comments on commit f2a899a

Please sign in to comment.