├── DiceRoller ├── app │ ├── .gitignore │ ├── src │ │ └── main │ │ │ ├── res │ │ │ ├── drawable │ │ │ │ ├── dice_1.png │ │ │ │ ├── dice_2.png │ │ │ │ ├── dice_3.png │ │ │ │ ├── dice_4.png │ │ │ │ ├── dice_5.png │ │ │ │ ├── dice_6.png │ │ │ │ └── ic_launcher_background.xml │ │ │ ├── mipmap-hdpi │ │ │ │ ├── ic_launcher.png │ │ │ │ └── ic_launcher_round.png │ │ │ ├── mipmap-mdpi │ │ │ │ ├── ic_launcher.png │ │ │ │ └── ic_launcher_round.png │ │ │ ├── mipmap-xhdpi │ │ │ │ ├── ic_launcher.png │ │ │ │ └── ic_launcher_round.png │ │ │ ├── mipmap-xxhdpi │ │ │ │ ├── ic_launcher.png │ │ │ │ └── ic_launcher_round.png │ │ │ ├── mipmap-xxxhdpi │ │ │ │ ├── ic_launcher.png │ │ │ │ └── ic_launcher_round.png │ │ │ ├── values │ │ │ │ ├── strings.xml │ │ │ │ ├── colors.xml │ │ │ │ └── styles.xml │ │ │ ├── mipmap-anydpi-v26 │ │ │ │ ├── ic_launcher.xml │ │ │ │ └── ic_launcher_round.xml │ │ │ ├── layout │ │ │ │ └── activity_main.xml │ │ │ └── drawable-v24 │ │ │ │ └── ic_launcher_foreground.xml │ │ │ ├── AndroidManifest.xml │ │ │ └── java │ │ │ └── com │ │ │ └── example │ │ │ └── diceroller │ │ │ └── MainActivity.kt │ ├── proguard-rules.pro │ └── build.gradle ├── settings.gradle ├── gradle │ └── wrapper │ │ ├── gradle-wrapper.jar │ │ └── gradle-wrapper.properties ├── build.gradle ├── README.md ├── CONTRIBUTING.md ├── gradle.properties ├── gradlew.bat ├── gradlew └── LICENSE ├── dice_images.zip ├── .github ├── renovate.json └── ISSUE_TEMPLATE │ ├── android-basics-issue.md │ └── android-basics--read-and-update-data-with-room-issue-template.md ├── .gitignore ├── README.md ├── CONTRIBUTING.md └── LICENSE /DiceRoller/app/.gitignore: -------------------------------------------------------------------------------- 1 | /build 2 | -------------------------------------------------------------------------------- /DiceRoller/settings.gradle: -------------------------------------------------------------------------------- 1 | rootProject.name='Dice Roller' 2 | include ':app' 3 | -------------------------------------------------------------------------------- /dice_images.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/google-developer-training/android-basics-kotlin-dice-roller-with-images-app-solution/HEAD/dice_images.zip -------------------------------------------------------------------------------- /.github/renovate.json: -------------------------------------------------------------------------------- 1 | { 2 | "$schema": "https://docs.renovatebot.com/renovate-schema.json", 3 | "extends": [ 4 | "local>android/.github:renovate-config" 5 | ] 6 | } 7 | -------------------------------------------------------------------------------- /DiceRoller/gradle/wrapper/gradle-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/google-developer-training/android-basics-kotlin-dice-roller-with-images-app-solution/HEAD/DiceRoller/gradle/wrapper/gradle-wrapper.jar -------------------------------------------------------------------------------- /DiceRoller/app/src/main/res/drawable/dice_1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/google-developer-training/android-basics-kotlin-dice-roller-with-images-app-solution/HEAD/DiceRoller/app/src/main/res/drawable/dice_1.png -------------------------------------------------------------------------------- /DiceRoller/app/src/main/res/drawable/dice_2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/google-developer-training/android-basics-kotlin-dice-roller-with-images-app-solution/HEAD/DiceRoller/app/src/main/res/drawable/dice_2.png -------------------------------------------------------------------------------- /DiceRoller/app/src/main/res/drawable/dice_3.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/google-developer-training/android-basics-kotlin-dice-roller-with-images-app-solution/HEAD/DiceRoller/app/src/main/res/drawable/dice_3.png -------------------------------------------------------------------------------- /DiceRoller/app/src/main/res/drawable/dice_4.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/google-developer-training/android-basics-kotlin-dice-roller-with-images-app-solution/HEAD/DiceRoller/app/src/main/res/drawable/dice_4.png -------------------------------------------------------------------------------- /DiceRoller/app/src/main/res/drawable/dice_5.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/google-developer-training/android-basics-kotlin-dice-roller-with-images-app-solution/HEAD/DiceRoller/app/src/main/res/drawable/dice_5.png -------------------------------------------------------------------------------- /DiceRoller/app/src/main/res/drawable/dice_6.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/google-developer-training/android-basics-kotlin-dice-roller-with-images-app-solution/HEAD/DiceRoller/app/src/main/res/drawable/dice_6.png -------------------------------------------------------------------------------- /DiceRoller/app/src/main/res/mipmap-hdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/google-developer-training/android-basics-kotlin-dice-roller-with-images-app-solution/HEAD/DiceRoller/app/src/main/res/mipmap-hdpi/ic_launcher.png -------------------------------------------------------------------------------- /DiceRoller/app/src/main/res/mipmap-mdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/google-developer-training/android-basics-kotlin-dice-roller-with-images-app-solution/HEAD/DiceRoller/app/src/main/res/mipmap-mdpi/ic_launcher.png -------------------------------------------------------------------------------- /DiceRoller/app/src/main/res/mipmap-xhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/google-developer-training/android-basics-kotlin-dice-roller-with-images-app-solution/HEAD/DiceRoller/app/src/main/res/mipmap-xhdpi/ic_launcher.png -------------------------------------------------------------------------------- /DiceRoller/app/src/main/res/mipmap-xxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/google-developer-training/android-basics-kotlin-dice-roller-with-images-app-solution/HEAD/DiceRoller/app/src/main/res/mipmap-xxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /DiceRoller/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/google-developer-training/android-basics-kotlin-dice-roller-with-images-app-solution/HEAD/DiceRoller/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /DiceRoller/app/src/main/res/mipmap-hdpi/ic_launcher_round.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/google-developer-training/android-basics-kotlin-dice-roller-with-images-app-solution/HEAD/DiceRoller/app/src/main/res/mipmap-hdpi/ic_launcher_round.png -------------------------------------------------------------------------------- /DiceRoller/app/src/main/res/mipmap-mdpi/ic_launcher_round.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/google-developer-training/android-basics-kotlin-dice-roller-with-images-app-solution/HEAD/DiceRoller/app/src/main/res/mipmap-mdpi/ic_launcher_round.png -------------------------------------------------------------------------------- /DiceRoller/app/src/main/res/mipmap-xhdpi/ic_launcher_round.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/google-developer-training/android-basics-kotlin-dice-roller-with-images-app-solution/HEAD/DiceRoller/app/src/main/res/mipmap-xhdpi/ic_launcher_round.png -------------------------------------------------------------------------------- /DiceRoller/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/google-developer-training/android-basics-kotlin-dice-roller-with-images-app-solution/HEAD/DiceRoller/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png -------------------------------------------------------------------------------- /DiceRoller/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/google-developer-training/android-basics-kotlin-dice-roller-with-images-app-solution/HEAD/DiceRoller/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png -------------------------------------------------------------------------------- /DiceRoller/gradle/wrapper/gradle-wrapper.properties: -------------------------------------------------------------------------------- 1 | #Wed Nov 11 16:08:41 PST 2020 2 | distributionBase=GRADLE_USER_HOME 3 | distributionPath=wrapper/dists 4 | zipStoreBase=GRADLE_USER_HOME 5 | zipStorePath=wrapper/dists 6 | distributionUrl=https\://services.gradle.org/distributions/gradle-7.4.2-bin.zip 7 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/android-basics-issue.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: Android Basics issue 3 | about: Report problems with the Android Basics codelabs 4 | title: 'Android Basics issue:' 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 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | 2 | */.gitignore 3 | .gradle 4 | .DS_Store 5 | 6 | # built application files 7 | *.apk 8 | *.ap_ 9 | 10 | # files for the dex VM 11 | *.dex 12 | 13 | # Java class files 14 | *.class 15 | 16 | # generated files 17 | bin/ 18 | out/ 19 | gen/ 20 | 21 | # Libraries used by the app 22 | # Can explicitly add if we want, but shouldn't do so blindly. Licenses, bloat, etc. 23 | /libs 24 | 25 | 26 | # Build stuff (auto-generated by android update project ...) 27 | build.xml 28 | ant.properties 29 | local.properties 30 | project.properties 31 | 32 | # Eclipse project files 33 | .classpath 34 | .project 35 | 36 | # idea project files 37 | .idea/ 38 | .idea/.name 39 | *.iml 40 | *.ipr 41 | *.iws 42 | 43 | ##Gradle-based build 44 | .gradle 45 | build/ 46 | -------------------------------------------------------------------------------- /DiceRoller/build.gradle: -------------------------------------------------------------------------------- 1 | // Top-level build file where you can add configuration options common to all sub-projects/modules. 2 | 3 | buildscript { 4 | ext.kotlin_version = '1.6.20' 5 | repositories { 6 | google() 7 | mavenCentral() 8 | } 9 | dependencies { 10 | classpath 'com.android.tools.build:gradle:7.1.2' 11 | classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version" 12 | 13 | // NOTE: Do not place your application dependencies here; they belong 14 | // in the individual module build.gradle files 15 | } 16 | } 17 | 18 | allprojects { 19 | repositories { 20 | google() 21 | mavenCentral() 22 | } 23 | } 24 | 25 | task clean(type: Delete) { 26 | delete rootProject.buildDir 27 | } 28 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/android-basics--read-and-update-data-with-room-issue-template.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: 'Android Basics: Read and update data with Room issue template' 3 | about: Report problems with the Android Basics codelabs 4 | title: 'Android Basics: Read and update data with Room' 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 | -------------------------------------------------------------------------------- /DiceRoller/README.md: -------------------------------------------------------------------------------- 1 | 2 | Dice Roller App 3 | ======================= 4 | 5 | Sample app that randomly rolls a dice and updates the dice image on screen. 6 | Used in the Android Basics with Kotlin course. 7 | 8 | Pre-requisites 9 | -------------- 10 | 11 | - Android SDK 29 12 | - Android Build Tools v29.0.3 13 | - Android Support Repository 14 | 15 | Getting Started 16 | --------------- 17 | 18 | This sample uses the Gradle build system. To build this project, use the 19 | "gradlew build" command or use "Import Project" in Android Studio. 20 | 21 | Support 22 | ------- 23 | 24 | - Stack Overflow: http://stackoverflow.com/questions/tagged/android 25 | 26 | Patches are encouraged, and may be submitted by forking this project and 27 | submitting a pull request through GitHub. Please see CONTRIBUTING.md for more details. -------------------------------------------------------------------------------- /DiceRoller/app/src/main/res/values/strings.xml: -------------------------------------------------------------------------------- 1 | 15 | 16 | Dice Roller 17 | Roll 18 | 19 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | Add more conditional behavior in Kotlin - Solution Code 2 | ======================================= 3 | 4 | Solution code for the Android Basics in Kotlin: Add more conditional behavior in Kotlin codelab. 5 | 6 | Introduction 7 | ------------ 8 | In this codelab, you add images to the Dice Roller app, which enhance the user experience. 9 | 10 | Pre-requisites 11 | -------------- 12 | 13 | You need to know: 14 | - Completed the Create a Dice Roller Android App with Button codelab. 15 | - Able to write control flow statements (if / else, when statements). 16 | - Able to update the UI of the app based on user input (modifying the MainActivity.kt file). 17 | - Able to add a click listener to a Button. 18 | - Able to add image resources to an Android app. 19 | 20 | 21 | Getting Started 22 | --------------- 23 | 24 | 1. Download and run the app. 25 | -------------------------------------------------------------------------------- /DiceRoller/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 22 | -------------------------------------------------------------------------------- /DiceRoller/app/src/main/res/values/colors.xml: -------------------------------------------------------------------------------- 1 | 2 | 16 | 17 | #6200EE 18 | #3700B3 19 | #03DAC5 20 | 21 | -------------------------------------------------------------------------------- /DiceRoller/app/src/main/res/mipmap-anydpi-v26/ic_launcher.xml: -------------------------------------------------------------------------------- 1 | 2 | 16 | 17 | 18 | 19 | -------------------------------------------------------------------------------- /DiceRoller/app/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml: -------------------------------------------------------------------------------- 1 | 2 | 16 | 17 | 18 | 19 | -------------------------------------------------------------------------------- /DiceRoller/app/src/main/res/values/styles.xml: -------------------------------------------------------------------------------- 1 | 15 | 16 | 17 | 18 | 24 | 25 | 26 | -------------------------------------------------------------------------------- /DiceRoller/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/). -------------------------------------------------------------------------------- /DiceRoller/app/build.gradle: -------------------------------------------------------------------------------- 1 | apply plugin: 'com.android.application' 2 | apply plugin: 'kotlin-android' 3 | 4 | android { 5 | compileSdkVersion 32 6 | 7 | defaultConfig { 8 | applicationId "com.example.diceroller" 9 | minSdkVersion 19 10 | targetSdkVersion 32 11 | versionCode 1 12 | versionName "1.0" 13 | 14 | testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" 15 | } 16 | 17 | buildTypes { 18 | release { 19 | minifyEnabled false 20 | proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro' 21 | } 22 | } 23 | 24 | compileOptions { 25 | sourceCompatibility JavaVersion.VERSION_1_8 26 | targetCompatibility JavaVersion.VERSION_1_8 27 | } 28 | } 29 | 30 | dependencies { 31 | implementation fileTree(dir: 'libs', include: ['*.jar']) 32 | implementation 'androidx.appcompat:appcompat:1.4.1' 33 | implementation 'androidx.constraintlayout:constraintlayout:2.1.3' 34 | testImplementation 'junit:junit:4.13.2' 35 | androidTestImplementation 'androidx.test.ext:junit:1.1.3' 36 | androidTestImplementation 'androidx.test.espresso:espresso-core:3.4.0' 37 | } 38 | -------------------------------------------------------------------------------- /DiceRoller/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=-Xmx1536m 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 | # Automatically convert third-party libraries to use AndroidX 19 | android.enableJetifier=true 20 | # Kotlin code style for this project: "official" or "obsolete": 21 | kotlin.code.style=official 22 | -------------------------------------------------------------------------------- /DiceRoller/app/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 2 | 16 | 18 | 19 | 26 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | -------------------------------------------------------------------------------- /CONTRIBUTING.md: -------------------------------------------------------------------------------- 1 | # How to become a contributor and submit your own code 2 | 3 | ## Contributor License Agreements 4 | 5 | We'd love to accept your sample apps and patches! Before we can take them, we 6 | have to jump a couple of legal hurdles. 7 | 8 | Please fill out either the individual or corporate Contributor License Agreement 9 | (CLA). 10 | 11 | * If you are an individual writing original source code and you're sure you 12 | own the intellectual property, then you'll need to sign an [individual CLA] 13 | (https://developers.google.com/open-source/cla/individual). 14 | * If you work for a company that wants to allow you to contribute your work, 15 | then you'll need to sign a [corporate CLA] 16 | (https://developers.google.com/open-source/cla/corporate). 17 | 18 | Follow either of the two links above to access the appropriate CLA and 19 | instructions for how to sign and return it. Once we receive it, we'll be able to 20 | accept your pull requests. 21 | 22 | ## Contributing A Patch 23 | 24 | 1. Submit an issue describing your proposed change to the repo in question. 25 | 1. The repo owner will respond to your issue promptly. 26 | 1. If your proposed change is accepted, and you haven't already done so, sign a 27 | Contributor License Agreement (see details above). 28 | 1. Fork the desired repo, develop and test your code changes. 29 | 1. Ensure that your code adheres to the existing style in the sample to which 30 | you are contributing. Refer to the 31 | [Google Cloud Platform Samples Style Guide] 32 | (https://github.com/GoogleCloudPlatform/Template/wiki/style.html) for the 33 | recommended coding standards for this organization. 34 | 1. Ensure that your code has an appropriate set of unit tests which all pass. 35 | 1. Submit a pull request. 36 | 37 | -------------------------------------------------------------------------------- /DiceRoller/app/src/main/res/layout/activity_main.xml: -------------------------------------------------------------------------------- 1 | 2 | 16 | 17 | 24 | 25 |