// Path: src/com/abewy/android/apps/contacts/adapter/holder/ContactPhoneHolder.java
// public class ContactPhoneHolder
// {
// 	public final TextView		primaryText;
// 	public final TextView		secondaryText;
// 	public final ImageButton	messageButton;
// 
// 	public ContactPhoneHolder(TextView primaryText, TextView secondaryText, ImageButton messageButton)
// 	{
// 		this.primaryText = primaryText;
// 		this.secondaryText = secondaryText;
// 		this.messageButton = messageButton;
// 	}
// }
// 
// Path: src/com/abewy/android/apps/contacts/model/ContactPhone.java
// public class ContactPhone extends BaseContact
// {
// 	public final String phoneNumber;
// 	public final int type;
// 	public final String label;
// 	
// 	public ContactPhone(String phoneNumber, int type)
// 	{
// 		this(phoneNumber, type, "");
// 	}
// 	
// 	public ContactPhone(String phoneNumber, int type, String label)
// 	{
// 		this.phoneNumber = phoneNumber;
// 		this.type = type;
// 		this.label = label;
// 	}
// 
// 	@Override
// 	public int getItemViewType()
// 	{
// 		return ObjectType.CONTACT_PHONE;
// 	}
// 
// 	@Override
// 	public String getItemPrimaryLabel()
// 	{
// 		return phoneNumber;
// 	}
// }
// 
// Path: libs_external/Abewy_Extended/src/com/abewy/android/extended/items/BaseType.java
// public abstract class BaseType
// {
// 	public static final int	HEADER			= 1;
// 	public static final int	PROGRESS		= 2;
// 	public static final int	TEXT_BUTTON		= 3;
// 	public static final int	TEXT			= 4;
// 	public static final int	TITLE			= 5;
// 	public static final int	TITLE_TEXT		= 6;
// 	public static final int	TITLE_TWO_ITEM	= 7;
// 
// 	/**
// 	 * Return an unique data type to associate with a list view item
// 	 */
// 	public abstract int getItemViewType();
// 
// 	public abstract String getItemPrimaryLabel();
// }
// 
// Path: libs_external/Abewy_Extended/src/com/abewy/android/extended/util/PhoneUtil.java
// public class PhoneUtil
// {
// 
// 	public static void openDialActivity(Context context, String phoneNumber)
// 	{
// 		try
// 		{
// 			Intent intent = new Intent(Intent.ACTION_DIAL, Uri.parse("tel:" + phoneNumber));
// 			context.startActivity(intent);
// 		}
// 		catch (ActivityNotFoundException activityException)
// 		{
// 			Log.d("PhoneUtil", "openDialActivity: ", activityException);
// 		}
// 	}
// 
// 	public static void callNumber(Context context, String phoneNumber)
// 	{
// 		try
// 		{
// 			Intent intent = new Intent(Intent.ACTION_CALL);
// 			intent.setData(Uri.parse("tel:" + phoneNumber));
// 			context.startActivity(intent);
// 		}
// 		catch (ActivityNotFoundException activityException)
// 		{
// 			Log.d("PhoneUtil", "callNumber: ", activityException);
// 		}
// 	}
// 
// 	public static void sendSMS(Context context, String phoneNumber)
// 	{
// 		try
// 		{
// 			Uri uri = Uri.parse("sms:" + phoneNumber);
// 			Intent intent = new Intent(Intent.ACTION_VIEW, uri);
// 			context.startActivity(intent);
// 		}
// 		catch (ActivityNotFoundException activityException)
// 		{
// 			Log.d("PhoneUtil", "sendSMS: ", activityException);
// 		}
// 	}
// 
// 	public static void sendMail(Context context, String email)
// 	{
// 		Intent intent = new Intent(Intent.ACTION_SENDTO, Uri.fromParts("mailto", email, null));
// 
// 		try
// 		{
// 			context.startActivity(Intent.createChooser(intent, "Send mail..."));
// 		}
// 		catch (android.content.ActivityNotFoundException activityException)
// 		{
// 			Log.d("PhoneUtil", "sendMail: ", activityException);
// 		}
// 	}
// 
// 	public static void openURL(Context context, String url)
// 	{
// 		if (url.indexOf("http://") != 0)
// 		{
// 			if (url.indexOf("https://") != 0)
// 				url = "http://" + url;
// 		}
// 
// 		Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse(url));
// 		context.startActivity(intent);
// 	}
// }


import android.provider.ContactsContract.CommonDataKinds.Phone;
import android.telephony.PhoneNumberUtils;
import android.view.View;
import android.widget.ImageButton;
import android.widget.TextView;
import com.abewy.android.apps.contacts.R;
import com.abewy.android.apps.contacts.adapter.holder.ContactPhoneHolder;
import com.abewy.android.apps.contacts.model.ContactPhone;
import com.abewy.android.extended.items.BaseType;
import com.abewy.android.extended.util.PhoneUtil;
import com.google.i18n.phonenumbers.NumberParseException;
import com.google.i18n.phonenumbers.PhoneNumberUtil;
import com.google.i18n.phonenumbers.PhoneNumberUtil.PhoneNumberFormat;
import com.google.i18n.phonenumbers.Phonenumber.PhoneNumber;

		setHolder(view, new ContactPhoneHolder(primaryText, secondaryText, button));
	}

	@Override
	public void bindData(View view, BaseType data, int position)
	{
		final ContactPhoneHolder holder = (ContactPhoneHolder) getHolder(view);

		final ContactPhone phone = ((ContactPhone) data);

		PhoneNumberUtil phoneUtil = PhoneNumberUtil.getInstance();
		
		try
		{
			PhoneNumber numberProto = phoneUtil.parse(phone.phoneNumber, "");
			holder.primaryText.setText(phoneUtil.format(numberProto, PhoneNumberFormat.NATIONAL));
		}
		catch (NumberParseException e)
		{
			holder.primaryText.setText(phone.phoneNumber);
		}

		holder.secondaryText.setText(Phone.getTypeLabel(holder.secondaryText.getResources(), phone.type, phone.label));
		
		holder.messageButton.setOnClickListener(new View.OnClickListener() {
			
			@Override
			public void onClick(View v)
			{
// Path: src/com/abewy/android/apps/contacts/adapter/holder/ContactPhoneHolder.java
// public class ContactPhoneHolder
// {
// 	public final TextView		primaryText;
// 	public final TextView		secondaryText;
// 	public final ImageButton	messageButton;
// 
// 	public ContactPhoneHolder(TextView primaryText, TextView secondaryText, ImageButton messageButton)
// 	{
// 		this.primaryText = primaryText;
// 		this.secondaryText = secondaryText;
// 		this.messageButton = messageButton;
// 	}
// }
// 
// Path: src/com/abewy/android/apps/contacts/model/ContactPhone.java
// public class ContactPhone extends BaseContact
// {
// 	public final String phoneNumber;
// 	public final int type;
// 	public final String label;
// 	
// 	public ContactPhone(String phoneNumber, int type)
// 	{
// 		this(phoneNumber, type, "");
// 	}
// 	
// 	public ContactPhone(String phoneNumber, int type, String label)
// 	{
// 		this.phoneNumber = phoneNumber;
// 		this.type = type;
// 		this.label = label;
// 	}
// 
// 	@Override
// 	public int getItemViewType()
// 	{
// 		return ObjectType.CONTACT_PHONE;
// 	}
// 
// 	@Override
// 	public String getItemPrimaryLabel()
// 	{
// 		return phoneNumber;
// 	}
// }
// 
// Path: libs_external/Abewy_Extended/src/com/abewy/android/extended/items/BaseType.java
// public abstract class BaseType
// {
// 	public static final int	HEADER			= 1;
// 	public static final int	PROGRESS		= 2;
// 	public static final int	TEXT_BUTTON		= 3;
// 	public static final int	TEXT			= 4;
// 	public static final int	TITLE			= 5;
// 	public static final int	TITLE_TEXT		= 6;
// 	public static final int	TITLE_TWO_ITEM	= 7;
// 
// 	/**
// 	 * Return an unique data type to associate with a list view item
// 	 */
// 	public abstract int getItemViewType();
// 
// 	public abstract String getItemPrimaryLabel();
// }
// 
// Path: libs_external/Abewy_Extended/src/com/abewy/android/extended/util/PhoneUtil.java
// public class PhoneUtil
// {
// 
// 	public static void openDialActivity(Context context, String phoneNumber)
// 	{
// 		try
// 		{
// 			Intent intent = new Intent(Intent.ACTION_DIAL, Uri.parse("tel:" + phoneNumber));
// 			context.startActivity(intent);
// 		}
// 		catch (ActivityNotFoundException activityException)
// 		{
// 			Log.d("PhoneUtil", "openDialActivity: ", activityException);
// 		}
// 	}
// 
// 	public static void callNumber(Context context, String phoneNumber)
// 	{
// 		try
// 		{
// 			Intent intent = new Intent(Intent.ACTION_CALL);
// 			intent.setData(Uri.parse("tel:" + phoneNumber));
// 			context.startActivity(intent);
// 		}
// 		catch (ActivityNotFoundException activityException)
// 		{
// 			Log.d("PhoneUtil", "callNumber: ", activityException);
// 		}
// 	}
// 
// 	public static void sendSMS(Context context, String phoneNumber)
// 	{
// 		try
// 		{
// 			Uri uri = Uri.parse("sms:" + phoneNumber);
// 			Intent intent = new Intent(Intent.ACTION_VIEW, uri);
// 			context.startActivity(intent);
// 		}
// 		catch (ActivityNotFoundException activityException)
// 		{
// 			Log.d("PhoneUtil", "sendSMS: ", activityException);
// 		}
// 	}
// 
// 	public static void sendMail(Context context, String email)
// 	{
// 		Intent intent = new Intent(Intent.ACTION_SENDTO, Uri.fromParts("mailto", email, null));
// 
// 		try
// 		{
// 			context.startActivity(Intent.createChooser(intent, "Send mail..."));
// 		}
// 		catch (android.content.ActivityNotFoundException activityException)
// 		{
// 			Log.d("PhoneUtil", "sendMail: ", activityException);
// 		}
// 	}
// 
// 	public static void openURL(Context context, String url)
// 	{
// 		if (url.indexOf("http://") != 0)
// 		{
// 			if (url.indexOf("https://") != 0)
// 				url = "http://" + url;
// 		}
// 
// 		Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse(url));
// 		context.startActivity(intent);
// 	}
// }


// Path: src/com/abewy/android/apps/contacts/adapter/ContactPhoneAdapter.java
import android.provider.ContactsContract.CommonDataKinds.Phone;
import android.telephony.PhoneNumberUtils;
import android.view.View;
import android.widget.ImageButton;
import android.widget.TextView;
import com.abewy.android.apps.contacts.R;
import com.abewy.android.apps.contacts.adapter.holder.ContactPhoneHolder;
import com.abewy.android.apps.contacts.model.ContactPhone;
import com.abewy.android.extended.items.BaseType;
import com.abewy.android.extended.util.PhoneUtil;
import com.google.i18n.phonenumbers.NumberParseException;
import com.google.i18n.phonenumbers.PhoneNumberUtil;
import com.google.i18n.phonenumbers.PhoneNumberUtil.PhoneNumberFormat;
import com.google.i18n.phonenumbers.Phonenumber.PhoneNumber;


		setHolder(view, new ContactPhoneHolder(primaryText, secondaryText, button));
	}

	@Override
	public void bindData(View view, BaseType data, int position)
	{
		final ContactPhoneHolder holder = (ContactPhoneHolder) getHolder(view);

		final ContactPhone phone = ((ContactPhone) data);

		PhoneNumberUtil phoneUtil = PhoneNumberUtil.getInstance();
		
		try
		{
			PhoneNumber numberProto = phoneUtil.parse(phone.phoneNumber, "");
			holder.primaryText.setText(phoneUtil.format(numberProto, PhoneNumberFormat.NATIONAL));
		}
		catch (NumberParseException e)
		{
			holder.primaryText.setText(phone.phoneNumber);
		}

		holder.secondaryText.setText(Phone.getTypeLabel(holder.secondaryText.getResources(), phone.type, phone.label));
		
		holder.messageButton.setOnClickListener(new View.OnClickListener() {
			
			@Override
			public void onClick(View v)
			{
				PhoneUtil.sendSMS(v.getContext(), phone.phoneNumber);