From 0ef0c6158eeed42abd5cd7502d5658bfc200993f Mon Sep 17 00:00:00 2001 From: Apostolof Date: Thu, 1 Dec 2016 02:09:11 +0200 Subject: [PATCH] Fixed: header expand/collapse animation, WebView's click handling bug, login focus, password hide/show, eye of the satan error. Created topic package. --- app/src/main/AndroidManifest.xml | 2 +- .../gr/thmmy/mthmmy/activities/LoginActivity.java | 2 +- .../thmmy/mthmmy/activities/main/MainActivity.java | 2 +- .../activities/{ => topic}/TopicActivity.java | 13 +++++-------- app/src/main/res/layout/activity_login.xml | 6 +++++- app/src/main/res/layout/activity_topic.xml | 6 +----- app/src/main/res/values/styles.xml | 2 +- 7 files changed, 15 insertions(+), 18 deletions(-) rename app/src/main/java/gr/thmmy/mthmmy/activities/{ => topic}/TopicActivity.java (99%) diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index 6d90bd10..f007a712 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -39,7 +39,7 @@ android:value=".activities.main.MainActivity"/> diff --git a/app/src/main/java/gr/thmmy/mthmmy/activities/LoginActivity.java b/app/src/main/java/gr/thmmy/mthmmy/activities/LoginActivity.java index 3f16f9bc..a7f97d1d 100644 --- a/app/src/main/java/gr/thmmy/mthmmy/activities/LoginActivity.java +++ b/app/src/main/java/gr/thmmy/mthmmy/activities/LoginActivity.java @@ -106,7 +106,7 @@ public class LoginActivity extends BaseActivity { } if (password.isEmpty()) { - inputPassword.setError("Enter a valid password"); + inputPassword.setError("Enter a valid password", null); valid = false; } else { inputPassword.setError(null); diff --git a/app/src/main/java/gr/thmmy/mthmmy/activities/main/MainActivity.java b/app/src/main/java/gr/thmmy/mthmmy/activities/main/MainActivity.java index 8988e1b2..41747d6a 100644 --- a/app/src/main/java/gr/thmmy/mthmmy/activities/main/MainActivity.java +++ b/app/src/main/java/gr/thmmy/mthmmy/activities/main/MainActivity.java @@ -12,7 +12,7 @@ import android.support.v7.widget.Toolbar; import gr.thmmy.mthmmy.R; import gr.thmmy.mthmmy.activities.BaseActivity; import gr.thmmy.mthmmy.activities.LoginActivity; -import gr.thmmy.mthmmy.activities.TopicActivity; +import gr.thmmy.mthmmy.activities.topic.TopicActivity; import gr.thmmy.mthmmy.data.TopicSummary; import gr.thmmy.mthmmy.activities.main.forum.ForumFragment; import gr.thmmy.mthmmy.activities.main.recent.RecentFragment; diff --git a/app/src/main/java/gr/thmmy/mthmmy/activities/TopicActivity.java b/app/src/main/java/gr/thmmy/mthmmy/activities/topic/TopicActivity.java similarity index 99% rename from app/src/main/java/gr/thmmy/mthmmy/activities/TopicActivity.java rename to app/src/main/java/gr/thmmy/mthmmy/activities/topic/TopicActivity.java index 60dea0b3..622ae868 100644 --- a/app/src/main/java/gr/thmmy/mthmmy/activities/TopicActivity.java +++ b/app/src/main/java/gr/thmmy/mthmmy/activities/topic/TopicActivity.java @@ -1,4 +1,4 @@ -package gr.thmmy.mthmmy.activities; +package gr.thmmy.mthmmy.activities.topic; import android.animation.Animator; import android.animation.AnimatorListenerAdapter; @@ -11,7 +11,6 @@ import android.os.Build; import android.os.Bundle; import android.os.Handler; import android.support.v4.content.ContextCompat; -import android.support.v7.app.ActionBar; import android.support.v7.widget.CardView; import android.support.v7.widget.Toolbar; import android.text.TextUtils; @@ -46,6 +45,7 @@ import java.util.Objects; import javax.net.ssl.SSLHandshakeException; import gr.thmmy.mthmmy.R; +import gr.thmmy.mthmmy.activities.BaseActivity; import gr.thmmy.mthmmy.data.Post; import gr.thmmy.mthmmy.utils.CircularNetworkImageView; import gr.thmmy.mthmmy.utils.ImageController; @@ -714,10 +714,9 @@ public class TopicActivity extends BaseActivity { break; case MotionEvent.ACTION_UP: - fingerState = FINGER_RELEASED; webViewLongClickHandler.removeCallbacks(WebViewLongClick); - if(!wasLongClick) { + if(!wasLongClick && fingerState != FINGER_DRAGGING) { //If this was a link don't expand the card WebView.HitTestResult htResult = post.getHitTestResult(); if (htResult.getExtra() != null @@ -728,6 +727,7 @@ public class TopicActivity extends BaseActivity { } else wasLongClick = false; + fingerState = FINGER_RELEASED; break; case MotionEvent.ACTION_MOVE: @@ -735,9 +735,8 @@ public class TopicActivity extends BaseActivity { if (((Math.abs(downCoordinateX - motionEvent.getX()) > SCROLL_THRESHOLD || Math.abs(downCoordinateY - motionEvent.getY()) > SCROLL_THRESHOLD))) { webViewLongClickHandler.removeCallbacks(WebViewLongClick); - } - if (fingerState == FINGER_TOUCHED || fingerState == FINGER_DRAGGING) fingerState = FINGER_DRAGGING; + } else fingerState = FINGER_UNDEFINED; break; @@ -842,7 +841,6 @@ public class TopicActivity extends BaseActivity { // Start the animation userExtra.animate() - .translationY(0) .alpha(1.0f) .setDuration(300) .setListener(new AnimatorListenerAdapter() { @@ -859,7 +857,6 @@ public class TopicActivity extends BaseActivity { // Start the animation userExtra.animate() - .translationY(userExtra.getHeight()) .alpha(0.0f) .setDuration(300) .setListener(new AnimatorListenerAdapter() { diff --git a/app/src/main/res/layout/activity_login.xml b/app/src/main/res/layout/activity_login.xml index 60b7fe76..0e5f4b1e 100644 --- a/app/src/main/res/layout/activity_login.xml +++ b/app/src/main/res/layout/activity_login.xml @@ -1,5 +1,6 @@ @@ -8,6 +9,7 @@ android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_gravity="top" + android:focusableInTouchMode="true" android:orientation="vertical" android:paddingLeft="24dp" android:paddingRight="24dp"> @@ -57,6 +59,7 @@ @@ -76,7 +79,8 @@ android:layout_marginBottom="24dp" android:layout_marginTop="24dp" android:padding="12dp" - android:text="@string/btn_login"/> + android:text="@string/btn_login" + android:textSize="18sp"/>