Loading res/menu/edit_contact.xml +4 −3 Original line number Original line Diff line number Diff line Loading @@ -16,9 +16,10 @@ <menu xmlns:android="http://schemas.android.com/apk/res/android"> <menu xmlns:android="http://schemas.android.com/apk/res/android"> <item <item android:id="@+id/menu_done" android:id="@+id/menu_save" android:alphabeticShortcut="\n" android:showAsAction="always" android:showAsAction="always" /> android:icon="@drawable/ic_done_wht_24dp" android:title="@string/menu_save" /> <item <item android:id="@+id/menu_split" android:id="@+id/menu_split" Loading res/values/strings.xml +3 −0 Original line number Original line Diff line number Diff line Loading @@ -150,6 +150,9 @@ <!-- Menu item that joins an aggregate with another aggregate --> <!-- Menu item that joins an aggregate with another aggregate --> <string name="menu_joinAggregate">Merge</string> <string name="menu_joinAggregate">Merge</string> <!-- Menu item (in the action bar) to indicate that changes should be saved [CHAR LIMIT=20] --> <string name="menu_save">Save</string> <!-- Heading of the Join Contact screen --> <!-- Heading of the Join Contact screen --> <string name="titleJoinContactDataWith">Join contacts</string> <string name="titleJoinContactDataWith">Join contacts</string> Loading src/com/android/contacts/activities/CompactContactEditorActivity.java +1 −1 Original line number Original line Diff line number Diff line Loading @@ -60,7 +60,7 @@ public class CompactContactEditorActivity extends ContactEditorBaseActivity { @Override @Override public void onBackPressed() { public void onBackPressed() { if (mFragment != null) { if (mFragment != null) { mFragment.save(ContactEditor.SaveMode.CLOSE, /* backPressed =*/ true); mFragment.revert(); } } } } } } src/com/android/contacts/activities/ContactEditorBaseActivity.java +6 −0 Original line number Original line Diff line number Diff line Loading @@ -161,6 +161,12 @@ abstract public class ContactEditorBaseActivity extends ContactsActivity */ */ boolean save(int saveMode, boolean backPressed); boolean save(int saveMode, boolean backPressed); /** * If there are no unsaved changes, just close the editor, otherwise the user is prompted * before discarding unsaved changes. */ boolean revert(); /** /** * Invoked after the contact is saved. * Invoked after the contact is saved. */ */ Loading src/com/android/contacts/editor/CompactContactEditorFragment.java +10 −1 Original line number Original line Diff line number Diff line Loading @@ -36,6 +36,7 @@ import android.net.Uri; import android.os.Bundle; import android.os.Bundle; import android.util.Log; import android.util.Log; import android.view.LayoutInflater; import android.view.LayoutInflater; import android.view.MenuItem; import android.view.View; import android.view.View; import android.view.ViewGroup; import android.view.ViewGroup; import android.widget.LinearLayout; import android.widget.LinearLayout; Loading Loading @@ -190,6 +191,14 @@ public class CompactContactEditorFragment extends ContactEditorBaseFragment impl } } } } @Override public boolean onOptionsItemSelected(MenuItem item) { if (item.getItemId() == android.R.id.home) { return revert(); } return super.onOptionsItemSelected(item); } @Override @Override protected void bindEditors() { protected void bindEditors() { if (!isReadyToBindEditors()) { if (!isReadyToBindEditors()) { Loading Loading @@ -347,7 +356,7 @@ public class CompactContactEditorFragment extends ContactEditorBaseFragment impl if (isInsert) { if (isInsert) { // For inserts, prevent any changes from being saved when the base fragment is destroyed // For inserts, prevent any changes from being saved when the base fragment is destroyed mStatus = Status.CLOSING; mStatus = Status.CLOSING; } else if (hasPendingChanges()) { } else if (hasPendingRawContactChanges()) { // Save whatever is in the form // Save whatever is in the form save(SaveMode.CLOSE, /* backPressed =*/ false); save(SaveMode.CLOSE, /* backPressed =*/ false); } } Loading Loading
res/menu/edit_contact.xml +4 −3 Original line number Original line Diff line number Diff line Loading @@ -16,9 +16,10 @@ <menu xmlns:android="http://schemas.android.com/apk/res/android"> <menu xmlns:android="http://schemas.android.com/apk/res/android"> <item <item android:id="@+id/menu_done" android:id="@+id/menu_save" android:alphabeticShortcut="\n" android:showAsAction="always" android:showAsAction="always" /> android:icon="@drawable/ic_done_wht_24dp" android:title="@string/menu_save" /> <item <item android:id="@+id/menu_split" android:id="@+id/menu_split" Loading
res/values/strings.xml +3 −0 Original line number Original line Diff line number Diff line Loading @@ -150,6 +150,9 @@ <!-- Menu item that joins an aggregate with another aggregate --> <!-- Menu item that joins an aggregate with another aggregate --> <string name="menu_joinAggregate">Merge</string> <string name="menu_joinAggregate">Merge</string> <!-- Menu item (in the action bar) to indicate that changes should be saved [CHAR LIMIT=20] --> <string name="menu_save">Save</string> <!-- Heading of the Join Contact screen --> <!-- Heading of the Join Contact screen --> <string name="titleJoinContactDataWith">Join contacts</string> <string name="titleJoinContactDataWith">Join contacts</string> Loading
src/com/android/contacts/activities/CompactContactEditorActivity.java +1 −1 Original line number Original line Diff line number Diff line Loading @@ -60,7 +60,7 @@ public class CompactContactEditorActivity extends ContactEditorBaseActivity { @Override @Override public void onBackPressed() { public void onBackPressed() { if (mFragment != null) { if (mFragment != null) { mFragment.save(ContactEditor.SaveMode.CLOSE, /* backPressed =*/ true); mFragment.revert(); } } } } } }
src/com/android/contacts/activities/ContactEditorBaseActivity.java +6 −0 Original line number Original line Diff line number Diff line Loading @@ -161,6 +161,12 @@ abstract public class ContactEditorBaseActivity extends ContactsActivity */ */ boolean save(int saveMode, boolean backPressed); boolean save(int saveMode, boolean backPressed); /** * If there are no unsaved changes, just close the editor, otherwise the user is prompted * before discarding unsaved changes. */ boolean revert(); /** /** * Invoked after the contact is saved. * Invoked after the contact is saved. */ */ Loading
src/com/android/contacts/editor/CompactContactEditorFragment.java +10 −1 Original line number Original line Diff line number Diff line Loading @@ -36,6 +36,7 @@ import android.net.Uri; import android.os.Bundle; import android.os.Bundle; import android.util.Log; import android.util.Log; import android.view.LayoutInflater; import android.view.LayoutInflater; import android.view.MenuItem; import android.view.View; import android.view.View; import android.view.ViewGroup; import android.view.ViewGroup; import android.widget.LinearLayout; import android.widget.LinearLayout; Loading Loading @@ -190,6 +191,14 @@ public class CompactContactEditorFragment extends ContactEditorBaseFragment impl } } } } @Override public boolean onOptionsItemSelected(MenuItem item) { if (item.getItemId() == android.R.id.home) { return revert(); } return super.onOptionsItemSelected(item); } @Override @Override protected void bindEditors() { protected void bindEditors() { if (!isReadyToBindEditors()) { if (!isReadyToBindEditors()) { Loading Loading @@ -347,7 +356,7 @@ public class CompactContactEditorFragment extends ContactEditorBaseFragment impl if (isInsert) { if (isInsert) { // For inserts, prevent any changes from being saved when the base fragment is destroyed // For inserts, prevent any changes from being saved when the base fragment is destroyed mStatus = Status.CLOSING; mStatus = Status.CLOSING; } else if (hasPendingChanges()) { } else if (hasPendingRawContactChanges()) { // Save whatever is in the form // Save whatever is in the form save(SaveMode.CLOSE, /* backPressed =*/ false); save(SaveMode.CLOSE, /* backPressed =*/ false); } } Loading