diff options
author | Chiao Cheng <chiaocheng@google.com> | 2012-12-07 11:36:00 -0800 |
---|---|---|
committer | Chiao Cheng <chiaocheng@google.com> | 2012-12-07 11:36:00 -0800 |
commit | 073b5cf341964796ccf082d30aff63225d3adb28 (patch) | |
tree | f41e73ef8151ebb239bbaf192f6697caf606edb2 | |
parent | 472309228c3aaef3c5010cde35965af892f4835a (diff) |
Add notification to "add contacts" when no activity found.
If a user disables the contacts application, the "add contact" option will
no longer work. Add a notification to inform them that they need to enable
the contact app to use the feature.
Bug: 7694569
Change-Id: I1aad7b1396f624461083cfab7ba470f9d4ac25ce
-rw-r--r-- | res/values/strings.xml | 3 | ||||
-rw-r--r-- | src/com/android/dialer/DialtactsActivity.java | 21 |
2 files changed, 21 insertions, 3 deletions
diff --git a/res/values/strings.xml b/res/values/strings.xml index 35c9d6ab1..9bf0ee842 100644 --- a/res/values/strings.xml +++ b/res/values/strings.xml @@ -508,4 +508,7 @@ <!-- Dialog title displayed when loading a phone number from the SIM card for speed dial --> <string name="simContacts_title">SIM card contacts</string> + <!-- Message displayed when there is no application available to handle the add contact menu option. [CHAR LIMIT=NONE] --> + <string name="add_contact_not_available">Re-enable the People application to use this feature.</string> + </resources> diff --git a/src/com/android/dialer/DialtactsActivity.java b/src/com/android/dialer/DialtactsActivity.java index c9419a3c4..2557ebc3e 100644 --- a/src/com/android/dialer/DialtactsActivity.java +++ b/src/com/android/dialer/DialtactsActivity.java @@ -24,6 +24,7 @@ import android.app.Activity; import android.app.Fragment; import android.app.FragmentManager; import android.app.FragmentTransaction; +import android.content.ActivityNotFoundException; import android.content.Context; import android.content.Intent; import android.content.SharedPreferences; @@ -55,6 +56,7 @@ import android.widget.PopupMenu; import android.widget.SearchView; import android.widget.SearchView.OnCloseListener; import android.widget.SearchView.OnQueryTextListener; +import android.widget.Toast; import com.android.contacts.common.CallUtil; import com.android.contacts.common.activity.TransactionSafeActivity; @@ -938,13 +940,10 @@ public class DialtactsActivity extends TransactionSafeActivity implements View.O final MenuItem callSettingsMenuItem = menu.findItem(R.id.menu_call_settings); 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); callSettingsMenuItem.setIntent(DialtactsActivity.getCallSettingsIntent()); searchMenuItem.setOnMenuItemClickListener(mSearchMenuItemClickListener); filterOptionMenuItem.setOnMenuItemClickListener(mFilterOptionsMenuItemClickListener); - addContactOptionMenuItem.setIntent( - new Intent(Intent.ACTION_INSERT, Contacts.CONTENT_URI)); return true; } @@ -973,6 +972,22 @@ public class DialtactsActivity extends TransactionSafeActivity implements View.O return true; } + @Override + public boolean onOptionsItemSelected(MenuItem item) { + switch (item.getItemId()) { + case R.id.add_contact: + try { + startActivity(new Intent(Intent.ACTION_INSERT, Contacts.CONTENT_URI)); + } catch (ActivityNotFoundException e) { + Toast toast = Toast.makeText(this, R.string.add_contact_not_available, + Toast.LENGTH_SHORT); + toast.show(); + } + return true; + } + return super.onOptionsItemSelected(item); + } + private void prepareOptionsMenuInSearchMode(Menu menu) { // get references to menu items final MenuItem searchMenuItem = menu.findItem(R.id.search_on_action_bar); |