Commit 22966800 authored by iman Fauzi's avatar iman Fauzi

add content dashboard login

parent fdd71a8b
......@@ -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
......@@ -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
<?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>
......
<?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>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment