Clean up activity a bit and disable it by default

Test: visual & demo mode
Change-Id: I3718e7f58d21a28ae937064882c4edff10534701
Fixes: 36020978
diff --git a/packages/SystemUI/res/drawable/ic_activity_down.xml b/packages/SystemUI/res/drawable/ic_activity_down.xml
new file mode 100644
index 0000000..526c987
--- /dev/null
+++ b/packages/SystemUI/res/drawable/ic_activity_down.xml
@@ -0,0 +1,24 @@
+<!--
+    Copyright (C) 2017 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="5dp"
+        android:height="17.0dp"
+        android:viewportWidth="7.1"
+        android:viewportHeight="24.0">
+    <path
+        android:fillColor="#FFFFFFFF"
+        android:pathData="M3.6000004,13.2l-3.6,0.0 3.6,7.3 0.0,0.0 0.0,0.0 0.0,0.0 0.0,0.0 3.5,-7.3z"/>
+</vector>
diff --git a/packages/SystemUI/res/drawable/ic_activity_up.xml b/packages/SystemUI/res/drawable/ic_activity_up.xml
new file mode 100644
index 0000000..8d18beb
--- /dev/null
+++ b/packages/SystemUI/res/drawable/ic_activity_up.xml
@@ -0,0 +1,24 @@
+<!--
+    Copyright (C) 2017 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="5dp"
+        android:height="17.0dp"
+        android:viewportWidth="7.1"
+        android:viewportHeight="24.0">
+    <path
+        android:fillColor="#FFFFFFFF"
+        android:pathData="M3.6000004,10.8l3.5,0.0 -3.5,-7.3 0.0,0.0 0.0,0.0 0.0,0.0 0.0,0.0 -3.6,7.3z"/>
+</vector>
diff --git a/packages/SystemUI/res/layout/mobile_signal_group.xml b/packages/SystemUI/res/layout/mobile_signal_group.xml
index d988acc..33effba 100644
--- a/packages/SystemUI/res/layout/mobile_signal_group.xml
+++ b/packages/SystemUI/res/layout/mobile_signal_group.xml
@@ -16,48 +16,67 @@
 ** limitations under the License.
 */
 -->
-<FrameLayout
+<LinearLayout
     xmlns:android="http://schemas.android.com/apk/res/android"
     xmlns:systemui="http://schemas.android.com/apk/res-auto"
     android:id="@+id/mobile_combo"
     android:layout_width="wrap_content"
     android:layout_height="wrap_content"
+    android:orientation="horizontal"
     >
-    <com.android.systemui.statusbar.AnimatedImageView
-        android:theme="@style/DualToneLightTheme"
-        android:id="@+id/mobile_signal"
-        android:layout_height="wrap_content"
-        android:layout_width="wrap_content"
-        systemui:hasOverlappingRendering="false"
-        />
-    <com.android.systemui.statusbar.AnimatedImageView
-        android:theme="@style/DualToneDarkTheme"
-        android:id="@+id/mobile_signal_dark"
-        android:layout_height="wrap_content"
-        android:layout_width="wrap_content"
-        android:alpha="0.0"
-        systemui:hasOverlappingRendering="false"
-        />
-    <ImageView
-        android:id="@+id/mobile_type"
-        android:layout_height="wrap_content"
-        android:layout_width="wrap_content"
-        />
-    <ImageView
-        android:id="@+id/mobile_roaming"
-        android:layout_width="wrap_content"
+    <FrameLayout
         android:layout_height="17dp"
-        android:paddingStart="22dp"
-        android:paddingTop="1.5dp"
-        android:paddingBottom="3dp"
-        android:scaleType="fitCenter"
-        android:src="@drawable/stat_sys_roaming"
-        android:contentDescription="@string/accessibility_data_connection_roaming"
-        android:visibility="gone" />
-    <ImageView
-        android:id="@+id/mobile_inout"
-        android:layout_height="wrap_content"
+        android:layout_width="wrap_content">
+        <ImageView
+            android:id="@+id/mobile_in"
+            android:layout_height="wrap_content"
+            android:layout_width="wrap_content"
+            android:src="@drawable/ic_activity_down"
+            android:visibility="gone"
+            android:paddingEnd="2dp"
+            />
+        <ImageView
+            android:id="@+id/mobile_out"
+            android:layout_height="wrap_content"
+            android:layout_width="wrap_content"
+            android:src="@drawable/ic_activity_up"
+            android:paddingEnd="2dp"
+            android:visibility="gone"
+            />
+    </FrameLayout>
+    <FrameLayout
         android:layout_width="wrap_content"
-        android:visibility="gone"
-        />
-</FrameLayout>
+        android:layout_height="wrap_content">
+        <com.android.systemui.statusbar.AnimatedImageView
+            android:theme="@style/DualToneLightTheme"
+            android:id="@+id/mobile_signal"
+            android:layout_height="wrap_content"
+            android:layout_width="wrap_content"
+            systemui:hasOverlappingRendering="false"
+            />
+        <com.android.systemui.statusbar.AnimatedImageView
+            android:theme="@style/DualToneDarkTheme"
+            android:id="@+id/mobile_signal_dark"
+            android:layout_height="wrap_content"
+            android:layout_width="wrap_content"
+            android:alpha="0.0"
+            systemui:hasOverlappingRendering="false"
+            />
+        <ImageView
+            android:id="@+id/mobile_type"
+            android:layout_height="wrap_content"
+            android:layout_width="wrap_content"
+            />
+        <ImageView
+            android:id="@+id/mobile_roaming"
+            android:layout_width="wrap_content"
+            android:layout_height="17dp"
+            android:paddingStart="22dp"
+            android:paddingTop="1.5dp"
+            android:paddingBottom="3dp"
+            android:scaleType="fitCenter"
+            android:src="@drawable/stat_sys_roaming"
+            android:contentDescription="@string/accessibility_data_connection_roaming"
+            android:visibility="gone" />
+    </FrameLayout>
+</LinearLayout>
diff --git a/packages/SystemUI/res/layout/signal_cluster_view.xml b/packages/SystemUI/res/layout/signal_cluster_view.xml
index 4d03f0f..da7e4d7 100644
--- a/packages/SystemUI/res/layout/signal_cluster_view.xml
+++ b/packages/SystemUI/res/layout/signal_cluster_view.xml
@@ -53,6 +53,26 @@
             />
     </FrameLayout>
     <FrameLayout
+        android:layout_height="17dp"
+        android:layout_width="wrap_content">
+        <ImageView
+            android:id="@+id/wifi_in"
+            android:layout_height="wrap_content"
+            android:layout_width="wrap_content"
+            android:src="@drawable/ic_activity_down"
+            android:visibility="gone"
+            android:paddingEnd="2dp"
+            />
+        <ImageView
+            android:id="@+id/wifi_out"
+            android:layout_height="wrap_content"
+            android:layout_width="wrap_content"
+            android:src="@drawable/ic_activity_up"
+            android:paddingEnd="2dp"
+            android:visibility="gone"
+            />
+    </FrameLayout>
+    <FrameLayout
         android:id="@+id/wifi_combo"
         android:layout_height="wrap_content"
         android:layout_width="wrap_content"
diff --git a/packages/SystemUI/res/values/config.xml b/packages/SystemUI/res/values/config.xml
index f15475c..e9d6fec 100644
--- a/packages/SystemUI/res/values/config.xml
+++ b/packages/SystemUI/res/values/config.xml
@@ -332,4 +332,7 @@
     <!-- Whether or the notifications can be shown and dismissed with a drag. -->
     <bool name="config_enableNotificationShadeDrag">true</bool>
 
+    <!-- Whether to show activity indicators in the status bar -->
+    <bool name="config_showActivity">false</bool>
+
 </resources>
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/SignalClusterView.java b/packages/SystemUI/src/com/android/systemui/statusbar/SignalClusterView.java
index 88711fe..c5e1438 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/SignalClusterView.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/SignalClusterView.java
@@ -83,7 +83,8 @@
     private int mWifiStrengthId = 0;
     private int mLastWifiBadgeId = -1;
     private int mLastWifiStrengthId = -1;
-    private int mWifiActivityId = 0;
+    private boolean mWifiIn;
+    private boolean mWifiOut;
     private int mLastWifiActivityId = -1;
     private boolean mIsAirplaneMode = false;
     private int mAirplaneIconId = 0;
@@ -99,7 +100,8 @@
     ViewGroup mEthernetGroup, mWifiGroup;
     View mNoSimsCombo;
     ImageView mVpn, mEthernet, mWifi, mAirplane, mNoSims, mEthernetDark, mWifiDark, mNoSimsDark;
-    ImageView mWifiActivity;
+    ImageView mWifiActivityIn;
+    ImageView mWifiActivityOut;
     View mWifiAirplaneSpacer;
     View mWifiSignalSpacer;
     LinearLayout mMobileSignalGroup;
@@ -116,6 +118,7 @@
     private boolean mBlockMobile;
     private boolean mBlockWifi;
     private boolean mBlockEthernet;
+    private boolean mActivityEnabled;
 
     public SignalClusterView(Context context) {
         this(context, null);
@@ -144,6 +147,7 @@
         mIconScaleFactor = typedValue.getFloat();
         mNetworkController = Dependency.get(NetworkController.class);
         mSecurityController = Dependency.get(SecurityController.class);
+        updateActivityEnabled();
     }
 
     @Override
@@ -180,7 +184,8 @@
         mWifiGroup      = (ViewGroup) findViewById(R.id.wifi_combo);
         mWifi           = (ImageView) findViewById(R.id.wifi_signal);
         mWifiDark       = (ImageView) findViewById(R.id.wifi_signal_dark);
-        mWifiActivity   = (ImageView) findViewById(R.id.wifi_inout);
+        mWifiActivityIn = (ImageView) findViewById(R.id.wifi_in);
+        mWifiActivityOut= (ImageView) findViewById(R.id.wifi_out);
         mAirplane       = (ImageView) findViewById(R.id.airplane);
         mNoSims         = (ImageView) findViewById(R.id.no_sims);
         mNoSimsDark     = (ImageView) findViewById(R.id.no_sims_dark);
@@ -264,6 +269,10 @@
         });
     }
 
+    private void updateActivityEnabled() {
+        mActivityEnabled = mContext.getResources().getBoolean(R.bool.config_showActivity);
+    }
+
     @Override
     public void setWifiIndicators(boolean enabled, IconState statusIcon, IconState qsIcon,
             boolean activityIn, boolean activityOut, String description, boolean isTransient) {
@@ -271,10 +280,8 @@
         mWifiStrengthId = statusIcon.icon;
         mWifiBadgeId = statusIcon.iconOverlay;
         mWifiDescription = statusIcon.contentDescription;
-        mWifiActivityId = activityIn && activityOut ? R.drawable.stat_sys_wifi_inout
-                : activityIn ? R.drawable.stat_sys_wifi_in
-                : activityOut ? R.drawable.stat_sys_wifi_out
-                : 0;
+        mWifiIn = activityIn && mActivityEnabled;
+        mWifiOut = activityOut && mActivityEnabled;
 
         apply();
     }
@@ -294,10 +301,8 @@
         state.mMobileTypeDescription = typeContentDescription;
         state.mIsMobileTypeIconWide = statusType != 0 && isWide;
         state.mRoaming = roaming;
-        state.mMobileActivityId = activityIn && activityOut ? R.drawable.stat_sys_signal_inout
-                : activityIn ? R.drawable.stat_sys_signal_in
-                : activityOut ? R.drawable.stat_sys_signal_out
-                : 0;
+        state.mActivityIn = activityIn && mActivityEnabled;
+        state.mActivityOut = activityOut && mActivityEnabled;
 
         apply();
     }
@@ -421,10 +426,6 @@
             mLastWifiStrengthId = -1;
             mLastWifiBadgeId = -1;
         }
-        if (mWifiActivity !=  null) {
-            mWifiActivity.setImageDrawable(null);
-            mLastWifiActivityId = -1;
-        }
 
         for (PhoneState state : mPhoneStates) {
             if (state.mMobile != null) {
@@ -441,10 +442,6 @@
                 state.mMobileType.setImageDrawable(null);
                 state.mLastMobileTypeId = -1;
             }
-            if (state.mMobileActivity != null) {
-                state.mMobileActivity.setImageDrawable(null);
-                state.mLastMobileActivityId = -1;
-            }
         }
 
         if (mAirplane != null) {
@@ -504,12 +501,6 @@
                 mLastWifiStrengthId = mWifiStrengthId;
                 mLastWifiBadgeId = mWifiBadgeId;
             }
-            if (mWifiActivityId != mLastWifiActivityId) {
-                if (mWifiActivityId != 0) {
-                    setIconForView(mWifiActivity, mWifiActivityId);
-                }
-                mLastWifiActivityId = mWifiActivityId;
-            }
             mWifiGroup.setContentDescription(mWifiDescription);
             mWifiGroup.setVisibility(View.VISIBLE);
         } else {
@@ -521,7 +512,8 @@
                     (mWifiVisible ? "VISIBLE" : "GONE"),
                     mWifiStrengthId));
 
-        mWifiActivity.setVisibility(mWifiActivityId != 0 ? View.VISIBLE : View.GONE);
+        mWifiActivityIn.setVisibility(mWifiIn ? View.VISIBLE : View.GONE);
+        mWifiActivityOut.setVisibility(mWifiOut ? View.VISIBLE : View.GONE);
 
         boolean anyMobileVisible = false;
         int firstMobileTypeId = 0;
@@ -631,8 +623,10 @@
         applyDarkIntensity(
                 DarkIconDispatcher.getDarkIntensity(mTintArea, mWifi, mDarkIntensity),
                 mWifi, mWifiDark);
-        setTint(mWifiActivity,
-                DarkIconDispatcher.getTint(mTintArea, mWifiActivity, mIconTint));
+        setTint(mWifiActivityIn,
+                DarkIconDispatcher.getTint(mTintArea, mWifiActivityIn, mIconTint));
+        setTint(mWifiActivityOut,
+                DarkIconDispatcher.getTint(mTintArea, mWifiActivityOut, mIconTint));
         applyDarkIntensity(
                 DarkIconDispatcher.getDarkIntensity(mTintArea, mEthernet, mDarkIntensity),
                 mEthernet, mEthernetDark);
@@ -657,7 +651,7 @@
     private class PhoneState {
         private final int mSubId;
         private boolean mMobileVisible = false;
-        private int mMobileStrengthId = 0, mMobileTypeId = 0, mMobileActivityId = 0;
+        private int mMobileStrengthId = 0, mMobileTypeId = 0;
         private int mLastMobileStrengthId = -1;
         private int mLastMobileTypeId = -1;
         private int mLastMobileActivityId = -1;
@@ -667,7 +661,10 @@
         private ViewGroup mMobileGroup;
         private ImageView mMobile, mMobileDark, mMobileType, mMobileRoaming;
         public boolean mRoaming;
-        private ImageView mMobileActivity;
+        private ImageView mMobileActivityIn;
+        private ImageView mMobileActivityOut;
+        public boolean mActivityIn;
+        public boolean mActivityOut;
 
         public PhoneState(int subId, Context context) {
             ViewGroup root = (ViewGroup) LayoutInflater.from(context)
@@ -678,11 +675,12 @@
 
         public void setViews(ViewGroup root) {
             mMobileGroup    = root;
-            mMobile         = (ImageView) root.findViewById(R.id.mobile_signal);
-            mMobileDark     = (ImageView) root.findViewById(R.id.mobile_signal_dark);
-            mMobileType     = (ImageView) root.findViewById(R.id.mobile_type);
-            mMobileRoaming  = (ImageView) root.findViewById(R.id.mobile_roaming);
-            mMobileActivity = (ImageView) root.findViewById(R.id.mobile_inout);
+            mMobile         = root.findViewById(R.id.mobile_signal);
+            mMobileDark     = root.findViewById(R.id.mobile_signal_dark);
+            mMobileType     = root.findViewById(R.id.mobile_type);
+            mMobileRoaming  = root.findViewById(R.id.mobile_roaming);
+            mMobileActivityIn = root.findViewById(R.id.mobile_in);
+            mMobileActivityOut = root.findViewById(R.id.mobile_out);
         }
 
         public boolean apply(boolean isSecondaryIcon) {
@@ -698,10 +696,6 @@
                     mLastMobileTypeId = mMobileTypeId;
                 }
 
-                if (mLastMobileActivityId != mMobileActivityId) {
-                    mMobileActivity.setImageResource(mMobileActivityId);
-                    mLastMobileActivityId = mMobileActivityId;
-                }
                 mMobileGroup.setContentDescription(mMobileTypeDescription
                         + " " + mMobileDescription);
                 mMobileGroup.setVisibility(View.VISIBLE);
@@ -724,7 +718,8 @@
 
             mMobileType.setVisibility(mMobileTypeId != 0 ? View.VISIBLE : View.GONE);
             mMobileRoaming.setVisibility(mRoaming ? View.VISIBLE : View.GONE);
-            mMobileActivity.setVisibility(mMobileActivityId != 0 ? View.VISIBLE : View.GONE);
+            mMobileActivityIn.setVisibility(mActivityIn ? View.VISIBLE : View.GONE);
+            mMobileActivityOut.setVisibility(mActivityOut ? View.VISIBLE : View.GONE);
 
             return mMobileVisible;
         }
@@ -786,8 +781,10 @@
             setTint(mMobileType, DarkIconDispatcher.getTint(tintArea, mMobileType, tint));
             setTint(mMobileRoaming, DarkIconDispatcher.getTint(tintArea, mMobileRoaming,
                     tint));
-            setTint(mMobileActivity,
-                    DarkIconDispatcher.getTint(tintArea, mMobileActivity, tint));
+            setTint(mMobileActivityIn,
+                    DarkIconDispatcher.getTint(tintArea, mMobileActivityIn, tint));
+            setTint(mMobileActivityOut,
+                    DarkIconDispatcher.getTint(tintArea, mMobileActivityOut, tint));
         }
     }
 }