-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Removed legacy MainActivity * Implemented image loading on warehouse items. * Added cloud zeroconf bypass * Added item images * Added OrdersActivity * Added qr code library to app * Added bob logo to app * Added ViewOrderDialog * Added qr code generation * Added quality of life improvements to shopping cart.
- Loading branch information
Showing
14 changed files
with
260 additions
and
32 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
75 changes: 75 additions & 0 deletions
75
android/app/src/main/java/io/github/assis10t/bobandroid/ViewOrderDialog.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
package io.github.assis10t.bobandroid | ||
|
||
import android.app.Dialog | ||
import android.content.Context | ||
import android.content.Intent | ||
import android.net.Uri | ||
import android.os.Bundle | ||
import android.support.v7.widget.LinearLayoutManager | ||
import android.support.v7.widget.RecyclerView | ||
import android.text.Editable | ||
import android.text.TextWatcher | ||
import android.view.LayoutInflater | ||
import android.view.View | ||
import android.view.ViewGroup | ||
import android.widget.TextView | ||
import android.widget.Toast | ||
import io.github.assis10t.bobandroid.pojo.Item | ||
import io.github.assis10t.bobandroid.pojo.Order | ||
import kotlinx.android.synthetic.main.dialog_view_order.* | ||
import org.w3c.dom.Text | ||
import timber.log.Timber | ||
|
||
class ViewOrderDialog(context: Context, val order: Order): Dialog(context) { | ||
override fun onCreate(savedInstanceState: Bundle?) { | ||
super.onCreate(savedInstanceState) | ||
setContentView(R.layout.dialog_view_order) | ||
|
||
cart.layoutManager = LinearLayoutManager(context, LinearLayoutManager.VERTICAL, false) | ||
cart.adapter = ViewCartDialog.CartAdapter(order.items) | ||
|
||
warehouse_title.text = order.warehouse!!.name | ||
status.text = when(order.status) { | ||
Order.Status.PENDING -> "Pending" | ||
Order.Status.IN_TRANSIT -> "In transit" | ||
Order.Status.COMPLETE -> "Ready" | ||
Order.Status.CANCELED -> "Canceled" | ||
} | ||
status.setTextColor(when(order.status) { | ||
Order.Status.PENDING -> R.color.statusPending | ||
Order.Status.IN_TRANSIT -> R.color.statusInTransit | ||
Order.Status.COMPLETE -> R.color.statusReady | ||
Order.Status.CANCELED -> R.color.statusCanceled | ||
}) | ||
|
||
view_qr.visibility = | ||
if (order.status == Order.Status.COMPLETE) | ||
View.VISIBLE | ||
else | ||
View.VISIBLE //TODO: Change to View.GONE | ||
|
||
val totalAmount = | ||
if (order.items.isEmpty()) | ||
0.0 | ||
else | ||
order.items | ||
.map{ it.quantity!! * it.price } | ||
.reduce { a, b -> a + b} | ||
|
||
total.text = "£${"%.2f".format(totalAmount)}" | ||
|
||
|
||
view_qr.setOnClickListener { | ||
ViewQRDialog(context, order).show() | ||
} | ||
|
||
get_directions.setOnClickListener { | ||
val location = order.warehouse!!.location!! | ||
val intent = Intent( | ||
Intent.ACTION_VIEW, | ||
Uri.parse("https://www.google.com/maps/dir/?api=1&destination=${location.latitude},${location.longitude}") | ||
) | ||
context.startActivity(intent) | ||
} | ||
} | ||
} |
21 changes: 21 additions & 0 deletions
21
android/app/src/main/java/io/github/assis10t/bobandroid/ViewQRDialog.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
package io.github.assis10t.bobandroid | ||
|
||
import android.app.Dialog | ||
import android.content.Context | ||
import android.os.Bundle | ||
import com.bumptech.glide.Glide | ||
import io.github.assis10t.bobandroid.pojo.Order | ||
import kotlinx.android.synthetic.main.dialog_view_qr.* | ||
|
||
class ViewQRDialog(context: Context, val order: Order): Dialog(context) { | ||
override fun onCreate(savedInstanceState: Bundle?) { | ||
super.onCreate(savedInstanceState) | ||
setContentView(R.layout.dialog_view_qr) | ||
|
||
instructions.text = "Show this code to the cashier at ${order.warehouse!!.name}." | ||
|
||
Glide.with(context) | ||
.load(generateQRCode(order._id!!)) | ||
.into(qr) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
<vector xmlns:android="http:https://schemas.android.com/apk/res/android" | ||
android:width="24dp" | ||
android:height="24dp" | ||
android:viewportWidth="24.0" | ||
android:viewportHeight="24.0"> | ||
<path | ||
android:fillColor="#FF000000" | ||
android:pathData="M6,19c0,1.1 0.9,2 2,2h8c1.1,0 2,-0.9 2,-2V7H6v12zM19,4h-3.5l-1,-1h-5l-1,1H5v2h14V4z"/> | ||
</vector> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
29 changes: 29 additions & 0 deletions
29
android/app/src/main/res/layout/dialog_view_cart_empty.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<android.support.design.card.MaterialCardView | ||
xmlns:android="http:https://schemas.android.com/apk/res/android" | ||
xmlns:app="http:https://schemas.android.com/apk/res-auto" | ||
xmlns:tools="http:https://schemas.android.com/tools" style="@style/Widget.MaterialComponents.CardView" | ||
android:layout_width="350dp" | ||
android:layout_height="wrap_content" | ||
app:cardElevation="8dp"> | ||
<RelativeLayout | ||
android:layout_width="match_parent" | ||
android:layout_height="wrap_content"> | ||
<TextView | ||
style="@style/TextAppearance.MaterialComponents.Headline6" | ||
android:id="@+id/title" | ||
android:layout_width="wrap_content" | ||
android:layout_height="wrap_content" | ||
android:text="Shopping Cart" | ||
android:layout_margin="8dp" | ||
/> | ||
<TextView | ||
android:layout_width="wrap_content" | ||
android:layout_height="wrap_content" | ||
android:text="Your cart is empty." | ||
android:layout_margin="16dp" | ||
android:layout_centerHorizontal="true" | ||
android:layout_below="@id/title" | ||
/> | ||
</RelativeLayout> | ||
</android.support.design.card.MaterialCardView> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<android.support.design.card.MaterialCardView | ||
xmlns:android="http:https://schemas.android.com/apk/res/android" | ||
xmlns:app="http:https://schemas.android.com/apk/res-auto" | ||
xmlns:tools="http:https://schemas.android.com/tools" style="@style/Widget.MaterialComponents.CardView" | ||
android:layout_width="300dp" | ||
android:layout_height="wrap_content" | ||
app:cardElevation="8dp"> | ||
<RelativeLayout | ||
android:layout_width="match_parent" | ||
android:layout_height="wrap_content"> | ||
<TextView | ||
android:id="@+id/instructions" | ||
style="@style/TextAppearance.MaterialComponents.Body2" | ||
android:layout_width="match_parent" | ||
android:layout_height="wrap_content" | ||
android:text="Show this code to the cashier at Appleton Tower Superstore." | ||
android:gravity="center" | ||
android:layout_margin="8dp"/> | ||
<ImageView | ||
android:id="@+id/qr" | ||
android:layout_width="300dp" | ||
android:layout_height="300dp" | ||
android:layout_below="@id/instructions" | ||
android:layout_centerHorizontal="true"/> | ||
</RelativeLayout> | ||
</android.support.design.card.MaterialCardView> |
Oops, something went wrong.