|
|
|
@ -26,8 +26,10 @@ import android.view.inputmethod.InputConnection; |
|
|
|
|
import com.keylesspalace.tusky.util.Assert; |
|
|
|
|
|
|
|
|
|
public class EditTextTyped extends AppCompatEditText { |
|
|
|
|
|
|
|
|
|
InputConnectionCompat.OnCommitContentListener onCommitContentListener; |
|
|
|
|
String[] mimeTypes; |
|
|
|
|
private OnPasteListener mOnPasteListener; |
|
|
|
|
|
|
|
|
|
public EditTextTyped(Context context) { |
|
|
|
|
super(context); |
|
|
|
@ -37,6 +39,10 @@ public class EditTextTyped extends AppCompatEditText { |
|
|
|
|
super(context, attributeSet); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public void addOnPasteListener(OnPasteListener mOnPasteListener) { |
|
|
|
|
this.mOnPasteListener = mOnPasteListener; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public void setMimeTypes(String[] types, |
|
|
|
|
InputConnectionCompat.OnCommitContentListener listener) { |
|
|
|
|
mimeTypes = types; |
|
|
|
@ -55,4 +61,26 @@ public class EditTextTyped extends AppCompatEditText { |
|
|
|
|
return connection; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
public boolean onTextContextMenuItem(int id) { |
|
|
|
|
boolean consumed = super.onTextContextMenuItem(id); |
|
|
|
|
switch (id) { |
|
|
|
|
case android.R.id.paste: |
|
|
|
|
onPaste(); |
|
|
|
|
} |
|
|
|
|
return consumed; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* Text was pasted into the EditText. |
|
|
|
|
*/ |
|
|
|
|
public void onPaste() { |
|
|
|
|
if (mOnPasteListener != null) |
|
|
|
|
mOnPasteListener.onPaste(); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public interface OnPasteListener { |
|
|
|
|
void onPaste(); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|