Merge "Pressed states for the notification panel's title area."

This commit is contained in:
Daniel Sandler
2011-03-02 21:20:08 -08:00
committed by Android (Google) Code Review
10 changed files with 75 additions and 3 deletions

Binary file not shown.

Before

Width:  |  Height:  |  Size: 625 B

After

Width:  |  Height:  |  Size: 578 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 408 B

After

Width:  |  Height:  |  Size: 362 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 514 B

After

Width:  |  Height:  |  Size: 380 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 41 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 84 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 80 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.1 KiB

After

Width:  |  Height:  |  Size: 288 B

View File

@@ -0,0 +1,22 @@
<?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">
<item android:state_pressed="true"
android:drawable="@drawable/notify_panel_clock_bg_pressed" />
<item android:drawable="@drawable/notify_panel_clock_bg_normal" />
</selector>

View File

@@ -22,6 +22,7 @@
android:layout_height="0dp"
android:orientation="vertical"
android:background="@drawable/notify_panel_clock_bg"
android:clickable="true"
>
<LinearLayout
android:id="@+id/icons"
@@ -171,10 +172,12 @@
android:layout_marginLeft="32dp"
/>
<Button
<view
class="com.android.systemui.statusbar.tablet.NotificationPanel$ModeToggle"
android:id="@+id/mode_toggle"
android:background="@null"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:clickable="true"
/>
</RelativeLayout>

View File

@@ -28,7 +28,10 @@ import android.graphics.Rect;
import android.graphics.drawable.Drawable;
import android.util.AttributeSet;
import android.util.Slog;
import android.view.accessibility.AccessibilityEvent;
import android.view.LayoutInflater;
import android.view.MotionEvent;
import android.view.SoundEffectConstants;
import android.view.View;
import android.view.ViewGroup;
import android.view.animation.AccelerateInterpolator;
@@ -51,7 +54,7 @@ public class NotificationPanel extends RelativeLayout implements StatusBarPanel,
boolean mShowing;
int mNotificationCount = 0;
View mTitleArea;
View mModeToggle;
ModeToggle mModeToggle;
View mSettingsButton;
View mNotificationButton;
View mNotificationScroller;
@@ -65,6 +68,48 @@ public class NotificationPanel extends RelativeLayout implements StatusBarPanel,
Choreographer mChoreo = new Choreographer();
static class ModeToggle extends View {
NotificationPanel mPanel;
View mTitle;
public ModeToggle(Context context, AttributeSet attrs) {
super(context, attrs);
}
public void setPanel(NotificationPanel p) {
mPanel = p;
}
public void setTitleArea(View v) {
mTitle = v;
}
@Override
public boolean onTouchEvent(MotionEvent e) {
final int x = (int)e.getX();
final int y = (int)e.getY();
switch (e.getAction()) {
case MotionEvent.ACTION_DOWN:
mTitle.setPressed(true);
break;
case MotionEvent.ACTION_MOVE:
mTitle.setPressed(x >= 0
&& x < getWidth()
&& y >= 0
&& y < getHeight());
break;
case MotionEvent.ACTION_CANCEL:
mTitle.setPressed(false);
break;
case MotionEvent.ACTION_UP:
if (mTitle.isPressed()) {
sendAccessibilityEvent(AccessibilityEvent.TYPE_VIEW_CLICKED);
playSoundEffect(SoundEffectConstants.CLICK);
mPanel.swapPanels();
mTitle.setPressed(false);
}
break;
}
return true;
}
}
public NotificationPanel(Context context, AttributeSet attrs) {
this(context, attrs, 0);
}
@@ -82,8 +127,10 @@ public class NotificationPanel extends RelativeLayout implements StatusBarPanel,
mContentParent = (ViewGroup)findViewById(R.id.content_parent);
mContentParent.bringToFront();
mTitleArea = findViewById(R.id.title_area);
mModeToggle = findViewById(R.id.mode_toggle);
mModeToggle = (ModeToggle) findViewById(R.id.mode_toggle);
mModeToggle.setOnClickListener(this);
mModeToggle.setPanel(this);
mModeToggle.setTitleArea(mTitleArea);
mSettingsButton = (ImageView)findViewById(R.id.settings_button);
mNotificationButton = (ImageView)findViewById(R.id.notification_button);