Home | History | Annotate | Download | only in ui
      1 /*
      2  * Copyright (C) 2015 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.messaging.ui;
     17 
     18 import android.content.Context;
     19 import android.support.v4.text.BidiFormatter;
     20 import android.support.v4.text.TextDirectionHeuristicsCompat;
     21 import android.util.AttributeSet;
     22 import android.view.View;
     23 import android.widget.LinearLayout;
     24 import android.widget.TextView;
     25 
     26 import com.android.messaging.R;
     27 import com.android.messaging.datamodel.data.ParticipantListItemData;
     28 
     29 /**
     30  * View for individual participant in blocked participants list.
     31  *
     32  * Unblocks participant when clicked.
     33  */
     34 public class BlockedParticipantListItemView extends LinearLayout {
     35     private TextView mNameTextView;
     36     private ContactIconView mContactIconView;
     37     private ParticipantListItemData mData;
     38 
     39     public BlockedParticipantListItemView(final Context context, final AttributeSet attrs) {
     40         super(context, attrs);
     41     }
     42 
     43     @Override
     44     protected void onFinishInflate() {
     45         mNameTextView = (TextView) findViewById(R.id.name);
     46         mContactIconView = (ContactIconView) findViewById(R.id.contact_icon);
     47         setOnClickListener(new OnClickListener() {
     48             @Override
     49             public void onClick(final View v) {
     50                 mData.unblock(getContext());
     51             }
     52         });
     53     }
     54 
     55     public void bind(final ParticipantListItemData data) {
     56         mData = data;
     57         final BidiFormatter bidiFormatter = BidiFormatter.getInstance();
     58         mNameTextView.setText(bidiFormatter.unicodeWrap(
     59                 data.getDisplayName(), TextDirectionHeuristicsCompat.LTR));
     60         mContactIconView.setImageResourceUri(data.getAvatarUri(), data.getContactId(),
     61                     data.getLookupKey(), data.getNormalizedDestination());
     62         mNameTextView.setText(data.getDisplayName());
     63     }
     64 }
     65