diff options
author | Jason Monk <jmonk@google.com> | 2014-09-03 13:18:57 -0400 |
---|---|---|
committer | Jason Monk <jmonk@google.com> | 2014-09-05 10:31:00 -0400 |
commit | 3128f12f216ef481b5d03892b35706cfeec26d7c (patch) | |
tree | 9404ce923746ca0d8ea9e052decb431b42195ae5 | |
parent | 6bed40eddc29c536c064c9238cfefe863c3d0db5 (diff) | |
download | frameworks_base-3128f12f216ef481b5d03892b35706cfeec26d7c.zip frameworks_base-3128f12f216ef481b5d03892b35706cfeec26d7c.tar.gz frameworks_base-3128f12f216ef481b5d03892b35706cfeec26d7c.tar.bz2 |
Add VPN Key to signal icons
Since the notification is going away, this gives a persistent
icon to indicate that VPN is active.
Bug: 16153201
Change-Id: Ic2ca7a332817967b76871bd0800d6f0a77a295cd
5 files changed, 65 insertions, 4 deletions
diff --git a/packages/SystemUI/res/drawable/stat_sys_vpn_ic.xml b/packages/SystemUI/res/drawable/stat_sys_vpn_ic.xml new file mode 100644 index 0000000..7ca8c40 --- /dev/null +++ b/packages/SystemUI/res/drawable/stat_sys_vpn_ic.xml @@ -0,0 +1,24 @@ +<!-- +Copyright (C) 2014 The Android Open Source Project + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +--> +<vector xmlns:android="http://schemas.android.com/apk/res/android" + android:width="17.0dp" + android:height="17.0dp" + android:viewportWidth="24.0" + android:viewportHeight="24.0"> + <path + android:fillColor="#FFFFFFFF" + android:pathData="M12.700000,10.000000c-0.800000,-2.300000 -3.000000,-4.000000 -5.700000,-4.000000c-3.300000,0.000000 -6.000000,2.700000 -6.000000,6.000000s2.700000,6.000000 6.000000,6.000000c2.600000,0.000000 4.800000,-1.700000 5.700000,-4.000000L17.000000,14.000000l0.000000,4.000000l4.000000,0.000000l0.000000,-4.000000l2.000000,0.000000l0.000000,-4.000000L12.700000,10.000000zM7.000000,14.000000c-1.100000,0.000000 -2.000000,-0.900000 -2.000000,-2.000000c0.000000,-1.100000 0.900000,-2.000000 2.000000,-2.000000s2.000000,0.900000 2.000000,2.000000C9.000000,13.100000 8.100000,14.000000 7.000000,14.000000z"/> +</vector> diff --git a/packages/SystemUI/res/layout/signal_cluster_view.xml b/packages/SystemUI/res/layout/signal_cluster_view.xml index 347c8a9..3a8a17d 100644 --- a/packages/SystemUI/res/layout/signal_cluster_view.xml +++ b/packages/SystemUI/res/layout/signal_cluster_view.xml @@ -25,6 +25,13 @@ android:gravity="center_vertical" android:orientation="horizontal" > + <ImageView + android:id="@+id/vpn" + android:layout_height="wrap_content" + android:layout_width="wrap_content" + android:paddingEnd="6dp" + android:src="@drawable/stat_sys_vpn_ic" + /> <FrameLayout android:id="@+id/wifi_combo" android:layout_height="wrap_content" diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/SignalClusterView.java b/packages/SystemUI/src/com/android/systemui/statusbar/SignalClusterView.java index 5883c26..740211f 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/SignalClusterView.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/SignalClusterView.java @@ -27,17 +27,21 @@ import android.widget.LinearLayout; import com.android.systemui.R; import com.android.systemui.statusbar.policy.NetworkControllerImpl; +import com.android.systemui.statusbar.policy.SecurityController; // Intimately tied to the design of res/layout/signal_cluster_view.xml public class SignalClusterView extends LinearLayout - implements NetworkControllerImpl.SignalCluster { + implements NetworkControllerImpl.SignalCluster, + SecurityController.SecurityControllerCallback { static final String TAG = "SignalClusterView"; static final boolean DEBUG = Log.isLoggable(TAG, Log.DEBUG); NetworkControllerImpl mNC; + SecurityController mSC; + private boolean mVpnVisible = false; private boolean mWifiVisible = false; private int mWifiStrengthId = 0; private boolean mMobileVisible = false; @@ -48,7 +52,7 @@ public class SignalClusterView private boolean mRoaming; ViewGroup mWifiGroup, mMobileGroup; - ImageView mWifi, mMobile, mMobileType, mAirplane; + ImageView mVpn, mWifi, mMobile, mMobileType, mAirplane; View mWifiAirplaneSpacer; public SignalClusterView(Context context) { @@ -68,10 +72,18 @@ public class SignalClusterView mNC = nc; } + public void setSecurityController(SecurityController sc) { + if (DEBUG) Log.d(TAG, "SecurityController=" + sc); + mSC = sc; + mSC.addCallback(this); + mVpnVisible = mSC.isVpnEnabled(); + } + @Override protected void onAttachedToWindow() { super.onAttachedToWindow(); + mVpn = (ImageView) findViewById(R.id.vpn); mWifiGroup = (ViewGroup) findViewById(R.id.wifi_combo); mWifi = (ImageView) findViewById(R.id.wifi_signal); mMobileGroup = (ViewGroup) findViewById(R.id.mobile_combo); @@ -85,6 +97,7 @@ public class SignalClusterView @Override protected void onDetachedFromWindow() { + mVpn = null; mWifiGroup = null; mWifi = null; mMobileGroup = null; @@ -95,6 +108,18 @@ public class SignalClusterView super.onDetachedFromWindow(); } + // From SecurityController. + @Override + public void onStateChanged() { + post(new Runnable() { + @Override + public void run() { + mVpnVisible = mSC.isVpnEnabled(); + apply(); + } + }); + } + @Override public void setWifiIndicators(boolean visible, int strengthIcon, String contentDescription) { mWifiVisible = visible; @@ -168,6 +193,8 @@ public class SignalClusterView private void apply() { if (mWifiGroup == null) return; + mVpn.setVisibility(mVpnVisible ? View.VISIBLE : View.GONE); + if (DEBUG) Log.d(TAG, String.format("vpn: %s", mVpnVisible ? "VISIBLE" : "GONE")); if (mWifiVisible) { mWifi.setImageResource(mWifiStrengthId); mWifiGroup.setContentDescription(mWifiDescription); diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/PhoneStatusBar.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/PhoneStatusBar.java index ddd03d6..9ddc64f 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/PhoneStatusBar.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/PhoneStatusBar.java @@ -786,8 +786,11 @@ public class PhoneStatusBar extends BaseStatusBar implements DemoMode, mNetworkController.addSignalCluster(signalCluster); mNetworkController.addSignalCluster(signalClusterKeyguard); mNetworkController.addSignalCluster(signalClusterQs); + signalCluster.setSecurityController(mSecurityController); signalCluster.setNetworkController(mNetworkController); + signalClusterKeyguard.setSecurityController(mSecurityController); signalClusterKeyguard.setNetworkController(mNetworkController); + signalClusterQs.setSecurityController(mSecurityController); signalClusterQs.setNetworkController(mNetworkController); final boolean isAPhone = mNetworkController.hasVoiceCallingFeature(); if (isAPhone) { diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/policy/SecurityControllerImpl.java b/packages/SystemUI/src/com/android/systemui/statusbar/policy/SecurityControllerImpl.java index a15ddaf..2fbb812 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/policy/SecurityControllerImpl.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/policy/SecurityControllerImpl.java @@ -139,14 +139,14 @@ public class SecurityControllerImpl implements SecurityController { } @Override - public void addCallback(SecurityControllerCallback callback) { + public void removeCallback(SecurityControllerCallback callback) { if (callback == null) return; if (DEBUG) Log.d(TAG, "removeCallback " + callback); mCallbacks.remove(callback); } @Override - public void removeCallback(SecurityControllerCallback callback) { + public void addCallback(SecurityControllerCallback callback) { if (callback == null || mCallbacks.contains(callback)) return; if (DEBUG) Log.d(TAG, "addCallback " + callback); mCallbacks.add(callback); |