Group editor: Just close activity when there's no accounts
Rather than crashing.
Bug 5035734
Change-Id: I433049de1a254213beb83501fdae74907f11a4cf
diff --git a/src/com/android/contacts/activities/GroupEditorActivity.java b/src/com/android/contacts/activities/GroupEditorActivity.java
index b397c19..544cd16 100644
--- a/src/com/android/contacts/activities/GroupEditorActivity.java
+++ b/src/com/android/contacts/activities/GroupEditorActivity.java
@@ -147,6 +147,11 @@
}
@Override
+ public void onAccountsNotFound() {
+ finish();
+ }
+
+ @Override
public void onSaveFinished(int resultCode, Intent resultIntent) {
// TODO: Collapse these 2 cases into 1 that will just launch an intent with the VIEW
// action to see the group URI (when group URIs are supported)
diff --git a/src/com/android/contacts/group/GroupEditorFragment.java b/src/com/android/contacts/group/GroupEditorFragment.java
index 4712871..2287557 100644
--- a/src/com/android/contacts/group/GroupEditorFragment.java
+++ b/src/com/android/contacts/group/GroupEditorFragment.java
@@ -107,6 +107,11 @@
* Contact was saved and the Fragment can now be closed safely.
*/
void onSaveFinished(int resultCode, Intent resultIntent);
+
+ /**
+ * Fragment is created but there's no accounts set up.
+ */
+ void onAccountsNotFound();
}
private static final int LOADER_GROUP_METADATA = 1;
@@ -308,7 +313,11 @@
AccountTypeManager.getInstance(mContext).getAccounts(true /* writeable */);
// No Accounts available
if (accounts.isEmpty()) {
- throw new IllegalStateException("No accounts were found.");
+ Log.e(TAG, "No accounts were found.");
+ if (mListener != null) {
+ mListener.onAccountsNotFound();
+ }
+ return;
}
// In the common case of a single account being writable, auto-select