OSDN Git Service

Automated import from //branches/cupcake/...@142029,142029
authorAmith Yamasani <>
Wed, 25 Mar 2009 01:50:53 +0000 (18:50 -0700)
committerThe Android Open Source Project <initial-contribution@android.com>
Wed, 25 Mar 2009 01:50:53 +0000 (18:50 -0700)
res/layout-finger/call_detail.xml
src/com/android/contacts/CallDetailActivity.java

index 69bfa9e..ad151c1 100644 (file)
             android:scrollbarStyle="outsideOverlay"
         />
 
+        <ScrollView android:id="@android:id/empty"
+                android:layout_width="fill_parent"
+                android:layout_height="fill_parent"
+                android:fillViewport="true">
+
+            <TextView android:id="@+id/emptyText"
+                android:layout_width="fill_parent"
+                android:layout_height="wrap_content"
+                android:text="@string/unknown"
+                android:textSize="20sp"
+                android:textColor="?android:attr/textColorSecondary"
+                android:paddingLeft="10dip"
+                android:paddingRight="10dip"
+                android:paddingTop="10dip"
+                android:gravity="center"
+                android:lineSpacingMultiplier="0.92"/>
+
+        </ScrollView>
+
         <View
             android:layout_width="fill_parent"
             android:layout_height="wrap_content"
index 974fc05..d7d888c 100644 (file)
@@ -16,6 +16,8 @@
 
 package com.android.contacts;
 
+import com.android.internal.telephony.CallerInfo;
+
 import android.app.ListActivity;
 import android.content.ContentResolver;
 import android.content.ContentUris;
@@ -184,61 +186,71 @@ public class CallDetailActivity extends ListActivity implements
                         break;
                 }
     
-                // Perform a reverse-phonebook lookup to find the PERSON_ID
-                String callLabel = null;
-                Uri personUri = null;
-                Uri phoneUri = Uri.withAppendedPath(Phones.CONTENT_FILTER_URL, Uri.encode(mNumber));
-                Cursor phonesCursor = resolver.query(phoneUri, PHONES_PROJECTION, null, null, null);
-                try {
-                    if (phonesCursor != null && phonesCursor.moveToFirst()) {
-                        long personId = phonesCursor.getLong(COLUMN_INDEX_ID);
-                        personUri = ContentUris.withAppendedId(
-                                Contacts.People.CONTENT_URI, personId);
-                        callText = getString(R.string.recentCalls_callNumber,
-                                phonesCursor.getString(COLUMN_INDEX_NAME));
-                        mNumber = phonesCursor.getString(COLUMN_INDEX_NUMBER);
-                        callLabel = Phones.getDisplayLabel(this,
-                                phonesCursor.getInt(COLUMN_INDEX_TYPE),
-                                phonesCursor.getString(COLUMN_INDEX_LABEL)).toString();
-                    } else {
-                        mNumber = PhoneNumberUtils.formatNumber(mNumber);
+                if (mNumber.equals(CallerInfo.UNKNOWN_NUMBER) ||
+                        mNumber.equals(CallerInfo.PRIVATE_NUMBER)) {
+                    // List is empty, let the empty view show instead.
+                    TextView emptyText = (TextView) findViewById(R.id.emptyText);
+                    if (emptyText != null) {
+                        emptyText.setText(mNumber.equals(CallerInfo.PRIVATE_NUMBER) 
+                                ? R.string.private_num : R.string.unknown);
                     }
-                } finally {
-                    if (phonesCursor != null) phonesCursor.close();
-                }
-
-                // Build list of various available actions
-                List<ViewEntry> actions = new ArrayList<ViewEntry>();
-                
-                Intent callIntent = new Intent(Intent.ACTION_CALL_PRIVILEGED,
-                        Uri.fromParts("tel", mNumber, null));
-                ViewEntry entry = new ViewEntry(android.R.drawable.sym_action_call, callText,
-                        callIntent);
-                entry.number = mNumber;
-                entry.label = callLabel;
-                actions.add(entry);
-                
-                Intent smsIntent = new Intent(Intent.ACTION_SENDTO,
-                        Uri.fromParts("sms", mNumber, null));
-                actions.add(new ViewEntry(R.drawable.sym_action_sms,
-                        getString(R.string.menu_sendTextMessage), smsIntent));
-                
-                // Let user view contact details if they exist, otherwise add option
-                // to create new contact from this number.
-                if (personUri != null) {
-                    Intent viewIntent = new Intent(Intent.ACTION_VIEW, personUri);
-                    actions.add(new ViewEntry(R.drawable.sym_action_view_contact,
-                            getString(R.string.menu_viewContact), viewIntent));
                 } else {
-                    Intent createIntent = new Intent(Intent.ACTION_INSERT_OR_EDIT);
-                    createIntent.setType(People.CONTENT_ITEM_TYPE);
-                    createIntent.putExtra(Insert.PHONE, mNumber);
-                    actions.add(new ViewEntry(R.drawable.sym_action_add,
-                            getString(R.string.recentCalls_addToContact), createIntent));
+                    // Perform a reverse-phonebook lookup to find the PERSON_ID
+                    String callLabel = null;
+                    Uri personUri = null;
+                    Uri phoneUri = Uri.withAppendedPath(Phones.CONTENT_FILTER_URL, Uri.encode(mNumber));
+                    Cursor phonesCursor = resolver.query(phoneUri, PHONES_PROJECTION, null, null, null);
+                    try {
+                        if (phonesCursor != null && phonesCursor.moveToFirst()) {
+                            long personId = phonesCursor.getLong(COLUMN_INDEX_ID);
+                            personUri = ContentUris.withAppendedId(
+                                    Contacts.People.CONTENT_URI, personId);
+                            callText = getString(R.string.recentCalls_callNumber,
+                                    phonesCursor.getString(COLUMN_INDEX_NAME));
+                            mNumber = phonesCursor.getString(COLUMN_INDEX_NUMBER);
+                            callLabel = Phones.getDisplayLabel(this,
+                                    phonesCursor.getInt(COLUMN_INDEX_TYPE),
+                                    phonesCursor.getString(COLUMN_INDEX_LABEL)).toString();
+                        } else {
+                            mNumber = PhoneNumberUtils.formatNumber(mNumber);
+                        }
+                    } finally {
+                        if (phonesCursor != null) phonesCursor.close();
+                    }
+    
+                    // Build list of various available actions
+                    List<ViewEntry> actions = new ArrayList<ViewEntry>();
+                    
+                    Intent callIntent = new Intent(Intent.ACTION_CALL_PRIVILEGED,
+                            Uri.fromParts("tel", mNumber, null));
+                    ViewEntry entry = new ViewEntry(android.R.drawable.sym_action_call, callText,
+                            callIntent);
+                    entry.number = mNumber;
+                    entry.label = callLabel;
+                    actions.add(entry);
+                    
+                    Intent smsIntent = new Intent(Intent.ACTION_SENDTO,
+                            Uri.fromParts("sms", mNumber, null));
+                    actions.add(new ViewEntry(R.drawable.sym_action_sms,
+                            getString(R.string.menu_sendTextMessage), smsIntent));
+                    
+                    // Let user view contact details if they exist, otherwise add option
+                    // to create new contact from this number.
+                    if (personUri != null) {
+                        Intent viewIntent = new Intent(Intent.ACTION_VIEW, personUri);
+                        actions.add(new ViewEntry(R.drawable.sym_action_view_contact,
+                                getString(R.string.menu_viewContact), viewIntent));
+                    } else {
+                        Intent createIntent = new Intent(Intent.ACTION_INSERT_OR_EDIT);
+                        createIntent.setType(People.CONTENT_ITEM_TYPE);
+                        createIntent.putExtra(Insert.PHONE, mNumber);
+                        actions.add(new ViewEntry(R.drawable.sym_action_add,
+                                getString(R.string.recentCalls_addToContact), createIntent));
+                    }
+                    
+                    ViewAdapter adapter = new ViewAdapter(this, actions);
+                    setListAdapter(adapter);
                 }
-                
-                ViewAdapter adapter = new ViewAdapter(this, actions);
-                setListAdapter(adapter);
             } else {
                 // Something went wrong reading in our primary data, so we're going to
                 // bail out and show error to users.