Merge "Fix padding between battery and system icons" into lmp-mr1-dev
diff --git a/packages/SystemUI/res/layout/signal_cluster_view.xml b/packages/SystemUI/res/layout/signal_cluster_view.xml
index 5889c55..f45aa85 100644
--- a/packages/SystemUI/res/layout/signal_cluster_view.xml
+++ b/packages/SystemUI/res/layout/signal_cluster_view.xml
@@ -24,6 +24,7 @@
     android:layout_width="wrap_content"
     android:gravity="center_vertical"
     android:orientation="horizontal"
+    android:paddingEnd="@dimen/signal_cluster_battery_padding"
     >
     <ImageView
         android:id="@+id/vpn"
diff --git a/packages/SystemUI/res/layout/system_icons.xml b/packages/SystemUI/res/layout/system_icons.xml
index 21386ef..943e846 100644
--- a/packages/SystemUI/res/layout/system_icons.xml
+++ b/packages/SystemUI/res/layout/system_icons.xml
@@ -36,6 +36,5 @@
     <com.android.systemui.BatteryMeterView android:id="@+id/battery"
         android:layout_height="14.5dp"
         android:layout_width="9.5dp"
-        android:layout_marginBottom="@dimen/battery_margin_bottom"
-        android:layout_marginStart="7dp"/>
+        android:layout_marginBottom="@dimen/battery_margin_bottom"/>
 </LinearLayout>
\ No newline at end of file
diff --git a/packages/SystemUI/res/values/dimens.xml b/packages/SystemUI/res/values/dimens.xml
index 51372276..07573e0 100644
--- a/packages/SystemUI/res/values/dimens.xml
+++ b/packages/SystemUI/res/values/dimens.xml
@@ -508,4 +508,10 @@
     <dimen name="fake_shadow_inset">1dp</dimen>
 
     <dimen name="fake_shadow_size">8dp</dimen>
+
+    <!-- Padding between signal cluster and battery icon -->
+    <dimen name="signal_cluster_battery_padding">7dp</dimen>
+
+    <!-- Padding for signal cluster and battery icon when there are not icons in signal cluster -->
+    <dimen name="no_signal_cluster_battery_padding">3dp</dimen>
 </resources>
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/SignalClusterView.java b/packages/SystemUI/src/com/android/systemui/statusbar/SignalClusterView.java
index 4f82f66..9154a48 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/SignalClusterView.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/SignalClusterView.java
@@ -57,6 +57,8 @@
     View mWifiSignalSpacer;
 
     private int mWideTypeIconStartPadding;
+    private int mEndPadding;
+    private int mEndPaddingNothingVisible;
 
     public SignalClusterView(Context context) {
         this(context, null);
@@ -87,6 +89,10 @@
         super.onFinishInflate();
         mWideTypeIconStartPadding = getContext().getResources().getDimensionPixelSize(
                 R.dimen.wide_type_icon_start_padding);
+        mEndPadding = getContext().getResources().getDimensionPixelSize(
+                R.dimen.signal_cluster_battery_padding);
+        mEndPaddingNothingVisible = getContext().getResources().getDimensionPixelSize(
+                R.dimen.no_signal_cluster_battery_padding);
     }
 
     @Override
@@ -255,6 +261,9 @@
                     mMobileStrengthId, mMobileTypeId));
 
         mMobileType.setVisibility(mMobileTypeId != 0 ? View.VISIBLE : View.GONE);
+
+        boolean anythingVisible = mWifiVisible || mIsAirplaneMode || mMobileVisible || mVpnVisible;
+        setPaddingRelative(0, 0, anythingVisible ? mEndPadding : mEndPaddingNothingVisible, 0);
     }
 }