package com.github.vacxe.phonemask;

import android.util.Log;
import android.view.View;
import android.widget.EditText;

/**
 * Created by konstantinaksenov on 17.05.17.
 */

public class PhoneMaskManager {
    private String mask = null;
    private String region = "";
    private ValueListener valueListener = null;

    public PhoneMaskManager withMask(String mask)  {
        this.mask = mask;
        return this;
    }

    public PhoneMaskManager withRegion(String region)  {
        this.region = region;
        return this;
    }

    public PhoneMaskManager withValueListener(ValueListener valueListener)  {
        this.valueListener = valueListener;
        return this;
    }

    public void bindTo(final EditText editText) {
        if (mask == null) {
            Log.e("PhoneMaskManager", "Mask can't be null");
        } else {
            editText.setOnFocusChangeListener(new View.OnFocusChangeListener() {
                @Override
                public void onFocusChange(View v, boolean hasFocus) {
                    if (hasFocus) {
                        if (editText.getText().toString().isEmpty()) {
                            editText.setText(region);
                        }
                    }
                }
            });
            editText.addTextChangedListener(new PhoneMaskWatcher(mask, region, valueListener));
        }

    }
}
@@ -311,16 +311,85 @@
  = null;
+%0A    private View.OnFocusChangeListener onFocusChangeListener = null;
 %0A%0A    pu
@@ -746,32 +746,227 @@
 rn this;%0A    %7D%0A%0A
+    public PhoneMaskManager withOnFocusChangeListener(View.OnFocusChangeListener onFocusChangeListener)  %7B%0A        this.onFocusChangeListener = onFocusChangeListener;%0A        return this;%0A    %7D%0A%0A
     public void 
@@ -1443,16 +1443,16 @@
 egion);%0A
-
         
@@ -1482,32 +1482,184 @@
                %7D
+%0A%0A                    if(onFocusChangeListener != null)%7B%0A                        onFocusChangeListener.onFocusChange(v, hasFocus);%0A                    %7D
 %0A               

Add external onFocusChangeListener