fix press feedback on notification rows

Change-Id: I50de2f4d6142c2553428abc853c820f4354d0640
Bug: 6362246
This commit is contained in:
Chris Wren
2012-04-19 17:58:03 -04:00
committed by Android (Google) Code Review
parent e17fc7d669
commit d84e593746
16 changed files with 98 additions and 14 deletions

View File

@@ -26,8 +26,11 @@ import android.content.Context;
import android.content.res.TypedArray;
import android.graphics.Color;
import android.graphics.drawable.ColorDrawable;
import android.graphics.drawable.Drawable;
import android.graphics.drawable.StateListDrawable;
import android.util.AttributeSet;
import android.util.Log;
import android.util.StateSet;
import android.view.View;
import android.view.ViewDebug;
import android.view.ViewGroup;
@@ -90,8 +93,14 @@ public class SizeAdaptiveLayout extends ViewGroup {
private void initialize() {
mModestyPanel = new View(getContext());
// If the SizeAdaptiveLayout has a solid background, use it as a transition hint.
if (getBackground() instanceof ColorDrawable) {
mModestyPanel.setBackgroundDrawable(getBackground());
Drawable background = getBackground();
if (background instanceof StateListDrawable) {
StateListDrawable sld = (StateListDrawable) background;
sld.setState(StateSet.WILD_CARD);
background = sld.getCurrent();
}
if (background instanceof ColorDrawable) {
mModestyPanel.setBackgroundDrawable(background);
} else {
mModestyPanel.setBackgroundColor(Color.BLACK);
}

View File

@@ -16,7 +16,7 @@
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:internal="http://schemas.android.com/apk/prv/res/android"
android:background="@android:color/background_dark"
android:background="@android:drawable/notification_bg"
android:id="@+id/status_bar_latest_event_content"
android:layout_width="match_parent"
android:layout_height="64dp"

View File

@@ -16,7 +16,7 @@
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:internal="http://schemas.android.com/apk/prv/res/android"
android:background="@android:color/background_dark"
android:background="@android:drawable/notification_bg"
android:id="@+id/status_bar_latest_event_content"
android:layout_width="match_parent"
android:layout_height="match_parent"

View File

@@ -15,7 +15,7 @@
-->
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:internal="http://schemas.android.com/apk/prv/res/android"
android:background="@android:color/background_dark"
android:background="@android:drawable/notification_bg"
android:id="@+id/status_bar_latest_event_content"
android:layout_width="match_parent"
android:layout_height="wrap_content"

View File

@@ -22,6 +22,8 @@
<drawable name="screen_background_dark">#ff000000</drawable>
<drawable name="status_bar_closed_default_background">#ff000000</drawable>
<drawable name="status_bar_opened_default_background">#ff000000</drawable>
<drawable name="notification_item_background_color">#ff111111</drawable>
<drawable name="notification_item_background_color_pressed">#ff257390</drawable>
<drawable name="search_bar_default_color">#ff000000</drawable>
<drawable name="safe_mode_background">#60000000</drawable>
<!-- Background drawable that can be used for a transparent activity to

View File

@@ -1002,6 +1002,7 @@
<java-symbol type="drawable" name="ic_lockscreen_silent" />
<java-symbol type="drawable" name="ic_lockscreen_unlock" />
<java-symbol type="drawable" name="ic_lockscreen_search" />
<java-symbol type="drawable" name="notification_bg" />
<java-symbol type="layout" name="action_bar_home" />
<java-symbol type="layout" name="action_bar_title_item" />

View File

@@ -0,0 +1,21 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- Copyright (C) 2011 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.
-->
<selector xmlns:android="http://schemas.android.com/apk/res/android"
android:exitFadeDuration="@android:integer/config_mediumAnimTime">
<item android:state_pressed="true" android:drawable="@drawable/blue" />
<item android:state_pressed="false" android:drawable="@drawable/red" />
</selector>

View File

@@ -0,0 +1,41 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- Copyright (C) 2012 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.
-->
<com.android.internal.widget.SizeAdaptiveLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:internal="http://schemas.android.com/apk/prv/res/android"
android:background="@drawable/size_adaptive_statelist"
android:id="@+id/multi1"
android:layout_width="match_parent"
android:layout_height="64dp" >
<include
android:id="@+id/one_u"
layout="@layout/size_adaptive_one_u"
android:layout_width="fill_parent"
android:layout_height="64dp"
internal:layout_minHeight="64dp"
internal:layout_maxHeight="64dp"
/>
<include
android:id="@+id/four_u"
layout="@layout/size_adaptive_four_u"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
internal:layout_minHeight="65dp"
internal:layout_maxHeight="unbounded"/>
</com.android.internal.widget.SizeAdaptiveLayout>

View File

@@ -19,6 +19,7 @@ package com.android.internal.widget;
import com.android.frameworks.coretests.R;
import android.content.Context;
import android.graphics.Color;
import android.graphics.drawable.ColorDrawable;
import android.test.AndroidTestCase;
import android.test.suitebuilder.annotation.SmallTest;
@@ -427,6 +428,17 @@ public class SizeAdaptiveLayoutTest extends AndroidTestCase {
panelColor.getColor(), salColor.getColor());
}
@SmallTest
public void testModestyPanelTracksStateListColor() {
inflate(R.layout.size_adaptive_color_statelist);
View panel = mSizeAdaptiveLayout.getModestyPanel();
assertEquals("ModestyPanel should have a ColorDrawable background" ,
panel.getBackground().getClass(), ColorDrawable.class);
ColorDrawable panelColor = (ColorDrawable) panel.getBackground();
assertEquals("ModestyPanel color should match the SizeAdaptiveLayout",
panelColor.getColor(), Color.RED);
}
@SmallTest
public void testModestyPanelHasDefault() {
inflate(R.layout.size_adaptive);

View File

@@ -17,6 +17,6 @@
<selector xmlns:android="http://schemas.android.com/apk/res/android"
android:exitFadeDuration="@android:integer/config_mediumAnimTime">
<item android:state_pressed="true" android:drawable="@drawable/notification_item_background_color_pressed" />
<item android:state_pressed="true" android:drawable="@*android:drawable/notification_item_background_color_pressed" />
<item android:state_pressed="false" android:drawable="@drawable/notification_item_background_legacy_color" />
</selector>

View File

@@ -19,7 +19,7 @@
android:opacity="translucent"
>
<item
android:drawable="@drawable/notification_item_background_color"
android:drawable="@*android:drawable/notification_item_background_color"
/>
</layer-list>

View File

@@ -20,7 +20,7 @@
>
<!-- the large icon extends 12dp beyond the edge of the status bar -->
<item
android:drawable="@drawable/notification_item_background_color"
android:drawable="@*android:drawable/notification_item_background_color"
android:top="12dp"
/>
</layer-list>

View File

@@ -1,6 +1,7 @@
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@*android:drawable/notification_bg"
>
<Button
@@ -20,11 +21,10 @@
android:layout_marginBottom="@dimen/notification_divider_height"
android:focusable="true"
android:clickable="true"
android:background="@drawable/notification_row_bg"
>
<com.android.internal.widget.SizeAdaptiveLayout android:id="@+id/adaptive"
android:background="@android:color/background_dark"
android:background="@*android:drawable/notification_bg"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
@@ -34,7 +34,7 @@
android:layout_width="match_parent"
android:layout_height="@dimen/notification_divider_height"
android:gravity="bottom"
android:background="@drawable/status_bar_notification_row_background_color"
android:background="@*android:drawable/notification_bg"
/>
</FrameLayout>

View File

@@ -18,8 +18,6 @@
-->
<resources>
<drawable name="notification_number_text_color">#ffffffff</drawable>
<drawable name="notification_item_background_color">#ff111111</drawable>
<drawable name="notification_item_background_color_pressed">#ff257390</drawable>
<drawable name="ticker_background_color">#ff1d1d1d</drawable>
<drawable name="status_bar_background">#ff000000</drawable>
<drawable name="status_bar_recents_app_thumbnail_background">#88000000</drawable>

View File

@@ -213,7 +213,7 @@ public abstract class BaseStatusBar extends SystemUI implements
if (version > 0 && version < Build.VERSION_CODES.GINGERBREAD) {
content.setBackgroundResource(R.drawable.notification_row_legacy_bg);
} else {
content.setBackgroundResource(R.drawable.notification_row_bg);
content.setBackgroundResource(com.android.internal.R.drawable.notification_bg);
}
}
}