diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index c3229e3f7..a8b1362e1 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -27,7 +27,8 @@ + android:configChanges="orientation|screenSize" + android:windowSoftInputMode="adjustResize" /> map = new LinkedHashMap(); + LinkedHashMap map = new LinkedHashMap(); for (int i = 0; i < Math.min(keys.length, values.length); ++i) { map.put(keys[i], values[i]); } - if(map.containsKey(county)) { + if (map.containsKey(county)) { county = map.get(county); } - if (!email.isEmpty() && !password.isEmpty() && !county.isEmpty()){ + if (!email.isEmpty() && !password.isEmpty() && !county.isEmpty()) { new LoginTask(this).execute(email, password, county); } else { Toast.makeText(this, R.string.data_text, Toast.LENGTH_SHORT).show(); } } + + @Override + public boolean dispatchTouchEvent(MotionEvent ev) { + + if (ev.getAction() == MotionEvent.ACTION_DOWN) { + mTouchPosition = ev.getY(); + } + if (ev.getAction() == MotionEvent.ACTION_UP) { + mReleasePosition = ev.getY(); + + if (mTouchPosition - mReleasePosition == 0 ) { + View view = getCurrentFocus(); + if (view != null && (ev.getAction() == MotionEvent.ACTION_UP || ev.getAction() == MotionEvent.ACTION_MOVE) && view instanceof EditText && !view.getClass().getName().startsWith("android.webkit.")) { + + int scrcoords[] = new int[2]; + view.getLocationOnScreen(scrcoords); + float x = ev.getRawX() + view.getLeft() - scrcoords[0]; + float y = ev.getRawY() + view.getTop() - scrcoords[1]; + if (x < view.getLeft() || x > view.getRight() || y < view.getTop() || y > view.getBottom()) { + ((InputMethodManager) this.getSystemService(Context.INPUT_METHOD_SERVICE)).hideSoftInputFromWindow((this.getWindow().getDecorView().getApplicationWindowToken()), 0); + } + } + } + } + return super.dispatchTouchEvent(ev); + } } \ No newline at end of file diff --git a/app/src/main/res/layout/activity_main.xml b/app/src/main/res/layout/activity_main.xml index 77d173385..7b6c2e61e 100644 --- a/app/src/main/res/layout/activity_main.xml +++ b/app/src/main/res/layout/activity_main.xml @@ -1,87 +1,62 @@ - + android:layout_height="match_parent"> - + + - + - + -