Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in / Register
Toggle navigation
M
meser
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Muhammad Suryono
meser
Commits
372a38b6
Commit
372a38b6
authored
Sep 04, 2020
by
fauzi
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
forgot password
🐛
parent
f4aa3bf7
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
175 additions
and
75 deletions
+175
-75
ForgotCode.java
app/src/main/java/com/yono/messeripos/ForgotCode.java
+6
-5
ForgotPassword.java
app/src/main/java/com/yono/messeripos/ForgotPassword.java
+97
-0
ForgotPasswordActivity.java
...main/java/com/yono/messeripos/ForgotPasswordActivity.java
+3
-1
UsersService.java
...in/java/com/yono/messeripos/api/service/UsersService.java
+3
-0
ForgotPasswordModels.java
...java/com/yono/messeripos/models/ForgotPasswordModels.java
+11
-0
Utils.java
app/src/main/java/com/yono/messeripos/utils/Utils.java
+2
-2
forgot_new_password.xml
app/src/main/res/layout/forgot_new_password.xml
+53
-67
No files found.
app/src/main/java/com/yono/messeripos/ForgotCode.java
View file @
372a38b6
...
...
@@ -36,13 +36,12 @@ public class ForgotCode extends BottomSheetDialogFragment {
RelativeLayout
fpass
;
View
view
;
PinEntryEditText
pinEntry
;
DataResponse
response
;
ForgotPasswordModels
forgotPasswordModels
;
Context
context
;
public
ForgotCode
(
Context
context
,
DataResponse
response
)
{
public
ForgotCode
(
Context
context
,
ForgotPasswordModels
forgotPasswordModels
)
{
this
.
context
=
context
;
this
.
response
=
response
;
this
.
forgotPasswordModels
=
forgotPasswordModels
;
}
@NonNull
...
...
@@ -64,7 +63,7 @@ public class ForgotCode extends BottomSheetDialogFragment {
sheetBehavior
=
BottomSheetBehavior
.
from
((
View
)
(
view
.
getParent
()));
// get Window size
int
setHeight
=
utils
.
getWindowHeight
()
-
(
utils
.
getWindowHeight
()
*
5
0
)
/
100
;
int
setHeight
=
utils
.
getWindowHeight
()
-
(
utils
.
getWindowHeight
()
*
5
)
/
100
;
// set max height
sheetBehavior
.
setPeekHeight
(
setHeight
);
...
...
@@ -80,7 +79,9 @@ public class ForgotCode extends BottomSheetDialogFragment {
@Override
public
void
onPinEntered
(
CharSequence
str
)
{
if
(
str
.
toString
().
equals
(
forgotPasswordModels
.
getMessage
()))
{
Toast
.
makeText
(
context
,
"SUCCESS"
,
Toast
.
LENGTH_SHORT
).
show
();
ForgotPassword
forgotPassword
=
new
ForgotPassword
(
context
,
forgotPasswordModels
);
forgotPassword
.
setCancelable
(
false
);
forgotPassword
.
show
(
getActivity
().
getSupportFragmentManager
(),
"Forgot Confirm"
);
}
else
{
Toast
.
makeText
(
context
,
"FAIL"
,
Toast
.
LENGTH_SHORT
).
show
();
pinEntry
.
setText
(
null
);
...
...
app/src/main/java/com/yono/messeripos/ForgotPassword.java
0 → 100644
View file @
372a38b6
package
com
.
yono
.
messeripos
;
import
android.app.AlertDialog
;
import
android.app.Dialog
;
import
android.content.Context
;
import
android.content.Intent
;
import
android.os.Bundle
;
import
android.util.Log
;
import
android.view.View
;
import
android.widget.RelativeLayout
;
import
androidx.annotation.NonNull
;
import
androidx.annotation.Nullable
;
import
com.google.android.material.bottomsheet.BottomSheetBehavior
;
import
com.google.android.material.bottomsheet.BottomSheetDialog
;
import
com.google.android.material.bottomsheet.BottomSheetDialogFragment
;
import
com.google.android.material.button.MaterialButton
;
import
com.google.android.material.textfield.TextInputEditText
;
import
com.yono.messeripos.api.service.UsersService
;
import
com.yono.messeripos.models.ForgotPasswordModels
;
import
com.yono.messeripos.models.UsersModels
;
import
com.yono.messeripos.response.DataResponse
;
import
com.yono.messeripos.utils.Utils
;
import
retrofit2.Call
;
import
retrofit2.Callback
;
import
retrofit2.Response
;
public
class
ForgotPassword
extends
BottomSheetDialogFragment
{
BottomSheetDialog
sheetDialog
;
BottomSheetBehavior
sheetBehavior
;
View
view
;
RelativeLayout
resetPassUI
;
Utils
utils
=
new
Utils
();
TextInputEditText
newPass
,
etConfPass
;
MaterialButton
btnReset
;
Context
context
;
UsersService
usersService
;
ForgotPasswordModels
forgotPasswordModels
;
public
ForgotPassword
(
Context
context
,
ForgotPasswordModels
forgotPasswordModels
)
{
this
.
context
=
context
;
this
.
forgotPasswordModels
=
forgotPasswordModels
;
}
@NonNull
@Override
public
Dialog
onCreateDialog
(
@Nullable
Bundle
savedInstanceState
)
{
sheetDialog
=
(
BottomSheetDialog
)
super
.
onCreateDialog
(
savedInstanceState
);
// inflating layout
view
=
View
.
inflate
(
getContext
(),
R
.
layout
.
forgot_new_password
,
null
);
// bindUI
resetPassUI
=
view
.
findViewById
(
R
.
id
.
resetPassword
);
newPass
=
view
.
findViewById
(
R
.
id
.
etNewPassword
);
etConfPass
=
view
.
findViewById
(
R
.
id
.
etPasswordConfirmation
);
btnReset
=
view
.
findViewById
(
R
.
id
.
btnReset
);
sheetDialog
.
setContentView
(
view
);
sheetBehavior
=
BottomSheetBehavior
.
from
((
View
)
(
view
.
getParent
()));
// get Window size
int
setHeight
=
utils
.
getWindowHeight
()
-
(
utils
.
getWindowHeight
()
*
5
)
/
100
;
// set max height
sheetBehavior
.
setPeekHeight
(
setHeight
);
resetPassUI
.
setMinimumHeight
(
setHeight
);
btnReset
.
setOnClickListener
(
new
View
.
OnClickListener
()
{
@Override
public
void
onClick
(
View
view
)
{
String
newPas
=
newPass
.
getText
().
toString
();
String
conPass
=
etConfPass
.
getText
().
toString
();
forgotPasswordModels
.
setPassword
(
newPass
.
getText
().
toString
());
if
(
newPas
.
equals
(
conPass
))
{
sheetDialog
.
dismiss
();
usersService
.
resetPassword
(
forgotPasswordModels
);
startActivity
(
new
Intent
(
context
,
LoginActivity
.
class
));
getActivity
().
finish
();
}
else
{
utils
.
dialog
(
context
,
true
,
"password does't match"
,
"Your password not match!"
).
show
();
}
}
});
return
sheetDialog
;
}
}
app/src/main/java/com/yono/messeripos/ForgotPasswordActivity.java
View file @
372a38b6
...
...
@@ -59,7 +59,9 @@ public class ForgotPasswordActivity extends AppCompatActivity {
usersService
.
postForgotPassword
(
forgotPasswordModels
).
enqueue
(
new
Callback
<
DataResponse
>()
{
@Override
public
void
onResponse
(
Call
<
DataResponse
>
call
,
Response
<
DataResponse
>
response
)
{
forgotCode
=
new
ForgotCode
(
ForgotPasswordActivity
.
this
,
response
.
body
());
forgotCode
=
new
ForgotCode
(
ForgotPasswordActivity
.
this
,
forgotPasswordModels
);
forgotCode
.
setCancelable
(
false
);
forgotCode
.
show
(
getSupportFragmentManager
(),
"forgot code"
);
}
...
...
app/src/main/java/com/yono/messeripos/api/service/UsersService.java
View file @
372a38b6
...
...
@@ -18,4 +18,7 @@ public interface UsersService {
@POST
(
ApiHelper
.
VERSI_API_1
+
"forgot-password"
)
Call
<
DataResponse
>
postForgotPassword
(
@Body
ForgotPasswordModels
forgotPasswordModels
);
@POST
(
ApiHelper
.
VERSI_API_1
+
"reset-password"
)
Call
<
DataResponse
>
resetPassword
(
@Body
ForgotPasswordModels
forgotPasswordModels
);
}
app/src/main/java/com/yono/messeripos/models/ForgotPasswordModels.java
View file @
372a38b6
...
...
@@ -9,6 +9,9 @@ public class ForgotPasswordModels {
@SerializedName
(
"message"
)
private
String
message
;
@SerializedName
(
"password"
)
private
String
password
;
public
ForgotPasswordModels
()
{
}
...
...
@@ -32,4 +35,12 @@ public class ForgotPasswordModels {
public
void
setMessage
(
String
message
)
{
this
.
message
=
message
;
}
public
String
getPassword
()
{
return
password
;
}
public
void
setPassword
(
String
password
)
{
this
.
password
=
password
;
}
}
app/src/main/java/com/yono/messeripos/utils/Utils.java
View file @
372a38b6
...
...
@@ -399,9 +399,9 @@ public class Utils {
// It will generate 6 digit random Number.
// from 0 to 999999
Random
rnd
=
new
Random
();
int
number
=
rnd
.
nextInt
(
9999
99
);
int
number
=
rnd
.
nextInt
(
9999
);
// this will convert any number sequence into 6 character.
return
String
.
format
(
"%0
6
d"
,
number
);
return
String
.
format
(
"%0
4
d"
,
number
);
}
}
app/src/main/res/layout/forgot_new_password.xml
View file @
372a38b6
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout
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:fitsSystemWindows=
"true"
>
<layout
xmlns:android=
"http://schemas.android.com/apk/res/android"
xmlns:app=
"http://schemas.android.com/apk/res-auto"
>
<com.google.android.material.textfield.TextInputLayout
android:id=
"@+id/tfCurrentPassword"
android:layout_width=
"match_parent"
android:layout_height=
"wrap_content"
android:layout_margin=
"10dp"
android:hint=
"Current Password"
android:textColor=
"#fff"
style=
"@style/Widget.MaterialComponents.TextInputLayout.OutlinedBox"
tools:ignore=
"MissingConstraints"
>
<androidx.coordinatorlayout.widget.CoordinatorLayout
xmlns:tools=
"http://schemas.android.com/tools"
android:layout_height=
"match_parent"
android:layout_width=
"match_parent"
>
<com.google.android.material.textfield.TextInputEditText
android:id=
"@+id/etCurrentPassword"
<RelativeLayout
android:id=
"@+id/resetPassword"
xmlns:tools=
"http://schemas.android.com/tools"
android:layout_width=
"match_parent"
android:inputType=
"textPassword"
android:imeOptions=
"actionNext"
android:layout_height=
"wrap_content"
/>
android:layout_height=
"match_parent"
android:fitsSystemWindows=
"true"
>
</com.google.android.material.textfield.TextInputLayout>
<com.google.android.material.textfield.TextInputLayout
android:id=
"@+id/tfNewPassword"
android:layout_width=
"match_parent"
android:layout_height=
"wrap_content"
android:layout_margin=
"10dp"
android:hint=
"New Password"
android:textColor=
"#fff"
style=
"@style/Widget.MaterialComponents.TextInputLayout.OutlinedBox"
>
<com.google.android.material.textfield.TextInputLayout
android:id=
"@+id/tfNewPassword"
android:layout_width=
"match_parent"
android:layout_height=
"wrap_content"
android:layout_margin=
"10dp"
android:hint=
"New Password"
android:textColor=
"#fff"
style=
"@style/Widget.MaterialComponents.TextInputLayout.OutlinedBox"
app:layout_constraintTop_toBottomOf=
"@id/tfCurrentPassword"
>
<com.google.android.material.textfield.TextInputEditText
android:id=
"@+id/etNewPassword"
android:layout_width=
"match_parent"
android:inputType=
"textPassword"
android:imeOptions=
"actionNext"
android:layout_height=
"wrap_content"
/>
<com.google.android.material.textfield.TextInputEditText
android:id=
"@+id/etNewPassword"
android:layout_width=
"match_parent"
android:inputType=
"textPassword"
android:imeOptions=
"actionNext"
android:layout_height=
"wrap_content"
/>
</com.google.android.material.textfield.TextInputLayout>
</com.google.android.material.textfield.TextInputLayout>
<com.google.android.material.textfield.TextInputLayout
android:id=
"@+id/tfPasswordConfirmation"
style=
"@style/Widget.MaterialComponents.TextInputLayout.OutlinedBox"
android:layout_width=
"match_parent"
android:layout_height=
"wrap_content"
android:layout_margin=
"10dp"
android:hint=
"Password Confirmation"
android:textColor=
"#fff"
app:layout_constraintTop_toBottomOf=
"@id/tfNewPassword"
tools:layout_editor_absoluteX=
"10dp"
>
<com.google.android.material.textfield.TextInputEditText
android:id=
"@+id/etPasswordConfirmation"
android:layout_width=
"match_parent"
android:layout_height=
"wrap_content"
android:inputType=
"textPassword"
android:imeOptions=
"actionNext"
/>
<com.google.android.material.textfield.TextInputLayout
android:id=
"@+id/tfPasswordConfirmation"
style=
"@style/Widget.MaterialComponents.TextInputLayout.OutlinedBox"
android:layout_width=
"match_parent"
android:layout_height=
"wrap_content"
android:layout_margin=
"10dp"
android:hint=
"Password Confirmation"
android:textColor=
"#fff"
android:layout_below=
"@id/tfNewPassword"
>
</com.google.android.material.textfield.TextInputLayout>
<com.google.android.material.textfield.TextInputEditText
android:id=
"@+id/etPasswordConfirmation"
android:layout_width=
"match_parent"
android:layout_height=
"wrap_content"
android:inputType=
"textPassword"
android:imeOptions=
"actionNext"
/>
<com.google.android.material.button.MaterialButton
android:id=
"@+id/btnAdd"
android:layout_width=
"match_parent"
android:layout_height=
"wrap_content"
android:layout_margin=
"10dp"
android:text=
"@string/add"
android:padding=
"16dp"
app:layout_constraintTop_toBottomOf=
"@id/tfPasswordConfirmation"
tools:ignore=
"MissingConstraints"
/>
</com.google.android.material.textfield.TextInputLayout>
<com.google.android.material.button.MaterialButton
android:id=
"@+id/btnReset"
android:layout_width=
"match_parent"
android:layout_height=
"wrap_content"
android:layout_margin=
"10dp"
android:text=
"@string/btn_reset_password"
android:padding=
"16dp"
android:layout_below=
"@id/tfPasswordConfirmation"
/>
</androidx.constraintlayout.widget.ConstraintLayout>
\ No newline at end of file
</RelativeLayout>
</androidx.coordinatorlayout.widget.CoordinatorLayout>
</layout>
\ No newline at end of file
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment