├── app ├── .gitignore ├── src │ ├── main │ │ ├── ic_launcher-playstore.png │ │ ├── res │ │ │ ├── mipmap-anydpi-v26 │ │ │ │ ├── ic_launcher.xml │ │ │ │ └── ic_launcher_round.xml │ │ │ ├── drawable │ │ │ │ ├── ic_launcher_background.xml │ │ │ │ ├── ic_add_24.xml │ │ │ │ ├── ic_notes_24.xml │ │ │ │ ├── ic_edit_24.xml │ │ │ │ ├── ic_location_24.xml │ │ │ │ ├── ic_calendar_24.xml │ │ │ │ └── ic_launcher_foreground.xml │ │ │ ├── menu │ │ │ │ └── menu_main.xml │ │ │ ├── values │ │ │ │ ├── dimens.xml │ │ │ │ ├── colors.xml │ │ │ │ ├── strings.xml │ │ │ │ └── themes.xml │ │ │ ├── values-night │ │ │ │ └── themes.xml │ │ │ ├── layout │ │ │ │ ├── content_main.xml │ │ │ │ ├── activity_main.xml │ │ │ │ ├── fragment_forageable_list.xml │ │ │ │ ├── list_item_forageable.xml │ │ │ │ ├── fragment_add_forageable.xml │ │ │ │ └── fragment_forageable_detail.xml │ │ │ └── navigation │ │ │ │ └── nav_graph.xml │ │ ├── java │ │ │ └── com │ │ │ │ └── example │ │ │ │ └── forage │ │ │ │ ├── BaseApplication.kt │ │ │ │ ├── data │ │ │ │ ├── ForageDatabase.kt │ │ │ │ └── ForageableDao.kt │ │ │ │ ├── model │ │ │ │ └── Forageable.kt │ │ │ │ ├── ui │ │ │ │ ├── adapter │ │ │ │ │ └── ForageableListAdapter.kt │ │ │ │ ├── viewmodel │ │ │ │ │ └── ForageableViewModel.kt │ │ │ │ ├── ForageableListFragment.kt │ │ │ │ ├── ForageableDetailFragment.kt │ │ │ │ └── AddForageableFragment.kt │ │ │ │ └── MainActivity.kt │ │ └── AndroidManifest.xml │ └── androidTest │ │ └── java │ │ └── com │ │ └── example │ │ └── forage │ │ └── PersistenceInstrumentationTests.kt ├── proguard-rules.pro └── build.gradle ├── settings.gradle ├── gradle └── wrapper │ ├── gradle-wrapper.jar │ └── gradle-wrapper.properties ├── .gitignore ├── .github └── ISSUE_TEMPLATE ├── gradle.properties ├── CONTRIBUTING.md ├── README.md ├── gradlew.bat ├── code-of-conduct.md ├── gradlew └── LICENSE /app/.gitignore: -------------------------------------------------------------------------------- 1 | /build -------------------------------------------------------------------------------- /settings.gradle: -------------------------------------------------------------------------------- 1 | rootProject.name = "Forage" 2 | include ':app' 3 | -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/google-developer-training/android-basics-kotlin-forage-app/HEAD/gradle/wrapper/gradle-wrapper.jar -------------------------------------------------------------------------------- /app/src/main/ic_launcher-playstore.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/google-developer-training/android-basics-kotlin-forage-app/HEAD/app/src/main/ic_launcher-playstore.png -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.properties: -------------------------------------------------------------------------------- 1 | #Mon Aug 09 14:37:25 PDT 2021 2 | distributionBase=GRADLE_USER_HOME 3 | distributionUrl=https\://services.gradle.org/distributions/gradle-6.7.1-bin.zip 4 | distributionPath=wrapper/dists 5 | zipStorePath=wrapper/dists 6 | zipStoreBase=GRADLE_USER_HOME 7 | -------------------------------------------------------------------------------- /app/src/main/res/mipmap-anydpi-v26/ic_launcher.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | -------------------------------------------------------------------------------- /app/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/ic_launcher_background.xml: -------------------------------------------------------------------------------- 1 | 6 | 9 | 10 | -------------------------------------------------------------------------------- /app/src/main/res/menu/menu_main.xml: -------------------------------------------------------------------------------- 1 | 5 | 10 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # built application files 2 | *.apk 3 | *.ap_ 4 | # Mac files 5 | .DS_Store 6 | # files for the dex VM 7 | *.dex 8 | # Java class files 9 | *.class 10 | # generated files 11 | bin/ 12 | gen/ 13 | # Ignore gradle files 14 | .gradle/ 15 | build/ 16 | # Local configuration file (sdk path, etc) 17 | local.properties 18 | # Proguard folder generated by Eclipse 19 | proguard/ 20 | proguard-project.txt 21 | # Eclipse files 22 | .project 23 | .classpath 24 | .settings/ 25 | # Android Studio/IDEA 26 | *.iml 27 | .idea 28 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE: -------------------------------------------------------------------------------- 1 | --- 2 | name: 'Android Basics: Forage app' 3 | about: Describe this issue template's purpose here. 4 | title: 'Android Basics: Forage app' 5 | labels: '' 6 | assignees: '' 7 | 8 | --- 9 | 10 | **URL of codelab** 11 | 12 | 13 | **In which task and step of the codelab can this issue be found?** 14 | 15 | 16 | **Describe the problem** 17 | 18 | 19 | 20 | 21 | **Steps to reproduce?** 22 | 1. Go to... 23 | 2. Click on... 24 | 3. See error... 25 | 26 | **Versions** 27 | _Android Studio version:_ 28 | _API version of the emulator:_ 29 | 30 | 31 | **Additional information** 32 | _Include screenshots if they would be useful in clarifying the problem._ 33 | -------------------------------------------------------------------------------- /app/src/main/res/values/dimens.xml: -------------------------------------------------------------------------------- 1 | 16 | 17 | 16dp 18 | 19 | -------------------------------------------------------------------------------- /app/proguard-rules.pro: -------------------------------------------------------------------------------- 1 | # Add project specific ProGuard rules here. 2 | # You can control the set of applied configuration files using the 3 | # proguardFiles setting in build.gradle. 4 | # 5 | # For more details, see 6 | # http://developer.android.com/guide/developing/tools/proguard.html 7 | 8 | # If your project uses WebView with JS, uncomment the following 9 | # and specify the fully qualified class name to the JavaScript interface 10 | # class: 11 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview { 12 | # public *; 13 | #} 14 | 15 | # Uncomment this to preserve the line number information for 16 | # debugging stack traces. 17 | #-keepattributes SourceFile,LineNumberTable 18 | 19 | # If you keep the line number information, uncomment this to 20 | # hide the original source file name. 21 | #-renamesourcefileattribute SourceFile -------------------------------------------------------------------------------- /app/src/main/res/drawable/ic_add_24.xml: -------------------------------------------------------------------------------- 1 | 16 | 19 | 20 | 21 | -------------------------------------------------------------------------------- /app/src/main/java/com/example/forage/BaseApplication.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2021 The Android Open Source Project. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.example.forage 17 | 18 | import android.app.Application 19 | import com.example.forage.data.ForageDatabase 20 | 21 | /** 22 | * An application class that inherits from [Application], allows for the creation of a singleton 23 | * instance of the [ForageDatabase] 24 | */ 25 | class BaseApplication : Application() { 26 | 27 | // TODO: provide a ForageDatabase value by lazy here 28 | } -------------------------------------------------------------------------------- /app/src/main/java/com/example/forage/data/ForageDatabase.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2021 The Android Open Source Project. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.example.forage.data 17 | 18 | import androidx.room.RoomDatabase 19 | import com.example.forage.model.Forageable 20 | 21 | /** 22 | * Room database to persist data for the Forage app. 23 | * This database stores a [Forageable] entity 24 | */ 25 | // TODO: create the database with all necessary annotations, methods, variables, etc. 26 | abstract class ForageDatabase : RoomDatabase() 27 | -------------------------------------------------------------------------------- /app/src/main/res/values/colors.xml: -------------------------------------------------------------------------------- 1 | 2 | 17 | 18 | #FFBB86FC 19 | #FF6200EE 20 | #FF3700B3 21 | #FF03DAC5 22 | #FF018786 23 | #FF000000 24 | #FFFFFFFF 25 | 26 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/ic_notes_24.xml: -------------------------------------------------------------------------------- 1 | 16 | 22 | 25 | 26 | -------------------------------------------------------------------------------- /gradle.properties: -------------------------------------------------------------------------------- 1 | # Project-wide Gradle settings. 2 | # IDE (e.g. Android Studio) users: 3 | # Gradle settings configured through the IDE *will override* 4 | # any settings specified in this file. 5 | # For more details on how to configure your build environment visit 6 | # http://www.gradle.org/docs/current/userguide/build_environment.html 7 | # Specifies the JVM arguments used for the daemon process. 8 | # The setting is particularly useful for tweaking memory settings. 9 | org.gradle.jvmargs=-Xmx2048m -Dfile.encoding=UTF-8 10 | # When configured, Gradle will run in incubating parallel mode. 11 | # This option should only be used with decoupled projects. More details, visit 12 | # http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects 13 | # org.gradle.parallel=true 14 | # AndroidX package structure to make it clearer which packages are bundled with the 15 | # Android operating system, and which are packaged with your app"s APK 16 | # https://developer.android.com/topic/libraries/support-library/androidx-rn 17 | android.useAndroidX=true 18 | # Kotlin code style for this project: "official" or "obsolete": 19 | kotlin.code.style=official -------------------------------------------------------------------------------- /app/src/main/res/drawable/ic_edit_24.xml: -------------------------------------------------------------------------------- 1 | 16 | 19 | 20 | 21 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/ic_location_24.xml: -------------------------------------------------------------------------------- 1 | 16 | 19 | 20 | 21 | -------------------------------------------------------------------------------- /CONTRIBUTING.md: -------------------------------------------------------------------------------- 1 | # How to Contribute 2 | 3 | We'd love to accept your patches and contributions to this project. There are 4 | just a few small guidelines you need to follow. 5 | 6 | ## Contributor License Agreement 7 | 8 | Contributions to this project must be accompanied by a Contributor License 9 | Agreement (CLA). You (or your employer) retain the copyright to your 10 | contribution; this simply gives us permission to use and redistribute your 11 | contributions as part of the project. Head over to 12 | to see your current agreements on file or 13 | to sign a new one. 14 | 15 | You generally only need to submit a CLA once, so if you've already submitted one 16 | (even if it was for a different project), you probably don't need to do it 17 | again. 18 | 19 | ## Code reviews 20 | 21 | All submissions, including submissions by project members, require review. We 22 | use GitHub pull requests for this purpose. Consult 23 | [GitHub Help](https://help.github.com/articles/about-pull-requests/) for more 24 | information on using pull requests. 25 | 26 | ## Community Guidelines 27 | 28 | This project follows 29 | [Google's Open Source Community Guidelines](https://opensource.google/conduct/). 30 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/ic_calendar_24.xml: -------------------------------------------------------------------------------- 1 | 16 | 19 | 20 | 21 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | Forage - Starter Code 2 | ================================== 3 | 4 | Starter code for the fifth independent project for Android Basics in Kotlin. This project pairs 5 | with Unit 5 of Android Basics in Kotlin 6 | 7 | Introduction 8 | ------------ 9 | 10 | This is the starter code for the Forage app project. This project is an opportunity for you to 11 | demonstrate the concepts you learned in Unit 5 of Android Basics in Kotlin. 12 | 13 | Pre-requisites 14 | -------------- 15 | 16 | - Complete Unit 1 of Android Basics in Kotlin 17 | - Complete Project 1: Lemonade App 18 | - Complete Unit 2 of Android Basics in Kotlin 19 | - Complete Project 2: Dogglers 20 | - Complete Unit 3 of Android Basics in Kotlin 21 | - Complete Project 3: Lunch Tray 22 | - Complete Unit 4 of Android Basics in Kotlin 23 | - Complete Project 4: Amphibians 24 | - Complete Unit 5 of Android Basics in Kotlin 25 | 26 | Getting Started 27 | --------------- 28 | 29 | 1. Download the starter code 30 | 2. Open the project in Android Studio 31 | 3. Complete the project in accordance with the app requirements 32 | 33 | 34 | Tasks 35 | --------------- 36 | 37 | Tips 38 | ---- 39 | 40 | - Use the provided tests to ensure your app is running as expected 41 | - DO NOT ALTER THE PROVIDED TESTS 42 | -------------------------------------------------------------------------------- /app/src/main/java/com/example/forage/model/Forageable.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2021 The Android Open Source Project. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.example.forage.model 17 | 18 | /** 19 | * Forageable entity to be stored in the forageable_database. 20 | */ 21 | // TODO: annotate this data class as an entity with a parameter for the table name 22 | data class Forageable( 23 | // TODO: declare the id to be an autogenerated primary key 24 | val id: Long = 0, 25 | val name: String, 26 | val address: String, 27 | // TODO: make a custom column name for the inSeason variable that follows SQL column name 28 | // conventions (the column name should be in_season) 29 | val inSeason: Boolean, 30 | val notes: String? 31 | ) 32 | -------------------------------------------------------------------------------- /app/src/main/java/com/example/forage/data/ForageableDao.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2021 The Android Open Source Project. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.example.forage.data 17 | 18 | import androidx.room.Dao 19 | 20 | /** 21 | * Data Access Object for database interaction. 22 | */ 23 | @Dao 24 | interface ForageableDao { 25 | 26 | // TODO: implement a method to retrieve all Forageables from the database 27 | 28 | // TODO: implement a method to retrieve a Forageable from the database by id 29 | 30 | // TODO: implement a method to insert a Forageable into the database 31 | // (use OnConflictStrategy.REPLACE) 32 | 33 | // TODO: implement a method to update a Forageable that is already in the database 34 | 35 | // TODO: implement a method to delete a Forageable from the database. 36 | } 37 | -------------------------------------------------------------------------------- /app/src/main/res/values/strings.xml: -------------------------------------------------------------------------------- 1 | 16 | 17 | Forage 18 | Settings 19 | 20 | List Fragment 21 | Add Fragment 22 | 23 | Name 24 | Location 25 | Currently in season 26 | Currently out of season 27 | Notes 28 | Save 29 | Delete 30 | 31 | -------------------------------------------------------------------------------- /app/src/main/res/values-night/themes.xml: -------------------------------------------------------------------------------- 1 | 16 | 17 | 18 | 31 | 32 | -------------------------------------------------------------------------------- /app/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 2 | 17 | 19 | 20 | 28 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | -------------------------------------------------------------------------------- /app/src/main/res/layout/content_main.xml: -------------------------------------------------------------------------------- 1 | 2 | 17 | 23 | 24 | 35 | 36 | -------------------------------------------------------------------------------- /app/src/main/res/layout/activity_main.xml: -------------------------------------------------------------------------------- 1 | 2 | 17 | 24 | 25 | 29 | 30 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | -------------------------------------------------------------------------------- /app/src/main/res/values/themes.xml: -------------------------------------------------------------------------------- 1 | 16 | 17 | 18 | 31 | 32 | 36 | 37 |