Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit c90cc15b authored by Walter Jang's avatar Walter Jang
Browse files

Make saving a contact less confusing

* Add always visible save menu item (a checkmark icon) on both
  the compact and full editors.  Selecting it saves changes
  and closes the editor (what back does currently).
* On the compact editor, make back perform a discard,
  including warning the user if there are unsaved changes.
* On the full editor, back still saves and goes back to
  the full editor. This is not ideal but it's out of
  scope to not save changes between the two editors
  when editing an existing contact.

Bug 19983789

Change-Id: Ie23b75978db70f2b438a824e39f0ae8fb8aa99ec
parent fa127a1c
Loading
Loading
Loading
Loading
+4 −3
Original line number Diff line number Diff line
@@ -16,9 +16,10 @@

<menu xmlns:android="http://schemas.android.com/apk/res/android">
    <item
        android:id="@+id/menu_done"
        android:alphabeticShortcut="\n"
        android:showAsAction="always" />
        android:id="@+id/menu_save"
        android:showAsAction="always"
        android:icon="@drawable/ic_done_wht_24dp"
        android:title="@string/menu_save" />

    <item
        android:id="@+id/menu_split"
+3 −0
Original line number Diff line number Diff line
@@ -150,6 +150,9 @@
    <!-- Menu item that joins an aggregate with another aggregate -->
    <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 -->
    <string name="titleJoinContactDataWith">Join contacts</string>

+1 −1
Original line number Diff line number Diff line
@@ -60,7 +60,7 @@ public class CompactContactEditorActivity extends ContactEditorBaseActivity {
    @Override
    public void onBackPressed() {
        if (mFragment != null) {
            mFragment.save(ContactEditor.SaveMode.CLOSE, /* backPressed =*/ true);
            mFragment.revert();
        }
    }
}
+6 −0
Original line number Diff line number Diff line
@@ -161,6 +161,12 @@ abstract public class ContactEditorBaseActivity extends ContactsActivity
         */
        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.
         */
+10 −1
Original line number Diff line number Diff line
@@ -36,6 +36,7 @@ import android.net.Uri;
import android.os.Bundle;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.MenuItem;
import android.view.View;
import android.view.ViewGroup;
import android.widget.LinearLayout;
@@ -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
    protected void bindEditors() {
        if (!isReadyToBindEditors()) {
@@ -347,7 +356,7 @@ public class CompactContactEditorFragment extends ContactEditorBaseFragment impl
        if (isInsert) {
            // For inserts, prevent any changes from being saved when the base fragment is destroyed
            mStatus = Status.CLOSING;
        } else if (hasPendingChanges()) {
        } else if (hasPendingRawContactChanges()) {
            // Save whatever is in the form
            save(SaveMode.CLOSE, /* backPressed =*/ false);
        }
Loading