Skip to content

Commit cd3e6e2

Browse files
cwrenAndroid (Google) Code Review
authored andcommitted
Merge "fix press feedback on notification rows"
2 parents d6d6d35 + d84e593 commit cd3e6e2

File tree

16 files changed

+98
-14
lines changed

16 files changed

+98
-14
lines changed

core/java/com/android/internal/widget/SizeAdaptiveLayout.java

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,11 @@
2626
import android.content.res.TypedArray;
2727
import android.graphics.Color;
2828
import android.graphics.drawable.ColorDrawable;
29+
import android.graphics.drawable.Drawable;
30+
import android.graphics.drawable.StateListDrawable;
2931
import android.util.AttributeSet;
3032
import android.util.Log;
33+
import android.util.StateSet;
3134
import android.view.View;
3235
import android.view.ViewDebug;
3336
import android.view.ViewGroup;
@@ -90,8 +93,14 @@ public SizeAdaptiveLayout(Context context, AttributeSet attrs, int defStyle) {
9093
private void initialize() {
9194
mModestyPanel = new View(getContext());
9295
// If the SizeAdaptiveLayout has a solid background, use it as a transition hint.
93-
if (getBackground() instanceof ColorDrawable) {
94-
mModestyPanel.setBackgroundDrawable(getBackground());
96+
Drawable background = getBackground();
97+
if (background instanceof StateListDrawable) {
98+
StateListDrawable sld = (StateListDrawable) background;
99+
sld.setState(StateSet.WILD_CARD);
100+
background = sld.getCurrent();
101+
}
102+
if (background instanceof ColorDrawable) {
103+
mModestyPanel.setBackgroundDrawable(background);
95104
} else {
96105
mModestyPanel.setBackgroundColor(Color.BLACK);
97106
}
File renamed without changes.

core/res/res/layout/notification_template_base.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616

1717
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
1818
xmlns:internal="http://schemas.android.com/apk/prv/res/android"
19-
android:background="@android:color/background_dark"
19+
android:background="@android:drawable/notification_bg"
2020
android:id="@+id/status_bar_latest_event_content"
2121
android:layout_width="match_parent"
2222
android:layout_height="64dp"

core/res/res/layout/notification_template_big_picture.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616

1717
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
1818
xmlns:internal="http://schemas.android.com/apk/prv/res/android"
19-
android:background="@android:color/background_dark"
19+
android:background="@android:drawable/notification_bg"
2020
android:id="@+id/status_bar_latest_event_content"
2121
android:layout_width="match_parent"
2222
android:layout_height="match_parent"

core/res/res/layout/notification_template_big_text.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
-->
1616
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
1717
xmlns:internal="http://schemas.android.com/apk/prv/res/android"
18-
android:background="@android:color/background_dark"
18+
android:background="@android:drawable/notification_bg"
1919
android:id="@+id/status_bar_latest_event_content"
2020
android:layout_width="match_parent"
2121
android:layout_height="wrap_content"

core/res/res/values/colors.xml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,8 @@
2222
<drawable name="screen_background_dark">#ff000000</drawable>
2323
<drawable name="status_bar_closed_default_background">#ff000000</drawable>
2424
<drawable name="status_bar_opened_default_background">#ff000000</drawable>
25+
<drawable name="notification_item_background_color">#ff111111</drawable>
26+
<drawable name="notification_item_background_color_pressed">#ff257390</drawable>
2527
<drawable name="search_bar_default_color">#ff000000</drawable>
2628
<drawable name="safe_mode_background">#60000000</drawable>
2729
<!-- Background drawable that can be used for a transparent activity to

core/res/res/values/public.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1002,6 +1002,7 @@
10021002
<java-symbol type="drawable" name="ic_lockscreen_silent" />
10031003
<java-symbol type="drawable" name="ic_lockscreen_unlock" />
10041004
<java-symbol type="drawable" name="ic_lockscreen_search" />
1005+
<java-symbol type="drawable" name="notification_bg" />
10051006

10061007
<java-symbol type="layout" name="action_bar_home" />
10071008
<java-symbol type="layout" name="action_bar_title_item" />
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<!-- Copyright (C) 2011 The Android Open Source Project
3+
4+
Licensed under the Apache License, Version 2.0 (the "License");
5+
you may not use this file except in compliance with the License.
6+
You may obtain a copy of the License at
7+
8+
http://www.apache.org/licenses/LICENSE-2.0
9+
10+
Unless required by applicable law or agreed to in writing, software
11+
distributed under the License is distributed on an "AS IS" BASIS,
12+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
See the License for the specific language governing permissions and
14+
limitations under the License.
15+
-->
16+
<selector xmlns:android="http://schemas.android.com/apk/res/android"
17+
android:exitFadeDuration="@android:integer/config_mediumAnimTime">
18+
19+
<item android:state_pressed="true" android:drawable="@drawable/blue" />
20+
<item android:state_pressed="false" android:drawable="@drawable/red" />
21+
</selector>
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<!-- Copyright (C) 2012 The Android Open Source Project
3+
4+
Licensed under the Apache License, Version 2.0 (the "License");
5+
you may not use this file except in compliance with the License.
6+
You may obtain a copy of the License at
7+
8+
http://www.apache.org/licenses/LICENSE-2.0
9+
10+
Unless required by applicable law or agreed to in writing, software
11+
distributed under the License is distributed on an "AS IS" BASIS,
12+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
See the License for the specific language governing permissions and
14+
limitations under the License.
15+
-->
16+
<com.android.internal.widget.SizeAdaptiveLayout
17+
xmlns:android="http://schemas.android.com/apk/res/android"
18+
xmlns:internal="http://schemas.android.com/apk/prv/res/android"
19+
android:background="@drawable/size_adaptive_statelist"
20+
android:id="@+id/multi1"
21+
android:layout_width="match_parent"
22+
android:layout_height="64dp" >
23+
24+
<include
25+
android:id="@+id/one_u"
26+
layout="@layout/size_adaptive_one_u"
27+
android:layout_width="fill_parent"
28+
android:layout_height="64dp"
29+
internal:layout_minHeight="64dp"
30+
internal:layout_maxHeight="64dp"
31+
/>
32+
33+
<include
34+
android:id="@+id/four_u"
35+
layout="@layout/size_adaptive_four_u"
36+
android:layout_width="fill_parent"
37+
android:layout_height="wrap_content"
38+
internal:layout_minHeight="65dp"
39+
internal:layout_maxHeight="unbounded"/>
40+
41+
</com.android.internal.widget.SizeAdaptiveLayout>

core/tests/coretests/src/com/android/internal/widget/SizeAdaptiveLayoutTest.java

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
import com.android.frameworks.coretests.R;
2020

2121
import android.content.Context;
22+
import android.graphics.Color;
2223
import android.graphics.drawable.ColorDrawable;
2324
import android.test.AndroidTestCase;
2425
import android.test.suitebuilder.annotation.SmallTest;
@@ -427,6 +428,17 @@ public void testModestyPanelChangesColorWhite() {
427428
panelColor.getColor(), salColor.getColor());
428429
}
429430

431+
@SmallTest
432+
public void testModestyPanelTracksStateListColor() {
433+
inflate(R.layout.size_adaptive_color_statelist);
434+
View panel = mSizeAdaptiveLayout.getModestyPanel();
435+
assertEquals("ModestyPanel should have a ColorDrawable background" ,
436+
panel.getBackground().getClass(), ColorDrawable.class);
437+
ColorDrawable panelColor = (ColorDrawable) panel.getBackground();
438+
assertEquals("ModestyPanel color should match the SizeAdaptiveLayout",
439+
panelColor.getColor(), Color.RED);
440+
}
441+
430442
@SmallTest
431443
public void testModestyPanelHasDefault() {
432444
inflate(R.layout.size_adaptive);

0 commit comments

Comments
 (0)