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

Commit 2f61a1c9 authored by Yuli Huang's avatar Yuli Huang
Browse files

Simplify Yes/No/Cancel dialog to Yes/Cancel dialog.

Simplify the dialog options to confirm if the user wants to discard
unsaved edited photo, similar to MMS asking if the user wants to discard
the unsent message.

bug:6436477
Change-Id: Ic5af09a1ed46033a25b4ac42bf05b9739f6e8447
parent 37531196
Loading
Loading
Loading
Loading
+2 −5
Original line number Diff line number Diff line
@@ -27,15 +27,12 @@
    <!-- Toast shown when edited photo is successfully saved under %s folder [CHAR LIMIT=40] -->
    <string name="photo_saved">Edited photo saved to <xliff:g id="folder_name">%s</xliff:g></string>

    <!-- Dialog message prompted when the user is abandoning unsaved changes. [CHAR LIMIT=40] -->
    <string name="save_photo">Save edited photo?</string>
    <!-- Dialog message prompted to confirm the user is abandoning unsaved changes. [CHAR LIMIT=40] -->
    <string name="discard_unsaved_photo">Discard unsaved changes?</string>

    <!-- Dialog yes button for the user to accept text presented in a dialog. [CHAR LIMIT=12] -->
    <string name="yes">Yes</string>

    <!-- Dialog no button for the user to decline text presented in a dialog. [CHAR LIMIT=12] -->
    <string name="no">No</string>

    <!-- Text button in the action bar for the user to save edited photo. [CHAR LIMIT=8] -->
    <string name="save">SAVE</string>

+0 −4
Original line number Diff line number Diff line
@@ -92,10 +92,6 @@ public class ActionBar extends RestorableView {
        findViewById(R.id.action_bar_back).performClick();
    }

    public void clickSave() {
        findViewById(R.id.save_button).performClick();
    }

    public boolean canSave() {
        return findViewById(R.id.save_button).isEnabled();
    }
+3 −9
Original line number Diff line number Diff line
@@ -183,22 +183,16 @@ public class PhotoEditor extends Activity {
            public void run() {
                // Exit effects or go back to the previous activity on pressing back button.
                if (!effectsBar.exit(null)) {
                    // Pop-up a dialog to save unsaved photo.
                    // Pop-up a dialog if there are unsaved changes.
                    if (actionBar.canSave()) {
                        new YesNoCancelDialogBuilder(PhotoEditor.this, new Runnable() {

                            @Override
                            public void run() {
                                actionBar.clickSave();
                            }
                        }, new Runnable() {
                        new YesCancelDialogBuilder(PhotoEditor.this, new Runnable() {

                            @Override
                            public void run() {
                                // Discard unsaved photo for the result.
                                finish();
                            }
                        }, R.string.save_photo).show();
                        }, R.string.discard_unsaved_photo).show();
                    } else {
                        setResult(RESULT_OK, new Intent().setData(saveUri));
                        finish();
+3 −11
Original line number Diff line number Diff line
@@ -7,12 +7,11 @@ import android.content.DialogInterface;
import com.android.gallery3d.R;

/**
 * Alert dialog builder that builds a simple Yes/No/Cancel dialog.
 * Alert dialog builder that builds a simple Yes/Cancel dialog.
 */
public class YesNoCancelDialogBuilder extends AlertDialog.Builder {
public class YesCancelDialogBuilder extends AlertDialog.Builder {

    public YesNoCancelDialogBuilder(Context context, final Runnable yes, final Runnable no,
            int messageId) {
    public YesCancelDialogBuilder(Context context, final Runnable yes, int messageId) {
        super(context);
        setPositiveButton(R.string.yes, new DialogInterface.OnClickListener() {

@@ -21,13 +20,6 @@ public class YesNoCancelDialogBuilder extends AlertDialog.Builder {
                yes.run();
            }
        })
        .setNeutralButton(R.string.no, new DialogInterface.OnClickListener() {

            @Override
            public void onClick(DialogInterface dialog, int which) {
                no.run();
            }
        })
        .setNegativeButton(R.string.cancel, new DialogInterface.OnClickListener() {

            @Override