diff --git a/.gitignore b/.gitignore index aa724b7..b2dc3af 100644 --- a/.gitignore +++ b/.gitignore @@ -13,3 +13,4 @@ .externalNativeBuild .cxx local.properties +/keystore.jks diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..938a0d8 --- /dev/null +++ b/LICENSE @@ -0,0 +1,21 @@ +MIT License + +Copyright (c) 2024 TheBrokenRail + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/app/build.gradle.kts b/app/build.gradle.kts index a549fb2..51b67b8 100644 --- a/app/build.gradle.kts +++ b/app/build.gradle.kts @@ -18,6 +18,8 @@ android { buildTypes { release { + isMinifyEnabled = true + isShrinkResources = true proguardFiles(getDefaultProguardFile("proguard-android-optimize.txt"), "proguard-rules.pro") } } @@ -27,6 +29,24 @@ android { // Desugaring (Java 8+ APIs) isCoreLibraryDesugaringEnabled = true } + + // Release Builds + val keystoreFile = File(rootDir, "keystore.jks") + if (keystoreFile.exists()) { + signingConfigs { + create("release") { + keyAlias = "key0" + keyPassword = "password" + storeFile = keystoreFile + storePassword = "password" + } + } + buildTypes { + release { + signingConfig = signingConfigs["release"] + } + } + } } dependencies { 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 ec5833b..8b3b424 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 @@ -68,7 +68,7 @@ public class ItemDialog { for (String filterType : new String[]{LABEL_FILTER, ALLERGEN_FILTER}) { List filters = getFilters(item, filterType); if (filters.size() > 0) { - writeNewline(message, 1); + writeNewline(message, 2); @StringRes int filterName = filterType.equals(LABEL_FILTER) ? R.string.labels : R.string.allergens; message.append(context.getString(filterName), new StyleSpan(Typeface.BOLD), Spanned.SPAN_EXCLUSIVE_EXCLUSIVE); for (String filter : filters) { @@ -81,7 +81,7 @@ public class ItemDialog { message.append(context.getString(R.string.portion), new StyleSpan(Typeface.BOLD), Spanned.SPAN_EXCLUSIVE_EXCLUSIVE); message.append(item.portion); } - writeNewline(message, 1); + writeNewline(message, 2); if (item.ingredients != null) { message.append(context.getString(R.string.ingredients), new StyleSpan(Typeface.BOLD), Spanned.SPAN_EXCLUSIVE_EXCLUSIVE); message.append(item.ingredients); @@ -112,9 +112,11 @@ public class ItemDialog { */ private static List getFilters(PeriodDetail.Response.Menu.PeriodData.MenuCategory.MenuItem item, String type) { List out = new ArrayList<>(); - for (PeriodDetail.Response.Menu.PeriodData.MenuCategory.MenuItem.Filter filter : item.filters) { - if (filter.type.equals(type)) { - out.add(filter.name); + if (item.filters != null) { + for (PeriodDetail.Response.Menu.PeriodData.MenuCategory.MenuItem.Filter filter : item.filters) { + if (filter.type.equals(type)) { + out.add(filter.name); + } } } return out; @@ -132,7 +134,9 @@ public class ItemDialog { if (name != null) { message.append(name + ": ", new StyleSpan(Typeface.BOLD), Spanned.SPAN_EXCLUSIVE_EXCLUSIVE); } - message.append(value); + if (value != null) { + message.append(value); + } } /** diff --git a/app/src/main/java/com/thebrokenrail/mtudining/activity/menu/MenuViewModel.java b/app/src/main/java/com/thebrokenrail/mtudining/activity/menu/MenuViewModel.java index 532b541..bf05038 100644 --- a/app/src/main/java/com/thebrokenrail/mtudining/activity/menu/MenuViewModel.java +++ b/app/src/main/java/com/thebrokenrail/mtudining/activity/menu/MenuViewModel.java @@ -9,12 +9,12 @@ import com.thebrokenrail.mtudining.api.Connection; * Data preserved between screen rotations for {@link MenuActivity}. */ public class MenuViewModel extends ViewModel { - private final Connection connection = new Connection(); public final MenuState state; public final MenuTask task; public MenuViewModel(SavedStateHandle savedStateHandle) { state = new MenuState(savedStateHandle); + Connection connection = new Connection(); task = new MenuTask(connection, state); } }