OSDN Git Service

Settings tweaks
authorJason Monk <jmonk@google.com>
Fri, 8 Apr 2016 18:54:17 +0000 (14:54 -0400)
committerJason Monk <jmonk@google.com>
Fri, 8 Apr 2016 20:44:31 +0000 (16:44 -0400)
Change-Id: I68829fa8e49534d4635a008c94dced3c7ab6f4b1
Fixes: 27834471
Fixes: 27834626
Fixes: 27567838
Fixes: 27834676

res/layout/condition_card.xml
res/layout/dashboard_category.xml
res/layout/dashboard_spacer.xml
res/values/colors.xml
res/xml/location_settings.xml
res/xml/manage_assist.xml
res/xml/wifi_configure_settings.xml
src/com/android/settings/dashboard/DashboardDecorator.java [new file with mode: 0644]
src/com/android/settings/dashboard/DashboardSummary.java
src/com/android/settings/fuelgauge/BatteryHistoryPreference.java

index 6a08d55..0e480a5 100644 (file)
@@ -27,7 +27,7 @@
         android:orientation="vertical"
         android:paddingStart="16dp"
         android:background="?android:attr/colorAccent"
-        android:elevation="3dp"
+        android:elevation="2dp"
         android:clickable="true">
 
         <LinearLayout
index 0a7aed9..b3500b2 100644 (file)
     android:background="@color/card_background"
     android:importantForAccessibility="noHideDescendants">
 
-    <View
-        android:layout_width="match_parent"
-        android:layout_height="1dp"
-        android:background="?android:attr/listDivider" />
-
     <TextView android:id="@android:id/title"
         android:layout_width="match_parent"
         android:layout_height="match_parent"
index d7d9717..19ef8ff 100644 (file)
@@ -16,4 +16,4 @@
 
 <View xmlns:android="http://schemas.android.com/apk/res/android"
         android:layout_width="match_parent"
-        android:layout_height="10dp" />
+        android:layout_height="6dp" />
index 34ca866..89b2d15 100644 (file)
 
     <color name="seek_bar_preference_preview_text">#fff</color>
 
+    <color name="usage_graph_dots">#B0BEC5</color>
+
 </resources>
index 9fd0826..1abf9be 100644 (file)
@@ -34,7 +34,7 @@
             android:enabled="false"
             android:selectable="true" />
 
-        <PreferenceCategory
+        <com.android.settings.DividedCategory
             android:key="recent_location_requests"
             android:title="@string/location_category_recent_location_requests" />
 
index 97a06ea..6984f88 100644 (file)
@@ -17,6 +17,7 @@
 
 <PreferenceScreen
         xmlns:android="http://schemas.android.com/apk/res/android"
+        xmlns:settings="http://schemas.android.com/apk/res-auto"
         android:key="manage_assist">
 
     <com.android.settings.applications.DefaultAssistPreference
@@ -40,8 +41,9 @@
             android:title="@string/voice_input_settings_title"
             />
 
-    <Preference
+    <com.android.settings.DividerPreference
         android:summary="@string/assist_footer"
-        android:selectable="false"/>
+        android:selectable="false"
+        settings:allowDividerAbove="true" />
 
 </PreferenceScreen>
index 71a81dd..3aeb83e 100644 (file)
@@ -15,6 +15,7 @@
 -->
 
 <PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android"
+        xmlns:settings="http://schemas.android.com/apk/res-auto"
         android:title="@string/wifi_configure_titlebar">
 
     <Preference
         android:summary="@string/wifi_automatically_connect_summary"
         android:dialogTitle="@string/wifi_select_assistant_dialog_title" />
 
-    <Preference
+    <com.android.settings.DividerPreference
         android:key="mac_address"
         android:title="@string/wifi_advanced_mac_address_title"
-        android:layout="@layout/wifi_advance_layout" />
+        android:layout="@layout/wifi_advance_layout"
+        settings:allowDividerAbove="true" />
 
     <Preference
         android:key="current_ip_address"
diff --git a/src/com/android/settings/dashboard/DashboardDecorator.java b/src/com/android/settings/dashboard/DashboardDecorator.java
new file mode 100644 (file)
index 0000000..2e7afaf
--- /dev/null
@@ -0,0 +1,69 @@
+/*
+ * 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
+ *
+ *      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.
+ */
+
+package com.android.settings.dashboard;
+
+import android.content.Context;
+import android.graphics.Canvas;
+import android.graphics.drawable.Drawable;
+import android.support.v4.view.ViewCompat;
+import android.support.v7.widget.RecyclerView;
+import android.support.v7.widget.RecyclerView.State;
+import android.support.v7.widget.RecyclerView.ViewHolder;
+import android.util.Log;
+import android.util.TypedValue;
+import android.view.View;
+import com.android.settings.R;
+
+public class DashboardDecorator extends RecyclerView.ItemDecoration {
+
+    private final Context mContext;
+    private final Drawable mDivider;
+
+    public DashboardDecorator(Context context) {
+        mContext = context;
+        TypedValue value = new TypedValue();
+        mContext.getTheme().resolveAttribute(android.R.attr.listDivider, value, true);
+        mDivider = mContext.getDrawable(value.resourceId);
+    }
+
+    @Override
+    public void onDrawOver(Canvas c, RecyclerView parent, State state) {
+        final int childCount = parent.getChildCount();
+        final int width = parent.getWidth();
+        final int bottom = parent.getBottom();
+        for (int i = 1; i < childCount; i++) {
+            final View child = parent.getChildAt(i);
+            final ViewHolder holder = parent.getChildViewHolder(child);
+            if (holder.getItemViewType() == R.layout.dashboard_category) {
+                if (parent.getChildViewHolder(parent.getChildAt(i - 1)).getItemViewType()
+                        != R.layout.dashboard_tile) {
+                    continue;
+                }
+            } else if (holder.getItemViewType() != R.layout.condition_card) {
+                continue;
+            }
+
+            int top = getChildTop(child);
+            mDivider.setBounds(0, top, width, top + mDivider.getIntrinsicHeight());
+            mDivider.draw(c);
+        }
+    }
+
+    private int getChildTop(View child) {
+        final RecyclerView.LayoutParams params = (RecyclerView.LayoutParams) child
+                .getLayoutParams();
+        return child.getTop() + params.topMargin + Math.round(ViewCompat.getTranslationY(child));
+    }
+}
index 5d9a79b..12a92bd 100644 (file)
@@ -171,6 +171,7 @@ public class DashboardSummary extends InstrumentedFragment
         mDashboard.setLayoutManager(mLayoutManager);
         mDashboard.setHasFixedSize(true);
         mDashboard.setListener(this);
+        mDashboard.addItemDecoration(new DashboardDecorator(getContext()));
         mAdapter = new DashboardAdapter(getContext());
         mAdapter.setConditions(mConditionManager.getConditions());
         mAdapter.setSuggestions(mSuggestionParser);
index ba93f98..0f36ab1 100644 (file)
@@ -76,6 +76,7 @@ public class BatteryHistoryPreference extends Preference {
         ((TextView) view.findViewById(R.id.charge)).setText(mBatteryInfo.batteryPercentString);
         ((TextView) view.findViewById(R.id.estimation)).setText(mBatteryInfo.remainingLabel);
         UsageView usageView = (UsageView) view.findViewById(R.id.battery_usage);
+        usageView.findViewById(R.id.label_group).setAlpha(.7f);
         mBatteryInfo.bindHistory(usageView);
     }
 }