Futureproof trusted credentials for multiple profiles
Made use of the shiny LayoutTransition.CHANGING animations. Now it's a little more obvious where things are going when tapping a header. Future work: maybe show the usernames / user icons in there too? This could get complicated, and it'll need to be done everywhere at once. Change-Id: Id7396235abe6218d591d16db91af0f56a83a7bcd Fix: 28310002
This commit is contained in:
@@ -14,10 +14,9 @@
|
||||
limitations under the License.
|
||||
-->
|
||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="vertical"
|
||||
android:visibility="gone">
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:orientation="vertical">
|
||||
<LinearLayout
|
||||
android:id="@+id/header_view"
|
||||
android:layout_width="fill_parent"
|
||||
|
@@ -54,20 +54,8 @@
|
||||
android:orientation="vertical"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:visibility="gone">
|
||||
|
||||
<include
|
||||
android:id="@+id/system_personal_container"
|
||||
layout="@layout/trusted_credential_list_container"/>
|
||||
<include
|
||||
android:id="@+id/system_work_container"
|
||||
layout="@layout/trusted_credential_list_container"/>
|
||||
|
||||
<ExpandableListView
|
||||
android:id="@+id/system_expandable_list"
|
||||
style="@style/TrustedCredentialsList"
|
||||
android:visibility="gone">
|
||||
</ExpandableListView>
|
||||
android:visibility="gone"
|
||||
android:animateLayoutChanges="true">
|
||||
</LinearLayout>
|
||||
|
||||
</FrameLayout>
|
||||
@@ -91,21 +79,8 @@
|
||||
android:orientation="vertical"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:visibility="gone">
|
||||
|
||||
<include
|
||||
android:id="@+id/user_personal_container"
|
||||
layout="@layout/trusted_credential_list_container"/>
|
||||
|
||||
<include
|
||||
android:id="@+id/user_work_container"
|
||||
layout="@layout/trusted_credential_list_container"/>
|
||||
|
||||
<ExpandableListView
|
||||
android:id="@+id/user_expandable_list"
|
||||
style="@style/TrustedCredentialsList"
|
||||
android:visibility="gone">
|
||||
</ExpandableListView>
|
||||
android:visibility="gone"
|
||||
android:animateLayoutChanges="true">
|
||||
</LinearLayout>
|
||||
|
||||
</FrameLayout>
|
||||
|
@@ -147,8 +147,8 @@
|
||||
</style>
|
||||
|
||||
<style name="TrustedCredentialsList">
|
||||
<item name="android:layout_width">fill_parent</item>
|
||||
<item name="android:layout_height">fill_parent</item>
|
||||
<item name="android:layout_width">match_parent</item>
|
||||
<item name="android:layout_height">match_parent</item>
|
||||
<item name="android:scrollbarStyle">outsideOverlay</item>
|
||||
</style>
|
||||
|
||||
|
@@ -16,6 +16,10 @@
|
||||
|
||||
package com.android.settings;
|
||||
|
||||
import static android.widget.LinearLayout.LayoutParams.MATCH_PARENT;
|
||||
import static android.widget.LinearLayout.LayoutParams.WRAP_CONTENT;
|
||||
|
||||
import android.animation.LayoutTransition;
|
||||
import android.annotation.UiThread;
|
||||
import android.app.Activity;
|
||||
import android.app.KeyguardManager;
|
||||
@@ -96,18 +100,12 @@ public class TrustedCredentialsSettings extends OptionsMenuFragment
|
||||
R.string.trusted_credentials_system_tab,
|
||||
R.id.system_tab,
|
||||
R.id.system_progress,
|
||||
R.id.system_personal_container,
|
||||
R.id.system_work_container,
|
||||
R.id.system_expandable_list,
|
||||
R.id.system_content,
|
||||
true),
|
||||
USER("user",
|
||||
R.string.trusted_credentials_user_tab,
|
||||
R.id.user_tab,
|
||||
R.id.user_progress,
|
||||
R.id.user_personal_container,
|
||||
R.id.user_work_container,
|
||||
R.id.user_expandable_list,
|
||||
R.id.user_content,
|
||||
false);
|
||||
|
||||
@@ -115,21 +113,14 @@ public class TrustedCredentialsSettings extends OptionsMenuFragment
|
||||
private final int mLabel;
|
||||
private final int mView;
|
||||
private final int mProgress;
|
||||
private final int mPersonalList;
|
||||
private final int mWorkList;
|
||||
private final int mExpandableList;
|
||||
private final int mContentView;
|
||||
private final boolean mSwitch;
|
||||
|
||||
private Tab(String tag, int label, int view, int progress, int personalList, int workList,
|
||||
int expandableList, int contentView, boolean withSwitch) {
|
||||
private Tab(String tag, int label, int view, int progress, int contentView, boolean withSwitch) {
|
||||
mTag = tag;
|
||||
mLabel = label;
|
||||
mView = view;
|
||||
mProgress = progress;
|
||||
mPersonalList = personalList;
|
||||
mWorkList = workList;
|
||||
mExpandableList = expandableList;
|
||||
mContentView = contentView;
|
||||
mSwitch = withSwitch;
|
||||
}
|
||||
@@ -279,31 +270,31 @@ public class TrustedCredentialsSettings extends OptionsMenuFragment
|
||||
.setContent(tab.mView);
|
||||
mTabHost.addTab(systemSpec);
|
||||
|
||||
final int profilesSize = mUserManager.getUserProfiles().size();
|
||||
final GroupAdapter groupAdapter = new GroupAdapter(tab);
|
||||
mGroupAdapters.add(groupAdapter);
|
||||
final int profilesSize = groupAdapter.getGroupCount();
|
||||
|
||||
if (profilesSize == 1) {
|
||||
final ChildAdapter adapter = groupAdapter.getChildAdapter(0);
|
||||
adapter.setContainerViewId(tab.mPersonalList);
|
||||
adapter.prepare();
|
||||
} else if (profilesSize == 2) {
|
||||
final int workIndex = groupAdapter.getUserInfoByGroup(1).isManagedProfile() ? 1 : 0;
|
||||
final int personalIndex = workIndex == 1 ? 0 : 1;
|
||||
// Add a transition for non-visibility events like resizing the pane.
|
||||
final ViewGroup contentView = (ViewGroup) mTabHost.findViewById(tab.mContentView);
|
||||
contentView.getLayoutTransition().enableTransitionType(LayoutTransition.CHANGING);
|
||||
|
||||
final ChildAdapter personalAdapter = groupAdapter.getChildAdapter(personalIndex);
|
||||
personalAdapter.setContainerViewId(tab.mPersonalList);
|
||||
personalAdapter.showHeader(true);
|
||||
personalAdapter.prepare();
|
||||
final LayoutInflater inflater = LayoutInflater.from(getActivity());
|
||||
for (int i = 0; i < groupAdapter.getGroupCount(); i++) {
|
||||
final boolean isWork = groupAdapter.getUserInfoByGroup(i).isManagedProfile();
|
||||
final ChildAdapter adapter = groupAdapter.getChildAdapter(i);
|
||||
|
||||
final ChildAdapter workAdapter = groupAdapter.getChildAdapter(workIndex);
|
||||
workAdapter.setContainerViewId(tab.mWorkList);
|
||||
workAdapter.showHeader(true);
|
||||
workAdapter.showDivider(true);
|
||||
workAdapter.prepare();
|
||||
} else if (profilesSize >= 3) {
|
||||
groupAdapter.setExpandableListView(
|
||||
(ExpandableListView) mTabHost.findViewById(tab.mExpandableList));
|
||||
final LinearLayout containerView = (LinearLayout) inflater
|
||||
.inflate(R.layout.trusted_credential_list_container, contentView, false);
|
||||
adapter.setContainerView(containerView);
|
||||
|
||||
adapter.showHeader(profilesSize > 1);
|
||||
adapter.showDivider(isWork);
|
||||
adapter.setExpandIfAvailable(profilesSize <= 2 ? true : !isWork);
|
||||
if (isWork) {
|
||||
contentView.addView(containerView);
|
||||
} else {
|
||||
contentView.addView(containerView, 0);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -504,10 +495,12 @@ public class TrustedCredentialsSettings extends OptionsMenuFragment
|
||||
AdapterView.OnItemClickListener {
|
||||
private final int[] GROUP_EXPANDED_STATE_SET = {com.android.internal.R.attr.state_expanded};
|
||||
private final int[] EMPTY_STATE_SET = {};
|
||||
private final LinearLayout.LayoutParams HIDE_LAYOUT_PARAMS = new LinearLayout.LayoutParams(
|
||||
LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.WRAP_CONTENT);
|
||||
private final LinearLayout.LayoutParams HIDE_CONTAINER_LAYOUT_PARAMS =
|
||||
new LinearLayout.LayoutParams(MATCH_PARENT, WRAP_CONTENT, 0f);
|
||||
private final LinearLayout.LayoutParams HIDE_LIST_LAYOUT_PARAMS =
|
||||
new LinearLayout.LayoutParams(MATCH_PARENT, 0);
|
||||
private final LinearLayout.LayoutParams SHOW_LAYOUT_PARAMS = new LinearLayout.LayoutParams(
|
||||
LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.MATCH_PARENT, 1f);
|
||||
LinearLayout.LayoutParams.MATCH_PARENT, MATCH_PARENT, 1f);
|
||||
private final GroupAdapter mParent;
|
||||
private final int mGroupPosition;
|
||||
/*
|
||||
@@ -577,9 +570,8 @@ public class TrustedCredentialsSettings extends OptionsMenuFragment
|
||||
showCertDialog(getItem(pos));
|
||||
}
|
||||
|
||||
public void setContainerViewId(int viewId) {
|
||||
mContainerView = (LinearLayout) mTabHost.findViewById(viewId);
|
||||
mContainerView.setVisibility(View.VISIBLE);
|
||||
public void setContainerView(LinearLayout containerView) {
|
||||
mContainerView = containerView;
|
||||
|
||||
mListView = (ListView) mContainerView.findViewById(R.id.cert_list);
|
||||
mListView.setAdapter(this);
|
||||
@@ -607,9 +599,9 @@ public class TrustedCredentialsSettings extends OptionsMenuFragment
|
||||
dividerView.setVisibility(showDivider ? View.VISIBLE : View.GONE );
|
||||
}
|
||||
|
||||
public void prepare() {
|
||||
mIsListExpanded = mParent.checkGroupExpandableAndStartWarningActivity(mGroupPosition,
|
||||
false /* startActivity */);
|
||||
public void setExpandIfAvailable(boolean expanded) {
|
||||
mIsListExpanded = expanded && mParent.checkGroupExpandableAndStartWarningActivity(
|
||||
mGroupPosition, false /* startActivity */);
|
||||
refreshViews();
|
||||
}
|
||||
|
||||
@@ -620,9 +612,10 @@ public class TrustedCredentialsSettings extends OptionsMenuFragment
|
||||
private void refreshViews() {
|
||||
mIndicatorView.setImageState(mIsListExpanded ? GROUP_EXPANDED_STATE_SET
|
||||
: EMPTY_STATE_SET, false);
|
||||
mListView.setVisibility(mIsListExpanded ? View.VISIBLE : View.GONE);
|
||||
mListView.setLayoutParams(mIsListExpanded ? SHOW_LAYOUT_PARAMS
|
||||
: HIDE_LIST_LAYOUT_PARAMS);
|
||||
mContainerView.setLayoutParams(mIsListExpanded ? SHOW_LAYOUT_PARAMS
|
||||
: HIDE_LAYOUT_PARAMS);
|
||||
: HIDE_CONTAINER_LAYOUT_PARAMS);
|
||||
}
|
||||
|
||||
// Get group indicator from styles of ExpandableListView
|
||||
|
Reference in New Issue
Block a user