diff options
| -rw-r--r-- | packages/SystemUI/src/com/android/systemui/qs/QSSecurityFooter.java | 36 | ||||
| -rw-r--r-- | packages/SystemUI/tests/src/com/android/systemui/qs/QSSecurityFooterTest.java | 52 |
2 files changed, 88 insertions, 0 deletions
diff --git a/packages/SystemUI/src/com/android/systemui/qs/QSSecurityFooter.java b/packages/SystemUI/src/com/android/systemui/qs/QSSecurityFooter.java index e574c01dd077..a48bcbd1f840 100644 --- a/packages/SystemUI/src/com/android/systemui/qs/QSSecurityFooter.java +++ b/packages/SystemUI/src/com/android/systemui/qs/QSSecurityFooter.java @@ -310,11 +310,47 @@ public class QSSecurityFooter implements OnClickListener, DialogInterface.OnClic vpnWarning.setMovementMethod(new LinkMovementMethod()); } + // Note: if a new section is added, should update configSubtitleVisibility to include + // the handling of the subtitle + configSubtitleVisibility(managementMessage != null, + caCertsMessage != null, + networkLoggingMessage != null, + vpnMessage != null, + dialogView); + mDialog.show(); mDialog.getWindow().setLayout(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT); } + protected void configSubtitleVisibility(boolean showDeviceManagement, boolean showCaCerts, + boolean showNetworkLogging, boolean showVpn, View dialogView) { + // Device Management title should always been shown + // When there is a Device Management message, all subtitles should be shown + if (showDeviceManagement) { + return; + } + // Hide the subtitle if there is only 1 message shown + int mSectionCountExcludingDeviceMgt = 0; + if (showCaCerts) { mSectionCountExcludingDeviceMgt++; } + if (showNetworkLogging) { mSectionCountExcludingDeviceMgt++; } + if (showVpn) { mSectionCountExcludingDeviceMgt++; } + + // No work needed if there is no sections or more than 1 section + if (mSectionCountExcludingDeviceMgt != 1) { + return; + } + if (showCaCerts) { + dialogView.findViewById(R.id.ca_certs_subtitle).setVisibility(View.GONE); + } + if (showNetworkLogging) { + dialogView.findViewById(R.id.network_logging_subtitle).setVisibility(View.GONE); + } + if (showVpn) { + dialogView.findViewById(R.id.vpn_subtitle).setVisibility(View.GONE); + } + } + private String getSettingsButton() { return mContext.getString(R.string.monitoring_button_view_policies); } diff --git a/packages/SystemUI/tests/src/com/android/systemui/qs/QSSecurityFooterTest.java b/packages/SystemUI/tests/src/com/android/systemui/qs/QSSecurityFooterTest.java index a8487b3eff4e..4f98836eeec7 100644 --- a/packages/SystemUI/tests/src/com/android/systemui/qs/QSSecurityFooterTest.java +++ b/packages/SystemUI/tests/src/com/android/systemui/qs/QSSecurityFooterTest.java @@ -29,6 +29,7 @@ import android.provider.Settings; import android.support.test.runner.AndroidJUnit4; import android.test.suitebuilder.annotation.SmallTest; import android.text.SpannableStringBuilder; +import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; import android.widget.TextView; @@ -395,6 +396,57 @@ public class QSSecurityFooterTest extends SysuiTestCase { mFooter.getVpnMessage(false, true, VPN_PACKAGE, null)); } + @Test + public void testConfigSubtitleVisibility() { + View view = LayoutInflater.from(mContext) + .inflate(R.layout.quick_settings_footer_dialog, null); + + // Device Management subtitle should be shown when there is Device Management section only + // Other sections visibility will be set somewhere else so it will not be tested here + mFooter.configSubtitleVisibility(true, false, false, false, view); + assertEquals(View.VISIBLE, + view.findViewById(R.id.device_management_subtitle).getVisibility()); + + // If there are multiple sections, all subtitles should be shown + mFooter.configSubtitleVisibility(true, true, false, false, view); + assertEquals(View.VISIBLE, + view.findViewById(R.id.device_management_subtitle).getVisibility()); + assertEquals(View.VISIBLE, + view.findViewById(R.id.ca_certs_subtitle).getVisibility()); + + // If there are multiple sections, all subtitles should be shown + mFooter.configSubtitleVisibility(true, true, true, true, view); + assertEquals(View.VISIBLE, + view.findViewById(R.id.device_management_subtitle).getVisibility()); + assertEquals(View.VISIBLE, + view.findViewById(R.id.ca_certs_subtitle).getVisibility()); + assertEquals(View.VISIBLE, + view.findViewById(R.id.network_logging_subtitle).getVisibility()); + assertEquals(View.VISIBLE, + view.findViewById(R.id.vpn_subtitle).getVisibility()); + + // If there are multiple sections, all subtitles should be shown, event if there is no + // Device Management section + mFooter.configSubtitleVisibility(false, true, true, true, view); + assertEquals(View.VISIBLE, + view.findViewById(R.id.ca_certs_subtitle).getVisibility()); + assertEquals(View.VISIBLE, + view.findViewById(R.id.network_logging_subtitle).getVisibility()); + assertEquals(View.VISIBLE, + view.findViewById(R.id.vpn_subtitle).getVisibility()); + + // If there is only 1 section, the title should be hidden + mFooter.configSubtitleVisibility(false, true, false, false, view); + assertEquals(View.GONE, + view.findViewById(R.id.ca_certs_subtitle).getVisibility()); + mFooter.configSubtitleVisibility(false, false, true, false, view); + assertEquals(View.GONE, + view.findViewById(R.id.network_logging_subtitle).getVisibility()); + mFooter.configSubtitleVisibility(false, false, false, true, view); + assertEquals(View.GONE, + view.findViewById(R.id.vpn_subtitle).getVisibility()); + } + private CharSequence addLink(CharSequence description) { final SpannableStringBuilder message = new SpannableStringBuilder(); message.append(description); |