Merge "Refocus conversation expand button in TalkBack" into rvc-dev
This commit is contained in:
committed by
Android (Google) Code Review
commit
2c99d90744
@@ -1223,7 +1223,6 @@ public class ConversationLayout extends FrameLayout
|
||||
mExpandButtonContainer.setVisibility(VISIBLE);
|
||||
mExpandButtonInnerContainer.setOnClickListener(onClickListener);
|
||||
} else {
|
||||
// TODO: handle content paddings to end of layout
|
||||
mExpandButtonContainer.setVisibility(GONE);
|
||||
}
|
||||
updateContentEndPaddings();
|
||||
|
||||
@@ -557,9 +557,9 @@ public class NotificationContentView extends FrameLayout {
|
||||
|
||||
private void focusExpandButtonIfNecessary() {
|
||||
if (mFocusOnVisibilityChange) {
|
||||
NotificationHeaderView header = getVisibleNotificationHeader();
|
||||
if (header != null) {
|
||||
ImageView expandButton = header.getExpandButton();
|
||||
NotificationViewWrapper wrapper = getVisibleWrapper(mVisibleType);
|
||||
if (wrapper != null) {
|
||||
View expandButton = wrapper.getExpandButton();
|
||||
if (expandButton != null) {
|
||||
expandButton.requestAccessibilityFocus();
|
||||
}
|
||||
|
||||
@@ -50,6 +50,7 @@ class NotificationConversationTemplateViewWrapper constructor(
|
||||
private lateinit var conversationBadgeBg: View
|
||||
private lateinit var expandButton: View
|
||||
private lateinit var expandButtonContainer: View
|
||||
private lateinit var expandButtonInnerContainer: View
|
||||
private lateinit var imageMessageContainer: ViewGroup
|
||||
private lateinit var messagingLinearLayout: MessagingLinearLayout
|
||||
private lateinit var conversationTitleView: View
|
||||
@@ -69,6 +70,8 @@ class NotificationConversationTemplateViewWrapper constructor(
|
||||
expandButton = requireViewById(com.android.internal.R.id.expand_button)
|
||||
expandButtonContainer =
|
||||
requireViewById(com.android.internal.R.id.expand_button_container)
|
||||
expandButtonInnerContainer =
|
||||
requireViewById(com.android.internal.R.id.expand_button_inner_container)
|
||||
importanceRing = requireViewById(com.android.internal.R.id.conversation_icon_badge_ring)
|
||||
appName = requireViewById(com.android.internal.R.id.app_name_text)
|
||||
conversationTitleView = requireViewById(com.android.internal.R.id.conversation_text)
|
||||
@@ -134,6 +137,8 @@ class NotificationConversationTemplateViewWrapper constructor(
|
||||
)
|
||||
}
|
||||
|
||||
override fun getExpandButton() = expandButtonInnerContainer
|
||||
|
||||
override fun setShelfIconVisible(visible: Boolean) {
|
||||
if (conversationLayout.isImportantConversation) {
|
||||
if (conversationIconView.visibility != GONE) {
|
||||
|
||||
@@ -316,6 +316,11 @@ public class NotificationHeaderViewWrapper extends NotificationViewWrapper {
|
||||
return mNotificationHeader;
|
||||
}
|
||||
|
||||
@Override
|
||||
public View getExpandButton() {
|
||||
return mExpandButton;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getOriginalIconColor() {
|
||||
return mIcon.getOriginalIconColor();
|
||||
|
||||
@@ -240,6 +240,13 @@ public abstract class NotificationViewWrapper implements TransformableView {
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the expand button if it exists
|
||||
*/
|
||||
public @Nullable View getExpandButton() {
|
||||
return null;
|
||||
}
|
||||
|
||||
public int getOriginalIconColor() {
|
||||
return Notification.COLOR_INVALID;
|
||||
}
|
||||
|
||||
@@ -16,7 +16,6 @@
|
||||
|
||||
package com.android.systemui.statusbar.notification.row;
|
||||
|
||||
import static org.mockito.ArgumentMatchers.any;
|
||||
import static org.mockito.ArgumentMatchers.anyFloat;
|
||||
import static org.mockito.Mockito.doNothing;
|
||||
import static org.mockito.Mockito.doReturn;
|
||||
@@ -30,11 +29,13 @@ import android.app.AppOpsManager;
|
||||
import android.util.ArraySet;
|
||||
import android.view.NotificationHeaderView;
|
||||
import android.view.View;
|
||||
import android.view.ViewPropertyAnimator;
|
||||
|
||||
import androidx.test.annotation.UiThreadTest;
|
||||
import androidx.test.filters.SmallTest;
|
||||
import androidx.test.runner.AndroidJUnit4;
|
||||
|
||||
import com.android.internal.widget.NotificationExpandButton;
|
||||
import com.android.systemui.SysuiTestCase;
|
||||
|
||||
import org.junit.Before;
|
||||
@@ -98,4 +99,42 @@ public class NotificationContentViewTest extends SysuiTestCase {
|
||||
verify(mockExpanded, times(1)).setVisibility(View.VISIBLE);
|
||||
verify(mockHeadsUp, times(1)).setVisibility(View.VISIBLE);
|
||||
}
|
||||
|
||||
@Test
|
||||
@UiThreadTest
|
||||
public void testExpandButtonFocusIsCalled() {
|
||||
View mockContractedEB = mock(NotificationExpandButton.class);
|
||||
View mockContracted = mock(NotificationHeaderView.class);
|
||||
when(mockContracted.animate()).thenReturn(mock(ViewPropertyAnimator.class));
|
||||
when(mockContracted.findViewById(com.android.internal.R.id.expand_button)).thenReturn(
|
||||
mockContractedEB);
|
||||
|
||||
View mockExpandedEB = mock(NotificationExpandButton.class);
|
||||
View mockExpanded = mock(NotificationHeaderView.class);
|
||||
when(mockExpanded.animate()).thenReturn(mock(ViewPropertyAnimator.class));
|
||||
when(mockExpanded.findViewById(com.android.internal.R.id.expand_button)).thenReturn(
|
||||
mockExpandedEB);
|
||||
|
||||
View mockHeadsUpEB = mock(NotificationExpandButton.class);
|
||||
View mockHeadsUp = mock(NotificationHeaderView.class);
|
||||
when(mockHeadsUp.animate()).thenReturn(mock(ViewPropertyAnimator.class));
|
||||
when(mockHeadsUp.findViewById(com.android.internal.R.id.expand_button)).thenReturn(
|
||||
mockHeadsUpEB);
|
||||
|
||||
// Set up all 3 child forms
|
||||
mView.setContractedChild(mockContracted);
|
||||
mView.setExpandedChild(mockExpanded);
|
||||
mView.setHeadsUpChild(mockHeadsUp);
|
||||
|
||||
// This is required to call requestAccessibilityFocus()
|
||||
mView.setFocusOnVisibilityChange();
|
||||
|
||||
// The following will initialize the view and switch from not visible to expanded.
|
||||
// (heads-up is actually an alternate form of contracted, hence this enters expanded state)
|
||||
mView.setHeadsUp(true);
|
||||
|
||||
verify(mockContractedEB, times(0)).requestAccessibilityFocus();
|
||||
verify(mockExpandedEB, times(1)).requestAccessibilityFocus();
|
||||
verify(mockHeadsUpEB, times(0)).requestAccessibilityFocus();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user