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

Commit 8f9d84ff authored by Brian Attwell's avatar Brian Attwell
Browse files

Remove field when removing the only char

This allows us to make a simplifying assumption for b/18004959.
After this, we can assume that updateEmptyEditors is never called
with emptyEditors.size() > 1 and findFocus() == null.

Bug: 18004959
Bug: 18194655
Change-Id: Idaf2c64bf3d359c1aa8938150a6cda3684542d42
parent 5d2e262a
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -113,6 +113,7 @@ public class EventFieldEditorView extends LabeledEditorView {
        mDateView.setEnabled(isEnabled() && !readOnly);

        rebuildDateView();
        updateEmptiness();
    }

    private void rebuildDateView() {
+11 −2
Original line number Diff line number Diff line
@@ -301,6 +301,14 @@ public abstract class LabeledEditorView extends LinearLayout implements Editor,
        mEntry.put(column, value);
    }

    /**
     * Sub classes should call this at the end of {@link #setValues} once they finish changing
     * isEmpty(). This is needed to fix b/18194655.
     */
    protected final void updateEmptiness() {
        mWasEmpty = isEmpty();
    }

    protected void notifyEditorListener() {
        if (mListener != null) {
            mListener.onRequest(EditorListener.FIELD_CHANGED);
@@ -337,8 +345,9 @@ public abstract class LabeledEditorView extends LinearLayout implements Editor,
    }

    /**
     * Prepare this editor using the given {@link DataKind} for defining
     * structure and {@link ValuesDelta} describing the content to edit.
     * Prepare this editor using the given {@link DataKind} for defining structure and
     * {@link ValuesDelta} describing the content to edit. When overriding this, be careful
     * to call {@link #updateEmptiness} at the end.
     */
    @Override
    public void setValues(DataKind kind, ValuesDelta entry, RawContactDelta state, boolean readOnly,
+1 −0
Original line number Diff line number Diff line
@@ -108,6 +108,7 @@ public class PhoneticNameEditorView extends TextFieldsEditorView {
            entry = new PhoneticValuesDelta(entry);
        }
        super.setValues(kind, entry, state, readOnly, vig);
        updateEmptiness();
    }

    @Override
+1 −0
Original line number Diff line number Diff line
@@ -73,6 +73,7 @@ public class StructuredNameEditorView extends TextFieldsEditorView {
        } else {
            mChanged = false;
        }
        updateEmptiness();
    }

    @Override
+2 −0
Original line number Diff line number Diff line
@@ -281,6 +281,8 @@ public class TextFieldsEditorView extends LabeledEditorView {
        // When hiding fields, place expandable
        setupExpansionView(hidePossible, mHideOptional);
        mExpansionView.setEnabled(!readOnly && isEnabled());

        updateEmptiness();
    }

    @Override