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
This commit is contained in:
Fabrice Di Meglio
2014-07-18 15:20:34 -07:00
parent 3bd0515242
commit d40dd45c18
8 changed files with 45 additions and 21 deletions

View File

@@ -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>

View File

@@ -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>

View File

@@ -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"
/>

View File

@@ -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>

View File

@@ -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>

View File

@@ -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>

View File

@@ -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>

View File

@@ -489,9 +489,10 @@ public class SettingsActivity extends Activity
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 class SettingsActivity extends Activity
*/
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 @@ public class SettingsActivity extends Activity
}
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 @@ public class SettingsActivity extends Activity
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 {