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

@ -154,6 +154,7 @@ android {
buildConfigField "String", "EVENTLOG_WIKI", "\"commonswiki\"" buildConfigField "String", "EVENTLOG_WIKI", "\"commonswiki\""
buildConfigField "String", "SIGNUP_LANDING_URL", "\"https://commons.m.wikimedia.org/w/index.php?title=Special:CreateAccount&returnto=Main+Page&returntoquery=welcome%3Dyes\"" buildConfigField "String", "SIGNUP_LANDING_URL", "\"https://commons.m.wikimedia.org/w/index.php?title=Special:CreateAccount&returnto=Main+Page&returntoquery=welcome%3Dyes\""
buildConfigField "String", "SIGNUP_SUCCESS_REDIRECTION_URL", "\"https://commons.m.wikimedia.org/w/index.php?title=Main_Page&welcome=yes\"" buildConfigField "String", "SIGNUP_SUCCESS_REDIRECTION_URL", "\"https://commons.m.wikimedia.org/w/index.php?title=Main_Page&welcome=yes\""
buildConfigField "String", "FORGOT_PASSWORD_URL", "\"https://commons.wikimedia.org/wiki/Special:PasswordReset\""
dimension 'tier' dimension 'tier'
} }
@ -168,6 +169,7 @@ android {
buildConfigField "String", "EVENTLOG_WIKI", "\"commonswiki\"" buildConfigField "String", "EVENTLOG_WIKI", "\"commonswiki\""
buildConfigField "String", "SIGNUP_LANDING_URL", "\"https://commons.m.wikimedia.beta.wmflabs.org/w/index.php?title=Special:CreateAccount&returnto=Main+Page&returntoquery=welcome%3Dyes\"" buildConfigField "String", "SIGNUP_LANDING_URL", "\"https://commons.m.wikimedia.beta.wmflabs.org/w/index.php?title=Special:CreateAccount&returnto=Main+Page&returntoquery=welcome%3Dyes\""
buildConfigField "String", "SIGNUP_SUCCESS_REDIRECTION_URL", "\"https://commons.m.wikimedia.beta.wmflabs.org/w/index.php?title=Main_Page&welcome=yes\"" buildConfigField "String", "SIGNUP_SUCCESS_REDIRECTION_URL", "\"https://commons.m.wikimedia.beta.wmflabs.org/w/index.php?title=Main_Page&welcome=yes\""
buildConfigField "String", "FORGOT_PASSWORD_URL", "\"https://commons.wikimedia.beta.wmflabs.org/wiki/Special:PasswordReset\""
dimension 'tier' dimension 'tier'
} }
} }

View file

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

View file

@ -187,12 +187,23 @@
</LinearLayout> </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 <fr.free.nrw.commons.ui.widget.HtmlTextView
android:id="@+id/about_privacy_policy" android:id="@+id/about_privacy_policy"
style="?android:textAppearanceSmall" style="?android:textAppearanceSmall"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_below="@id/buttonFrame" android:layout_below="@id/forgotPassword"
android:layout_centerHorizontal="true" android:layout_centerHorizontal="true"
android:layout_gravity="center_horizontal" android:layout_gravity="center_horizontal"
android:layout_marginBottom="@dimen/standard_gap" android:layout_marginBottom="@dimen/standard_gap"

View file

@ -187,12 +187,23 @@
</LinearLayout> </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 <fr.free.nrw.commons.ui.widget.HtmlTextView
android:id="@+id/about_privacy_policy" android:id="@+id/about_privacy_policy"
style="?android:textAppearanceSmall" style="?android:textAppearanceSmall"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_below="@id/buttonFrame" android:layout_below="@id/forgotPassword"
android:layout_centerHorizontal="true" android:layout_centerHorizontal="true"
android:layout_gravity="center_horizontal" android:layout_gravity="center_horizontal"
android:layout_marginBottom="@dimen/standard_gap" android:layout_marginBottom="@dimen/standard_gap"

View file

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

View file

@ -7,6 +7,7 @@
<string name="password">Password</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="login">Log in</string>
<string name="forgot_password">Forgot Password?</string>
<string name="signup">Sign up</string> <string name="signup">Sign up</string>
<string name="logging_in_title">Logging in</string> <string name="logging_in_title">Logging in</string>
<string name="logging_in_message">Please wait…</string> <string name="logging_in_message">Please wait…</string>

View file

@ -1,5 +1,6 @@
#Sat Mar 03 13:58:47 IST 2018
distributionBase=GRADLE_USER_HOME distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-4.1-bin.zip distributionUrl=https\://services.gradle.org/distributions/gradle-4.1-all.zip