Renaming an activity class. Removing dead code.

Change-Id: I509fa747441d8d3d5168aa07a4ada4434f02d190
diff --git a/src/com/android/contacts/ContactsUtils.java b/src/com/android/contacts/ContactsUtils.java
index 7c54f62..181fb37 100644
--- a/src/com/android/contacts/ContactsUtils.java
+++ b/src/com/android/contacts/ContactsUtils.java
@@ -16,180 +16,24 @@
 
 package com.android.contacts;
 
-import com.android.contacts.model.AccountType;
 import com.android.contacts.util.Constants;
 
-import android.content.ContentResolver;
-import android.content.ContentUris;
 import android.content.ContentValues;
 import android.content.Context;
 import android.content.Intent;
-import android.database.Cursor;
-import android.graphics.Bitmap;
-import android.graphics.BitmapFactory;
-import android.graphics.drawable.Drawable;
 import android.location.CountryDetector;
 import android.net.Uri;
-import android.provider.ContactsContract.Contacts;
-import android.provider.ContactsContract.Data;
-import android.provider.ContactsContract.RawContacts;
 import android.provider.ContactsContract.CommonDataKinds.Email;
 import android.provider.ContactsContract.CommonDataKinds.Im;
-import android.provider.ContactsContract.CommonDataKinds.Organization;
 import android.provider.ContactsContract.CommonDataKinds.Phone;
-import android.provider.ContactsContract.CommonDataKinds.Photo;
-import android.provider.ContactsContract.CommonDataKinds.StructuredPostal;
+import android.provider.ContactsContract.Data;
 import android.telephony.PhoneNumberUtils;
 import android.text.TextUtils;
-import android.view.LayoutInflater;
-import android.view.View;
-import android.view.ViewGroup;
-import android.widget.ImageView;
-import android.widget.TextView;
-
-import java.util.ArrayList;
 
 public class ContactsUtils {
     private static final String TAG = "ContactsUtils";
     private static final String WAIT_SYMBOL_AS_STRING = String.valueOf(PhoneNumberUtils.WAIT);
-    /**
-     * Build the display title for the {@link Data#CONTENT_URI} entry in the
-     * provided cursor, assuming the given mimeType.
-     */
-    public static final CharSequence getDisplayLabel(Context context,
-            String mimeType, Cursor cursor) {
-        // Try finding the type and label for this mimetype
-        int colType;
-        int colLabel;
 
-        if (Phone.CONTENT_ITEM_TYPE.equals(mimeType)
-                || Constants.MIME_SMS_ADDRESS.equals(mimeType)) {
-            // Reset to phone mimetype so we generate a label for SMS case
-            mimeType = Phone.CONTENT_ITEM_TYPE;
-            colType = cursor.getColumnIndex(Phone.TYPE);
-            colLabel = cursor.getColumnIndex(Phone.LABEL);
-        } else if (Email.CONTENT_ITEM_TYPE.equals(mimeType)) {
-            colType = cursor.getColumnIndex(Email.TYPE);
-            colLabel = cursor.getColumnIndex(Email.LABEL);
-        } else if (StructuredPostal.CONTENT_ITEM_TYPE.equals(mimeType)) {
-            colType = cursor.getColumnIndex(StructuredPostal.TYPE);
-            colLabel = cursor.getColumnIndex(StructuredPostal.LABEL);
-        } else if (Organization.CONTENT_ITEM_TYPE.equals(mimeType)) {
-            colType = cursor.getColumnIndex(Organization.TYPE);
-            colLabel = cursor.getColumnIndex(Organization.LABEL);
-        } else {
-            return null;
-        }
-
-        final int type = cursor.getInt(colType);
-        final CharSequence label = cursor.getString(colLabel);
-
-        return getDisplayLabel(context, mimeType, type, label);
-    }
-
-    public static final CharSequence getDisplayLabel(Context context, String mimetype, int type,
-            CharSequence label) {
-        CharSequence display = "";
-        final int customType;
-        final int defaultType;
-        final int arrayResId;
-
-        if (Phone.CONTENT_ITEM_TYPE.equals(mimetype)) {
-            defaultType = Phone.TYPE_HOME;
-            customType = Phone.TYPE_CUSTOM;
-            arrayResId = com.android.internal.R.array.phoneTypes;
-        } else if (Email.CONTENT_ITEM_TYPE.equals(mimetype)) {
-            defaultType = Email.TYPE_HOME;
-            customType = Email.TYPE_CUSTOM;
-            arrayResId = com.android.internal.R.array.emailAddressTypes;
-        } else if (StructuredPostal.CONTENT_ITEM_TYPE.equals(mimetype)) {
-            defaultType = StructuredPostal.TYPE_HOME;
-            customType = StructuredPostal.TYPE_CUSTOM;
-            arrayResId = com.android.internal.R.array.postalAddressTypes;
-        } else if (Organization.CONTENT_ITEM_TYPE.equals(mimetype)) {
-            defaultType = Organization.TYPE_WORK;
-            customType = Organization.TYPE_CUSTOM;
-            arrayResId = com.android.internal.R.array.organizationTypes;
-        } else {
-            // Can't return display label for given mimetype.
-            return display;
-        }
-
-        if (type != customType) {
-            CharSequence[] labels = context.getResources().getTextArray(arrayResId);
-            try {
-                display = labels[type - 1];
-            } catch (ArrayIndexOutOfBoundsException e) {
-                display = labels[defaultType - 1];
-            }
-        } else {
-            if (!TextUtils.isEmpty(label)) {
-                display = label;
-            }
-        }
-        return display;
-    }
-
-    /**
-     * Opens an InputStream for the person's photo and returns the photo as a Bitmap.
-     * If the person's photo isn't present returns null.
-     *
-     * @param aggCursor the Cursor pointing to the data record containing the photo.
-     * @param bitmapColumnIndex the column index where the photo Uri is stored.
-     * @param options the decoding options, can be set to null
-     * @return the photo Bitmap
-     */
-    public static Bitmap loadContactPhoto(Cursor cursor, int bitmapColumnIndex,
-            BitmapFactory.Options options) {
-        if (cursor == null) {
-            return null;
-        }
-
-        byte[] data = cursor.getBlob(bitmapColumnIndex);
-        return BitmapFactory.decodeByteArray(data, 0, data.length, options);
-    }
-
-    /**
-     * Loads a placeholder photo.
-     *
-     * @param placeholderImageResource the resource to use for the placeholder image
-     * @param context the Context
-     * @param options the decoding options, can be set to null
-     * @return the placeholder Bitmap.
-     */
-    public static Bitmap loadPlaceholderPhoto(int placeholderImageResource, Context context,
-            BitmapFactory.Options options) {
-        if (placeholderImageResource == 0) {
-            return null;
-        }
-        return BitmapFactory.decodeResource(context.getResources(),
-                placeholderImageResource, options);
-    }
-
-    public static Bitmap loadContactPhoto(Context context, long photoId,
-            BitmapFactory.Options options) {
-        Cursor photoCursor = null;
-        Bitmap photoBm = null;
-
-        try {
-            photoCursor = context.getContentResolver().query(
-                    ContentUris.withAppendedId(Data.CONTENT_URI, photoId),
-                    new String[] { Photo.PHOTO },
-                    null, null, null);
-
-            if (photoCursor.moveToFirst() && !photoCursor.isNull(0)) {
-                byte[] photoData = photoCursor.getBlob(0);
-                photoBm = BitmapFactory.decodeByteArray(photoData, 0,
-                        photoData.length, options);
-            }
-        } finally {
-            if (photoCursor != null) {
-                photoCursor.close();
-            }
-        }
-
-        return photoBm;
-    }
 
     // TODO find a proper place for the canonical version of these
     public interface ProviderNames {
@@ -350,150 +194,6 @@
         return true;
     }
 
-    public static long queryForContactId(ContentResolver cr, long rawContactId) {
-        Cursor contactIdCursor = null;
-        long contactId = -1;
-        try {
-            contactIdCursor = cr.query(RawContacts.CONTENT_URI,
-                    new String[] {RawContacts.CONTACT_ID},
-                    RawContacts._ID + "=" + rawContactId, null, null);
-            if (contactIdCursor != null && contactIdCursor.moveToFirst()) {
-                contactId = contactIdCursor.getLong(0);
-            }
-        } finally {
-            if (contactIdCursor != null) {
-                contactIdCursor.close();
-            }
-        }
-        return contactId;
-    }
-
-    public static String querySuperPrimaryPhone(ContentResolver cr, long contactId) {
-        Cursor c = null;
-        String phone = null;
-        try {
-            Uri baseUri = ContentUris.withAppendedId(Contacts.CONTENT_URI, contactId);
-            Uri dataUri = Uri.withAppendedPath(baseUri, Contacts.Data.CONTENT_DIRECTORY);
-
-            c = cr.query(dataUri,
-                    new String[] {Phone.NUMBER},
-                    Data.MIMETYPE + "=" + Phone.MIMETYPE +
-                        " AND " + Data.IS_SUPER_PRIMARY + "=1",
-                    null, null);
-            if (c != null && c.moveToFirst()) {
-                // Just return the first one.
-                phone = c.getString(0);
-            }
-        } finally {
-            if (c != null) {
-                c.close();
-            }
-        }
-        return phone;
-    }
-
-    public static long queryForRawContactId(ContentResolver cr, long contactId) {
-        Cursor rawContactIdCursor = null;
-        long rawContactId = -1;
-        try {
-            rawContactIdCursor = cr.query(RawContacts.CONTENT_URI,
-                    new String[] {RawContacts._ID},
-                    RawContacts.CONTACT_ID + "=" + contactId, null, null);
-            if (rawContactIdCursor != null && rawContactIdCursor.moveToFirst()) {
-                // Just return the first one.
-                rawContactId = rawContactIdCursor.getLong(0);
-            }
-        } finally {
-            if (rawContactIdCursor != null) {
-                rawContactIdCursor.close();
-            }
-        }
-        return rawContactId;
-    }
-
-    public static ArrayList<Long> queryForAllRawContactIds(ContentResolver cr, long contactId) {
-        Cursor rawContactIdCursor = null;
-        ArrayList<Long> rawContactIds = new ArrayList<Long>();
-        try {
-            rawContactIdCursor = cr.query(RawContacts.CONTENT_URI,
-                    new String[] {RawContacts._ID},
-                    RawContacts.CONTACT_ID + "=" + contactId, null, null);
-            if (rawContactIdCursor != null) {
-                while (rawContactIdCursor.moveToNext()) {
-                    rawContactIds.add(rawContactIdCursor.getLong(0));
-                }
-            }
-        } finally {
-            if (rawContactIdCursor != null) {
-                rawContactIdCursor.close();
-            }
-        }
-        return rawContactIds;
-    }
-
-
-    /**
-     * Utility for creating a standard tab indicator view.
-     *
-     * @param parent The parent ViewGroup to attach the new view to.
-     * @param label The label to display in the tab indicator. If null, not label will be displayed.
-     * @param icon The icon to display. If null, no icon will be displayed.
-     * @return The tab indicator View.
-     */
-    public static View createTabIndicatorView(ViewGroup parent, CharSequence label, Drawable icon) {
-        final LayoutInflater inflater = (LayoutInflater)parent.getContext().getSystemService(
-                Context.LAYOUT_INFLATER_SERVICE);
-        final View tabIndicator = inflater.inflate(R.layout.tab_indicator, parent, false);
-        tabIndicator.getBackground().setDither(true);
-
-        final TextView tv = (TextView) tabIndicator.findViewById(R.id.tab_title);
-        tv.setText(label);
-
-        final ImageView iconView = (ImageView) tabIndicator.findViewById(R.id.tab_icon);
-        iconView.setImageDrawable(icon);
-
-        return tabIndicator;
-    }
-
-    /**
-     * Utility for creating a standard tab indicator view.
-     *
-     * @param parent The parent ViewGroup to attach the new view to.
-     * @param accountType The {@link AccountType} to build the tab view from.
-     * @return The tab indicator View.
-     */
-    public static View createTabIndicatorView(ViewGroup parent, AccountType accountType) {
-        Drawable icon = null;
-        if (accountType != null) {
-            icon = accountType.getDisplayIcon(parent.getContext());
-        }
-        return createTabIndicatorView(parent, null, icon);
-    }
-
-    /**
-     * Kick off an intent to initiate a call.
-     *
-     * @param phoneNumber must not be null.
-     * @throws NullPointerException when the given argument is null.
-     */
-    public static void initiateCall(Context context, CharSequence phoneNumber) {
-        Intent intent = new Intent(Intent.ACTION_CALL_PRIVILEGED,
-                Uri.fromParts("tel", phoneNumber.toString(), null));
-        context.startActivity(intent);
-    }
-
-    /**
-     * Kick off an intent to initiate an Sms/Mms message.
-     *
-     * @param phoneNumber must not be null.
-     * @throws NullPointerException when the given argument is null.
-     */
-    public static void initiateSms(Context context, CharSequence phoneNumber) {
-        Intent intent = new Intent(Intent.ACTION_SENDTO,
-                Uri.fromParts("sms", phoneNumber.toString(), null));
-        context.startActivity(intent);
-    }
-
     /**
      * Test if the given {@link CharSequence} contains any graphic characters,
      * first checking {@link TextUtils#isEmpty(CharSequence)} to handle null.
diff --git a/src/com/android/contacts/AttachImage.java b/src/com/android/contacts/activities/AttachPhotoActivity.java
similarity index 88%
rename from src/com/android/contacts/AttachImage.java
rename to src/com/android/contacts/activities/AttachPhotoActivity.java
index 5e0ead4..f5114fd 100644
--- a/src/com/android/contacts/AttachImage.java
+++ b/src/com/android/contacts/activities/AttachPhotoActivity.java
@@ -14,9 +14,11 @@
  * limitations under the License.
  */
 
-package com.android.contacts;
+package com.android.contacts.activities;
 
-import com.google.android.collect.Maps;
+import com.android.contacts.R;
+import com.android.contacts.model.ExchangeAccountType;
+import com.android.contacts.model.GoogleAccountType;
 
 import android.app.Activity;
 import android.content.ContentProviderOperation;
@@ -31,17 +33,13 @@
 import android.os.Bundle;
 import android.os.RemoteException;
 import android.provider.ContactsContract;
+import android.provider.ContactsContract.CommonDataKinds.Photo;
 import android.provider.ContactsContract.Contacts;
 import android.provider.ContactsContract.RawContacts;
-import android.provider.ContactsContract.CommonDataKinds.Photo;
 import android.widget.Toast;
 
-import com.android.contacts.model.ExchangeAccountType;
-import com.android.contacts.model.GoogleAccountType;
-
 import java.io.ByteArrayOutputStream;
 import java.util.ArrayList;
-import java.util.HashMap;
 
 /**
  * Provides an external interface for other applications to attach images
@@ -49,16 +47,12 @@
  * image that is handed to it through the cropper to make the image the proper
  * size and give the user a chance to use the face detector.
  */
-public class AttachImage extends Activity {
+public class AttachPhotoActivity extends Activity {
     private static final int REQUEST_PICK_CONTACT = 1;
     private static final int REQUEST_CROP_PHOTO = 2;
 
     private static final String RAW_CONTACT_URIS_KEY = "raw_contact_uris";
 
-    public AttachImage() {
-
-    }
-
     private Long[] mRawContactIds;
 
     private ContentResolver mContentResolver;
@@ -134,7 +128,7 @@
 
             // while they're cropping, convert the contact into a raw_contact
             final long contactId = ContentUris.parseId(result.getData());
-            final ArrayList<Long> rawContactIdsList = ContactsUtils.queryForAllRawContactIds(
+            final ArrayList<Long> rawContactIdsList = queryForAllRawContactIds(
                     mContentResolver, contactId);
             mRawContactIds = new Long[rawContactIdsList.size()];
             mRawContactIds = rawContactIdsList.toArray(mRawContactIds);
@@ -172,6 +166,27 @@
         }
     }
 
+    // TODO: move to background
+    public static ArrayList<Long> queryForAllRawContactIds(ContentResolver cr, long contactId) {
+        Cursor rawContactIdCursor = null;
+        ArrayList<Long> rawContactIds = new ArrayList<Long>();
+        try {
+            rawContactIdCursor = cr.query(RawContacts.CONTENT_URI,
+                    new String[] {RawContacts._ID},
+                    RawContacts.CONTACT_ID + "=" + contactId, null, null);
+            if (rawContactIdCursor != null) {
+                while (rawContactIdCursor.moveToNext()) {
+                    rawContactIds.add(rawContactIdCursor.getLong(0));
+                }
+            }
+        } finally {
+            if (rawContactIdCursor != null) {
+                rawContactIdCursor.close();
+            }
+        }
+        return rawContactIds;
+    }
+
     /**
      * Inserts a photo on the raw contact.
      * @param values the photo values
@@ -233,8 +248,9 @@
                 }).withExpectedCount(1).build());
 
         // update that photo
-        operations.add(ContentProviderOperation.newUpdate(rawContactDataUri).withSelection(Photo.MIMETYPE + "=?", new String[] {
-                    Photo.CONTENT_ITEM_TYPE}).withValues(values).build());
+        operations.add(ContentProviderOperation.newUpdate(rawContactDataUri)
+                .withSelection(Photo.MIMETYPE + "=?", new String[] {Photo.CONTENT_ITEM_TYPE})
+                .withValues(values).build());
 
         try {
             mContentResolver.applyBatch(ContactsContract.AUTHORITY, operations);