Add Forgot Password Option in LoginActivity (#1242)

* Add Forgot Password Option in LoginActivity

* Add Forgot Password Option in LoginActivity

* Add Forgot Password Option in LoginActivity

* Update URL for the "beta" flavor

* Update forgotPassword function
This commit is contained in:
Madhur Gupta 2018-03-10 23:00:05 +05:30 committed by Vivek Maskara
parent 57bfb7b328
commit de673eb4ca
7 changed files with 56 additions and 8 deletions

View file

@ -8,6 +8,7 @@ import android.app.Activity;
import android.app.ProgressDialog;
import android.content.Intent;
import android.content.SharedPreferences;
import android.net.Uri;
import android.os.Bundle;
import android.support.annotation.ColorRes;
import android.support.annotation.NonNull;
@ -27,6 +28,7 @@ import android.view.inputmethod.InputMethodManager;
import android.widget.Button;
import android.widget.EditText;
import android.widget.TextView;
import android.widget.Toast;
import java.io.IOException;
@ -44,6 +46,7 @@ import fr.free.nrw.commons.contributions.ContributionsActivity;
import fr.free.nrw.commons.di.ApplicationlessInjection;
import fr.free.nrw.commons.mwapi.MediaWikiApi;
import fr.free.nrw.commons.theme.NavigationBaseActivity;
import fr.free.nrw.commons.ui.widget.HtmlTextView;
import io.reactivex.Observable;
import io.reactivex.android.schedulers.AndroidSchedulers;
import io.reactivex.schedulers.Schedulers;
@ -73,7 +76,9 @@ public class LoginActivity extends AccountAuthenticatorActivity {
@BindView(R.id.error_message_container) ViewGroup errorMessageContainer;
@BindView(R.id.error_message) TextView errorMessage;
@BindView(R.id.login_credentials) TextView loginCredentials;
@BindView(R.id.two_factor_container)TextInputLayout twoFactorContainer;
@BindView(R.id.two_factor_container) TextInputLayout twoFactorContainer;
@BindView(R.id.forgotPassword) HtmlTextView forgotPasswordText;
ProgressDialog progressDialog;
private AppCompatDelegate delegate;
private LoginTextWatcher textWatcher = new LoginTextWatcher();
@ -114,6 +119,8 @@ public class LoginActivity extends AccountAuthenticatorActivity {
loginButton.setOnClickListener(view -> performLogin());
signupButton.setOnClickListener(view -> signUp());
forgotPasswordText.setOnClickListener(view -> forgotPassword());
if(BuildConfig.FLAVOR == "beta"){
loginCredentials.setText(getString(R.string.login_credential));
} else {
@ -121,6 +128,10 @@ public class LoginActivity extends AccountAuthenticatorActivity {
}
}
private void forgotPassword() {
Utils.handleWebUrl(this, Uri.parse(BuildConfig.FORGOT_PASSWORD_URL));
}
public void hideKeyboard(View view) {
InputMethodManager inputMethodManager =(InputMethodManager)this.getSystemService(Activity.INPUT_METHOD_SERVICE);

View file

@ -187,12 +187,23 @@
</LinearLayout>
<fr.free.nrw.commons.ui.widget.HtmlTextView
android:visibility="visible"
android:id="@+id/forgotPassword"
android:layout_width="match_parent"
android:gravity="center_horizontal"
android:layout_height="wrap_content"
android:layout_below="@id/buttonFrame"
android:layout_marginBottom="@dimen/standard_gap"
android:text="@string/forgot_password"
android:textColor="@color/status_bar_blue"/>
<fr.free.nrw.commons.ui.widget.HtmlTextView
android:id="@+id/about_privacy_policy"
style="?android:textAppearanceSmall"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@id/buttonFrame"
android:layout_below="@id/forgotPassword"
android:layout_centerHorizontal="true"
android:layout_gravity="center_horizontal"
android:layout_marginBottom="@dimen/standard_gap"

View file

@ -187,12 +187,23 @@
</LinearLayout>
<fr.free.nrw.commons.ui.widget.HtmlTextView
android:visibility="visible"
android:id="@+id/forgotPassword"
android:layout_width="match_parent"
android:gravity="center_horizontal"
android:layout_height="wrap_content"
android:layout_below="@id/buttonFrame"
android:layout_marginBottom="@dimen/standard_gap"
android:text="@string/forgot_password"
android:textColor="@color/status_bar_blue" />
<fr.free.nrw.commons.ui.widget.HtmlTextView
android:id="@+id/about_privacy_policy"
style="?android:textAppearanceSmall"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@id/buttonFrame"
android:layout_below="@id/forgotPassword"
android:layout_centerHorizontal="true"
android:layout_gravity="center_horizontal"
android:layout_marginBottom="@dimen/standard_gap"

View file

@ -7,7 +7,7 @@
<FrameLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_gravity="center_vertical"
android:layout_marginTop="@dimen/small_gap">
<android.support.v7.widget.CardView
@ -192,18 +192,30 @@
</LinearLayout>
<fr.free.nrw.commons.ui.widget.HtmlTextView
android:visibility="visible"
android:id="@+id/forgotPassword"
android:layout_width="match_parent"
android:gravity="center_horizontal"
android:layout_height="wrap_content"
android:layout_below="@id/buttonFrame"
android:layout_marginBottom="@dimen/standard_gap"
android:text="@string/forgot_password"
android:textColor="@color/status_bar_blue" />
<fr.free.nrw.commons.ui.widget.HtmlTextView
android:id="@+id/about_privacy_policy"
style="?android:textAppearanceSmall"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@id/buttonFrame"
android:layout_below="@id/forgotPassword"
android:layout_centerHorizontal="true"
android:layout_gravity="center_horizontal"
android:layout_marginBottom="@dimen/standard_gap"
android:text="@string/about_privacy_policy" />
</RelativeLayout>
</android.support.v7.widget.CardView>
<android.support.v7.widget.AppCompatImageView
@ -222,7 +234,6 @@
android:elevation="8dp"
app:srcCompat="@drawable/commons_logo_large"
tools:ignore="UnusedAttribute" />
</FrameLayout>
</ScrollView>

View file

@ -5,8 +5,9 @@
<string name="menu_settings">Settings</string>
<string name="username">Username</string>
<string name="password">Password</string>
<string name="login_credential">Log in to your Commons Beta account</string>
<string name="login_credential">Log in to your Commons Beta account</string>
<string name="login">Log in</string>
<string name="forgot_password">Forgot Password?</string>
<string name="signup">Sign up</string>
<string name="logging_in_title">Logging in</string>
<string name="logging_in_message">Please wait…</string>