Fix overdraw and do some layout optimizations
- use a specific layout for the Dashboard and for the Preferences
- use a specific background for the Dashboard and for the Preferences
The main idea here is that you cannot have the same layout / background
because the Dashboard is using the "Z elevation" for having its card
"poping up"
Change-Id: I42b7c91efea14315b8a60cf3876938a7f1d1e0b3
diff --git a/res/drawable/preference_list_fragment_background.xml b/res/drawable/preference_background.xml
similarity index 91%
rename from res/drawable/preference_list_fragment_background.xml
rename to res/drawable/preference_background.xml
index 94e0381..f47bcf5 100644
--- a/res/drawable/preference_list_fragment_background.xml
+++ b/res/drawable/preference_background.xml
@@ -21,9 +21,7 @@
android:insetBottom="0dip">
<shape android:shape="rectangle">
-
- <solid android:color="@color/preference_list_fragment_background_color" />
-
+ <solid android:color="@color/preference_background_color" />
</shape>
</inset>
diff --git a/res/layout/preference_list_fragment.xml b/res/layout/preference_list_fragment.xml
index a97415e..8391641 100644
--- a/res/layout/preference_list_fragment.xml
+++ b/res/layout/preference_list_fragment.xml
@@ -36,8 +36,6 @@
android:scrollbarStyle="@*android:integer/preference_fragment_scrollbarStyle"
android:clipToPadding="false"
android:drawSelectorOnTop="false"
- android:cacheColorHint="@android:color/white"
- android:background="@drawable/preference_list_fragment_background"
android:elevation="@dimen/dashboard_category_elevation"
android:scrollbarAlwaysDrawVerticalTrack="true" />
@@ -82,6 +80,8 @@
android:text="@*android:string/next_button_label"
/>
</LinearLayout>
+
</RelativeLayout>
+
</LinearLayout>
diff --git a/res/layout/settings_main_dashboard.xml b/res/layout/settings_main_dashboard.xml
new file mode 100644
index 0000000..56f2737
--- /dev/null
+++ b/res/layout/settings_main_dashboard.xml
@@ -0,0 +1,25 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+/*
+** Copyright 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.
+*/
+-->
+
+<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
+ android:id="@+id/main_content"
+ android:layout_height="match_parent"
+ android:layout_width="match_parent"
+ android:background="@color/dashboard_background_color"
+ />
diff --git a/res/layout/settings_main.xml b/res/layout/settings_main_prefs.xml
similarity index 94%
rename from res/layout/settings_main.xml
rename to res/layout/settings_main_prefs.xml
index 56737a1..53fd918 100644
--- a/res/layout/settings_main.xml
+++ b/res/layout/settings_main_prefs.xml
@@ -20,8 +20,7 @@
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_height="match_parent"
- android:layout_width="match_parent"
- android:background="?attr/dashboardBackgroundColor">
+ android:layout_width="match_parent">
<LinearLayout
android:orientation="vertical"
@@ -37,9 +36,10 @@
/>
<FrameLayout
- android:id="@+id/prefs"
+ android:id="@+id/main_content"
android:layout_width="match_parent"
android:layout_height="match_parent"
+ android:background="?attr/preferenceBackgroundColor"
/>
</LinearLayout>
diff --git a/res/values/attrs.xml b/res/values/attrs.xml
index 71e08d8..2987de1 100644
--- a/res/values/attrs.xml
+++ b/res/values/attrs.xml
@@ -101,5 +101,5 @@
<attr name="switchBarMarginStart" format="dimension" />
<attr name="switchBarMarginEnd" format="dimension" />
- <attr name="dashboardBackgroundColor" format="color" />
+ <attr name="preferenceBackgroundColor" format="color" />
</resources>
diff --git a/res/values/colors.xml b/res/values/colors.xml
index 0b3ea39..e34097b 100644
--- a/res/values/colors.xml
+++ b/res/values/colors.xml
@@ -60,6 +60,6 @@
<color name="switch_accent_color">#ff7fcac3</color>
<color name="default_preference_background_color">@android:color/white</color>
- <color name="preference_list_fragment_background_color">@color/default_preference_background_color</color>
+ <color name="preference_background_color">@color/default_preference_background_color</color>
<color name="search_panel_list_background_color">@color/default_preference_background_color</color>
</resources>
diff --git a/res/values/themes.xml b/res/values/themes.xml
index 92bb3b2..4f8add7 100644
--- a/res/values/themes.xml
+++ b/res/values/themes.xml
@@ -33,7 +33,7 @@
<item name="ic_wps">@drawable/ic_wps_dark</item>
<item name="setup_divider_color">@color/setup_divider_color_dark</item>
<item name="wifi_signal">@drawable/wifi_signal_dark</item>
- <item name="dashboardBackgroundColor">@color/dashboard_background_color</item>
+ <item name="preferenceBackgroundColor">@drawable/preference_background</item>
</style>
<style name="SetupWizardWifiTheme.Light" parent="android:Theme.Material.Light.NoActionBar">
@@ -48,7 +48,7 @@
<item name="ic_wps">@drawable/ic_wps_light</item>
<item name="setup_divider_color">@color/setup_divider_color_light</item>
<item name="wifi_signal">@drawable/wifi_signal_light</item>
- <item name="dashboardBackgroundColor">@color/dashboard_background_color</item>
+ <item name="preferenceBackgroundColor">@drawable/preference_background</item>
</style>
<style name="Theme.WifiDialog" parent="@*android:style/Theme.Material.Dialog.Alert">
@@ -92,7 +92,7 @@
<item name="switchBarTheme">@style/Theme.SwitchBar.Settings</item>
- <item name="dashboardBackgroundColor">@color/dashboard_background_color</item>
+ <item name="preferenceBackgroundColor">@drawable/preference_background</item>
<!-- Redefine the ActionBar style for contentInsetStart -->
<item name="android:actionBarStyle">@style/Theme.ActionBar</item>
@@ -142,7 +142,7 @@
<!-- Redefine the ActionBar style for contentInsetStart -->
<item name="android:actionBarStyle">@style/Theme.ActionBar</item>
- <item name="dashboardBackgroundColor">@color/dashboard_background_color</item>
+ <item name="preferenceBackgroundColor">@drawable/preference_background</item>
</style>
<style name="Theme.CryptKeeper" parent="@android:style/Theme.Material.Light.NoActionBar">
@@ -156,7 +156,7 @@
<item name="android:actionBarWidgetTheme">@null</item>
<item name="android:actionBarTheme">@android:style/ThemeOverlay.Material.Dark.ActionBar</item>
- <item name="dashboardBackgroundColor">@color/dashboard_background_color</item>
+ <item name="preferenceBackgroundColor">@drawable/preference_background</item>
</style>
<style name="Theme.AlertDialog" parent="@*android:style/Theme.Material.Light.Dialog.Alert">
@@ -177,7 +177,7 @@
<item name="switchBarMarginStart">0dip</item>
<item name="switchBarMarginEnd">0dip</item>
- <item name="dashboardBackgroundColor">@android:color/transparent</item>
+ <item name="preferenceBackgroundColor">@android:color/transparent</item>
</style>
</resources>
diff --git a/src/com/android/settings/SettingsActivity.java b/src/com/android/settings/SettingsActivity.java
index 290473e..a0f43fb 100644
--- a/src/com/android/settings/SettingsActivity.java
+++ b/src/com/android/settings/SettingsActivity.java
@@ -489,9 +489,10 @@
setTheme(R.style.Theme_SubSettings);
}
- setContentView(R.layout.settings_main);
+ setContentView(mIsShowingDashboard ?
+ R.layout.settings_main_dashboard : R.layout.settings_main_prefs);
- mContent = (ViewGroup) findViewById(R.id.prefs);
+ mContent = (ViewGroup) findViewById(R.id.main_content);
getFragmentManager().addOnBackStackChangedListener(this);
@@ -830,7 +831,7 @@
*/
public void startPreferenceFragment(Fragment fragment, boolean push) {
FragmentTransaction transaction = getFragmentManager().beginTransaction();
- transaction.replace(R.id.prefs, fragment);
+ transaction.replace(R.id.main_content, fragment);
if (push) {
transaction.setTransition(FragmentTransaction.TRANSIT_FRAGMENT_OPEN);
transaction.addToBackStack(BACK_STACK_PREFS);
@@ -851,7 +852,7 @@
}
Fragment f = Fragment.instantiate(this, fragmentName, args);
FragmentTransaction transaction = getFragmentManager().beginTransaction();
- transaction.replace(R.id.prefs, f);
+ transaction.replace(R.id.main_content, f);
if (withTransition) {
TransitionManager.beginDelayedTransition(mContent);
}
@@ -1239,7 +1240,7 @@
if (mSearchResultsFragment != null) {
return;
}
- Fragment current = getFragmentManager().findFragmentById(R.id.prefs);
+ Fragment current = getFragmentManager().findFragmentById(R.id.main_content);
if (current != null && current instanceof SearchResultsSummary) {
mSearchResultsFragment = (SearchResultsSummary) current;
} else {