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
This commit is contained in:
Kholoud Mohamed
2020-05-15 19:51:26 +01:00
parent 241f65ced5
commit 77bc0f15e3
2 changed files with 25 additions and 0 deletions

View File

@@ -62,6 +62,7 @@ public abstract class AbstractMultiProfilePagerAdapter extends PagerAdapter {
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 @@ public abstract class AbstractMultiProfilePagerAdapter extends PagerAdapter {
mOnProfileSelectedListener = listener;
}
void setOnSwitchOnWorkSelectedListener(OnSwitchOnWorkSelectedListener listener) {
mOnSwitchOnWorkSelectedListener = listener;
}
Context getContext() {
return mContext;
}
@@ -397,6 +402,9 @@ public abstract class AbstractMultiProfilePagerAdapter extends PagerAdapter {
ProfileDescriptor descriptor = getItem(
userHandleToPageIndex(listAdapter.getUserHandle()));
showSpinner(descriptor.getEmptyStateView());
if (mOnSwitchOnWorkSelectedListener != null) {
mOnSwitchOnWorkSelectedListener.onSwitchOnWorkSelected();
}
mInjector.requestQuietModeEnabled(false, mWorkProfileUserHandle);
});
return true;
@@ -575,6 +583,16 @@ public abstract class AbstractMultiProfilePagerAdapter extends PagerAdapter {
void onProfileSelected(int profileIndex);
}
/**
* 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.
*/

View File

@@ -1656,6 +1656,13 @@ public class ResolverActivity extends Activity implements
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);
}