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
22966800
Commit
22966800
authored
Sep 01, 2020
by
iman Fauzi
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add content dashboard login
parent
fdd71a8b
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
112 additions
and
65 deletions
+112
-65
LoginActivity.java
app/src/main/java/com/yono/messeripos/LoginActivity.java
+61
-60
gradient.xml
app/src/main/res/drawable/gradient.xml
+1
-1
dashboard_login.xml
app/src/main/res/layout/dashboard_login.xml
+49
-4
colors.xml
app/src/main/res/values/colors.xml
+1
-0
No files found.
app/src/main/java/com/yono/messeripos/LoginActivity.java
View file @
22966800
...
...
@@ -34,71 +34,72 @@ public class LoginActivity extends AppCompatActivity {
@Override
protected
void
onCreate
(
Bundle
savedInstanceState
)
{
super
.
onCreate
(
savedInstanceState
);
setContentView
(
R
.
layout
.
dashboard_login
);
if
(
Build
.
VERSION
.
SDK_INT
>=
Build
.
VERSION_CODES
.
KITKAT
)
{
Window
w
=
getWindow
();
w
.
setFlags
(
WindowManager
.
LayoutParams
.
FLAG_LAYOUT_NO_LIMITS
,
WindowManager
.
LayoutParams
.
FLAG_LAYOUT_NO_LIMITS
);
}
setContentView
(
R
.
layout
.
activity_login_m
);
username
=
findViewById
(
R
.
id
.
tiUsername
);
password
=
findViewById
(
R
.
id
.
tiPassword
);
btnLogin
=
findViewById
(
R
.
id
.
btnLogin
);
progressBar
=
findViewById
(
R
.
id
.
progressBar
);
progressBar
.
setVisibility
(
View
.
GONE
);
mainViewModels
=
ViewModelProviders
.
of
(
this
).
get
(
MainViewModels
.
class
);
sharedPreferences
=
getSharedPreferences
(
SplashScreen
.
MY_SHARED_PREFERENCES
,
Context
.
MODE_PRIVATE
);
btnLogin
.
setOnClickListener
(
new
View
.
OnClickListener
()
{
@Override
public
void
onClick
(
View
v
)
{
Snackbar
snackbar
=
Snackbar
.
make
(
v
,
"Oppss! Wrong Username Or Password!"
,
Snackbar
.
LENGTH_LONG
);
if
(
TextUtils
.
isEmpty
(
username
.
getText
().
toString
())
&&
TextUtils
.
isEmpty
(
password
.
getText
().
toString
())){
username
.
setError
(
"This field can't empty"
);
password
.
setError
(
"This field can't empty"
);
}
else
if
(
TextUtils
.
isEmpty
(
username
.
getText
().
toString
())){
username
.
setError
(
"This field can't empty"
);
}
else
if
(
TextUtils
.
isEmpty
(
password
.
getText
().
toString
())){
password
.
setError
(
"This field can't empty"
);
}
else
{
progressBar
.
setVisibility
(
View
.
VISIBLE
);
username
.
setEnabled
(
false
);
password
.
setEnabled
(
false
);
btnLogin
.
setEnabled
(
false
);
mainViewModels
.
checkLogin
(
new
UsersModels
(
username
.
getText
().
toString
(),
password
.
getText
().
toString
())).
observe
(
LoginActivity
.
this
,
new
Observer
<
DataResponse
<
UsersModels
>>()
{
@Override
public
void
onChanged
(
DataResponse
<
UsersModels
>
usersModelsDataResponse
)
{
Log
.
d
(
"Status"
,
usersModelsDataResponse
.
getMessageData
());
if
(
usersModelsDataResponse
.
getStatusData
()){
SharedPreferences
.
Editor
editor
=
sharedPreferences
.
edit
();
editor
.
putBoolean
(
SplashScreen
.
SESSION
,
true
);
editor
.
commit
();
startActivity
(
new
Intent
(
LoginActivity
.
this
,
MainActivity
.
class
));
progressBar
.
setVisibility
(
View
.
GONE
);
username
.
setEnabled
(
true
);
password
.
setEnabled
(
true
);
btnLogin
.
setEnabled
(
true
);
}
else
{
snackbar
.
show
();
progressBar
.
setVisibility
(
View
.
GONE
);
username
.
setEnabled
(
true
);
password
.
setEnabled
(
true
);
btnLogin
.
setEnabled
(
true
);
}
}
});
}
}
});
//
//
setContentView(R.layout.activity_login_m);
//
username = findViewById(R.id.tiUsername);
//
password = findViewById(R.id.tiPassword);
//
btnLogin = findViewById(R.id.btnLogin);
//
progressBar = findViewById(R.id.progressBar);
//
progressBar.setVisibility(View.GONE);
//
mainViewModels = ViewModelProviders.of(this).get(MainViewModels.class);
//
//
sharedPreferences = getSharedPreferences(SplashScreen.MY_SHARED_PREFERENCES, Context.MODE_PRIVATE);
//
//
btnLogin.setOnClickListener(new View.OnClickListener() {
//
@Override
//
public void onClick(View v) {
//
Snackbar snackbar = Snackbar.make(v, "Oppss! Wrong Username Or Password!", Snackbar.LENGTH_LONG);
//
//
if (TextUtils.isEmpty(username.getText().toString()) &&
//
TextUtils.isEmpty(password.getText().toString())){
//
username.setError("This field can't empty");
//
password.setError("This field can't empty");
//
}else if (TextUtils.isEmpty(username.getText().toString())){
//
username.setError("This field can't empty");
//
}else if (TextUtils.isEmpty(password.getText().toString())){
//
password.setError("This field can't empty");
//
}else{
//
progressBar.setVisibility(View.VISIBLE);
//
username.setEnabled(false);
//
password.setEnabled(false);
//
btnLogin.setEnabled(false);
//
//
mainViewModels.checkLogin(new UsersModels(username.getText().toString(),
//
password.getText().toString())).observe(LoginActivity.this, new Observer<DataResponse<UsersModels>>() {
//
@Override
//
public void onChanged(DataResponse<UsersModels> usersModelsDataResponse) {
//
Log.d("Status", usersModelsDataResponse.getMessageData());
//
//
if (usersModelsDataResponse.getStatusData()){
//
SharedPreferences.Editor editor = sharedPreferences.edit();
//
editor.putBoolean(SplashScreen.SESSION, true);
//
editor.commit();
//
//
startActivity(new Intent(LoginActivity.this, MainActivity.class));
//
//
progressBar.setVisibility(View.GONE);
//
username.setEnabled(true);
//
password.setEnabled(true);
//
btnLogin.setEnabled(true);
//
}else {
//
snackbar.show();
//
progressBar.setVisibility(View.GONE);
//
username.setEnabled(true);
//
password.setEnabled(true);
//
btnLogin.setEnabled(true);
//
}
//
//
}
//
});
//
}
//
}
//
});
}
}
\ No newline at end of file
app/src/main/res/drawable/gradient.xml
View file @
22966800
...
...
@@ -2,7 +2,7 @@
<selector
xmlns:android=
"http://schemas.android.com/apk/res/android"
>
<item>
<shape>
<gradient
android:startColor=
"@color/colorPrimary"
android:
endColor=
"@color/colorPrimaryDark"
android:angle=
"90
"
/>
<gradient
android:startColor=
"@color/colorPrimary"
android:
centerColor=
"@color/colorPrimaryCenter"
android:endColor=
"@color/colorPrimaryDark"
android:angle=
"-90"
android:centerY=
"0.7
"
/>
</shape>
</item>
</selector>
\ No newline at end of file
app/src/main/res/layout/dashboard_login.xml
View file @
22966800
<?xml version="1.0" encoding="utf-8"?>
<androidx.coordinatorlayout.widget.CoordinatorLayout
android:layout_width=
"match_parent"
<androidx.coordinatorlayout.widget.CoordinatorLayout
android:layout_width=
"match_parent"
android:layout_height=
"match_parent"
xmlns:app=
"http://schemas.android.com/apk/res-auto"
xmlns:tools=
"http://schemas.android.com/tools"
android:background=
"@drawable/gradient"
xmlns:android=
"http://schemas.android.com/apk/res/android"
>
xmlns:android=
"http://schemas.android.com/apk/res/android"
tools:context=
".LoginActivity"
>
<RelativeLayout
android:layout_width=
"match_parent"
android:layout_height=
"match_parent"
>
android:layout_height=
"match_parent"
android:paddingHorizontal=
"20dp"
android:paddingVertical=
"25dp"
>
<ImageView
android:id=
"@+id/messerLogoDashboardLogin"
...
...
@@ -17,6 +21,47 @@
android:layout_centerHorizontal=
"true"
android:layout_marginTop=
"50dp"
/>
<com.google.android.material.textview.MaterialTextView
android:layout_width=
"wrap_content"
android:layout_height=
"wrap_content"
android:text=
"messer"
android:textSize=
"30dp"
android:fontFamily=
"@font/poppins_bold"
android:textStyle=
"bold"
android:textColor=
"@color/colorWhite"
android:layout_below=
"@id/messerLogoDashboardLogin"
android:layout_centerHorizontal=
"true"
/>
<com.google.android.material.button.MaterialButton
android:id=
"@+id/signUpButtonDashboardLogin"
android:layout_width=
"match_parent"
android:layout_height=
"wrap_content"
style=
"?attr/materialButtonOutlinedStyle"
app:strokeColor=
"#fff"
android:text=
"sign up"
android:textStyle=
"bold"
android:textColor=
"#fff"
app:strokeWidth=
"2dp"
app:rippleColor=
"@color/colorWhite"
android:padding=
"20dp"
app:cornerRadius=
"5dp"
android:layout_above=
"@id/signInButtonDashboardLogin"
android:layout_marginBottom=
"10dp"
/>
<com.google.android.material.button.MaterialButton
android:id=
"@+id/signInButtonDashboardLogin"
android:layout_width=
"match_parent"
android:layout_height=
"wrap_content"
android:backgroundTint=
"@color/colorWhite"
android:layout_alignParentBottom=
"true"
android:padding=
"20dp"
android:text=
"sign in"
android:textStyle=
"bold"
app:rippleColor=
"#A8A8A8"
app:cornerRadius=
"5dp"
android:textColor=
"@color/colorPrimary"
/>
</RelativeLayout>
...
...
app/src/main/res/values/colors.xml
View file @
22966800
<?xml version="1.0" encoding="utf-8"?>
<resources>
<color
name=
"colorPrimary"
>
#4d089a
</color>
<color
name=
"colorPrimaryCenter"
>
#4021B9
</color>
<color
name=
"colorPrimaryDark"
>
#323edd
</color>
<color
name=
"colorAccent"
>
#dc2ade
</color>
<color
name=
"colorAccentDark"
>
#e8f044
</color>
...
...
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