(edit text typed) add onPast listener on the view
This commit is contained in:
parent
864bad819a
commit
1f62c34a13
1 changed files with 28 additions and 0 deletions
|
@ -26,8 +26,10 @@ import android.view.inputmethod.InputConnection;
|
||||||
import com.keylesspalace.tusky.util.Assert;
|
import com.keylesspalace.tusky.util.Assert;
|
||||||
|
|
||||||
public class EditTextTyped extends AppCompatEditText {
|
public class EditTextTyped extends AppCompatEditText {
|
||||||
|
|
||||||
InputConnectionCompat.OnCommitContentListener onCommitContentListener;
|
InputConnectionCompat.OnCommitContentListener onCommitContentListener;
|
||||||
String[] mimeTypes;
|
String[] mimeTypes;
|
||||||
|
private OnPasteListener mOnPasteListener;
|
||||||
|
|
||||||
public EditTextTyped(Context context) {
|
public EditTextTyped(Context context) {
|
||||||
super(context);
|
super(context);
|
||||||
|
@ -37,6 +39,10 @@ public class EditTextTyped extends AppCompatEditText {
|
||||||
super(context, attributeSet);
|
super(context, attributeSet);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void addOnPasteListener(OnPasteListener mOnPasteListener) {
|
||||||
|
this.mOnPasteListener = mOnPasteListener;
|
||||||
|
}
|
||||||
|
|
||||||
public void setMimeTypes(String[] types,
|
public void setMimeTypes(String[] types,
|
||||||
InputConnectionCompat.OnCommitContentListener listener) {
|
InputConnectionCompat.OnCommitContentListener listener) {
|
||||||
mimeTypes = types;
|
mimeTypes = types;
|
||||||
|
@ -55,4 +61,26 @@ public class EditTextTyped extends AppCompatEditText {
|
||||||
return connection;
|
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();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue