|
|
@@ -5,7 +5,9 @@ import android.content.Context;
|
|
|
import android.content.Intent;
|
|
|
import android.inputmethodservice.InputMethodService;
|
|
|
import android.os.Build;
|
|
|
+import android.os.Handler;
|
|
|
import android.view.LayoutInflater;
|
|
|
+import android.view.MotionEvent;
|
|
|
import android.view.View;
|
|
|
import android.view.inputmethod.EditorInfo;
|
|
|
import android.view.inputmethod.InputMethodManager;
|
|
|
@@ -85,7 +87,41 @@ public class InputService extends InputMethodService implements PasswordClickLis
|
|
|
fInputView.findViewById(R.id.prevButton).setOnClickListener(view -> {
|
|
|
SwitchToPreviousInputMethod();
|
|
|
});
|
|
|
- fInputView.findViewById(R.id.backspaceButton).setOnClickListener(view -> getCurrentInputConnection().deleteSurroundingText(1, 0));
|
|
|
+ fInputView.findViewById(R.id.backspaceButton).setOnTouchListener(new View.OnTouchListener() {
|
|
|
+ private final static int INIT_DELAY = 650;
|
|
|
+ private final static int DELAY = 250;
|
|
|
+ private Handler handler;
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public boolean onTouch(View v, MotionEvent event) {
|
|
|
+ switch (event.getAction()) {
|
|
|
+ case MotionEvent.ACTION_DOWN:
|
|
|
+ if (handler != null)
|
|
|
+ return true;
|
|
|
+ handler = new Handler();
|
|
|
+ handler.postDelayed(fBackspaceHandler, INIT_DELAY);
|
|
|
+ break;
|
|
|
+ case MotionEvent.ACTION_UP:
|
|
|
+ if (handler != null) {
|
|
|
+ handler.removeCallbacks(fBackspaceHandler);
|
|
|
+ handler = null;
|
|
|
+ }
|
|
|
+ fBackspaceHandler.run();
|
|
|
+ v.performClick();
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+
|
|
|
+ private final Runnable fBackspaceHandler = new Runnable() {
|
|
|
+ @Override
|
|
|
+ public void run() {
|
|
|
+ getCurrentInputConnection().deleteSurroundingText(1, 0);
|
|
|
+ if (handler != null)
|
|
|
+ handler.postDelayed(this, DELAY);
|
|
|
+ }
|
|
|
+ };
|
|
|
+ });
|
|
|
fInputView.findViewById(R.id.generateButton).setOnClickListener(view -> CreatePassword());
|
|
|
fInputView.findViewById(R.id.openAppButton).setOnClickListener(view -> startActivity(new Intent(InputService.this, MainActivity.class)));
|
|
|
return fInputView;
|