Merge "Misc clean up. move widgets from graph to widget package."
diff --git a/res/layout/battery_history_detail.xml b/res/layout/battery_history_detail.xml
index ea75865..ff83801 100644
--- a/res/layout/battery_history_detail.xml
+++ b/res/layout/battery_history_detail.xml
@@ -49,7 +49,7 @@
                 android:textAppearance="?android:attr/textAppearanceMedium"
                 android:textColor="?android:attr/textColorSecondary"/>
 
-            <com.android.settings.graph.UsageView
+            <com.android.settings.widget.UsageView
                 android:id="@+id/battery_usage"
                 android:layout_width="match_parent"
                 android:layout_height="141dp"
diff --git a/res/layout/battery_usage_graph.xml b/res/layout/battery_usage_graph.xml
index f46ac6a..93001c3 100644
--- a/res/layout/battery_usage_graph.xml
+++ b/res/layout/battery_usage_graph.xml
@@ -33,7 +33,7 @@
         android:textSize="36sp"
         android:textColor="?android:attr/colorAccent" />
 
-    <com.android.settings.graph.UsageView
+    <com.android.settings.widget.UsageView
         android:id="@+id/battery_usage"
         android:layout_width="match_parent"
         android:layout_height="141dp"
diff --git a/res/layout/data_usage_graph.xml b/res/layout/data_usage_graph.xml
index 8f83d14..ef16341 100644
--- a/res/layout/data_usage_graph.xml
+++ b/res/layout/data_usage_graph.xml
@@ -22,7 +22,7 @@
     android:paddingEnd="?android:attr/listPreferredItemPaddingEnd"
     android:orientation="vertical">
 
-    <com.android.settings.graph.UsageView
+    <com.android.settings.widget.UsageView
         android:id="@+id/data_usage"
         android:layout_width="match_parent"
         android:layout_height="@dimen/data_usage_chart_height"
diff --git a/res/layout/usage_view.xml b/res/layout/usage_view.xml
index 8e9c580..16b4916 100644
--- a/res/layout/usage_view.xml
+++ b/res/layout/usage_view.xml
@@ -57,7 +57,7 @@
 
         </LinearLayout>
 
-        <com.android.settings.graph.UsageGraph
+        <com.android.settings.widget.UsageGraph
             android:id="@+id/usage_graph"
             android:layout_width="match_parent"
             android:layout_height="match_parent"
@@ -76,7 +76,7 @@
             android:id="@+id/bottom_label_space"
             android:layout_width="@dimen/usage_graph_labels_width"
             android:layout_height="wrap_content"/>
-        <com.android.settings.graph.BottomLabelLayout
+        <com.android.settings.widget.BottomLabelLayout
             android:layout_width="0dp"
             android:layout_height="wrap_content"
             android:layout_weight="1"
@@ -93,7 +93,7 @@
 
             <include android:id="@+id/label_end"
                      layout="@layout/usage_side_label" />
-        </com.android.settings.graph.BottomLabelLayout>
+        </com.android.settings.widget.BottomLabelLayout>
     </LinearLayout>
 
 </LinearLayout>
diff --git a/src/com/android/settings/datausage/ChartDataUsagePreference.java b/src/com/android/settings/datausage/ChartDataUsagePreference.java
index d02aa88..92d5cc8 100644
--- a/src/com/android/settings/datausage/ChartDataUsagePreference.java
+++ b/src/com/android/settings/datausage/ChartDataUsagePreference.java
@@ -18,9 +18,6 @@
 import android.net.NetworkPolicy;
 import android.net.NetworkStatsHistory;
 import android.net.TrafficStats;
-import androidx.annotation.VisibleForTesting;
-import androidx.preference.Preference;
-import androidx.preference.PreferenceViewHolder;
 import android.text.SpannableStringBuilder;
 import android.text.TextUtils;
 import android.text.format.Formatter;
@@ -30,7 +27,11 @@
 
 import com.android.settings.R;
 import com.android.settings.Utils;
-import com.android.settings.graph.UsageView;
+import com.android.settings.widget.UsageView;
+
+import androidx.annotation.VisibleForTesting;
+import androidx.preference.Preference;
+import androidx.preference.PreferenceViewHolder;
 
 public class ChartDataUsagePreference extends Preference {
 
diff --git a/src/com/android/settings/fuelgauge/BatteryHistoryDetail.java b/src/com/android/settings/fuelgauge/BatteryHistoryDetail.java
index 3661467..1343fef 100644
--- a/src/com/android/settings/fuelgauge/BatteryHistoryDetail.java
+++ b/src/com/android/settings/fuelgauge/BatteryHistoryDetail.java
@@ -25,12 +25,13 @@
 import android.view.View;
 import android.view.ViewGroup;
 import android.widget.TextView;
+
 import com.android.internal.logging.nano.MetricsProto.MetricsEvent;
 import com.android.internal.os.BatteryStatsHelper;
 import com.android.settings.R;
 import com.android.settings.SettingsPreferenceFragment;
 import com.android.settings.fuelgauge.BatteryActiveView.BatteryActiveProvider;
-import com.android.settings.graph.UsageView;
+import com.android.settings.widget.UsageView;
 
 public class BatteryHistoryDetail extends SettingsPreferenceFragment {
     public static final String EXTRA_STATS = "stats";
@@ -76,7 +77,7 @@
         mPhoneParser = new BatteryCellParser();
         setHasOptionsMenu(true);
     }
-    
+
     @Override
     public View onCreateView(LayoutInflater inflater, ViewGroup container,
             Bundle savedInstanceState) {
diff --git a/src/com/android/settings/fuelgauge/BatteryHistoryPreference.java b/src/com/android/settings/fuelgauge/BatteryHistoryPreference.java
index 6ef0957..89b3edd 100644
--- a/src/com/android/settings/fuelgauge/BatteryHistoryPreference.java
+++ b/src/com/android/settings/fuelgauge/BatteryHistoryPreference.java
@@ -17,15 +17,17 @@
 package com.android.settings.fuelgauge;
 
 import android.content.Context;
-import androidx.annotation.VisibleForTesting;
-import androidx.preference.Preference;
-import androidx.preference.PreferenceViewHolder;
 import android.util.AttributeSet;
 import android.view.View;
 import android.widget.TextView;
+
 import com.android.internal.os.BatteryStatsHelper;
 import com.android.settings.R;
-import com.android.settings.graph.UsageView;
+import com.android.settings.widget.UsageView;
+
+import androidx.annotation.VisibleForTesting;
+import androidx.preference.Preference;
+import androidx.preference.PreferenceViewHolder;
 
 /**
  * Custom preference for displaying power consumption as a bar and an icon on the left for the
diff --git a/src/com/android/settings/fuelgauge/BatteryInfo.java b/src/com/android/settings/fuelgauge/BatteryInfo.java
index 9afaaba..f642d30 100644
--- a/src/com/android/settings/fuelgauge/BatteryInfo.java
+++ b/src/com/android/settings/fuelgauge/BatteryInfo.java
@@ -24,18 +24,19 @@
 import android.os.BatteryStats.HistoryItem;
 import android.os.Bundle;
 import android.os.SystemClock;
-import androidx.annotation.WorkerThread;
 import android.text.format.Formatter;
 import android.util.SparseIntArray;
 
 import com.android.internal.os.BatteryStatsHelper;
 import com.android.settings.Utils;
-import com.android.settings.graph.UsageView;
 import com.android.settings.overlay.FeatureFactory;
+import com.android.settings.widget.UsageView;
 import com.android.settingslib.R;
 import com.android.settingslib.utils.PowerUtil;
 import com.android.settingslib.utils.StringUtil;
 
+import androidx.annotation.WorkerThread;
+
 public class BatteryInfo {
 
     public CharSequence chargeLabel;
@@ -129,7 +130,7 @@
             remaining = context.getString(R.string.remaining_length_format,
                     Formatter.formatShortElapsedTime(context, remainingTimeUs / 1000));
         }
-        view.setBottomLabels(new CharSequence[]{timeString, remaining});
+        view.setBottomLabels(new CharSequence[] {timeString, remaining});
     }
 
     public static void getBatteryInfo(final Context context, final Callback callback) {
@@ -173,7 +174,7 @@
                 if (discharging && provider != null
                         && provider.isEnhancedBatteryPredictionEnabled(context)) {
                     Estimate estimate = provider.getEnhancedBatteryPrediction(context);
-                    if(estimate != null) {
+                    if (estimate != null) {
                         BatteryUtils
                                 .logRuntime(LOG_TAG, "time for enhanced BatteryInfo", startTime);
                         return BatteryInfo.getBatteryInfo(context, batteryBroadcast, stats,
diff --git a/src/com/android/settings/graph/BottomLabelLayout.java b/src/com/android/settings/widget/BottomLabelLayout.java
similarity index 98%
rename from src/com/android/settings/graph/BottomLabelLayout.java
rename to src/com/android/settings/widget/BottomLabelLayout.java
index 20d97e5..dca528f 100644
--- a/src/com/android/settings/graph/BottomLabelLayout.java
+++ b/src/com/android/settings/widget/BottomLabelLayout.java
@@ -1,5 +1,6 @@
 /*
  * 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
@@ -11,11 +12,9 @@
  * 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.
- *
- *
  */
 
-package com.android.settings.graph;
+package com.android.settings.widget;
 
 import android.annotation.Nullable;
 import android.content.Context;
diff --git a/src/com/android/settings/graph/UsageGraph.java b/src/com/android/settings/widget/UsageGraph.java
similarity index 96%
rename from src/com/android/settings/graph/UsageGraph.java
rename to src/com/android/settings/widget/UsageGraph.java
index b9d517d..da61607 100644
--- a/src/com/android/settings/graph/UsageGraph.java
+++ b/src/com/android/settings/widget/UsageGraph.java
@@ -1,18 +1,20 @@
 /*
  * Copyright (C) 2016 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
+ * 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.
+ * 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.
  */
 
-package com.android.settings.graph;
+package com.android.settings.widget;
 
 import android.annotation.Nullable;
 import android.content.Context;
diff --git a/src/com/android/settings/graph/UsageView.java b/src/com/android/settings/widget/UsageView.java
similarity index 92%
rename from src/com/android/settings/graph/UsageView.java
rename to src/com/android/settings/widget/UsageView.java
index bcf0441..54e75b3 100644
--- a/src/com/android/settings/graph/UsageView.java
+++ b/src/com/android/settings/widget/UsageView.java
@@ -1,18 +1,20 @@
 /*
  * Copyright (C) 2016 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
+ * 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.
+ * 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.
  */
 
-package com.android.settings.graph;
+package com.android.settings.widget;
 
 import android.content.Context;
 import android.content.res.TypedArray;
@@ -24,6 +26,7 @@
 import android.widget.FrameLayout;
 import android.widget.LinearLayout;
 import android.widget.TextView;
+
 import com.android.settingslib.R;
 
 public class UsageView extends FrameLayout {
diff --git a/tests/robotests/src/com/android/settings/datausage/ChartDataUsagePreferenceTest.java b/tests/robotests/src/com/android/settings/datausage/ChartDataUsagePreferenceTest.java
index 00d02a3..e053e16 100644
--- a/tests/robotests/src/com/android/settings/datausage/ChartDataUsagePreferenceTest.java
+++ b/tests/robotests/src/com/android/settings/datausage/ChartDataUsagePreferenceTest.java
@@ -25,8 +25,10 @@
 import android.net.NetworkStatsHistory;
 import android.net.NetworkStatsHistory.Entry;
 import android.util.SparseIntArray;
-import com.android.settings.graph.UsageView;
+
 import com.android.settings.testutils.SettingsRobolectricTestRunner;
+import com.android.settings.widget.UsageView;
+
 import org.junit.Before;
 import org.junit.Test;
 import org.junit.runner.RunWith;
@@ -65,7 +67,7 @@
         when(mNetworkStatsHistory.getIndexAfter(end)).thenReturn(7);
         final UsageView usageView = mock(UsageView.class);
         final ArgumentCaptor<SparseIntArray> pointsCaptor =
-            ArgumentCaptor.forClass(SparseIntArray.class);
+                ArgumentCaptor.forClass(SparseIntArray.class);
 
         mPreference.calcPoints(usageView);
 
@@ -84,7 +86,7 @@
         when(mNetworkStatsHistory.getIndexAfter(end)).thenReturn(5);
         final UsageView usageView = mock(UsageView.class);
         final ArgumentCaptor<SparseIntArray> pointsCaptor =
-            ArgumentCaptor.forClass(SparseIntArray.class);
+                ArgumentCaptor.forClass(SparseIntArray.class);
 
         mPreference.calcPoints(usageView);
 
@@ -113,9 +115,10 @@
      * Create a network entry to be used to calculate the usage chart. In the calculation, we only
      * need bucketStart, total bytes (rx + tx), and bucketDuration (which is set when we create
      * the NetworkStatsHistory object). Other fields are ignored, so we don't initialize here.
+     *
      * @param start the timestamp when this entry begins
-     * @param rx the total number of received bytes
-     * @param tx the total number of transmitted bytes
+     * @param rx    the total number of received bytes
+     * @param tx    the total number of transmitted bytes
      * @return the network entry with the corresponding start time and data usage
      */
     private Entry createEntry(long start, long rx, long tx) {
diff --git a/tests/robotests/src/com/android/settings/fuelgauge/BatteryHistoryPreferenceTest.java b/tests/robotests/src/com/android/settings/fuelgauge/BatteryHistoryPreferenceTest.java
index 0da118a..d9e5bc0 100644
--- a/tests/robotests/src/com/android/settings/fuelgauge/BatteryHistoryPreferenceTest.java
+++ b/tests/robotests/src/com/android/settings/fuelgauge/BatteryHistoryPreferenceTest.java
@@ -23,15 +23,14 @@
 import static org.mockito.Mockito.when;
 
 import android.content.Context;
-import androidx.preference.PreferenceViewHolder;
 import android.view.LayoutInflater;
 import android.view.View;
 import android.widget.TextView;
 
 import com.android.settings.R;
-import com.android.settings.graph.UsageView;
 import com.android.settings.testutils.SettingsRobolectricTestRunner;
 import com.android.settings.testutils.shadow.SettingsShadowResources;
+import com.android.settings.widget.UsageView;
 
 import org.junit.Before;
 import org.junit.Test;
@@ -41,6 +40,8 @@
 import org.robolectric.RuntimeEnvironment;
 import org.robolectric.annotation.Config;
 
+import androidx.preference.PreferenceViewHolder;
+
 @RunWith(SettingsRobolectricTestRunner.class)
 @Config(shadows = SettingsShadowResources.SettingsShadowTheme.class)
 public class BatteryHistoryPreferenceTest {
@@ -63,7 +64,7 @@
         MockitoAnnotations.initMocks(this);
         final Context context = RuntimeEnvironment.application;
         final View itemView =
-            LayoutInflater.from(context).inflate(R.layout.battery_usage_graph, null);
+                LayoutInflater.from(context).inflate(R.layout.battery_usage_graph, null);
 
         mBatteryHistoryPreference = new BatteryHistoryPreference(context, null);
         mBatteryHistoryPreference.mBatteryInfo = mBatteryInfo;
diff --git a/tests/robotests/src/com/android/settings/fuelgauge/BatteryInfoTest.java b/tests/robotests/src/com/android/settings/fuelgauge/BatteryInfoTest.java
index 99967f7..44486f8 100644
--- a/tests/robotests/src/com/android/settings/fuelgauge/BatteryInfoTest.java
+++ b/tests/robotests/src/com/android/settings/fuelgauge/BatteryInfoTest.java
@@ -36,12 +36,11 @@
 import android.os.SystemClock;
 import android.util.SparseIntArray;
 
-import com.android.settings.graph.UsageView;
 import com.android.settings.testutils.BatteryTestUtils;
 import com.android.settings.testutils.FakeFeatureFactory;
 import com.android.settings.testutils.SettingsRobolectricTestRunner;
+import com.android.settings.widget.UsageView;
 import com.android.settingslib.R;
-import com.android.settingslib.utils.PowerUtil;
 
 import org.junit.Before;
 import org.junit.Test;
@@ -172,7 +171,8 @@
     }
 
     @Test
-    public void testGetBatteryInfo_basedOnUsageTrueBetweenSevenAndFifteenMinutes_usesCorrectString() {
+    public void
+    testGetBatteryInfo_basedOnUsageTrueBetweenSevenAndFifteenMinutes_usesCorrectString() {
         Estimate estimate = new Estimate(Duration.ofMinutes(10).toMillis(),
                 true /* isBasedOnUsage */,
                 1000 /* averageDischargeTime */);
diff --git a/tests/robotests/src/com/android/settings/graph/BottomLabelLayoutTest.java b/tests/robotests/src/com/android/settings/widget/BottomLabelLayoutTest.java
similarity index 97%
rename from tests/robotests/src/com/android/settings/graph/BottomLabelLayoutTest.java
rename to tests/robotests/src/com/android/settings/widget/BottomLabelLayoutTest.java
index 6ba22d1..ea0d89a 100644
--- a/tests/robotests/src/com/android/settings/graph/BottomLabelLayoutTest.java
+++ b/tests/robotests/src/com/android/settings/widget/BottomLabelLayoutTest.java
@@ -1,5 +1,6 @@
 /*
  * 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
@@ -11,11 +12,9 @@
  * 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.
- *
- *
  */
 
-package com.android.settings.graph;
+package com.android.settings.widget;
 
 import static com.google.common.truth.Truth.assertThat;
 
diff --git a/tests/robotests/src/com/android/settings/graph/UsageGraphTest.java b/tests/robotests/src/com/android/settings/widget/UsageGraphTest.java
similarity index 99%
rename from tests/robotests/src/com/android/settings/graph/UsageGraphTest.java
rename to tests/robotests/src/com/android/settings/widget/UsageGraphTest.java
index 788d130..15658d5 100644
--- a/tests/robotests/src/com/android/settings/graph/UsageGraphTest.java
+++ b/tests/robotests/src/com/android/settings/widget/UsageGraphTest.java
@@ -1,5 +1,6 @@
 /*
  * 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
@@ -11,11 +12,9 @@
  * 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.
- *
- *
  */
 
-package com.android.settings.graph;
+package com.android.settings.widget;
 
 import static com.google.common.truth.Truth.assertThat;
 import static org.mockito.Mockito.doReturn;