package com.firebase.ui.auth.ui;

import android.support.annotation.RestrictTo;
import android.view.KeyEvent;
import android.view.inputmethod.EditorInfo;
import android.widget.EditText;
import android.widget.TextView;

@RestrictTo(RestrictTo.Scope.LIBRARY_GROUP)
public class ImeHelper {
    public interface DonePressedListener {
        void onDonePressed();
    }

    public static void setImeOnDoneListener(EditText doneEditText,
                                            final DonePressedListener listener) {
        doneEditText.setOnEditorActionListener(new TextView.OnEditorActionListener() {
            @Override
            public boolean onEditorAction(TextView view, int actionId, KeyEvent event) {
                if (event != null
                        && event.getKeyCode() == KeyEvent.KEYCODE_ENTER
                        || actionId == EditorInfo.IME_ACTION_DONE) {
                    listener.onDonePressed();
                    return true;
                }
                return false;
            }
        });
    }
}

@@ -741,21 +741,68 @@
  != null
-%0A    
+ && event.getKeyCode() == KeyEvent.KEYCODE_ENTER) %7B%0A
         
@@ -813,19 +813,20 @@
         
-&& 
+if (
 event.ge
@@ -818,39 +818,38 @@
    if (event.get
-KeyCode
+Action
 () == KeyEvent.K
@@ -847,29 +847,78 @@
 eyEvent.
-KEYCODE_ENTER
+ACTION_UP) %7B%0A                        listener.onDonePressed();
 %0A       
@@ -933,16 +933,216 @@
     
+ %7D%0A%0A
      
-%7C%7C 
+               // We need to return true even if we didn't handle the event to continue%0A                    // receiving future callbacks.%0A                    return true;%0A                %7D else if (
 acti

Fix duplicated callback events in DonePressedListener (#885)