commit 708d9b763e6cb5f740c1baa9b65c0c20bee92ad8 Author: Diego Ezequiel Guillén Date: Sat Apr 16 19:47:47 2022 -0300 Initial commit diff --git a/._.github b/._.github new file mode 100644 index 0000000..c2dc452 Binary files /dev/null and b/._.github differ diff --git a/._.gitignore b/._.gitignore new file mode 100644 index 0000000..c2dc452 Binary files /dev/null and b/._.gitignore differ diff --git a/._CONTRIBUTING.md b/._CONTRIBUTING.md new file mode 100644 index 0000000..c2dc452 Binary files /dev/null and b/._CONTRIBUTING.md differ diff --git a/._LICENSE b/._LICENSE new file mode 100644 index 0000000..c2dc452 Binary files /dev/null and b/._LICENSE differ diff --git a/._README.md b/._README.md new file mode 100644 index 0000000..c2dc452 Binary files /dev/null and b/._README.md differ diff --git a/._app b/._app new file mode 100644 index 0000000..c2dc452 Binary files /dev/null and b/._app differ diff --git a/._build.gradle b/._build.gradle new file mode 100644 index 0000000..c2dc452 Binary files /dev/null and b/._build.gradle differ diff --git a/._code-of-conduct.md b/._code-of-conduct.md new file mode 100644 index 0000000..c2dc452 Binary files /dev/null and b/._code-of-conduct.md differ diff --git a/._gradle b/._gradle new file mode 100644 index 0000000..c2dc452 Binary files /dev/null and b/._gradle differ diff --git a/._gradle.properties b/._gradle.properties new file mode 100644 index 0000000..c2dc452 Binary files /dev/null and b/._gradle.properties differ diff --git a/._gradlew b/._gradlew new file mode 100644 index 0000000..c2dc452 Binary files /dev/null and b/._gradlew differ diff --git a/._gradlew.bat b/._gradlew.bat new file mode 100644 index 0000000..c2dc452 Binary files /dev/null and b/._gradlew.bat differ diff --git a/._local.properties b/._local.properties new file mode 100644 index 0000000..71fba4b Binary files /dev/null and b/._local.properties differ diff --git a/._settings.gradle b/._settings.gradle new file mode 100644 index 0000000..c2dc452 Binary files /dev/null and b/._settings.gradle differ diff --git a/.gitattributes b/.gitattributes new file mode 100644 index 0000000..dfe0770 --- /dev/null +++ b/.gitattributes @@ -0,0 +1,2 @@ +# Auto detect text files and perform LF normalization +* text=auto diff --git a/.github/._ISSUE_TEMPLATE b/.github/._ISSUE_TEMPLATE new file mode 100644 index 0000000..c2dc452 Binary files /dev/null and b/.github/._ISSUE_TEMPLATE differ diff --git a/.github/ISSUE_TEMPLATE/._android-basics--lemonade-app.md b/.github/ISSUE_TEMPLATE/._android-basics--lemonade-app.md new file mode 100644 index 0000000..c2dc452 Binary files /dev/null and b/.github/ISSUE_TEMPLATE/._android-basics--lemonade-app.md differ diff --git a/.github/ISSUE_TEMPLATE/android-basics--lemonade-app.md b/.github/ISSUE_TEMPLATE/android-basics--lemonade-app.md new file mode 100644 index 0000000..22f5d4a --- /dev/null +++ b/.github/ISSUE_TEMPLATE/android-basics--lemonade-app.md @@ -0,0 +1,32 @@ +--- +name: 'Android Basics: Lemonade app' +about: Describe this issue template's purpose here. +title: 'Android Basics: Lemonade app' +labels: '' +assignees: '' + +--- + +**URL of codelab** + + +**In which task and step of the codelab can this issue be found?** + + +**Describe the problem** + + + + +**Steps to reproduce?** +1. Go to... +2. Click on... +3. See error... + +**Versions** +_Android Studio version:_ +_API version of the emulator:_ + + +**Additional information** +_Include screenshots if they would be useful in clarifying the problem._ diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..a68e5b5 --- /dev/null +++ b/.gitignore @@ -0,0 +1,30 @@ +# Gradle files +.gradle/ +build/ + +# Local configuration file (sdk path, etc) +local.properties + +# Log/OS Files +*.log + +# Android Studio generated files and folders +captures/ +.externalNativeBuild/ +.cxx/ +*.apk +output.json + +# IntelliJ +*.iml +.idea/ + +# Keystore files +*.jks +*.keystore + +# Google Services (e.g. APIs or Firebase) +google-services.json + +# Android Profiling +*.hprof diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md new file mode 100644 index 0000000..22b241c --- /dev/null +++ b/CONTRIBUTING.md @@ -0,0 +1,29 @@ +# How to Contribute + +We'd love to accept your patches and contributions to this project. There are +just a few small guidelines you need to follow. + +## Contributor License Agreement + +Contributions to this project must be accompanied by a Contributor License +Agreement (CLA). You (or your employer) retain the copyright to your +contribution; this simply gives us permission to use and redistribute your +contributions as part of the project. Head over to + to see your current agreements on file or +to sign a new one. + +You generally only need to submit a CLA once, so if you've already submitted one +(even if it was for a different project), you probably don't need to do it +again. + +## Code reviews + +All submissions, including submissions by project members, require review. We +use GitHub pull requests for this purpose. Consult +[GitHub Help](https://help.github.com/articles/about-pull-requests/) for more +information on using pull requests. + +## Community Guidelines + +This project follows +[Google's Open Source Community Guidelines](https://opensource.google/conduct/). diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..b09cd78 --- /dev/null +++ b/LICENSE @@ -0,0 +1,201 @@ +Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "[]" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + + Copyright [yyyy] [name of copyright owner] + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. diff --git a/README.md b/README.md new file mode 100644 index 0000000..9146413 --- /dev/null +++ b/README.md @@ -0,0 +1,27 @@ +Project: Lemonade App - Starter Code +================================== + +Starter code for the first independent project for [Android Basics in Kotlin](https://developer.android.com/courses/android-basics-kotlin/course) + +Introduction +------------ + +This is the starter code for the Lemonade app project in the [final pathway](https://developer.android.com/courses/pathways/android-basics-kotlin-four) of Android Basics [Unit 1](https://developer.android.com/courses/android-basics-kotlin/unit-1). This project is an opportunity for you to demonstrate the concepts you learned in the unit. + +Pre-requisites +-------------- + +- Complete [Unit 1](https://developer.android.com/courses/android-basics-kotlin/unit-1) of Android Basics in Kotlin + +Getting Started +--------------- + +1. Download the starter code +2. Open the project in Android Studio +3. Complete the project in accordance with the [project instructions](https://developer.android.com/codelabs/basic-android-kotlin-training-project-lemonade) + +Tips +---- + +- Use the provided tests to ensure your app is running as expected +- DO NOT ALTER THE PROVIDED TESTS diff --git a/app/._.gitignore b/app/._.gitignore new file mode 100644 index 0000000..c2dc452 Binary files /dev/null and b/app/._.gitignore differ diff --git a/app/._build.gradle b/app/._build.gradle new file mode 100644 index 0000000..c2dc452 Binary files /dev/null and b/app/._build.gradle differ diff --git a/app/._proguard-rules.pro b/app/._proguard-rules.pro new file mode 100644 index 0000000..c2dc452 Binary files /dev/null and b/app/._proguard-rules.pro differ diff --git a/app/._src b/app/._src new file mode 100644 index 0000000..c2dc452 Binary files /dev/null and b/app/._src differ diff --git a/app/.gitignore b/app/.gitignore new file mode 100644 index 0000000..42afabf --- /dev/null +++ b/app/.gitignore @@ -0,0 +1 @@ +/build \ No newline at end of file diff --git a/app/build.gradle b/app/build.gradle new file mode 100644 index 0000000..dc56945 --- /dev/null +++ b/app/build.gradle @@ -0,0 +1,61 @@ +/* + * Copyright (C) 2021 The Android Open Source Project. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +plugins { + id 'com.android.application' + id 'kotlin-android' +} + +android { + compileSdkVersion 30 + buildToolsVersion "30.0.3" + + defaultConfig { + applicationId "com.example.lemonade" + minSdkVersion 21 + targetSdkVersion 30 + versionCode 1 + versionName "1.0" + + testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" + } + + buildTypes { + release { + minifyEnabled false + proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro' + } + } + compileOptions { + sourceCompatibility JavaVersion.VERSION_1_8 + targetCompatibility JavaVersion.VERSION_1_8 + } + kotlinOptions { + jvmTarget = '1.8' + } +} + +dependencies { + + implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version" + implementation 'androidx.core:core-ktx:1.6.0' + implementation 'androidx.appcompat:appcompat:1.3.1' + implementation 'com.google.android.material:material:1.4.0' + implementation 'androidx.constraintlayout:constraintlayout:2.1.1' + testImplementation 'junit:junit:4.13.2' + androidTestImplementation 'androidx.test.ext:junit:1.1.3' + androidTestImplementation "androidx.test:core-ktx:1.4.0" + androidTestImplementation 'androidx.test.espresso:espresso-core:3.4.0' +} diff --git a/app/proguard-rules.pro b/app/proguard-rules.pro new file mode 100644 index 0000000..481bb43 --- /dev/null +++ b/app/proguard-rules.pro @@ -0,0 +1,21 @@ +# Add project specific ProGuard rules here. +# You can control the set of applied configuration files using the +# proguardFiles setting in build.gradle. +# +# For more details, see +# http://developer.android.com/guide/developing/tools/proguard.html + +# If your project uses WebView with JS, uncomment the following +# and specify the fully qualified class name to the JavaScript interface +# class: +#-keepclassmembers class fqcn.of.javascript.interface.for.webview { +# public *; +#} + +# Uncomment this to preserve the line number information for +# debugging stack traces. +#-keepattributes SourceFile,LineNumberTable + +# If you keep the line number information, uncomment this to +# hide the original source file name. +#-renamesourcefileattribute SourceFile \ No newline at end of file diff --git a/app/src/._androidTest b/app/src/._androidTest new file mode 100644 index 0000000..c2dc452 Binary files /dev/null and b/app/src/._androidTest differ diff --git a/app/src/._main b/app/src/._main new file mode 100644 index 0000000..c2dc452 Binary files /dev/null and b/app/src/._main differ diff --git a/app/src/androidTest/._java b/app/src/androidTest/._java new file mode 100644 index 0000000..c2dc452 Binary files /dev/null and b/app/src/androidTest/._java differ diff --git a/app/src/androidTest/java/._com b/app/src/androidTest/java/._com new file mode 100644 index 0000000..c2dc452 Binary files /dev/null and b/app/src/androidTest/java/._com differ diff --git a/app/src/androidTest/java/com/._example b/app/src/androidTest/java/com/._example new file mode 100644 index 0000000..c2dc452 Binary files /dev/null and b/app/src/androidTest/java/com/._example differ diff --git a/app/src/androidTest/java/com/example/._lemonade b/app/src/androidTest/java/com/example/._lemonade new file mode 100644 index 0000000..c2dc452 Binary files /dev/null and b/app/src/androidTest/java/com/example/._lemonade differ diff --git a/app/src/androidTest/java/com/example/lemonade/._BaseTest.kt b/app/src/androidTest/java/com/example/lemonade/._BaseTest.kt new file mode 100644 index 0000000..c2dc452 Binary files /dev/null and b/app/src/androidTest/java/com/example/lemonade/._BaseTest.kt differ diff --git a/app/src/androidTest/java/com/example/lemonade/._LemonadeTests.kt b/app/src/androidTest/java/com/example/lemonade/._LemonadeTests.kt new file mode 100644 index 0000000..c2dc452 Binary files /dev/null and b/app/src/androidTest/java/com/example/lemonade/._LemonadeTests.kt differ diff --git a/app/src/androidTest/java/com/example/lemonade/BaseTest.kt b/app/src/androidTest/java/com/example/lemonade/BaseTest.kt new file mode 100644 index 0000000..e2f4103 --- /dev/null +++ b/app/src/androidTest/java/com/example/lemonade/BaseTest.kt @@ -0,0 +1,157 @@ +/* + * Copyright (C) 2021 The Android Open Source Project. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.example.lemonade + +import android.graphics.Bitmap +import android.graphics.Canvas +import android.graphics.drawable.Drawable +import android.view.View +import android.widget.ImageView +import androidx.annotation.DrawableRes +import androidx.core.content.ContextCompat +import androidx.test.espresso.Espresso.onView +import androidx.test.espresso.NoMatchingViewException +import androidx.test.espresso.ViewInteraction +import androidx.test.espresso.action.ViewActions.click +import androidx.test.espresso.assertion.ViewAssertions.matches +import androidx.test.espresso.matcher.BoundedMatcher +import androidx.test.espresso.matcher.ViewMatchers +import androidx.test.espresso.matcher.ViewMatchers.isDisplayed +import androidx.test.espresso.matcher.ViewMatchers.withId +import androidx.test.ext.junit.rules.ActivityScenarioRule +import com.example.lemonade.DrawableMatcher.withDrawable +import org.hamcrest.Description +import org.hamcrest.Matcher +import org.junit.Rule + +/** + * The lemonade app is effectively a state machine. + * In order to avoid stateful tests (tests that rely on previous tests), + * these utility methods move states and reduce code duplication. + * This class is meant to be inherited by the @Test methods to leverage these methods. + */ +open class BaseTest { + + /** + * Test to ensure the app is in the correct state. + * @param textActionResource Integer for the expected text resource. + * @param drawableResource Integer for the expected drawable resource. + */ + fun testState(textActionResource: Int, drawableResource: Int) { + onView(withId(R.id.text_action)) + .check(matches(ViewMatchers.withText(textActionResource))) + onView(withId(R.id.image_lemon_state)).check( + matches(withDrawable(drawableResource))) + } + + /** + * Clicks the lemon tree image. + */ + fun pickLemon() { + onView(withDrawable(R.drawable.lemon_tree)) + .perform(click()) + } + + /** + * Squeeze the lemon until the lemon image is gone. + * The number of clicks required is determined by a random number that the test is not + * aware of, so we loop and click until the image changes. + */ + fun juiceLemon() { + while (onView(withDrawable(R.drawable.lemon_squeeze)).isPresent()) { + onView(withId(R.id.image_lemon_state)).perform(click()) + } + } + + /** + * Click the lemonade image. + */ + fun drinkJuice() { + onView(withDrawable(R.drawable.lemon_drink)) + .perform(click()) + } + + /** + * Click the empty glass image to restart. + */ + fun restart() { + onView(withDrawable(R.drawable.lemon_restart)) + .perform(click()) + } + + /** + * Extension function to determine if element is present. + * This is used to click the lemon image until it changes because the number of clicks + * required is determined by a random number that the test doesn't know about. + */ + private fun ViewInteraction.isPresent(): Boolean { + return try { + check(matches(isDisplayed())) + true + } catch (e: NoMatchingViewException) { + false + } + } +} + +/** + * Custom matcher to find drawable. + */ +object DrawableMatcher { + + fun withDrawable(@DrawableRes resourceId: Int): Matcher { + return object : BoundedMatcher(ImageView::class.java) { + override fun describeTo(description: Description?) { + description!!.appendText("has drawable resource $resourceId") + } + + override fun matchesSafely(imageView: ImageView): Boolean { + return isSameBitmap(imageView, imageView.drawable, resourceId) + } + } + } + + private fun isSameBitmap(item: View, drawable: Drawable?, expectedResId: Int): Boolean { + val image = item as ImageView + if (expectedResId < 0) { + return image.drawable == null + } + val expectedDrawable: Drawable? = ContextCompat.getDrawable(item.context, expectedResId) + if (drawable == null || expectedDrawable == null) { + return false + } + // Make tint consistent just in case they differ + val bitmap = getBitmap(drawable) + val expectedBitmap = getBitmap(expectedDrawable) + return bitmap.sameAs(expectedBitmap) + } + + /** + * Convert vector drawable to bitmap + * @param drawable vector drawable + */ + private fun getBitmap(drawable: Drawable): Bitmap { + val bitmap = Bitmap.createBitmap( + drawable.intrinsicWidth, + drawable.intrinsicHeight, + Bitmap.Config.ARGB_8888 + ) + val canvas = Canvas(bitmap) + drawable.setBounds(0, 0, canvas.width, canvas.height) + drawable.draw(canvas) + return bitmap + } +} diff --git a/app/src/androidTest/java/com/example/lemonade/LemonadeTests.kt b/app/src/androidTest/java/com/example/lemonade/LemonadeTests.kt new file mode 100644 index 0000000..bcbafb8 --- /dev/null +++ b/app/src/androidTest/java/com/example/lemonade/LemonadeTests.kt @@ -0,0 +1,114 @@ +/* + * Copyright (C) 2021 The Android Open Source Project. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.example.lemonade + +import androidx.test.core.app.launchActivity +import androidx.test.espresso.Espresso.onView +import androidx.test.espresso.action.ViewActions.click +import androidx.test.espresso.action.ViewActions.longClick +import androidx.test.espresso.assertion.ViewAssertions.matches +import androidx.test.espresso.matcher.ViewMatchers.withId +import androidx.test.espresso.matcher.ViewMatchers.withText +import androidx.test.ext.junit.runners.AndroidJUnit4 +import androidx.test.filters.LargeTest +import org.junit.Before +import org.junit.Test +import org.junit.runner.RunWith + +/** + * Instrumentation tests to be run on a physical device or emulator. + */ +@RunWith(AndroidJUnit4::class) +@LargeTest +class LemonadeTests : BaseTest() { + + @Before + fun setup() { + launchActivity() + } + + /** + * Test the view components of the pick lemon state + */ + @Test + fun `test_initial_state`() { + testState(R.string.lemon_select, R.drawable.lemon_tree) + } + + /** + * Test that the pick lemon functionality takes us to the "squeeze state" + */ + @Test + fun `test_picking_lemon_proceeds_to_squeeze_state`() { + // Click image to progress state + onView(withId(R.id.image_lemon_state)).perform(click()) + testState(R.string.lemon_squeeze, R.drawable.lemon_squeeze) + } + + /** + * Test that the squeeze functionality takes us to the "drink state" + */ + @Test + fun `test_squeezing_lemon_proceeds_to_drink_state`() { + // Click image to progress state + onView(withId(R.id.image_lemon_state)).perform(click()) + juiceLemon() + testState(R.string.lemon_drink, R.drawable.lemon_drink) + } + + /** + * Test squeeze count snackbar + */ + @Test + fun `test_squeeze_count_snackbar_is_displayed`() { + // Click image to progress state + onView(withId(R.id.image_lemon_state)).perform(click()) + // Click image to progress state + onView(withId(R.id.image_lemon_state)).perform(click()) + // Click image to progress state + onView(withId(R.id.image_lemon_state)).perform(longClick()) + onView(withId(com.google.android.material.R.id.snackbar_text)) + .check(matches(withText("Squeeze count: 1, keep squeezing!"))) + } + + /** + * Test that the drink functionality takes us to the "restart state" + */ + @Test + fun `test_drinking_juice_proceeds_to_restart_state`() { + // Click image to progress state + onView(withId(R.id.image_lemon_state)).perform(click()) + juiceLemon() + onView(withId(R.id.image_lemon_state)).perform(click()) + // Click image to progress state + testState(R.string.lemon_empty_glass, R.drawable.lemon_restart) + } + + /** + * Test that the restart functionality takes us back to the "pick lemon state" + */ + @Test + fun `test_restarting_proceeds_to_pick_lemon_state`() { + // Click image to progress state + onView(withId(R.id.image_lemon_state)).perform(click()) + juiceLemon() + // Click image to progress state + onView(withId(R.id.image_lemon_state)).perform(click()) + // Click image to progress state + onView(withId(R.id.image_lemon_state)).perform(click()) + testState(R.string.lemon_select, R.drawable.lemon_tree) + } +} diff --git a/app/src/main/._AndroidManifest.xml b/app/src/main/._AndroidManifest.xml new file mode 100644 index 0000000..c2dc452 Binary files /dev/null and b/app/src/main/._AndroidManifest.xml differ diff --git a/app/src/main/._ic_launcher_lemonade-playstore.png b/app/src/main/._ic_launcher_lemonade-playstore.png new file mode 100644 index 0000000..c2dc452 Binary files /dev/null and b/app/src/main/._ic_launcher_lemonade-playstore.png differ diff --git a/app/src/main/._java b/app/src/main/._java new file mode 100644 index 0000000..c2dc452 Binary files /dev/null and b/app/src/main/._java differ diff --git a/app/src/main/._res b/app/src/main/._res new file mode 100644 index 0000000..c2dc452 Binary files /dev/null and b/app/src/main/._res differ diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml new file mode 100644 index 0000000..1f268c5 --- /dev/null +++ b/app/src/main/AndroidManifest.xml @@ -0,0 +1,36 @@ + + + + + + + + + + + + + + + diff --git a/app/src/main/ic_launcher_lemonade-playstore.png b/app/src/main/ic_launcher_lemonade-playstore.png new file mode 100644 index 0000000..39a28e9 Binary files /dev/null and b/app/src/main/ic_launcher_lemonade-playstore.png differ diff --git a/app/src/main/java/._com b/app/src/main/java/._com new file mode 100644 index 0000000..c2dc452 Binary files /dev/null and b/app/src/main/java/._com differ diff --git a/app/src/main/java/com/._example b/app/src/main/java/com/._example new file mode 100644 index 0000000..c2dc452 Binary files /dev/null and b/app/src/main/java/com/._example differ diff --git a/app/src/main/java/com/example/._lemonade b/app/src/main/java/com/example/._lemonade new file mode 100644 index 0000000..c2dc452 Binary files /dev/null and b/app/src/main/java/com/example/._lemonade differ diff --git a/app/src/main/java/com/example/lemonade/._MainActivity.kt b/app/src/main/java/com/example/lemonade/._MainActivity.kt new file mode 100644 index 0000000..c2dc452 Binary files /dev/null and b/app/src/main/java/com/example/lemonade/._MainActivity.kt differ diff --git a/app/src/main/java/com/example/lemonade/MainActivity.kt b/app/src/main/java/com/example/lemonade/MainActivity.kt new file mode 100644 index 0000000..32cd93e --- /dev/null +++ b/app/src/main/java/com/example/lemonade/MainActivity.kt @@ -0,0 +1,198 @@ +/* + * Copyright (C) 2021 The Android Open Source Project. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.example.lemonade + +import android.os.Bundle +import android.widget.ImageView +import android.widget.TextView +import androidx.appcompat.app.AppCompatActivity +import com.google.android.material.snackbar.Snackbar + +class MainActivity : AppCompatActivity() { + + /** + * DO NOT ALTER ANY VARIABLE OR VALUE NAMES OR THEIR INITIAL VALUES. + * + * Anything labeled var instead of val is expected to be changed in the functions but DO NOT + * alter their initial values declared here, this could cause the app to not function properly. + */ + private val LEMONADE_STATE = "LEMONADE_STATE" + private val LEMON_SIZE = "LEMON_SIZE" + private val SQUEEZE_COUNT = "SQUEEZE_COUNT" + // SELECT represents the "pick lemon" state + private val SELECT = "select" + // SQUEEZE represents the "squeeze lemon" state + private val SQUEEZE = "squeeze" + // DRINK represents the "drink lemonade" state + private val DRINK = "drink" + // RESTART represents the state where the lemonade has been drunk and the glass is empty + private val RESTART = "restart" + // Default the state to select + private var lemonadeState = "select" + // Default lemonSize to -1 + private var lemonSize = -1 + // Default the squeezeCount to -1 + private var squeezeCount = -1 + + private var lemonTree = LemonTree() + private var lemonImage: ImageView? = null + + + override fun onCreate(savedInstanceState: Bundle?) { + super.onCreate(savedInstanceState) + setContentView(R.layout.activity_main) + + // === DO NOT ALTER THE CODE IN THE FOLLOWING IF STATEMENT === + if (savedInstanceState != null) { + lemonadeState = savedInstanceState.getString(LEMONADE_STATE, "select") + lemonSize = savedInstanceState.getInt(LEMON_SIZE, -1) + squeezeCount = savedInstanceState.getInt(SQUEEZE_COUNT, -1) + } + // === END IF STATEMENT === + + lemonImage = findViewById(R.id.image_lemon_state) + setViewElements() + lemonImage!!.setOnClickListener { + // TODO: call the method that handles the state when the image is clicked + clickLemonImage() + } + lemonImage!!.setOnLongClickListener { + // TODO: replace 'false' with a call to the function that shows the squeeze count + showSnackbar()//false + } + } + + /** + * === DO NOT ALTER THIS METHOD === + * + * This method saves the state of the app if it is put in the background. + */ + override fun onSaveInstanceState(outState: Bundle) { + outState.putString(LEMONADE_STATE, lemonadeState) + outState.putInt(LEMON_SIZE, lemonSize) + outState.putInt(SQUEEZE_COUNT, squeezeCount) + super.onSaveInstanceState(outState) + } + + /** + * Clicking will elicit a different response depending on the state. + * This method determines the state and proceeds with the correct action. + */ + private fun clickLemonImage() { + // TODO: use a conditional statement like 'if' or 'when' to track the lemonadeState + // when the image is clicked we may need to change state to the next step in the + // lemonade making progression (or at least make some changes to the current state in the + // case of squeezing the lemon). That should be done in this conditional statement + when (lemonadeState) { + + // TODO: When the image is clicked in the SELECT state, the state should become SQUEEZE + SELECT -> { + lemonadeState = SQUEEZE + // - The lemonSize variable needs to be set using the 'pick()' method in the LemonTree class + lemonSize = lemonTree.pick() + // - The squeezeCount should be 0 since we haven't squeezed any lemons just yet. + squeezeCount = 0 + } + + // TODO: When the image is clicked in the SQUEEZE state the squeezeCount needs to be + SQUEEZE -> { + // INCREASED by 1 and lemonSize needs to be DECREASED by 1. + squeezeCount++ + lemonSize-- + // - If the lemonSize has reached 0, it has been juiced and the state should become DRINK + if (lemonSize == 0) { + lemonadeState = DRINK + // - Additionally, lemonSize is no longer relevant and should be set to -1 + lemonSize = -1 + } + } + + // TODO: When the image is clicked in the DRINK state the state should become RESTART + DRINK -> { + lemonadeState = RESTART + lemonSize = -1 + } + + // TODO: When the image is clicked in the RESTART state the state should become SELECT + RESTART -> lemonadeState = SELECT + + } + // TODO: lastly, before the function terminates we need to set the view elements so that the + // UI can reflect the correct state + setViewElements() + } + + /** + * Set up the view elements according to the state. + */ + private fun setViewElements() { + val textAction: TextView = findViewById(R.id.text_action) + + // TODO: set up a conditional that tracks the lemonadeState + when (lemonadeState){ + SELECT -> { + // TODO: for each state, the textAction TextView should be set to the corresponding string from + // the string resources file. The strings are named to match the state + textAction.setText(R.string.lemon_select) + // TODO: Additionally, for each state, the lemonImage should be set to the corresponding + // drawable from the drawable resources. The drawables have the same names as the strings + // but remember that they are drawables, not strings. + lemonImage?.setImageResource(R.drawable.lemon_tree) + } + SQUEEZE -> { + textAction.setText(R.string.lemon_squeeze) + lemonImage?.setImageResource(R.drawable.lemon_squeeze) + } + DRINK -> { + textAction.setText(R.string.lemon_drink) + lemonImage?.setImageResource(R.drawable.lemon_drink) + } + RESTART -> { + textAction.setText(R.string.lemon_empty_glass) + lemonImage?.setImageResource(R.drawable.lemon_restart) + } + } + + } + + /** + * === DO NOT ALTER THIS METHOD === + * + * Long clicking the lemon image will show how many times the lemon has been squeezed. + */ + private fun showSnackbar(): Boolean { + if (lemonadeState != SQUEEZE) { + return false + } + val squeezeText = getString(R.string.squeeze_count, squeezeCount) + Snackbar.make( + findViewById(R.id.constraint_Layout), + squeezeText, + Snackbar.LENGTH_SHORT + ).show() + return true + } +} + +/** + * A Lemon tree class with a method to "pick" a lemon. The "size" of the lemon is randomized + * and determines how many times a lemon needs to be squeezed before you get lemonade. + */ +class LemonTree { + fun pick(): Int { + return (2..4).random() + } +} diff --git a/app/src/main/res/._drawable b/app/src/main/res/._drawable new file mode 100644 index 0000000..c2dc452 Binary files /dev/null and b/app/src/main/res/._drawable differ diff --git a/app/src/main/res/._layout b/app/src/main/res/._layout new file mode 100644 index 0000000..c2dc452 Binary files /dev/null and b/app/src/main/res/._layout differ diff --git a/app/src/main/res/._mipmap-anydpi-v26 b/app/src/main/res/._mipmap-anydpi-v26 new file mode 100644 index 0000000..c2dc452 Binary files /dev/null and b/app/src/main/res/._mipmap-anydpi-v26 differ diff --git a/app/src/main/res/._mipmap-hdpi b/app/src/main/res/._mipmap-hdpi new file mode 100644 index 0000000..c2dc452 Binary files /dev/null and b/app/src/main/res/._mipmap-hdpi differ diff --git a/app/src/main/res/._mipmap-mdpi b/app/src/main/res/._mipmap-mdpi new file mode 100644 index 0000000..c2dc452 Binary files /dev/null and b/app/src/main/res/._mipmap-mdpi differ diff --git a/app/src/main/res/._mipmap-xhdpi b/app/src/main/res/._mipmap-xhdpi new file mode 100644 index 0000000..c2dc452 Binary files /dev/null and b/app/src/main/res/._mipmap-xhdpi differ diff --git a/app/src/main/res/._mipmap-xxhdpi b/app/src/main/res/._mipmap-xxhdpi new file mode 100644 index 0000000..c2dc452 Binary files /dev/null and b/app/src/main/res/._mipmap-xxhdpi differ diff --git a/app/src/main/res/._mipmap-xxxhdpi b/app/src/main/res/._mipmap-xxxhdpi new file mode 100644 index 0000000..c2dc452 Binary files /dev/null and b/app/src/main/res/._mipmap-xxxhdpi differ diff --git a/app/src/main/res/._values b/app/src/main/res/._values new file mode 100644 index 0000000..c2dc452 Binary files /dev/null and b/app/src/main/res/._values differ diff --git a/app/src/main/res/._values-night b/app/src/main/res/._values-night new file mode 100644 index 0000000..c2dc452 Binary files /dev/null and b/app/src/main/res/._values-night differ diff --git a/app/src/main/res/drawable/._ic_launcher_lemonade_background.xml b/app/src/main/res/drawable/._ic_launcher_lemonade_background.xml new file mode 100644 index 0000000..c2dc452 Binary files /dev/null and b/app/src/main/res/drawable/._ic_launcher_lemonade_background.xml differ diff --git a/app/src/main/res/drawable/._ic_launcher_lemonade_foreground.xml b/app/src/main/res/drawable/._ic_launcher_lemonade_foreground.xml new file mode 100644 index 0000000..c2dc452 Binary files /dev/null and b/app/src/main/res/drawable/._ic_launcher_lemonade_foreground.xml differ diff --git a/app/src/main/res/drawable/._lemon_drink.xml b/app/src/main/res/drawable/._lemon_drink.xml new file mode 100644 index 0000000..c2dc452 Binary files /dev/null and b/app/src/main/res/drawable/._lemon_drink.xml differ diff --git a/app/src/main/res/drawable/._lemon_restart.xml b/app/src/main/res/drawable/._lemon_restart.xml new file mode 100644 index 0000000..c2dc452 Binary files /dev/null and b/app/src/main/res/drawable/._lemon_restart.xml differ diff --git a/app/src/main/res/drawable/._lemon_squeeze.xml b/app/src/main/res/drawable/._lemon_squeeze.xml new file mode 100644 index 0000000..c2dc452 Binary files /dev/null and b/app/src/main/res/drawable/._lemon_squeeze.xml differ diff --git a/app/src/main/res/drawable/._lemon_tree.xml b/app/src/main/res/drawable/._lemon_tree.xml new file mode 100644 index 0000000..c2dc452 Binary files /dev/null and b/app/src/main/res/drawable/._lemon_tree.xml differ diff --git a/app/src/main/res/drawable/ic_launcher_lemonade_background.xml b/app/src/main/res/drawable/ic_launcher_lemonade_background.xml new file mode 100644 index 0000000..0b6a122 --- /dev/null +++ b/app/src/main/res/drawable/ic_launcher_lemonade_background.xml @@ -0,0 +1,27 @@ + + + + + + diff --git a/app/src/main/res/drawable/ic_launcher_lemonade_foreground.xml b/app/src/main/res/drawable/ic_launcher_lemonade_foreground.xml new file mode 100644 index 0000000..c47703b --- /dev/null +++ b/app/src/main/res/drawable/ic_launcher_lemonade_foreground.xml @@ -0,0 +1,142 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/app/src/main/res/drawable/lemon_drink.xml b/app/src/main/res/drawable/lemon_drink.xml new file mode 100644 index 0000000..1675978 --- /dev/null +++ b/app/src/main/res/drawable/lemon_drink.xml @@ -0,0 +1,103 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/app/src/main/res/drawable/lemon_restart.xml b/app/src/main/res/drawable/lemon_restart.xml new file mode 100644 index 0000000..c5f5379 --- /dev/null +++ b/app/src/main/res/drawable/lemon_restart.xml @@ -0,0 +1,27 @@ + + + + + diff --git a/app/src/main/res/drawable/lemon_squeeze.xml b/app/src/main/res/drawable/lemon_squeeze.xml new file mode 100644 index 0000000..cc90a93 --- /dev/null +++ b/app/src/main/res/drawable/lemon_squeeze.xml @@ -0,0 +1,69 @@ + + + + + + + + + + + + + + + + + + + diff --git a/app/src/main/res/drawable/lemon_tree.xml b/app/src/main/res/drawable/lemon_tree.xml new file mode 100644 index 0000000..a307871 --- /dev/null +++ b/app/src/main/res/drawable/lemon_tree.xml @@ -0,0 +1,156 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/app/src/main/res/layout/._activity_main.xml b/app/src/main/res/layout/._activity_main.xml new file mode 100644 index 0000000..c2dc452 Binary files /dev/null and b/app/src/main/res/layout/._activity_main.xml differ diff --git a/app/src/main/res/layout/activity_main.xml b/app/src/main/res/layout/activity_main.xml new file mode 100644 index 0000000..b7d8787 --- /dev/null +++ b/app/src/main/res/layout/activity_main.xml @@ -0,0 +1,49 @@ + + + + + + + + diff --git a/app/src/main/res/mipmap-anydpi-v26/._ic_launcher_lemonade.xml b/app/src/main/res/mipmap-anydpi-v26/._ic_launcher_lemonade.xml new file mode 100644 index 0000000..c2dc452 Binary files /dev/null and b/app/src/main/res/mipmap-anydpi-v26/._ic_launcher_lemonade.xml differ diff --git a/app/src/main/res/mipmap-anydpi-v26/._ic_launcher_lemonade_round.xml b/app/src/main/res/mipmap-anydpi-v26/._ic_launcher_lemonade_round.xml new file mode 100644 index 0000000..c2dc452 Binary files /dev/null and b/app/src/main/res/mipmap-anydpi-v26/._ic_launcher_lemonade_round.xml differ diff --git a/app/src/main/res/mipmap-anydpi-v26/ic_launcher_lemonade.xml b/app/src/main/res/mipmap-anydpi-v26/ic_launcher_lemonade.xml new file mode 100644 index 0000000..a082bbe --- /dev/null +++ b/app/src/main/res/mipmap-anydpi-v26/ic_launcher_lemonade.xml @@ -0,0 +1,5 @@ + + + + + \ No newline at end of file diff --git a/app/src/main/res/mipmap-anydpi-v26/ic_launcher_lemonade_round.xml b/app/src/main/res/mipmap-anydpi-v26/ic_launcher_lemonade_round.xml new file mode 100644 index 0000000..a082bbe --- /dev/null +++ b/app/src/main/res/mipmap-anydpi-v26/ic_launcher_lemonade_round.xml @@ -0,0 +1,5 @@ + + + + + \ No newline at end of file diff --git a/app/src/main/res/mipmap-hdpi/._ic_launcher_lemonade.png b/app/src/main/res/mipmap-hdpi/._ic_launcher_lemonade.png new file mode 100644 index 0000000..c2dc452 Binary files /dev/null and b/app/src/main/res/mipmap-hdpi/._ic_launcher_lemonade.png differ diff --git a/app/src/main/res/mipmap-hdpi/._ic_launcher_lemonade_round.png b/app/src/main/res/mipmap-hdpi/._ic_launcher_lemonade_round.png new file mode 100644 index 0000000..c2dc452 Binary files /dev/null and b/app/src/main/res/mipmap-hdpi/._ic_launcher_lemonade_round.png differ diff --git a/app/src/main/res/mipmap-hdpi/ic_launcher_lemonade.png b/app/src/main/res/mipmap-hdpi/ic_launcher_lemonade.png new file mode 100644 index 0000000..f56ea0b Binary files /dev/null and b/app/src/main/res/mipmap-hdpi/ic_launcher_lemonade.png differ diff --git a/app/src/main/res/mipmap-hdpi/ic_launcher_lemonade_round.png b/app/src/main/res/mipmap-hdpi/ic_launcher_lemonade_round.png new file mode 100644 index 0000000..47e5034 Binary files /dev/null and b/app/src/main/res/mipmap-hdpi/ic_launcher_lemonade_round.png differ diff --git a/app/src/main/res/mipmap-mdpi/._ic_launcher_lemonade.png b/app/src/main/res/mipmap-mdpi/._ic_launcher_lemonade.png new file mode 100644 index 0000000..c2dc452 Binary files /dev/null and b/app/src/main/res/mipmap-mdpi/._ic_launcher_lemonade.png differ diff --git a/app/src/main/res/mipmap-mdpi/._ic_launcher_lemonade_round.png b/app/src/main/res/mipmap-mdpi/._ic_launcher_lemonade_round.png new file mode 100644 index 0000000..c2dc452 Binary files /dev/null and b/app/src/main/res/mipmap-mdpi/._ic_launcher_lemonade_round.png differ diff --git a/app/src/main/res/mipmap-mdpi/ic_launcher_lemonade.png b/app/src/main/res/mipmap-mdpi/ic_launcher_lemonade.png new file mode 100644 index 0000000..c085f7b Binary files /dev/null and b/app/src/main/res/mipmap-mdpi/ic_launcher_lemonade.png differ diff --git a/app/src/main/res/mipmap-mdpi/ic_launcher_lemonade_round.png b/app/src/main/res/mipmap-mdpi/ic_launcher_lemonade_round.png new file mode 100644 index 0000000..3e6eb78 Binary files /dev/null and b/app/src/main/res/mipmap-mdpi/ic_launcher_lemonade_round.png differ diff --git a/app/src/main/res/mipmap-xhdpi/._ic_launcher_lemonade.png b/app/src/main/res/mipmap-xhdpi/._ic_launcher_lemonade.png new file mode 100644 index 0000000..c2dc452 Binary files /dev/null and b/app/src/main/res/mipmap-xhdpi/._ic_launcher_lemonade.png differ diff --git a/app/src/main/res/mipmap-xhdpi/._ic_launcher_lemonade_round.png b/app/src/main/res/mipmap-xhdpi/._ic_launcher_lemonade_round.png new file mode 100644 index 0000000..c2dc452 Binary files /dev/null and b/app/src/main/res/mipmap-xhdpi/._ic_launcher_lemonade_round.png differ diff --git a/app/src/main/res/mipmap-xhdpi/ic_launcher_lemonade.png b/app/src/main/res/mipmap-xhdpi/ic_launcher_lemonade.png new file mode 100644 index 0000000..175b160 Binary files /dev/null and b/app/src/main/res/mipmap-xhdpi/ic_launcher_lemonade.png differ diff --git a/app/src/main/res/mipmap-xhdpi/ic_launcher_lemonade_round.png b/app/src/main/res/mipmap-xhdpi/ic_launcher_lemonade_round.png new file mode 100644 index 0000000..9755b5b Binary files /dev/null and b/app/src/main/res/mipmap-xhdpi/ic_launcher_lemonade_round.png differ diff --git a/app/src/main/res/mipmap-xxhdpi/._ic_launcher_lemonade.png b/app/src/main/res/mipmap-xxhdpi/._ic_launcher_lemonade.png new file mode 100644 index 0000000..c2dc452 Binary files /dev/null and b/app/src/main/res/mipmap-xxhdpi/._ic_launcher_lemonade.png differ diff --git a/app/src/main/res/mipmap-xxhdpi/._ic_launcher_lemonade_round.png b/app/src/main/res/mipmap-xxhdpi/._ic_launcher_lemonade_round.png new file mode 100644 index 0000000..c2dc452 Binary files /dev/null and b/app/src/main/res/mipmap-xxhdpi/._ic_launcher_lemonade_round.png differ diff --git a/app/src/main/res/mipmap-xxhdpi/ic_launcher_lemonade.png b/app/src/main/res/mipmap-xxhdpi/ic_launcher_lemonade.png new file mode 100644 index 0000000..b4f6285 Binary files /dev/null and b/app/src/main/res/mipmap-xxhdpi/ic_launcher_lemonade.png differ diff --git a/app/src/main/res/mipmap-xxhdpi/ic_launcher_lemonade_round.png b/app/src/main/res/mipmap-xxhdpi/ic_launcher_lemonade_round.png new file mode 100644 index 0000000..9fbc6db Binary files /dev/null and b/app/src/main/res/mipmap-xxhdpi/ic_launcher_lemonade_round.png differ diff --git a/app/src/main/res/mipmap-xxxhdpi/._ic_launcher_lemonade.png b/app/src/main/res/mipmap-xxxhdpi/._ic_launcher_lemonade.png new file mode 100644 index 0000000..c2dc452 Binary files /dev/null and b/app/src/main/res/mipmap-xxxhdpi/._ic_launcher_lemonade.png differ diff --git a/app/src/main/res/mipmap-xxxhdpi/._ic_launcher_lemonade_round.png b/app/src/main/res/mipmap-xxxhdpi/._ic_launcher_lemonade_round.png new file mode 100644 index 0000000..c2dc452 Binary files /dev/null and b/app/src/main/res/mipmap-xxxhdpi/._ic_launcher_lemonade_round.png differ diff --git a/app/src/main/res/mipmap-xxxhdpi/ic_launcher_lemonade.png b/app/src/main/res/mipmap-xxxhdpi/ic_launcher_lemonade.png new file mode 100644 index 0000000..6b49424 Binary files /dev/null and b/app/src/main/res/mipmap-xxxhdpi/ic_launcher_lemonade.png differ diff --git a/app/src/main/res/mipmap-xxxhdpi/ic_launcher_lemonade_round.png b/app/src/main/res/mipmap-xxxhdpi/ic_launcher_lemonade_round.png new file mode 100644 index 0000000..f864082 Binary files /dev/null and b/app/src/main/res/mipmap-xxxhdpi/ic_launcher_lemonade_round.png differ diff --git a/app/src/main/res/values-night/._themes.xml b/app/src/main/res/values-night/._themes.xml new file mode 100644 index 0000000..c2dc452 Binary files /dev/null and b/app/src/main/res/values-night/._themes.xml differ diff --git a/app/src/main/res/values-night/themes.xml b/app/src/main/res/values-night/themes.xml new file mode 100644 index 0000000..37d9f99 --- /dev/null +++ b/app/src/main/res/values-night/themes.xml @@ -0,0 +1,31 @@ + + + + + diff --git a/app/src/main/res/values/._colors.xml b/app/src/main/res/values/._colors.xml new file mode 100644 index 0000000..c2dc452 Binary files /dev/null and b/app/src/main/res/values/._colors.xml differ diff --git a/app/src/main/res/values/._strings.xml b/app/src/main/res/values/._strings.xml new file mode 100644 index 0000000..c2dc452 Binary files /dev/null and b/app/src/main/res/values/._strings.xml differ diff --git a/app/src/main/res/values/._themes.xml b/app/src/main/res/values/._themes.xml new file mode 100644 index 0000000..c2dc452 Binary files /dev/null and b/app/src/main/res/values/._themes.xml differ diff --git a/app/src/main/res/values/colors.xml b/app/src/main/res/values/colors.xml new file mode 100644 index 0000000..7a32c30 --- /dev/null +++ b/app/src/main/res/values/colors.xml @@ -0,0 +1,25 @@ + + + + #ffff8b + #ffee58 + #FFD600 + #FF03DAC5 + #FF018786 + #FF000000 + #FFFFFFFF + diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml new file mode 100644 index 0000000..88eb9e7 --- /dev/null +++ b/app/src/main/res/values/strings.xml @@ -0,0 +1,23 @@ + + + Lemonade + Click to select a lemon! + Click to juice the lemon! + Click to drink your lemonade! + Click to start again! + Squeeze count: %1$d, keep squeezing! + diff --git a/app/src/main/res/values/themes.xml b/app/src/main/res/values/themes.xml new file mode 100644 index 0000000..052f33e --- /dev/null +++ b/app/src/main/res/values/themes.xml @@ -0,0 +1,27 @@ + + + + + diff --git a/build.gradle b/build.gradle new file mode 100644 index 0000000..5fb9455 --- /dev/null +++ b/build.gradle @@ -0,0 +1,26 @@ +// Top-level build file where you can add configuration options common to all sub-projects/modules. +buildscript { + ext.kotlin_version = "1.5.20" + repositories { + google() + mavenCentral() + } + dependencies { + classpath "com.android.tools.build:gradle:4.1.3" + classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version" + + // NOTE: Do not place your application dependencies here; they belong + // in the individual module build.gradle files + } +} + +allprojects { + repositories { + google() + mavenCentral() + } +} + +task clean(type: Delete) { + delete rootProject.buildDir +} diff --git a/code-of-conduct.md b/code-of-conduct.md new file mode 100644 index 0000000..dc079b4 --- /dev/null +++ b/code-of-conduct.md @@ -0,0 +1,93 @@ +# Code of Conduct + +## Our Pledge + +In the interest of fostering an open and welcoming environment, we as +contributors and maintainers pledge to making participation in our project and +our community a harassment-free experience for everyone, regardless of age, body +size, disability, ethnicity, gender identity and expression, level of +experience, education, socio-economic status, nationality, personal appearance, +race, religion, or sexual identity and orientation. + +## Our Standards + +Examples of behavior that contributes to creating a positive environment +include: + +* Using welcoming and inclusive language +* Being respectful of differing viewpoints and experiences +* Gracefully accepting constructive criticism +* Focusing on what is best for the community +* Showing empathy towards other community members + +Examples of unacceptable behavior by participants include: + +* The use of sexualized language or imagery and unwelcome sexual attention or + advances +* Trolling, insulting/derogatory comments, and personal or political attacks +* Public or private harassment +* Publishing others' private information, such as a physical or electronic + address, without explicit permission +* Other conduct which could reasonably be considered inappropriate in a + professional setting + +## Our Responsibilities + +Project maintainers are responsible for clarifying the standards of acceptable +behavior and are expected to take appropriate and fair corrective action in +response to any instances of unacceptable behavior. + +Project maintainers have the right and responsibility to remove, edit, or reject +comments, commits, code, wiki edits, issues, and other contributions that are +not aligned to this Code of Conduct, or to ban temporarily or permanently any +contributor for other behaviors that they deem inappropriate, threatening, +offensive, or harmful. + +## Scope + +This Code of Conduct applies both within project spaces and in public spaces +when an individual is representing the project or its community. Examples of +representing a project or community include using an official project e-mail +address, posting via an official social media account, or acting as an appointed +representative at an online or offline event. Representation of a project may be +further defined and clarified by project maintainers. + +This Code of Conduct also applies outside the project spaces when the Project +Steward has a reasonable belief that an individual's behavior may have a +negative impact on the project or its community. + +## Conflict Resolution + +We do not believe that all conflict is bad; healthy debate and disagreement +often yield positive results. However, it is never okay to be disrespectful or +to engage in behavior that violates the project’s code of conduct. + +If you see someone violating the code of conduct, you are encouraged to address +the behavior directly with those involved. Many issues can be resolved quickly +and easily, and this gives people more control over the outcome of their +dispute. If you are unable to resolve the matter for any reason, or if the +behavior is threatening or harassing, report it. We are dedicated to providing +an environment where participants feel welcome and safe. + +Reports should be directed to *[PROJECT STEWARD NAME(s) AND EMAIL(s)]*, the +Project Steward(s) for *[PROJECT NAME]*. It is the Project Steward’s duty to +receive and address reported violations of the code of conduct. They will then +work with a committee consisting of representatives from the Open Source +Programs Office and the Google Open Source Strategy team. If for any reason you +are uncomfortable reaching out to the Project Steward, please email +opensource@google.com. + +We will investigate every complaint, but you may not receive a direct response. +We will use our discretion in determining when and how to follow up on reported +incidents, which may range from not taking action to permanent expulsion from +the project and project-sponsored spaces. We will notify the accused of the +report and provide them an opportunity to discuss it before any action is taken. +The identity of the reporter will be omitted from the details of the report +supplied to the accused. In potentially harmful situations, such as ongoing +harassment or threats to anyone's safety, we may take action without notice. + +## Attribution + +This Code of Conduct is adapted from the Contributor Covenant, version 1.4, +available at +https://www.contributor-covenant.org/version/1/4/code-of-conduct.html diff --git a/gradle.properties b/gradle.properties new file mode 100644 index 0000000..98bed16 --- /dev/null +++ b/gradle.properties @@ -0,0 +1,21 @@ +# Project-wide Gradle settings. +# IDE (e.g. Android Studio) users: +# Gradle settings configured through the IDE *will override* +# any settings specified in this file. +# For more details on how to configure your build environment visit +# http://www.gradle.org/docs/current/userguide/build_environment.html +# Specifies the JVM arguments used for the daemon process. +# The setting is particularly useful for tweaking memory settings. +org.gradle.jvmargs=-Xmx2048m -Dfile.encoding=UTF-8 +# When configured, Gradle will run in incubating parallel mode. +# This option should only be used with decoupled projects. More details, visit +# http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects +# org.gradle.parallel=true +# AndroidX package structure to make it clearer which packages are bundled with the +# Android operating system, and which are packaged with your app"s APK +# https://developer.android.com/topic/libraries/support-library/androidx-rn +android.useAndroidX=true +# Automatically convert third-party libraries to use AndroidX +android.enableJetifier=true +# Kotlin code style for this project: "official" or "obsolete": +kotlin.code.style=official \ No newline at end of file diff --git a/gradle/._wrapper b/gradle/._wrapper new file mode 100644 index 0000000..c2dc452 Binary files /dev/null and b/gradle/._wrapper differ diff --git a/gradle/wrapper/._gradle-wrapper.jar b/gradle/wrapper/._gradle-wrapper.jar new file mode 100644 index 0000000..c2dc452 Binary files /dev/null and b/gradle/wrapper/._gradle-wrapper.jar differ diff --git a/gradle/wrapper/._gradle-wrapper.properties b/gradle/wrapper/._gradle-wrapper.properties new file mode 100644 index 0000000..c2dc452 Binary files /dev/null and b/gradle/wrapper/._gradle-wrapper.properties differ diff --git a/gradle/wrapper/gradle-wrapper.jar b/gradle/wrapper/gradle-wrapper.jar new file mode 100644 index 0000000..f6b961f Binary files /dev/null and b/gradle/wrapper/gradle-wrapper.jar differ diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties new file mode 100644 index 0000000..34be84c --- /dev/null +++ b/gradle/wrapper/gradle-wrapper.properties @@ -0,0 +1,6 @@ +#Fri Apr 23 15:43:43 PDT 2021 +distributionBase=GRADLE_USER_HOME +distributionPath=wrapper/dists +zipStoreBase=GRADLE_USER_HOME +zipStorePath=wrapper/dists +distributionUrl=https\://services.gradle.org/distributions/gradle-6.5-bin.zip diff --git a/gradlew b/gradlew new file mode 100644 index 0000000..cccdd3d --- /dev/null +++ b/gradlew @@ -0,0 +1,172 @@ +#!/usr/bin/env sh + +############################################################################## +## +## Gradle start up script for UN*X +## +############################################################################## + +# Attempt to set APP_HOME +# Resolve links: $0 may be a link +PRG="$0" +# Need this for relative symlinks. +while [ -h "$PRG" ] ; do + ls=`ls -ld "$PRG"` + link=`expr "$ls" : '.*-> \(.*\)$'` + if expr "$link" : '/.*' > /dev/null; then + PRG="$link" + else + PRG=`dirname "$PRG"`"/$link" + fi +done +SAVED="`pwd`" +cd "`dirname \"$PRG\"`/" >/dev/null +APP_HOME="`pwd -P`" +cd "$SAVED" >/dev/null + +APP_NAME="Gradle" +APP_BASE_NAME=`basename "$0"` + +# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. +DEFAULT_JVM_OPTS="" + +# Use the maximum available, or set MAX_FD != -1 to use that value. +MAX_FD="maximum" + +warn () { + echo "$*" +} + +die () { + echo + echo "$*" + echo + exit 1 +} + +# OS specific support (must be 'true' or 'false'). +cygwin=false +msys=false +darwin=false +nonstop=false +case "`uname`" in + CYGWIN* ) + cygwin=true + ;; + Darwin* ) + darwin=true + ;; + MINGW* ) + msys=true + ;; + NONSTOP* ) + nonstop=true + ;; +esac + +CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar + +# Determine the Java command to use to start the JVM. +if [ -n "$JAVA_HOME" ] ; then + if [ -x "$JAVA_HOME/jre/sh/java" ] ; then + # IBM's JDK on AIX uses strange locations for the executables + JAVACMD="$JAVA_HOME/jre/sh/java" + else + JAVACMD="$JAVA_HOME/bin/java" + fi + if [ ! -x "$JAVACMD" ] ; then + die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME + +Please set the JAVA_HOME variable in your environment to match the +location of your Java installation." + fi +else + JAVACMD="java" + which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. + +Please set the JAVA_HOME variable in your environment to match the +location of your Java installation." +fi + +# Increase the maximum file descriptors if we can. +if [ "$cygwin" = "false" -a "$darwin" = "false" -a "$nonstop" = "false" ] ; then + MAX_FD_LIMIT=`ulimit -H -n` + if [ $? -eq 0 ] ; then + if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then + MAX_FD="$MAX_FD_LIMIT" + fi + ulimit -n $MAX_FD + if [ $? -ne 0 ] ; then + warn "Could not set maximum file descriptor limit: $MAX_FD" + fi + else + warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT" + fi +fi + +# For Darwin, add options to specify how the application appears in the dock +if $darwin; then + GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\"" +fi + +# For Cygwin, switch paths to Windows format before running java +if $cygwin ; then + APP_HOME=`cygpath --path --mixed "$APP_HOME"` + CLASSPATH=`cygpath --path --mixed "$CLASSPATH"` + JAVACMD=`cygpath --unix "$JAVACMD"` + + # We build the pattern for arguments to be converted via cygpath + ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null` + SEP="" + for dir in $ROOTDIRSRAW ; do + ROOTDIRS="$ROOTDIRS$SEP$dir" + SEP="|" + done + OURCYGPATTERN="(^($ROOTDIRS))" + # Add a user-defined pattern to the cygpath arguments + if [ "$GRADLE_CYGPATTERN" != "" ] ; then + OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)" + fi + # Now convert the arguments - kludge to limit ourselves to /bin/sh + i=0 + for arg in "$@" ; do + CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -` + CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option + + if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition + eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"` + else + eval `echo args$i`="\"$arg\"" + fi + i=$((i+1)) + done + case $i in + (0) set -- ;; + (1) set -- "$args0" ;; + (2) set -- "$args0" "$args1" ;; + (3) set -- "$args0" "$args1" "$args2" ;; + (4) set -- "$args0" "$args1" "$args2" "$args3" ;; + (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;; + (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;; + (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;; + (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;; + (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;; + esac +fi + +# Escape application args +save () { + for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done + echo " " +} +APP_ARGS=$(save "$@") + +# Collect all arguments for the java command, following the shell quoting and substitution rules +eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS" + +# by default we should be in the correct project dir, but when run from Finder on Mac, the cwd is wrong +if [ "$(uname)" = "Darwin" ] && [ "$HOME" = "$PWD" ]; then + cd "$(dirname "$0")" +fi + +exec "$JAVACMD" "$@" diff --git a/gradlew.bat b/gradlew.bat new file mode 100644 index 0000000..f955316 --- /dev/null +++ b/gradlew.bat @@ -0,0 +1,84 @@ +@if "%DEBUG%" == "" @echo off +@rem ########################################################################## +@rem +@rem Gradle startup script for Windows +@rem +@rem ########################################################################## + +@rem Set local scope for the variables with windows NT shell +if "%OS%"=="Windows_NT" setlocal + +set DIRNAME=%~dp0 +if "%DIRNAME%" == "" set DIRNAME=. +set APP_BASE_NAME=%~n0 +set APP_HOME=%DIRNAME% + +@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. +set DEFAULT_JVM_OPTS= + +@rem Find java.exe +if defined JAVA_HOME goto findJavaFromJavaHome + +set JAVA_EXE=java.exe +%JAVA_EXE% -version >NUL 2>&1 +if "%ERRORLEVEL%" == "0" goto init + +echo. +echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. +echo. +echo Please set the JAVA_HOME variable in your environment to match the +echo location of your Java installation. + +goto fail + +:findJavaFromJavaHome +set JAVA_HOME=%JAVA_HOME:"=% +set JAVA_EXE=%JAVA_HOME%/bin/java.exe + +if exist "%JAVA_EXE%" goto init + +echo. +echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% +echo. +echo Please set the JAVA_HOME variable in your environment to match the +echo location of your Java installation. + +goto fail + +:init +@rem Get command-line arguments, handling Windows variants + +if not "%OS%" == "Windows_NT" goto win9xME_args + +:win9xME_args +@rem Slurp the command line arguments. +set CMD_LINE_ARGS= +set _SKIP=2 + +:win9xME_args_slurp +if "x%~1" == "x" goto execute + +set CMD_LINE_ARGS=%* + +:execute +@rem Setup the command line + +set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar + +@rem Execute Gradle +"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS% + +:end +@rem End local scope for the variables with windows NT shell +if "%ERRORLEVEL%"=="0" goto mainEnd + +:fail +rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of +rem the _cmd.exe /c_ return code! +if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1 +exit /b 1 + +:mainEnd +if "%OS%"=="Windows_NT" endlocal + +:omega diff --git a/settings.gradle b/settings.gradle new file mode 100644 index 0000000..2a4225c --- /dev/null +++ b/settings.gradle @@ -0,0 +1,2 @@ +include ':app' +rootProject.name = "Lemonade" \ No newline at end of file