Commit 2a9cc378 authored by Ahmad Abi Mulya's avatar Ahmad Abi Mulya

Fix Login Session and UI

parents bee2fb9a 9154539c
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.yourcashiertest">
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-feature
android:name="android.hardware.camera"
android:required="true" />
......@@ -17,13 +17,25 @@
android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="@style/AppTheme2">
<activity android:name=".activities.WelcomeActivity"></activity>
<activity android:name=".activities.ForgetPassword" />
<activity android:name=".activities.RegisterActivity" />
<activity android:name=".activities.StatusPayment" />
<activity
android:name=".activities.SkActivity"
android:screenOrientation="portrait"/>
<activity
android:name=".activities.WelcomeActivity"
android:screenOrientation="portrait"/>
<activity
android:name=".activities.ForgetPassword"
android:screenOrientation="portrait"/>
<activity
android:name=".activities.RegisterActivity"
android:screenOrientation="portrait"/>
<activity
android:name=".activities.StatusPayment"
android:screenOrientation="portrait"/>
<activity
android:name=".activities.SplashActivity"
android:theme="@style/AppTheme2">
android:theme="@style/AppTheme2"
android:screenOrientation="portrait">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
......@@ -32,17 +44,19 @@
</activity>
<activity
android:name=".activities.PaymentActivity"
android:theme="@style/AppTheme2" />
android:screenOrientation="portrait"/>
<activity
android:name=".activities.CartActivity"
android:theme="@style/AppTheme2" />
android:screenOrientation="portrait"/>
<activity
android:name=".activities.MainActivity"
android:theme="@style/AppTheme2" />
android:screenOrientation="portrait"/>
<activity
android:name=".activities.ProductActivity"
android:theme="@style/AppTheme2" />
<activity android:name=".activities.LoginActivity" />
android:screenOrientation="portrait"/>
<activity
android:name=".activities.LoginActivity"
android:screenOrientation="portrait"/>
<provider
android:name="androidx.core.content.FileProvider"
android:authorities="com.example.yourcashiertest.fileprovider"
......
package com.example.yourcashiertest.activities;
import androidx.appcompat.app.AppCompatActivity;
import android.app.AlertDialog;
import android.content.DialogInterface;
import androidx.databinding.DataBindingUtil;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.ImageView;
import android.widget.TextView;
import com.example.yourcashiertest.R;
import com.example.yourcashiertest.adapters.CartAdapter;
import com.example.yourcashiertest.databinding.ActivityCartBinding;
import com.example.yourcashiertest.databinding.ItemListBinding;
import java.text.DecimalFormat;
import java.text.DecimalFormatSymbols;
public class CartActivity extends AppCompatActivity {
ImageView btnBack;
ActivityCartBinding binding;
TextView tvName, tvTotalPrice, tvQty, tvPrice, tvItems;
Button btnAdd, btnMin, btnCheckout;
int count = 1;
int pricePerQty;
int totalPrice;
int totalItems;
CartAdapter adapter;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_cart);
btnCheckout = findViewById(R.id.btnCheckout);
btnBack = findViewById(R.id.ivBtnBack);
tvName = findViewById(R.id.burger_medi);
tvQty = findViewById(R.id.tv_qty);
btnAdd = findViewById(R.id.btn_add);
btnMin = findViewById(R.id.btn_min);
tvPrice = findViewById(R.id.some_id);
tvTotalPrice = findViewById(R.id.tvTotalPrice);
tvItems = findViewById(R.id.items);
binding = DataBindingUtil.setContentView(this, R.layout.activity_cart);
// adapter = new CartAdapter();
// binding.rvCartList.setLayoutManager(new LinearLayoutManager(this));
// binding.rvCartList.setAdapter(adapter);
int price = 10000;
tvName.setText("Burger KING");
btnAdd.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
count++;
pricePerQty = price * count;
changeOnClick(count, pricePerQty, totalPrice);
}
});
// CartViewModel cartViewModel = new ViewModelProvider(this).get(CartViewModel.class);
// cartViewModel.getCarts().observe(this, carts -> adapter.setCartList(carts));
//
// binding.setViewModelCart(cartViewModel);
btnMin.setOnClickListener(view -> {
count--;
if (count == 0){
}
pricePerQty = price * count;
changeOnClick(count, pricePerQty, totalPrice);
});
btnBack.setOnClickListener(view -> startActivity(new Intent(CartActivity.this, MainActivity.class)));
btnCheckout.setOnClickListener(view -> {
binding.ivBtnBack.setOnClickListener(view -> startActivity(new Intent(CartActivity.this, MainActivity.class)));
binding.btnCheckout.setOnClickListener(view -> {
startActivity(new Intent(CartActivity.this, PaymentActivity.class));
finish();
});
}
......@@ -93,10 +50,4 @@ public class CartActivity extends AppCompatActivity {
return priceRupiah;
}
private void changeOnClick(int count, int pricePerQty, int totalPrice){
tvQty.setText(String.valueOf(count));
tvPrice.setText(changeToCurrency(pricePerQty));
tvTotalPrice.setText(changeToCurrency(totalPrice));
}
}
\ No newline at end of file
......@@ -2,7 +2,9 @@ package com.example.yourcashiertest.activities;
import androidx.appcompat.app.AppCompatActivity;
import android.content.Context;
import android.content.Intent;
import android.content.SharedPreferences;
import android.os.Bundle;
import android.view.View;
import android.widget.Toast;
......@@ -15,19 +17,28 @@ public class LoginActivity extends AppCompatActivity {
TextInputEditText etUsername, etPassword;
MaterialButton btnLogin;
public static final String DATA_LOGIN = "DATA_LOGIN";
public static Boolean syarat;
// SharedPreferences sharedPreferences;
// public static final String SESS_SYARAT = "syarat";
// public static final String my_shared = "session_status";
private PrefManager prefManager;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_login);
// sharedPreferences = getSharedPreferences(my_shared, Context.MODE_PRIVATE);
// syarat = sharedPreferences.getBoolean(SESS_SYARAT, false);
prefManager = new PrefManager(this);
if (!prefManager.isFirstLogin()) {
launchMain();
finish();
}
etPassword = findViewById(R.id.etPassword);
etUsername = findViewById(R.id.etUsername);
btnLogin = findViewById(R.id.btnLogin);
btnLogin.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
btnLogin.setOnClickListener(view -> {
if(etUsername.getText().toString().length() == 0 || etPassword.getText().toString().length() == 0){
Toast.makeText(getApplicationContext(), "Please input Username and Password", Toast.LENGTH_SHORT).show();
......@@ -38,7 +49,7 @@ public class LoginActivity extends AppCompatActivity {
}else{
startActivity(new Intent(LoginActivity.this, MainActivity.class)
.putExtra(DATA_LOGIN, etUsername.getText().toString()));
}
finish();
}
});
}
......@@ -50,4 +61,9 @@ public class LoginActivity extends AppCompatActivity {
public void tvSignUpHere(View view) {
startActivity(new Intent(LoginActivity.this, RegisterActivity.class));
}
public void launchMain() {
prefManager.setFirstLogin(false);
startActivity(new Intent(LoginActivity.this, MainActivity.class));
finish();
}
}
\ No newline at end of file
......@@ -3,28 +3,36 @@ package com.example.yourcashiertest.activities;
import androidx.annotation.NonNull;
import androidx.appcompat.app.AppCompatActivity;
import androidx.databinding.DataBindingUtil;
import androidx.lifecycle.Observer;
import androidx.lifecycle.ViewModelProvider;
import android.Manifest;
import android.content.Intent;
import android.content.SharedPreferences;
import android.os.Bundle;
import android.text.Editable;
import android.text.TextWatcher;
import android.view.Menu;
import android.view.View;
import android.widget.PopupMenu;
import com.example.yourcashiertest.R;
import com.example.yourcashiertest.adapters.ProductAdapter;
import com.example.yourcashiertest.databinding.ActivityMainBinding;
import com.example.yourcashiertest.databinding.ItemListBinding;
import com.example.yourcashiertest.entities.Product;
import com.example.yourcashiertest.models.CartModel;
import com.example.yourcashiertest.viewmodels.CartViewModel;
import com.example.yourcashiertest.viewmodels.ProductViewModel;
import java.util.ArrayList;
import java.util.List;
public class MainActivity extends AppCompatActivity {
ActivityMainBinding binding;
ItemListBinding bindingItem;
private PrefManager prefManager;
SharedPreferences sharedPreferences;
public static final String DATA_PRODUCT = "DATA_PRODUCT";
private static final int REQUEST_PERMISSIONS = 111;
......@@ -32,14 +40,20 @@ public class MainActivity extends AppCompatActivity {
private String[] permissions = new String[]{Manifest.permission.READ_EXTERNAL_STORAGE,
Manifest.permission.WRITE_EXTERNAL_STORAGE};
public static boolean visibility = false;
CartViewModel cartViewModel;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
requestPermissions(permissions, REQUEST_PERMISSIONS);
prefManager = new PrefManager(this);
ProductAdapter adapter = new ProductAdapter();
binding = DataBindingUtil.setContentView(this, R.layout.activity_main);
// cartViewModel = new ViewModelProvider(this).get(CartViewModel.class);
String name = getIntent().getStringExtra(LoginActivity.DATA_LOGIN);
binding.tvUser.setText(name);
// settings menu
......@@ -53,12 +67,30 @@ public class MainActivity extends AppCompatActivity {
startActivity(new Intent(MainActivity.this, ProductActivity.class));
break;
case R.id.item_two:
adapter.setVisibility(true);
if (visibility){
visibility = false;
}else {
visibility = true;
}
finish();
overridePendingTransition(0, 0);
startActivity(getIntent());
overridePendingTransition(0, 0);
return true;
case R.id.item_three:
prefManager.removeLoginSession();
startActivity(new Intent(MainActivity.this, LoginActivity.class));
finish();
break;
}
return false;
});
popupMenu.inflate(R.menu.settings_menu);
if (visibility){
popupMenu.getMenu().findItem(R.id.item_two).setTitle("Back");
}else {
popupMenu.getMenu().findItem(R.id.item_two).setTitle("Update or Delete");
}
popupMenu.show();
});
......@@ -77,6 +109,11 @@ public class MainActivity extends AppCompatActivity {
public void onDelete(Product product) {
viewModel.deleteProduct(product);
}
@Override
public void onAddToCart(Product product) {
addToCart(product);
}
});
binding.etSearch.addTextChangedListener(new TextWatcher() {
......@@ -98,6 +135,31 @@ public class MainActivity extends AppCompatActivity {
binding.setViewModel(viewModel);
}
public void addToCart(Product product){
// Cart cart = new Cart(0,"", "", 0, 0);
// cart.setIdProduct(product.getId());
// cart.setImage(product.getPhoto());
// cart.setNameProduct(product.getName());
// cart.setPrice(product.getPrice());
// cart.setQty(1);
// cartViewModel.insertCart(cart);
List<CartModel> list = new ArrayList<>();
CartModel cart = new CartModel();
cart.setIdProduct(product.getId());
cart.setNameProduct(product.getName());
cart.setImage(product.getPhoto());
cart.setPrice(product.getPrice());
cart.setQty(product.getQuantity());
}
@Override
public void onBackPressed() {
super.onBackPressed();
visibility = false;
}
@Override
public void onRequestPermissionsResult(int requestCode, @NonNull String[] permissions, @NonNull int[] grantResults) {
super.onRequestPermissionsResult(requestCode, permissions, grantResults);
......
......@@ -3,22 +3,68 @@ package com.example.yourcashiertest.activities;
import androidx.appcompat.app.AppCompatActivity;
import androidx.cardview.widget.CardView;
import android.annotation.SuppressLint;
import android.content.Intent;
import android.os.Bundle;
import android.view.MotionEvent;
import android.view.View;
import com.example.yourcashiertest.R;
public class PaymentActivity extends AppCompatActivity {
CardView cvCash, cvCard;
boolean change = false;
@SuppressLint("ClickableViewAccessibility")
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_payment);
cvCash = findViewById(R.id.cvCash);
cvCard = findViewById(R.id.cvCard);
cvCash.setOnTouchListener(new View.OnTouchListener() {
@Override
public boolean onTouch(View view, MotionEvent event) {
changeCvColor(event, cvCash);
return true;
}
});
cvCard.setOnTouchListener(new View.OnTouchListener() {
@Override
public boolean onTouch(View view, MotionEvent event) {
changeCvColor(event, cvCard);
return true;
}
});
}
public void btnPay(View view) {
startActivity(new Intent(PaymentActivity.this, StatusPayment.class));
finish();
}
public void changeCvColor(MotionEvent event, CardView cv){
if (change) {
change = false;
switch (event.getAction()) {
case MotionEvent.ACTION_DOWN:
cv.setCardBackgroundColor(getResources().getColor(R.color.colorPrimary));
break;
case MotionEvent.ACTION_UP:
cv.setCardBackgroundColor(getResources().getColor(R.color.white));
}
} else {
change = true;
switch (event.getAction()) {
case MotionEvent.ACTION_DOWN:
cv.setCardBackgroundColor(getResources().getColor(R.color.white));
break;
case MotionEvent.ACTION_UP:
cv.setCardBackgroundColor(getResources().getColor(R.color.colorPrimary));
}
}
}
}
\ No newline at end of file
......@@ -8,14 +8,13 @@ public class PrefManager {
SharedPreferences pref;
SharedPreferences.Editor editor;
Context _context;
// shared pref mode
int PRIVATE_MODE = 0;
// Shared preferences file name
private static final String PREF_NAME = "introslider";
private static final String IS_FIRST_TIME_LAUNCH = "IsFirstTimeLaunch";
private static final String PREF_NAME = "preferences";
private static final String IS_FIRST_WELCOME = "IsFirstWelcome";
private static final String IS_FIRST_LOGIN = "IsFirstLogin";
public PrefManager(Context context) {
this._context = context;
......@@ -23,13 +22,20 @@ public class PrefManager {
editor = pref.edit();
}
public void setFirstTimeLaunch(boolean isFirstTime) {
editor.putBoolean(IS_FIRST_TIME_LAUNCH, isFirstTime);
public void setFirstWelcome(boolean isFirstTime) {
editor.putBoolean(IS_FIRST_WELCOME, isFirstTime);
editor.commit();
}
public boolean isFirstTimeLaunch() {
return pref.getBoolean(IS_FIRST_TIME_LAUNCH, true);
public void setFirstLogin(boolean isFirstTime) {
editor.putBoolean(IS_FIRST_LOGIN, isFirstTime);
editor.commit();
}
public boolean isFirstLogin(){return pref.getBoolean(IS_FIRST_LOGIN, true);}
public boolean isFirstWelcome() { return pref.getBoolean(IS_FIRST_WELCOME, true); }
public void removeLoginSession(){
// loginActivity.launchMain(true);
editor.remove(IS_FIRST_LOGIN);
editor.apply();
}
}
......@@ -4,20 +4,16 @@ import androidx.appcompat.app.AppCompatActivity;
import androidx.core.content.FileProvider;
import androidx.databinding.DataBindingUtil;
import androidx.lifecycle.ViewModelProvider;
import android.Manifest;
import android.annotation.SuppressLint;
import android.app.AlertDialog;
import android.content.Context;
import android.content.DialogInterface;
import android.content.Intent;
import android.database.Cursor;
import android.graphics.Bitmap;
import android.net.Uri;
import android.os.Bundle;
import android.os.Environment;
import android.provider.MediaStore;
import android.text.TextUtils;
import android.util.Log;
import com.example.yourcashiertest.R;
import com.example.yourcashiertest.databinding.ActivityProductBinding;
import com.example.yourcashiertest.entities.Product;
......@@ -39,6 +35,7 @@ public class ProductActivity extends AppCompatActivity{
viewModel = new ViewModelProvider(this).get(ProductViewModel.class);
binding = DataBindingUtil.setContentView(this, R.layout.activity_product);
Product product = getIntent().getParcelableExtra(MainActivity.DATA_PRODUCT);
if (getSupportActionBar() != null) {
getSupportActionBar().setHomeButtonEnabled(true);
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
......@@ -84,6 +81,7 @@ public class ProductActivity extends AppCompatActivity{
});
binding.setViewModel(viewModel);
}
private void takePhoto() {
Intent takePictureIntent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
if (takePictureIntent.resolveActivity(getPackageManager()) != null) {
......
......@@ -5,10 +5,15 @@ import androidx.appcompat.app.AppCompatActivity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.webkit.WebView;
import android.widget.ProgressBar;
import com.example.yourcashiertest.R;
public class RegisterActivity extends AppCompatActivity {
WebView wbCompany;
ProgressBar pbLoading;
private static final String urLCompany = "http://multidaya.id/";
@Override
protected void onCreate(Bundle savedInstanceState) {
......@@ -18,5 +23,10 @@ public class RegisterActivity extends AppCompatActivity {
public void tvSignInHere(View view) {
startActivity(new Intent(RegisterActivity.this, LoginActivity.class));
finish();
}
public void tvSK(View view) {
startActivity(new Intent(RegisterActivity.this, SkActivity.class));
}
}
\ No newline at end of file
package com.example.yourcashiertest.activities;
import androidx.appcompat.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;
import android.webkit.WebView;
import android.webkit.WebViewClient;
import android.widget.ProgressBar;
import com.example.yourcashiertest.R;
public class SkActivity extends AppCompatActivity {
WebView wbCompany;
ProgressBar pbLoading;
private static final String urLCompany = "http://multidaya.id/";
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_sk);
pbLoading = findViewById(R.id.pbLoading);
wbCompany = findViewById(R.id.wbCompany);
wbCompany.getSettings().setLoadsImagesAutomatically(true);
wbCompany.getSettings().setJavaScriptEnabled(true);
wbCompany.setScrollBarStyle(View.SCROLLBARS_INSIDE_OVERLAY);
wbCompany.setWebViewClient(new WebViewClient() {
@Override
public void onPageFinished(WebView view, String url) {
wbCompany.setVisibility(View.VISIBLE);
pbLoading.setVisibility(View.GONE);
if (getSupportActionBar() != null)
getSupportActionBar().setTitle("Multidaya Dinamika");
}
});
wbCompany.loadUrl(urLCompany);
}
}
\ No newline at end of file
......@@ -36,7 +36,7 @@ public class WelcomeActivity extends AppCompatActivity {
// mengecek lauch activity - sebelum memanggil setContentView()
prefManager = new PrefManager(this);
if (!prefManager.isFirstTimeLaunch()) {
if (!prefManager.isFirstWelcome()) {
launchHomeScreen();
finish();
}
......@@ -118,7 +118,7 @@ public class WelcomeActivity extends AppCompatActivity {
}
private void launchHomeScreen() {
prefManager.setFirstTimeLaunch(false);
prefManager.setFirstWelcome(false);
startActivity(new Intent(WelcomeActivity.this, LoginActivity.class));
finish();
}
......
......@@ -10,26 +10,29 @@ import androidx.recyclerview.widget.RecyclerView;
import com.example.yourcashiertest.R;
import com.example.yourcashiertest.databinding.CartItemBinding;
import com.example.yourcashiertest.entities.Cart;
import com.example.yourcashiertest.entities.Product;
import com.example.yourcashiertest.models.CartModel;
import java.util.ArrayList;
import java.util.List;
public class CartAdapter extends RecyclerView.Adapter<CartAdapter.ViewHolder> {
private List<Product> productList = new ArrayList<>();
private List<Cart> carts = new ArrayList<>();
public interface Listener{
public interface CartListener{
void onIncrease();
void onDecrease();
}
private CartListener listener;
public void setCartListener(CartListener listener){
this.listener = listener;
}
public Listener listener;
public CartAdapter(List<Product> productList) {
this.productList = productList;
public void setCartList(List<Cart> carts){
this.carts = carts;
notifyDataSetChanged();
}
......@@ -48,12 +51,12 @@ public class CartAdapter extends RecyclerView.Adapter<CartAdapter.ViewHolder> {
@Override
public void onBindViewHolder(@NonNull CartAdapter.ViewHolder holder, int position) {
holder.bindData(productList.get(position));
holder.bindData(carts.get(position), listener);
}
@Override
public int getItemCount() {
return productList.size();
return carts.size();
}
public class ViewHolder extends RecyclerView.ViewHolder {
......@@ -66,13 +69,8 @@ public class CartAdapter extends RecyclerView.Adapter<CartAdapter.ViewHolder> {
this.cartItemBinding = cartItemBinding;
}
public void bindData(Product product) {
cartItemBinding.setCartProduct(product);
cartItemBinding.btnAdd.setOnClickListener(view -> listener.onIncrease());
cartItemBinding.btnMin.setOnClickListener(view -> listener.onDecrease());
public void bindData(Cart cart, CartListener listener) {
cartItemBinding.setCartProduct(cart);
}
}
......
......@@ -8,6 +8,7 @@ import androidx.databinding.DataBindingUtil;
import androidx.recyclerview.widget.RecyclerView;
import com.example.yourcashiertest.R;
import com.example.yourcashiertest.activities.MainActivity;
import com.example.yourcashiertest.databinding.ItemListBinding;
import com.example.yourcashiertest.entities.Product;
......@@ -19,12 +20,13 @@ import java.util.List;
public class ProductAdapter extends RecyclerView.Adapter<ProductAdapter.ViewHolder> {
private List<Product> products = new ArrayList<>();
private Boolean visibility;
public interface ProductListener {
void onUpdate(Product product);
void onDelete(Product product);
void onAddToCart(Product product);
}
private ProductListener listener;
......@@ -55,7 +57,6 @@ public class ProductAdapter extends RecyclerView.Adapter<ProductAdapter.ViewHold
@Override
public void onBindViewHolder(@NonNull ProductAdapter.ViewHolder holder, int position) {
holder.bindData(products.get(position), listener);
holder.binding.setVisibility(visibility);
}
@Override
......@@ -65,7 +66,6 @@ public class ProductAdapter extends RecyclerView.Adapter<ProductAdapter.ViewHold
public static class ViewHolder extends RecyclerView.ViewHolder {
private ItemListBinding binding;
private Boolean visibility;
public ViewHolder(@NonNull ItemListBinding binding) {
super(binding.getRoot());
......@@ -75,6 +75,8 @@ public class ProductAdapter extends RecyclerView.Adapter<ProductAdapter.ViewHold
public void bindData(Product product, ProductListener listener) {
binding.setProduct(product);
binding.setVisibility(MainActivity.visibility);
DecimalFormat rupiah = (DecimalFormat) DecimalFormat.getCurrencyInstance();
DecimalFormatSymbols format = new DecimalFormatSymbols();
......@@ -88,10 +90,7 @@ public class ProductAdapter extends RecyclerView.Adapter<ProductAdapter.ViewHold
binding.ivUpdate.setOnClickListener(view -> listener.onUpdate(product));
binding.ivDelete.setOnClickListener(view -> listener.onDelete(product));
binding.vAdd.setOnClickListener(view -> listener.onAddToCart(product));
}
}
public void setVisibility(Boolean visibility){
this.visibility = visibility;
}
}
\ No newline at end of file
package com.example.yourcashiertest.daos;
import androidx.lifecycle.LiveData;
import androidx.room.Dao;
import androidx.room.Delete;
import androidx.room.Insert;
import androidx.room.OnConflictStrategy;
import androidx.room.Query;
import androidx.room.Update;
import com.example.yourcashiertest.entities.Cart;
import java.util.List;
@Dao
public interface CartDao {
@Query("SELECT * FROM Cart ORDER BY id DESC")
public LiveData<List<Cart>> getCarts();
@Insert(onConflict = OnConflictStrategy.IGNORE)
public void insertCart(Cart cart);
@Update
public void updateCart(Cart cart);
@Delete
public void deleteCart(Cart cart);
}
......@@ -8,10 +8,13 @@ import androidx.room.DatabaseConfiguration;
import androidx.room.InvalidationTracker;
import androidx.room.Room;
import androidx.room.RoomDatabase;
import androidx.room.migration.Migration;
import androidx.sqlite.db.SupportSQLiteDatabase;
import androidx.sqlite.db.SupportSQLiteOpenHelper;
import com.example.yourcashiertest.daos.CartDao;
import com.example.yourcashiertest.daos.ProductDao;
import com.example.yourcashiertest.entities.Cart;
import com.example.yourcashiertest.entities.Product;
import java.util.concurrent.ExecutorService;
......@@ -21,6 +24,7 @@ import java.util.concurrent.Executors;
public abstract class LocalDatabase extends RoomDatabase {
public abstract ProductDao productDao();
// public abstract CartDao cartDao();
private static volatile LocalDatabase INSTANCE;
private static final int NUMBER_OF_THREADS = 4;
......@@ -28,6 +32,27 @@ public abstract class LocalDatabase extends RoomDatabase {
public static final ExecutorService databaseWriteExecutor =
Executors.newFixedThreadPool(NUMBER_OF_THREADS);
// public static final Migration MIGRATION_1_2 = new Migration(1,2) {
// @Override
// public void migrate(@NonNull SupportSQLiteDatabase database) {
// database.execSQL("CREATE TABLE IF NOT EXISTS Cart (id INTEGER, idProduct INTEGER,price INTEGER, qty INTEGER,nameProduct TEXT, image TEXT)");
// }
// };
//
// public static final Migration MIGRATION_1_3 = new Migration(1,3) {
// @Override
// public void migrate(@NonNull SupportSQLiteDatabase database) {
// database.execSQL("DROP TABLE Cart");
// }
// };
//
// public static final Migration MIGRATION_1_4 = new Migration(1,4) {
// @Override
// public void migrate(@NonNull SupportSQLiteDatabase database) {
// database.execSQL("CREATE TABLE IF NOT EXISTS Cart (id INTEGER, idProduct INTEGER,price INTEGER, qty INTEGER,nameProduct TEXT, image TEXT)");
// }
// };
public static LocalDatabase getDatabase(Context context) {
if (INSTANCE == null) {
synchronized (LocalDatabase.class) {
......
......@@ -3,26 +3,45 @@ package com.example.yourcashiertest.entities;
import android.os.Parcel;
import android.os.Parcelable;
import androidx.annotation.NonNull;
import androidx.room.ColumnInfo;
import androidx.room.Entity;
import androidx.room.PrimaryKey;
@Entity(tableName = "carts")
@Entity
public class Cart implements Parcelable {
@PrimaryKey(autoGenerate = true)
@NonNull
@ColumnInfo(name = "id")
private long id;
Product item;
long amount;
@NonNull
@ColumnInfo(name = "idProduct")
long idProduct;
public Cart(Product item, long amount){
this.item = item;
this.amount = amount;
}
@NonNull
@ColumnInfo(name = "price")
long price;
@NonNull
@ColumnInfo(name = "qty")
long qty;
@NonNull
@ColumnInfo(name = "nameProduct")
String nameProduct;
@NonNull
@ColumnInfo(name = "image")
String image;
protected Cart(Parcel in) {
id = in.readLong();
item = in.readParcelable(Product.class.getClassLoader());
amount = in.readLong();
idProduct = in.readLong();
nameProduct = in.readString();
image = in.readString();
price = in.readLong();
qty = in.readLong();
}
public static final Creator<Cart> CREATOR = new Creator<Cart>() {
......@@ -37,6 +56,14 @@ public class Cart implements Parcelable {
}
};
public Cart(long idProduct, String nameProduct, String image, long price, long qty){
this.idProduct = idProduct;
this.nameProduct = nameProduct;
this.image = image;
this.price = price;
this.qty = qty;
}
public long getId() {
return id;
}
......@@ -45,20 +72,44 @@ public class Cart implements Parcelable {
this.id = id;
}
public Product getItem() {
return item;
public long getIdProduct() {
return idProduct;
}
public void setIdProduct(long idProduct) {
this.idProduct = idProduct;
}
public String getNameProduct() {
return nameProduct;
}
public void setNameProduct(String nameProduct) {
this.nameProduct = nameProduct;
}
public String getImage() {
return image;
}
public void setImage(String image) {
this.image = image;
}
public long getPrice() {
return price;
}
public void setItem(Product item) {
this.item = item;
public void setPrice(long price) {
this.price = price;
}
public long getAmount() {
return amount;
public long getQty() {
return qty;
}
public void setAmount(long amount) {
this.amount = amount;
public void setQty(long qty) {
this.qty = qty;
}
@Override
......@@ -69,7 +120,10 @@ public class Cart implements Parcelable {
@Override
public void writeToParcel(Parcel dest, int flags) {
dest.writeLong(id);
dest.writeParcelable(item, flags);
dest.writeLong(amount);
dest.writeLong(idProduct);
dest.writeString(nameProduct);
dest.writeString(image);
dest.writeLong(price);
dest.writeLong(qty);
}
}
package com.example.yourcashiertest.models;
public class CartModel {
long price, qty, idProduct;
String nameProduct, image;
public long getPrice() {
return price;
}
public void setPrice(long price) {
this.price = price;
}
public long getQty() {
return qty;
}
public void setQty(long qty) {
this.qty = qty;
}
public long getIdProduct() {
return idProduct;
}
public void setIdProduct(long idProduct) {
this.idProduct = idProduct;
}
public String getNameProduct() {
return nameProduct;
}
public void setNameProduct(String nameProduct) {
this.nameProduct = nameProduct;
}
public String getImage() {
return image;
}
public void setImage(String image) {
this.image = image;
}
}
package com.example.yourcashiertest.repositories;
import android.app.Application;
import androidx.lifecycle.LiveData;
import com.example.yourcashiertest.daos.CartDao;
import com.example.yourcashiertest.databases.LocalDatabase;
import com.example.yourcashiertest.entities.Cart;
import java.util.List;
public class CartRepository {
private CartDao cartDao;
private LiveData<List<Cart>> carts;
public CartRepository(Application application){
LocalDatabase db = LocalDatabase.getDatabase(application);
// cartDao = db.cartDao();
carts = cartDao.getCarts();
}
public void insert(Cart cart){
LocalDatabase.databaseWriteExecutor.execute(() -> cartDao.insertCart(cart));
}
public void update(Cart cart){
LocalDatabase.databaseWriteExecutor.execute(() -> cartDao.updateCart(cart));
}
public void delete(Cart cart){
LocalDatabase.databaseWriteExecutor.execute(() -> cartDao.deleteCart(cart));
}
public LiveData<List<Cart>> getAllCart(){
return this.carts;
}
}
package com.example.yourcashiertest.viewmodels;
import androidx.lifecycle.MutableLiveData;
import androidx.lifecycle.ViewModel;
import com.example.yourcashiertest.models.CartModel;
import java.util.List;
public class CartVM extends ViewModel {
public MutableLiveData<List<CartModel>> allCart;
public MutableLiveData<List<CartModel>> getAllCart() {
return allCart;
}
public void setAllCart(List<CartModel> cart) {
this.allCart.postValue(cart);
}
}
package com.example.yourcashiertest.viewmodels;
public class CartViewModel {
import android.app.Application;
import androidx.annotation.NonNull;
import androidx.lifecycle.AndroidViewModel;
import androidx.lifecycle.LiveData;
import androidx.lifecycle.MutableLiveData;
import com.example.yourcashiertest.entities.Cart;
import com.example.yourcashiertest.repositories.CartRepository;
import java.util.List;
public class CartViewModel extends AndroidViewModel {
private MutableLiveData<Cart> cart = new MutableLiveData<>();
private CartRepository repository;
private LiveData<List<Cart>> carts;
public CartViewModel(@NonNull Application application) {
super(application);
repository = new CartRepository(application);
this.carts = repository.getAllCart();
}
public LiveData<List<Cart>> getCarts(){
return this.carts;
}
public void insertCart(Cart cart){
repository.insert(cart);
}
public void updateCart(Cart cart){
repository.update(cart);
}
public void deleteCart(Cart cart){
repository.delete(cart);
}
public MutableLiveData<Cart> getCart(){
return this.cart;
}
}
<vector android:height="511.68176dp" android:viewportHeight="517.3097"
android:viewportWidth="567.1704" android:width="561dp" xmlns:android="http://schemas.android.com/apk/res/android">
<path android:fillColor="#3f3d56" android:pathData="M13.551,186.032l475.239,-138.465l12.588,43.204l-475.239,138.465z"/>
<path android:fillColor="#3f3d56" android:pathData="M70.329,384.481 L0.283,144.068a7,7 0,0 1,4.763 -8.679L468.764,0.281a7.006,7.006 0,0 1,8.679 4.762l62.056,212.989 -1.92,0.56L475.522,5.603a5.009,5.009 0,0 0,-6.199 -3.402L5.605,137.309a5,5 0,0 0,-3.402 6.199l70.047,240.413Z"/>
<path android:fillColor="#E0A240" android:pathData="M436.862,219.022a6.512,6.512 0,0 1,-6.243 -4.683l-11.749,-40.323a6.507,6.507 0,0 1,4.422 -8.059l40.323,-11.749a6.507,6.507 0,0 1,8.059 4.423L483.423,198.955a6.507,6.507 0,0 1,-4.422 8.059l-40.323,11.749A6.479,6.479 0,0 1,436.862 219.022Z"/>
<path android:fillColor="#E0A240" android:pathData="M69.246,144.812a11.691,11.691 0,0 0,-0.43 -1.22,12 12,0 0,0 -22.91,6.67 11.38,11.38 0,0 0,0.29 1.26,12.019 12.019,0 0,0 11.53,8.64 11.749,11.749 0,0 0,3.35 -0.48A12.013,12.013 0,0 0,69.246 144.812ZM60.516,157.762a10.013,10.013 0,0 1,-12.4 -6.8,11.435 11.435,0 0,1 -0.28,-1.26 9.997,9.997 0,0 1,19.04 -5.54,8.338 8.338,0 0,1 0.45,1.21A10.004,10.004 0,0 1,60.516 157.762Z"/>
<path android:fillColor="#E0A240" android:pathData="M39.814,153.382a11.002,11.002 0,0 1,4.208 -12.057,11 11,0 1,0 5.818,19.967A11.002,11.002 0,0 1,39.814 153.382Z"/>
<path android:fillColor="#ccc" android:pathData="M350.676,202.942a6.042,6.042 0,0 0,-7.45 -4.2L276.836,217.312l-7.15,2h44.9l7.15,-2 24.75,-6.92A6.049,6.049 0,0 0,350.676 202.942Z"/>
<path android:fillColor="#ccc" android:pathData="M303.706,189.072a6.045,6.045 0,0 0,-7.45 -4.19l-99.62,27.86a6.068,6.068 0,0 0,-4.37 6.57h25.79l7.16,-2 74.3,-20.78A6.055,6.055 0,0 0,303.706 189.072Z"/>
<path android:fillColor="#3f3d56" android:pathData="M560.17,217.31L77.17,217.31a7.008,7.008 0,0 0,-7 7v286a7.008,7.008 0,0 0,7 7L560.17,517.31a7.008,7.008 0,0 0,7 -7v-286A7.008,7.008 0,0 0,560.17 217.31ZM565.17,510.31a5.002,5.002 0,0 1,-5 5L77.17,515.31a5.002,5.002 0,0 1,-5 -5v-286a5.002,5.002 0,0 1,5 -5L560.17,219.31a5.002,5.002 0,0 1,5 5Z"/>
<path android:fillColor="#E0A240" android:pathData="M124.166,256.312a12,12 0,1 1,12 -12A12.014,12.014 0,0 1,124.166 256.312ZM124.166,234.312a10,10 0,1 0,10 10A10.011,10.011 0,0 0,124.166 234.312Z"/>
<path android:fillColor="#E0A240" android:pathData="M105.514,244.312a11.002,11.002 0,0 1,7.413 -10.399,11 11,0 1,0 0,20.797A11.002,11.002 0,0 1,105.514 244.312Z"/>
<path android:fillColor="#E0A240" android:pathData="M172.81,386.09a9.01,9.01 0,0 1,-9 -9v-27a9,9 0,0 1,18 0v27A9.01,9.01 0,0 1,172.81 386.09Z"/>
<path android:fillColor="#E0A240" android:pathData="M196.81,386.09a9.01,9.01 0,0 1,-9 -9v-27a9,9 0,0 1,18 0v27A9.01,9.01 0,0 1,196.81 386.09Z"/>
<path android:fillColor="#E0A240" android:pathData="M220.81,386.09a9.01,9.01 0,0 1,-9 -9v-27a9,9 0,0 1,18 0v27A9.01,9.01 0,0 1,220.81 386.09Z"/>
<path android:fillColor="#E0A240" android:pathData="M257.81,386.09a9.01,9.01 0,0 1,-9 -9v-27a9,9 0,0 1,18 0v27A9.01,9.01 0,0 1,257.81 386.09Z"/>
<path android:fillColor="#E0A240" android:pathData="M281.81,386.09a9.01,9.01 0,0 1,-9 -9v-27a9,9 0,0 1,18 0v27A9.01,9.01 0,0 1,281.81 386.09Z"/>
<path android:fillColor="#E0A240" android:pathData="M305.81,386.09a9.01,9.01 0,0 1,-9 -9v-27a9,9 0,0 1,18 0v27A9.01,9.01 0,0 1,305.81 386.09Z"/>
<path android:fillColor="#E0A240" android:pathData="M342.81,386.09a9.01,9.01 0,0 1,-9 -9v-27a9,9 0,0 1,18 0v27A9.01,9.01 0,0 1,342.81 386.09Z"/>
<path android:fillColor="#E0A240" android:pathData="M366.81,386.09a9.01,9.01 0,0 1,-9 -9v-27a9,9 0,0 1,18 0v27A9.01,9.01 0,0 1,366.81 386.09Z"/>
<path android:fillColor="#E0A240" android:pathData="M390.81,386.09a9.01,9.01 0,0 1,-9 -9v-27a9,9 0,0 1,18 0v27A9.01,9.01 0,0 1,390.81 386.09Z"/>
<path android:fillColor="#E0A240" android:pathData="M427.81,386.09a9.01,9.01 0,0 1,-9 -9v-27a9,9 0,0 1,18 0v27A9.01,9.01 0,0 1,427.81 386.09Z"/>
<path android:fillColor="#E0A240" android:pathData="M451.81,386.09a9.01,9.01 0,0 1,-9 -9v-27a9,9 0,0 1,18 0v27A9.01,9.01 0,0 1,451.81 386.09Z"/>
<path android:fillColor="#E0A240" android:pathData="M475.81,386.09a9.01,9.01 0,0 1,-9 -9v-27a9,9 0,0 1,18 0v27A9.01,9.01 0,0 1,475.81 386.09Z"/>
<path android:fillColor="#e6e6e6" android:pathData="M233.828,486.257L104.388,486.257a6.047,6.047 0,1 1,0 -12.095L233.828,474.162a6.047,6.047 0,1 1,0 12.095Z"/>
<path android:fillColor="#e6e6e6" android:pathData="M192.328,460.257L145.888,460.257a6.047,6.047 0,1 1,0 -12.095h46.44a6.047,6.047 0,1 1,0 12.095Z"/>
<path android:fillColor="#3f3d56" android:pathData="M71.81,277.09h493v2h-493z"/>
</vector>
This diff is collapsed.
......@@ -5,9 +5,14 @@
xmlns:tools="http://schemas.android.com/tools"
>
<data>
<variable
name="viewModelCart"
type="com.example.yourcashiertest.viewmodels.CartViewModel" />
<variable
name="totalPrice"
type="String" />
<variable
name="totalItems"
type="String" />
......@@ -100,16 +105,18 @@
app:layout_constraintTop_toBottomOf="@+id/rvCartList"
app:layout_constraintVertical_bias="1.0"
tools:layout_editor_absoluteX="39dp" />
<include
<androidx.recyclerview.widget.RecyclerView
android:id="@+id/rvCartList"
layout="@layout/cart_item"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="@dimen/space_default"
app:layout_constraintStart_toStartOf="parent"
android:layout_height="0dp"
android:layout_marginVertical="15dp"
android:padding="@dimen/space_small"
app:layout_constraintBottom_toTopOf="@id/btnCheckout"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/view"
/>
tools:ignore="MissingConstraints" />
</androidx.constraintlayout.widget.ConstraintLayout>
......
......@@ -6,15 +6,25 @@
android:layout_height="match_parent"
android:paddingHorizontal="10dp"
tools:context=".activities.ForgetPassword">
<com.google.android.material.textview.MaterialTextView
android:id="@+id/tvResetPassword"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textSize="25dp"
android:layout_marginStart="10dp"
android:layout_marginTop="50dp"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
android:textStyle="bold"
android:text="RESET PASSWORD"/>
<com.google.android.material.textfield.TextInputLayout
android:id="@+id/tilEmail"
app:boxBackgroundColor="@color/white"
android:textColorHint="@color/grey"
app:boxStrokeColor="@color/black"
style="@style/Widget.MaterialComponents.TextInputLayout.FilledBox.Dense"
style="@style/Widget.MaterialComponents.TextInputLayout.OutlinedBox"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintTop_toBottomOf="@id/tvResetPassword"
android:layout_marginTop="20dp"
android:layout_marginStart="@dimen/space_default"
android:layout_marginEnd="@dimen/space_default"
......@@ -29,17 +39,65 @@
android:imeOptions="actionNext"
android:textSize="@dimen/text_default" />
</com.google.android.material.textfield.TextInputLayout>
<com.google.android.material.button.MaterialButton
android:id="@+id/btnResetPw"
<com.google.android.material.textfield.TextInputLayout
android:id="@+id/tilCrPw"
app:passwordToggleEnabled="true"
app:boxBackgroundColor="@color/white"
android:textColorHint="@color/grey"
style="@style/Widget.MaterialComponents.TextInputLayout.OutlinedBox"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:layout_constraintTop_toBottomOf="@id/tilEmail"
android:layout_marginTop="20dp"
android:layout_marginStart="@dimen/space_default"
android:layout_marginEnd="@dimen/space_default"
android:layout_marginBottom="@dimen/space_default">
<com.google.android.material.textfield.TextInputEditText
android:id="@+id/etCrPw"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="Current Password"
android:imeOptions="actionNext"
android:inputType="text"
android:textSize="@dimen/text_default" />
</com.google.android.material.textfield.TextInputLayout>
<com.google.android.material.textfield.TextInputLayout
android:id="@+id/tilNewPw"
app:passwordToggleEnabled="true"
app:boxBackgroundColor="@color/white"
android:textColorHint="@color/grey"
style="@style/Widget.MaterialComponents.TextInputLayout.OutlinedBox"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:layout_constraintTop_toBottomOf="@id/tilCrPw"
android:layout_marginTop="20dp"
android:layout_marginStart="@dimen/space_default"
android:layout_marginEnd="@dimen/space_default"
android:layout_marginBottom="@dimen/space_default">
<com.google.android.material.textfield.TextInputEditText
android:id="@+id/etNewPw"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="New Password"
android:inputType="text"
android:imeOptions="actionNext"
android:textSize="@dimen/text_default" />
</com.google.android.material.textfield.TextInputLayout>
<com.google.android.material.button.MaterialButton
android:id="@+id/btnResetPw"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="20dp"
android:layout_marginEnd="4dp"
android:backgroundTint="@color/colorPrimary"
android:padding="@dimen/space_default"
android:text="RESET PASSWORD"
app:cornerRadius="@dimen/space_default"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toBottomOf="@+id/tilEmail" />
app:layout_constraintTop_toBottomOf="@+id/tilNewPw"
app:layout_constraintVertical_bias="0.008" />
</androidx.constraintlayout.widget.ConstraintLayout>
\ No newline at end of file
......@@ -17,7 +17,7 @@
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toTopOf="parent"
android:textStyle="bold"
android:text="Login"/>
android:text="LOGIN"/>
<com.google.android.material.textfield.TextInputLayout
android:id="@+id/tilUsername"
......
......@@ -4,9 +4,15 @@
xmlns:tools="http://schemas.android.com/tools">
<data>
<import type="android.view.View" />
<variable
name="viewModel"
type="com.example.yourcashiertest.viewmodels.ProductViewModel" />
<variable
name="visibility"
type="boolean" />
</data>
<androidx.constraintlayout.widget.ConstraintLayout
......
......@@ -48,18 +48,23 @@
<androidx.constraintlayout.widget.ConstraintLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<RadioButton
android:id="@+id/rbCash"
android:layout_width="30dp"
android:layout_height="30dp"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintEnd_toStartOf="@id/iv_cash"/>
<ImageView
android:id="@+id/iv_cash"
android:layout_width="200dp"
android:layout_height="wrap_content"
android:src="@drawable/wallet"
android:layout_width="90dp"
android:layout_height="90dp"
android:src="@drawable/ic_undraw_wallet"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.0"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintVertical_bias="0.8" />
app:layout_constraintStart_toEndOf="@id/rbCash"
app:layout_constraintTop_toTopOf="parent" />
<TextView
android:id="@+id/cash"
......@@ -97,14 +102,13 @@
<ImageView
android:id="@+id/iv_card"
android:layout_width="200dp"
android:layout_height="wrap_content"
android:src="@drawable/credit_card"
android:layout_height="90dp"
android:src="@drawable/ic_undraw_credit_card"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.0"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintVertical_bias="0.8" />
app:layout_constraintTop_toTopOf="parent" />
<TextView
android:id="@+id/card"
......
......@@ -4,9 +4,6 @@
xmlns:tools="http://schemas.android.com/tools">
<data>
<variable
name="photo"
type="String" />
<variable
name="viewModel"
type="com.example.yourcashiertest.viewmodels.ProductViewModel" />
......@@ -18,7 +15,7 @@
android:background="@color/white"
android:layout_height="wrap_content">
<TextView
<com.google.android.material.textview.MaterialTextView
android:id="@+id/tvHeadProduct"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
......@@ -42,11 +39,11 @@
<ImageView
android:id="@+id/ivProduct"
android:layout_width="146dp"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:scaleType="centerCrop"
android:src="@drawable/unnamed"
app:file="@{photo}" />
app:file="@{viewModel.product.photo}"/>
</com.google.android.material.card.MaterialCardView>
......
......@@ -10,12 +10,12 @@
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textSize="25dp"
android:layout_marginTop="80dp"
android:layout_marginTop="50dp"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toTopOf="parent"
android:textStyle="bold"
android:text="Register Account"/>
android:text="REGISTER ACCOUNT"/>
<com.google.android.material.textfield.TextInputLayout
android:id="@+id/tilUsername"
......@@ -23,7 +23,7 @@
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:layout_constraintTop_toBottomOf="@+id/tvRegister"
android:layout_marginTop="60dp"
android:layout_marginTop="40dp"
android:layout_marginStart="@dimen/space_default"
android:layout_marginEnd="@dimen/space_default"
android:layout_marginBottom="@dimen/space_default">
......@@ -98,11 +98,45 @@
android:imeOptions="actionNext"
android:textSize="@dimen/text_default" />
</com.google.android.material.textfield.TextInputLayout>
<com.google.android.material.textview.MaterialTextView
android:id="@+id/tvDescSk"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="10dp"
android:layout_marginTop="15dp"
android:text="By registering you have agreed to the"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/tilPassword" />
<com.google.android.material.textview.MaterialTextView
android:id="@+id/tvSK"
android:onClick="tvSK"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="75dp"
android:layout_marginTop="10dp"
android:text="Terms and Conditions"
android:textColor="@color/blue"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/tvDescSk" />
<com.google.android.material.textview.MaterialTextView
android:id="@+id/tvYourCashier"
android:onClick="tvSignInHere"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="2dp"
android:layout_marginTop="10dp"
android:text="Your Cashier"
app:layout_constraintStart_toEndOf="@id/tvSK"
app:layout_constraintTop_toBottomOf="@id/tvDescSk"/>
<com.google.android.material.button.MaterialButton
android:id="@+id/btnRegister"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="20dp"
android:layout_marginTop="15dp"
android:layout_marginStart="@dimen/space_default"
android:layout_marginEnd="@dimen/space_default"
android:backgroundTint="@color/colorPrimary"
......@@ -110,13 +144,13 @@
android:text="Register My Account"
app:cornerRadius="@dimen/space_default"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toBottomOf="@+id/tilPassword" />
app:layout_constraintTop_toBottomOf="@+id/tvSK" />
<com.google.android.material.textview.MaterialTextView
android:id="@+id/tvDontHaveAnAccount"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="60dp"
android:layout_marginStart="75dp"
android:layout_marginTop="15dp"
android:text="@string/dont_have_an_account"
app:layout_constraintEnd_toStartOf="@id/tvSignInHere"
......
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".activities.SkActivity">
<WebView
android:id="@+id/wbCompany"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:visibility="gone"
tools:context=".materials.designs.webview.CompanyActivity" />
<ProgressBar
android:id="@+id/pbLoading"
android:layout_width="128dp"
android:layout_height="128dp"
android:layout_centerInParent="true" />
</RelativeLayout>
\ No newline at end of file
......@@ -17,12 +17,4 @@
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<ProgressBar
android:id="@+id/pbLoading"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toBottomOf="@id/ivLogo"
app:layout_constraintBottom_toBottomOf="parent"/>
</androidx.constraintlayout.widget.ConstraintLayout>
\ No newline at end of file
......@@ -6,7 +6,7 @@
<data>
<variable
name="cartProduct"
type="com.example.yourcashiertest.entities.Product" />
type="com.example.yourcashiertest.entities.Cart" />
<variable
name="qty"
type="String" />
......
......@@ -15,7 +15,7 @@
<variable
name="visibility"
type="Boolean" />
type="boolean" />
</data>
<com.google.android.material.card.MaterialCardView
......@@ -50,7 +50,7 @@
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:padding="@dimen/space_small"
android:visibility="visible"
android:visibility="@{visibility ? View.VISIBLE : View.GONE}"
android:src="@drawable/ic_update"
app:layout_constraintBottom_toBottomOf="@+id/iv_product"
app:layout_constraintStart_toStartOf="@+id/iv_product"
......@@ -63,7 +63,7 @@
android:layout_height="wrap_content"
android:layout_alignParentEnd="true"
android:padding="@dimen/space_small"
android:visibility="visible"
android:visibility="@{visibility ? View.VISIBLE : View.GONE}"
android:src="@drawable/ic_delete"
app:layout_constraintBottom_toBottomOf="@+id/iv_product"
app:layout_constraintEnd_toEndOf="@+id/iv_product"
......
......@@ -6,4 +6,7 @@
<item
android:id="@+id/item_two"
android:title="Update / Delete Product"/>
<item
android:id="@+id/item_three"
android:title="Log Out"/>
</menu>
\ No newline at end of file
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