From dcb237a3dfc4d75d9660c71b68f7a787f6725566 Mon Sep 17 00:00:00 2001 From: TheBrokenRail Date: Sat, 17 Feb 2024 19:06:43 -0500 Subject: [PATCH] Dialogs And Colors! --- .idea/deploymentTargetDropDown.xml | 15 +- .../mtudining/activity/menu/ItemDialog.java | 40 ++++- .../mtudining/activity/menu/MenuAdapter.java | 3 +- .../mtudining/api/method/PeriodDetail.java | 8 + app/src/main/res/values-night/colors.xml | 152 +++++++++--------- app/src/main/res/values/colors.xml | 138 ++++++++-------- app/src/main/res/values/strings.xml | 4 + 7 files changed, 212 insertions(+), 148 deletions(-) diff --git a/.idea/deploymentTargetDropDown.xml b/.idea/deploymentTargetDropDown.xml index 0c0c338..b72ff7d 100644 --- a/.idea/deploymentTargetDropDown.xml +++ b/.idea/deploymentTargetDropDown.xml @@ -3,7 +3,20 @@ - + + + + + + + + + + + + + + diff --git a/app/src/main/java/com/thebrokenrail/mtudining/activity/menu/ItemDialog.java b/app/src/main/java/com/thebrokenrail/mtudining/activity/menu/ItemDialog.java index f402ff9..493b87f 100644 --- a/app/src/main/java/com/thebrokenrail/mtudining/activity/menu/ItemDialog.java +++ b/app/src/main/java/com/thebrokenrail/mtudining/activity/menu/ItemDialog.java @@ -1,10 +1,48 @@ package com.thebrokenrail.mtudining.activity.menu; +import android.content.Context; +import android.graphics.Typeface; +import android.text.SpannableStringBuilder; +import android.text.Spanned; +import android.text.style.StyleSpan; + +import com.google.android.material.dialog.MaterialAlertDialogBuilder; +import com.thebrokenrail.mtudining.R; +import com.thebrokenrail.mtudining.api.method.PeriodDetail; + /** * Dialog for a food item. */ public class ItemDialog { - public void show() { + /** + * Show dialog. + * @param context The context + * @param item The food item to display + */ + public static void show(Context context, PeriodDetail.Response.Menu.PeriodData.MenuCategory.MenuItem item) { + // Build Message + SpannableStringBuilder message = new SpannableStringBuilder(item.desc != null ? item.desc.trim() : ""); + if (message.length() > 0) { + message.append("\n\n"); + } + message.append(context.getString(R.string.portion), new StyleSpan(Typeface.BOLD), Spanned.SPAN_EXCLUSIVE_EXCLUSIVE); + message.append(item.portion); + message.append('\n'); + message.append(context.getString(R.string.ingredients), new StyleSpan(Typeface.BOLD), Spanned.SPAN_EXCLUSIVE_EXCLUSIVE); + message.append(item.ingredients); + message.append('\n'); + message.append(context.getString(R.string.nutrients), new StyleSpan(Typeface.BOLD), Spanned.SPAN_EXCLUSIVE_EXCLUSIVE); + for (PeriodDetail.Response.Menu.PeriodData.MenuCategory.MenuItem.Nutrient nutrient : item.nutrients) { + message.append('\n'); + message.append("• " + nutrient.name + ": ", new StyleSpan(Typeface.BOLD), Spanned.SPAN_EXCLUSIVE_EXCLUSIVE); + message.append(nutrient.value); + } + // Show + new MaterialAlertDialogBuilder(context) + .setTitle(item.name) + .setMessage(message) + .setPositiveButton(R.string.ok, (dialog, which) -> {}) + .show(); } } diff --git a/app/src/main/java/com/thebrokenrail/mtudining/activity/menu/MenuAdapter.java b/app/src/main/java/com/thebrokenrail/mtudining/activity/menu/MenuAdapter.java index e778057..55f1404 100644 --- a/app/src/main/java/com/thebrokenrail/mtudining/activity/menu/MenuAdapter.java +++ b/app/src/main/java/com/thebrokenrail/mtudining/activity/menu/MenuAdapter.java @@ -66,7 +66,8 @@ class MenuAdapter extends TaskAdapter { data.isOpen = !data.isOpen; notifyItemChanged(meal.categories.indexOf(data) + getFirstElementPosition()); }, item -> { - // Do Something! + // Show Dialog + ItemDialog.show(view.getContext(), item); }); } diff --git a/app/src/main/java/com/thebrokenrail/mtudining/api/method/PeriodDetail.java b/app/src/main/java/com/thebrokenrail/mtudining/api/method/PeriodDetail.java index 197b7ca..47063fe 100644 --- a/app/src/main/java/com/thebrokenrail/mtudining/api/method/PeriodDetail.java +++ b/app/src/main/java/com/thebrokenrail/mtudining/api/method/PeriodDetail.java @@ -35,8 +35,16 @@ public class PeriodDetail implements Method { public static class PeriodData { public static class MenuCategory { public static class MenuItem implements Category.Named { + public static class Nutrient { + public String name; + public String value; + } + public String name; public String desc; + public String ingredients; + public String portion; + public List nutrients; public int sort_order; @Override diff --git a/app/src/main/res/values-night/colors.xml b/app/src/main/res/values-night/colors.xml index 466a692..390ec53 100644 --- a/app/src/main/res/values-night/colors.xml +++ b/app/src/main/res/values-night/colors.xml @@ -1,145 +1,145 @@ - #E0C56D - #3C2F00 - #564500 - #FDE186 - #E0C56D - #3C2F00 - #564500 - #FDE186 - #E0C56D - #3C2F00 - #564500 - #FDE186 + #E2C46D + #3D2F00 + #574500 + #FFE089 + #E2C46D + #3D2F00 + #574500 + #FFE089 + #E2C46D + #3D2F00 + #574500 + #FFE089 #FFB4AB #690005 #93000A #FFDAD6 #16130B - #E9E2D4 + #EAE1D4 #16130B - #E9E2D4 + #EAE1D4 #4C4639 - #CEC6B4 - #979080 + #CFC6B4 + #989080 #4C4639 #000000 - #E9E2D4 + #EAE1D4 #343027 - #715C0D - #FDE186 - #231B00 - #E0C56D - #564500 - #FDE186 - #231B00 - #E0C56D - #564500 - #FDE186 - #231B00 - #E0C56D - #564500 + #725C0C + #FFE089 + #241A00 + #E2C46D + #574500 + #FFE089 + #241A00 + #E2C46D + #574500 + #FFE089 + #241A00 + #E2C46D + #574500 #16130B #3D392F #110E07 - #1E1B13 - #221F17 + #1F1B13 + #231F17 #2D2A21 #38342B - #E4C971 - #1D1600 - #A78F3D + #E7C870 + #1D1500 + #A98E3D #000000 - #E4C971 - #1D1600 - #A78F3D + #E7C870 + #1D1500 + #A98E3D #000000 - #E4C971 - #1D1600 - #A78F3D + #E7C870 + #1D1500 + #A98E3D #000000 #FFBAB1 #370001 #FF5449 #000000 #16130B - #E9E2D4 + #EAE1D4 #16130B #FFFAF6 #4C4639 - #D2CAB8 + #D3CAB8 #AAA291 - #898373 + #8A8273 #000000 - #E9E2D4 + #EAE1D4 #2D2A21 - #574600 - #FDE186 + #594600 + #FFE089 #171000 - #E0C56D - #423500 - #FDE186 + #E2C46D + #433400 + #FFE089 #171000 - #E0C56D - #423500 - #FDE186 + #E2C46D + #433400 + #FFE089 #171000 - #E0C56D - #423500 + #E2C46D + #433400 #16130B #3D392F #110E07 - #1E1B13 - #221F17 + #1F1B13 + #231F17 #2D2A21 #38342B #FFFAF6 #000000 - #E4C971 + #E7C870 #000000 #FFFAF6 #000000 - #E4C971 + #E7C870 #000000 #FFFAF6 #000000 - #E4C971 + #E7C870 #000000 #FFF9F9 #000000 #FFBAB1 #000000 #16130B - #E9E2D4 + #EAE1D4 #16130B #FFFFFF #4C4639 #FFFAF6 - #D2CAB8 - #D2CAB8 + #D3CAB8 + #D3CAB8 #000000 - #E9E2D4 + #EAE1D4 #000000 - #342900 - #FFE597 + #352900 + #FFE59E #000000 - #E4C971 - #1D1600 - #FFE597 + #E7C870 + #1D1500 + #FFE59E #000000 - #E4C971 - #1D1600 - #FFE597 + #E7C870 + #1D1500 + #FFE59E #000000 - #E4C971 - #1D1600 + #E7C870 + #1D1500 #16130B #3D392F #110E07 - #1E1B13 - #221F17 + #1F1B13 + #231F17 #2D2A21 #38342B diff --git a/app/src/main/res/values/colors.xml b/app/src/main/res/values/colors.xml index 64c63e3..ec937e8 100644 --- a/app/src/main/res/values/colors.xml +++ b/app/src/main/res/values/colors.xml @@ -3,145 +3,145 @@ #FF000000 #FFFFFFFF - #715C0D + #725C0C #FFFFFF - #FDE186 - #231B00 - #715C0D + #FFE089 + #241A00 + #725C0C #FFFFFF - #FDE186 - #231B00 - #715C0D + #FFE089 + #241A00 + #725C0C #FFFFFF - #FDE186 - #231B00 + #FFE089 + #241A00 #BA1A1A #FFFFFF #FFDAD6 #410002 #FFF8F0 - #1E1B13 + #1F1B13 #FFF8F0 - #1E1B13 - #EBE2CF + #1F1B13 + #EBE1CF #4C4639 - #7D7767 - #CEC6B4 + #7D7667 + #CFC6B4 #000000 #343027 #F8F0E2 - #E0C56D - #FDE186 - #231B00 - #E0C56D - #564500 - #FDE186 - #231B00 - #E0C56D - #564500 - #FDE186 - #231B00 - #E0C56D - #564500 + #E2C46D + #FFE089 + #241A00 + #E2C46D + #574500 + #FFE089 + #241A00 + #E2C46D + #574500 + #FFE089 + #241A00 + #E2C46D + #574500 #E1D9CC #FFF8F0 #FFFFFF #FBF3E5 #F5EDDF - #EFE7DA - #E9E2D4 - #514100 + #EFE7D9 + #EAE1D4 + #534100 #FFFFFF - #897324 + #8A7223 #FFFFFF - #514100 + #534100 #FFFFFF - #897324 + #8A7223 #FFFFFF - #514100 + #534100 #FFFFFF - #897324 + #8A7223 #FFFFFF #8C0009 #FFFFFF #DA342E #FFFFFF #FFF8F0 - #1E1B13 + #1F1B13 #FFF8F0 - #1E1B13 - #EBE2CF - #474235 - #645F50 + #1F1B13 + #EBE1CF + #484235 + #655E50 #817A6B #000000 #343027 #F8F0E2 - #E0C56D - #897324 + #E2C46D + #8A7223 #FFFFFF - #6E5A09 + #705909 #FFFFFF - #897324 + #8A7223 #FFFFFF - #6E5A09 + #705909 #FFFFFF - #897324 + #8A7223 #FFFFFF - #6E5A09 + #705909 #FFFFFF #E1D9CC #FFF8F0 #FFFFFF #FBF3E5 #F5EDDF - #EFE7DA - #E9E2D4 - #2B2100 + #EFE7D9 + #EAE1D4 + #2C2100 #FFFFFF - #514100 + #534100 #FFFFFF - #2B2100 + #2C2100 #FFFFFF - #514100 + #534100 #FFFFFF - #2B2100 + #2C2100 #FFFFFF - #514100 + #534100 #FFFFFF #4E0002 #FFFFFF #8C0009 #FFFFFF #FFF8F0 - #1E1B13 + #1F1B13 #FFF8F0 #000000 - #EBE2CF - #282418 - #474235 - #474235 + #EBE1CF + #282318 + #484235 + #484235 #000000 #343027 #FFFFFF - #FFEBB2 - #514100 + #FFEAB7 + #534100 #FFFFFF - #372B00 + #382B00 #FFFFFF - #514100 + #534100 #FFFFFF - #372B00 + #382B00 #FFFFFF - #514100 + #534100 #FFFFFF - #372B00 + #382B00 #FFFFFF #E1D9CC #FFF8F0 #FFFFFF #FBF3E5 #F5EDDF - #EFE7DA - #E9E2D4 + #EFE7D9 + #EAE1D4 \ No newline at end of file diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 8f7e3b3..fc78d4c 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -7,4 +7,8 @@ Meal Select Date N/A + OK + Ingredients:\u0020 + Portion:\u0020 + Nutrients: \ No newline at end of file