1 /* 2 * Copyright (C) 2014 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 17 package com.example.android.support.wearable.notifications; 18 19 import android.content.Context; 20 import android.graphics.drawable.GradientDrawable; 21 import android.support.wearable.view.WearableListView; 22 import android.util.AttributeSet; 23 import android.widget.ImageView; 24 import android.widget.LinearLayout; 25 import android.widget.TextView; 26 27 public class WearableListItemLayout extends LinearLayout 28 implements WearableListView.OnCenterProximityListener { 29 30 private final float mFadedTextAlpha; 31 private final int mFadedCircleColor; 32 private final int mChosenCircleColor; 33 private ImageView mCircle; 34 private float mScale; 35 private TextView mName; 36 WearableListItemLayout(Context context)37 public WearableListItemLayout(Context context) { 38 this(context, null); 39 } 40 WearableListItemLayout(Context context, AttributeSet attrs)41 public WearableListItemLayout(Context context, AttributeSet attrs) { 42 this(context, attrs, 0); 43 } 44 WearableListItemLayout(Context context, AttributeSet attrs, int defStyle)45 public WearableListItemLayout(Context context, AttributeSet attrs, int defStyle) { 46 super(context, attrs, defStyle); 47 mFadedTextAlpha = getResources().getInteger(R.integer.action_text_faded_alpha) / 100f; 48 mFadedCircleColor = getResources().getColor(R.color.wl_gray); 49 mChosenCircleColor = getResources().getColor(R.color.wl_blue); 50 } 51 52 @Override onFinishInflate()53 protected void onFinishInflate() { 54 super.onFinishInflate(); 55 mCircle = (ImageView) findViewById(R.id.circle); 56 mName = (TextView) findViewById(R.id.name); 57 } 58 59 @Override onCenterPosition(boolean animate)60 public void onCenterPosition(boolean animate) { 61 mName.setAlpha(1f); 62 ((GradientDrawable) mCircle.getDrawable()).setColor(mChosenCircleColor); 63 } 64 65 @Override onNonCenterPosition(boolean animate)66 public void onNonCenterPosition(boolean animate) { 67 ((GradientDrawable) mCircle.getDrawable()).setColor(mFadedCircleColor); 68 mName.setAlpha(mFadedTextAlpha); 69 } 70 } 71