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
Hide 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 {
...
@@ -34,71 +34,72 @@ public class LoginActivity extends AppCompatActivity {
@Override
@Override
protected
void
onCreate
(
Bundle
savedInstanceState
)
{
protected
void
onCreate
(
Bundle
savedInstanceState
)
{
super
.
onCreate
(
savedInstanceState
);
super
.
onCreate
(
savedInstanceState
);
setContentView
(
R
.
layout
.
dashboard_login
);
if
(
Build
.
VERSION
.
SDK_INT
>=
Build
.
VERSION_CODES
.
KITKAT
)
{
if
(
Build
.
VERSION
.
SDK_INT
>=
Build
.
VERSION_CODES
.
KITKAT
)
{
Window
w
=
getWindow
();
Window
w
=
getWindow
();
w
.
setFlags
(
WindowManager
.
LayoutParams
.
FLAG_LAYOUT_NO_LIMITS
,
WindowManager
.
LayoutParams
.
FLAG_LAYOUT_NO_LIMITS
);
w
.
setFlags
(
WindowManager
.
LayoutParams
.
FLAG_LAYOUT_NO_LIMITS
,
WindowManager
.
LayoutParams
.
FLAG_LAYOUT_NO_LIMITS
);
}
}
//
setContentView
(
R
.
layout
.
activity_login_m
);
//
setContentView(R.layout.activity_login_m);
username
=
findViewById
(
R
.
id
.
tiUsername
);
//
username = findViewById(R.id.tiUsername);
password
=
findViewById
(
R
.
id
.
tiPassword
);
//
password = findViewById(R.id.tiPassword);
btnLogin
=
findViewById
(
R
.
id
.
btnLogin
);
//
btnLogin = findViewById(R.id.btnLogin);
progressBar
=
findViewById
(
R
.
id
.
progressBar
);
//
progressBar = findViewById(R.id.progressBar);
progressBar
.
setVisibility
(
View
.
GONE
);
//
progressBar.setVisibility(View.GONE);
mainViewModels
=
ViewModelProviders
.
of
(
this
).
get
(
MainViewModels
.
class
);
//
mainViewModels = ViewModelProviders.of(this).get(MainViewModels.class);
//
sharedPreferences
=
getSharedPreferences
(
SplashScreen
.
MY_SHARED_PREFERENCES
,
Context
.
MODE_PRIVATE
);
//
sharedPreferences = getSharedPreferences(SplashScreen.MY_SHARED_PREFERENCES, Context.MODE_PRIVATE);
//
btnLogin
.
setOnClickListener
(
new
View
.
OnClickListener
()
{
//
btnLogin.setOnClickListener(new View.OnClickListener() {
@Override
//
@Override
public
void
onClick
(
View
v
)
{
//
public void onClick(View v) {
Snackbar
snackbar
=
Snackbar
.
make
(
v
,
"Oppss! Wrong Username Or Password!"
,
Snackbar
.
LENGTH_LONG
);
//
Snackbar snackbar = Snackbar.make(v, "Oppss! Wrong Username Or Password!", Snackbar.LENGTH_LONG);
//
if
(
TextUtils
.
isEmpty
(
username
.
getText
().
toString
())
&&
//
if (TextUtils.isEmpty(username.getText().toString()) &&
TextUtils
.
isEmpty
(
password
.
getText
().
toString
())){
//
TextUtils.isEmpty(password.getText().toString())){
username
.
setError
(
"This field can't empty"
);
//
username.setError("This field can't empty");
password
.
setError
(
"This field can't empty"
);
//
password.setError("This field can't empty");
}
else
if
(
TextUtils
.
isEmpty
(
username
.
getText
().
toString
())){
//
}else if (TextUtils.isEmpty(username.getText().toString())){
username
.
setError
(
"This field can't empty"
);
//
username.setError("This field can't empty");
}
else
if
(
TextUtils
.
isEmpty
(
password
.
getText
().
toString
())){
//
}else if (TextUtils.isEmpty(password.getText().toString())){
password
.
setError
(
"This field can't empty"
);
//
password.setError("This field can't empty");
}
else
{
//
}else{
progressBar
.
setVisibility
(
View
.
VISIBLE
);
//
progressBar.setVisibility(View.VISIBLE);
username
.
setEnabled
(
false
);
//
username.setEnabled(false);
password
.
setEnabled
(
false
);
//
password.setEnabled(false);
btnLogin
.
setEnabled
(
false
);
//
btnLogin.setEnabled(false);
//
mainViewModels
.
checkLogin
(
new
UsersModels
(
username
.
getText
().
toString
(),
//
mainViewModels.checkLogin(new UsersModels(username.getText().toString(),
password
.
getText
().
toString
())).
observe
(
LoginActivity
.
this
,
new
Observer
<
DataResponse
<
UsersModels
>>()
{
//
password.getText().toString())).observe(LoginActivity.this, new Observer<DataResponse<UsersModels>>() {
@Override
//
@Override
public
void
onChanged
(
DataResponse
<
UsersModels
>
usersModelsDataResponse
)
{
//
public void onChanged(DataResponse<UsersModels> usersModelsDataResponse) {
Log
.
d
(
"Status"
,
usersModelsDataResponse
.
getMessageData
());
//
Log.d("Status", usersModelsDataResponse.getMessageData());
//
if
(
usersModelsDataResponse
.
getStatusData
()){
//
if (usersModelsDataResponse.getStatusData()){
SharedPreferences
.
Editor
editor
=
sharedPreferences
.
edit
();
//
SharedPreferences.Editor editor = sharedPreferences.edit();
editor
.
putBoolean
(
SplashScreen
.
SESSION
,
true
);
//
editor.putBoolean(SplashScreen.SESSION, true);
editor
.
commit
();
//
editor.commit();
//
startActivity
(
new
Intent
(
LoginActivity
.
this
,
MainActivity
.
class
));
//
startActivity(new Intent(LoginActivity.this, MainActivity.class));
//
progressBar
.
setVisibility
(
View
.
GONE
);
//
progressBar.setVisibility(View.GONE);
username
.
setEnabled
(
true
);
//
username.setEnabled(true);
password
.
setEnabled
(
true
);
//
password.setEnabled(true);
btnLogin
.
setEnabled
(
true
);
//
btnLogin.setEnabled(true);
}
else
{
//
}else {
snackbar
.
show
();
//
snackbar.show();
progressBar
.
setVisibility
(
View
.
GONE
);
//
progressBar.setVisibility(View.GONE);
username
.
setEnabled
(
true
);
//
username.setEnabled(true);
password
.
setEnabled
(
true
);
//
password.setEnabled(true);
btnLogin
.
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 @@
...
@@ -2,7 +2,7 @@
<selector
xmlns:android=
"http://schemas.android.com/apk/res/android"
>
<selector
xmlns:android=
"http://schemas.android.com/apk/res/android"
>
<item>
<item>
<shape>
<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>
</shape>
</item>
</item>
</selector>
</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"?>
<?xml version="1.0" encoding="utf-8"?>
<androidx.coordinatorlayout.widget.CoordinatorLayout
<androidx.coordinatorlayout.widget.CoordinatorLayout
android:layout_width=
"match_parent"
android:layout_width=
"match_parent"
android:layout_height=
"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"
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
<RelativeLayout
android:layout_width=
"match_parent"
android:layout_width=
"match_parent"
android:layout_height=
"match_parent"
>
android:layout_height=
"match_parent"
android:paddingHorizontal=
"20dp"
android:paddingVertical=
"25dp"
>
<ImageView
<ImageView
android:id=
"@+id/messerLogoDashboardLogin"
android:id=
"@+id/messerLogoDashboardLogin"
...
@@ -17,6 +21,47 @@
...
@@ -17,6 +21,47 @@
android:layout_centerHorizontal=
"true"
android:layout_centerHorizontal=
"true"
android:layout_marginTop=
"50dp"
/>
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>
</RelativeLayout>
...
...
app/src/main/res/values/colors.xml
View file @
22966800
<?xml version="1.0" encoding="utf-8"?>
<?xml version="1.0" encoding="utf-8"?>
<resources>
<resources>
<color
name=
"colorPrimary"
>
#4d089a
</color>
<color
name=
"colorPrimary"
>
#4d089a
</color>
<color
name=
"colorPrimaryCenter"
>
#4021B9
</color>
<color
name=
"colorPrimaryDark"
>
#323edd
</color>
<color
name=
"colorPrimaryDark"
>
#323edd
</color>
<color
name=
"colorAccent"
>
#dc2ade
</color>
<color
name=
"colorAccent"
>
#dc2ade
</color>
<color
name=
"colorAccentDark"
>
#e8f044
</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