Merge "Add Rounded corners to cards." into nyc-dev

am: be8f788

* commit 'be8f788f86acd0755ad5d30401f20b0390c18e1b':
  Add Rounded corners to cards.

Change-Id: Ifb55764a4327392c2cbe67b7e288170f508f2920
This commit is contained in:
Sid Soundararajan
2016-04-18 17:36:45 +00:00
committed by android-build-merger
4 changed files with 41 additions and 5 deletions

View File

@@ -0,0 +1,25 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- Copyright (C) 2016 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.
-->
<shape
xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle">
<solid
android:color="@color/recents_tv_card_background_color"/>
<corners
android:radius="@dimen/recents_tv_card_corner_radius" />
</shape>

View File

@@ -30,7 +30,7 @@
android:layout_height="@dimen/recents_tv_screenshot_height" android:layout_height="@dimen/recents_tv_screenshot_height"
android:gravity="center" android:gravity="center"
android:orientation="vertical" android:orientation="vertical"
android:background="@color/recents_tv_card_background_color" android:background="@drawable/recents_tv_card_thumbnail_background"
android:layout_centerHorizontal="true" > android:layout_centerHorizontal="true" >
<ImageView <ImageView

View File

@@ -29,6 +29,7 @@
<dimen name="recents_tv_icon_padding_bottom">8dip</dimen> <dimen name="recents_tv_icon_padding_bottom">8dip</dimen>
<dimen name="recents_tv_text_padding_start">12dip</dimen> <dimen name="recents_tv_text_padding_start">12dip</dimen>
<dimen name="recents_tv_text_padding_bottom">12dip</dimen> <dimen name="recents_tv_text_padding_bottom">12dip</dimen>
<dimen name="recents_tv_card_corner_radius">2dip</dimen>
<!-- Padding for grid view in recents view on tv --> <!-- Padding for grid view in recents view on tv -->
<dimen name="recents_tv_gird_row_top_margin">215dip</dimen> <dimen name="recents_tv_gird_row_top_margin">215dip</dimen>

View File

@@ -21,6 +21,7 @@ import android.content.pm.PackageManager;
import android.content.res.Configuration; import android.content.res.Configuration;
import android.content.res.Resources; import android.content.res.Resources;
import android.graphics.Bitmap; import android.graphics.Bitmap;
import android.graphics.Outline;
import android.graphics.Point; import android.graphics.Point;
import android.graphics.Rect; import android.graphics.Rect;
import android.graphics.drawable.Drawable; import android.graphics.drawable.Drawable;
@@ -30,6 +31,7 @@ import android.util.TypedValue;
import android.view.Display; import android.view.Display;
import android.view.KeyEvent; import android.view.KeyEvent;
import android.view.View; import android.view.View;
import android.view.ViewOutlineProvider;
import android.view.WindowManager; import android.view.WindowManager;
import android.widget.ImageView; import android.widget.ImageView;
import android.widget.LinearLayout; import android.widget.LinearLayout;
@@ -49,6 +51,7 @@ public class TaskCardView extends LinearLayout {
private ImageView mBadgeView; private ImageView mBadgeView;
private Task mTask; private Task mTask;
private boolean mDismissState; private boolean mDismissState;
private int mCornerRadius;
private ViewFocusAnimator mViewFocusAnimator; private ViewFocusAnimator mViewFocusAnimator;
private DismissAnimationsHolder mDismissAnimationsHolder; private DismissAnimationsHolder mDismissAnimationsHolder;
@@ -77,6 +80,8 @@ public class TaskCardView extends LinearLayout {
mBadgeView = (ImageView) findViewById(R.id.card_extra_badge); mBadgeView = (ImageView) findViewById(R.id.card_extra_badge);
mDismissAnimationsHolder = new DismissAnimationsHolder(this); mDismissAnimationsHolder = new DismissAnimationsHolder(this);
View title = findViewById(R.id.card_info_field); View title = findViewById(R.id.card_info_field);
mCornerRadius = getResources().getDimensionPixelSize(
R.dimen.recents_task_view_rounded_corners_radius);
mRecentsRowFocusAnimationHolder = new RecentsRowFocusAnimationHolder(this, title); mRecentsRowFocusAnimationHolder = new RecentsRowFocusAnimationHolder(this, title);
mViewFocusAnimator = new ViewFocusAnimator(this); mViewFocusAnimator = new ViewFocusAnimator(this);
} }
@@ -272,13 +277,18 @@ public class TaskCardView extends LinearLayout {
private void setAsScreenShotView(Bitmap screenshot, ImageView screenshotView) { private void setAsScreenShotView(Bitmap screenshot, ImageView screenshotView) {
LayoutParams lp = (LayoutParams) screenshotView.getLayoutParams(); LayoutParams lp = (LayoutParams) screenshotView.getLayoutParams();
lp.width = getResources() lp.width = LayoutParams.MATCH_PARENT;
.getDimensionPixelSize(R.dimen.recents_tv_card_width); lp.height = LayoutParams.MATCH_PARENT;
lp.height = getResources()
.getDimensionPixelSize(R.dimen.recents_tv_screenshot_height);
screenshotView.setLayoutParams(lp); screenshotView.setLayoutParams(lp);
screenshotView.setImageBitmap(screenshot); screenshotView.setImageBitmap(screenshot);
screenshotView.setClipToOutline(true);
screenshotView.setOutlineProvider(new ViewOutlineProvider() {
@Override
public void getOutline(View view, Outline outline) {
outline.setRoundRect(0, 0, view.getWidth(), view.getHeight(), mCornerRadius);
}
});
} }
private void setAsBannerView(Drawable banner, ImageView bannerView) { private void setAsBannerView(Drawable banner, ImageView bannerView) {