Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in / Register
Toggle navigation
Y
Your Cashier
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
Ahmad Abi Mulya
Your Cashier
Commits
5500bf2e
Commit
5500bf2e
authored
Aug 25, 2020
by
Ahmad Abi Mulya
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add Login Validation and Payment Activity
parent
e1f16914
Show whitespace changes
Inline
Side-by-side
Showing
32 changed files
with
927 additions
and
152 deletions
+927
-152
build.gradle
app/build.gradle
+20
-10
AndroidManifest.xml
app/src/main/AndroidManifest.xml
+3
-2
CartActivity.java
.../com/example/yourcashiertest/activities/CartActivity.java
+9
-0
LoginActivity.java
...com/example/yourcashiertest/activities/LoginActivity.java
+49
-0
MainActivity.java
.../com/example/yourcashiertest/activities/MainActivity.java
+25
-31
SplashActivity.java
...om/example/yourcashiertest/activities/SplashActivity.java
+1
-1
ProductAdapter.java
.../com/example/yourcashiertest/adapters/ProductAdapter.java
+91
-0
ProductDao.java
...ain/java/com/example/yourcashiertest/daos/ProductDao.java
+31
-0
LocalDatabase.java
.../com/example/yourcashiertest/databases/LocalDatabase.java
+59
-0
Product.java
...in/java/com/example/yourcashiertest/entities/Product.java
+121
-0
ProductRepository.java
...ample/yourcashiertest/repositories/ProductRepository.java
+41
-0
ProductViewModel.java
.../example/yourcashiertest/viewmodels/ProductViewModel.java
+76
-0
btn_shape.xml
app/src/main/res/drawable/btn_shape.xml
+14
-0
burger.jpg
app/src/main/res/drawable/burger.jpg
+0
-0
credit_card.png
app/src/main/res/drawable/credit_card.png
+0
-0
edit_text.xml
app/src/main/res/drawable/edit_text.xml
+4
-0
elips.xml
app/src/main/res/drawable/elips.xml
+1
-1
ic_baseline_add_shopping_cart_24.xml
...rc/main/res/drawable/ic_baseline_add_shopping_cart_24.xml
+5
-0
ic_delete.xml
app/src/main/res/drawable/ic_delete.xml
+12
-0
ic_update.xml
app/src/main/res/drawable/ic_update.xml
+12
-0
splash2.xml
app/src/main/res/drawable/splash2.xml
+8
-0
wallet.png
app/src/main/res/drawable/wallet.png
+0
-0
activity_cart.xml
app/src/main/res/layout/activity_cart.xml
+11
-0
activity_login.xml
app/src/main/res/layout/activity_login.xml
+80
-0
activity_main.xml
app/src/main/res/layout/activity_main.xml
+1
-2
activity_payment.xml
app/src/main/res/layout/activity_payment.xml
+106
-58
activity_product.xml
app/src/main/res/layout/activity_product.xml
+5
-0
activity_splash.xml
app/src/main/res/layout/activity_splash.xml
+1
-1
cart_item.xml
app/src/main/res/layout/cart_item.xml
+9
-9
item_list.xml
app/src/main/res/layout/item_list.xml
+125
-35
strings.xml
app/src/main/res/values/strings.xml
+5
-0
styles.xml
app/src/main/res/values/styles.xml
+2
-2
No files found.
app/build.gradle
View file @
5500bf2e
apply
plugin:
'com.android.application'
apply
plugin:
'com.android.application'
android
{
android
{
compileSdkVersion
30
compileSdkVersion
29
buildToolsVersion
"30.0.2"
buildToolsVersion
"30.0.2"
defaultConfig
{
defaultConfig
{
applicationId
"com.example.yourcashiertest"
applicationId
"com.example.yourcashiertest"
minSdkVersion
23
minSdkVersion
23
targetSdkVersion
30
targetSdkVersion
29
versionCode
1
versionCode
1
versionName
"1.0"
versionName
"1.0"
...
@@ -33,15 +33,25 @@ android {
...
@@ -33,15 +33,25 @@ android {
dependencies
{
dependencies
{
implementation
fileTree
(
dir:
"libs"
,
include:
[
"*.jar"
])
implementation
fileTree
(
dir:
"libs"
,
include:
[
"*.jar"
])
implementation
'androidx.appcompat:appcompat:1.2.0'
implementation
'androidx.appcompat:appcompat:1.2.0'
implementation
'com.google.android.material:material:1.2.0'
implementation
'androidx.constraintlayout:constraintlayout:1.1.3'
implementation
'androidx.constraintlayout:constraintlayout:1.1.3'
testImplementation
'junit:junit:4.12'
def
room_version
=
"2.2.5"
implementation
"androidx.room:room-runtime:$room_version"
annotationProcessor
"androidx.room:room-compiler:$room_version"
def
lifecycle_version
=
"2.2.0"
implementation
"androidx.lifecycle:lifecycle-extensions:$lifecycle_version"
implementation
"androidx.lifecycle:lifecycle-common-java8:$lifecycle_version"
def
glide_version
=
"4.11.0"
implementation
"com.github.bumptech.glide:glide:$glide_version"
annotationProcessor
"com.github.bumptech.glide:compiler:$glide_version"
testImplementation
'junit:junit:4.13'
androidTestImplementation
'androidx.test.ext:junit:1.1.1'
androidTestImplementation
'androidx.test.ext:junit:1.1.1'
androidTestImplementation
'androidx.test.espresso:espresso-core:3.2.0'
androidTestImplementation
'androidx.test.espresso:espresso-core:3.2.0'
implementation
"androidx.lifecycle:lifecycle-extensions:2.2.0"
implementation
"androidx.lifecycle:lifecycle-common-java8:2.2.0"
implementation
'com.google.android.material:material:1.2.0'
implementation
"com.github.bumptech.glide:glide:4.11.0"
annotationProcessor
"com.github.bumptech.glide:compiler:4.11.0"
implementation
"androidx.room:room-runtime:2.2.5"
annotationProcessor
"androidx.room:room-compiler:2.2.5"
}
}
\ No newline at end of file
app/src/main/AndroidManifest.xml
View file @
5500bf2e
...
@@ -22,8 +22,9 @@
...
@@ -22,8 +22,9 @@
<activity
<activity
android:name=
".activities.CartActivity"
android:name=
".activities.CartActivity"
android:theme=
"@style/AppTheme2"
/>
android:theme=
"@style/AppTheme2"
/>
<activity
android:name=
".activities.MainActivity"
android:theme=
"@style/AppTheme2"
/>
<activity
android:name=
".activities.MainActivity"
/>
<activity
android:name=
".activities.ProductActivity"
android:theme=
"@style/AppTheme2"
/>
<activity
android:name=
".activities.ProductActivity"
/>
<activity
android:name=
".activities.LoginActivity"
/>
<meta-data
<meta-data
android:name=
"preloaded_fonts"
android:name=
"preloaded_fonts"
android:resource=
"@array/preloaded_fonts"
/>
android:resource=
"@array/preloaded_fonts"
/>
...
...
app/src/main/java/com/example/yourcashiertest/activities/CartActivity.java
View file @
5500bf2e
...
@@ -12,11 +12,13 @@ import com.example.yourcashiertest.R;
...
@@ -12,11 +12,13 @@ import com.example.yourcashiertest.R;
public
class
CartActivity
extends
AppCompatActivity
{
public
class
CartActivity
extends
AppCompatActivity
{
ImageView
btnBack
;
ImageView
btnBack
;
Button
btnCheckout
;
@Override
@Override
protected
void
onCreate
(
Bundle
savedInstanceState
)
{
protected
void
onCreate
(
Bundle
savedInstanceState
)
{
super
.
onCreate
(
savedInstanceState
);
super
.
onCreate
(
savedInstanceState
);
setContentView
(
R
.
layout
.
activity_cart
);
setContentView
(
R
.
layout
.
activity_cart
);
btnCheckout
=
findViewById
(
R
.
id
.
btnCheckout
);
btnBack
=
findViewById
(
R
.
id
.
ivBtnBack
);
btnBack
=
findViewById
(
R
.
id
.
ivBtnBack
);
btnBack
.
setOnClickListener
(
new
View
.
OnClickListener
()
{
btnBack
.
setOnClickListener
(
new
View
.
OnClickListener
()
{
@Override
@Override
...
@@ -24,5 +26,12 @@ public class CartActivity extends AppCompatActivity {
...
@@ -24,5 +26,12 @@ public class CartActivity extends AppCompatActivity {
startActivity
(
new
Intent
(
CartActivity
.
this
,
MainActivity
.
class
));
startActivity
(
new
Intent
(
CartActivity
.
this
,
MainActivity
.
class
));
}
}
});
});
btnCheckout
.
setOnClickListener
(
new
View
.
OnClickListener
()
{
@Override
public
void
onClick
(
View
view
)
{
startActivity
(
new
Intent
(
CartActivity
.
this
,
PaymentActivity
.
class
));
}
});
}
}
}
}
\ No newline at end of file
app/src/main/java/com/example/yourcashiertest/activities/LoginActivity.java
0 → 100644
View file @
5500bf2e
package
com
.
example
.
yourcashiertest
.
activities
;
import
androidx.appcompat.app.AppCompatActivity
;
import
android.content.Intent
;
import
android.os.Bundle
;
import
android.view.View
;
import
android.widget.Toast
;
import
com.example.yourcashiertest.R
;
import
com.google.android.material.button.MaterialButton
;
import
com.google.android.material.textfield.TextInputEditText
;
public
class
LoginActivity
extends
AppCompatActivity
{
TextInputEditText
etUsername
,
etPassword
;
MaterialButton
btnLogin
;
@Override
protected
void
onCreate
(
Bundle
savedInstanceState
)
{
super
.
onCreate
(
savedInstanceState
);
setContentView
(
R
.
layout
.
activity_login
);
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
)
{
Intent
intent
=
new
Intent
(
LoginActivity
.
this
,
MainActivity
.
class
);
intent
.
putExtra
(
"username"
,
etUsername
.
getText
().
toString
());
if
(
etUsername
.
getText
().
toString
().
length
()
==
0
||
etPassword
.
getText
().
toString
().
length
()
==
0
){
Toast
.
makeText
(
getApplicationContext
(),
"Please input Username and Password"
,
Toast
.
LENGTH_SHORT
).
show
();
}
else
if
(!
etPassword
.
getText
().
toString
().
matches
(
"[A-Za-z0-9]+"
)){
etPassword
.
setError
(
"Passwords can only contain Alphanumeric"
);
}
else
if
(
etPassword
.
getText
().
toString
().
length
()
<
8
)
{
etPassword
.
setError
(
"Password length cannot be less than 8 characters"
);
}
else
{
finish
();
startActivity
(
intent
);
}
}
});
}
}
\ No newline at end of file
app/src/main/java/com/example/yourcashiertest/activities/MainActivity.java
View file @
5500bf2e
...
@@ -9,33 +9,29 @@ import android.view.MenuItem;
...
@@ -9,33 +9,29 @@ import android.view.MenuItem;
import
android.view.View
;
import
android.view.View
;
import
android.widget.ImageView
;
import
android.widget.ImageView
;
import
android.widget.PopupMenu
;
import
android.widget.PopupMenu
;
import
android.widget.TextView
;
import
com.example.yourcashiertest.R
;
import
com.example.yourcashiertest.R
;
import
com.google.android.material.textfield.TextInputEditText
;
public
class
MainActivity
extends
AppCompatActivity
{
public
class
MainActivity
extends
AppCompatActivity
{
TextView
tv_user
;
ImageView
iv_settings
,
ivCart
;
@Override
@Override
protected
void
onCreate
(
Bundle
savedInstanceState
)
{
protected
void
onCreate
(
Bundle
savedInstanceState
)
{
super
.
onCreate
(
savedInstanceState
);
super
.
onCreate
(
savedInstanceState
);
setContentView
(
R
.
layout
.
activity_main
);
setContentView
(
R
.
layout
.
activity_main
);
ImageView
iv_settings
,
ivCart
;
tv_user
=
findViewById
(
R
.
id
.
tv_user
);
ivCart
=
findViewById
(
R
.
id
.
ivCart
);
ivCart
=
findViewById
(
R
.
id
.
ivCart
);
iv_settings
=
findViewById
(
R
.
id
.
iv_settings
);
iv_settings
=
findViewById
(
R
.
id
.
iv_settings
);
ivCart
.
setOnClickListener
(
new
View
.
OnClickListener
()
{
@Override
tv_user
.
setText
(
getIntent
().
getStringExtra
(
"username"
));
public
void
onClick
(
View
view
)
{
ivCart
.
setOnClickListener
(
view
->
startActivity
(
new
Intent
(
MainActivity
.
this
,
CartActivity
.
class
)));
startActivity
(
new
Intent
(
MainActivity
.
this
,
CartActivity
.
class
));
iv_settings
.
setOnClickListener
(
view
->
{
}
});
iv_settings
.
setOnClickListener
(
new
View
.
OnClickListener
()
{
@Override
public
void
onClick
(
View
view
)
{
PopupMenu
popupMenu
=
new
PopupMenu
(
getApplicationContext
(),
iv_settings
);
PopupMenu
popupMenu
=
new
PopupMenu
(
getApplicationContext
(),
iv_settings
);
popupMenu
.
setOnMenuItemClickListener
(
new
PopupMenu
.
OnMenuItemClickListener
()
{
popupMenu
.
setOnMenuItemClickListener
(
item
->
{
@Override
public
boolean
onMenuItemClick
(
MenuItem
item
)
{
switch
(
item
.
getItemId
())
{
switch
(
item
.
getItemId
())
{
case
R
.
id
.
item_one
:
case
R
.
id
.
item_one
:
// item one clicked
// item one clicked
...
@@ -47,11 +43,9 @@ public class MainActivity extends AppCompatActivity {
...
@@ -47,11 +43,9 @@ public class MainActivity extends AppCompatActivity {
}
}
return
false
;
return
false
;
}
});
});
popupMenu
.
inflate
(
R
.
menu
.
settings_menu
);
popupMenu
.
inflate
(
R
.
menu
.
settings_menu
);
popupMenu
.
show
();
popupMenu
.
show
();
}
});
});
}
}
}
}
\ No newline at end of file
app/src/main/java/com/example/yourcashiertest/activities/SplashActivity.java
View file @
5500bf2e
...
@@ -14,7 +14,7 @@ public class SplashActivity extends AppCompatActivity {
...
@@ -14,7 +14,7 @@ public class SplashActivity extends AppCompatActivity {
super
.
onCreate
(
savedInstanceState
);
super
.
onCreate
(
savedInstanceState
);
setContentView
(
R
.
layout
.
activity_splash
);
setContentView
(
R
.
layout
.
activity_splash
);
new
Handler
(
Looper
.
getMainLooper
()).
postDelayed
(()
->
{
new
Handler
(
Looper
.
getMainLooper
()).
postDelayed
(()
->
{
startActivity
(
new
Intent
(
this
,
Ma
inActivity
.
class
));
startActivity
(
new
Intent
(
this
,
Log
inActivity
.
class
));
finish
();
finish
();
},
3000
);
},
3000
);
}
}
...
...
app/src/main/java/com/example/yourcashiertest/adapters/ProductAdapter.java
0 → 100644
View file @
5500bf2e
package
com
.
example
.
yourcashiertest
.
adapters
;
import
android.view.LayoutInflater
;
import
android.view.ViewGroup
;
import
androidx.annotation.NonNull
;
import
androidx.databinding.DataBindingUtil
;
import
androidx.recyclerview.widget.RecyclerView
;
import
com.example.yourcashiertest.R
;
import
com.example.yourcashiertest.databinding.ItemListBinding
;
import
com.example.yourcashiertest.entities.Product
;
import
java.text.DecimalFormat
;
import
java.text.DecimalFormatSymbols
;
import
java.util.ArrayList
;
import
java.util.List
;
public
class
ProductAdapter
extends
RecyclerView
.
Adapter
<
ProductAdapter
.
ViewHolder
>
{
private
List
<
Product
>
products
=
new
ArrayList
<>();
public
interface
ProductListener
{
void
onUpdate
(
Product
product
);
void
onDelete
(
Product
product
);
}
private
ProductListener
listener
;
public
void
setListener
(
ProductListener
listener
)
{
this
.
listener
=
listener
;
}
public
void
setProducts
(
List
<
Product
>
products
)
{
this
.
products
=
products
;
notifyDataSetChanged
();
}
@NonNull
@Override
public
ProductAdapter
.
ViewHolder
onCreateViewHolder
(
@NonNull
ViewGroup
parent
,
int
viewType
)
{
return
new
ViewHolder
(
DataBindingUtil
.
inflate
(
LayoutInflater
.
from
(
parent
.
getContext
()),
R
.
layout
.
item_product
,
parent
,
false
)
);
}
@Override
public
void
onBindViewHolder
(
@NonNull
ProductAdapter
.
ViewHolder
holder
,
int
position
)
{
holder
.
bindData
(
products
.
get
(
position
),
listener
);
}
@Override
public
int
getItemCount
()
{
return
products
.
size
();
}
public
static
class
ViewHolder
extends
RecyclerView
.
ViewHolder
{
private
ItemListBinding
binding
;
public
ViewHolder
(
@NonNull
ItemListBinding
binding
)
{
super
(
binding
.
getRoot
());
this
.
binding
=
binding
;
}
public
void
bindData
(
Product
product
,
ProductListener
listener
)
{
binding
.
setProduct
(
product
);
DecimalFormat
rupiah
=
(
DecimalFormat
)
DecimalFormat
.
getCurrencyInstance
();
DecimalFormatSymbols
format
=
new
DecimalFormatSymbols
();
format
.
setCurrencySymbol
(
"Rp. "
);
format
.
setMonetaryDecimalSeparator
(
','
);
format
.
setGroupingSeparator
(
'.'
);
rupiah
.
setDecimalFormatSymbols
(
format
);
binding
.
setPrice
(
rupiah
.
format
(
product
.
getPrice
()));
binding
.
ivUpdate
.
setOnClickListener
(
view
->
listener
.
onUpdate
(
product
));
binding
.
ivDelete
.
setOnClickListener
(
view
->
listener
.
onDelete
(
product
));
}
}
}
\ No newline at end of file
app/src/main/java/com/example/yourcashiertest/daos/ProductDao.java
0 → 100644
View file @
5500bf2e
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.Product
;
import
java.util.List
;
@Dao
public
interface
ProductDao
{
@Query
(
"SELECT * FROM products ORDER BY id DESC"
)
public
LiveData
<
List
<
Product
>>
getProducts
();
@Query
(
"SELECT * FROM products WHERE name LIKE :query ORDER BY id DESC"
)
public
LiveData
<
List
<
Product
>>
getFilteredProducts
(
String
query
);
@Insert
(
onConflict
=
OnConflictStrategy
.
IGNORE
)
public
void
insertProduct
(
Product
product
);
@Update
public
void
updateProduct
(
Product
product
);
@Delete
public
void
deleteProduct
(
Product
product
);
}
app/src/main/java/com/example/yourcashiertest/databases/LocalDatabase.java
0 → 100644
View file @
5500bf2e
package
com
.
example
.
yourcashiertest
.
databases
;
import
android.content.Context
;
import
androidx.annotation.NonNull
;
import
androidx.room.Database
;
import
androidx.room.DatabaseConfiguration
;
import
androidx.room.InvalidationTracker
;
import
androidx.room.Room
;
import
androidx.room.RoomDatabase
;
import
androidx.sqlite.db.SupportSQLiteOpenHelper
;
import
com.example.yourcashiertest.daos.ProductDao
;
import
com.example.yourcashiertest.entities.Product
;
import
java.util.concurrent.ExecutorService
;
import
java.util.concurrent.Executors
;
@Database
(
entities
=
{
Product
.
class
},
version
=
1
,
exportSchema
=
false
)
public
abstract
class
LocalDatabase
extends
RoomDatabase
{
public
abstract
ProductDao
productDao
();
private
static
volatile
LocalDatabase
INSTANCE
;
private
static
final
int
NUMBER_OF_THREADS
=
4
;
public
static
final
ExecutorService
databaseWriteExecutor
=
Executors
.
newFixedThreadPool
(
NUMBER_OF_THREADS
);
public
static
LocalDatabase
getDatabase
(
Context
context
)
{
if
(
INSTANCE
==
null
)
{
synchronized
(
LocalDatabase
.
class
)
{
if
(
INSTANCE
==
null
)
{
INSTANCE
=
Room
.
databaseBuilder
(
context
.
getApplicationContext
(),
LocalDatabase
.
class
,
"pasarindo_database"
)
.
build
();
}
}
}
return
INSTANCE
;
}
@NonNull
@Override
protected
SupportSQLiteOpenHelper
createOpenHelper
(
DatabaseConfiguration
config
)
{
return
null
;
}
@NonNull
@Override
protected
InvalidationTracker
createInvalidationTracker
()
{
return
null
;
}
@Override
public
void
clearAllTables
()
{
}
}
app/src/main/java/com/example/yourcashiertest/entities/Product.java
0 → 100644
View file @
5500bf2e
package
com
.
example
.
yourcashiertest
.
entities
;
import
android.os.Parcel
;
import
android.os.Parcelable
;
import
androidx.room.Entity
;
import
androidx.room.PrimaryKey
;
@Entity
(
tableName
=
"products"
)
public
class
Product
implements
Parcelable
{
@PrimaryKey
(
autoGenerate
=
true
)
private
long
id
;
private
long
price
,
quantity
;
private
String
photo
=
""
,
name
=
""
,
description
=
""
,
category
=
""
;
public
Product
(
long
price
,
long
quantity
,
String
photo
,
String
name
,
String
description
,
String
category
)
{
this
.
price
=
price
;
this
.
quantity
=
quantity
;
this
.
photo
=
photo
;
this
.
name
=
name
;
this
.
description
=
description
;
this
.
category
=
category
;
}
protected
Product
(
Parcel
in
)
{
id
=
in
.
readLong
();
price
=
in
.
readLong
();
quantity
=
in
.
readLong
();
photo
=
in
.
readString
();
name
=
in
.
readString
();
description
=
in
.
readString
();
category
=
in
.
readString
();
}
public
static
final
Creator
<
Product
>
CREATOR
=
new
Creator
<
Product
>()
{
@Override
public
Product
createFromParcel
(
Parcel
in
)
{
return
new
Product
(
in
);
}
@Override
public
Product
[]
newArray
(
int
size
)
{
return
new
Product
[
size
];
}
};
public
long
getId
()
{
return
id
;
}
public
void
setId
(
long
id
)
{
this
.
id
=
id
;
}
public
long
getPrice
()
{
return
price
;
}
public
void
setPrice
(
long
price
)
{
this
.
price
=
price
;
}
public
long
getQuantity
()
{
return
quantity
;
}
public
void
setQuantity
(
long
quantity
)
{
this
.
quantity
=
quantity
;
}
public
String
getPhoto
()
{
return
photo
;
}
public
void
setPhoto
(
String
photo
)
{
this
.
photo
=
photo
;
}
public
String
getName
()
{
return
name
;
}
public
void
setName
(
String
name
)
{
this
.
name
=
name
;
}
public
String
getDescription
()
{
return
description
;
}
public
void
setDescription
(
String
description
)
{
this
.
description
=
description
;
}
public
String
getCategory
()
{
return
category
;
}
public
void
setCategory
(
String
category
)
{
this
.
category
=
category
;
}
@Override
public
int
describeContents
()
{
return
0
;
}
@Override
public
void
writeToParcel
(
Parcel
parcel
,
int
i
)
{
parcel
.
writeLong
(
id
);
parcel
.
writeLong
(
price
);
parcel
.
writeLong
(
quantity
);
parcel
.
writeString
(
photo
);
parcel
.
writeString
(
name
);
parcel
.
writeString
(
description
);
parcel
.
writeString
(
category
);
}
}
app/src/main/java/com/example/yourcashiertest/repositories/ProductRepository.java
0 → 100644
View file @
5500bf2e
package
com
.
example
.
yourcashiertest
.
repositories
;
import
android.app.Application
;
import
androidx.lifecycle.LiveData
;
import
com.example.yourcashiertest.daos.ProductDao
;
import
com.example.yourcashiertest.databases.LocalDatabase
;
import
com.example.yourcashiertest.entities.Product
;
import
java.util.List
;
public
class
ProductRepository
{
private
ProductDao
productDao
;
private
LiveData
<
List
<
Product
>>
products
;
public
ProductRepository
(
Application
application
)
{
LocalDatabase
db
=
LocalDatabase
.
getDatabase
(
application
);
productDao
=
db
.
productDao
();
products
=
productDao
.
getProducts
();
}
public
void
insert
(
Product
product
)
{
LocalDatabase
.
databaseWriteExecutor
.
execute
(()
->
productDao
.
insertProduct
(
product
));
}
public
void
update
(
Product
product
)
{
LocalDatabase
.
databaseWriteExecutor
.
execute
(()
->
productDao
.
updateProduct
(
product
));
}
public
void
delete
(
Product
product
)
{
LocalDatabase
.
databaseWriteExecutor
.
execute
(()
->
productDao
.
deleteProduct
(
product
));
}
public
LiveData
<
List
<
Product
>>
filteredProducts
(
String
s
)
{
return
productDao
.
getFilteredProducts
(
s
);
}
}
app/src/main/java/com/example/yourcashiertest/viewmodels/ProductViewModel.java
0 → 100644
View file @
5500bf2e
package
com
.
example
.
yourcashiertest
.
viewmodels
;
import
android.app.Application
;
import
android.text.TextUtils
;
import
androidx.annotation.NonNull
;
import
androidx.lifecycle.AndroidViewModel
;
import
androidx.lifecycle.LiveData
;
import
androidx.lifecycle.MutableLiveData
;
import
androidx.lifecycle.Transformations
;
import
com.example.yourcashiertest.entities.Product
;
import
com.example.yourcashiertest.repositories.ProductRepository
;
import
java.io.File
;
import
java.util.List
;
public
class
ProductViewModel
extends
AndroidViewModel
{
private
MutableLiveData
<
String
>
photo
=
new
MutableLiveData
<>(
""
);
private
MutableLiveData
<
String
>
query
=
new
MutableLiveData
<>(
"%"
);
private
MutableLiveData
<
Product
>
product
=
new
MutableLiveData
<>();
private
LiveData
<
List
<
Product
>>
products
;
private
ProductRepository
repository
;
public
void
setPhoto
(
String
photo
)
{
this
.
photo
.
setValue
(
photo
);
}
public
void
setProduct
(
Product
product
)
{
this
.
product
.
setValue
(
product
);
}
public
LiveData
<
String
>
getPhoto
()
{
return
photo
;
}
public
LiveData
<
List
<
Product
>>
getProducts
()
{
return
products
;
}
public
ProductViewModel
(
@NonNull
Application
application
)
{
super
(
application
);
repository
=
new
ProductRepository
(
application
);
products
=
Transformations
.
switchMap
(
query
,
s
->
repository
.
filteredProducts
(
s
));
}
public
void
filter
(
String
s
)
{
String
query
=
TextUtils
.
isEmpty
(
s
)
?
"%"
:
"%"
+
s
+
"%"
;
this
.
query
.
postValue
(
query
);
}
public
void
insertProduct
(
Product
product
)
{
repository
.
insert
(
product
);
}
public
void
updateProduct
(
Product
product
)
{
repository
.
update
(
product
);
}
public
void
deleteProduct
(
Product
product
)
{
File
photo
=
new
File
(
product
.
getPhoto
());
if
(
photo
.
exists
()
&&
photo
.
delete
())
System
.
out
.
println
(
"DELETED: "
+
product
.
getPhoto
());
repository
.
delete
(
product
);
}
public
MutableLiveData
<
Product
>
getProduct
()
{
return
product
;
}
}
\ No newline at end of file
app/src/main/res/drawable/btn_shape.xml
0 → 100644
View file @
5500bf2e
<?xml version="1.0" encoding="utf-8"?>
<shape
xmlns:android=
"http://schemas.android.com/apk/res/android"
android:shape=
"rectangle"
>
<corners
android:radius=
"50dp"
/>
<stroke
android:width=
"0.5dp"
android:color=
"#45E1D1"
/>
<solid
android:color=
"#45E1D1"
/>
</shape>
\ No newline at end of file
app/src/main/res/drawable/burger.jpg
0 → 100644
View file @
5500bf2e
33 KB
app/src/main/res/drawable/credit_card.png
0 → 100644
View file @
5500bf2e
18.2 KB
app/src/main/res/drawable/edit_text.xml
0 → 100644
View file @
5500bf2e
<?xml version="1.0" encoding="utf-8"?>
<selector
xmlns:android=
"http://schemas.android.com/apk/res/android"
>
</selector>
\ No newline at end of file
app/src/main/res/drawable/elips.xml
View file @
5500bf2e
...
@@ -6,7 +6,7 @@
...
@@ -6,7 +6,7 @@
android:radius=
"200dp"
/>
android:radius=
"200dp"
/>
<stroke
<stroke
android:width=
"
0.5
dp"
android:width=
"
10
dp"
android:color=
"#FFFFFF"
/>
android:color=
"#FFFFFF"
/>
<solid
android:color=
"@color/color_white"
/>
<solid
android:color=
"@color/color_white"
/>
...
...
app/src/main/res/drawable/ic_baseline_add_shopping_cart_24.xml
0 → 100644
View file @
5500bf2e
<vector
android:height=
"24dp"
android:tint=
"#FFFFFF"
android:viewportHeight=
"24"
android:viewportWidth=
"24"
android:width=
"24dp"
xmlns:android=
"http://schemas.android.com/apk/res/android"
>
<path
android:fillColor=
"@android:color/white"
android:pathData=
"M11,9h2L13,6h3L16,4h-3L13,1h-2v3L8,4v2h3v3zM7,18c-1.1,0 -1.99,0.9 -1.99,2S5.9,22 7,22s2,-0.9 2,-2 -0.9,-2 -2,-2zM17,18c-1.1,0 -1.99,0.9 -1.99,2s0.89,2 1.99,2 2,-0.9 2,-2 -0.9,-2 -2,-2zM7.17,14.75l0.03,-0.12 0.9,-1.63h7.45c0.75,0 1.41,-0.41 1.75,-1.03l3.86,-7.01L19.42,4h-0.01l-1.1,2 -2.76,5L8.53,11l-0.13,-0.27L6.16,6l-0.95,-2 -0.94,-2L1,2v2h2l3.6,7.59 -1.35,2.45c-0.16,0.28 -0.25,0.61 -0.25,0.96 0,1.1 0.9,2 2,2h12v-2L7.42,15c-0.13,0 -0.25,-0.11 -0.25,-0.25z"
/>
</vector>
app/src/main/res/drawable/ic_delete.xml
0 → 100644
View file @
5500bf2e
<vector
xmlns:android=
"http://schemas.android.com/apk/res/android"
android:width=
"24dp"
android:height=
"24dp"
android:viewportWidth=
"380"
android:viewportHeight=
"384"
>
<path
android:fillColor=
"@android:color/white"
android:pathData=
"M64,341.333C64,364.907 83.093,384 106.667,384h170.667C300.907,384 320,364.907 320,341.333v-256H64V341.333z"
/>
<path
android:fillColor=
"@android:color/white"
android:pathData=
"M266.667,21.333l-21.334,-21.333l-106.666,0l-21.334,21.333l-74.666,0l0,42.667l298.666,0l0,-42.667z"
/>
</vector>
app/src/main/res/drawable/ic_update.xml
0 → 100644
View file @
5500bf2e
<vector
xmlns:android=
"http://schemas.android.com/apk/res/android"
android:width=
"24dp"
android:height=
"24dp"
android:viewportWidth=
"348.882"
android:viewportHeight=
"348.882"
>
<path
android:fillColor=
"@android:color/white"
android:pathData=
"M333.988,11.758l-0.42,-0.383C325.538,4.04 315.129,0 304.258,0c-12.187,0 -23.888,5.159 -32.104,14.153L116.803,184.231c-1.416,1.55 -2.49,3.379 -3.154,5.37l-18.267,54.762c-2.112,6.331 -1.052,13.333 2.835,18.729c3.918,5.438 10.23,8.685 16.886,8.685c0,0 0.001,0 0.001,0c2.879,0 5.693,-0.592 8.362,-1.76l52.89,-23.138c1.923,-0.841 3.648,-2.076 5.063,-3.626L336.771,73.176C352.937,55.479 351.69,27.929 333.988,11.758zM130.381,234.247l10.719,-32.134l0.904,-0.99l20.316,18.556l-0.904,0.99L130.381,234.247zM314.621,52.943L182.553,197.53l-20.316,-18.556L294.305,34.386c2.583,-2.828 6.118,-4.386 9.954,-4.386c3.365,0 6.588,1.252 9.082,3.53l0.419,0.383C319.244,38.922 319.63,47.459 314.621,52.943z"
/>
<path
android:fillColor=
"@android:color/white"
android:pathData=
"M303.85,138.388c-8.284,0 -15,6.716 -15,15v127.347c0,21.034 -17.113,38.147 -38.147,38.147H68.904c-21.035,0 -38.147,-17.113 -38.147,-38.147V100.413c0,-21.034 17.113,-38.147 38.147,-38.147h131.587c8.284,0 15,-6.716 15,-15s-6.716,-15 -15,-15H68.904c-37.577,0 -68.147,30.571 -68.147,68.147v180.321c0,37.576 30.571,68.147 68.147,68.147h181.798c37.576,0 68.147,-30.571 68.147,-68.147V153.388C318.85,145.104 312.134,138.388 303.85,138.388z"
/>
</vector>
app/src/main/res/drawable/splash2.xml
0 → 100644
View file @
5500bf2e
<?xml version="1.0" encoding="utf-8"?>
<selector
xmlns:android=
"http://schemas.android.com/apk/res/android"
>
<item>
<shape>
<gradient
android:endColor=
"@color/colorPrimary"
android:startColor=
"@color/white"
android:angle=
"90"
/>
</shape>
</item>
</selector>
\ No newline at end of file
app/src/main/res/drawable/wallet.png
0 → 100644
View file @
5500bf2e
56.7 KB
app/src/main/res/layout/activity_cart.xml
View file @
5500bf2e
...
@@ -80,6 +80,7 @@
...
@@ -80,6 +80,7 @@
tools:layout_editor_absoluteX=
"9dp"
/>
tools:layout_editor_absoluteX=
"9dp"
/>
<include
<include
android:id=
"@+id/include"
layout=
"@layout/cart_item"
layout=
"@layout/cart_item"
android:layout_width=
"match_parent"
android:layout_width=
"match_parent"
android:layout_height=
"wrap_content"
android:layout_height=
"wrap_content"
...
@@ -88,5 +89,15 @@
...
@@ -88,5 +89,15 @@
app:layout_constraintTop_toBottomOf=
"@+id/view"
app:layout_constraintTop_toBottomOf=
"@+id/view"
app:layout_constraintVertical_bias=
"0.071"
/>
app:layout_constraintVertical_bias=
"0.071"
/>
<Button
android:id=
"@+id/btnCheckout"
android:layout_width=
"match_parent"
android:layout_height=
"wrap_content"
android:text=
"@string/checkout"
app:layout_constraintBottom_toBottomOf=
"parent"
app:layout_constraintTop_toBottomOf=
"@+id/include"
app:layout_constraintVertical_bias=
"1.0"
tools:layout_editor_absoluteX=
"39dp"
/>
</androidx.constraintlayout.widget.ConstraintLayout>
</androidx.constraintlayout.widget.ConstraintLayout>
\ No newline at end of file
app/src/main/res/layout/activity_login.xml
0 → 100644
View file @
5500bf2e
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout
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_margin=
"@dimen/space_default"
android:layout_height=
"match_parent"
tools:context=
".activities.LoginActivity"
>
<com.google.android.material.textview.MaterialTextView
android:id=
"@+id/tvLogin"
android:layout_width=
"wrap_content"
android:layout_height=
"wrap_content"
android:textSize=
"25dp"
android:layout_marginTop=
"80dp"
app:layout_constraintStart_toStartOf=
"parent"
app:layout_constraintEnd_toEndOf=
"parent"
app:layout_constraintTop_toTopOf=
"parent"
android:textStyle=
"bold"
android:text=
"Login"
/>
<com.google.android.material.textfield.TextInputLayout
android:id=
"@+id/tilUsername"
style=
"@style/Widget.MaterialComponents.TextInputLayout.OutlinedBox.Dense"
android:layout_width=
"match_parent"
android:layout_height=
"wrap_content"
app:layout_constraintTop_toBottomOf=
"@+id/tvLogin"
android:layout_marginTop=
"60dp"
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/etUsername"
android:layout_width=
"match_parent"
android:layout_height=
"wrap_content"
android:hint=
"Masukkan username..."
android:inputType=
"textCapWords"
android:imeOptions=
"actionNext"
android:textSize=
"@dimen/text_default"
/>
</com.google.android.material.textfield.TextInputLayout>
<com.google.android.material.textfield.TextInputLayout
android:id=
"@+id/tilPassword"
style=
"@style/Widget.MaterialComponents.TextInputLayout.OutlinedBox.Dense"
android:layout_width=
"match_parent"
android:layout_height=
"wrap_content"
app:layout_constraintTop_toBottomOf=
"@+id/tilUsername"
android:layout_marginStart=
"@dimen/space_default"
android:layout_marginTop=
"20dp"
android:layout_marginEnd=
"@dimen/space_default"
android:layout_marginBottom=
"@dimen/space_default"
>
<com.google.android.material.textfield.TextInputEditText
android:id=
"@+id/etPassword"
android:layout_width=
"match_parent"
android:layout_height=
"wrap_content"
android:hint=
"Masukkan password..."
android:inputType=
"textPassword"
android:textSize=
"@dimen/text_default"
/>
</com.google.android.material.textfield.TextInputLayout>
<com.google.android.material.button.MaterialButton
android:id=
"@+id/btnLogin"
android:layout_width=
"wrap_content"
android:layout_height=
"wrap_content"
android:text=
"Login"
android:backgroundTint=
"@color/colorPrimary"
app:layout_constraintTop_toBottomOf=
"@+id/tilPassword"
android:layout_marginTop=
"60dp"
app:layout_constraintEnd_toEndOf=
"parent"
android:padding=
"@dimen/space_default"
app:cornerRadius=
"@dimen/space_default"
android:layout_marginEnd=
"@dimen/space_default"
/>
</androidx.constraintlayout.widget.ConstraintLayout>
\ No newline at end of file
app/src/main/res/layout/activity_main.xml
View file @
5500bf2e
...
@@ -7,8 +7,6 @@
...
@@ -7,8 +7,6 @@
tools:context=
".activities.MainActivity"
>
tools:context=
".activities.MainActivity"
>
<!-- Rectangle 4 -->
<!-- Rectangle 4 -->
<View
<View
android:id=
"@+id/rectangle_4"
android:id=
"@+id/rectangle_4"
android:layout_width=
"match_parent"
android:layout_width=
"match_parent"
...
@@ -90,6 +88,7 @@
...
@@ -90,6 +88,7 @@
style=
"@style/Widget.MaterialComponents.TextInputLayout.OutlinedBox.Dense"
style=
"@style/Widget.MaterialComponents.TextInputLayout.OutlinedBox.Dense"
android:layout_width=
"match_parent"
android:layout_width=
"match_parent"
android:padding=
"10dp"
android:padding=
"10dp"
app:hintTextColor=
"@color/black"
android:layout_height=
"wrap_content"
android:layout_height=
"wrap_content"
android:layout_margin=
"@dimen/space_default"
android:layout_margin=
"@dimen/space_default"
app:layout_constraintBottom_toBottomOf=
"@+id/rectangle_4"
app:layout_constraintBottom_toBottomOf=
"@+id/rectangle_4"
...
...
app/src/main/res/layout/activity_payment.xml
View file @
5500bf2e
...
@@ -4,111 +4,159 @@
...
@@ -4,111 +4,159 @@
xmlns:tools=
"http://schemas.android.com/tools"
xmlns:tools=
"http://schemas.android.com/tools"
android:layout_width=
"match_parent"
android:layout_width=
"match_parent"
android:layout_height=
"match_parent"
android:layout_height=
"match_parent"
android:padding=
"12dp"
tools:context=
".activities.PaymentActivity"
>
tools:context=
".activities.PaymentActivity"
>
<!-- Payment -->
<!-- Payment -->
<com.google.android.material.textview.MaterialTextView
<TextView
android:id=
"@+id/tvPayment"
android:id=
"@+id/payment"
android:layout_width=
"108dp"
android:layout_width=
"108dp"
android:layout_height=
"28dp"
android:layout_height=
"wrap_content"
android:layout_alignParentLeft=
"true"
android:layout_alignParentTop=
"true"
android:gravity=
"top"
android:gravity=
"top"
android:text=
"@string/payment"
android:text=
"@string/payment"
android:textAppearance=
"@style/payment"
android:textAppearance=
"@style/payment"
app:layout_constraintBottom_to
BottomOf=
"parent
"
app:layout_constraintBottom_to
TopOf=
"@id/cvCash
"
app:layout_constraintEnd_toEndOf=
"parent"
app:layout_constraintEnd_toEndOf=
"parent"
app:layout_constraintHorizontal_bias=
"0.
115
"
app:layout_constraintHorizontal_bias=
"0.
0
"
app:layout_constraintStart_toStartOf=
"parent"
app:layout_constraintStart_toStartOf=
"parent"
app:layout_constraintTop_toTopOf=
"parent"
app:layout_constraintTop_toTopOf=
"parent"
app:layout_constraintVertical_bias=
"0.
044
"
/>
app:layout_constraintVertical_bias=
"0.
105
"
/>
<com.google.android.material.textview.MaterialTextView
android:id=
"@+id/tvTotal"
android:layout_width=
"wrap_content"
android:layout_height=
"wrap_content"
android:elegantTextHeight=
"true"
android:gravity=
"center"
android:text=
"Rp. 500.000"
android:textSize=
"24dp"
app:layout_constraintEnd_toEndOf=
"parent"
app:layout_constraintHorizontal_bias=
"0.902"
app:layout_constraintStart_toStartOf=
"parent"
app:layout_constraintTop_toBottomOf=
"@id/tvPayment"
app:layout_constraintVertical_bias=
"0.0"
/>
<com.google.android.material.card.MaterialCardView
<com.google.android.material.card.MaterialCardView
android:layout_width=
"340dp"
android:id=
"@+id/cvCash"
android:layout_width=
"match_parent"
android:layout_height=
"100dp"
android:layout_height=
"100dp"
app:layout_constraintBottom_toBottomOf=
"parent"
android:layout_marginTop=
"20dp"
android:clickable=
"true"
app:layout_constraintEnd_toEndOf=
"parent"
app:layout_constraintEnd_toEndOf=
"parent"
app:layout_constraintStart_toStartOf=
"parent"
app:layout_constraintStart_toStartOf=
"parent"
app:layout_constraintTop_toBottomOf=
"@+id/payment"
app:layout_constraintTop_toBottomOf=
"@+id/tvTotal"
>
app:layout_constraintVertical_bias=
"0.04000002"
>
<androidx.constraintlayout.widget.ConstraintLayout
<androidx.constraintlayout.widget.ConstraintLayout
android:layout_width=
"match_parent"
android:layout_width=
"match_parent"
android:layout_height=
"match_parent"
>
android:layout_height=
"match_parent"
>
<ImageView
<ImageView
android:id=
"@+id/iv_cash"
android:id=
"@+id/iv_cash"
android:layout_width=
"
wrap_content
"
android:layout_width=
"
200dp
"
android:layout_height=
"wrap_content"
android:layout_height=
"wrap_content"
android:src=
"@drawable/wallet"
app:layout_constraintBottom_toBottomOf=
"parent"
app:layout_constraintBottom_toBottomOf=
"parent"
app:layout_constraintEnd_toEndOf=
"parent"
app:layout_constraintEnd_toEndOf=
"parent"
app:layout_constraintHorizontal_bias=
"0.0"
app:layout_constraintHorizontal_bias=
"0.0"
app:layout_constraintStart_toStartOf=
"parent"
app:layout_constraintStart_toStartOf=
"parent"
app:layout_constraintTop_toTopOf=
"parent"
app:layout_constraintTop_toTopOf=
"parent"
app:layout_constraintVertical_bias=
"0.8"
app:layout_constraintVertical_bias=
"0.8"
/>
tools:srcCompat=
"@tools:sample/avatars"
/>
<TextView
<TextView
android:id=
"@+id/cash"
android:id=
"@+id/cash"
android:layout_width=
"138dp"
android:layout_width=
"138dp"
android:layout_height=
"33dp"
android:layout_height=
"33dp"
android:gravity=
"center"
android:text=
"@string/cash"
android:text=
"@string/cash"
android:textAppearance=
"@style/cash"
android:textAppearance=
"@style/cash"
app:layout_constraintBottom_toBottomOf=
"
@+id/iv_cash
"
app:layout_constraintBottom_toBottomOf=
"
parent
"
app:layout_constraintEnd_toEndOf=
"parent"
app:layout_constraintEnd_toEndOf=
"parent"
app:layout_constraintHorizontal_bias=
"0.
189
"
app:layout_constraintHorizontal_bias=
"0.
324
"
app:layout_constraintStart_toEndOf=
"@+id/iv_cash"
app:layout_constraintStart_toEndOf=
"@+id/iv_cash"
app:layout_constraintTop_toTopOf=
"
@+id/iv_cash
"
app:layout_constraintTop_toTopOf=
"
parent
"
app:layout_constraintVertical_bias=
"0.
0
"
/>
app:layout_constraintVertical_bias=
"0.
507
"
/>
<TextView
android:id=
"@+id/rp_500_000"
</androidx.constraintlayout.widget.ConstraintLayout>
android:layout_width=
"138dp"
android:layout_height=
"33dp"
</com.google.android.material.card.MaterialCardView>
android:layout_alignParentLeft=
"true"
<com.google.android.material.card.MaterialCardView
android:layout_alignParentTop=
"true
"
android:id=
"@+id/cvCard
"
android:gravity=
"top
"
android:layout_width=
"match_parent
"
android:text=
"@string/rp_500_000
"
android:layout_height=
"100dp
"
android:textAppearance=
"@style/rp_500_000
"
android:clickable=
"true
"
app:layout_constraintBottom_toBottomOf=
"@+id/iv_cash
"
android:layout_marginTop=
"20dp
"
app:layout_constraintEnd_toEndOf=
"parent"
app:layout_constraintEnd_toEndOf=
"parent"
app:layout_constraintHorizontal_bias=
"0.193
"
app:layout_constraintStart_toStartOf=
"parent
"
app:layout_constraintStart_toEndOf=
"@+id/iv_c
ash"
app:layout_constraintTop_toBottomOf=
"@+id/cvC
ash"
app:layout_constraintTop_toBottomOf=
"@+id/cash"
app:layout_constraintVertical_bias=
"0.04000002"
>
app:layout_constraintVertical_bias=
"0.145"
/>
<androidx.constraintlayout.widget.ConstraintLayout
<View
android:layout_width=
"match_parent"
android:id=
"@+id/rectangle_2"
android:layout_height=
"match_parent"
>
android:layout_width=
"96dp"
android:layout_height=
"44dp"
<ImageView
android:
layout_alignParentLeft=
"true
"
android:
id=
"@+id/iv_card
"
android:layout_
alignParentTop=
"true
"
android:layout_
width=
"200dp
"
android:
background=
"@drawable/rectangle_2
"
android:
layout_height=
"wrap_content
"
android:
backgroundTint=
"#45E1D1
"
android:
src=
"@drawable/credit_card
"
app:layout_constraintBottom_toBottomOf=
"parent"
app:layout_constraintBottom_toBottomOf=
"parent"
app:layout_constraintEnd_toEndOf=
"parent"
app:layout_constraintEnd_toEndOf=
"parent"
app:layout_constraintHorizontal_bias=
"
1
.0"
app:layout_constraintHorizontal_bias=
"
0
.0"
app:layout_constraintStart_toStartOf=
"parent"
app:layout_constraintStart_toStartOf=
"parent"
app:layout_constraintTop_to
BottomOf=
"@+id/rp_500_000
"
app:layout_constraintTop_to
TopOf=
"parent
"
app:layout_constraintVertical_bias=
"
1.0
"
/>
app:layout_constraintVertical_bias=
"
0.8
"
/>
<TextView
<TextView
android:id=
"@+id/pay"
android:id=
"@+id/card"
android:layout_width=
"wrap_content"
android:layout_width=
"138dp"
android:layout_height=
"23dp"
android:layout_height=
"33dp"
android:text=
"@string/pay"
android:gravity=
"center"
android:textAppearance=
"@style/pay"
android:text=
"@string/card"
android:textStyle=
"bold"
android:textAppearance=
"@style/cash"
app:layout_constraintBottom_toBottomOf=
"@+id/rectangle_2"
app:layout_constraintBottom_toBottomOf=
"parent"
app:layout_constraintEnd_toEndOf=
"@+id/rectangle_2"
app:layout_constraintEnd_toEndOf=
"parent"
app:layout_constraintStart_toStartOf=
"@+id/rectangle_2"
app:layout_constraintHorizontal_bias=
"0.324"
app:layout_constraintTop_toTopOf=
"@+id/rectangle_2"
/>
app:layout_constraintStart_toEndOf=
"@+id/iv_card"
app:layout_constraintTop_toTopOf=
"parent"
app:layout_constraintVertical_bias=
"0.507"
/>
</androidx.constraintlayout.widget.ConstraintLayout>
</androidx.constraintlayout.widget.ConstraintLayout>
</com.google.android.material.card.MaterialCardView>
</com.google.android.material.card.MaterialCardView>
<com.google.android.material.textview.MaterialTextView
android:id=
"@+id/tvAmountPaid"
android:layout_width=
"100dp"
android:layout_height=
"30dp"
android:layout_marginTop=
"208dp"
android:layout_marginBottom=
"90dp"
android:gravity=
"start"
android:text=
"Amount paid"
app:layout_constraintBottom_toTopOf=
"@id/etAmountPaid"
app:layout_constraintEnd_toEndOf=
"parent"
app:layout_constraintHorizontal_bias=
"0.0"
app:layout_constraintStart_toStartOf=
"parent"
app:layout_constraintTop_toBottomOf=
"@id/cvCard"
/>
<EditText
android:id=
"@+id/etAmountPaid"
android:layout_width=
"match_parent"
android:layout_height=
"wrap_content"
android:layout_marginBottom=
"40dp"
android:gravity=
"center"
app:layout_constraintBottom_toTopOf=
"@id/btnPay"
app:layout_constraintEnd_toEndOf=
"parent"
app:layout_constraintHorizontal_bias=
"0.333"
app:layout_constraintStart_toStartOf=
"parent"
/>
<com.google.android.material.button.MaterialButton
android:id=
"@+id/btnPay"
android:layout_width=
"match_parent"
android:layout_height=
"wrap_content"
android:text=
"PAY"
app:layout_constraintStart_toStartOf=
"parent"
app:layout_constraintEnd_toEndOf=
"parent"
app:layout_constraintBottom_toBottomOf=
"parent"
tools:layout_editor_absoluteX=
"16dp"
tools:layout_editor_absoluteY=
"654dp"
/>
</androidx.constraintlayout.widget.ConstraintLayout>
</androidx.constraintlayout.widget.ConstraintLayout>
\ No newline at end of file
app/src/main/res/layout/activity_product.xml
View file @
5500bf2e
...
@@ -7,6 +7,10 @@
...
@@ -7,6 +7,10 @@
<variable
<variable
name=
"photo"
name=
"photo"
type=
"String"
/>
type=
"String"
/>
<variable
name=
"viewModel"
type=
"com.example.yourcashiertest.viewmodels.ProductViewModel"
/>
</data>
</data>
<LinearLayout
<LinearLayout
...
@@ -118,6 +122,7 @@
...
@@ -118,6 +122,7 @@
android:layout_marginEnd=
"@dimen/space_default"
>
android:layout_marginEnd=
"@dimen/space_default"
>
<AutoCompleteTextView
<AutoCompleteTextView
android:id=
"@+id/spCategory"
android:id=
"@+id/spCategory"
android:hint=
"Categori"
android:layout_width=
"match_parent"
android:layout_width=
"match_parent"
android:layout_height=
"wrap_content"
/>
android:layout_height=
"wrap_content"
/>
</com.google.android.material.textfield.TextInputLayout>
</com.google.android.material.textfield.TextInputLayout>
...
...
app/src/main/res/layout/activity_splash.xml
View file @
5500bf2e
...
@@ -6,7 +6,7 @@
...
@@ -6,7 +6,7 @@
android:id=
"@+id/splash_scre"
android:id=
"@+id/splash_scre"
android:layout_width=
"fill_parent"
android:layout_width=
"fill_parent"
android:layout_height=
"fill_parent"
android:layout_height=
"fill_parent"
android:background=
"@drawable/splash
_scre
"
android:background=
"@drawable/splash
2
"
tools:context=
".activities.SplashActivity"
>
tools:context=
".activities.SplashActivity"
>
<ImageView
<ImageView
android:id=
"@+id/ivLogo"
android:id=
"@+id/ivLogo"
...
...
app/src/main/res/layout/cart_item.xml
View file @
5500bf2e
...
@@ -58,7 +58,7 @@
...
@@ -58,7 +58,7 @@
app:layout_constraintVertical_bias=
"1.0"
/>
app:layout_constraintVertical_bias=
"1.0"
/>
<View
<View
android:id=
"@+id/
rectangle_1
"
android:id=
"@+id/
v_add
"
android:layout_width=
"78dp"
android:layout_width=
"78dp"
android:layout_height=
"40dp"
android:layout_height=
"40dp"
android:layout_alignParentLeft=
"true"
android:layout_alignParentLeft=
"true"
...
@@ -77,9 +77,9 @@
...
@@ -77,9 +77,9 @@
android:layout_height=
"10dp"
android:layout_height=
"10dp"
android:layout_marginStart=
"8dp"
android:layout_marginStart=
"8dp"
android:background=
"@drawable/minus"
android:background=
"@drawable/minus"
app:layout_constraintBottom_toBottomOf=
"@+id/
rectangle_1
"
app:layout_constraintBottom_toBottomOf=
"@+id/
v_add
"
app:layout_constraintStart_toStartOf=
"@+id/
rectangle_1
"
app:layout_constraintStart_toStartOf=
"@+id/
v_add
"
app:layout_constraintTop_toTopOf=
"@+id/
rectangle_1
"
app:layout_constraintTop_toTopOf=
"@+id/
v_add
"
app:layout_constraintVertical_bias=
"0.566"
/>
app:layout_constraintVertical_bias=
"0.566"
/>
<Button
<Button
...
@@ -88,9 +88,9 @@
...
@@ -88,9 +88,9 @@
android:layout_height=
"10dp"
android:layout_height=
"10dp"
android:layout_marginEnd=
"8dp"
android:layout_marginEnd=
"8dp"
android:background=
"@drawable/plus"
android:background=
"@drawable/plus"
app:layout_constraintBottom_toBottomOf=
"@+id/
rectangle_1
"
app:layout_constraintBottom_toBottomOf=
"@+id/
v_add
"
app:layout_constraintEnd_toEndOf=
"@+id/
rectangle_1
"
app:layout_constraintEnd_toEndOf=
"@+id/
v_add
"
app:layout_constraintTop_toTopOf=
"@+id/
rectangle_1
"
app:layout_constraintTop_toTopOf=
"@+id/
v_add
"
app:layout_constraintVertical_bias=
"0.533"
/>
app:layout_constraintVertical_bias=
"0.533"
/>
<TextView
<TextView
...
@@ -98,10 +98,10 @@
...
@@ -98,10 +98,10 @@
android:layout_width=
"10dp"
android:layout_width=
"10dp"
android:layout_height=
"wrap_content"
android:layout_height=
"wrap_content"
android:text=
"2"
android:text=
"2"
app:layout_constraintBottom_toBottomOf=
"@+id/
rectangle_1
"
app:layout_constraintBottom_toBottomOf=
"@+id/
v_add
"
app:layout_constraintEnd_toStartOf=
"@+id/btn_add"
app:layout_constraintEnd_toStartOf=
"@+id/btn_add"
app:layout_constraintStart_toEndOf=
"@+id/btn_min"
app:layout_constraintStart_toEndOf=
"@+id/btn_min"
app:layout_constraintTop_toTopOf=
"@+id/
rectangle_1
"
/>
app:layout_constraintTop_toTopOf=
"@+id/
v_add
"
/>
<View
<View
android:layout_width=
"match_parent"
android:layout_width=
"match_parent"
...
...
app/src/main/res/layout/item_list.xml
View file @
5500bf2e
<?xml version="1.0" encoding="utf-8"?>
<?xml version="1.0" encoding="utf-8"?>
<com.google.android.material.card.MaterialCardView
<layout
xmlns:android=
"http://schemas.android.com/apk/res/android"
xmlns:android=
"http://schemas.android.com/apk/res/android"
xmlns:app=
"http://schemas.android.com/apk/res-auto"
xmlns:app=
"http://schemas.android.com/apk/res-auto"
xmlns:tools=
"http://schemas.android.com/tools"
xmlns:tools=
"http://schemas.android.com/tools"
>
<data>
<variable
name=
"product"
type=
"com.example.yourcashiertest.entities.Product"
/>
<variable
name=
"price"
type=
"String"
/>
</data>
<com.google.android.material.card.MaterialCardView
android:layout_width=
"match_parent"
android:layout_width=
"match_parent"
android:layout_height=
"match_par
ent"
>
android:layout_height=
"wrap_cont
ent"
>
<androidx.constraintlayout.widget.ConstraintLayout
<androidx.constraintlayout.widget.ConstraintLayout
android:layout_width=
"match_parent"
android:layout_width=
"match_parent"
android:padding=
"10dp"
android:layout_height=
"match_parent"
>
android:layout_height=
"match_parent"
>
<ImageView
<ImageView
android:id=
"@+id/imageView5"
android:id=
"@+id/iv_product"
android:layout_width=
"wrap_content"
android:adjustViewBounds=
"true"
android:layout_width=
"match_parent"
android:layout_height=
"wrap_content"
android:layout_height=
"wrap_content"
android:background=
"@drawable/elips"
app:layout_constraintBottom_toBottomOf=
"parent"
app:layout_constraintBottom_toBottomOf=
"parent"
app:layout_constraintEnd_toEndOf=
"parent"
app:layout_constraintEnd_toEndOf=
"parent"
app:layout_constraintHorizontal_bias=
"0.452
"
app:layout_constraintHorizontal_bias=
"0.526
"
app:layout_constraintStart_toStartOf=
"parent"
app:layout_constraintStart_toStartOf=
"parent"
app:layout_constraintTop_toTopOf=
"parent"
app:layout_constraintTop_toTopOf=
"parent"
app:layout_constraintVertical_bias=
"0.026"
app:layout_constraintVertical_bias=
"0.075"
tools:srcCompat=
"@tools:sample/avatars"
/>
android:src=
"@drawable/burger"
/>
<ImageView
android:id=
"@+id/ivUpdate"
android:layout_width=
"wrap_content"
android:layout_height=
"wrap_content"
android:padding=
"@dimen/space_small"
android:src=
"@drawable/ic_update"
app:layout_constraintBottom_toBottomOf=
"@+id/iv_product"
app:layout_constraintStart_toStartOf=
"@+id/iv_product"
app:layout_constraintTop_toTopOf=
"@+id/iv_product"
app:layout_constraintVertical_bias=
"0.0"
/>
<ImageView
android:id=
"@+id/ivDelete"
android:layout_width=
"wrap_content"
android:layout_height=
"wrap_content"
android:layout_alignParentEnd=
"true"
android:padding=
"@dimen/space_small"
android:src=
"@drawable/ic_delete"
app:layout_constraintBottom_toBottomOf=
"@+id/iv_product"
app:layout_constraintEnd_toEndOf=
"@+id/iv_product"
app:layout_constraintTop_toTopOf=
"@+id/iv_product"
app:layout_constraintVertical_bias=
"0.0"
/>
<TextView
<TextView
android:id=
"@+id/tv_name"
android:id=
"@+id/tv_name"
android:layout_width=
"wrap_cont
ent"
android:layout_width=
"match_par
ent"
android:layout_height=
"wrap_content"
android:layout_height=
"wrap_content"
android:text=
"Burger Medium"
android:text=
"@string/name"
android:layout_margin=
"10dp"
android:textStyle=
"bold"
app:layout_constraintBottom_toBottomOf=
"parent"
app:layout_constraintBottom_toBottomOf=
"parent"
app:layout_constraintEnd_toEndOf=
"parent"
app:layout_constraintEnd_toEndOf=
"parent"
app:layout_constraintHorizontal_bias=
"0.45"
app:layout_constraintHorizontal_bias=
"0.45"
app:layout_constraintStart_toStartOf=
"parent"
app:layout_constraintStart_toStartOf=
"parent"
app:layout_constraintTop_toBottomOf=
"@+id/imageView5
"
app:layout_constraintTop_toBottomOf=
"@+id/iv_product
"
app:layout_constraintVertical_bias=
"0.089"
/>
app:layout_constraintVertical_bias=
"0.089"
/>
<TextView
android:id=
"@+id/tv_desc"
android:layout_width=
"wrap_content"
android:layout_height=
"wrap_content"
android:layout_marginTop=
"5dp"
android:text=
"@string/deskripsi"
app:layout_constraintBottom_toBottomOf=
"parent"
app:layout_constraintEnd_toEndOf=
"@+id/tv_name"
app:layout_constraintHorizontal_bias=
"0.0"
app:layout_constraintStart_toStartOf=
"@+id/tv_name"
app:layout_constraintTop_toBottomOf=
"@+id/tv_name"
app:layout_constraintVertical_bias=
"0.045"
/>
<TextView
android:id=
"@+id/tv_price"
android:layout_width=
"wrap_content"
android:layout_height=
"wrap_content"
android:layout_marginTop=
"3dp"
android:text=
"@string/price"
android:textStyle=
"bold"
app:layout_constraintBottom_toBottomOf=
"parent"
app:layout_constraintEnd_toEndOf=
"parent"
app:layout_constraintHorizontal_bias=
"0.0"
app:layout_constraintStart_toStartOf=
"@+id/tv_desc"
app:layout_constraintTop_toBottomOf=
"@+id/tv_desc"
app:layout_constraintVertical_bias=
"0.37"
/>
<View
android:id=
"@+id/v_add"
android:layout_width=
"70dp"
android:layout_height=
"30dp"
android:background=
"@drawable/btn_shape"
app:layout_constraintBottom_toBottomOf=
"@+id/tv_price"
app:layout_constraintEnd_toEndOf=
"@+id/tv_name"
app:layout_constraintHorizontal_bias=
"1.0"
app:layout_constraintStart_toEndOf=
"@+id/tv_price"
app:layout_constraintTop_toTopOf=
"@+id/tv_price"
app:layout_constraintVertical_bias=
"0.0"
/>
<ImageView
android:id=
"@+id/iv_add"
android:layout_width=
"wrap_content"
android:layout_height=
"wrap_content"
app:layout_constraintBottom_toBottomOf=
"@+id/v_add"
app:layout_constraintEnd_toEndOf=
"@+id/v_add"
app:layout_constraintStart_toStartOf=
"@+id/v_add"
app:layout_constraintTop_toTopOf=
"@+id/v_add"
app:srcCompat=
"@drawable/ic_baseline_add_shopping_cart_24"
/>
</androidx.constraintlayout.widget.ConstraintLayout>
</androidx.constraintlayout.widget.ConstraintLayout>
</com.google.android.material.card.MaterialCardView>
</com.google.android.material.card.MaterialCardView>
\ No newline at end of file
</layout>
\ No newline at end of file
app/src/main/res/values/strings.xml
View file @
5500bf2e
...
@@ -14,6 +14,11 @@
...
@@ -14,6 +14,11 @@
<string
name=
"items"
>
3 items
</string>
<string
name=
"items"
>
3 items
</string>
<string
name=
"payment"
>
Payment
</string>
<string
name=
"payment"
>
Payment
</string>
<string
name=
"cash"
>
Cash
</string>
<string
name=
"cash"
>
Cash
</string>
<string
name=
"card"
>
Card
</string>
<string
name=
"rp_500_000"
>
Rp. 500.000
</string>
<string
name=
"rp_500_000"
>
Rp. 500.000
</string>
<string
name=
"pay"
>
Pay
</string>
<string
name=
"pay"
>
Pay
</string>
<string
name=
"checkout"
>
Checkout
</string>
<string
name=
"deskripsi"
>
Burger medium with tomato and meet.
</string>
<string
name=
"name"
>
Burger Medium
</string>
<string
name=
"price"
>
$600.00
</string>
</resources>
</resources>
\ No newline at end of file
app/src/main/res/values/styles.xml
View file @
5500bf2e
...
@@ -11,7 +11,7 @@
...
@@ -11,7 +11,7 @@
<!-- Customize your theme here. -->
<!-- Customize your theme here. -->
<item
name=
"colorPrimary"
>
@color/colorPrimary
</item>
<item
name=
"colorPrimary"
>
@color/colorPrimary
</item>
<item
name=
"colorPrimaryDark"
>
@color/colorPrimaryDark
</item>
<item
name=
"colorPrimaryDark"
>
@color/colorPrimaryDark
</item>
<item
name=
"colorAccent"
>
@color/colorAccent
</item>
<item
name=
"colorAccent"
>
#333
</item>
</style>
</style>
<style
name=
"burger_medi"
>
<style
name=
"burger_medi"
>
...
@@ -65,7 +65,7 @@
...
@@ -65,7 +65,7 @@
<style
name=
"payment"
>
<style
name=
"payment"
>
<item
name=
"android:textSize"
>
<item
name=
"android:textSize"
>
2
4
sp
2
7
sp
</item>
</item>
<item
name=
"android:textColor"
>
<item
name=
"android:textColor"
>
...
...
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