diff --git a/labs/Lab-DevelopmentEnvironment/Lab-DevelopmentEnvironment_AndroidStudio.pdf b/labs/Lab-DevelopmentEnvironment/Lab-DevelopmentEnvironment_AndroidStudio.pdf new file mode 100644 index 0000000000000000000000000000000000000000..70a242c9d901f270d2a9ea0bcc70873cc983c035 Binary files /dev/null and b/labs/Lab-DevelopmentEnvironment/Lab-DevelopmentEnvironment_AndroidStudio.pdf differ diff --git a/labs/Lab-DevelopmentEnvironment/TheAnswer/app/build.gradle b/labs/Lab-DevelopmentEnvironment/TheAnswer/app/build.gradle new file mode 100755 index 0000000000000000000000000000000000000000..21fc73663bd041c9a6f64f7ddb32cdc57d6f8013 --- /dev/null +++ b/labs/Lab-DevelopmentEnvironment/TheAnswer/app/build.gradle @@ -0,0 +1,26 @@ +apply plugin: 'com.android.application' +apply plugin: 'kotlin-android' + +android { + compileSdkVersion 30 + + defaultConfig { + applicationId "course.examples.theanswer" + minSdkVersion 21 + targetSdkVersion 30 + versionCode 1 + versionName "1.0" + } + buildTypes { + release { + minifyEnabled false + proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' + } + } +} +repositories { + mavenCentral() +} +dependencies { + implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version" +} diff --git a/labs/Lab-DevelopmentEnvironment/TheAnswer/app/src/main/AndroidManifest.xml b/labs/Lab-DevelopmentEnvironment/TheAnswer/app/src/main/AndroidManifest.xml new file mode 100755 index 0000000000000000000000000000000000000000..79425dad7b125999aff61f3ba9c682ec0ff507b5 --- /dev/null +++ b/labs/Lab-DevelopmentEnvironment/TheAnswer/app/src/main/AndroidManifest.xml @@ -0,0 +1,21 @@ +<?xml version="1.0" encoding="utf-8"?> +<manifest xmlns:android="http://schemas.android.com/apk/res/android" + package="course.examples.theanswer"> + + <application + android:allowBackup="false" + android:icon="@mipmap/ic_launcher" + android:label="@string/app_name" + android:theme="@style/MaterialTheme" > + <activity + android:name="course.examples.theanswer.TheAnswer" + android:label="@string/app_name" > + <intent-filter> + <action android:name="android.intent.action.MAIN" /> + + <category android:name="android.intent.category.LAUNCHER" /> + </intent-filter> + </activity> + </application> + +</manifest> diff --git a/labs/Lab-DevelopmentEnvironment/TheAnswer/app/src/main/java/course/examples/theanswer/TheAnswer.kt b/labs/Lab-DevelopmentEnvironment/TheAnswer/app/src/main/java/course/examples/theanswer/TheAnswer.kt new file mode 100755 index 0000000000000000000000000000000000000000..a4ac8160b9c01ac78f59becde87fc07db8aab42c --- /dev/null +++ b/labs/Lab-DevelopmentEnvironment/TheAnswer/app/src/main/java/course/examples/theanswer/TheAnswer.kt @@ -0,0 +1,42 @@ +package course.examples.theanswer + +import android.app.Activity +import android.os.Bundle +import android.util.Log +import android.widget.TextView + +class TheAnswer : Activity() { + + companion object { + private val answers = intArrayOf(42, -10, 0, 100, 1000) + private const val answer = 42 + private const val TAG = "TheAnswer" + } + + override fun onCreate(savedInstanceState: Bundle?) { + + // Required call through to Activity.onCreate() + // Restore any saved instance state + super.onCreate(savedInstanceState) + + // Set up the application's user interface (content view) + setContentView(R.layout.answer_layout) + + // Get a reference to a TextView in the content view + val answerView = findViewById<TextView>(R.id.answer_view) + val value = findAnswer() + val output = + if (value == answer) answer.toString() else getString(R.string.never_know_string) + + // Set desired text in answerView TextView + answerView.text = output + } + + private fun findAnswer(): Int? { + Log.d(TAG, "Entering findAnswer()") + // Incorrect behavior + return answers.firstOrNull { it == -answer } + // Correct behavior +// return answers.firstOrNull { it == answer } + } +} \ No newline at end of file diff --git a/labs/Lab-DevelopmentEnvironment/TheAnswer/app/src/main/res/layout/answer_layout.xml b/labs/Lab-DevelopmentEnvironment/TheAnswer/app/src/main/res/layout/answer_layout.xml new file mode 100755 index 0000000000000000000000000000000000000000..ce1d3bb6a7f29a5cb2f5270f8455b9e4a26321cf --- /dev/null +++ b/labs/Lab-DevelopmentEnvironment/TheAnswer/app/src/main/res/layout/answer_layout.xml @@ -0,0 +1,23 @@ +<!--suppress XmlUnusedNamespaceDeclaration --> +<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" + android:layout_width="match_parent" + android:layout_height="match_parent" + android:padding="@dimen/activity_margin"> + + <TextView + android:id="@+id/text_view" + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:layout_alignParentTop="true" + android:layout_centerHorizontal="true" + android:text="@string/question_string" + android:textAppearance="@android:style/TextAppearance.Material.Large" /> + + <TextView + android:id="@+id/answer_view" + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:layout_centerInParent="true" + android:textAppearance="@android:style/TextAppearance.Material.Display3" /> + +</RelativeLayout> \ No newline at end of file diff --git a/labs/Lab-DevelopmentEnvironment/TheAnswer/app/src/main/res/mipmap-hdpi/ic_launcher.png b/labs/Lab-DevelopmentEnvironment/TheAnswer/app/src/main/res/mipmap-hdpi/ic_launcher.png new file mode 100755 index 0000000000000000000000000000000000000000..288b66551d1efd1f13dd06f20a67534d2df57946 Binary files /dev/null and b/labs/Lab-DevelopmentEnvironment/TheAnswer/app/src/main/res/mipmap-hdpi/ic_launcher.png differ diff --git a/labs/Lab-DevelopmentEnvironment/TheAnswer/app/src/main/res/mipmap-mdpi/ic_launcher.png b/labs/Lab-DevelopmentEnvironment/TheAnswer/app/src/main/res/mipmap-mdpi/ic_launcher.png new file mode 100755 index 0000000000000000000000000000000000000000..6ae570b4db4da165fada0650079061cb56aa8793 Binary files /dev/null and b/labs/Lab-DevelopmentEnvironment/TheAnswer/app/src/main/res/mipmap-mdpi/ic_launcher.png differ diff --git a/labs/Lab-DevelopmentEnvironment/TheAnswer/app/src/main/res/mipmap-xhdpi/ic_launcher.png b/labs/Lab-DevelopmentEnvironment/TheAnswer/app/src/main/res/mipmap-xhdpi/ic_launcher.png new file mode 100755 index 0000000000000000000000000000000000000000..d4fb7cd9d868f1d7d9964f1686dcbc018ef9495a Binary files /dev/null and b/labs/Lab-DevelopmentEnvironment/TheAnswer/app/src/main/res/mipmap-xhdpi/ic_launcher.png differ diff --git a/labs/Lab-DevelopmentEnvironment/TheAnswer/app/src/main/res/mipmap-xxhdpi/ic_launcher.png b/labs/Lab-DevelopmentEnvironment/TheAnswer/app/src/main/res/mipmap-xxhdpi/ic_launcher.png new file mode 100755 index 0000000000000000000000000000000000000000..85a6081587e2c2b9793d796ee7b07e12fdf860db Binary files /dev/null and b/labs/Lab-DevelopmentEnvironment/TheAnswer/app/src/main/res/mipmap-xxhdpi/ic_launcher.png differ diff --git a/labs/Lab-DevelopmentEnvironment/TheAnswer/app/src/main/res/values/colors.xml b/labs/Lab-DevelopmentEnvironment/TheAnswer/app/src/main/res/values/colors.xml new file mode 100644 index 0000000000000000000000000000000000000000..057a511a3c15f455b6f444f8dc71c7c97e3bbadc --- /dev/null +++ b/labs/Lab-DevelopmentEnvironment/TheAnswer/app/src/main/res/values/colors.xml @@ -0,0 +1,8 @@ +<?xml version="1.0" encoding="utf-8"?> +<resources> +<color name="primary">#FF5722</color> +<color name="primary_dark">#E64A19</color> + <color name="accent">#FFC107</color> +<color name="primary_text">#ffffff</color> +<color name="secondary_text">#727272</color> +</resources> diff --git a/labs/Lab-DevelopmentEnvironment/TheAnswer/app/src/main/res/values/dimens.xml b/labs/Lab-DevelopmentEnvironment/TheAnswer/app/src/main/res/values/dimens.xml new file mode 100644 index 0000000000000000000000000000000000000000..7009639d734c83ff44d80ca9aa3f7e0030aa32a7 --- /dev/null +++ b/labs/Lab-DevelopmentEnvironment/TheAnswer/app/src/main/res/values/dimens.xml @@ -0,0 +1,5 @@ +<?xml version="1.0" encoding="utf-8"?> +<resources> + <!-- Default screen margins, per the Android Design guidelines. --> + <dimen name="activity_margin">16dp</dimen> +</resources> \ No newline at end of file diff --git a/labs/Lab-DevelopmentEnvironment/TheAnswer/app/src/main/res/values/strings.xml b/labs/Lab-DevelopmentEnvironment/TheAnswer/app/src/main/res/values/strings.xml new file mode 100755 index 0000000000000000000000000000000000000000..715b452e5a0b6ffad36d51f2bef90659ef8fc38a --- /dev/null +++ b/labs/Lab-DevelopmentEnvironment/TheAnswer/app/src/main/res/values/strings.xml @@ -0,0 +1,8 @@ +<?xml version="1.0" encoding="utf-8"?> +<resources> + + <string name="app_name">TheAnswer</string> + <string name="question_string">The answer to life, the universe and everything is:</string> + <string name="never_know_string">We may never know</string> + +</resources> diff --git a/labs/Lab-DevelopmentEnvironment/TheAnswer/app/src/main/res/values/styles.xml b/labs/Lab-DevelopmentEnvironment/TheAnswer/app/src/main/res/values/styles.xml new file mode 100755 index 0000000000000000000000000000000000000000..de46adb1ac48f0cbecd02d17067725a2c2c07e02 --- /dev/null +++ b/labs/Lab-DevelopmentEnvironment/TheAnswer/app/src/main/res/values/styles.xml @@ -0,0 +1,10 @@ +<?xml version="1.0" encoding="utf-8"?> +<resources> + <style name="MaterialTheme" parent="android:Theme.Material.Light"> + <item name="android:colorPrimary">@color/primary</item> + <item name="android:colorPrimaryDark">@color/primary_dark</item> + <item name="android:colorAccent">@color/accent</item> + <item name="android:textColorPrimary">@color/primary_text</item> + <item name="android:textColor">@color/secondary_text</item> + </style> +</resources> \ No newline at end of file diff --git a/labs/Lab-DevelopmentEnvironment/TheAnswer/build.gradle b/labs/Lab-DevelopmentEnvironment/TheAnswer/build.gradle new file mode 100755 index 0000000000000000000000000000000000000000..98fee96066615bfe8785334355432ec771b34933 --- /dev/null +++ b/labs/Lab-DevelopmentEnvironment/TheAnswer/build.gradle @@ -0,0 +1,23 @@ +// Top-level build file where you can add configuration options common to all sub-projects/modules. + +buildscript { + ext.kotlin_version = '1.4.0' + repositories { + jcenter() + google() + } + dependencies { + classpath 'com.android.tools.build:gradle:4.0.1' + 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 { + jcenter() + google() + } +} diff --git a/labs/Lab-DevelopmentEnvironment/TheAnswer/gradle/wrapper/gradle-wrapper.jar b/labs/Lab-DevelopmentEnvironment/TheAnswer/gradle/wrapper/gradle-wrapper.jar new file mode 100755 index 0000000000000000000000000000000000000000..8c0fb64a8698b08ecc4158d828ca593c4928e9dd Binary files /dev/null and b/labs/Lab-DevelopmentEnvironment/TheAnswer/gradle/wrapper/gradle-wrapper.jar differ diff --git a/labs/Lab-DevelopmentEnvironment/TheAnswer/gradle/wrapper/gradle-wrapper.properties b/labs/Lab-DevelopmentEnvironment/TheAnswer/gradle/wrapper/gradle-wrapper.properties new file mode 100755 index 0000000000000000000000000000000000000000..7487b2481fe4b2ee96b682995734217050a2e439 --- /dev/null +++ b/labs/Lab-DevelopmentEnvironment/TheAnswer/gradle/wrapper/gradle-wrapper.properties @@ -0,0 +1,6 @@ +#Mon Aug 24 15:39:15 EDT 2020 +distributionBase=GRADLE_USER_HOME +distributionPath=wrapper/dists +zipStoreBase=GRADLE_USER_HOME +zipStorePath=wrapper/dists +distributionUrl=https\://services.gradle.org/distributions/gradle-6.1.1-all.zip diff --git a/labs/Lab-DevelopmentEnvironment/TheAnswer/gradlew b/labs/Lab-DevelopmentEnvironment/TheAnswer/gradlew new file mode 100755 index 0000000000000000000000000000000000000000..91a7e269e19dfc62e27137a0b57ef3e430cee4fd --- /dev/null +++ b/labs/Lab-DevelopmentEnvironment/TheAnswer/gradlew @@ -0,0 +1,164 @@ +#!/usr/bin/env bash + +############################################################################## +## +## Gradle start up script for UN*X +## +############################################################################## + +# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. +DEFAULT_JVM_OPTS="" + +APP_NAME="Gradle" +APP_BASE_NAME=`basename "$0"` + +# 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 +case "`uname`" in + CYGWIN* ) + cygwin=true + ;; + Darwin* ) + darwin=true + ;; + MINGW* ) + msys=true + ;; +esac + +# For Cygwin, ensure paths are in UNIX format before anything is touched. +if $cygwin ; then + [ -n "$JAVA_HOME" ] && JAVA_HOME=`cygpath --unix "$JAVA_HOME"` +fi + +# 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\"`/" >&- +APP_HOME="`pwd -P`" +cd "$SAVED" >&- + +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" ] ; 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"` + + # 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 + +# Split up the JVM_OPTS And GRADLE_OPTS values into an array, following the shell quoting and substitution rules +function splitJvmOpts() { + JVM_OPTS=("$@") +} +eval splitJvmOpts $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS +JVM_OPTS[${#JVM_OPTS[*]}]="-Dorg.gradle.appname=$APP_BASE_NAME" + +exec "$JAVACMD" "${JVM_OPTS[@]}" -classpath "$CLASSPATH" org.gradle.wrapper.GradleWrapperMain "$@" diff --git a/labs/Lab-DevelopmentEnvironment/TheAnswer/gradlew.bat b/labs/Lab-DevelopmentEnvironment/TheAnswer/gradlew.bat new file mode 100755 index 0000000000000000000000000000000000000000..8a0b282aa6885fb573c106b3551f7275c5f17e8e --- /dev/null +++ b/labs/Lab-DevelopmentEnvironment/TheAnswer/gradlew.bat @@ -0,0 +1,90 @@ +@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 + +@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= + +set DIRNAME=%~dp0 +if "%DIRNAME%" == "" set DIRNAME=. +set APP_BASE_NAME=%~n0 +set APP_HOME=%DIRNAME% + +@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 Windowz variants + +if not "%OS%" == "Windows_NT" goto win9xME_args +if "%@eval[2+2]" == "4" goto 4NT_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=%* +goto execute + +:4NT_args +@rem Get arguments from the 4NT Shell from JP Software +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/labs/Lab-DevelopmentEnvironment/TheAnswer/settings.gradle b/labs/Lab-DevelopmentEnvironment/TheAnswer/settings.gradle new file mode 100755 index 0000000000000000000000000000000000000000..e7b4def49cb53d9aa04228dd3edb14c9e635e003 --- /dev/null +++ b/labs/Lab-DevelopmentEnvironment/TheAnswer/settings.gradle @@ -0,0 +1 @@ +include ':app'