Fix the pressed state for thumbnails in Recents
- pressed state is now in foreground - also, keep drawing pressed drawable on long press Change-Id: I1a2025b5a79a5bfd4aaacf5312d52404fc3361a1
This commit is contained in:
|
Before Width: | Height: | Size: 235 B After Width: | Height: | Size: 235 B |
Binary file not shown.
|
Before Width: | Height: | Size: 207 B |
|
Before Width: | Height: | Size: 252 B After Width: | Height: | Size: 252 B |
@@ -14,7 +14,6 @@
|
||||
limitations under the License.
|
||||
-->
|
||||
<selector xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<item android:drawable="@drawable/recents_thumbnail_bg_press" android:state_pressed="true" />
|
||||
<item android:drawable="@drawable/recents_thumbnail_bg" android:state_activated="true" />
|
||||
<item android:drawable="@drawable/recents_thumbnail_bg_dragging" android:state_activated="true" />
|
||||
<item android:drawable="@*android:color/transparent"/>
|
||||
</selector>
|
||||
@@ -18,7 +18,6 @@
|
||||
*/
|
||||
-->
|
||||
|
||||
<!-- android:background="@drawable/status_bar_closed_default_background" -->
|
||||
<FrameLayout
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:layout_height="match_parent"
|
||||
@@ -37,7 +36,7 @@
|
||||
android:layout_alignParentTop="true"
|
||||
android:layout_marginLeft="@dimen/status_bar_recents_thumbnail_left_margin"
|
||||
android:scaleType="center"
|
||||
android:background="@drawable/recents_thumbnail_overlay">
|
||||
android:background="@drawable/recents_thumbnail_bg">
|
||||
<ImageView android:id="@+id/app_thumbnail_image"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
|
||||
@@ -18,7 +18,6 @@
|
||||
*/
|
||||
-->
|
||||
|
||||
<!-- android:background="@drawable/status_bar_closed_default_background" -->
|
||||
<FrameLayout
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:layout_height="wrap_content"
|
||||
@@ -35,7 +34,7 @@
|
||||
android:layout_alignParentTop="true"
|
||||
android:layout_marginLeft="@dimen/status_bar_recents_thumbnail_left_margin"
|
||||
android:scaleType="center"
|
||||
android:background="@drawable/recents_thumbnail_overlay">
|
||||
android:background="@drawable/recents_thumbnail_bg">
|
||||
<ImageView android:id="@+id/app_thumbnail_image"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
|
||||
@@ -18,7 +18,6 @@
|
||||
*/
|
||||
-->
|
||||
|
||||
<!-- android:background="@drawable/status_bar_closed_default_background" -->
|
||||
<RelativeLayout android:id="@+id/recent_item"
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:layout_height="wrap_content"
|
||||
@@ -31,7 +30,7 @@
|
||||
android:layout_alignParentTop="true"
|
||||
android:layout_marginLeft="@dimen/status_bar_recents_thumbnail_left_margin"
|
||||
android:scaleType="center"
|
||||
android:background="@drawable/recents_thumbnail_overlay">
|
||||
android:background="@drawable/recents_thumbnail_bg">
|
||||
<ImageView android:id="@+id/app_thumbnail_image"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
|
||||
@@ -16,6 +16,10 @@
|
||||
*/
|
||||
-->
|
||||
<resources>
|
||||
<!-- padding of pressed drawable for recents thumbnails (should be the same on left, right,
|
||||
top, and bottom -->
|
||||
<dimen name="recents_thumbnail_bg_press_padding">3px</dimen>
|
||||
|
||||
<!-- thickness (height) of each notification row, including any separators or padding -->
|
||||
<!-- Note: this is 64dip + 1px divider = 97px. -->
|
||||
<dimen name="notification_height">97px</dimen>
|
||||
|
||||
22
packages/SystemUI/res/values-mdpi/dimens.xml
Normal file
22
packages/SystemUI/res/values-mdpi/dimens.xml
Normal 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.
|
||||
*/
|
||||
-->
|
||||
<resources>
|
||||
<!-- padding of pressed drawable for recents thumbnails (should be the same on left, right,
|
||||
top, and bottom -->
|
||||
<dimen name="recents_thumbnail_bg_press_padding">2px</dimen>
|
||||
</resources>
|
||||
@@ -26,7 +26,7 @@ public interface RecentsCallback {
|
||||
|
||||
void handleOnClick(View selectedView);
|
||||
void handleSwipe(View selectedView);
|
||||
void handleLongPress(View selectedView, View anchorView);
|
||||
void handleLongPress(View selectedView, View anchorView, View thumbnailView);
|
||||
void handleShowBackground(boolean show);
|
||||
void dismiss();
|
||||
|
||||
|
||||
@@ -26,7 +26,6 @@ import android.util.Log;
|
||||
import android.view.MotionEvent;
|
||||
import android.view.View;
|
||||
import android.view.ViewConfiguration;
|
||||
import android.view.View.OnClickListener;
|
||||
import android.widget.HorizontalScrollView;
|
||||
import android.widget.LinearLayout;
|
||||
|
||||
@@ -48,7 +47,8 @@ public class RecentsHorizontalScrollView extends HorizontalScrollView
|
||||
private OnLongClickListener mOnLongClick = new OnLongClickListener() {
|
||||
public boolean onLongClick(View v) {
|
||||
final View anchorView = v.findViewById(R.id.app_description);
|
||||
mCallback.handleLongPress(v, anchorView);
|
||||
final View thumbnailView = v.findViewById(R.id.app_thumbnail);
|
||||
mCallback.handleLongPress(v, anchorView, thumbnailView);
|
||||
return true;
|
||||
}
|
||||
};
|
||||
|
||||
@@ -30,15 +30,14 @@ import android.content.pm.ResolveInfo;
|
||||
import android.content.res.Configuration;
|
||||
import android.content.res.Resources;
|
||||
import android.graphics.Bitmap;
|
||||
import android.graphics.BitmapFactory;
|
||||
import android.graphics.Canvas;
|
||||
import android.graphics.Matrix;
|
||||
import android.graphics.Paint;
|
||||
import android.graphics.Rect;
|
||||
import android.graphics.RectF;
|
||||
import android.graphics.Shader.TileMode;
|
||||
import android.graphics.drawable.BitmapDrawable;
|
||||
import android.graphics.drawable.Drawable;
|
||||
import android.graphics.drawable.StateListDrawable;
|
||||
import android.net.Uri;
|
||||
import android.os.AsyncTask;
|
||||
import android.os.Handler;
|
||||
@@ -57,6 +56,7 @@ import android.view.ViewGroup;
|
||||
import android.view.animation.AnimationUtils;
|
||||
import android.widget.AdapterView;
|
||||
import android.widget.BaseAdapter;
|
||||
import android.widget.FrameLayout;
|
||||
import android.widget.HorizontalScrollView;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.PopupMenu;
|
||||
@@ -85,6 +85,7 @@ public class RecentsPanelView extends RelativeLayout
|
||||
private View mRecentsGlowView;
|
||||
private ViewGroup mRecentsContainer;
|
||||
private Bitmap mDefaultThumbnailBackground;
|
||||
private BitmapDrawable mPressedDrawable;
|
||||
|
||||
private boolean mShowing;
|
||||
private Choreographer mChoreo;
|
||||
@@ -182,6 +183,13 @@ public class RecentsPanelView extends RelativeLayout
|
||||
holder.iconView = (ImageView) convertView.findViewById(R.id.app_icon);
|
||||
holder.labelView = (TextView) convertView.findViewById(R.id.app_label);
|
||||
holder.descriptionView = (TextView) convertView.findViewById(R.id.app_description);
|
||||
|
||||
StateListDrawable thumbnailForegroundDrawable = new StateListDrawable();
|
||||
thumbnailForegroundDrawable.addState(new int[] { android.R.attr.state_pressed },
|
||||
mPressedDrawable);
|
||||
thumbnailForegroundDrawable.addState(new int[] { android.R.attr.state_selected },
|
||||
mPressedDrawable);
|
||||
((FrameLayout)holder.thumbnailView).setForeground(thumbnailForegroundDrawable);
|
||||
convertView.setTag(holder);
|
||||
} else {
|
||||
holder = (ViewHolder) convertView.getTag();
|
||||
@@ -339,9 +347,23 @@ public class RecentsPanelView extends RelativeLayout
|
||||
int width = (int) res.getDimension(R.dimen.status_bar_recents_thumbnail_width);
|
||||
int height = (int) res.getDimension(R.dimen.status_bar_recents_thumbnail_height);
|
||||
int color = res.getColor(R.drawable.status_bar_recents_app_thumbnail_background);
|
||||
|
||||
// Render the default thumbnail background
|
||||
mDefaultThumbnailBackground = Bitmap.createBitmap(width, height, Bitmap.Config.ARGB_8888);
|
||||
Canvas c = new Canvas(mDefaultThumbnailBackground);
|
||||
c.drawColor(color);
|
||||
|
||||
// Render the pressed state (setting the 9 patch drawable directly causes padding issues)
|
||||
int bgPadding = (int) res.getDimension(R.dimen.recents_thumbnail_bg_press_padding);
|
||||
Bitmap pressedOverlay = Bitmap.createBitmap(
|
||||
width + 2 * bgPadding, height + 2 * bgPadding, Bitmap.Config.ARGB_8888);
|
||||
c.setBitmap(pressedOverlay);
|
||||
|
||||
Drawable pressedDrawable9Patch = res.getDrawable(R.drawable.recents_thumbnail_bg_press);
|
||||
pressedDrawable9Patch.getCurrent().setBounds(
|
||||
0, 0, pressedOverlay.getWidth(), pressedOverlay.getHeight());
|
||||
pressedDrawable9Patch.draw(c);
|
||||
mPressedDrawable = new BitmapDrawable(res, pressedOverlay);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -715,7 +737,9 @@ public class RecentsPanelView extends RelativeLayout
|
||||
getContext().startActivity(intent);
|
||||
}
|
||||
|
||||
public void handleLongPress(final View selectedView, final View anchorView) {
|
||||
public void handleLongPress(
|
||||
final View selectedView, final View anchorView, final View thumbnailView) {
|
||||
thumbnailView.setSelected(true);
|
||||
PopupMenu popup = new PopupMenu(mContext, anchorView == null ? selectedView : anchorView);
|
||||
popup.getMenuInflater().inflate(R.menu.recent_popup_menu, popup.getMenu());
|
||||
popup.setOnMenuItemClickListener(new PopupMenu.OnMenuItemClickListener() {
|
||||
@@ -737,6 +761,11 @@ public class RecentsPanelView extends RelativeLayout
|
||||
return true;
|
||||
}
|
||||
});
|
||||
popup.setOnDismissListener(new PopupMenu.OnDismissListener() {
|
||||
public void onDismiss(PopupMenu menu) {
|
||||
thumbnailView.setSelected(false);
|
||||
}
|
||||
});
|
||||
popup.show();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -46,7 +46,8 @@ public class RecentsVerticalScrollView extends ScrollView implements SwipeHelper
|
||||
private OnLongClickListener mOnLongClick = new OnLongClickListener() {
|
||||
public boolean onLongClick(View v) {
|
||||
final View anchorView = v.findViewById(R.id.app_description);
|
||||
mCallback.handleLongPress(v, anchorView);
|
||||
final View thumbnailView = v.findViewById(R.id.app_thumbnail);
|
||||
mCallback.handleLongPress(v, anchorView, thumbnailView);
|
||||
return true;
|
||||
}
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user