Skip to content

Commit

Permalink
Change authentication message appearing and text.
Browse files Browse the repository at this point in the history
  • Loading branch information
arturdryomov committed Jun 20, 2014
1 parent 25a13a9 commit 11188c2
Show file tree
Hide file tree
Showing 9 changed files with 115 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,11 @@
import android.os.Bundle;
import android.text.Editable;
import android.text.TextWatcher;
import android.text.method.LinkMovementMethod;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.Toast;
import android.widget.TextView;
import android.widget.ViewAnimator;

import com.squareup.otto.Subscribe;
Expand Down Expand Up @@ -58,6 +59,7 @@ protected void onCreate(Bundle savedInstanceState) {
setUpInjections();

setUpAuthenticationAction();
setUpAuthenticationMessages();
setUpAuthenticationListeners();
}

Expand Down Expand Up @@ -85,6 +87,14 @@ private Button getAuthenticationButton() {
return (Button) findViewById(R.id.button_authentication);
}

private void setUpAuthenticationMessages() {
TextView authenticationFailureMessage = (TextView) findViewById(R.id.text_message_authentication);
TextView authenticationConnectionFailureMessage = (TextView) findViewById(R.id.text_message_authentication_connection);

authenticationFailureMessage.setMovementMethod(LinkMovementMethod.getInstance());
authenticationConnectionFailureMessage.setMovementMethod(LinkMovementMethod.getInstance());
}

private void setUpAuthenticationListeners() {
setUpAuthenticationTextListener();
setUpAuthenticationActionListener();
Expand All @@ -106,6 +116,13 @@ private EditText getPasswordEdit() {
@Override
public void onTextChanged(CharSequence text, int after, int before, int count) {
setUpAuthenticationAction();

hideAuthenticationFailureMessage();
}

private void hideAuthenticationFailureMessage() {
ViewAnimator animator = (ViewAnimator) findViewById(R.id.animator_message);
animator.setDisplayedChild(animator.indexOfChild(findViewById(R.id.view_message_empty)));
}

@Override
Expand All @@ -131,6 +148,8 @@ private void setUpAuthentication() {
hideAuthenticationText();

showProgress();

hideAuthenticationFailureMessage();
}

private void hideAuthenticationText() {
Expand All @@ -139,7 +158,7 @@ private void hideAuthenticationText() {
}

private void showProgress() {
ViewAnimator animator = (ViewAnimator) findViewById(R.id.animator);
ViewAnimator animator = (ViewAnimator) findViewById(R.id.animator_button);
animator.setDisplayedChild(animator.indexOfChild(findViewById(android.R.id.progress)));
}

Expand All @@ -166,12 +185,13 @@ private void showAuthenticationText() {
}

private void hideProgress() {
ViewAnimator animator = (ViewAnimator) findViewById(R.id.animator);
ViewAnimator animator = (ViewAnimator) findViewById(R.id.animator_button);
animator.setDisplayedChild(animator.indexOfChild(findViewById(R.id.button_authentication)));
}

private void showAuthenticationFailureMessage() {
Toast.makeText(this, "Authentication failed.", Toast.LENGTH_LONG).show();
ViewAnimator animator = (ViewAnimator) findViewById(R.id.animator_message);
animator.setDisplayedChild(animator.indexOfChild(findViewById(R.id.text_message_authentication)));
}

@Subscribe
Expand All @@ -182,7 +202,8 @@ public void onAuthenticationConnectionFailed(AuthenticationConnectionFailedEvent
}

private void showAuthenticationConnectionFailureMessage() {
Toast.makeText(this, "Connection failed.", Toast.LENGTH_LONG).show();
ViewAnimator animator = (ViewAnimator) findViewById(R.id.animator_message);
animator.setDisplayedChild(animator.indexOfChild(findViewById(R.id.text_message_authentication_connection)));
}

@Subscribe
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -223,7 +223,7 @@ private void showAudio() {
}

private void showAudioControls() {
Animation showAnimation = AnimationUtils.loadAnimation(this, R.anim.slide_up);
Animation showAnimation = AnimationUtils.loadAnimation(this, R.anim.slide_up_view);
audioControls.startAnimation(showAnimation);

audioControls.show(0);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -405,7 +405,7 @@ private void showSystemControls() {
}

private void showVlcControls() {
Animation showAnimation = AnimationUtils.loadAnimation(this, R.anim.slide_up);
Animation showAnimation = AnimationUtils.loadAnimation(this, R.anim.slide_up_view);
vlcControls.startAnimation(showAnimation);

vlcControls.show(0);
Expand All @@ -428,7 +428,7 @@ private void hideControls() {
private void hideVlcControls() {
vlcControls.hide();

Animation hideAnimation = AnimationUtils.loadAnimation(this, R.anim.slide_down);
Animation hideAnimation = AnimationUtils.loadAnimation(this, R.anim.slide_down_view);
vlcControls.startAnimation(hideAnimation);
}

Expand Down
25 changes: 25 additions & 0 deletions src/main/res/anim/slide_down_text.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
~ Copyright (c) 2014 Amahi
~
~ This file is part of Amahi.
~
~ Amahi is free software: you can redistribute it and/or modify
~ it under the terms of the GNU General Public License as published by
~ the Free Software Foundation, either version 3 of the License, or
~ (at your option) any later version.
~
~ Amahi is distributed in the hope that it will be useful,
~ but WITHOUT ANY WARRANTY; without even the implied warranty of
~ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
~ GNU General Public License for more details.
~
~ You should have received a copy of the GNU General Public License
~ along with Amahi. If not, see <http ://www.gnu.org/licenses/>.
-->

<translate xmlns:android="http://schemas.android.com/apk/res/android"
android:fromYDelta="-100%p"
android:toYDelta="0%p"
android:interpolator="@android:anim/accelerate_interpolator"
android:duration="@android:integer/config_shortAnimTime"/>
File renamed without changes.
25 changes: 25 additions & 0 deletions src/main/res/anim/slide_up_text.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
~ Copyright (c) 2014 Amahi
~
~ This file is part of Amahi.
~
~ Amahi is free software: you can redistribute it and/or modify
~ it under the terms of the GNU General Public License as published by
~ the Free Software Foundation, either version 3 of the License, or
~ (at your option) any later version.
~
~ Amahi is distributed in the hope that it will be useful,
~ but WITHOUT ANY WARRANTY; without even the implied warranty of
~ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
~ GNU General Public License for more details.
~
~ You should have received a copy of the GNU General Public License
~ along with Amahi. If not, see <http ://www.gnu.org/licenses/>.
-->

<translate xmlns:android="http://schemas.android.com/apk/res/android"
android:fromYDelta="0%p"
android:toYDelta="-100%p"
android:interpolator="@android:anim/decelerate_interpolator"
android:duration="@android:integer/config_shortAnimTime"/>
File renamed without changes.
34 changes: 33 additions & 1 deletion src/main/res/layout/layout_authentication.xml
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@
android:layout_height="16dp"/>

<ViewAnimator
android:id="@+id/animator"
android:id="@+id/animator_button"
android:inAnimation="@android:anim/fade_in"
android:outAnimation="@android:anim/fade_out"
android:layout_width="match_parent"
Expand All @@ -73,4 +73,36 @@

</ViewAnimator>

<Space
android:layout_width="match_parent"
android:layout_height="16dp"/>

<ViewAnimator
android:id="@+id/animator_message"
android:inAnimation="@anim/slide_down_text"
android:outAnimation="@anim/slide_up_text"
android:layout_width="match_parent"
android:layout_height="match_parent">

<Space
android:id="@+id/view_message_empty"
android:layout_width="0dp"
android:layout_height="0dp"/>

<TextView
android:id="@+id/text_message_authentication"
android:text="@string/error_authentication"
android:gravity="center_horizontal"
android:layout_width="match_parent"
android:layout_height="wrap_content"/>

<TextView
android:id="@+id/text_message_authentication_connection"
android:text="@string/error_authentication_connection"
android:gravity="center_horizontal"
android:layout_width="match_parent"
android:layout_height="wrap_content"/>

</ViewAnimator>

</LinearLayout>
3 changes: 3 additions & 0 deletions src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -24,5 +24,8 @@

<string name="menu_navigation_open">Open navigation</string>
<string name="menu_navigation_close">Close navigation</string>

<string name="error_authentication">The username or password are not correct. Please try again. <a href="https://www.amahi.org/forgot">Forgot your password?</a></string>
<string name="error_authentication_connection">Connection error. Check your settings and try again.</string>

</resources>

0 comments on commit 11188c2

Please sign in to comment.