Skip to content
This repository has been archived by the owner on Jul 25, 2024. It is now read-only.

Fixes #392 : Re-designs the login page #412

Open
wants to merge 6 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -67,8 +67,8 @@ android {
}

dependencies {
compile 'com.android.support:appcompat-v7:24.1.1'
compile 'com.android.support:design:24.1.1'
compile 'com.android.support:appcompat-v7:24.2.0'
compile 'com.android.support:design:24.2.0'
compile 'com.android.support:recyclerview-v7:24.1.1'
compile 'com.google.android.gms:play-services-gcm:8.4.0'
compile 'com.google.android.gms:play-services-auth:8.4.0'
Expand Down Expand Up @@ -102,7 +102,7 @@ dependencies {
androidTestCompile('com.android.support.test.espresso:espresso-contrib:2.2.2') {
exclude group: 'com.android.support'
}
androidTestCompile('com.android.support:support-annotations:24.1.1') {
androidTestCompile('com.android.support:support-annotations:24.2.0') {
exclude group: 'com.android.support'
}

Expand Down
96 changes: 36 additions & 60 deletions app/src/main/java/com/zulip/android/activities/LoginActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,6 @@
import android.os.Bundle;
import android.support.customtabs.CustomTabsIntent;
import android.support.v7.app.AlertDialog;
import android.support.v7.widget.Toolbar;
import android.text.Editable;
import android.text.InputType;
import android.text.TextWatcher;
import android.util.Log;
import android.util.Patterns;
import android.view.View;
Expand Down Expand Up @@ -70,7 +66,7 @@ public class LoginActivity extends BaseActivity implements View.OnClickListener,
private EditText mServerEditText;
private EditText mUserName;
private EditText mPassword;
private ImageView mShowPassword;
private ImageView logo;
private EditText serverIn;
private boolean skipAnimations = false;
//endregion
Expand All @@ -83,10 +79,6 @@ protected void onCreate(Bundle savedInstanceState) {

setContentView(R.layout.login);

Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
toolbar.setTitle(R.string.title_login);
setSupportActionBar(toolbar);

// Progress bar to be displayed if the connection failure is not resolved.
commonProgressDialog = new CommonProgressDialog(this);
mServerEditText = (EditText) findViewById(R.id.server_url);
Expand All @@ -95,7 +87,7 @@ protected void onCreate(Bundle savedInstanceState) {
findViewById(R.id.zulip_login).setOnClickListener(this);
mUserName = (EditText) findViewById(R.id.username);
mPassword = (EditText) findViewById(R.id.password);
mShowPassword = (ImageView) findViewById(R.id.showPassword);
logo = (ImageView) findViewById(R.id.logo);
serverIn = (EditText) findViewById(R.id.server_url_in);
String serverUrl = getIntent().getStringExtra(Constants.SERVER_URL);
if (serverUrl != null) {
Expand All @@ -118,6 +110,8 @@ public void onClick(View view) {
findViewById(R.id.passwordAuthLayout).setVisibility(View.GONE);
findViewById(R.id.google_sign_in_button).setVisibility(View.GONE);
findViewById(R.id.local_server_button).setVisibility(View.GONE);
findViewById(R.id.forgotRegister).setVisibility(View.GONE);
findViewById(R.id.logo).setVisibility(View.VISIBLE);
//remove error from all editText as user now corrected serverUrl
mPassword.setError(null);
mUserName.setError(null);
Expand All @@ -134,49 +128,6 @@ public void onClick(View view) {
mPassword.setText(savedInstanceState.getString(PASSWORD));
}

mShowPassword.setVisibility(View.GONE);
mPassword.setInputType(InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_VARIATION_PASSWORD);
mPassword.addTextChangedListener(new TextWatcher() {
@Override
public void beforeTextChanged(CharSequence s, int start, int count, int after) {

}

@Override
public void onTextChanged(CharSequence s, int start, int before, int count) {

if (mPassword.getText().length() > 0) {
mShowPassword.setVisibility(View.VISIBLE);
} else {
mShowPassword.setVisibility(View.GONE);
}

}

@Override
public void afterTextChanged(Editable s) {

}
});


mShowPassword.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {

if (mShowPassword.getTag().toString().equals("visible")) {
mShowPassword.setTag("hide");
mShowPassword.setImageResource(R.drawable.ic_visibility_off_black_24dp);
mPassword.setInputType(InputType.TYPE_TEXT_VARIATION_VISIBLE_PASSWORD);
mPassword.setSelection(mPassword.length());
} else {
mShowPassword.setTag("visible");
mShowPassword.setImageResource(R.drawable.ic_visibility_black_24dp);
mPassword.setInputType(InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_VARIATION_PASSWORD);
mPassword.setSelection(mPassword.length());
}
}
});
}

private void showLoginFields() {
Expand Down Expand Up @@ -314,6 +265,9 @@ public void onSuccess(Call<ZulipBackendResponse> call, Response<ZulipBackendResp
imm.hideSoftInputFromWindow(view.getWindowToken(), 0);
}

findViewById(R.id.forgotRegister).setVisibility(View.VISIBLE);
findViewById(R.id.logo).setVisibility(View.GONE);

if (response.body().isPassword()) {
findViewById(R.id.passwordAuthLayout).setVisibility(View.VISIBLE);
}
Expand Down Expand Up @@ -576,11 +530,35 @@ public void onTaskFailure(String result) {
case R.id.register:
openRegister();
break;
case R.id.forgot:
forgotPassword();
break;
default:
break;
}
}

private void forgotPassword() {

Uri uri;
if (serverIn == null || serverIn.getText().toString().isEmpty() || serverIn.getText().toString().equals("")) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

TextUtils.isEmpty() can be used

return;
} else {
uri = Uri.parse(serverIn.getText().toString() + "accounts/" + "password/" + "reset");
}
if (Build.VERSION.SDK_INT < 15) {
Intent intent = new Intent(Intent.ACTION_VIEW, uri);
startActivity(intent);
return;
}
CustomTabsIntent.Builder builder = new CustomTabsIntent.Builder();
builder.setStartAnimations(LoginActivity.this, R.anim.slide_in_right, R.anim.slide_out_left);
builder.setExitAnimations(LoginActivity.this, R.anim.slide_in_left, R.anim.slide_out_right);
builder.setToolbarColor(getResources().getColor(R.color.colorPrimaryDark));
CustomTabsIntent intent = builder.build();
intent.launchUrl(LoginActivity.this, uri);
}

private void openRegister() {
Uri uri;
if (serverIn == null || serverIn.getText().toString().isEmpty() || serverIn.getText().toString().equals("")) {
Expand All @@ -594,6 +572,9 @@ private void openRegister() {
return;
}
CustomTabsIntent.Builder builder = new CustomTabsIntent.Builder();
builder.setStartAnimations(LoginActivity.this, R.anim.slide_in_right, R.anim.slide_out_left);
builder.setExitAnimations(LoginActivity.this, R.anim.slide_in_left, R.anim.slide_out_right);
builder.setToolbarColor(getResources().getColor(R.color.colorPrimaryDark));
CustomTabsIntent intent = builder.build();
intent.launchUrl(LoginActivity.this, uri);
}
Expand All @@ -619,14 +600,9 @@ private boolean isInputValidForDevAuth() {
private boolean isInputValid() {
boolean isValid = true;

if (mPassword.length() == 0) {
isValid = false;
mPassword.setError(getString(R.string.password_required));
}

if (mUserName.length() == 0) {
if (mPassword.length() == 0 || mUserName.length() == 0) {
isValid = false;
mUserName.setError(getString(R.string.username_required));
Toast.makeText(LoginActivity.this, R.string.email_or_password_empty, Toast.LENGTH_SHORT).show();
}

if (mServerEditText.length() == 0) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
import android.app.Activity;
import android.content.Context;

import com.zulip.android.R;

/**
* Default Activity transition animation.
*/
Expand All @@ -16,7 +18,7 @@ public class ActivityTransitionAnim {
public static void transition(Context activityContext) {
// avoid invalid class cast exception
if (activityContext instanceof Activity) {
((Activity) activityContext).overridePendingTransition(android.R.anim.fade_in, android.R.anim.fade_out);
((Activity) activityContext).overridePendingTransition(R.anim.slide_in_right, android.R.anim.fade_out);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

}
}
}
8 changes: 8 additions & 0 deletions app/src/main/res/anim/slide_in_left.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<?xml version="1.0" encoding="utf-8"?>
<set
xmlns:android="http://schemas.android.com/apk/res/android">
<translate
android:fromXDelta="-100%p"
android:toXDelta="0"
android:duration="300"/>
</set>
8 changes: 8 additions & 0 deletions app/src/main/res/anim/slide_in_right.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<?xml version="1.0" encoding="utf-8"?>
<set
xmlns:android="http://schemas.android.com/apk/res/android">
<translate
android:fromXDelta="100%p"
android:toXDelta="0"
android:duration="300"/>
</set>
8 changes: 8 additions & 0 deletions app/src/main/res/anim/slide_out_left.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<?xml version="1.0" encoding="utf-8"?>
<set
xmlns:android="http://schemas.android.com/apk/res/android">
<translate
android:fromXDelta="0"
android:toXDelta="-100%p"
android:duration="300"/>
</set>
8 changes: 8 additions & 0 deletions app/src/main/res/anim/slide_out_right.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<?xml version="1.0" encoding="utf-8"?>
<set
xmlns:android="http://schemas.android.com/apk/res/android">
<translate
android:fromXDelta="0"
android:toXDelta="100%p"
android:duration="300"/>
</set>
10 changes: 0 additions & 10 deletions app/src/main/res/animator-v21/appbar_always_elevated.xml

This file was deleted.

Binary file not shown.
Binary file not shown.
Binary file added app/src/main/res/drawable-hdpi/logo.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
24 changes: 24 additions & 0 deletions app/src/main/res/drawable/login_button.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android" >
<item android:state_pressed="true" >
<shape android:shape="rectangle" >
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if its not much work, it wold be awesome to have a ripple effect on long press

<corners android:radius="5dip" />
<stroke android:width="4dip" android:color="#075818" />
<gradient android:angle="-90" android:startColor="#075818" android:endColor="#075818" />
</shape>
</item>
<item android:state_focused="true">
<shape android:shape="rectangle" >
<corners android:radius="5dip" />
<stroke android:width="1dip" android:color="#075818" />
<solid android:color="#075818"/>
</shape>
</item>
<item >
<shape android:shape="rectangle" >
<corners android:radius="5dip" />
<stroke android:width="1dip" android:color="#075818" />
<gradient android:angle="-90" android:startColor="#075818" android:endColor="#075818" />
</shape>
</item>
</selector>
Loading