Fix talkback for switch on work in ResolverActivity
Set the focus to the work tab when switch on
work profile is clicked.
Fixes: 152014143
Test: Manually tested the bug no longer happens
Change-Id: Iba72f238cdaf564256648327d12a54c6227dd23b
diff --git a/core/java/com/android/internal/app/AbstractMultiProfilePagerAdapter.java b/core/java/com/android/internal/app/AbstractMultiProfilePagerAdapter.java
index a47ad73..c8f5be4 100644
--- a/core/java/com/android/internal/app/AbstractMultiProfilePagerAdapter.java
+++ b/core/java/com/android/internal/app/AbstractMultiProfilePagerAdapter.java
@@ -62,6 +62,7 @@
private final Context mContext;
private int mCurrentPage;
private OnProfileSelectedListener mOnProfileSelectedListener;
+ private OnSwitchOnWorkSelectedListener mOnSwitchOnWorkSelectedListener;
private Set<Integer> mLoadedPages;
private final UserHandle mPersonalProfileUserHandle;
private final UserHandle mWorkProfileUserHandle;
@@ -124,6 +125,10 @@
mOnProfileSelectedListener = listener;
}
+ void setOnSwitchOnWorkSelectedListener(OnSwitchOnWorkSelectedListener listener) {
+ mOnSwitchOnWorkSelectedListener = listener;
+ }
+
Context getContext() {
return mContext;
}
@@ -397,6 +402,9 @@
ProfileDescriptor descriptor = getItem(
userHandleToPageIndex(listAdapter.getUserHandle()));
showSpinner(descriptor.getEmptyStateView());
+ if (mOnSwitchOnWorkSelectedListener != null) {
+ mOnSwitchOnWorkSelectedListener.onSwitchOnWorkSelected();
+ }
mInjector.requestQuietModeEnabled(false, mWorkProfileUserHandle);
});
return true;
@@ -576,6 +584,16 @@
}
/**
+ * Listener for when the user switches on the work profile from the work tab.
+ */
+ interface OnSwitchOnWorkSelectedListener {
+ /**
+ * Callback for when the user switches on the work profile from the work tab.
+ */
+ void onSwitchOnWorkSelected();
+ }
+
+ /**
* Describes an injector to be used for cross profile functionality. Overridable for testing.
*/
@VisibleForTesting
diff --git a/core/java/com/android/internal/app/ResolverActivity.java b/core/java/com/android/internal/app/ResolverActivity.java
index 83dabe8..2b30698 100644
--- a/core/java/com/android/internal/app/ResolverActivity.java
+++ b/core/java/com/android/internal/app/ResolverActivity.java
@@ -1656,6 +1656,13 @@
resetButtonBar();
resetCheckedItem();
});
+ mMultiProfilePagerAdapter.setOnSwitchOnWorkSelectedListener(
+ () -> {
+ final View workTab = tabHost.getTabWidget().getChildAt(1);
+ workTab.setFocusable(true);
+ workTab.setFocusableInTouchMode(true);
+ workTab.requestFocus();
+ });
findViewById(R.id.resolver_tab_divider).setVisibility(View.VISIBLE);
}