Home | History | Annotate | Download | only in list
      1 /*
      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 package com.android.contacts.list;
     17 
     18 import com.android.contacts.R;
     19 
     20 import android.content.Context;
     21 import android.content.Intent;
     22 import android.util.AttributeSet;
     23 import android.view.View;
     24 import android.widget.ImageButton;
     25 
     26 /**
     27  * Displays the contact's picture overlayed with their name
     28  * in a perfect square. It also has an additional touch target for a secondary action.
     29  */
     30 public class ContactTilePhoneStarredView extends ContactTileView {
     31     private ImageButton mSecondaryButton;
     32 
     33     public ContactTilePhoneStarredView(Context context, AttributeSet attrs) {
     34         super(context, attrs);
     35     }
     36 
     37     @Override
     38     protected void onFinishInflate() {
     39         super.onFinishInflate();
     40 
     41         mSecondaryButton = (ImageButton) findViewById(R.id.contact_tile_secondary_button);
     42         mSecondaryButton.setOnClickListener(new OnClickListener() {
     43             @Override
     44             public void onClick(View v) {
     45                 Intent intent = new Intent(Intent.ACTION_VIEW, getLookupUri());
     46                 // Secondary target will be visible only from phone's favorite screen, then
     47                 // we want to launch it as a separate People task.
     48                 intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TOP);
     49                 getContext().startActivity(intent);
     50             }
     51         });
     52     }
     53 
     54     @Override
     55     protected boolean isDarkTheme() {
     56         return true;
     57     }
     58 
     59     @Override
     60     protected int getApproximateImageSize() {
     61         // The picture is the full size of the tile (minus some padding, but we can be generous)
     62         return mListener.getApproximateTileWidth();
     63     }
     64 }
     65