Merge pull request #903 from psh/login-screen-improvement

Login screen improvement
This commit is contained in:
Josephine Lim 2017-10-16 17:08:14 +10:00 committed by GitHub
commit e3ef7002d5
20 changed files with 761 additions and 225 deletions

View file

@ -13,7 +13,7 @@ dependencies {
compile 'org.mediawiki:api:1.3'
compile 'commons-codec:commons-codec:1.10'
compile 'com.github.pedrovgs:renderers:3.3.3'
compile 'com.google.code.gson:gson:2.8.0'
compile 'com.google.code.gson:gson:2.8.1'
compile 'com.jakewharton.timber:timber:4.5.1'
compile 'info.debatty:java-string-similarity:0.24'
compile ('com.mapbox.mapboxsdk:mapbox-android-sdk:5.1.0@aar'){
@ -24,6 +24,8 @@ dependencies {
compile "com.android.support:appcompat-v7:${project.supportLibVersion}"
compile "com.android.support:design:${project.supportLibVersion}"
compile "com.android.support:cardview-v7:${project.supportLibVersion}"
compile "com.jakewharton:butterknife:$BUTTERKNIFE_VERSION"
annotationProcessor "com.jakewharton:butterknife-compiler:$BUTTERKNIFE_VERSION"
@ -43,12 +45,12 @@ dependencies {
compile 'com.facebook.stetho:stetho:1.5.0'
testCompile 'junit:junit:4.12'
testCompile 'org.robolectric:robolectric:3.3.2'
testCompile 'org.robolectric:robolectric:3.4'
testCompile 'com.squareup.okhttp3:mockwebserver:3.8.1'
androidTestCompile 'com.squareup.okhttp3:mockwebserver:3.8.1'
androidTestCompile "com.android.support:support-annotations:${project.supportLibVersion}"
androidTestCompile 'com.android.support.test.espresso:espresso-core:2.2.2'
androidTestCompile 'com.android.support.test.espresso:espresso-core:3.0.1'
debugCompile 'com.squareup.leakcanary:leakcanary-android:1.5.1'
releaseCompile 'com.squareup.leakcanary:leakcanary-android-no-op:1.5.1'

View file

@ -19,7 +19,7 @@
android:name=".CommonsApplication"
android:icon="@drawable/ic_launcher"
android:label="@string/app_name"
android:theme="@style/Theme.AppCompat"
android:theme="@style/LightAppTheme"
android:supportsRtl="true" >
<activity android:name="org.acra.CrashReportDialog"
android:theme="@android:style/Theme.Dialog"

View file

@ -5,57 +5,66 @@ import android.app.ProgressDialog;
import android.content.Intent;
import android.content.SharedPreferences;
import android.os.Bundle;
import android.support.annotation.ColorRes;
import android.support.annotation.NonNull;
import android.support.annotation.StringRes;
import android.support.v4.app.NavUtils;
import android.support.v4.content.ContextCompat;
import android.support.v7.app.AppCompatDelegate;
import android.text.Editable;
import android.text.TextWatcher;
import android.view.MenuInflater;
import android.view.MenuItem;
import android.view.View;
import android.view.ViewGroup;
import android.widget.Button;
import android.widget.EditText;
import android.widget.TextView;
import android.widget.Toast;
import butterknife.BindView;
import butterknife.ButterKnife;
import fr.free.nrw.commons.BuildConfig;
import fr.free.nrw.commons.CommonsApplication;
import fr.free.nrw.commons.R;
import fr.free.nrw.commons.WelcomeActivity;
import fr.free.nrw.commons.PageTitle;
import fr.free.nrw.commons.R;
import fr.free.nrw.commons.Utils;
import fr.free.nrw.commons.WelcomeActivity;
import fr.free.nrw.commons.contributions.ContributionsActivity;
import timber.log.Timber;
import static android.view.KeyEvent.KEYCODE_ENTER;
import static android.view.inputmethod.EditorInfo.IME_ACTION_DONE;
public class LoginActivity extends AccountAuthenticatorActivity {
public static final String PARAM_USERNAME = "fr.free.nrw.commons.login.username";
private SharedPreferences prefs = null;
private Button loginButton;
private EditText usernameEdit;
private EditText passwordEdit;
private EditText twoFactorEdit;
ProgressDialog progressDialog;
private LoginTextWatcher textWatcher = new LoginTextWatcher();
@BindView(R.id.loginButton) Button loginButton;
@BindView(R.id.signupButton) Button signupButton;
@BindView(R.id.loginUsername) EditText usernameEdit;
@BindView(R.id.loginPassword) EditText passwordEdit;
@BindView(R.id.loginTwoFactor) EditText twoFactorEdit;
@BindView(R.id.error_message_container) ViewGroup errorMessageContainer;
@BindView(R.id.error_message) TextView errorMessage;
private CommonsApplication app;
ProgressDialog progressDialog;
private AppCompatDelegate delegate;
private SharedPreferences prefs = null;
private LoginTextWatcher textWatcher = new LoginTextWatcher();
@Override
public void onCreate(Bundle savedInstanceState) {
setTheme(Utils.isDarkTheme(this) ? R.style.DarkAppTheme : R.style.LightAppTheme);
getDelegate().installViewFactory();
getDelegate().onCreate(savedInstanceState);
super.onCreate(savedInstanceState);
app = CommonsApplication.getInstance();
setContentView(R.layout.activity_login);
loginButton = (Button) findViewById(R.id.loginButton);
Button signupButton = (Button) findViewById(R.id.signupButton);
usernameEdit = (EditText) findViewById(R.id.loginUsername);
passwordEdit = (EditText) findViewById(R.id.loginPassword);
twoFactorEdit = (EditText) findViewById(R.id.loginTwoFactor);
ButterKnife.bind(this);
prefs = getSharedPreferences("fr.free.nrw.commons", MODE_PRIVATE);
@ -64,45 +73,17 @@ public class LoginActivity extends AccountAuthenticatorActivity {
twoFactorEdit.addTextChangedListener(textWatcher);
passwordEdit.setOnEditorActionListener(newLoginInputActionListener());
loginButton.setOnClickListener(this::performLogin);
signupButton.setOnClickListener(this::signUp);
loginButton.setOnClickListener(view -> performLogin());
signupButton.setOnClickListener(view -> signUp());
}
private class LoginTextWatcher implements TextWatcher {
@Override
public void beforeTextChanged(CharSequence charSequence, int start, int count, int after) {
}
@Override
public void onTextChanged(CharSequence charSequence, int start, int count, int after) {
}
@Override
public void afterTextChanged(Editable editable) {
if (usernameEdit.getText().length() != 0 && passwordEdit.getText().length() != 0 &&
(BuildConfig.DEBUG || twoFactorEdit.getText().length() != 0 || twoFactorEdit.getVisibility() != View.VISIBLE)) {
loginButton.setEnabled(true);
} else {
loginButton.setEnabled(false);
}
}
}
private TextView.OnEditorActionListener newLoginInputActionListener() {
return (textView, actionId, keyEvent) -> {
if (loginButton.isEnabled()) {
if (actionId == IME_ACTION_DONE) {
performLogin(textView);
return true;
} else if ((keyEvent != null) && keyEvent.getKeyCode() == KEYCODE_ENTER) {
performLogin(textView);
return true;
}
}
return false;
};
@Override
protected void onPostCreate(Bundle savedInstanceState) {
super.onPostCreate(savedInstanceState);
getDelegate().onPostCreate(savedInstanceState);
}
@Override
protected void onResume() {
super.onResume();
if (prefs.getBoolean("firstrun", true)) {
@ -127,15 +108,104 @@ public class LoginActivity extends AccountAuthenticatorActivity {
usernameEdit.removeTextChangedListener(textWatcher);
passwordEdit.removeTextChangedListener(textWatcher);
twoFactorEdit.removeTextChangedListener(textWatcher);
delegate.onDestroy();
super.onDestroy();
}
private void performLogin(View view) {
@Override
protected void onStart() {
super.onStart();
delegate.onStart();
}
@Override
protected void onStop() {
super.onStop();
delegate.onStop();
}
@Override
protected void onPostResume() {
super.onPostResume();
getDelegate().onPostResume();
}
@Override
public void setContentView(View view, ViewGroup.LayoutParams params) {
getDelegate().setContentView(view, params);
}
@Override
public boolean onOptionsItemSelected(MenuItem item) {
switch (item.getItemId()) {
case android.R.id.home:
NavUtils.navigateUpFromSameTask(this);
return true;
}
return super.onOptionsItemSelected(item);
}
@Override
@NonNull
public MenuInflater getMenuInflater() {
return getDelegate().getMenuInflater();
}
public void askUserForTwoFactorAuth() {
if (BuildConfig.DEBUG) {
twoFactorEdit.setVisibility(View.VISIBLE);
showMessageAndCancelDialog(R.string.login_failed_2fa_needed);
} else {
showMessageAndCancelDialog(R.string.login_failed_2fa_not_supported);
}
}
public void showMessageAndCancelDialog(@StringRes int resId) {
showMessage(resId, R.color.secondaryDarkColor);
progressDialog.cancel();
}
public void showSuccessAndDismissDialog() {
showMessage(R.string.login_success, R.color.primaryDarkColor);
progressDialog.dismiss();
}
public void emptySensitiveEditFields() {
passwordEdit.setText("");
twoFactorEdit.setText("");
}
public void startMainActivity() {
ContributionsActivity.startYourself(this);
finish();
}
private void performLogin() {
Timber.d("Login to start!");
LoginTask task = getLoginTask();
task.execute();
}
private void signUp() {
Intent intent = new Intent(this, SignupActivity.class);
startActivity(intent);
}
private TextView.OnEditorActionListener newLoginInputActionListener() {
return (textView, actionId, keyEvent) -> {
if (loginButton.isEnabled()) {
if (actionId == IME_ACTION_DONE) {
performLogin();
return true;
} else if ((keyEvent != null) && keyEvent.getKeyCode() == KEYCODE_ENTER) {
performLogin();
return true;
}
}
return false;
};
}
private LoginTask getLoginTask() {
return new LoginTask(
this,
@ -154,57 +224,33 @@ public class LoginActivity extends AccountAuthenticatorActivity {
return new PageTitle(username).getText();
}
@Override
public boolean onOptionsItemSelected(MenuItem item) {
switch (item.getItemId()) {
case android.R.id.home:
NavUtils.navigateUpFromSameTask(this);
return true;
private void showMessage(@StringRes int resId, @ColorRes int colorResId) {
errorMessage.setText(getString(resId));
errorMessage.setTextColor(ContextCompat.getColor(this, colorResId));
errorMessageContainer.setVisibility(View.VISIBLE);
}
private AppCompatDelegate getDelegate() {
if (delegate == null) {
delegate = AppCompatDelegate.create(this, null);
}
return super.onOptionsItemSelected(item);
return delegate;
}
/**
* Called when Sign Up button is clicked.
* @param view View
*/
public void signUp(View view) {
Intent intent = new Intent(this, SignupActivity.class);
startActivity(intent);
}
private class LoginTextWatcher implements TextWatcher {
@Override
public void beforeTextChanged(CharSequence charSequence, int start, int count, int after) {
}
public void askUserForTwoFactorAuth() {
if (BuildConfig.DEBUG) {
twoFactorEdit.setVisibility(View.VISIBLE);
showUserToastAndCancelDialog(R.string.login_failed_2fa_needed);
} else {
showUserToastAndCancelDialog(R.string.login_failed_2fa_not_supported);
@Override
public void onTextChanged(CharSequence charSequence, int start, int count, int after) {
}
@Override
public void afterTextChanged(Editable editable) {
boolean enabled = usernameEdit.getText().length() != 0 && passwordEdit.getText().length() != 0 &&
(BuildConfig.DEBUG || twoFactorEdit.getText().length() != 0 || twoFactorEdit.getVisibility() != View.VISIBLE);
loginButton.setEnabled(enabled);
}
}
public void showUserToastAndCancelDialog(int resId) {
showUserToast(resId);
progressDialog.cancel();
}
private void showUserToast(int resId) {
Toast.makeText(this, resId, Toast.LENGTH_LONG).show();
}
public void showSuccessToastAndDismissDialog() {
Toast successToast = Toast.makeText(this, R.string.login_success, Toast.LENGTH_SHORT);
successToast.show();
progressDialog.dismiss();
}
public void emptySensitiveEditFields() {
passwordEdit.setText("");
twoFactorEdit.setText("");
}
public void startMainActivity() {
ContributionsActivity.startYourself(this);
finish();
}
}

View file

@ -72,7 +72,7 @@ class LoginTask extends AsyncTask<String, String, String> {
}
private void handlePassResult() {
loginActivity.showSuccessToastAndDismissDialog();
loginActivity.showSuccessAndDismissDialog();
AccountAuthenticatorResponse response = null;
@ -99,27 +99,27 @@ class LoginTask extends AsyncTask<String, String, String> {
private void handleOtherResults(String result) {
if (result.equals("NetworkFailure")) {
// Matches NetworkFailure which is created by the doInBackground method
loginActivity.showUserToastAndCancelDialog(R.string.login_failed_network);
loginActivity.showMessageAndCancelDialog(R.string.login_failed_network);
} else if (result.toLowerCase().contains("nosuchuser".toLowerCase()) || result.toLowerCase().contains("noname".toLowerCase())) {
// Matches nosuchuser, nosuchusershort, noname
loginActivity.showUserToastAndCancelDialog(R.string.login_failed_username);
loginActivity.showMessageAndCancelDialog(R.string.login_failed_username);
loginActivity.emptySensitiveEditFields();
} else if (result.toLowerCase().contains("wrongpassword".toLowerCase())) {
// Matches wrongpassword, wrongpasswordempty
loginActivity.showUserToastAndCancelDialog(R.string.login_failed_password);
loginActivity.showMessageAndCancelDialog(R.string.login_failed_password);
loginActivity.emptySensitiveEditFields();
} else if (result.toLowerCase().contains("throttle".toLowerCase())) {
// Matches unknown throttle error codes
loginActivity.showUserToastAndCancelDialog(R.string.login_failed_throttled);
loginActivity.showMessageAndCancelDialog(R.string.login_failed_throttled);
} else if (result.toLowerCase().contains("userblocked".toLowerCase())) {
// Matches login-userblocked
loginActivity.showUserToastAndCancelDialog(R.string.login_failed_blocked);
loginActivity.showMessageAndCancelDialog(R.string.login_failed_blocked);
} else if (result.equals("2FA")) {
loginActivity.askUserForTwoFactorAuth();
} else {
// Occurs with unhandled login failure codes
Timber.d("Login failed with reason: %s", result);
loginActivity.showUserToastAndCancelDialog(R.string.login_failed_generic);
loginActivity.showMessageAndCancelDialog(R.string.login_failed_generic);
}
}
}

View file

@ -0,0 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="oval">
<solid android:color="@color/primarySuperLightColor" />
</shape>

View file

@ -0,0 +1,195 @@
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent">
<FrameLayout
android:layout_width="400sp"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_marginTop="8dp">
<android.support.v7.widget.CardView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="32dp"
android:layout_marginBottom="16dp"
android:layout_marginEnd="16dp"
android:layout_marginLeft="16dp"
android:layout_marginRight="16dp"
android:layout_marginStart="16dp"
app:cardCornerRadius="4dp"
app:cardElevation="4dp">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center"
android:orientation="vertical">
<TextView
android:id="@+id/title"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@color/primaryColor"
android:gravity="center"
android:paddingBottom="32dp"
android:paddingTop="32dp"
android:text="@string/login_to_your_account"
android:textColor="@android:color/white"
android:textSize="24sp" />
<FrameLayout
android:id="@+id/error_message_container"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@id/title"
android:visibility="gone"
tools:visibility="visible">
<TextView
android:id="@+id/error_message"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginEnd="16dp"
android:layout_marginLeft="16dp"
android:layout_marginRight="16dp"
android:layout_marginStart="16dp"
android:paddingBottom="8dp"
android:paddingTop="8dp"
android:textColor="@color/secondaryDarkColor"
tools:text="Check your password, something doesnt look right" />
</FrameLayout>
<android.support.design.widget.TextInputLayout
android:id="@+id/username_container"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@id/error_message_container"
android:layout_marginBottom="16dp"
android:layout_marginEnd="16dp"
android:layout_marginLeft="16dp"
android:layout_marginRight="16dp"
android:layout_marginStart="16dp"
android:layout_marginTop="16dp">
<android.support.design.widget.TextInputEditText
android:id="@+id/loginUsername"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="@string/username"
android:imeOptions="flagNoExtractUi"
android:inputType="textNoSuggestions">
<requestFocus />
</android.support.design.widget.TextInputEditText>
</android.support.design.widget.TextInputLayout>
<android.support.design.widget.TextInputLayout
android:id="@+id/password_container"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@id/username_container"
android:layout_marginBottom="16dp"
android:layout_marginEnd="16dp"
android:layout_marginLeft="16dp"
android:layout_marginRight="16dp"
android:layout_marginStart="16dp"
app:passwordToggleEnabled="false">
<android.support.design.widget.TextInputEditText
android:id="@+id/loginPassword"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="@string/password"
android:imeOptions="flagNoExtractUi"
android:inputType="textPassword" />
</android.support.design.widget.TextInputLayout>
<android.support.design.widget.TextInputLayout
android:id="@+id/two_factor_container"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@id/password_container"
android:layout_marginBottom="16dp"
android:layout_marginEnd="16dp"
android:layout_marginLeft="16dp"
android:layout_marginRight="16dp"
android:layout_marginStart="16dp"
android:visibility="gone"
app:passwordToggleEnabled="false"
tools:visibility="visible">
<android.support.design.widget.TextInputEditText
android:id="@+id/loginTwoFactor"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="@string/_2fa_code"
android:imeOptions="flagNoExtractUi"
android:inputType="textNoSuggestions"
android:visibility="gone"
tools:visibility="visible" />
</android.support.design.widget.TextInputLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@id/two_factor_container"
android:layout_marginBottom="16dp"
android:layout_marginEnd="16dp"
android:layout_marginLeft="16dp"
android:layout_marginRight="16dp"
android:layout_marginStart="16dp">
<Button
android:id="@+id/signupButton"
android:layout_width="0dp"
style="@style/Widget.AppCompat.Button.Borderless.Colored"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:layout_marginEnd="8dp"
android:layout_marginRight="8dp"
android:layout_weight="1"
android:text="@string/signup" />
<Button
android:id="@+id/loginButton"
android:layout_width="0dp"
style="@style/Widget.AppCompat.Button.Colored"
android:layout_height="wrap_content"
android:layout_marginLeft="8dp"
android:layout_marginStart="8dp"
android:layout_weight="1"
android:enabled="false"
android:text="@string/login" />
</LinearLayout>
</RelativeLayout>
</android.support.v7.widget.CardView>
<android.support.v7.widget.AppCompatImageView
android:layout_width="64dp"
android:layout_height="64dp"
android:elevation="8dp"
tools:ignore="UnusedAttribute"
android:layout_gravity="center_horizontal"
app:srcCompat="@drawable/blue_rinse_circle" />
<android.support.v7.widget.AppCompatImageView
android:layout_width="42dp"
tools:ignore="UnusedAttribute"
android:layout_height="42dp"
android:layout_gravity="center_horizontal"
android:layout_marginTop="8dp"
android:elevation="8dp"
app:srcCompat="@drawable/commons_logo_large" />
</FrameLayout>
</ScrollView>

View file

@ -0,0 +1,195 @@
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent">
<FrameLayout
android:layout_width="400sp"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_marginTop="8dp">
<android.support.v7.widget.CardView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="32dp"
android:layout_marginBottom="16dp"
android:layout_marginEnd="16dp"
android:layout_marginLeft="16dp"
android:layout_marginRight="16dp"
android:layout_marginStart="16dp"
app:cardCornerRadius="4dp"
app:cardElevation="4dp">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center"
android:orientation="vertical">
<TextView
android:id="@+id/title"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@color/primaryColor"
android:gravity="center"
android:paddingBottom="32dp"
android:paddingTop="32dp"
android:text="@string/login_to_your_account"
android:textColor="@android:color/white"
android:textSize="24sp" />
<FrameLayout
android:id="@+id/error_message_container"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@id/title"
android:visibility="gone"
tools:visibility="visible">
<TextView
android:id="@+id/error_message"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginEnd="16dp"
android:layout_marginLeft="16dp"
android:layout_marginRight="16dp"
android:layout_marginStart="16dp"
android:paddingBottom="8dp"
android:paddingTop="8dp"
android:textColor="@color/secondaryDarkColor"
tools:text="Check your password, something doesnt look right" />
</FrameLayout>
<android.support.design.widget.TextInputLayout
android:id="@+id/username_container"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@id/error_message_container"
android:layout_marginBottom="16dp"
android:layout_marginEnd="16dp"
android:layout_marginLeft="16dp"
android:layout_marginRight="16dp"
android:layout_marginStart="16dp"
android:layout_marginTop="16dp">
<android.support.design.widget.TextInputEditText
android:id="@+id/loginUsername"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="@string/username"
android:imeOptions="flagNoExtractUi"
android:inputType="textNoSuggestions">
<requestFocus />
</android.support.design.widget.TextInputEditText>
</android.support.design.widget.TextInputLayout>
<android.support.design.widget.TextInputLayout
android:id="@+id/password_container"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@id/username_container"
android:layout_marginBottom="16dp"
android:layout_marginEnd="16dp"
android:layout_marginLeft="16dp"
android:layout_marginRight="16dp"
android:layout_marginStart="16dp"
app:passwordToggleEnabled="false">
<android.support.design.widget.TextInputEditText
android:id="@+id/loginPassword"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="@string/password"
android:imeOptions="flagNoExtractUi"
android:inputType="textPassword" />
</android.support.design.widget.TextInputLayout>
<android.support.design.widget.TextInputLayout
android:id="@+id/two_factor_container"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@id/password_container"
android:layout_marginBottom="16dp"
android:layout_marginEnd="16dp"
android:layout_marginLeft="16dp"
android:layout_marginRight="16dp"
android:layout_marginStart="16dp"
android:visibility="gone"
app:passwordToggleEnabled="false"
tools:visibility="visible">
<android.support.design.widget.TextInputEditText
android:id="@+id/loginTwoFactor"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="@string/_2fa_code"
android:imeOptions="flagNoExtractUi"
android:inputType="textNoSuggestions"
android:visibility="gone"
tools:visibility="visible" />
</android.support.design.widget.TextInputLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@id/two_factor_container"
android:layout_marginBottom="16dp"
android:layout_marginEnd="16dp"
android:layout_marginLeft="16dp"
android:layout_marginRight="16dp"
android:layout_marginStart="16dp">
<Button
android:id="@+id/signupButton"
android:layout_width="0dp"
style="@style/Widget.AppCompat.Button.Borderless.Colored"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:layout_marginEnd="8dp"
android:layout_marginRight="8dp"
android:layout_weight="1"
android:text="@string/signup" />
<Button
android:id="@+id/loginButton"
android:layout_width="0dp"
style="@style/Widget.AppCompat.Button.Colored"
android:layout_height="wrap_content"
android:layout_marginLeft="8dp"
android:layout_marginStart="8dp"
android:layout_weight="1"
android:enabled="false"
android:text="@string/login" />
</LinearLayout>
</RelativeLayout>
</android.support.v7.widget.CardView>
<android.support.v7.widget.AppCompatImageView
android:layout_width="64dp"
android:layout_height="64dp"
android:elevation="8dp"
android:layout_gravity="center_horizontal"
app:srcCompat="@drawable/blue_rinse_circle"
tools:ignore="UnusedAttribute" />
<android.support.v7.widget.AppCompatImageView
android:layout_width="42dp"
android:layout_height="42dp"
android:layout_gravity="center_horizontal"
android:layout_marginTop="8dp"
tools:ignore="UnusedAttribute"
android:elevation="8dp"
app:srcCompat="@drawable/commons_logo_large" />
</FrameLayout>
</ScrollView>

View file

@ -1,100 +1,195 @@
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
>
android:layout_height="match_parent">
<LinearLayout
<FrameLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_margin="16dp"
android:gravity="center"
android:orientation="vertical"
>
android:layout_marginTop="8dp">
<TextView
android:id="@+id/loginSubtitle"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginBottom="48dp"
android:drawablePadding="8dp"
android:drawableTop="@drawable/commons_logo_large"
android:gravity="center_horizontal"
android:text="@string/app_name"
android:textAppearance="?android:attr/textAppearanceMedium"
/>
<android.support.design.widget.TextInputLayout
<android.support.v7.widget.CardView
android:layout_width="match_parent"
android:layout_height="wrap_content"
>
android:layout_marginBottom="16dp"
android:layout_marginEnd="16dp"
android:layout_marginLeft="16dp"
android:layout_marginRight="16dp"
android:layout_marginStart="16dp"
android:layout_marginTop="32dp"
app:cardCornerRadius="4dp"
app:cardElevation="4dp">
<android.support.design.widget.TextInputEditText
android:id="@+id/loginUsername"
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="@string/username"
android:imeOptions="flagNoExtractUi"
android:inputType="textNoSuggestions"
>
android:gravity="center"
android:orientation="vertical">
<requestFocus/>
<TextView
android:id="@+id/title"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@color/primaryColor"
android:gravity="center"
android:paddingBottom="32dp"
android:paddingTop="32dp"
android:text="@string/login_to_your_account"
android:textColor="@android:color/white"
android:textSize="24sp" />
</android.support.design.widget.TextInputEditText>
<FrameLayout
android:id="@+id/error_message_container"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@id/title"
android:visibility="gone"
tools:visibility="visible">
</android.support.design.widget.TextInputLayout>
<TextView
android:id="@+id/error_message"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginEnd="16dp"
android:layout_marginLeft="16dp"
android:layout_marginRight="16dp"
android:layout_marginStart="16dp"
android:paddingBottom="8dp"
android:paddingTop="8dp"
android:textColor="@color/secondaryDarkColor"
tools:text="Check your password, something doesnt look right" />
</FrameLayout>
<android.support.design.widget.TextInputLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:passwordToggleEnabled="false"
>
<android.support.design.widget.TextInputLayout
android:id="@+id/username_container"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@id/error_message_container"
android:layout_marginBottom="16dp"
android:layout_marginEnd="16dp"
android:layout_marginLeft="16dp"
android:layout_marginRight="16dp"
android:layout_marginStart="16dp"
android:layout_marginTop="16dp">
<android.support.design.widget.TextInputEditText
android:id="@+id/loginPassword"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="@string/password"
android:imeOptions="flagNoExtractUi"
android:inputType="textPassword"
/>
<android.support.design.widget.TextInputEditText
android:id="@+id/loginUsername"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="@string/username"
android:imeOptions="flagNoExtractUi"
android:inputType="textNoSuggestions">
</android.support.design.widget.TextInputLayout>
<requestFocus />
<android.support.design.widget.TextInputLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:passwordToggleEnabled="false"
>
</android.support.design.widget.TextInputEditText>
<android.support.design.widget.TextInputEditText
android:id="@+id/loginTwoFactor"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="@string/_2fa_code"
android:imeOptions="flagNoExtractUi"
android:inputType="textNoSuggestions"
android:visibility="gone"
/>
</android.support.design.widget.TextInputLayout>
</android.support.design.widget.TextInputLayout>
<android.support.design.widget.TextInputLayout
android:id="@+id/password_container"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@id/username_container"
android:layout_marginBottom="16dp"
android:layout_marginEnd="16dp"
android:layout_marginLeft="16dp"
android:layout_marginRight="16dp"
android:layout_marginStart="16dp"
app:passwordToggleEnabled="false">
<Button
android:id="@+id/loginButton"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:enabled="false"
android:text="@string/login"
/>
<android.support.design.widget.TextInputEditText
android:id="@+id/loginPassword"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="@string/password"
android:imeOptions="flagNoExtractUi"
android:inputType="textPassword" />
<Button
android:id="@+id/signupButton"
android:layout_width="match_parent"
android:layout_height="wrap_content"
</android.support.design.widget.TextInputLayout>
<android.support.design.widget.TextInputLayout
android:id="@+id/two_factor_container"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@id/password_container"
android:layout_marginBottom="16dp"
android:layout_marginEnd="16dp"
android:layout_marginLeft="16dp"
android:layout_marginRight="16dp"
android:layout_marginStart="16dp"
android:visibility="gone"
app:passwordToggleEnabled="false"
tools:visibility="visible">
<android.support.design.widget.TextInputEditText
android:id="@+id/loginTwoFactor"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="@string/_2fa_code"
android:imeOptions="flagNoExtractUi"
android:inputType="textNoSuggestions"
android:visibility="gone"
tools:visibility="visible" />
</android.support.design.widget.TextInputLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@id/two_factor_container"
android:layout_marginBottom="16dp"
android:layout_marginEnd="16dp"
android:layout_marginLeft="16dp"
android:layout_marginRight="16dp"
android:layout_marginStart="16dp">
<Button
android:id="@+id/signupButton"
android:layout_width="0dp"
style="@style/Widget.AppCompat.Button.Borderless.Colored"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:layout_marginEnd="8dp"
android:layout_marginRight="8dp"
android:layout_weight="1"
android:text="@string/signup" />
<Button
android:id="@+id/loginButton"
android:layout_width="0dp"
style="@style/Widget.AppCompat.Button.Colored"
android:layout_height="wrap_content"
android:layout_marginLeft="8dp"
android:layout_marginStart="8dp"
android:layout_weight="1"
android:enabled="false"
android:text="@string/login" />
</LinearLayout>
</RelativeLayout>
</android.support.v7.widget.CardView>
<android.support.v7.widget.AppCompatImageView
android:layout_width="64dp"
android:layout_height="64dp"
android:elevation="8dp"
tools:ignore="UnusedAttribute"
android:layout_gravity="center_horizontal"
android:text="@string/signup"
/>
app:srcCompat="@drawable/blue_rinse_circle" />
<android.support.v7.widget.AppCompatImageView
android:layout_width="42dp"
android:layout_height="42dp"
android:layout_gravity="center_horizontal"
android:layout_marginTop="8dp"
tools:ignore="UnusedAttribute"
android:elevation="8dp"
app:srcCompat="@drawable/commons_logo_large" />
</FrameLayout>
</LinearLayout>
</ScrollView>

View file

@ -2,21 +2,18 @@
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="?attr/commonsAppBlue"
>
android:background="@color/primaryColor">
<android.support.v4.view.ViewPager
android:id="@+id/welcomePager"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fadingEdge="none"
/>
android:fadingEdge="none" />
<com.viewpagerindicator.CirclePageIndicator
android:id="@+id/welcomePagerIndicator"
android:layout_height="24dp"
android:layout_width="match_parent"
android:layout_gravity="bottom"
/>
android:layout_gravity="bottom" />
</FrameLayout>

View file

@ -2,7 +2,7 @@
xmlns:app="http://schemas.android.com/apk/res-auto">
<item android:id="@+id/menu_upload_single"
android:title="@string/menu_upload_single"
android:icon="?attr/iconSend"
android:icon="@drawable/ic_send_white_24dp"
android:enabled="false"
app:showAsAction="always" />
</menu>

View file

@ -4,6 +4,6 @@
xmlns:app="http://schemas.android.com/apk/res-auto">
<item android:id="@+id/menu_save_categories"
android:title="@string/menu_save_categories"
android:icon="?attr/iconSave"
android:icon="@drawable/ic_save_white_24dp"
app:showAsAction="always" />
</menu>

View file

@ -3,12 +3,12 @@
<item android:id="@+id/menu_from_camera"
android:title="@string/menu_from_camera"
app:showAsAction="ifRoom|withText"
android:icon="?attr/iconCamera"
android:icon="@drawable/ic_photo_camera_white_24dp"
/>
<item android:id="@+id/menu_from_gallery"
android:title="@string/menu_from_gallery"
app:showAsAction="ifRoom|withText"
android:icon="?attr/iconPhoto"
android:icon="@drawable/ic_photo_white_24dp"
/>
<!--<item android:id="@+id/menu_nearby"-->
<!--android:title="@string/menu_nearby"-->

View file

@ -18,7 +18,7 @@
<item
android:id="@+id/menu_retry_current_image"
android:enabled="false"
android:icon="?attr/iconUndo"
android:icon="@drawable/ic_undo_white_24dp"
android:title="@string/menu_retry_upload"
android:visible="false"
app:showAsAction="ifRoom|withText" />

View file

@ -6,6 +6,6 @@
<item android:id="@+id/menu_upload_multiple"
android:title="@string/share_upload_button"
app:showAsAction="always|withText"
android:icon="?attr/iconSend"
android:icon="@drawable/ic_send_white_24dp"
/>
</menu>

View file

@ -2,17 +2,11 @@
<resources>
<attr name="mainBackground" format="reference"/>
<attr name="semitransparentText" format="reference"/>
<attr name="commonsAppBlue" format="reference"/>
<attr name="subBackground" format="reference"/>
<attr name="fragmentCategorisationBackground" format="reference"/>
<attr name="buttonBackground" format="reference"/>
<attr name="uploadOverlayBackground" format="reference"/>
<attr name="spinnerTheme" format="reference"/>
<attr name="iconSend" format="reference"/>
<attr name="iconSave" format="reference"/>
<attr name="iconCamera" format="reference"/>
<attr name="iconPhoto" format="reference"/>
<attr name="iconUndo" format="reference"/>
<declare-styleable name="CompatTextView">
<attr name="drawablePadding" format="dimension"/>

View file

@ -1,16 +1,26 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<!-- Main application background color -->
<color name="main_background_dark">#303030</color>
<color name="main_background_light">#fafafa</color>
<!-- Colors used by newer Android + Support library for material design theme -->
<color name="primaryColor">#0c609c</color>
<color name="primaryDarkColor">#00376d</color>
<color name="primaryLightColor">#528dcd</color>
<color name="primarySuperLightColor">#d7e8fb</color>
<color name="secondaryColor">#f38b04</color>
<color name="secondaryDarkColor">#ba5d00</color>
<color name="secondaryLightColor">#ffbc46</color>
<color name="primaryTextColor">#ffffff</color>
<color name="secondaryTextColor">#000000</color>
<!-- Some colours are same for dark/light themes. They are written two times in case
we want to change light ones later.
-->
<color name="item_white_background">#ffffffff</color>
<color name="main_background_dark">#000000</color>
<color name="main_background_light">#ffffff</color>
<color name="commons_app_blue_dark">#33FFFFFF</color>
<color name="commons_app_blue_light">#33FFFFFF</color>
<color name="activity_welcome_background_dark">#0c609c</color>
<color name="activity_welcome_background_light">#0c609c</color>
<color name="action_bar_blue">#0c609c</color>
<color name="status_bar_blue">#08436d</color>
<color name="sub_background_dark">#20ffffff</color>
<color name="sub_background_light">#20ffffff</color>
@ -20,4 +30,5 @@
<color name="button_background_light">#B0000000</color>
<color name="upload_overlay_background_dark">#77000000</color>
<color name="upload_overlay_background_light">#44000000</color>
</resources>

View file

@ -207,4 +207,5 @@ Tap this message (or hit back) to skip this step.</string>
<string name="give_permission">Give permission</string>
<string name="use_external_storage">Use external storage</string>
<string name="use_external_storage_summary">Save pictures taken with the in-app camera on your device</string>
<string name="login_to_your_account">Login to your account</string>
</resources>

View file

@ -2,36 +2,30 @@
<style name="DarkAppTheme" parent="Theme.AppCompat.NoActionBar">
<item name="mainBackground">@color/main_background_dark</item>
<item name="colorPrimary">@color/primaryColor</item>
<item name="colorPrimaryDark">@color/primaryDarkColor</item>
<item name="colorAccent">@color/primaryColor</item>
<item name="colorButtonNormal">@color/primaryColor</item>
<item name="semitransparentText">@color/commons_app_blue_dark</item>
<item name="commonsAppBlue">@color/activity_welcome_background_dark</item>
<item name="subBackground">@color/sub_background_dark</item>
<item name="fragmentCategorisationBackground">@color/fragment_categorisation_background_dark</item>
<item name="buttonBackground">@color/button_background_dark</item>
<item name="uploadOverlayBackground">@color/upload_overlay_background_dark</item>
<item name="iconSend">@drawable/ic_send_white_24dp</item>
<item name="iconSave">@drawable/ic_save_white_24dp</item>
<item name="iconCamera">@drawable/ic_photo_camera_white_24dp</item>
<item name="iconPhoto">@drawable/ic_photo_white_24dp</item>
<item name="iconUndo">@drawable/ic_undo_white_24dp</item>
<item name="spinnerTheme">@style/DarkSpinnerTheme</item>
</style>
<style name="LightAppTheme" parent="Theme.AppCompat.Light.NoActionBar">
<item name="mainBackground">@color/main_background_light</item>
<item name="colorPrimaryDark">@color/primaryDarkColor</item>
<item name="colorAccent">@color/primaryColor</item>
<item name="colorButtonNormal">@color/primaryColor</item>
<item name="semitransparentText">@color/commons_app_blue_light</item>
<item name="commonsAppBlue">@color/activity_welcome_background_light</item>
<item name="subBackground">@color/sub_background_light</item>
<item name="fragmentCategorisationBackground">@color/fragment_categorisation_background_light</item>
<item name="buttonBackground">@color/button_background_light</item>
<item name="uploadOverlayBackground">@color/upload_overlay_background_light</item>
<item name="iconSend">@drawable/ic_send_white_24dp</item>
<item name="iconSave">@drawable/ic_save_white_24dp</item>
<item name="iconCamera">@drawable/ic_photo_camera_white_24dp</item>
<item name="iconPhoto">@drawable/ic_photo_white_24dp</item>
<item name="iconUndo">@drawable/ic_undo_white_24dp</item>
<item name="colorPrimary">@color/action_bar_blue</item>
<item name="colorPrimaryDark">@color/status_bar_blue</item>
<item name="spinnerTheme">@style/LightSpinnerTheme</item>
</style>

View file

@ -16,5 +16,6 @@ allprojects {
repositories {
jcenter()
maven { url "https://jitpack.io" }
maven { url "https://maven.google.com" }
}
}

View file

@ -1,8 +1,8 @@
gradleVersion = 2.3.3
supportLibVersion = 25.3.1
supportLibVersion = 26.1.0
compileSdkVersion = android-25
compileSdkVersion = android-26
buildToolsVersion = 26.0.1
minSdkVersion = 15