diff --git a/Labs/Lab2_Activity/.gitignore b/Labs/Lab2_Activity/.gitignore new file mode 100644 index 0000000000000000000000000000000000000000..ceff37eff0e621e8f96607f26a6bced4727fb5a5 --- /dev/null +++ b/Labs/Lab2_Activity/.gitignore @@ -0,0 +1,39 @@ +# built application files +*.apk +*.ap_ + +# files for the dex VM +*.dex + +# Java class files +*.class + +# generated files +bin/ +gen/ + +# Local configuration file (sdk path, etc) +local.properties + +# Eclipse project files +.classpath +.settings + +# Proguard folder generated by Eclipse +proguard/ + +# Intellij project files +*.iml +*.ipr +*.iws +.idea +.idea/workspace.xml +.gradle +build/ +captures/ + +# Mac files +.DS_Store + +# Windows thumbnail db +Thumbs.db diff --git a/Labs/Lab2_Activity/ActivityLab.mp4 b/Labs/Lab2_Activity/ActivityLab.mp4 new file mode 100644 index 0000000000000000000000000000000000000000..4242159377d7a699ed6cd2c62c8c6992b4453aad Binary files /dev/null and b/Labs/Lab2_Activity/ActivityLab.mp4 differ diff --git a/Labs/Lab2_Activity/ActivityLifecycleWalkthrough.pdf b/Labs/Lab2_Activity/ActivityLifecycleWalkthrough.pdf new file mode 100644 index 0000000000000000000000000000000000000000..caf06819035e5d1e566c9faeaa4dbbaacb94bc3e Binary files /dev/null and b/Labs/Lab2_Activity/ActivityLifecycleWalkthrough.pdf differ diff --git a/Labs/Lab2_Activity/ActivityNoReconfig.mp4 b/Labs/Lab2_Activity/ActivityNoReconfig.mp4 new file mode 100644 index 0000000000000000000000000000000000000000..30fb2f900d6515e0e5e1c429377636d5dc4d9677 Binary files /dev/null and b/Labs/Lab2_Activity/ActivityNoReconfig.mp4 differ diff --git a/Labs/Lab2_Activity/ActivityReconfig.mp4 b/Labs/Lab2_Activity/ActivityReconfig.mp4 new file mode 100644 index 0000000000000000000000000000000000000000..6f7faccf9504f9f72eb0855587e49d14c37f4d8f Binary files /dev/null and b/Labs/Lab2_Activity/ActivityReconfig.mp4 differ diff --git a/Labs/Lab2_Activity/Lab-Activity.pdf b/Labs/Lab2_Activity/Lab-Activity.pdf new file mode 100644 index 0000000000000000000000000000000000000000..a805ea092760ccdf287a4c14bb83ed0c0286d0bb Binary files /dev/null and b/Labs/Lab2_Activity/Lab-Activity.pdf differ diff --git a/Labs/Lab2_Activity/app/build.gradle b/Labs/Lab2_Activity/app/build.gradle new file mode 100644 index 0000000000000000000000000000000000000000..6b15214ec2542666a5a3284910a9b604535adea9 --- /dev/null +++ b/Labs/Lab2_Activity/app/build.gradle @@ -0,0 +1,33 @@ +apply plugin: 'com.android.application' +apply plugin: 'kotlin-android' +apply plugin: 'kotlin-android-extensions' + +android { + compileSdkVersion 26 + buildToolsVersion '29.0.3' + + defaultConfig { + applicationId "course.labs.activitylab" + minSdkVersion 21 + targetSdkVersion 26 + + testApplicationId "course.labs.activitylab.tests" + testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner" + } + + buildTypes { + release { + minifyEnabled false + proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt' + } + } +} + +dependencies { + androidTestImplementation 'com.android.support.test:rules:1.0.2' + androidTestImplementation 'com.jayway.android.robotium:robotium-solo:5.6.0' + implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version" +} +repositories { + mavenCentral() +} diff --git a/Labs/Lab2_Activity/app/src/androidTest/java/course/labs/activitylab/tests/Test1_StartActivityOneTest.kt b/Labs/Lab2_Activity/app/src/androidTest/java/course/labs/activitylab/tests/Test1_StartActivityOneTest.kt new file mode 100644 index 0000000000000000000000000000000000000000..4b19f596d415a7a74cdd8c03e81e8228d4ae4824 --- /dev/null +++ b/Labs/Lab2_Activity/app/src/androidTest/java/course/labs/activitylab/tests/Test1_StartActivityOneTest.kt @@ -0,0 +1,56 @@ +package course.labs.activitylab.tests + +import android.test.ActivityInstrumentationTestCase2 + +import android.support.test.rule.ActivityTestRule + +import com.robotium.solo.Solo + +import course.labs.activitylab.ActivityOne + +import junit.framework.Assert; + + +class Test1_StartActivityOneTest : ActivityInstrumentationTestCase2<ActivityOne>(ActivityOne::class.java) { + + private var solo: Solo? = null + + @Throws(Exception::class) + public override fun setUp() { + solo = Solo(instrumentation, activity) + } + + @Throws(Exception::class) + override fun tearDown() { + solo!!.finishOpenedActivities() + } + + // Execution of StartActivityOneTest + fun testRun() { + + // ==================== Section One ===================== + // Wait for activity: 'course.labs.activitylab.ActivityOne' + val timeout = 20000 + Assert.assertTrue("StartActivityOneTest failed: " + "Section One:" + + "ActivityOne did not correctly load", solo!!.waitForActivity( + course.labs.activitylab.ActivityOne::class.java, timeout)) + + + // ==================== Section Two ===================== + // Check for proper counts + Assert.assertTrue("StartActivityOneTest failed:" + "Section Two:" + + "onCreate() count was off for ActivityOne", + solo!!.waitForText("onCreate\\(\\) calls: 1")) + Assert.assertTrue("StartActivityOneTest failed:" + "Section Two:" + + "onStart() count was off for ActivityOne", + solo!!.waitForText("onStart\\(\\) calls: 1")) + Assert.assertTrue("StartActivityOneTest failed:" + "Section Two:" + + "onResume() count was off for ActivityOne", + solo!!.waitForText("onResume\\(\\) calls: 1")) + Assert.assertTrue("StartActivityOneTest failed:" + "Section Two:" + + "onRestart() count was off for ActivityOne", + solo!!.waitForText("onRestart\\(\\) calls: 0")) + + } + +} diff --git a/Labs/Lab2_Activity/app/src/androidTest/java/course/labs/activitylab/tests/Test2_DoubleRotateActivityOneTest.kt b/Labs/Lab2_Activity/app/src/androidTest/java/course/labs/activitylab/tests/Test2_DoubleRotateActivityOneTest.kt new file mode 100644 index 0000000000000000000000000000000000000000..bae8440a2637900e70ddccd0f5a643890a66ae9b --- /dev/null +++ b/Labs/Lab2_Activity/app/src/androidTest/java/course/labs/activitylab/tests/Test2_DoubleRotateActivityOneTest.kt @@ -0,0 +1,83 @@ +package course.labs.activitylab.tests + +import android.test.ActivityInstrumentationTestCase2 + +import com.robotium.solo.Solo + +import course.labs.activitylab.ActivityOne + +import junit.framework.Assert; + + +class Test2_DoubleRotateActivityOneTest : ActivityInstrumentationTestCase2<ActivityOne>(ActivityOne::class.java) { + + private var solo: Solo? = null + + @Throws(Exception::class) + public override fun setUp() { + solo = Solo(instrumentation, activity) + } + + @Throws(Exception::class) + override fun tearDown() { + solo!!.finishOpenedActivities() + } + + fun testRun() { + // ==================== Section One ===================== + // Wait for activity: 'course.labs.activitylab.ActivityOne' + val timeout = 20000 + Assert.assertTrue("DoubleRotateActivityOneTest failed: " + + "Section One:" + + "ActivityOne did not correctly load", + solo!!.waitForActivity(course.labs.activitylab.ActivityOne::class.java, timeout)) + + + val sleep = 1000 + solo!!.sleep(sleep) + + // ==================== Section Two ===================== + // Rotate the screen + solo!!.setActivityOrientation(Solo.LANDSCAPE) + + // Wait for activity: 'course.labs.activitylab.ActivityOne' + Assert.assertTrue("DoubleRotateActivityOneTest failed:" + + "Section Two:" + + "ActivityOne did not correctly load after first LANDSCAPE rotation.", + solo!!.waitForActivity(course.labs.activitylab.ActivityOne::class.java, timeout)) + + + solo!!.sleep(sleep) + + // ==================== Section Three ===================== + // Rotate the screen + solo!!.setActivityOrientation(Solo.PORTRAIT) + + // Wait for activity: 'course.labs.activitylab.ActivityOne' + Assert.assertTrue("DoubleRotateActivityOneTest failed:" + + "Section Three:" + + "ActivityOne did not correctly load after second PORTRAIT rotation.", + solo!!.waitForActivity(course.labs.activitylab.ActivityOne::class.java, timeout)) + + solo!!.sleep(sleep) + + // Check for proper counts + Assert.assertTrue("DoubleRotateActivityOneTest failed:" + + "Section Three:" + + "onCreate() count was off for ActivityOne after second PORTRAIT rotation.", + solo!!.searchText("onCreate\\(\\) calls: 3")) + Assert.assertTrue("DoubleRotateActivityOneTest failed:" + + "Section Three:" + + "onStart() count was off for ActivityOne after second PORTRAIT rotation.", + solo!!.searchText("onStart\\(\\) calls: 3")) + Assert.assertTrue("DoubleRotateActivityOneTest failed:" + + "Section Three:" + + "onResume() count was off for ActivityOne after second PORTRAIT rotation.", + solo!!.searchText("onResume\\(\\) calls: 3")) + Assert.assertTrue("DoubleRotateActivityOneTest failed:" + + "Section Three:" + + "onRestart() count was off for ActivityOne after second PORTRAIT rotation.", + solo!!.searchText("onRestart\\(\\) calls: 0")) + } + +} diff --git a/Labs/Lab2_Activity/app/src/androidTest/java/course/labs/activitylab/tests/Test3_StartActivityTwoTest.kt b/Labs/Lab2_Activity/app/src/androidTest/java/course/labs/activitylab/tests/Test3_StartActivityTwoTest.kt new file mode 100644 index 0000000000000000000000000000000000000000..80cb2b7d7eee05f14db4324197ebcb02cc9f7b83 --- /dev/null +++ b/Labs/Lab2_Activity/app/src/androidTest/java/course/labs/activitylab/tests/Test3_StartActivityTwoTest.kt @@ -0,0 +1,74 @@ +package course.labs.activitylab.tests + +import android.test.ActivityInstrumentationTestCase2 + +import com.robotium.solo.Solo + +import course.labs.activitylab.ActivityOne + +import junit.framework.Assert; + + +class Test3_StartActivityTwoTest : ActivityInstrumentationTestCase2<ActivityOne>(ActivityOne::class.java) { + + private var solo: Solo? = null + + @Throws(Exception::class) + override fun setUp() { + solo = Solo(instrumentation, activity) + } + + @Throws(Exception::class) + override fun tearDown() { + solo!!.finishOpenedActivities() + } + + // Executes the StartActivityTwoTest + fun testRun() { + + // ==================== Section One ===================== + // Wait for activity: 'course.labs.activitylab.ActivityOne' + val timeout = 20000 + Assert.assertTrue("StartActivityTwoTest failed:" + + "Section One:" + + "ActivityOne did not load correctly", + solo!!.waitForActivity(course.labs.activitylab.ActivityOne::class.java, timeout)) + + + // ==================== Section Two ===================== + // Click on Start Activity Two + + solo!!.waitForView(course.labs.activitylab.R.id.bLaunchActivityTwo) + solo!!.clickOnView(solo!! + .getView(course.labs.activitylab.R.id.bLaunchActivityTwo)) + + // Wait for activity: 'course.labs.activitylab.ActivityTwo' + Assert.assertTrue("StartActivityTwoTest failed:" + + "Section Two:" + + "ActivityTwo did not load correctly", + solo!!.waitForActivity(course.labs.activitylab.ActivityTwo::class.java, timeout)) + + + // Check for proper counts after ActivityTwo has been opened + Assert.assertTrue("StartActivityTwoTest failed:" + + "Section Two:" + + "onCreate() count was off for ActivityTwo.", + solo!!.waitForText("onCreate\\(\\) calls: 1")) + + Assert.assertTrue("StartActivityTwoTest failed:" + + "Section Two:" + + "onStart() count was off for ActivityTwo.", + solo!!.waitForText("onStart\\(\\) calls: 1")) + + Assert.assertTrue("StartActivityTwoTest failed:" + + "Section Two:" + + "onResume() count was off for ActivityTwo.", + solo!!.waitForText("onResume\\(\\) calls: 1")) + + Assert.assertTrue("StartActivityTwoTest failed:" + + "Section Two:" + + "onRestart() count was off for ActivityTwo.", + solo!!.waitForText("onRestart\\(\\) calls: 0")) + } + +} diff --git a/Labs/Lab2_Activity/app/src/androidTest/java/course/labs/activitylab/tests/Test4_DoubleRotateActivityTwoTest.kt b/Labs/Lab2_Activity/app/src/androidTest/java/course/labs/activitylab/tests/Test4_DoubleRotateActivityTwoTest.kt new file mode 100644 index 0000000000000000000000000000000000000000..29d66060c4dbe34d6b6c2365d3933497ced86839 --- /dev/null +++ b/Labs/Lab2_Activity/app/src/androidTest/java/course/labs/activitylab/tests/Test4_DoubleRotateActivityTwoTest.kt @@ -0,0 +1,98 @@ +package course.labs.activitylab.tests + +import android.test.ActivityInstrumentationTestCase2 + +import com.robotium.solo.Solo + +import course.labs.activitylab.ActivityOne + +import junit.framework.Assert; + + +class Test4_DoubleRotateActivityTwoTest : ActivityInstrumentationTestCase2<ActivityOne>(ActivityOne::class.java) { + + private var solo: Solo? = null + + @Throws(Exception::class) + override fun setUp() { + solo = Solo(instrumentation, activity) + } + + @Throws(Exception::class) + override fun tearDown() { + solo!!.finishOpenedActivities() + } + + // Executes the DoubleRotateActivityTwoTest + fun testRun() { + // ==================== Section One ===================== + // Wait for activity: 'course.labs.activitylab.ActivityOne' + val timeout = 20000 + Assert.assertTrue("DoubleRotateActivityTwoTest failed:" + + "Section One:" + + "ActivityOne did not load correctly", + solo!!.waitForActivity(course.labs.activitylab.ActivityOne::class.java, timeout)) + + + // ==================== Section Two ===================== + // Click on Start Activity Two + solo!!.waitForView(course.labs.activitylab.R.id.bLaunchActivityTwo) + solo!!.clickOnView(solo!! + .getView(course.labs.activitylab.R.id.bLaunchActivityTwo)) + + // Wait for activity: 'course.labs.activitylab.ActivityTwo' + Assert.assertTrue("DoubleRotateActivityTwoTest failed:" + + "Section Two:" + + "ActivityTwo did not load correctly", + solo!!.waitForActivity(course.labs.activitylab.ActivityTwo::class.java, timeout)) + + + solo!!.waitForView(course.labs.activitylab.R.id.bClose) + + // ==================== Section Three ===================== + // Rotate the screen + solo!!.setActivityOrientation(Solo.LANDSCAPE) + + // Wait for activity: 'course.labs.activitylab.ActivityTwo' + Assert.assertTrue("DoubleRotateActivityTwoTest failed:" + + "Section Three:" + + "ActivityTwo did not correctly load after first LANDSCAPE rotation.", + solo!!.waitForActivity(course.labs.activitylab.ActivityTwo::class.java, timeout)) + + solo!!.waitForView(course.labs.activitylab.R.id.bClose) + + // ==================== Section Four ===================== + // Rotate the screen + solo!!.setActivityOrientation(Solo.PORTRAIT) + + // Wait for activity: 'course.labs.activitylab.ActivityTwo' + Assert.assertTrue("DoubleRotateActivityTwoTest failed:" + + "Section Four:" + + "ActivityTwo did not correctly load after second PORTRAIT rotation.", + solo!!.waitForActivity(course.labs.activitylab.ActivityTwo::class.java, timeout)) + + solo!!.waitForView(course.labs.activitylab.R.id.bClose) + + // Check for proper counts + Assert.assertTrue("DoubleRotateActivityTwoTest failed:" + + "Section Four:" + + "onCreate() count was off for ActivityTwo after second PORTRAIT rotation.", + solo!!.waitForText("onCreate\\(\\) calls: 3")) + + Assert.assertTrue("DoubleRotateActivityTwoTest failed:" + + "Section Four:" + + "onStart() count was off for ActivityTwo after second PORTRAIT rotation.", + solo!!.waitForText("onStart\\(\\) calls: 3")) + + Assert.assertTrue("DoubleRotateActivityTwoTest failed:" + + "Section Four:" + + "onResume() count was off for ActivityTwo after second PORTRAIT rotation.", + solo!!.waitForText("onResume\\(\\) calls: 3")) + + Assert.assertTrue("DoubleRotateActivityTwoTest failed:" + + "Section Four:" + + "onRestart() count was off for ActivityTwo after second PORTRAIT rotation.", + solo!!.waitForText("onRestart\\(\\) calls: 0")) + } + +} diff --git a/Labs/Lab2_Activity/app/src/androidTest/java/course/labs/activitylab/tests/Test5_CloseActivityTwoTest.kt b/Labs/Lab2_Activity/app/src/androidTest/java/course/labs/activitylab/tests/Test5_CloseActivityTwoTest.kt new file mode 100644 index 0000000000000000000000000000000000000000..00969a48748cb04c940f23c5502b60ee94d5cf1e --- /dev/null +++ b/Labs/Lab2_Activity/app/src/androidTest/java/course/labs/activitylab/tests/Test5_CloseActivityTwoTest.kt @@ -0,0 +1,92 @@ +package course.labs.activitylab.tests + +import android.test.ActivityInstrumentationTestCase2 + +import com.robotium.solo.Solo + +import course.labs.activitylab.ActivityOne + +import junit.framework.Assert; + + +class Test5_CloseActivityTwoTest : ActivityInstrumentationTestCase2<ActivityOne>(ActivityOne::class.java) { + + private var solo: Solo? = null + + @Throws(Exception::class) + override fun setUp() { + solo = Solo(instrumentation, activity) + } + + @Throws(Exception::class) + override fun tearDown() { + solo!!.finishOpenedActivities() + } + + // Executes the CloseActivityTwoTest + fun testRun() { + + // ==================== Section One ===================== + // Wait for activity: 'course.labs.activitylab.ActivityOne' + val timeout = 20000 + Assert.assertTrue("CloseActivityTwoTest failed:" + + "Section One:" + + "ActivityOne did not load correctly", + solo!!.waitForActivity(course.labs.activitylab.ActivityOne::class.java, timeout)) + + solo!!.waitForView(course.labs.activitylab.R.id.bLaunchActivityTwo) + + // ==================== Section Two ===================== + // Click on Start Activity Two + solo!!.clickOnView(solo!!.getView(course.labs.activitylab.R.id.bLaunchActivityTwo)) + + // Wait for activity: 'course.labs.activitylab.ActivityTwo' + Assert.assertTrue("CloseActivityTwoTest failed:" + + "Section Two:" + + "ActivityTwo did not load correctly", + solo!!.waitForActivity(course.labs.activitylab.ActivityTwo::class.java, timeout)) + + + // ==================== Section Three ===================== + // Click on Close Activity + + solo!!.waitForView(course.labs.activitylab.R.id.bClose) + + val sleep = 1000 + solo!!.sleep(sleep) + + solo!!.clickOnView(solo!!.getView(course.labs.activitylab.R.id.bClose)) + + + // Wait for activity: 'course.labs.activitylab.ActivityOne' + Assert.assertTrue("CloseActivityTwoTest failed:" + + "Section Three:" + + "ActivityTwo did not close correctly", + solo!!.waitForActivity(course.labs.activitylab.ActivityOne::class.java, timeout)) + + solo!!.waitForView(course.labs.activitylab.R.id.bLaunchActivityTwo) + + // Check for proper counts + Assert.assertTrue("CloseActivityTwoTest failed:" + + "Section Three:" + + "onCreate() count was off for ActivityOne after ActivityTwo closed.", + solo!!.waitForText("onCreate\\(\\) calls: 1")) + + Assert.assertTrue("CloseActivityTwoTest failed:" + + "Section Three:" + + "onStart() count was off for ActivityOne after ActivityTwo closed.", + solo!!.waitForText("onStart\\(\\) calls: 2")) + + Assert.assertTrue("CloseActivityTwoTest failed:" + + "Section Three:" + + "onResume() count was off for ActivityOne after ActivityTwo closed.", + solo!!.waitForText("onResume\\(\\) calls: 2")) + + Assert.assertTrue("CloseActivityTwoTest failed:" + + "Section Three:" + + "onRestart() count was off for ActivityOne after ActivityTwo closed.", + solo!!.waitForText("onRestart\\(\\) calls: 1")) + + } + +} diff --git a/Labs/Lab2_Activity/app/src/androidTest/java/course/labs/activitylab/tests/Test6_ReopenActivityTwoTest.kt b/Labs/Lab2_Activity/app/src/androidTest/java/course/labs/activitylab/tests/Test6_ReopenActivityTwoTest.kt new file mode 100644 index 0000000000000000000000000000000000000000..1f4a18bb4c8d5eb859dc3550c68fb108cf9e5407 --- /dev/null +++ b/Labs/Lab2_Activity/app/src/androidTest/java/course/labs/activitylab/tests/Test6_ReopenActivityTwoTest.kt @@ -0,0 +1,104 @@ +package course.labs.activitylab.tests + +import android.test.ActivityInstrumentationTestCase2 + +import com.robotium.solo.Solo + +import course.labs.activitylab.ActivityOne + +import junit.framework.Assert; + + +class Test6_ReopenActivityTwoTest : ActivityInstrumentationTestCase2<ActivityOne>(ActivityOne::class.java) { + + private var solo: Solo? = null + + @Throws(Exception::class) + public override fun setUp() { + solo = Solo(instrumentation, activity) + } + + @Throws(Exception::class) + override fun tearDown() { + solo!!.finishOpenedActivities() + } + + // Executes the ReopenActivityTwoTest + fun testRun() { + + // ==================== Section One ===================== + // Wait for activity: 'course.labs.activitylab.ActivityOne' + val timeout = 20000 + Assert.assertTrue("ReopenActivityTwoTest failed:" + + "Section One:" + + "ActivityOne did not load correctly", + solo!!.waitForActivity(course.labs.activitylab.ActivityOne::class.java, timeout)) + + solo!!.waitForView(course.labs.activitylab.R.id.bLaunchActivityTwo) + + // ==================== Section Two ===================== + // Click on Start Activity Two + solo!!.clickOnView(solo!!.getView(course.labs.activitylab.R.id.bLaunchActivityTwo)) + + // Wait for activity: 'course.labs.activitylab.ActivityTwo' + Assert.assertTrue("ReopenActivityTwoTest failed:" + + "Section Two:" + + "ActivityTwo did not load correctly", + solo!!.waitForActivity(course.labs.activitylab.ActivityTwo::class.java, timeout)) + + solo!!.waitForView(course.labs.activitylab.R.id.bClose) + + val sleep = 1000 + solo!!.sleep(sleep) + + // ==================== Section Three ===================== + // Click on Close Activity + solo!!.clickOnView(solo!!.getView(course.labs.activitylab.R.id.bClose)) + + // Wait for activity: 'course.labs.activitylab.ActivityOne' + Assert.assertTrue("ReopenActivityTwoTest failed:" + + "Section Three:" + + "ActivityTwo did not close correctly", + solo!!.waitForActivity(course.labs.activitylab.ActivityOne::class.java, timeout)) + + solo!!.waitForView(course.labs.activitylab.R.id.bLaunchActivityTwo) + + solo!!.sleep(sleep) + + // ==================== Section Four ===================== + // Click on Start Activity Two + solo!!.clickOnView(solo!!.getView(course.labs.activitylab.R.id.bLaunchActivityTwo)) + + // Wait for activity: 'course.labs.activitylab.ActivityTwo' + Assert.assertTrue("ReopenActivityTwoTest failed:" + + "Section Four:" + + "ActivityTwo did not reopen correctly after being closed", + solo!!.waitForActivity(course.labs.activitylab.ActivityTwo::class.java, timeout)) + + solo!!.waitForView(course.labs.activitylab.R.id.bClose) + + // Check for proper counts + Assert.assertTrue("ReopenActivityTwoTest failed:" + + "Section Four:" + + "onCreate() count was off for ActivityTwo after being reopened for a second time.", + solo!!.waitForText("onCreate\\(\\) calls: 1")) + + Assert.assertTrue("ReopenActivityTwoTest failed:" + + "Section Four:" + + "onStart() count was off for ActivityTwo after being reopened for a second time.", + solo!!.waitForText("onStart\\(\\) calls: 1")) + + Assert.assertTrue("ReopenActivityTwoTest failed:" + + "Section Four:" + + "onResume() count was off for ActivityTwo after being reopened for a second time.", + solo!!.waitForText("onResume\\(\\) calls: 1")) + + Assert.assertTrue("ReopenActivityTwoTest failed:" + + "Section Four:" + + "onRestart() count was off for ActivityTwo after being reopened for a second time.", + solo!!.waitForText("onRestart\\(\\) calls: 0")) + + + } + +} diff --git a/Labs/Lab2_Activity/app/src/androidTest/res/.gitkeep b/Labs/Lab2_Activity/app/src/androidTest/res/.gitkeep new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git a/Labs/Lab2_Activity/app/src/main/AndroidManifest.xml b/Labs/Lab2_Activity/app/src/main/AndroidManifest.xml new file mode 100644 index 0000000000000000000000000000000000000000..46d261ccee95fbae62ed8b4ebfe8e78dd308e0be --- /dev/null +++ b/Labs/Lab2_Activity/app/src/main/AndroidManifest.xml @@ -0,0 +1,27 @@ +<?xml version="1.0" encoding="utf-8"?> +<manifest xmlns:android="http://schemas.android.com/apk/res/android" + package="course.labs.activitylab" + android:versionCode="1" + android:versionName="1.0" > + + <application + android:allowBackup="true" + android:icon="@mipmap/ic_launcher" + android:label="@string/app_name" + android:theme="@style/AppTheme" > + <activity + android:name=".ActivityOne" + android:label="@string/app_name" > + <intent-filter> + <action android:name="android.intent.action.MAIN" /> + + <category android:name="android.intent.category.LAUNCHER" /> + </intent-filter> + </activity> + <activity + android:name=".ActivityTwo" + android:label="@string/title_activity_activity_two" > + </activity> + </application> + +</manifest> \ No newline at end of file diff --git a/Labs/Lab2_Activity/app/src/main/java/course/labs/activitylab/ActivityOne.kt b/Labs/Lab2_Activity/app/src/main/java/course/labs/activitylab/ActivityOne.kt new file mode 100644 index 0000000000000000000000000000000000000000..c5908debe5e3e017df0ac31062fc8a774e1c0be3 --- /dev/null +++ b/Labs/Lab2_Activity/app/src/main/java/course/labs/activitylab/ActivityOne.kt @@ -0,0 +1,162 @@ +/* See https://kotlinlang.org/docs/reference/ for reference material on + the Kotlin language */ + +package course.labs.activitylab + +import android.app.Activity +import android.content.Intent +import android.os.Bundle +import android.util.Log +import android.view.View +import android.view.View.OnClickListener +import android.widget.Button +import android.widget.TextView + +class ActivityOne : Activity() { + + + // Lifecycle counters + + // TODO: + // Create counter variables for onCreate(), onRestart(), onStart() and + // onResume() + // You will need to increment these variables' values when their + // corresponding lifecycle methods get called + + + // TODO: Create variables for each of the TextViews + + override fun onCreate(savedInstanceState: Bundle?) { + super.onCreate(savedInstanceState) + setContentView(R.layout.activity_one) + + // TODO: Assign the appropriate TextViews to the TextView variables + // Hint: Access the TextView by calling Activity's findViewById() + // textView1 = findViewById(R.id.textView1); + + + + val launchActivityTwoButton = findViewById<Button>(R.id.bLaunchActivityTwo) + launchActivityTwoButton.setOnClickListener { + // TODO: + // Launch Activity Two + // Hint: use Context's startActivity() method + + // Create an intent stating which Activity you would like to start + + // Launch the Activity using the intent + } + + // Has previous state been saved? + if (savedInstanceState != null) { + + // TODO: + // Restore value of counters from saved state + // Only need 4 lines of code, one for every count variable + + + } + + // Emit LogCat message + Log.i(TAG, "Entered the onCreate() method") + + // TODO: + // Update the appropriate count variable + // Update the user interface via the displayCounts() method + + + } + + // Lifecycle callback overrides + + public override fun onStart() { + super.onStart() + + // Emit LogCat message + Log.i(TAG, "Entered the onStart() method") + + // TODO: + // Update the appropriate count variable + // Update the user interface + + } + + public override fun onResume() { + super.onResume() + + // Emit LogCat message + // Follow the previous 2 examples provided + + + + // TODO: + // Update the appropriate count variable + // Update the user interface + + } + + public override fun onPause() { + super.onPause() + + // Emit LogCat message + // Follow the previous 2 examples provided + + + } + + public override fun onStop() { + super.onStop() + + // Emit LogCat message + // Follow the previous 2 examples provided + + + } + + public override fun onRestart() { + super.onRestart() + + // Emit LogCat message + // Follow the previous 2 examples provided + + + // TODO: + // Update the appropriate count variable + // Update the user interface + + + } + + public override fun onDestroy() { + super.onDestroy() + + // Emit LogCat message + // Follow the previous 2 examples provided + + + } + + public override fun onSaveInstanceState(savedInstanceState: Bundle) { + // TODO: + // Save state information with a collection of key-value pairs + + } + + // Updates the displayed counters + private fun displayCounts() { + // TODO: + // set text for text view variables + + } + + companion object { + + private val RESTART_KEY = "restart" + private val RESUME_KEY = "resume" + private val START_KEY = "start" + private val CREATE_KEY = "create" + + // String for LogCat documentation + private val TAG = "Lab-ActivityOne" + } +} diff --git a/Labs/Lab2_Activity/app/src/main/java/course/labs/activitylab/ActivityTwo.kt b/Labs/Lab2_Activity/app/src/main/java/course/labs/activitylab/ActivityTwo.kt new file mode 100644 index 0000000000000000000000000000000000000000..161c0e1b7dc440ff5b1377735b3a95e5e6a64b6c --- /dev/null +++ b/Labs/Lab2_Activity/app/src/main/java/course/labs/activitylab/ActivityTwo.kt @@ -0,0 +1,157 @@ +/* See https://kotlinlang.org/docs/reference/ for reference material on + the Kotlin language */ + +package course.labs.activitylab + +import android.app.Activity +import android.os.Bundle +import android.util.Log +import android.view.View +import android.view.View.OnClickListener +import android.widget.Button +import android.widget.TextView + +class ActivityTwo : Activity() { + + // Lifecycle counters + + // TODO: + // Create counter variables for onCreate(), onRestart(), onStart() and + // onResume() + // You will need to increment these variables' values when their + // corresponding lifecycle methods get called + + + + // TODO: Create variables for each of the TextViews + + override fun onCreate(savedInstanceState: Bundle?) { + super.onCreate(savedInstanceState) + setContentView(R.layout.activity_two) + + // TODO: Assign the appropriate TextViews to the TextView variables + // Hint: Access the TextView by calling Activity's findViewById() + // textView1 = (TextView) findViewById(R.id.textView1); + + + + val closeButton = findViewById<Button>(R.id.bClose) + closeButton.setOnClickListener { + // TODO: + // This function closes Activity Two + // Hint: use Context's finish() method + + + } + + // Has previous state been saved? + if (savedInstanceState != null) { + + // TODO: + // Restore value of counters from saved state + // Only need 4 lines of code, one for every count variable + + } + + // Emit LogCat message + + Log.i(TAG, "Entered the onCreate() method") + + // TODO: + // Update the appropriate count variable + // Update the user interface via the displayCounts() method + + } + + // Lifecycle callback methods overrides + + public override fun onStart() { + super.onStart() + + // Emit LogCat message + Log.i(TAG, "Entered the onStart() method") + + // TODO: + // Update the appropriate count variable + // Update the user interface + + } + + public override fun onResume() { + super.onResume() + + // Emit LogCat message + // Follow the previous 2 examples provided + + + // TODO: + // Update the appropriate count variable + // Update the user interface + + } + + public override fun onPause() { + super.onPause() + + // Emit LogCat message + // Follow the previous 2 examples provided + + + } + + public override fun onStop() { + super.onStop() + + // Emit LogCat message + // Follow the previous 2 examples provided + + } + + public override fun onRestart() { + super.onRestart() + + // Emit LogCat message + // Follow the previous 2 examples provided + + + // TODO: + // Update the appropriate count variable + // Update the user interface + + } + + public override fun onDestroy() { + super.onDestroy() + + // Emit LogCat message + // Follow the previous 2 examples provided + + + } + + public override fun onSaveInstanceState(savedInstanceState: Bundle) { + + // TODO: + // Save counter state information with a collection of key-value pairs + // 4 lines of code, one for every count variable + + + } + + // Updates the displayed counters + private fun displayCounts() { + + + } + + companion object { + + private val RESTART_KEY = "restart" + private val RESUME_KEY = "resume" + private val START_KEY = "start" + private val CREATE_KEY = "create" + + // String for LogCat documentation + private val TAG = "Lab-ActivityTwo" + } +} diff --git a/Labs/Lab2_Activity/app/src/main/res/layout/activity_one.xml b/Labs/Lab2_Activity/app/src/main/res/layout/activity_one.xml new file mode 100644 index 0000000000000000000000000000000000000000..a9c1cf78e745c623d17c6a40fb1f18ebd7f9a1b0 --- /dev/null +++ b/Labs/Lab2_Activity/app/src/main/res/layout/activity_one.xml @@ -0,0 +1,31 @@ +<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" + android:layout_width="match_parent" + android:layout_height="match_parent" + android:orientation="vertical"> + + <TextView android:id="@+id/create" + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:text="@string/onCreate" /> + + <TextView android:id="@+id/start" + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:text="@string/onStart" /> + + <TextView android:id="@+id/resume" + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:text="@string/onResume" /> + + <TextView android:id="@+id/restart" + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:text="@string/onRestart" /> + + <Button android:id="@+id/bLaunchActivityTwo" + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:text="@string/button" /> + +</LinearLayout> \ No newline at end of file diff --git a/Labs/Lab2_Activity/app/src/main/res/layout/activity_two.xml b/Labs/Lab2_Activity/app/src/main/res/layout/activity_two.xml new file mode 100644 index 0000000000000000000000000000000000000000..fe23337df67ad62e3174280711c749a01319e897 --- /dev/null +++ b/Labs/Lab2_Activity/app/src/main/res/layout/activity_two.xml @@ -0,0 +1,32 @@ +<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" + android:layout_width="match_parent" + android:layout_height="match_parent" + android:orientation="vertical"> + + <TextView android:id="@+id/create" + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:text="@string/onCreate" /> + + <TextView android:id="@+id/start" + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:text="@string/onStart" /> + + <TextView android:id="@+id/resume" + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:text="@string/onResume" /> + + <TextView android:id="@+id/restart" + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:text="@string/onRestart" /> + + <Button android:id="@+id/bClose" + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:text="@string/close" + /> + +</LinearLayout> \ No newline at end of file diff --git a/Labs/Lab2_Activity/app/src/main/res/mipmap-hdpi/ic_launcher.png b/Labs/Lab2_Activity/app/src/main/res/mipmap-hdpi/ic_launcher.png new file mode 100644 index 0000000000000000000000000000000000000000..0e79b184fcf8cc47dede6d7ccde00d1a1e2d9c23 Binary files /dev/null and b/Labs/Lab2_Activity/app/src/main/res/mipmap-hdpi/ic_launcher.png differ diff --git a/Labs/Lab2_Activity/app/src/main/res/mipmap-ldpi/ic_launcher.png b/Labs/Lab2_Activity/app/src/main/res/mipmap-ldpi/ic_launcher.png new file mode 100644 index 0000000000000000000000000000000000000000..ebfac7d78b9e17c113f734d10af74bd2b100beba Binary files /dev/null and b/Labs/Lab2_Activity/app/src/main/res/mipmap-ldpi/ic_launcher.png differ diff --git a/Labs/Lab2_Activity/app/src/main/res/mipmap-mdpi/ic_launcher.png b/Labs/Lab2_Activity/app/src/main/res/mipmap-mdpi/ic_launcher.png new file mode 100644 index 0000000000000000000000000000000000000000..1183441937efcae0151b75099bec444d034886e9 Binary files /dev/null and b/Labs/Lab2_Activity/app/src/main/res/mipmap-mdpi/ic_launcher.png differ diff --git a/Labs/Lab2_Activity/app/src/main/res/mipmap-xhdpi/ic_launcher.png b/Labs/Lab2_Activity/app/src/main/res/mipmap-xhdpi/ic_launcher.png new file mode 100644 index 0000000000000000000000000000000000000000..c8ab2a114716b712ec0c5122f9e9524afaa60b52 Binary files /dev/null and b/Labs/Lab2_Activity/app/src/main/res/mipmap-xhdpi/ic_launcher.png differ diff --git a/Labs/Lab2_Activity/app/src/main/res/values/strings.xml b/Labs/Lab2_Activity/app/src/main/res/values/strings.xml new file mode 100644 index 0000000000000000000000000000000000000000..ea863b3e7ee7c735bac513ce6078c5b25046b05f --- /dev/null +++ b/Labs/Lab2_Activity/app/src/main/res/values/strings.xml @@ -0,0 +1,13 @@ +<?xml version="1.0" encoding="utf-8"?> +<resources> + + <string name="app_name">ActivityLab</string> + <string name="onCreate">onCreate() calls: 0</string> + <string name="onStart">onStart() calls: 0</string> + <string name="onResume">onResume() calls: 0</string> + <string name="onRestart">onRestart() calls: 0</string> + <string name="button">Start Activity Two</string> + <string name="title_activity_activity_two">Activity Two</string> + <string name="close">Close Activity</string> + +</resources> \ No newline at end of file diff --git a/Labs/Lab2_Activity/app/src/main/res/values/styles.xml b/Labs/Lab2_Activity/app/src/main/res/values/styles.xml new file mode 100644 index 0000000000000000000000000000000000000000..4a10ca492dd2610011d3979b4dc551f471fa27ab --- /dev/null +++ b/Labs/Lab2_Activity/app/src/main/res/values/styles.xml @@ -0,0 +1,20 @@ +<resources> + + <!-- + Base application theme, dependent on API level. This theme is replaced + by AppBaseTheme from res/values-vXX/styles.xml on newer devices. + --> + <style name="AppBaseTheme" parent="android:Theme.Light"> + <!-- + Theme customizations available in newer API levels can go in + res/values-vXX/styles.xml, while customizations related to + backward-compatibility can go here. + --> + </style> + + <!-- Application theme. --> + <style name="AppTheme" parent="AppBaseTheme"> + <!-- All customizations that are NOT specific to a particular API-level can go here. --> + </style> + +</resources> \ No newline at end of file diff --git a/Labs/Lab2_Activity/build.gradle b/Labs/Lab2_Activity/build.gradle new file mode 100644 index 0000000000000000000000000000000000000000..30abbc15080994316f7c9c46ed0d99a67b829906 --- /dev/null +++ b/Labs/Lab2_Activity/build.gradle @@ -0,0 +1,19 @@ +// Top-level build file where you can add configuration options common to all sub-projects/modules. +buildscript { + ext.kotlin_version = '1.3.50' + repositories { + jcenter() + google() + } + dependencies { + classpath 'com.android.tools.build:gradle:4.0.1' + classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version" + } +} + +allprojects { + repositories { + jcenter() + google() + } +} diff --git a/Labs/Lab2_Activity/gradle/wrapper/gradle-wrapper.jar b/Labs/Lab2_Activity/gradle/wrapper/gradle-wrapper.jar new file mode 100644 index 0000000000000000000000000000000000000000..8c0fb64a8698b08ecc4158d828ca593c4928e9dd Binary files /dev/null and b/Labs/Lab2_Activity/gradle/wrapper/gradle-wrapper.jar differ diff --git a/Labs/Lab2_Activity/gradle/wrapper/gradle-wrapper.properties b/Labs/Lab2_Activity/gradle/wrapper/gradle-wrapper.properties new file mode 100644 index 0000000000000000000000000000000000000000..ed0141d5b5b800e636e508bf030e0a111eb7d673 --- /dev/null +++ b/Labs/Lab2_Activity/gradle/wrapper/gradle-wrapper.properties @@ -0,0 +1,6 @@ +#Sun Sep 13 21:17:50 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/Lab2_Activity/gradlew b/Labs/Lab2_Activity/gradlew new file mode 100755 index 0000000000000000000000000000000000000000..91a7e269e19dfc62e27137a0b57ef3e430cee4fd --- /dev/null +++ b/Labs/Lab2_Activity/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/Lab2_Activity/gradlew.bat b/Labs/Lab2_Activity/gradlew.bat new file mode 100644 index 0000000000000000000000000000000000000000..8a0b282aa6885fb573c106b3551f7275c5f17e8e --- /dev/null +++ b/Labs/Lab2_Activity/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/Lab2_Activity/settings.gradle b/Labs/Lab2_Activity/settings.gradle new file mode 100644 index 0000000000000000000000000000000000000000..e7b4def49cb53d9aa04228dd3edb14c9e635e003 --- /dev/null +++ b/Labs/Lab2_Activity/settings.gradle @@ -0,0 +1 @@ +include ':app' diff --git a/Labs/Lab2_Intents/.gitignore b/Labs/Lab2_Intents/.gitignore new file mode 100644 index 0000000000000000000000000000000000000000..ceff37eff0e621e8f96607f26a6bced4727fb5a5 --- /dev/null +++ b/Labs/Lab2_Intents/.gitignore @@ -0,0 +1,39 @@ +# built application files +*.apk +*.ap_ + +# files for the dex VM +*.dex + +# Java class files +*.class + +# generated files +bin/ +gen/ + +# Local configuration file (sdk path, etc) +local.properties + +# Eclipse project files +.classpath +.settings + +# Proguard folder generated by Eclipse +proguard/ + +# Intellij project files +*.iml +*.ipr +*.iws +.idea +.idea/workspace.xml +.gradle +build/ +captures/ + +# Mac files +.DS_Store + +# Windows thumbnail db +Thumbs.db diff --git a/Labs/Lab2_Intents/IntentLab.webm b/Labs/Lab2_Intents/IntentLab.webm new file mode 100644 index 0000000000000000000000000000000000000000..f1d5888a96f9c8e33df1c450b708d86f53e674d7 Binary files /dev/null and b/Labs/Lab2_Intents/IntentLab.webm differ diff --git a/Labs/Lab2_Intents/Lab-Intents.pdf b/Labs/Lab2_Intents/Lab-Intents.pdf new file mode 100644 index 0000000000000000000000000000000000000000..6c833f4391edbb53714499298e327f2c9da0722e Binary files /dev/null and b/Labs/Lab2_Intents/Lab-Intents.pdf differ diff --git a/Labs/Lab2_Intents/app/build.gradle b/Labs/Lab2_Intents/app/build.gradle new file mode 100644 index 0000000000000000000000000000000000000000..954b785a737f5cdb626a486cb1d5ea0ce08d02c6 --- /dev/null +++ b/Labs/Lab2_Intents/app/build.gradle @@ -0,0 +1,33 @@ +apply plugin: 'com.android.application' +apply plugin: 'kotlin-android' + +android { + compileSdkVersion 31 + + defaultConfig { + applicationId "course.labs.intentslab" + minSdkVersion 21 + targetSdkVersion 31 + + testApplicationId "course.labs.intentslab.tests" + testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner" + } + + buildTypes { + release { + minifyEnabled false + proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt' + } + } +} + +dependencies { + implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version" + androidTestImplementation('androidx.test.espresso:espresso-core:3.4.0') + androidTestImplementation('androidx.test:runner:1.4.0') + androidTestImplementation('androidx.test:rules:1.4.0') + +} +repositories { + mavenCentral() +} diff --git a/Labs/Lab2_Intents/app/libs/robotium-solo-5.3.1.jar b/Labs/Lab2_Intents/app/libs/robotium-solo-5.3.1.jar new file mode 100644 index 0000000000000000000000000000000000000000..d7f816c4c2bbc8d55b827b821fe13c8d55be4d08 Binary files /dev/null and b/Labs/Lab2_Intents/app/libs/robotium-solo-5.3.1.jar differ diff --git a/Labs/Lab2_Intents/app/src/androidTest/java/course/labs/intentslab/tests/ExplicitActivationTest.kt b/Labs/Lab2_Intents/app/src/androidTest/java/course/labs/intentslab/tests/ExplicitActivationTest.kt new file mode 100644 index 0000000000000000000000000000000000000000..5f01159794f42d9dafe00b16a8097835fe4dc0d1 --- /dev/null +++ b/Labs/Lab2_Intents/app/src/androidTest/java/course/labs/intentslab/tests/ExplicitActivationTest.kt @@ -0,0 +1,105 @@ +package course.labs.intentslab.tests + + +import android.view.View +import android.view.ViewGroup +import androidx.test.espresso.Espresso.onView +import androidx.test.espresso.action.ViewActions.* +import androidx.test.espresso.assertion.ViewAssertions.matches +import androidx.test.espresso.matcher.ViewMatchers.* +import androidx.test.filters.LargeTest +import androidx.test.rule.ActivityTestRule +import androidx.test.runner.AndroidJUnit4 +import course.labs.intentslab.ActivityLoaderActivity +import course.labs.intentslab.R +import org.hamcrest.Description +import org.hamcrest.Matcher +import org.hamcrest.Matchers.allOf +import org.hamcrest.TypeSafeMatcher +import org.junit.Rule +import org.junit.Test +import org.junit.runner.RunWith + +@LargeTest +@RunWith(AndroidJUnit4::class) +class ExplicitActivationTest { + + @Rule + @JvmField + var mActivityTestRule = ActivityTestRule(ActivityLoaderActivity::class.java) + + @Test + fun explicitActivationTest() { + val button = onView( + allOf( + withId(R.id.explicit_activation_button), withText("Explicit Activation"), + childAtPosition( + childAtPosition( + withId(android.R.id.content), + 0 + ), + 0 + ), + isDisplayed() + ) + ) + button.perform(click()) + + val editText = onView( + allOf( + withId(R.id.editText), + childAtPosition( + childAtPosition( + withId(android.R.id.content), + 0 + ), + 1 + ), + isDisplayed() + ) + ) + editText.perform(replaceText("Test"), closeSoftKeyboard()) + + val button2 = onView( + allOf( + withId(R.id.enter_button), withText("Enter"), + childAtPosition( + childAtPosition( + withId(android.R.id.content), + 0 + ), + 2 + ), + isDisplayed() + ) + ) + button2.perform(click()) + + val textView = onView( + allOf( + withId(R.id.textView1), withText("Test"), + withParent(withParent(withId(android.R.id.content))), + isDisplayed() + ) + ) + textView.check(matches(withText("Test"))) + } + + private fun childAtPosition( + parentMatcher: Matcher<View>, position: Int + ): Matcher<View> { + + return object : TypeSafeMatcher<View>() { + override fun describeTo(description: Description) { + description.appendText("Child at position $position in parent ") + parentMatcher.describeTo(description) + } + + public override fun matchesSafely(view: View): Boolean { + val parent = view.parent + return parent is ViewGroup && parentMatcher.matches(parent) + && view == parent.getChildAt(position) + } + } + } +} diff --git a/Labs/Lab2_Intents/app/src/androidTest/java/course/labs/intentslab/tests/ImplicitIntentTest.kt b/Labs/Lab2_Intents/app/src/androidTest/java/course/labs/intentslab/tests/ImplicitIntentTest.kt new file mode 100644 index 0000000000000000000000000000000000000000..f0c4edddedd70846e32807ae78fd1258180d0b04 --- /dev/null +++ b/Labs/Lab2_Intents/app/src/androidTest/java/course/labs/intentslab/tests/ImplicitIntentTest.kt @@ -0,0 +1,88 @@ +package course.labs.intentslab.tests + + +import android.util.Log +import android.view.View +import android.view.ViewGroup +import androidx.test.espresso.Espresso.onView +import androidx.test.espresso.action.ViewActions.click +import androidx.test.espresso.matcher.ViewMatchers.* +import androidx.test.ext.junit.runners.AndroidJUnit4 +import androidx.test.filters.LargeTest +import androidx.test.platform.app.InstrumentationRegistry +import androidx.test.rule.ActivityTestRule +import androidx.test.uiautomator.UiDevice +import androidx.test.uiautomator.UiSelector +import course.labs.intentslab.ActivityLoaderActivity +import course.labs.intentslab.R +import junit.framework.Assert.assertTrue +import org.hamcrest.Description +import org.hamcrest.Matcher +import org.hamcrest.Matchers.allOf +import org.hamcrest.TypeSafeMatcher +import org.junit.Before +import org.junit.Rule +import org.junit.Test +import org.junit.runner.RunWith + + +@LargeTest +@RunWith(AndroidJUnit4::class) +class ImplicitIntentTest { + + @Rule + @JvmField + var mActivityTestRule = ActivityTestRule(ActivityLoaderActivity::class.java) + private var uiDevice: UiDevice? = null + + @Before + @Throws(Exception::class) + fun setUp() { + uiDevice = UiDevice.getInstance(InstrumentationRegistry.getInstrumentation()) + } + + + @Test + fun implicitIntentTest() { + val button = onView( + allOf( + withId(R.id.implicit_activation_button), withText("Implicit Activation"), + childAtPosition( + childAtPosition( + withId(android.R.id.content), + 0 + ), + 1 + ), + isDisplayed() + ) + ) + button.perform(click()) + + val testButton = uiDevice!!.findObject(UiSelector().text("MyDialer")) + assertTrue(testButton.exists()) + if (testButton.exists() && testButton.isEnabled) { + Log.i("Hello", "Check") + testButton.click() + } + uiDevice!!.pressHome() + } + + private fun childAtPosition( + parentMatcher: Matcher<View>, position: Int + ): Matcher<View> { + + return object : TypeSafeMatcher<View>() { + override fun describeTo(description: Description) { + description.appendText("Child at position $position in parent ") + parentMatcher.describeTo(description) + } + + public override fun matchesSafely(view: View): Boolean { + val parent = view.parent + return parent is ViewGroup && parentMatcher.matches(parent) + && view == parent.getChildAt(position) + } + } + } +} diff --git a/Labs/Lab2_Intents/app/src/androidTest/res/.gitignore b/Labs/Lab2_Intents/app/src/androidTest/res/.gitignore new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git a/Labs/Lab2_Intents/app/src/main/AndroidManifest.xml b/Labs/Lab2_Intents/app/src/main/AndroidManifest.xml new file mode 100644 index 0000000000000000000000000000000000000000..1f464e4498828f8001c76c7a67684feda2966bbb --- /dev/null +++ b/Labs/Lab2_Intents/app/src/main/AndroidManifest.xml @@ -0,0 +1,41 @@ +<?xml version="1.0" encoding="utf-8"?> +<manifest xmlns:android="http://schemas.android.com/apk/res/android" + package="course.labs.intentslab" + android:versionCode="1" + android:versionName="1.0"> + + <queries> + <!-- Specific apps you interact with, eg: + <package android:name="course.labs.intentslab.mydialer" /> + --> + <!-- + Specific intents you query for, + eg: for a custom share UI +--> + + <intent> + <action android:name="android.intent.action.DIAL" /> + <data android:scheme="tel"/> + </intent> + + </queries> + + <application + android:allowBackup="true" + android:icon="@mipmap/ic_launcher" + android:label="@string/app_name" + android:theme="@style/AppTheme"> + <activity android:name=".ActivityLoaderActivity" + android:exported="true"> + <intent-filter> + <action android:name="android.intent.action.MAIN" /> + + <category android:name="android.intent.category.LAUNCHER" /> + </intent-filter> + </activity> + <activity + android:name=".ExplicitlyLoadedActivity" + android:label="@string/title_explicit" /> + </application> + +</manifest> \ No newline at end of file diff --git a/Labs/Lab2_Intents/app/src/main/java/course/labs/intentslab/ActivityLoaderActivity.kt b/Labs/Lab2_Intents/app/src/main/java/course/labs/intentslab/ActivityLoaderActivity.kt new file mode 100755 index 0000000000000000000000000000000000000000..4ba2d54d5377fedc02edebfacf0cd15666f5d708 --- /dev/null +++ b/Labs/Lab2_Intents/app/src/main/java/course/labs/intentslab/ActivityLoaderActivity.kt @@ -0,0 +1,92 @@ +package course.labs.intentslab + +import android.app.Activity +import android.content.Intent +import android.os.Bundle +import android.util.Log +import android.widget.Button +import android.widget.TextView + +class ActivityLoaderActivity : Activity() { + + // TextView that displays user-entered text from ExplicitlyLoadedActivity runs + private var mUserTextView: TextView? = null + + // TODO - return a base intent for viewing a URL + // (HINT: second parameter uses Uri.parse()) + // You will need to write the get() = null + // into the code block get() {} + val baseIntent: Intent? + get() = null + + override fun onCreate(savedInstanceState: Bundle?) { + super.onCreate(savedInstanceState) + setContentView(R.layout.activity_loader_activity) + + // Get reference to the textView + mUserTextView = findViewById(R.id.textView1) + + // Declare and setup Explicit Activation button + val explicitActivationButton = findViewById<Button>(R.id.explicit_activation_button) + explicitActivationButton.setOnClickListener{ startExplicitActivation() } // Call startExplicitActivation() when pressed + + + // Declare and setup Implicit Activation button + val implicitActivationButton = findViewById<Button>(R.id.implicit_activation_button) + implicitActivationButton.setOnClickListener{ startImplicitActivation() } // Call startImplicitActivation() when pressed + + } + + + // Start the ExplicitlyLoadedActivity + + private fun startExplicitActivation() { + + Log.i(TAG, "Entered startExplicitActivation()") + + // TODO - Create a new intent to launch the ExplicitlyLoadedActivity class + + // TODO - Start an Activity using that intent and the request code defined above + + } + + // Start a Browser Activity to view a web page or its URL + + private fun startImplicitActivation() { + + Log.i(TAG, "Entered startImplicitActivation()") + + // TODO - Implement getBaseIntent() to Create a base intent for viewing a URL + val baseIntent = baseIntent + + // TODO - Create a chooser intent, for choosing which Activity + // will carry out the baseIntent + // (HINT: Use the Intent class' createChooser() method) + + //TODO - Log the chooser intent action + + // TODO - Start the chooser Activity, using the chooser intent + + } + + override fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent) { + + Log.i(TAG, "Entered onActivityResult()") + + // TODO - Process the result only if this method received both a + // RESULT_OK result code and a recognized request code + // If so, update the Textview showing the user-entered text. + + } + + companion object { + + private const val GET_TEXT_REQUEST_CODE = 1 + // private val URL = "http://www.google.com" + private const val URL = "tel:5555555555" + private const val TAG = "Lab-Intents" + + // For use with app chooser + private val CHOOSER_TEXT = "Load $URL with:" + } +} diff --git a/Labs/Lab2_Intents/app/src/main/java/course/labs/intentslab/ExplicitlyLoadedActivity.kt b/Labs/Lab2_Intents/app/src/main/java/course/labs/intentslab/ExplicitlyLoadedActivity.kt new file mode 100755 index 0000000000000000000000000000000000000000..cd9bef2597db02b2eb7e39ae79b0b5537b8f1a5f --- /dev/null +++ b/Labs/Lab2_Intents/app/src/main/java/course/labs/intentslab/ExplicitlyLoadedActivity.kt @@ -0,0 +1,47 @@ +package course.labs.intentslab + +import android.app.Activity +import android.os.Bundle +import android.util.Log +import android.widget.Button +import android.widget.EditText + +class ExplicitlyLoadedActivity : Activity() { + + private var mEditText: EditText? = null + + override fun onCreate(savedInstanceState: Bundle?) { + super.onCreate(savedInstanceState) + + setContentView(R.layout.explicitly_loaded_activity) + + // Get a reference to the EditText field + mEditText = findViewById(R.id.editText) + + // Declare and setup "Enter" button + val enterButton = findViewById<Button>(R.id.enter_button) + enterButton.setOnClickListener{ enterClicked() } // Call enterClicked() when pressed + + } + + // Sets result to send back to calling Activity and finishes + + private fun enterClicked() { + + Log.i(TAG, "Entered enterClicked()") + + // TODO - Save user provided input from the EditText field + + // TODO - Create a new intent and save the input from the EditText field as an extra + + // TODO - Set Activity's result with result code RESULT_OK + + // TODO - Finish the Activity + + } + + companion object { + + private val TAG = "Lab-Intents" + } +} diff --git a/Labs/Lab2_Intents/app/src/main/res/layout/activity_loader_activity.xml b/Labs/Lab2_Intents/app/src/main/res/layout/activity_loader_activity.xml new file mode 100644 index 0000000000000000000000000000000000000000..a3ede66a4c34bcccfd14ea77b10406a074504499 --- /dev/null +++ b/Labs/Lab2_Intents/app/src/main/res/layout/activity_loader_activity.xml @@ -0,0 +1,24 @@ +<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" + android:layout_width="match_parent" + android:layout_height="match_parent" + android:orientation="vertical"> + + <Button + android:id="@+id/explicit_activation_button" + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:text="@string/explicit_activation_button_string" /> + + <Button + android:id="@+id/implicit_activation_button" + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:text="@string/implicit_activation_button_string" /> + + <TextView + android:id="@+id/textView1" + android:layout_width="match_parent" + android:layout_height="wrap_content" + android:text="@string/no_text_entered" /> + +</LinearLayout> \ No newline at end of file diff --git a/Labs/Lab2_Intents/app/src/main/res/layout/explicitly_loaded_activity.xml b/Labs/Lab2_Intents/app/src/main/res/layout/explicitly_loaded_activity.xml new file mode 100644 index 0000000000000000000000000000000000000000..9dc73fdea7086e58aaa95ad19dc29dda339e508e --- /dev/null +++ b/Labs/Lab2_Intents/app/src/main/res/layout/explicitly_loaded_activity.xml @@ -0,0 +1,32 @@ +<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" + android:layout_width="match_parent" + android:layout_height="match_parent"> + + <TextView + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:layout_centerHorizontal="true" + android:layout_centerVertical="true" + android:text="@string/explicit_message" /> + + <EditText + android:id="@+id/editText" + android:layout_width="match_parent" + android:layout_height="wrap_content" + android:layout_alignParentStart="true" + android:layout_alignParentTop="true" + android:ems="10" + android:hint="@string/enter_text_here_string" > + + <requestFocus /> + </EditText> + + <Button + android:id="@+id/enter_button" + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:layout_alignParentStart="true" + android:layout_below="@+id/editText" + android:text="@string/enter_string" /> + +</RelativeLayout> \ No newline at end of file diff --git a/Labs/Lab2_Intents/app/src/main/res/mipmap-hdpi/ic_launcher.png b/Labs/Lab2_Intents/app/src/main/res/mipmap-hdpi/ic_launcher.png new file mode 100644 index 0000000000000000000000000000000000000000..0e79b184fcf8cc47dede6d7ccde00d1a1e2d9c23 Binary files /dev/null and b/Labs/Lab2_Intents/app/src/main/res/mipmap-hdpi/ic_launcher.png differ diff --git a/Labs/Lab2_Intents/app/src/main/res/mipmap-ldpi/ic_launcher.png b/Labs/Lab2_Intents/app/src/main/res/mipmap-ldpi/ic_launcher.png new file mode 100644 index 0000000000000000000000000000000000000000..ebfac7d78b9e17c113f734d10af74bd2b100beba Binary files /dev/null and b/Labs/Lab2_Intents/app/src/main/res/mipmap-ldpi/ic_launcher.png differ diff --git a/Labs/Lab2_Intents/app/src/main/res/mipmap-mdpi/ic_launcher.png b/Labs/Lab2_Intents/app/src/main/res/mipmap-mdpi/ic_launcher.png new file mode 100644 index 0000000000000000000000000000000000000000..1183441937efcae0151b75099bec444d034886e9 Binary files /dev/null and b/Labs/Lab2_Intents/app/src/main/res/mipmap-mdpi/ic_launcher.png differ diff --git a/Labs/Lab2_Intents/app/src/main/res/mipmap-xhdpi/ic_launcher.png b/Labs/Lab2_Intents/app/src/main/res/mipmap-xhdpi/ic_launcher.png new file mode 100644 index 0000000000000000000000000000000000000000..c8ab2a114716b712ec0c5122f9e9524afaa60b52 Binary files /dev/null and b/Labs/Lab2_Intents/app/src/main/res/mipmap-xhdpi/ic_launcher.png differ diff --git a/Labs/Lab2_Intents/app/src/main/res/values/strings.xml b/Labs/Lab2_Intents/app/src/main/res/values/strings.xml new file mode 100644 index 0000000000000000000000000000000000000000..2ea909a9eb0969e4c5b859793c180553a1036cc9 --- /dev/null +++ b/Labs/Lab2_Intents/app/src/main/res/values/strings.xml @@ -0,0 +1,14 @@ +<?xml version="1.0" encoding="utf-8"?> +<resources> + + <string name="app_name">IntentsLab</string> + <string name="title_explicit">Explicit Activation</string> + <string name="title_main">Activity Loader Activity</string> + <string name="explicit_message">You have sent an Explicit Intent!</string> + <string name="explicit_activation_button_string">Explicit Activation</string> + <string name="implicit_activation_button_string">Implicit Activation</string> + <string name="no_text_entered">No Text Entered</string> + <string name="enter_string">Enter</string> + <string name="enter_text_here_string">Enter Text Here</string> + +</resources> \ No newline at end of file diff --git a/Labs/Lab2_Intents/app/src/main/res/values/styles.xml b/Labs/Lab2_Intents/app/src/main/res/values/styles.xml new file mode 100644 index 0000000000000000000000000000000000000000..4a10ca492dd2610011d3979b4dc551f471fa27ab --- /dev/null +++ b/Labs/Lab2_Intents/app/src/main/res/values/styles.xml @@ -0,0 +1,20 @@ +<resources> + + <!-- + Base application theme, dependent on API level. This theme is replaced + by AppBaseTheme from res/values-vXX/styles.xml on newer devices. + --> + <style name="AppBaseTheme" parent="android:Theme.Light"> + <!-- + Theme customizations available in newer API levels can go in + res/values-vXX/styles.xml, while customizations related to + backward-compatibility can go here. + --> + </style> + + <!-- Application theme. --> + <style name="AppTheme" parent="AppBaseTheme"> + <!-- All customizations that are NOT specific to a particular API-level can go here. --> + </style> + +</resources> \ No newline at end of file diff --git a/Labs/Lab2_Intents/build.gradle b/Labs/Lab2_Intents/build.gradle new file mode 100644 index 0000000000000000000000000000000000000000..30abbc15080994316f7c9c46ed0d99a67b829906 --- /dev/null +++ b/Labs/Lab2_Intents/build.gradle @@ -0,0 +1,19 @@ +// Top-level build file where you can add configuration options common to all sub-projects/modules. +buildscript { + ext.kotlin_version = '1.3.50' + repositories { + jcenter() + google() + } + dependencies { + classpath 'com.android.tools.build:gradle:4.0.1' + classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version" + } +} + +allprojects { + repositories { + jcenter() + google() + } +} diff --git a/Labs/Lab2_Intents/gradle.properties b/Labs/Lab2_Intents/gradle.properties new file mode 100644 index 0000000000000000000000000000000000000000..7522776ab04105d4cc166973dfe0d10136683cf7 --- /dev/null +++ b/Labs/Lab2_Intents/gradle.properties @@ -0,0 +1,15 @@ +## 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. +# Default value: -Xmx1024m -XX:MaxPermSize=256m +# org.gradle.jvmargs=-Xmx2048m -XX:MaxPermSize=512m -XX:+HeapDumpOnOutOfMemoryError -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 +#Wed Feb 09 04:13:39 EST 2022 +android.useAndroidX=true +android.enableJetifier=true diff --git a/Labs/Lab2_Intents/gradle/wrapper/gradle-wrapper.jar b/Labs/Lab2_Intents/gradle/wrapper/gradle-wrapper.jar new file mode 100644 index 0000000000000000000000000000000000000000..8c0fb64a8698b08ecc4158d828ca593c4928e9dd Binary files /dev/null and b/Labs/Lab2_Intents/gradle/wrapper/gradle-wrapper.jar differ diff --git a/Labs/Lab2_Intents/gradle/wrapper/gradle-wrapper.properties b/Labs/Lab2_Intents/gradle/wrapper/gradle-wrapper.properties new file mode 100644 index 0000000000000000000000000000000000000000..76656ddd421d3cd2707e1030793f4e9d47e753df --- /dev/null +++ b/Labs/Lab2_Intents/gradle/wrapper/gradle-wrapper.properties @@ -0,0 +1,6 @@ +#Sat Sep 12 21:47:07 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/Lab2_Intents/gradlew b/Labs/Lab2_Intents/gradlew new file mode 100755 index 0000000000000000000000000000000000000000..91a7e269e19dfc62e27137a0b57ef3e430cee4fd --- /dev/null +++ b/Labs/Lab2_Intents/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/Lab2_Intents/gradlew.bat b/Labs/Lab2_Intents/gradlew.bat new file mode 100644 index 0000000000000000000000000000000000000000..8a0b282aa6885fb573c106b3551f7275c5f17e8e --- /dev/null +++ b/Labs/Lab2_Intents/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/Lab2_Intents/settings.gradle b/Labs/Lab2_Intents/settings.gradle new file mode 100644 index 0000000000000000000000000000000000000000..e7b4def49cb53d9aa04228dd3edb14c9e635e003 --- /dev/null +++ b/Labs/Lab2_Intents/settings.gradle @@ -0,0 +1 @@ +include ':app' diff --git a/Labs/Lab2_MyDialer/.gitignore b/Labs/Lab2_MyDialer/.gitignore new file mode 100644 index 0000000000000000000000000000000000000000..ceff37eff0e621e8f96607f26a6bced4727fb5a5 --- /dev/null +++ b/Labs/Lab2_MyDialer/.gitignore @@ -0,0 +1,39 @@ +# built application files +*.apk +*.ap_ + +# files for the dex VM +*.dex + +# Java class files +*.class + +# generated files +bin/ +gen/ + +# Local configuration file (sdk path, etc) +local.properties + +# Eclipse project files +.classpath +.settings + +# Proguard folder generated by Eclipse +proguard/ + +# Intellij project files +*.iml +*.ipr +*.iws +.idea +.idea/workspace.xml +.gradle +build/ +captures/ + +# Mac files +.DS_Store + +# Windows thumbnail db +Thumbs.db diff --git a/Labs/Lab2_MyDialer/app/build.gradle b/Labs/Lab2_MyDialer/app/build.gradle new file mode 100644 index 0000000000000000000000000000000000000000..f39bd66f8245db487e624080e1c9576d5eeaf571 --- /dev/null +++ b/Labs/Lab2_MyDialer/app/build.gradle @@ -0,0 +1,32 @@ +apply plugin: 'com.android.application' +apply plugin: 'kotlin-android-extensions' +apply plugin: 'kotlin-android' + +android { + compileSdkVersion 26 + buildToolsVersion '29.0.3' + + defaultConfig { + applicationId "course.labs.intentslab.mydialer" + minSdkVersion 21 + targetSdkVersion 26 + } + + buildTypes { + release { + minifyEnabled false + proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt' + } + } + + dependencies { + androidTestImplementation 'com.jayway.android.robotium:robotium-solo:5.6.3' + androidTestImplementation 'com.android.support.test:rules:1.0.2' + } +} +repositories { + mavenCentral() +} +dependencies { + implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version" +} diff --git a/Labs/Lab2_MyDialer/app/src/main/AndroidManifest.xml b/Labs/Lab2_MyDialer/app/src/main/AndroidManifest.xml new file mode 100644 index 0000000000000000000000000000000000000000..0c94f22d7e624221c1025551381d6d32dcf7167d --- /dev/null +++ b/Labs/Lab2_MyDialer/app/src/main/AndroidManifest.xml @@ -0,0 +1,28 @@ +<?xml version="1.0" encoding="utf-8"?> +<manifest xmlns:android="http://schemas.android.com/apk/res/android" + package="course.labs.intentslab.mydialer" + android:versionCode="1" + android:versionName="1.0" > + + <application + android:allowBackup="true" + android:icon="@mipmap/ic_launcher" + android:label="@string/app_name" + android:theme="@style/AppTheme" > + <activity + android:name=".MyDialerActivity" + android:label="@string/app_name" > + <intent-filter> + <action android:name="android.intent.action.MAIN" /> + + <category android:name="android.intent.category.LAUNCHER" /> + </intent-filter> + + <!-- TODO - Add necessary intent filter information so that this + Activity will accept Intents with the + action "android.intent.action.DIAL" and with an "telephone" + schemed data, also make the Intent category Default --> + </activity> + </application> + +</manifest> \ No newline at end of file diff --git a/Labs/Lab2_MyDialer/app/src/main/java/course/labs/intentslab/mydialer/MyDialerActivity.kt b/Labs/Lab2_MyDialer/app/src/main/java/course/labs/intentslab/mydialer/MyDialerActivity.kt new file mode 100644 index 0000000000000000000000000000000000000000..d5691883ffe92dacaec670f886f600ec3ec22fdc --- /dev/null +++ b/Labs/Lab2_MyDialer/app/src/main/java/course/labs/intentslab/mydialer/MyDialerActivity.kt @@ -0,0 +1,24 @@ +package course.labs.intentslab.mydialer + +import android.app.Activity +import android.os.Bundle +import android.widget.TextView + +class MyDialerActivity : Activity() { + + override fun onCreate(savedInstanceState: Bundle?) { + super.onCreate(savedInstanceState) + setContentView(R.layout.my_dialer_activity) + + // Save the String passed with the intent + var url = intent.dataString + + if (null == url) + url = "No Data Provided" + + // Get a reference to the TextView and set the text it to the String + val textView = findViewById<TextView>(R.id.url) + textView.text = url + } + +} diff --git a/Labs/Lab2_MyDialer/app/src/main/res/layout/my_dialer_activity.xml b/Labs/Lab2_MyDialer/app/src/main/res/layout/my_dialer_activity.xml new file mode 100644 index 0000000000000000000000000000000000000000..207604e1d23805881cd1b3f044f365f3e91546aa --- /dev/null +++ b/Labs/Lab2_MyDialer/app/src/main/res/layout/my_dialer_activity.xml @@ -0,0 +1,13 @@ +<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" + android:layout_width="match_parent" + android:layout_height="match_parent"> + + <TextView + android:id="@+id/url" + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:layout_centerHorizontal="true" + android:layout_centerVertical="true" + android:textSize="24sp" /> + +</RelativeLayout> \ No newline at end of file diff --git a/Labs/Lab2_MyDialer/app/src/main/res/mipmap-hdpi/ic_launcher.png b/Labs/Lab2_MyDialer/app/src/main/res/mipmap-hdpi/ic_launcher.png new file mode 100644 index 0000000000000000000000000000000000000000..96a442e5b8e9394ccf50bab9988cb2316026245d Binary files /dev/null and b/Labs/Lab2_MyDialer/app/src/main/res/mipmap-hdpi/ic_launcher.png differ diff --git a/Labs/Lab2_MyDialer/app/src/main/res/mipmap-mdpi/ic_launcher.png b/Labs/Lab2_MyDialer/app/src/main/res/mipmap-mdpi/ic_launcher.png new file mode 100644 index 0000000000000000000000000000000000000000..359047dfa4ed206e41e2354f9c6b307e713efe32 Binary files /dev/null and b/Labs/Lab2_MyDialer/app/src/main/res/mipmap-mdpi/ic_launcher.png differ diff --git a/Labs/Lab2_MyDialer/app/src/main/res/mipmap-xhdpi/ic_launcher.png b/Labs/Lab2_MyDialer/app/src/main/res/mipmap-xhdpi/ic_launcher.png new file mode 100644 index 0000000000000000000000000000000000000000..71c6d760f05183ef8a47c614d8d13380c8528499 Binary files /dev/null and b/Labs/Lab2_MyDialer/app/src/main/res/mipmap-xhdpi/ic_launcher.png differ diff --git a/Labs/Lab2_MyDialer/app/src/main/res/values/strings.xml b/Labs/Lab2_MyDialer/app/src/main/res/values/strings.xml new file mode 100644 index 0000000000000000000000000000000000000000..78bce4669dc43beccf6f2f2497a64447287554ac --- /dev/null +++ b/Labs/Lab2_MyDialer/app/src/main/res/values/strings.xml @@ -0,0 +1,6 @@ +<?xml version="1.0" encoding="utf-8"?> +<resources> + + <string name="app_name">MyDialer</string> + +</resources> diff --git a/Labs/Lab2_MyDialer/app/src/main/res/values/styles.xml b/Labs/Lab2_MyDialer/app/src/main/res/values/styles.xml new file mode 100644 index 0000000000000000000000000000000000000000..6ce89c7ba4394d8cab27953d41456ce234ca37c3 --- /dev/null +++ b/Labs/Lab2_MyDialer/app/src/main/res/values/styles.xml @@ -0,0 +1,20 @@ +<resources> + + <!-- + Base application theme, dependent on API level. This theme is replaced + by AppBaseTheme from res/values-vXX/styles.xml on newer devices. + --> + <style name="AppBaseTheme" parent="android:Theme.Light"> + <!-- + Theme customizations available in newer API levels can go in + res/values-vXX/styles.xml, while customizations related to + backward-compatibility can go here. + --> + </style> + + <!-- Application theme. --> + <style name="AppTheme" parent="AppBaseTheme"> + <!-- All customizations that are NOT specific to a particular API-level can go here. --> + </style> + +</resources> diff --git a/Labs/Lab2_MyDialer/build.gradle b/Labs/Lab2_MyDialer/build.gradle new file mode 100644 index 0000000000000000000000000000000000000000..30abbc15080994316f7c9c46ed0d99a67b829906 --- /dev/null +++ b/Labs/Lab2_MyDialer/build.gradle @@ -0,0 +1,19 @@ +// Top-level build file where you can add configuration options common to all sub-projects/modules. +buildscript { + ext.kotlin_version = '1.3.50' + repositories { + jcenter() + google() + } + dependencies { + classpath 'com.android.tools.build:gradle:4.0.1' + classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version" + } +} + +allprojects { + repositories { + jcenter() + google() + } +} diff --git a/Labs/Lab2_MyDialer/gradle/wrapper/gradle-wrapper.jar b/Labs/Lab2_MyDialer/gradle/wrapper/gradle-wrapper.jar new file mode 100644 index 0000000000000000000000000000000000000000..8c0fb64a8698b08ecc4158d828ca593c4928e9dd Binary files /dev/null and b/Labs/Lab2_MyDialer/gradle/wrapper/gradle-wrapper.jar differ diff --git a/Labs/Lab2_MyDialer/gradle/wrapper/gradle-wrapper.properties b/Labs/Lab2_MyDialer/gradle/wrapper/gradle-wrapper.properties new file mode 100644 index 0000000000000000000000000000000000000000..691e69ae678e20446122931e4ed7fbe59cfd5d6f --- /dev/null +++ b/Labs/Lab2_MyDialer/gradle/wrapper/gradle-wrapper.properties @@ -0,0 +1,6 @@ +#Sat Sep 12 22:40:31 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/Lab2_MyDialer/gradlew b/Labs/Lab2_MyDialer/gradlew new file mode 100644 index 0000000000000000000000000000000000000000..91a7e269e19dfc62e27137a0b57ef3e430cee4fd --- /dev/null +++ b/Labs/Lab2_MyDialer/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/Lab2_MyDialer/gradlew.bat b/Labs/Lab2_MyDialer/gradlew.bat new file mode 100644 index 0000000000000000000000000000000000000000..8a0b282aa6885fb573c106b3551f7275c5f17e8e --- /dev/null +++ b/Labs/Lab2_MyDialer/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/Lab2_MyDialer/settings.gradle b/Labs/Lab2_MyDialer/settings.gradle new file mode 100644 index 0000000000000000000000000000000000000000..e7b4def49cb53d9aa04228dd3edb14c9e635e003 --- /dev/null +++ b/Labs/Lab2_MyDialer/settings.gradle @@ -0,0 +1 @@ +include ':app'