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
3c5e6bc5
Commit
3c5e6bc5
authored
Sep 03, 2020
by
fauzi
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
menambahkan scroll view ke login dan register form
parent
c62d96a2
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
191 additions
and
179 deletions
+191
-179
LoginState.java
app/src/main/java/com/yono/messeripos/LoginState.java
+60
-72
empty.png
app/src/main/res/drawable/empty.png
+0
-0
login_image.png
app/src/main/res/drawable/login_image.png
+0
-0
register_image.png
app/src/main/res/drawable/register_image.png
+0
-0
visible_password.xml
app/src/main/res/drawable/visible_password.xml
+5
-0
login_form.xml
app/src/main/res/layout/login_form.xml
+107
-101
register_form.xml
app/src/main/res/layout/register_form.xml
+19
-6
No files found.
app/src/main/java/com/yono/messeripos/LoginState.java
View file @
3c5e6bc5
...
@@ -61,7 +61,6 @@ public class LoginState extends BottomSheetDialogFragment {
...
@@ -61,7 +61,6 @@ public class LoginState extends BottomSheetDialogFragment {
this
.
mainViewModels
=
mainViewModels
;
this
.
mainViewModels
=
mainViewModels
;
}
}
@NonNull
@NonNull
@Override
@Override
public
Dialog
onCreateDialog
(
@Nullable
Bundle
savedInstanceState
)
{
public
Dialog
onCreateDialog
(
@Nullable
Bundle
savedInstanceState
)
{
...
@@ -114,7 +113,6 @@ public class LoginState extends BottomSheetDialogFragment {
...
@@ -114,7 +113,6 @@ public class LoginState extends BottomSheetDialogFragment {
// close btn is clicked
// close btn is clicked
closeBtn
.
setOnClickListener
(
view12
->
{
closeBtn
.
setOnClickListener
(
view12
->
{
Log
.
d
(
TAG
,
"onCreateDialog: "
+
sheetBehavior
.
getState
());
sheetDialog
.
dismiss
();
sheetDialog
.
dismiss
();
});
});
...
@@ -134,14 +132,8 @@ public class LoginState extends BottomSheetDialogFragment {
...
@@ -134,14 +132,8 @@ public class LoginState extends BottomSheetDialogFragment {
}
else
{
}
else
{
/**
/**
* Jika tombol sign in ditekan
* Jika tombol sign in ditekan
*/
*
* nonaktifkan semua form */
// aktifkan progress bar
bar
.
setVisibility
(
View
.
VISIBLE
);
// hilangkan tulisan di button
loginButton
.
setText
(
""
);
// nonaktifkan semua form
username
.
setEnabled
(
false
);
username
.
setEnabled
(
false
);
password
.
setEnabled
(
false
);
password
.
setEnabled
(
false
);
loginButton
.
setEnabled
(
false
);
loginButton
.
setEnabled
(
false
);
...
@@ -150,74 +142,70 @@ public class LoginState extends BottomSheetDialogFragment {
...
@@ -150,74 +142,70 @@ public class LoginState extends BottomSheetDialogFragment {
// buat checking login
// buat checking login
mainViewModels
.
checkLogin
(
new
UsersModels
(
username
.
getText
().
toString
(),
mainViewModels
.
checkLogin
(
new
UsersModels
(
username
.
getText
().
toString
(),
password
.
getText
().
toString
()))
password
.
getText
().
toString
()))
.
observe
((
LifecycleOwner
)
context
,
new
Observer
<
DataResponse
<
UsersModels
>>()
{
.
observe
((
LifecycleOwner
)
context
,
usersModelsDataResponse
->
{
@SuppressLint
(
"ResourceType"
)
@Override
public
void
onChanged
(
DataResponse
<
UsersModels
>
usersModelsDataResponse
)
{
if
(
usersModelsDataResponse
!=
null
)
{
/**
* Jika response atau data ada dan cocok
*/
if
(
usersModelsDataResponse
.
getStatusData
())
{
SharedPreferences
.
Editor
editor
=
sharedPreferences
.
edit
();
editor
.
putBoolean
(
SplashScreen
.
SESSION
,
true
);
if
(
editor
.
commit
()){
startActivity
(
new
Intent
(
context
,
MainActivity
.
class
));
}
// redirect ke home
// set progress bar jadi nonaktif
if
(
usersModelsDataResponse
!=
null
)
{
bar
.
setVisibility
(
View
.
GONE
);
// munculkan tulisan default di button sign in
loginButton
.
setText
(
DEFAULT_LOGIN_NAME
);
// ubah sheet dialog jadi tidak bisa di slide atau cancel
sheetDialog
.
setCancelable
(
true
);
// set form jadi enable
username
.
setEnabled
(
true
);
password
.
setEnabled
(
true
);
loginButton
.
setEnabled
(
true
);
closeBtn
.
setEnabled
(
true
);
}
else
{
/**
/**
* Jika response atau data
tidak
cocok
* Jika response atau data
ada dan
cocok
*/
*/
if
(
usersModelsDataResponse
.
getStatusData
())
{
bar
.
setVisibility
(
View
.
GONE
);
SharedPreferences
.
Editor
editor
=
sharedPreferences
.
edit
();
loginButton
.
setText
(
DEFAULT_LOGIN_NAME
);
editor
.
putBoolean
(
SplashScreen
.
SESSION
,
true
);
if
(
editor
.
commit
()){
sheetDialog
.
setCancelable
(
true
);
startActivity
(
new
Intent
(
context
,
MainActivity
.
class
));
}
final
View
customLayout
=
getLayoutInflater
()
// redirect ke home
.
inflate
(
R
.
layout
.
alert_dialog
,
null
);
// set progress bar jadi nonaktif
bar
.
setVisibility
(
View
.
GONE
);
// tampilkan alert dialog
// munculkan tulisan default di button sign in
utils
=
new
Utils
(
customLayout
);
loginButton
.
setText
(
DEFAULT_LOGIN_NAME
);
utils
.
dialog
(
context
,
false
,
customLayout
,
"Wrong Username or Password"
,
"The username or password is incorrect. Please try again!"
,
// ubah sheet dialog jadi tidak bisa di slide atau cancel
"Try Again"
)
sheetDialog
.
setCancelable
(
true
);
.
show
();
utils
.
setListener
(
Dialog:
:
dismiss
);
// set form jadi enable
username
.
setEnabled
(
true
);
username
.
setEnabled
(
true
);
password
.
setEnabled
(
true
);
password
.
setEnabled
(
true
);
loginButton
.
setEnabled
(
true
);
loginButton
.
setEnabled
(
true
);
closeBtn
.
setEnabled
(
true
);
closeBtn
.
setEnabled
(
true
);
}
else
{
/**
* Jika response atau data tidak cocok
*/
bar
.
setVisibility
(
View
.
GONE
);
loginButton
.
setText
(
DEFAULT_LOGIN_NAME
);
sheetDialog
.
setCancelable
(
true
);
final
View
customLayout
=
getLayoutInflater
()
.
inflate
(
R
.
layout
.
alert_dialog
,
null
);
// tampilkan alert dialog
utils
=
new
Utils
(
customLayout
);
utils
.
dialog
(
context
,
false
,
customLayout
,
"Wrong Username or Password"
,
"The username or password is incorrect. Please try again!"
,
"Try Again"
)
.
show
();
utils
.
setListener
(
Dialog:
:
dismiss
);
username
.
setEnabled
(
true
);
password
.
setEnabled
(
true
);
loginButton
.
setEnabled
(
true
);
closeBtn
.
setEnabled
(
true
);
}
}
else
{
bar
.
setVisibility
(
View
.
VISIBLE
);
utils
.
snackBar
(
v
,
"Oppss! ログイン中にエラーが発生しました。しばらくしてからもう一度お試しください"
).
show
();
}
}
}
else
{
bar
.
setVisibility
(
View
.
VISIBLE
);
utils
.
snackBar
(
v
,
"Oppss! ログイン中にエラーが発生しました。しばらくしてからもう一度お試しください"
).
show
();
}
}
});
});
}
}
loginButton
.
setText
(
DEFAULT_LOGIN_NAME
);
loginButton
.
setText
(
DEFAULT_LOGIN_NAME
);
}
}
...
...
app/src/main/res/drawable/empty.png
0 → 100644
View file @
3c5e6bc5
38.9 KB
app/src/main/res/drawable/login_image.png
0 → 100644
View file @
3c5e6bc5
26.1 KB
app/src/main/res/drawable/register_image.png
0 → 100644
View file @
3c5e6bc5
25.3 KB
app/src/main/res/drawable/visible_password.xml
0 → 100644
View file @
3c5e6bc5
<vector
android:height=
"24dp"
android:tint=
"#B6B6B6"
android:viewportHeight=
"24"
android:viewportWidth=
"24"
android:width=
"24dp"
xmlns:android=
"http://schemas.android.com/apk/res/android"
>
<path
android:fillColor=
"@android:color/white"
android:pathData=
"M12,4.5C7,4.5 2.73,7.61 1,12c1.73,4.39 6,7.5 11,7.5s9.27,-3.11 11,-7.5c-1.73,-4.39 -6,-7.5 -11,-7.5zM12,17c-2.76,0 -5,-2.24 -5,-5s2.24,-5 5,-5 5,2.24 5,5 -2.24,5 -5,5zM12,9c-1.66,0 -3,1.34 -3,3s1.34,3 3,3 3,-1.34 3,-3 -1.34,-3 -3,-3z"
/>
</vector>
app/src/main/res/layout/login_form.xml
View file @
3c5e6bc5
...
@@ -26,112 +26,118 @@
...
@@ -26,112 +26,118 @@
android:scaleType=
"centerInside"
android:scaleType=
"centerInside"
android:src=
"@drawable/ic_close"
/>
android:src=
"@drawable/ic_close"
/>
<ImageView
<ScrollView
android:id=
"@+id/messerLogoInLogin"
android:layout_width=
"150dp"
android:layout_height=
"150dp"
android:layout_below=
"@id/closeBtnLogin"
android:layout_below=
"@id/closeBtnLogin"
android:layout_centerHorizontal=
"true"
android:layout_marginTop=
"20dp"
android:src=
"@drawable/ic_messer_primary"
/>
<com.google.android.material.textview.MaterialTextView
android:id=
"@+id/tvLogin"
android:layout_width=
"wrap_content"
android:layout_height=
"wrap_content"
android:layout_below=
"@id/messerLogoInLogin"
android:paddingLeft=
"12dp"
android:text=
"Login Your Account"
android:textColor=
"@color/colorPrimary"
android:textFontWeight=
"600"
android:textSize=
"16sp"
/>
<com.google.android.material.textfield.TextInputLayout
android:id=
"@+id/formUsernameLogin"
style=
"@style/Widget.MaterialComponents.TextInputLayout.OutlinedBox"
android:layout_width=
"match_parent"
android:layout_width=
"match_parent"
android:layout_height=
"wrap_content"
android:layout_height=
"match_parent"
>
android:layout_below=
"@id/tvLogin"
android:hint=
"@string/username"
>
<com.google.android.material.textfield.TextInputEditText
<RelativeLayout
android:id=
"@+id/ETUsernameLogin"
android:layout_width=
"match_parent"
android:layout_width=
"match_parent"
android:layout_height=
"match_parent"
>
<ImageView
android:id=
"@+id/messerLogoInLogin"
android:layout_width=
"wrap_content"
android:layout_height=
"213dp"
android:layout_centerHorizontal=
"true"
android:layout_marginTop=
"20dp"
android:layout_marginBottom=
"40dp"
android:src=
"@drawable/login_image"
/>
<com.google.android.material.textview.MaterialTextView
android:id=
"@+id/tvLogin"
android:layout_width=
"wrap_content"
android:layout_height=
"wrap_content"
android:layout_below=
"@id/messerLogoInLogin"
android:paddingLeft=
"12dp"
android:text=
"Login Your Account"
android:textColor=
"@color/colorPrimary"
android:textFontWeight=
"600"
android:textSize=
"16sp"
/>
<com.google.android.material.textfield.TextInputLayout
android:id=
"@+id/formUsernameLogin"
style=
"@style/Widget.MaterialComponents.TextInputLayout.OutlinedBox"
android:layout_width=
"match_parent"
android:layout_height=
"wrap_content"
android:layout_below=
"@id/tvLogin"
android:hint=
"@string/username"
>
<com.google.android.material.textfield.TextInputEditText
android:id=
"@+id/ETUsernameLogin"
android:layout_width=
"match_parent"
android:layout_height=
"wrap_content"
android:imeOptions=
"actionNext"
android:textColor=
"@color/colorPrimary"
android:inputType=
"text"
/>
</com.google.android.material.textfield.TextInputLayout>
<com.google.android.material.textfield.TextInputLayout
android:id=
"@+id/FormPasswordLogin"
style=
"@style/Widget.MaterialComponents.TextInputLayout.OutlinedBox"
android:layout_width=
"match_parent"
android:layout_height=
"wrap_content"
android:layout_below=
"@id/formUsernameLogin"
android:layout_marginTop=
"20dp"
android:hint=
"@string/password"
>
<com.google.android.material.textfield.TextInputEditText
android:id=
"@+id/ETPasswordLogin"
android:layout_width=
"match_parent"
android:layout_height=
"wrap_content"
android:imeOptions=
"actionDone|actionGo"
android:textColor=
"@color/colorPrimary"
android:inputType=
"textPassword"
/>
</com.google.android.material.textfield.TextInputLayout>
<androidx.constraintlayout.widget.ConstraintLayout
android:id=
"@+id/constraintBtn"
android:layout_below=
"@id/FormPasswordLogin"
android:layout_width=
"match_parent"
android:layout_height=
"wrap_content"
android:layout_marginTop=
"20dp"
>
<com.google.android.material.button.MaterialButton
android:id=
"@+id/SignInButtonInLogin"
android:layout_width=
"match_parent"
android:layout_height=
"wrap_content"
android:text=
"Sign in"
android:padding=
"20dp"
app:layout_constraintTop_toTopOf=
"parent"
app:layout_constraintBottom_toBottomOf=
"parent"
app:layout_constraintEnd_toEndOf=
"parent"
app:layout_constraintStart_toStartOf=
"parent"
/>
<ProgressBar
android:id=
"@+id/progressLogin"
style=
"?android:attr/progressBarStyle"
android:layout_width=
"wrap_content"
android:layout_height=
"wrap_content"
android:elevation=
"2dp"
app:layout_constraintBottom_toBottomOf=
"@id/SignInButtonInLogin"
app:layout_constraintTop_toTopOf=
"@id/SignInButtonInLogin"
app:layout_constraintStart_toStartOf=
"@id/SignInButtonInLogin"
app:layout_constraintEnd_toEndOf=
"@id/SignInButtonInLogin"
/>
</androidx.constraintlayout.widget.ConstraintLayout>
<com.google.android.material.textview.MaterialTextView
android:id=
"@+id/forgotPwd"
android:layout_width=
"wrap_content"
android:layout_height=
"wrap_content"
android:layout_height=
"wrap_content"
android:imeOptions=
"actionNext"
android:text=
"Forgot Password?"
android:inputType=
"text"
/>
android:layout_below=
"@id/constraintBtn"
android:layout_marginTop=
"10dp"
</com.google.android.material.textfield.TextInputLayout>
android:layout_alignParentEnd=
"true"
android:textColor=
"@color/colorPrimary"
/>
<com.google.android.material.textfield.TextInputLayout
android:id=
"@+id/FormPasswordLogin"
</RelativeLayout>
style=
"@style/Widget.MaterialComponents.TextInputLayout.OutlinedBox"
</ScrollView>
android:layout_width=
"match_parent"
android:layout_height=
"wrap_content"
android:layout_below=
"@id/formUsernameLogin"
android:layout_marginTop=
"20dp"
android:hint=
"@string/password"
>
<com.google.android.material.textfield.TextInputEditText
android:id=
"@+id/ETPasswordLogin"
android:layout_width=
"match_parent"
android:layout_height=
"wrap_content"
android:imeOptions=
"actionDone|actionGo"
android:inputType=
"textPassword"
/>
</com.google.android.material.textfield.TextInputLayout>
<CheckBox
android:id=
"@+id/CBRememberMe"
android:layout_width=
"wrap_content"
android:layout_height=
"wrap_content"
android:layout_below=
"@id/FormPasswordLogin"
android:layout_marginVertical=
"10dp"
android:text=
"Remember Me"
android:textColor=
"@color/colorPrimary"
app:useMaterialThemeColors=
"true"
/>
<androidx.constraintlayout.widget.ConstraintLayout
android:id=
"@+id/constraintBtn"
android:layout_below=
"@id/CBRememberMe"
android:layout_width=
"match_parent"
android:layout_height=
"wrap_content"
>
<com.google.android.material.button.MaterialButton
android:id=
"@+id/SignInButtonInLogin"
android:layout_width=
"match_parent"
android:layout_height=
"wrap_content"
android:text=
"Sign in"
android:padding=
"20dp"
app:layout_constraintTop_toTopOf=
"parent"
app:layout_constraintBottom_toBottomOf=
"parent"
app:layout_constraintEnd_toEndOf=
"parent"
app:layout_constraintStart_toStartOf=
"parent"
/>
<ProgressBar
android:id=
"@+id/progressLogin"
style=
"?android:attr/progressBarStyle"
android:layout_width=
"wrap_content"
android:layout_height=
"wrap_content"
android:elevation=
"2dp"
app:layout_constraintBottom_toBottomOf=
"@id/SignInButtonInLogin"
app:layout_constraintTop_toTopOf=
"@id/SignInButtonInLogin"
app:layout_constraintStart_toStartOf=
"@id/SignInButtonInLogin"
app:layout_constraintEnd_toEndOf=
"@id/SignInButtonInLogin"
/>
</androidx.constraintlayout.widget.ConstraintLayout>
<com.google.android.material.textview.MaterialTextView
android:id=
"@+id/forgotPwd"
android:layout_width=
"wrap_content"
android:layout_height=
"wrap_content"
android:text=
"Forgot Password?"
android:layout_below=
"@id/constraintBtn"
android:layout_marginTop=
"10dp"
android:layout_alignParentEnd=
"true"
android:textColor=
"@color/colorPrimary"
/>
</RelativeLayout>
</RelativeLayout>
</androidx.coordinatorlayout.widget.CoordinatorLayout>
</androidx.coordinatorlayout.widget.CoordinatorLayout>
...
...
app/src/main/res/layout/register_form.xml
View file @
3c5e6bc5
...
@@ -25,12 +25,22 @@
...
@@ -25,12 +25,22 @@
/>
/>
<ScrollView
android:layout_below=
"@id/ivclose"
android:layout_width=
"match_parent"
android:layout_height=
"match_parent"
>
<RelativeLayout
android:layout_width=
"match_parent"
android:layout_height=
"match_parent"
>
<ImageView
<ImageView
android:id=
"@+id/ivMeserRegister"
android:id=
"@+id/ivMeserRegister"
android:layout_width=
"150dp"
android:layout_width=
"match_parent"
android:layout_height=
"150dp"
android:layout_height=
"213dp"
android:src=
"@drawable/ic_messer_primary"
android:src=
"@drawable/register_image"
android:layout_below=
"@+id/ivclose"
android:layout_marginTop=
"20dp"
android:layout_marginBottom=
"40dp"
android:layout_centerHorizontal=
"true"
/>
android:layout_centerHorizontal=
"true"
/>
<com.google.android.material.textview.MaterialTextView
<com.google.android.material.textview.MaterialTextView
...
@@ -45,8 +55,6 @@
...
@@ -45,8 +55,6 @@
android:paddingLeft=
"12dp"
android:paddingLeft=
"12dp"
/>
/>
<com.google.android.material.textfield.TextInputLayout
<com.google.android.material.textfield.TextInputLayout
android:id=
"@+id/formUsernameReg"
android:id=
"@+id/formUsernameReg"
android:layout_width=
"match_parent"
android:layout_width=
"match_parent"
...
@@ -141,6 +149,11 @@
...
@@ -141,6 +149,11 @@
android:text=
"Create Account"
android:text=
"Create Account"
android:layout_below=
"@id/cbAgree"
android:layout_below=
"@id/cbAgree"
android:padding=
"20dp"
/>
android:padding=
"20dp"
/>
</RelativeLayout>
</ScrollView>
</RelativeLayout>
</RelativeLayout>
</androidx.coordinatorlayout.widget.CoordinatorLayout>
</androidx.coordinatorlayout.widget.CoordinatorLayout>
...
...
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