add contact capability for Phone UI
Also make edit screen exit to previous screen so that Phone UI
and 3rd applications won't confuse users with INSERT Intent.
TESTED:
* phones with/without a hard menu key
- Phone UI should have just one "create contact" menu on the right
place in the search mode.
- Phone UI should not show the menu outside the search mode.
- People UI should correctly navigate users using add/edit capability
* tablet
- People UI should correctly navigate users using add/edit capability
Bug: 5185218
Change-Id: Id8360aeb6ef99ef0d3ab2902e97c0bbe8f590c17
diff --git a/res/menu/dialtacts_options.xml b/res/menu/dialtacts_options.xml
index cc9543a..2c83f6b 100644
--- a/res/menu/dialtacts_options.xml
+++ b/res/menu/dialtacts_options.xml
@@ -29,4 +29,9 @@
android:id="@+id/filter_option"
android:title="@string/menu_contacts_filter"
android:showAsAction="withText" />
+
+ <item
+ android:id="@+id/add_contact"
+ android:title="@string/menu_newContact"
+ android:showAsAction="withText" />
</menu>
diff --git a/res/menu/dialtacts_search_options.xml b/res/menu/dialtacts_search_options.xml
index f2e0c67..0979ebb 100644
--- a/res/menu/dialtacts_search_options.xml
+++ b/res/menu/dialtacts_search_options.xml
@@ -19,4 +19,8 @@
android:id="@+id/filter_option"
android:title="@string/menu_contacts_filter"
android:showAsAction="withText" />
+ <item
+ android:id="@+id/add_contact"
+ android:title="@string/menu_newContact"
+ android:showAsAction="withText" />
</menu>
diff --git a/src/com/android/contacts/activities/ContactEditorActivity.java b/src/com/android/contacts/activities/ContactEditorActivity.java
index 2936110..c69cc04 100644
--- a/src/com/android/contacts/activities/ContactEditorActivity.java
+++ b/src/com/android/contacts/activities/ContactEditorActivity.java
@@ -151,11 +151,6 @@
public void onSaveFinished(Intent resultIntent) {
if (resultIntent != null) {
startActivity(resultIntent);
- } else {
- // Navigate home
- Intent intent = new Intent(ContactEditorActivity.this, PeopleActivity.class);
- intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
- startActivity(intent);
}
finish();
}
diff --git a/src/com/android/contacts/activities/DialtactsActivity.java b/src/com/android/contacts/activities/DialtactsActivity.java
index b6dfbfa..918a001 100644
--- a/src/com/android/contacts/activities/DialtactsActivity.java
+++ b/src/com/android/contacts/activities/DialtactsActivity.java
@@ -46,6 +46,7 @@
import android.os.RemoteException;
import android.os.ServiceManager;
import android.provider.CallLog.Calls;
+import android.provider.ContactsContract.Contacts;
import android.provider.ContactsContract.Intents.UI;
import android.support.v13.app.FragmentPagerAdapter;
import android.support.v4.view.ViewPager;
@@ -253,6 +254,9 @@
popupMenu.inflate(R.menu.dialtacts_search_options);
final MenuItem filterOptionMenuItem = menu.findItem(R.id.filter_option);
filterOptionMenuItem.setOnMenuItemClickListener(mFilterOptionsMenuItemClickListener);
+ final MenuItem addContactOptionMenuItem = menu.findItem(R.id.add_contact);
+ addContactOptionMenuItem.setIntent(
+ new Intent(Intent.ACTION_INSERT, Contacts.CONTENT_URI));
popupMenu.show();
}
};
@@ -692,6 +696,7 @@
public boolean onPrepareOptionsMenu(Menu menu) {
final MenuItem searchMenuItem = menu.findItem(R.id.search_on_action_bar);
final MenuItem filterOptionMenuItem = menu.findItem(R.id.filter_option);
+ final MenuItem addContactOptionMenuItem = menu.findItem(R.id.add_contact);
final MenuItem callSettingsMenuItem = menu.findItem(R.id.menu_call_settings);
Tab tab = getActionBar().getSelectedTab();
if (mInSearchUi) {
@@ -700,9 +705,13 @@
filterOptionMenuItem.setVisible(true);
filterOptionMenuItem.setOnMenuItemClickListener(
mFilterOptionsMenuItemClickListener);
+ addContactOptionMenuItem.setVisible(true);
+ addContactOptionMenuItem.setIntent(
+ new Intent(Intent.ACTION_INSERT, Contacts.CONTENT_URI));
} else {
// Filter option menu should be not be shown as a overflow menu.
filterOptionMenuItem.setVisible(false);
+ addContactOptionMenuItem.setVisible(false);
}
callSettingsMenuItem.setVisible(false);
} else {
@@ -718,6 +727,7 @@
showCallSettingsMenu = true;
}
filterOptionMenuItem.setVisible(false);
+ addContactOptionMenuItem.setVisible(false);
if (showCallSettingsMenu) {
callSettingsMenuItem.setVisible(true);