diff --git a/res/layout/trusted_credential_list_container.xml b/res/layout/trusted_credential_list_container.xml
index 78e7ab748de..aca0bc8bd73 100644
--- a/res/layout/trusted_credential_list_container.xml
+++ b/res/layout/trusted_credential_list_container.xml
@@ -14,10 +14,9 @@
limitations under the License.
-->
+ android:layout_width="match_parent"
+ android:layout_height="match_parent"
+ android:orientation="vertical">
-
\ No newline at end of file
+
diff --git a/res/layout/trusted_credentials.xml b/res/layout/trusted_credentials.xml
index e52310e74e8..d6b7c8f076c 100644
--- a/res/layout/trusted_credentials.xml
+++ b/res/layout/trusted_credentials.xml
@@ -54,20 +54,8 @@
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent"
- android:visibility="gone">
-
-
-
-
-
-
+ android:visibility="gone"
+ android:animateLayoutChanges="true">
@@ -91,21 +79,8 @@
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent"
- android:visibility="gone">
-
-
-
-
-
-
-
+ android:visibility="gone"
+ android:animateLayoutChanges="true">
diff --git a/res/values/styles.xml b/res/values/styles.xml
index 12b794ae460..9605e041f76 100644
--- a/res/values/styles.xml
+++ b/res/values/styles.xml
@@ -147,8 +147,8 @@
diff --git a/src/com/android/settings/TrustedCredentialsSettings.java b/src/com/android/settings/TrustedCredentialsSettings.java
index 92b7f6bc34f..f9efb977d75 100644
--- a/src/com/android/settings/TrustedCredentialsSettings.java
+++ b/src/com/android/settings/TrustedCredentialsSettings.java
@@ -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),
+ 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