Skip to content

Commit de673eb

Browse files
madhurgupta10Vivek Maskara
authored andcommitted
Add Forgot Password Option in LoginActivity (commons-app#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
1 parent 57bfb7b commit de673eb

File tree

7 files changed

+56
-8
lines changed

7 files changed

+56
-8
lines changed

app/build.gradle

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -154,6 +154,7 @@ android {
154154
buildConfigField "String", "EVENTLOG_WIKI", "\"commonswiki\""
155155
buildConfigField "String", "SIGNUP_LANDING_URL", "\"https://commons.m.wikimedia.org/w/index.php?title=Special:CreateAccount&returnto=Main+Page&returntoquery=welcome%3Dyes\""
156156
buildConfigField "String", "SIGNUP_SUCCESS_REDIRECTION_URL", "\"https://commons.m.wikimedia.org/w/index.php?title=Main_Page&welcome=yes\""
157+
buildConfigField "String", "FORGOT_PASSWORD_URL", "\"https://commons.wikimedia.org/wiki/Special:PasswordReset\""
157158
dimension 'tier'
158159
}
159160

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

app/src/main/java/fr/free/nrw/commons/auth/LoginActivity.java

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
import android.app.ProgressDialog;
99
import android.content.Intent;
1010
import android.content.SharedPreferences;
11+
import android.net.Uri;
1112
import android.os.Bundle;
1213
import android.support.annotation.ColorRes;
1314
import android.support.annotation.NonNull;
@@ -27,6 +28,7 @@
2728
import android.widget.Button;
2829
import android.widget.EditText;
2930
import android.widget.TextView;
31+
import android.widget.Toast;
3032

3133
import java.io.IOException;
3234

@@ -44,6 +46,7 @@
4446
import fr.free.nrw.commons.di.ApplicationlessInjection;
4547
import fr.free.nrw.commons.mwapi.MediaWikiApi;
4648
import fr.free.nrw.commons.theme.NavigationBaseActivity;
49+
import fr.free.nrw.commons.ui.widget.HtmlTextView;
4750
import io.reactivex.Observable;
4851
import io.reactivex.android.schedulers.AndroidSchedulers;
4952
import io.reactivex.schedulers.Schedulers;
@@ -73,7 +76,9 @@ public class LoginActivity extends AccountAuthenticatorActivity {
7376
@BindView(R.id.error_message_container) ViewGroup errorMessageContainer;
7477
@BindView(R.id.error_message) TextView errorMessage;
7578
@BindView(R.id.login_credentials) TextView loginCredentials;
76-
@BindView(R.id.two_factor_container)TextInputLayout twoFactorContainer;
79+
@BindView(R.id.two_factor_container) TextInputLayout twoFactorContainer;
80+
@BindView(R.id.forgotPassword) HtmlTextView forgotPasswordText;
81+
7782
ProgressDialog progressDialog;
7883
private AppCompatDelegate delegate;
7984
private LoginTextWatcher textWatcher = new LoginTextWatcher();
@@ -114,13 +119,19 @@ public void onCreate(Bundle savedInstanceState) {
114119
loginButton.setOnClickListener(view -> performLogin());
115120
signupButton.setOnClickListener(view -> signUp());
116121

122+
forgotPasswordText.setOnClickListener(view -> forgotPassword());
123+
117124
if(BuildConfig.FLAVOR == "beta"){
118125
loginCredentials.setText(getString(R.string.login_credential));
119126
} else {
120127
loginCredentials.setVisibility(View.GONE);
121128
}
122129
}
123130

131+
private void forgotPassword() {
132+
Utils.handleWebUrl(this, Uri.parse(BuildConfig.FORGOT_PASSWORD_URL));
133+
}
134+
124135

125136
public void hideKeyboard(View view) {
126137
InputMethodManager inputMethodManager =(InputMethodManager)this.getSystemService(Activity.INPUT_METHOD_SERVICE);

app/src/main/res/layout-land/activity_login.xml

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -187,12 +187,23 @@
187187

188188
</LinearLayout>
189189

190+
<fr.free.nrw.commons.ui.widget.HtmlTextView
191+
android:visibility="visible"
192+
android:id="@+id/forgotPassword"
193+
android:layout_width="match_parent"
194+
android:gravity="center_horizontal"
195+
android:layout_height="wrap_content"
196+
android:layout_below="@id/buttonFrame"
197+
android:layout_marginBottom="@dimen/standard_gap"
198+
android:text="@string/forgot_password"
199+
android:textColor="@color/status_bar_blue"/>
200+
190201
<fr.free.nrw.commons.ui.widget.HtmlTextView
191202
android:id="@+id/about_privacy_policy"
192203
style="?android:textAppearanceSmall"
193204
android:layout_width="wrap_content"
194205
android:layout_height="wrap_content"
195-
android:layout_below="@id/buttonFrame"
206+
android:layout_below="@id/forgotPassword"
196207
android:layout_centerHorizontal="true"
197208
android:layout_gravity="center_horizontal"
198209
android:layout_marginBottom="@dimen/standard_gap"

app/src/main/res/layout-xlarge/activity_login.xml

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -187,12 +187,23 @@
187187

188188
</LinearLayout>
189189

190+
<fr.free.nrw.commons.ui.widget.HtmlTextView
191+
android:visibility="visible"
192+
android:id="@+id/forgotPassword"
193+
android:layout_width="match_parent"
194+
android:gravity="center_horizontal"
195+
android:layout_height="wrap_content"
196+
android:layout_below="@id/buttonFrame"
197+
android:layout_marginBottom="@dimen/standard_gap"
198+
android:text="@string/forgot_password"
199+
android:textColor="@color/status_bar_blue" />
200+
190201
<fr.free.nrw.commons.ui.widget.HtmlTextView
191202
android:id="@+id/about_privacy_policy"
192203
style="?android:textAppearanceSmall"
193204
android:layout_width="wrap_content"
194205
android:layout_height="wrap_content"
195-
android:layout_below="@id/buttonFrame"
206+
android:layout_below="@id/forgotPassword"
196207
android:layout_centerHorizontal="true"
197208
android:layout_gravity="center_horizontal"
198209
android:layout_marginBottom="@dimen/standard_gap"

app/src/main/res/layout/activity_login.xml

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
<FrameLayout
88
android:layout_width="match_parent"
99
android:layout_height="wrap_content"
10-
android:layout_gravity="center"
10+
android:layout_gravity="center_vertical"
1111
android:layout_marginTop="@dimen/small_gap">
1212

1313
<android.support.v7.widget.CardView
@@ -192,18 +192,30 @@
192192

193193
</LinearLayout>
194194

195+
<fr.free.nrw.commons.ui.widget.HtmlTextView
196+
android:visibility="visible"
197+
android:id="@+id/forgotPassword"
198+
android:layout_width="match_parent"
199+
android:gravity="center_horizontal"
200+
android:layout_height="wrap_content"
201+
android:layout_below="@id/buttonFrame"
202+
android:layout_marginBottom="@dimen/standard_gap"
203+
android:text="@string/forgot_password"
204+
android:textColor="@color/status_bar_blue" />
205+
195206
<fr.free.nrw.commons.ui.widget.HtmlTextView
196207
android:id="@+id/about_privacy_policy"
197208
style="?android:textAppearanceSmall"
198209
android:layout_width="wrap_content"
199210
android:layout_height="wrap_content"
200-
android:layout_below="@id/buttonFrame"
211+
android:layout_below="@id/forgotPassword"
201212
android:layout_centerHorizontal="true"
202213
android:layout_gravity="center_horizontal"
203214
android:layout_marginBottom="@dimen/standard_gap"
204215
android:text="@string/about_privacy_policy" />
205216

206217
</RelativeLayout>
218+
207219
</android.support.v7.widget.CardView>
208220

209221
<android.support.v7.widget.AppCompatImageView
@@ -222,7 +234,6 @@
222234
android:elevation="8dp"
223235
app:srcCompat="@drawable/commons_logo_large"
224236
tools:ignore="UnusedAttribute" />
225-
226237
</FrameLayout>
227238

228239
</ScrollView>

app/src/main/res/values/strings.xml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,9 @@
55
<string name="menu_settings">Settings</string>
66
<string name="username">Username</string>
77
<string name="password">Password</string>
8-
<string name="login_credential">Log in to your Commons Beta account</string>
8+
<string name="login_credential">Log in to your Commons Beta account</string>
99
<string name="login">Log in</string>
10+
<string name="forgot_password">Forgot Password?</string>
1011
<string name="signup">Sign up</string>
1112
<string name="logging_in_title">Logging in</string>
1213
<string name="logging_in_message">Please wait…</string>
Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
1+
#Sat Mar 03 13:58:47 IST 2018
12
distributionBase=GRADLE_USER_HOME
23
distributionPath=wrapper/dists
34
zipStoreBase=GRADLE_USER_HOME
45
zipStorePath=wrapper/dists
5-
distributionUrl=https\://services.gradle.org/distributions/gradle-4.1-bin.zip
6+
distributionUrl=https\://services.gradle.org/distributions/gradle-4.1-all.zip

0 commit comments

Comments
 (0)