Fix the incorrect title of Panel

Since panel activity is singleInstance, a newer panel will reuse the
same fragment as the previous panel when they are displayed one after
another.

Panel fragment has two kinds of exclusive header layout which shouldn't
be showed at the same time, so we have to reset their visible states
when creating panel content.

Fixes: 154668079
Test: robotest
Change-Id: I701a7cde4b43322fbc63ae1cb74c41dd23b37c0c
diff --git a/src/com/android/settings/panel/PanelFragment.java b/src/com/android/settings/panel/PanelFragment.java
index 14450a3..9de4139 100644
--- a/src/com/android/settings/panel/PanelFragment.java
+++ b/src/com/android/settings/panel/PanelFragment.java
@@ -201,6 +201,8 @@
 
         final IconCompat icon = mPanel.getIcon();
         if (icon == null) {
+            mTitleView.setVisibility(View.VISIBLE);
+            mPanelHeader.setVisibility(View.GONE);
             mTitleView.setText(mPanel.getTitle());
         } else {
             mTitleView.setVisibility(View.GONE);
@@ -220,6 +222,7 @@
             if (TextUtils.isEmpty(customTitle)) {
                 mSeeMoreButton.setVisibility(View.GONE);
             } else {
+                mSeeMoreButton.setVisibility(View.VISIBLE);
                 mSeeMoreButton.setText(customTitle);
             }
         } else if (mPanel.getSeeMoreIntent() == null) {
diff --git a/src/com/android/settings/panel/SettingsPanelActivity.java b/src/com/android/settings/panel/SettingsPanelActivity.java
index da46564..6bf016e 100644
--- a/src/com/android/settings/panel/SettingsPanelActivity.java
+++ b/src/com/android/settings/panel/SettingsPanelActivity.java
@@ -117,7 +117,7 @@
         if (!shouldForceCreation && fragment != null && fragment instanceof PanelFragment) {
             final PanelFragment panelFragment = (PanelFragment) fragment;
             panelFragment.setArguments(mBundle);
-            ((PanelFragment) fragment).updatePanelWithAnimation();
+            panelFragment.updatePanelWithAnimation();
         } else {
             setContentView(R.layout.settings_panel);