Commit 64f8dc9a authored by fauzi's avatar fauzi

fix utils

parent 3bbcccda
...@@ -173,7 +173,6 @@ public class CartActivity extends AppCompatActivity { ...@@ -173,7 +173,6 @@ public class CartActivity extends AppCompatActivity {
}else{ }else{
utils.dialog(CartActivity.this, utils.dialog(CartActivity.this,
true, true,
getLayoutInflater().inflate(R.layout.alert_dialog, null),
"Warning", "Warning",
"Item stock does not meet").show(); "Item stock does not meet").show();
} }
......
...@@ -3,8 +3,11 @@ package com.yono.messeripos; ...@@ -3,8 +3,11 @@ package com.yono.messeripos;
import androidx.appcompat.app.AppCompatActivity; import androidx.appcompat.app.AppCompatActivity;
import androidx.fragment.app.FragmentManager; import androidx.fragment.app.FragmentManager;
import android.os.Build;
import android.os.Bundle; import android.os.Bundle;
import android.view.View; import android.view.View;
import android.view.Window;
import android.view.WindowManager;
import android.widget.ImageButton; import android.widget.ImageButton;
public class ForgotPasswordActivity extends AppCompatActivity { public class ForgotPasswordActivity extends AppCompatActivity {
...@@ -16,6 +19,11 @@ public class ForgotPasswordActivity extends AppCompatActivity { ...@@ -16,6 +19,11 @@ public class ForgotPasswordActivity extends AppCompatActivity {
super.onCreate(savedInstanceState); super.onCreate(savedInstanceState);
setContentView(R.layout.activity_forgot_password); setContentView(R.layout.activity_forgot_password);
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);
}
btnReset = findViewById(R.id.btn_reset_password); btnReset = findViewById(R.id.btn_reset_password);
btnReset.setOnClickListener(new View.OnClickListener() { btnReset.setOnClickListener(new View.OnClickListener() {
@Override @Override
......
...@@ -144,19 +144,17 @@ public class LoginState extends BottomSheetDialogFragment { ...@@ -144,19 +144,17 @@ public class LoginState extends BottomSheetDialogFragment {
.observe((LifecycleOwner) context, usersModelsDataResponse -> { .observe((LifecycleOwner) context, usersModelsDataResponse -> {
if (usersModelsDataResponse != null) { if (usersModelsDataResponse != null) {
final View customLayout = getLayoutInflater()
.inflate(R.layout.alert_dialog, null);
switch (usersModelsDataResponse.getMessageData().toLowerCase()) { switch (usersModelsDataResponse.getMessageData().toLowerCase()) {
case "invalid username or password": case "invalid username or password":
setAllLayoutToTrue(); setAllLayoutToTrue();
errUserPass(customLayout); errUserPass();
break; break;
case "please activate your email first": case "please activate your email first":
setAllLayoutToTrue(); setAllLayoutToTrue();
activateEmail(customLayout); activateEmail();
default: default:
break; break;
...@@ -206,10 +204,10 @@ public class LoginState extends BottomSheetDialogFragment { ...@@ -206,10 +204,10 @@ public class LoginState extends BottomSheetDialogFragment {
closeBtn.setEnabled(false); closeBtn.setEnabled(false);
} }
private void activateEmail(View customLayout) { private void activateEmail() {
utils = new Utils(customLayout); utils = new Utils();
utils.dialog(context, false, customLayout, "Please Verify Email", utils.dialog(context, false, "Please Verify Email",
"Please verify your email before login", "Please verify your email before login",
"close", "verify") "close", "verify")
.show(); .show();
...@@ -230,10 +228,10 @@ public class LoginState extends BottomSheetDialogFragment { ...@@ -230,10 +228,10 @@ public class LoginState extends BottomSheetDialogFragment {
}); });
} }
private void errUserPass(View customLayout) { private void errUserPass() {
utils = new Utils(customLayout); utils = new Utils();
utils.dialog(context, false, customLayout, "Wrong Username or Password", utils.dialog(context, false, "Wrong Username or Password",
"The username or password is incorrect. Please try again!", "The username or password is incorrect. Please try again!",
"Try Again") "Try Again")
.show(); .show();
......
...@@ -193,10 +193,10 @@ public class RegisterState extends BottomSheetDialogFragment { ...@@ -193,10 +193,10 @@ public class RegisterState extends BottomSheetDialogFragment {
return sheetDialog2; return sheetDialog2;
} }
private void activateEmail(View customLayout) { private void activateEmail() {
utils = new Utils(customLayout); utils = new Utils();
utils.dialog(context, false, customLayout, "Please Verifiy Email", utils.dialog(context, false, "Please Verifiy Email",
"Please verify your email before login", "Please verify your email before login",
"close", "verify") "close", "verify")
.show(); .show();
......
...@@ -8,6 +8,7 @@ import android.graphics.BitmapFactory; ...@@ -8,6 +8,7 @@ import android.graphics.BitmapFactory;
import android.os.Build; import android.os.Build;
import android.util.Base64; import android.util.Base64;
import android.util.Log; import android.util.Log;
import android.view.LayoutInflater;
import android.view.View; import android.view.View;
import android.widget.TextView; import android.widget.TextView;
import android.widget.Toast; import android.widget.Toast;
...@@ -223,12 +224,13 @@ public class Utils { ...@@ -223,12 +224,13 @@ public class Utils {
* Alert Dialog * Alert Dialog
* @param context * @param context
* @param cancelable * @param cancelable
* @param view
* @return * @return
*/ */
public AlertDialog dialog(Context context, Boolean cancelable, View view) { public AlertDialog dialog(Context context, Boolean cancelable) {
CardView btCard = view.findViewById(R.id.cvAlertOnClick); final View view = View.inflate(context, R.layout.alert_dialog, null);
CardView btnCard = view.findViewById(R.id.cvAlertOnClick);
AlertDialog.Builder builder = new AlertDialog.Builder(context) AlertDialog.Builder builder = new AlertDialog.Builder(context)
.setCancelable(cancelable) .setCancelable(cancelable)
...@@ -241,10 +243,14 @@ public class Utils { ...@@ -241,10 +243,14 @@ public class Utils {
} }
public AlertDialog dialog(Context context, Boolean cancelable, View view, @Nullable String titles) { public AlertDialog dialog(Context context,
Boolean cancelable,
@Nullable String titles) {
final View view = View.inflate(context, R.layout.alert_dialog, null);
TextView title = view.findViewById(R.id.alertTitles); TextView title = view.findViewById(R.id.alertTitles);
CardView btCard = view.findViewById(R.id.cvAlertOnClick); CardView btnCard = view.findViewById(R.id.cvAlertOnClick);
// set title and message // set title and message
if (titles != null){ if (titles != null){
...@@ -262,7 +268,12 @@ public class Utils { ...@@ -262,7 +268,12 @@ public class Utils {
} }
public AlertDialog dialog(Context context, Boolean cancelable, View view, @Nullable String titles, @Nullable String messages) { public AlertDialog dialog(Context context,
Boolean cancelable,
@Nullable String titles,
@Nullable String messages) {
final View view = View.inflate(context, R.layout.alert_dialog, null);
TextView title = view.findViewById(R.id.alertTitles); TextView title = view.findViewById(R.id.alertTitles);
TextView message = view.findViewById(R.id.alertBody); TextView message = view.findViewById(R.id.alertBody);
...@@ -289,16 +300,18 @@ public class Utils { ...@@ -289,16 +300,18 @@ public class Utils {
public AlertDialog dialog(Context context, public AlertDialog dialog(Context context,
Boolean cancelable, Boolean cancelable,
View view,
@Nullable String titles, @Nullable String titles,
@Nullable String messages, @Nullable String messages,
@Nullable String dismiss) { @Nullable String dismiss) {
final View view = View.inflate(context, R.layout.alert_dialog, null);
TextView title = view.findViewById(R.id.alertTitles); TextView title = view.findViewById(R.id.alertTitles);
TextView message = view.findViewById(R.id.alertBody); TextView message = view.findViewById(R.id.alertBody);
TextView button2 = view.findViewById(R.id.tvTextBtn2); TextView button2 = view.findViewById(R.id.tvTextBtn2);
CardView btnCard2 = view.findViewById(R.id.cvAlertOnClick2); CardView btnCard2 = view.findViewById(R.id.cvAlertOnClick2);
// set title and message // set title and message
if (titles != null){ if (titles != null){
title.setText(titles); title.setText(titles);
...@@ -327,7 +340,6 @@ public class Utils { ...@@ -327,7 +340,6 @@ public class Utils {
public AlertDialog dialog(Context context, public AlertDialog dialog(Context context,
Boolean cancelable, Boolean cancelable,
View view,
@Nullable String titles, @Nullable String titles,
@Nullable String messages, @Nullable String messages,
@Nullable String dismiss, @Nullable String dismiss,
...@@ -338,6 +350,8 @@ public class Utils { ...@@ -338,6 +350,8 @@ public class Utils {
* Button2 untuk link * Button2 untuk link
*/ */
final View view = View.inflate(context, R.layout.alert_dialog, null);
TextView title = view.findViewById(R.id.alertTitles); TextView title = view.findViewById(R.id.alertTitles);
TextView message = view.findViewById(R.id.alertBody); TextView message = view.findViewById(R.id.alertBody);
TextView button = view.findViewById(R.id.tvTextBtn); TextView button = view.findViewById(R.id.tvTextBtn);
......
...@@ -21,6 +21,7 @@ ...@@ -21,6 +21,7 @@
<LinearLayout <LinearLayout
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent" android:layout_height="match_parent"
android:paddingVertical="20dp"
android:orientation="vertical"> android:orientation="vertical">
<TextView <TextView
......
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