Browse Source

Pwd prompt touch handled properly

master
preyearegmi 6 years ago
parent
commit
7e9a2f3b8a
  1. 48
      app/src/main/java/com/gmeremit/online/gmeremittance_native/transactionpasspromt/TransactionPasswordPromptActivity.java
  2. 1
      app/src/main/res/layout/activity_transaction_password_prompt.xml

48
app/src/main/java/com/gmeremit/online/gmeremittance_native/transactionpasspromt/TransactionPasswordPromptActivity.java

@ -2,13 +2,17 @@ package com.gmeremit.online.gmeremittance_native.transactionpasspromt;
import android.content.Intent; import android.content.Intent;
import android.content.pm.ActivityInfo; import android.content.pm.ActivityInfo;
import android.graphics.Rect;
import android.os.Build; import android.os.Build;
import android.os.Bundle; import android.os.Bundle;
import android.support.v4.view.GestureDetectorCompat;
import android.util.Log; import android.util.Log;
import android.view.GestureDetector;
import android.view.MotionEvent; import android.view.MotionEvent;
import android.view.ViewGroup; import android.view.ViewGroup;
import android.view.Window; import android.view.Window;
import android.widget.FrameLayout; import android.widget.FrameLayout;
import android.widget.LinearLayout;
import android.widget.RelativeLayout; import android.widget.RelativeLayout;
import com.gmeremit.online.gmeremittance_native.R; import com.gmeremit.online.gmeremittance_native.R;
@ -36,10 +40,15 @@ public class TransactionPasswordPromptActivity extends BaseActivity implements S
@BindView(R.id.keypadBallon) @BindView(R.id.keypadBallon)
RelativeLayout ballonView; RelativeLayout ballonView;
@BindView(R.id.rootView)
LinearLayout rootView;
@BindView(R.id.passwordErrorTxt) @BindView(R.id.passwordErrorTxt)
GmeErrorTextView passwordErrorTxt; GmeErrorTextView passwordErrorTxt;
private SecurityKeypadListener securityKeypadListener; private SecurityKeypadListener securityKeypadListener;
private GestureDetectorCompat gestureDetector;
private TransactionPasswordPromptActivityGestureDetector myViewGestureDetector;
@Override @Override
@ -70,6 +79,8 @@ public class TransactionPasswordPromptActivity extends BaseActivity implements S
securityKeyboardView.setKeyboardContainerView(keypadContainer); securityKeyboardView.setKeyboardContainerView(keypadContainer);
securityKeyboardView.setKeyboardBallonView(ballonView); securityKeyboardView.setKeyboardBallonView(ballonView);
securityKeypadListener=new SecurityKeypadListener(); securityKeypadListener=new SecurityKeypadListener();
myViewGestureDetector = new TransactionPasswordPromptActivityGestureDetector();
gestureDetector = new GestureDetectorCompat(this, myViewGestureDetector);
try { try {
securityKeyboardManager = new SecurityKeyboardManager(this); securityKeyboardManager = new SecurityKeyboardManager(this);
SecurityKeypadRequestParamBuilder request = new SecurityKeypadRequestParamBuilder(this); SecurityKeypadRequestParamBuilder request = new SecurityKeypadRequestParamBuilder(this);
@ -96,8 +107,25 @@ public class TransactionPasswordPromptActivity extends BaseActivity implements S
@Override @Override
public boolean dispatchTouchEvent(MotionEvent ev) { public boolean dispatchTouchEvent(MotionEvent ev) {
return ( securityKeyboardView.checkIfTouchIntersectKeypadLayout(ev) || super.dispatchTouchEvent(ev));
return ( securityKeyboardView.checkIfTouchIntersectKeypadLayout(ev) ||gestureDetector.onTouchEvent(ev)|| super.dispatchTouchEvent(ev));
}
private boolean checkIfTouchOutsiedRootView(float x,float y) {
int posX = (int) x;
int posY = (int) y;
int[] rootViewLeftAndTopCoordinates = new int[2];
rootView.getLocationOnScreen(rootViewLeftAndTopCoordinates);
Rect rootViewBoundRect = new Rect(rootViewLeftAndTopCoordinates[0], rootViewLeftAndTopCoordinates[1],
rootViewLeftAndTopCoordinates[0] + rootView.getMeasuredWidth(),
rootViewLeftAndTopCoordinates[1] + rootView.getMeasuredHeight());
return !rootViewBoundRect.contains(posX, posY);
} }
@Override @Override
@ -135,7 +163,7 @@ public class TransactionPasswordPromptActivity extends BaseActivity implements S
@Override @Override
public void cancel(Intent intent) { public void cancel(Intent intent) {
Log.d("SecurityKeypad","done"); Log.d("SecurityKeypad","done");
finish();
} }
@ -168,4 +196,20 @@ public class TransactionPasswordPromptActivity extends BaseActivity implements S
} }
} }
class TransactionPasswordPromptActivityGestureDetector extends GestureDetector.SimpleOnGestureListener {
@Override
public boolean onSingleTapUp(MotionEvent e) {
if (e.getAction() == MotionEvent.ACTION_UP) {
boolean hasToucheOutsideTheView= checkIfTouchOutsiedRootView(e.getX(),e.getY());
if(hasToucheOutsideTheView)
finish();
return hasToucheOutsideTheView;
}
return super.onSingleTapUp(e);
}
}
} }

1
app/src/main/res/layout/activity_transaction_password_prompt.xml

@ -1,5 +1,6 @@
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical" android:layout_width="match_parent" android:orientation="vertical" android:layout_width="match_parent"
android:id="@+id/rootView"
android:layout_height="match_parent"> android:layout_height="match_parent">
<com.gmeremit.online.gmeremittance_native.customwidgets.GmeTextView <com.gmeremit.online.gmeremittance_native.customwidgets.GmeTextView
android:id="@+id/title" android:id="@+id/title"

Loading…
Cancel
Save