diff --git a/labs/Lab4_UILabs/.gitignore b/labs/Lab4_UILabs/.gitignore new file mode 100644 index 0000000000000000000000000000000000000000..ceff37eff0e621e8f96607f26a6bced4727fb5a5 --- /dev/null +++ b/labs/Lab4_UILabs/.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/Lab4_UILabs/Lab-UserInterface.pdf b/labs/Lab4_UILabs/Lab-UserInterface.pdf new file mode 100644 index 0000000000000000000000000000000000000000..afdee9a0aba74fe7bc621b0d6b002ac9111663a4 Binary files /dev/null and b/labs/Lab4_UILabs/Lab-UserInterface.pdf differ diff --git a/labs/Lab4_UILabs/UILabs.mp4 b/labs/Lab4_UILabs/UILabs.mp4 new file mode 100644 index 0000000000000000000000000000000000000000..fc2fff2a351ffffdb46aac00f207b41e93085e58 Binary files /dev/null and b/labs/Lab4_UILabs/UILabs.mp4 differ diff --git a/labs/Lab4_UILabs/app/build.gradle b/labs/Lab4_UILabs/app/build.gradle new file mode 100644 index 0000000000000000000000000000000000000000..bd3295d2e5193047888bc73c7b30661159e0ea22 --- /dev/null +++ b/labs/Lab4_UILabs/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 '27.0.3' + + defaultConfig { + applicationId "course.labs.todomanager" + minSdkVersion 21 + targetSdkVersion 26 + + testApplicationId "course.labs.todomanager.tests" + testInstrumentationRunner "android.test.InstrumentationTestRunner" + } + + buildTypes { + release { + minifyEnabled false + proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt' + } + } +} + +dependencies { + androidTestImplementation 'com.jayway.android.robotium:robotium-solo:5.6.3' + implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version" +} +repositories { + mavenCentral() +} diff --git a/labs/Lab4_UILabs/app/src/androidTest/java/course/labs/todomanager/tests/Test1_SubmitTest.kt b/labs/Lab4_UILabs/app/src/androidTest/java/course/labs/todomanager/tests/Test1_SubmitTest.kt new file mode 100644 index 0000000000000000000000000000000000000000..47715e57595affbbf9196368ca5ce6a96d7eb30f --- /dev/null +++ b/labs/Lab4_UILabs/app/src/androidTest/java/course/labs/todomanager/tests/Test1_SubmitTest.kt @@ -0,0 +1,99 @@ +package course.labs.todomanager.tests + +import android.test.ActivityInstrumentationTestCase2 + +import com.robotium.solo.Solo + +import course.labs.todomanager.ToDoManagerActivity +import junit.framework.Assert + +class Test1_SubmitTest : ActivityInstrumentationTestCase2<ToDoManagerActivity>(ToDoManagerActivity::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() + } + + // Execute the SubmitTest + fun testRun() { + + val delay = 2000 + + // ============= Section One =============== + // Wait for activity: 'course.labs.todomanager.ToDoManagerActivity' + Assert.assertTrue( + "SubmitTest failed:" + "Section One:" + + "ToDoManagerActivity did not load correctly.", + solo!!.waitForActivity(course.labs.todomanager.ToDoManagerActivity::class.java)) + + // Click on action bar item to delete all items + solo!!.clickOnActionBarItem(0x1) + + solo!!.sleep(delay) + + // Get footer view + Assert.assertTrue("FooterView didn't appear", + solo!!.waitForView(course.labs.todomanager.R.id.footerView)) + + // Click on Add New ToDo Item + solo!!.clickOnView(solo!!.getView(course.labs.todomanager.R.id.footerView)) + + // Wait for activity: 'course.labs.todomanager.AddToDoActivity' + Assert.assertTrue( + "Submit Test failed:" + "Section One:" + + "AddToDoActivity did not correctly load.", + solo!!.waitForActivity(course.labs.todomanager.AddToDoActivity::class.java)) + + // Hide the soft keyboard + solo!!.hideSoftKeyboard() + + // Enter the text: 't4' + solo!!.clearEditText(solo!! + .getView(course.labs.todomanager.R.id.title) as android.widget.EditText) + + solo!!.enterText(solo!! + .getView(course.labs.todomanager.R.id.title) as android.widget.EditText, "t4") + + // Hide the soft keyboard + solo!!.hideSoftKeyboard() + + // Click on Done: + solo!!.clickOnView(solo!!.getView(course.labs.todomanager.R.id.statusDone)) + + // Click on Low + solo!!.clickOnView(solo!!.getView(course.labs.todomanager.R.id.lowPriority)) + + // Click on Submit + solo!!.clickOnView(solo!! + .getView(course.labs.todomanager.R.id.submitButton)) + + // ================= Section Two ================ + // Wait for activity: 'course.labs.todomanager.ToDoManagerActivity' + Assert.assertTrue( + "SubmitTest failed:" + + "Section Two:" + + "ToDoManagerActivity did not load correctly after pressing submit.", + solo!!.waitForActivity(course.labs.todomanager.ToDoManagerActivity::class.java)) + + Assert.assertTrue("SubmitTest failed:" + "Section Two:" + + "Title was not correctly entered in the ToDoManager", + solo!!.searchText("t4")) + + Assert.assertTrue("SubmitTest failed:" + "Section Two:" + + "Priority was not correctly entered in the ToDoManager", + solo!!.searchText("[lL][oO][wW]")) + + Assert.assertTrue("SubmitTest failed:" + "Section Two:" + + "Did not correctly set completion status.", + solo!!.isCheckBoxChecked(0)) + + } + +} diff --git a/labs/Lab4_UILabs/app/src/androidTest/java/course/labs/todomanager/tests/Test2_DateTimeTest.kt b/labs/Lab4_UILabs/app/src/androidTest/java/course/labs/todomanager/tests/Test2_DateTimeTest.kt new file mode 100644 index 0000000000000000000000000000000000000000..6c860a11ce5cb8f464ecd557c7cc4a5fd2ed0356 --- /dev/null +++ b/labs/Lab4_UILabs/app/src/androidTest/java/course/labs/todomanager/tests/Test2_DateTimeTest.kt @@ -0,0 +1,142 @@ +package course.labs.todomanager.tests + +import android.test.ActivityInstrumentationTestCase2 + +import com.robotium.solo.Solo + +import course.labs.todomanager.ToDoManagerActivity +import junit.framework.Assert + +class Test2_DateTimeTest : ActivityInstrumentationTestCase2<ToDoManagerActivity>(ToDoManagerActivity::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 DateTimeTest + fun testRun() { + + val delay = 2000 + + // ============== Section One ================ + + // Wait for activity: 'course.labs.todomanager.ToDoManagerActivity' + Assert.assertTrue( + "DateTimeTest failed:" + "Section One:" + + "ToDoManagerActivity did not correctly load.", + solo!!.waitForActivity(course.labs.todomanager.ToDoManagerActivity::class.java)) + + // Click on action bar item to delete all items + solo!!.clickOnActionBarItem(0x1) + + solo!!.sleep(delay) + + // Get footer view + Assert.assertTrue("FooterView didn't appear", + solo!!.waitForView(course.labs.todomanager.R.id.footerView)) + + // Click on Add New ToDo Item + solo!!.clickOnView(solo!!.getView(course.labs.todomanager.R.id.footerView)) + + // Wait for activity: 'course.labs.todomanager.AddToDoActivity' + Assert.assertTrue( + "DateTimeTest failed:" + "Section One:" + + "AddToDoActivity did not correctly load.", + solo!!.waitForActivity(course.labs.todomanager.AddToDoActivity::class.java)) + + // Hide the soft keyboard + solo!!.hideSoftKeyboard() + + // Enter the text: 't1' + solo!!.clearEditText(solo!! + .getView(course.labs.todomanager.R.id.title) as android.widget.EditText) + + solo!!.enterText(solo!! + .getView(course.labs.todomanager.R.id.title) as android.widget.EditText, "t1") + + // Hide the soft keyboard + solo!!.hideSoftKeyboard() + + // Click on Done: + solo!!.clickOnView(solo!!.getView(course.labs.todomanager.R.id.statusDone)) + + // Click on Low + solo!!.clickOnView(solo!!.getView(course.labs.todomanager.R.id.lowPriority)) + + // Click on Choose Date + solo!!.clickOnView(solo!! + .getView(course.labs.todomanager.R.id.date_picker_button)) + + // Wait for dialog + solo!!.waitForDialogToOpen(10000) + + // Really set the date + solo!!.setDatePicker(0, 2014, 1, 28) + + // Click on Done + solo!!.clickOnView(solo!!.getView(android.R.id.button1)) + + solo!!.sleep(delay) + + // Click on Choose Time + solo!!.clickOnView(solo!! + .getView(course.labs.todomanager.R.id.time_picker_button)) + + // Wait for dialog + solo!!.waitForDialogToOpen(10000) + + + // Really set the time + solo!!.setTimePicker(0, 9, 19) + + // Click on Done + solo!!.clickOnView(solo!!.getView(android.R.id.button1)) + + solo!!.sleep(delay) + + // Click on Submit + solo!!.clickOnView(solo!! + .getView(course.labs.todomanager.R.id.submitButton)) + + // Wait for activity: 'course.labs.todomanager.ToDoManagerActivity' + Assert.assertTrue( + "DateTimeTest failed:" + "Section One:" + + "ToDoManagerActivity did not load correctly", + solo!!.waitForActivity(course.labs.todomanager.ToDoManagerActivity::class.java)) + + // ============== Section Two ============= + + // Makes sure the title was changed correctly + Assert.assertTrue("DateTimeTest failed:" + "Section Two:" + + "Did not modify title correctly", solo!!.searchText("t1")) + + // Checks to see if the status was changed correctly + Assert.assertTrue("DateTimeTest failed:" + "Section Two:" + + "Did not change status correctly", solo!!.isCheckBoxChecked(0)) + + // Checks to make sure the priority was correctly set + Assert.assertTrue("DateTimeTest failed:" + "Section Two:" + + "Did not correctly set priority", + solo!!.searchText("[lL][oO][wW]")) + + // Checks to make sure the Date was correctly set + Assert.assertTrue("DateTimeTest failed:" + "Section Two:" + + "Did not correctly set the date", + solo!!.searchText("2014-02-28")) + + // Checks to make sure the Time was correctly set + Assert.assertTrue("DateTimeTest failed:" + "Section Two:" + + "Did not correctly set the time", solo!!.searchText("09:19:00")) + + } + +} \ No newline at end of file diff --git a/labs/Lab4_UILabs/app/src/androidTest/java/course/labs/todomanager/tests/Test3_CancelTest.kt b/labs/Lab4_UILabs/app/src/androidTest/java/course/labs/todomanager/tests/Test3_CancelTest.kt new file mode 100644 index 0000000000000000000000000000000000000000..e4545fc45528a77c64a84b5a88029b99c37f3fd7 --- /dev/null +++ b/labs/Lab4_UILabs/app/src/androidTest/java/course/labs/todomanager/tests/Test3_CancelTest.kt @@ -0,0 +1,137 @@ +package course.labs.todomanager.tests + +import android.test.ActivityInstrumentationTestCase2 + +import com.robotium.solo.Solo + +import course.labs.todomanager.ToDoManagerActivity +import junit.framework.Assert + +class Test3_CancelTest : ActivityInstrumentationTestCase2<ToDoManagerActivity>(ToDoManagerActivity::class.java) { + private var solo: Solo? = null + + @Throws(Exception::class) + public override fun setUp() { + solo = Solo(instrumentation, activity) + } + + @Throws(Exception::class) + public override fun tearDown() { + solo!!.finishOpenedActivities() + } + + // Executes the CancelTest + fun testRun() { + + val delay = 2000 + + // Wait for activity: 'course.labs.todomanager.ToDoManagerActivity' + Assert.assertTrue( + "CancelTest failed:" + "Section One:" + + "ToDoManagerActivity did not load correctly.", + solo!!.waitForActivity(course.labs.todomanager.ToDoManagerActivity::class.java)) + + // Click on action bar item + solo!!.clickOnActionBarItem(0x1) + + solo!!.sleep(delay) + + // Get footer view + Assert.assertTrue("FooterView didn't appear", + solo!!.waitForView(course.labs.todomanager.R.id.footerView)) + + // Click on Add New ToDo Item + solo!!.clickOnView(solo!!.getView(course.labs.todomanager.R.id.footerView)) + + // Wait for activity: 'course.labs.todomanager.AddToDoActivity' + Assert.assertTrue( + "CancelTest failed:" + "Section One:" + + "AddToDoActivity did not load correctly.", + solo!!.waitForActivity(course.labs.todomanager.AddToDoActivity::class.java)) + + // Hide the soft keyboard + solo!!.hideSoftKeyboard() + + // Enter the text: 't3' + solo!!.clearEditText(solo!! + .getView(course.labs.todomanager.R.id.title) as android.widget.EditText) + + solo!!.enterText(solo!! + .getView(course.labs.todomanager.R.id.title) as android.widget.EditText, "t3") + + // Hide the soft keyboard + solo!!.hideSoftKeyboard() + + // Click on Done: + solo!!.clickOnView(solo!!.getView(course.labs.todomanager.R.id.statusDone)) + + // Click on High + solo!!.clickOnView(solo!! + .getView(course.labs.todomanager.R.id.highPriority)) + + // Click on Cancel + solo!!.clickOnView(solo!! + .getView(course.labs.todomanager.R.id.cancelButton)) + + // Wait for activity: 'course.labs.todomanager.AddToDoActivity' + Assert.assertTrue( + "Cancel test failed:" + "Section One:" + + "AddToDoActivity did not correctly load.", + solo!!.waitForActivity(course.labs.todomanager.AddToDoActivity::class.java)) + + // Click on Add New ToDo Item + solo!!.clickOnView(solo!!.getView(course.labs.todomanager.R.id.footerView)) + + // Wait for activity: 'course.labs.todomanager.AddToDoActivity' + Assert.assertTrue( + "CancelTest failed:" + "Section One:" + + "AddToDoActivity did not load correctly.", + solo!!.waitForActivity(course.labs.todomanager.AddToDoActivity::class.java)) + + // Hide the soft keyboard + solo!!.hideSoftKeyboard() + + // Enter the text: 't4' + solo!!.clearEditText(solo!! + .getView(course.labs.todomanager.R.id.title) as android.widget.EditText) + + solo!!.enterText(solo!! + .getView(course.labs.todomanager.R.id.title) as android.widget.EditText, "t4") + + // Hide the soft keyboard + solo!!.hideSoftKeyboard() + + // Click on Done: + solo!!.clickOnView(solo!!.getView(course.labs.todomanager.R.id.statusDone)) + + // Click on Low + solo!!.clickOnView(solo!!.getView(course.labs.todomanager.R.id.lowPriority)) + + // Click on Submit + solo!!.clickOnView(solo!! + .getView(course.labs.todomanager.R.id.submitButton)) + + // ================ Section Two =================== + + // Wait for activity: 'course.labs.todomanager.ToDoManagerActivity' + Assert.assertTrue( + "CancelTest failed:" + "Section Two:" + + "ToDoManagerActivity did not load correctly.", + solo!!.waitForActivity(course.labs.todomanager.ToDoManagerActivity::class.java)) + + Assert.assertFalse("CancelTest failed:" + "Section Two:" + + "Did not correctly cancel the creation of a ToDo Task.", + solo!!.searchText("t3")) + + Assert.assertTrue("CancelTest failed:" + "Section Two:" + + "Did not correctly set title of ToDo Task following cancel.", + solo!!.searchText("t4")) + + Assert.assertTrue( + "CancelTest failed:" + + "Section Two:" + + "Did not correctly set priority of ToDo Task following cancel.", + solo!!.searchText("[lL][oO][wW]")) + + } +} diff --git a/labs/Lab4_UILabs/app/src/androidTest/java/course/labs/todomanager/tests/Test4_ResetTest.kt b/labs/Lab4_UILabs/app/src/androidTest/java/course/labs/todomanager/tests/Test4_ResetTest.kt new file mode 100644 index 0000000000000000000000000000000000000000..3136df58cfbd9d7e26479b116bb3a1192b64c9d5 --- /dev/null +++ b/labs/Lab4_UILabs/app/src/androidTest/java/course/labs/todomanager/tests/Test4_ResetTest.kt @@ -0,0 +1,117 @@ +package course.labs.todomanager.tests + +import android.test.ActivityInstrumentationTestCase2 + +import com.robotium.solo.Solo + +import course.labs.todomanager.ToDoManagerActivity +import junit.framework.Assert + +class Test4_ResetTest : ActivityInstrumentationTestCase2<ToDoManagerActivity>(ToDoManagerActivity::class.java) { + private var solo: Solo? = null + + @Throws(Exception::class) + public override fun setUp() { + solo = Solo(instrumentation, activity) + } + + @Throws(Exception::class) + public override fun tearDown() { + solo!!.finishOpenedActivities() + } + + // Executes the ResetTest + fun testRun() { + + val delay = 2000 + + // ============= Section One ============== + // Wait for activity: 'course.labs.todomanager.ToDoManagerActivity' + Assert.assertTrue( + "ResetTest failed:" + "Section One:" + + "ToDoManagerActivity did not correctly load.", + solo!!.waitForActivity(course.labs.todomanager.ToDoManagerActivity::class.java)) + + // Click on action bar item + solo!!.clickOnActionBarItem(0x1) + + solo!!.sleep(delay) + + // Get footer view + Assert.assertTrue("FooterView didn't appear", + solo!!.waitForView(course.labs.todomanager.R.id.footerView)) + + // Click on Add New ToDo Item + solo!!.clickOnView(solo!!.getView(course.labs.todomanager.R.id.footerView)) + + // Wait for activity: 'course.labs.todomanager.AddToDoActivity' + Assert.assertTrue( + "ResetTest failed:" + "Section One:" + + "AddToDoActivity did not correctly load.", + solo!!.waitForActivity(course.labs.todomanager.AddToDoActivity::class.java)) + + // Hide the soft keyboard + solo!!.hideSoftKeyboard() + + // Enter the text: 't2' + solo!!.clearEditText(solo!! + .getView(course.labs.todomanager.R.id.title) as android.widget.EditText) + + solo!!.enterText(solo!! + .getView(course.labs.todomanager.R.id.title) as android.widget.EditText, "t2") + + // Hide the soft keyboard + solo!!.hideSoftKeyboard() + + // Click on Done: + solo!!.clickOnView(solo!!.getView(course.labs.todomanager.R.id.statusDone)) + + // Click on High + solo!!.clickOnView(solo!! + .getView(course.labs.todomanager.R.id.highPriority)) + + // Click on Reset + solo!!.clickOnView(solo!!.getView(course.labs.todomanager.R.id.resetButton)) + + solo!!.sleep(delay) + + // Click on Submit + solo!!.clickOnView(solo!! + .getView(course.labs.todomanager.R.id.submitButton)) + + // ============= Section Two ================= + // Checks that reset button reset the text + + // Wait for activity: 'course.labs.todomanager.AddToDoActivity' + Assert.assertTrue( + "ResetTest failed:" + "Section Two:" + + "AddToDoActivity did not correctly load.", + solo!!.waitForActivity(course.labs.todomanager.AddToDoActivity::class.java)) + + Assert.assertFalse("ResetTest failed:" + "Section Two:" + + "Title of ToDo Task was not correctly reset.", + solo!!.searchText("t2")) + + // Makes sure that the check box is not checked + Assert.assertFalse("ResetTest failed:" + "SectionTwo:" + + "Done status of ToDo Task was not correctly reset", + solo!!.isCheckBoxChecked(0)) + + // Makes sure that the priority was reset to Medium + Assert.assertTrue("ResetTest failed:" + "Section Two:" + + "Priority of ToDo Task was not correctly reset", + solo!!.searchText("[mM][eE][dD]")) + + // Clicks on the Done box + solo!!.clickOnCheckBox(0) + + // Makes sure that was able to correctly change completion status from + // ToDoManagerActivity + Assert.assertTrue( + "ResetTest failed:" + + "Section Two:" + + "Was not able to modify Done status of ToDo Task from ToDoManagerActivity", + solo!!.isCheckBoxChecked(0)) + + } +} \ No newline at end of file diff --git a/labs/Lab4_UILabs/app/src/androidTest/res/drawable/.gitignore b/labs/Lab4_UILabs/app/src/androidTest/res/drawable/.gitignore new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git a/labs/Lab4_UILabs/app/src/main/AndroidManifest.xml b/labs/Lab4_UILabs/app/src/main/AndroidManifest.xml new file mode 100644 index 0000000000000000000000000000000000000000..e5b11df3179c1772022fc4094b0563131406cc2f --- /dev/null +++ b/labs/Lab4_UILabs/app/src/main/AndroidManifest.xml @@ -0,0 +1,24 @@ +<?xml version="1.0" encoding="utf-8"?> +<manifest xmlns:android="http://schemas.android.com/apk/res/android" + package="course.labs.todomanager" + android:versionCode="1" + android:versionName="1.0" > + + <application + android:allowBackup="true" + android:icon="@drawable/ic_launcher" + android:label="@string/app_name" > + <activity + android:name=".ToDoManagerActivity" + 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=".AddToDoActivity" > + </activity> + </application> + +</manifest> \ No newline at end of file diff --git a/labs/Lab4_UILabs/app/src/main/java/course/labs/todomanager/AddToDoActivity.kt b/labs/Lab4_UILabs/app/src/main/java/course/labs/todomanager/AddToDoActivity.kt new file mode 100644 index 0000000000000000000000000000000000000000..9f48e05914ecfb2d1b64835ca7601699de9f756c --- /dev/null +++ b/labs/Lab4_UILabs/app/src/main/java/course/labs/todomanager/AddToDoActivity.kt @@ -0,0 +1,237 @@ +package course.labs.todomanager + +import java.util.Calendar +import java.util.Date + +import android.app.Activity +import android.app.DatePickerDialog +import android.app.Dialog +import android.app.DialogFragment +import android.app.TimePickerDialog +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.DatePicker +import android.widget.EditText +import android.widget.RadioButton +import android.widget.RadioGroup +import android.widget.TextView +import android.widget.TimePicker +import course.labs.todomanager.ToDoItem.Priority +import course.labs.todomanager.ToDoItem.Status + +class AddToDoActivity : Activity() { + + private var mDate: Date? = null + private var mPriorityRadioGroup: RadioGroup? = null + private var mStatusRadioGroup: RadioGroup? = null + private var mTitleText: EditText? = null + private var mDefaultStatusButton: RadioButton? = null + private var mDefaultPriorityButton: RadioButton? = null + private var dateView: TextView? = null + private var timeView: TextView? = null + + private val priority: Priority + get() { + + when (mPriorityRadioGroup!!.checkedRadioButtonId) { + R.id.lowPriority -> { + return Priority.LOW + } + R.id.highPriority -> { + return Priority.HIGH + } + else -> { + return Priority.MED + } + } + } + + private val status: Status + get() { + + when (mStatusRadioGroup!!.checkedRadioButtonId) { + R.id.statusDone -> { + return Status.DONE + } + else -> { + return Status.NOTDONE + } + } + } + + override fun onCreate(savedInstanceState: Bundle?) { + super.onCreate(savedInstanceState) + setContentView(R.layout.add_todo) + + mTitleText = findViewById<View>(R.id.title) as EditText + mDefaultStatusButton = findViewById<View>(R.id.statusNotDone) as RadioButton + mDefaultPriorityButton = findViewById<View>(R.id.medPriority) as RadioButton + mPriorityRadioGroup = findViewById<View>(R.id.priorityGroup) as RadioGroup + mStatusRadioGroup = findViewById<View>(R.id.statusGroup) as RadioGroup + dateView = findViewById<View>(R.id.date) as TextView + timeView = findViewById<View>(R.id.time) as TextView + + // Set the default date and time + + setDefaultDateTime() + + // OnClickListener for the Date button, calls showDatePickerDialog() to + // show + // the Date dialog + + val datePickerButton = findViewById<View>(R.id.date_picker_button) as Button + datePickerButton.setOnClickListener { showDatePickerDialog() } + + // OnClickListener for the Time button, calls showTimePickerDialog() to + // show + // the Time Dialog + + val timePickerButton = findViewById<View>(R.id.time_picker_button) as Button + timePickerButton.setOnClickListener { showTimePickerDialog() } + + // OnClickListener for the Cancel Button, + + val cancelButton = findViewById<View>(R.id.cancelButton) as Button + cancelButton.setOnClickListener { Log.i(TAG, "Entered cancelButton.OnClickListener.onClick()") + + // TODO - Indicate result and finish + + } + + // TODO - Set up OnClickListener for the Reset Button + + + // Set up OnClickListener for the Submit Button + + val submitButton = findViewById<View>(R.id.submitButton) as Button + submitButton.setOnClickListener { + Log.i(TAG, "Entered submitButton.OnClickListener.onClick()") + + // TODO - gather ToDoItem data + + + // TODO - return data Intent and finish + } + } + + private fun setDefaultDateTime() { + + // Default is current time + 7 days + mDate = Date() + mDate = Date(mDate!!.time + SEVEN_DAYS) + + val c = Calendar.getInstance() + c.time = mDate + + setDateString(c.get(Calendar.YEAR), c.get(Calendar.MONTH), + c.get(Calendar.DAY_OF_MONTH)) + + dateView!!.text = dateString + + setTimeString(c.get(Calendar.HOUR_OF_DAY), c.get(Calendar.MINUTE), + c.get(Calendar.MILLISECOND)) + + timeView!!.text = timeString + } + + // DialogFragment used to pick a ToDoItem deadline date + + class DatePickerFragment : DialogFragment(), DatePickerDialog.OnDateSetListener { + + override fun onCreateDialog(savedInstanceState: Bundle?): Dialog { + + // Use the current date as the default date in the picker + + val c = Calendar.getInstance() + val year = c.get(Calendar.YEAR) + val month = c.get(Calendar.MONTH) + val day = c.get(Calendar.DAY_OF_MONTH) + + // Create a new instance of DatePickerDialog and return it + return DatePickerDialog(activity, this, year, month, day) + } + + override fun onDateSet(view: DatePicker, year: Int, monthOfYear: Int, + dayOfMonth: Int) { + setDateString(year, monthOfYear, dayOfMonth) + val dateView: TextView = activity.findViewById(R.id.date) + dateView.text = dateString + } + + } + + // DialogFragment used to pick a ToDoItem deadline time + + class TimePickerFragment : DialogFragment(), TimePickerDialog.OnTimeSetListener { + + override fun onCreateDialog(savedInstanceState: Bundle): Dialog { + + // Use the current time as the default values for the picker + val c = Calendar.getInstance() + val hour = c.get(Calendar.HOUR_OF_DAY) + val minute = c.get(Calendar.MINUTE) + + // Create a new instance of TimePickerDialog and return + return TimePickerDialog(activity, this, hour, minute, true) + } + + override fun onTimeSet(view: TimePicker, hourOfDay: Int, minute: Int) { + setTimeString(hourOfDay, minute, 0) + val timeView: TextView = activity.findViewById(R.id.time) + timeView.text = timeString + } + } + + private fun showDatePickerDialog() { + val newFragment = DatePickerFragment() + newFragment.show(fragmentManager, "datePicker") + } + + private fun showTimePickerDialog() { + val newFragment = TimePickerFragment() + newFragment.show(fragmentManager, "timePicker") + } + + companion object { + + // 7 days in milliseconds - 7 * 24 * 60 * 60 * 1000 + private val SEVEN_DAYS = 604800000 + + private val TAG = "Lab-UserInterface" + + private var timeString: String? = null + private var dateString: String? = null + + private fun setDateString(year: Int, monthOfYear: Int, dayOfMonth: Int) { + var monthOfYear = monthOfYear + + // Increment monthOfYear for Calendar/Date -> Time Format setting + monthOfYear++ + var mon = "" + monthOfYear + var day = "" + dayOfMonth + + if (monthOfYear < 10) + mon = "0$monthOfYear" + if (dayOfMonth < 10) + day = "0$dayOfMonth" + + dateString = "$year-$mon-$day" + } + + private fun setTimeString(hourOfDay: Int, minute: Int, mili: Int) { + var hour = "" + hourOfDay + var min = "" + minute + + if (hourOfDay < 10) + hour = "0$hourOfDay" + if (minute < 10) + min = "0$minute" + + timeString = "$hour:$min:00" + } + } +} diff --git a/labs/Lab4_UILabs/app/src/main/java/course/labs/todomanager/ToDoItem.kt b/labs/Lab4_UILabs/app/src/main/java/course/labs/todomanager/ToDoItem.kt new file mode 100644 index 0000000000000000000000000000000000000000..801bf136c6d63ef3c9ed700ff95567c0c6ff79b2 --- /dev/null +++ b/labs/Lab4_UILabs/app/src/main/java/course/labs/todomanager/ToDoItem.kt @@ -0,0 +1,86 @@ +package course.labs.todomanager + +import java.text.ParseException +import java.text.SimpleDateFormat +import java.util.Date +import java.util.Locale + +import android.content.Intent + +class ToDoItem { + + var title = String() + var priority = Priority.LOW + var status = Status.NOTDONE + var date = Date() + + enum class Priority { + LOW, MED, HIGH + } + + enum class Status { + NOTDONE, DONE + } + + internal constructor(title: String, priority: Priority, status: Status, date: Date) { + this.title = title + this.priority = priority + this.status = status + this.date = date + } + + // Create a new ToDoItem from data packaged in an Intent + + internal constructor(intent: Intent) { + + title = intent.getStringExtra(ToDoItem.TITLE) + priority = Priority.valueOf(intent.getStringExtra(ToDoItem.PRIORITY)) + status = Status.valueOf(intent.getStringExtra(ToDoItem.STATUS)) + + try { + date = ToDoItem.FORMAT.parse(intent.getStringExtra(ToDoItem.DATE)) + } catch (e: ParseException) { + date = Date() + } + + } + + override fun toString(): String { + return (title + ITEM_SEP + priority + ITEM_SEP + status + ITEM_SEP + + FORMAT.format(date)) + } + + fun toLog(): String { + return ("Title:" + title + ITEM_SEP + "Priority:" + priority + + ITEM_SEP + "Status:" + status + ITEM_SEP + "Date:" + + FORMAT.format(date) + "\n") + } + + companion object { + + val ITEM_SEP = System.getProperty("line.separator") + + val TITLE = "title" + val PRIORITY = "priority" + val STATUS = "status" + val DATE = "date" + val FILENAME = "filename" + + val FORMAT = SimpleDateFormat( + "yyyy-MM-dd HH:mm:ss", Locale.US) + + // Take a set of String data values and + // package them for transport in an Intent + + fun packageIntent(intent: Intent, title: String, + priority: Priority, status: Status, date: String) { + + intent.putExtra(ToDoItem.TITLE, title) + intent.putExtra(ToDoItem.PRIORITY, priority.toString()) + intent.putExtra(ToDoItem.STATUS, status.toString()) + intent.putExtra(ToDoItem.DATE, date) + + } + } + +} diff --git a/labs/Lab4_UILabs/app/src/main/java/course/labs/todomanager/ToDoListAdapter.kt b/labs/Lab4_UILabs/app/src/main/java/course/labs/todomanager/ToDoListAdapter.kt new file mode 100644 index 0000000000000000000000000000000000000000..9dc4f9e5e24685f45aa05702dd8b33ef06be0867 --- /dev/null +++ b/labs/Lab4_UILabs/app/src/main/java/course/labs/todomanager/ToDoListAdapter.kt @@ -0,0 +1,123 @@ +package course.labs.todomanager + +import java.util.ArrayList + +import android.content.Context +import android.util.Log +import android.view.LayoutInflater +import android.view.View +import android.view.ViewGroup +import android.widget.BaseAdapter +import android.widget.CheckBox +import android.widget.CompoundButton +import android.widget.CompoundButton.OnCheckedChangeListener +import android.widget.RelativeLayout +import android.widget.TextView +import course.labs.todomanager.ToDoItem.Status + +class ToDoListAdapter(private val mContext: Context) : BaseAdapter() { + + private val mItems = ArrayList<ToDoItem>() + + // Add a ToDoItem to the adapter + // Notify observers that the data set has changed + + fun add(item: ToDoItem) { + + mItems.add(item) + notifyDataSetChanged() + + } + + // Clears the list adapter of all items. + + fun clear() { + + mItems.clear() + notifyDataSetChanged() + + } + + // Returns the number of ToDoItems + + override fun getCount(): Int { + + return mItems.size + + } + + // Retrieve the number of ToDoItems + + override fun getItem(pos: Int): Any { + + return mItems[pos] + + } + + // Get the ID for the ToDoItem + // In this case it's just the position + + override fun getItemId(pos: Int): Long { + + return pos.toLong() + + } + + // TODO - Create a View for the ToDoItem at specified position + // Remember to check whether convertView holds an already allocated View + // before created a new View. + // Consider using the ViewHolder pattern to make scrolling more efficient + // See: http://developer.android.com/training/improving-layouts/smooth-scrolling.html + + override fun getView(position: Int, convertView: View?, parent: ViewGroup): View? { + + // TODO - Get the current ToDoItem + + + val viewHolder: ViewHolder + + if (null == convertView) { + + viewHolder = ViewHolder() + + // TODO - Inflate the View for this ToDoItem + + } else { + viewHolder = convertView.tag as ViewHolder + viewHolder.mStatusView!!.setOnCheckedChangeListener(null) + + } + + // TODO - Fill in specific ToDoItem data + // Remember that the data that goes in this View + // corresponds to the user interface elements defined + // in the layout file + + // TODO - Display Title in TextView + + + // TODO - Set up Status CheckBox + + + // TODO - Display Priority in a TextView + + // TODO - Display Time and Date + + return viewHolder.mItemLayout + + } + + internal class ViewHolder { + var position: Int = 0 + var mItemLayout: RelativeLayout? = null + var mTitleView: TextView? = null + var mStatusView: CheckBox? = null + var mPriorityView: TextView? = null + var mDateView: TextView? = null + } + + companion object { + + private val TAG = "Lab-UserInterface" + } +} diff --git a/labs/Lab4_UILabs/app/src/main/java/course/labs/todomanager/ToDoManagerActivity.kt b/labs/Lab4_UILabs/app/src/main/java/course/labs/todomanager/ToDoManagerActivity.kt new file mode 100644 index 0000000000000000000000000000000000000000..31a7f22f94599e7385fec4b3a0377f69b0c4cd2f --- /dev/null +++ b/labs/Lab4_UILabs/app/src/main/java/course/labs/todomanager/ToDoManagerActivity.kt @@ -0,0 +1,189 @@ +package course.labs.todomanager + +import android.app.Activity +import java.io.BufferedReader +import java.io.BufferedWriter +import java.io.FileInputStream +import java.io.FileNotFoundException +import java.io.FileOutputStream +import java.io.IOException +import java.io.InputStreamReader +import java.io.OutputStreamWriter +import java.io.PrintWriter +import java.text.ParseException +import java.util.Date + +import android.app.ListActivity +import android.content.Context +import android.content.Intent +import android.os.Bundle +import android.util.Log +import android.view.LayoutInflater +import android.view.Menu +import android.view.MenuItem +import android.view.View +import android.view.View.OnClickListener +import android.widget.TextView +import course.labs.todomanager.ToDoItem.Priority +import course.labs.todomanager.ToDoItem.Status + +class ToDoManagerActivity : ListActivity() { + + internal lateinit var mAdapter: ToDoListAdapter + + public override fun onCreate(savedInstanceState: Bundle?) { + super.onCreate(savedInstanceState) + + // Create a new TodoListAdapter for this ListActivity's ListView + mAdapter = ToDoListAdapter(applicationContext) + + // Put divider between ToDoItems and FooterView + listView.setFooterDividersEnabled(true) + + // TODO - Inflate footerView for footer_view.xml file + + + // TODO - Add footerView to ListView + + // TODO - Attach Listener to FooterView + + // TODO - Attach the adapter to this ListActivity's ListView + + } + + override fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent?) { + + Log.i(TAG, "Entered onActivityResult()") + + // TODO - Check result code and request code + // if user submitted a new ToDoItem + // Create a new ToDoItem from the data Intent + // and then add it to the adapter + + } + + // Do not modify below here + + public override fun onResume() { + super.onResume() + + // Load saved ToDoItems, if necessary + + if (mAdapter.count == 0) + loadItems() + } + + override fun onPause() { + super.onPause() + + // Save ToDoItems + + saveItems() + + } + + override fun onCreateOptionsMenu(menu: Menu): Boolean { + super.onCreateOptionsMenu(menu) + + menu.add(Menu.NONE, MENU_DELETE, Menu.NONE, "Delete all") + menu.add(Menu.NONE, MENU_DUMP, Menu.NONE, "Dump to log") + return true + } + + override fun onOptionsItemSelected(item: MenuItem): Boolean { + when (item.itemId) { + MENU_DELETE -> { + mAdapter.clear() + return true + } + MENU_DUMP -> { + dump() + return true + } + else -> return super.onOptionsItemSelected(item) + } + } + + fun dump() { + for (i in 0 until mAdapter.count) { + val data = (mAdapter.getItem(i) as ToDoItem).toLog() + Log.i(TAG, + "Item " + i + ": " + data.replace(ToDoItem.ITEM_SEP, ",")) + } + } + + // Load stored ToDoItems + private fun loadItems() { + var reader: BufferedReader? = null + try { + val fis = openFileInput(FILE_NAME) + reader = BufferedReader(InputStreamReader(fis)) + + var title: String? = null + var priority: String? = null + var status: String? = null + var date: Date? = null + + do { + title = reader.readLine(); + if (title == null) + break + priority = reader.readLine() + status = reader.readLine() + date = ToDoItem.FORMAT.parse(reader.readLine()) + mAdapter.add(ToDoItem(title, Priority.valueOf(priority), + Status.valueOf(status), date)) + + } + while (true) + + } catch (e: FileNotFoundException) { + e.printStackTrace() + } catch (e: IOException) { + e.printStackTrace() + } catch (e: ParseException) { + e.printStackTrace() + } finally { + if (null != reader) { + try { + reader.close() + } catch (e: IOException) { + e.printStackTrace() + } + + } + } + } + + // Save ToDoItems to file + private fun saveItems() { + var writer: PrintWriter? = null + try { + val fos = openFileOutput(FILE_NAME, Context.MODE_PRIVATE) + writer = PrintWriter(BufferedWriter(OutputStreamWriter( + fos))) + + for (idx in 0 until mAdapter.count) { + + writer.println(mAdapter.getItem(idx)) + + } + } catch (e: IOException) { + e.printStackTrace() + } finally { + writer?.close() + } + } + + + companion object { + + private val ADD_TODO_ITEM_REQUEST = 0 + private val FILE_NAME = "TodoManagerActivityData.txt" + private val TAG = "Lab-UserInterface" + + // IDs for menu items + private val MENU_DELETE = Menu.FIRST + private val MENU_DUMP = Menu.FIRST + 1 + } +} \ No newline at end of file diff --git a/labs/Lab4_UILabs/app/src/main/res/drawable-hdpi/ic_launcher.png b/labs/Lab4_UILabs/app/src/main/res/drawable-hdpi/ic_launcher.png new file mode 100644 index 0000000000000000000000000000000000000000..0e79b184fcf8cc47dede6d7ccde00d1a1e2d9c23 Binary files /dev/null and b/labs/Lab4_UILabs/app/src/main/res/drawable-hdpi/ic_launcher.png differ diff --git a/labs/Lab4_UILabs/app/src/main/res/drawable-ldpi/ic_launcher.png b/labs/Lab4_UILabs/app/src/main/res/drawable-ldpi/ic_launcher.png new file mode 100644 index 0000000000000000000000000000000000000000..ebfac7d78b9e17c113f734d10af74bd2b100beba Binary files /dev/null and b/labs/Lab4_UILabs/app/src/main/res/drawable-ldpi/ic_launcher.png differ diff --git a/labs/Lab4_UILabs/app/src/main/res/drawable-mdpi/ic_launcher.png b/labs/Lab4_UILabs/app/src/main/res/drawable-mdpi/ic_launcher.png new file mode 100644 index 0000000000000000000000000000000000000000..1183441937efcae0151b75099bec444d034886e9 Binary files /dev/null and b/labs/Lab4_UILabs/app/src/main/res/drawable-mdpi/ic_launcher.png differ diff --git a/labs/Lab4_UILabs/app/src/main/res/drawable-xhdpi/ic_launcher.png b/labs/Lab4_UILabs/app/src/main/res/drawable-xhdpi/ic_launcher.png new file mode 100644 index 0000000000000000000000000000000000000000..c8ab2a114716b712ec0c5122f9e9524afaa60b52 Binary files /dev/null and b/labs/Lab4_UILabs/app/src/main/res/drawable-xhdpi/ic_launcher.png differ diff --git a/labs/Lab4_UILabs/app/src/main/res/layout/add_todo.xml b/labs/Lab4_UILabs/app/src/main/res/layout/add_todo.xml new file mode 100644 index 0000000000000000000000000000000000000000..c20cc47cdbdd8165523074a9cb0be3d5acb4aafd --- /dev/null +++ b/labs/Lab4_UILabs/app/src/main/res/layout/add_todo.xml @@ -0,0 +1,180 @@ +<?xml version="1.0" encoding="utf-8"?> +<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" + android:layout_width="match_parent" + android:layout_height="match_parent" > + + <!-- Title --> + + <TextView + android:id="@+id/TitleLabel" + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:layout_marginTop="8dp" + android:text="@string/title_string" + android:textAppearance="?android:attr/textAppearanceLarge" > + </TextView> + + <EditText + android:id="@+id/title" + android:layout_width="match_parent" + android:layout_height="wrap_content" + android:layout_alignParentLeft="true" + android:layout_below="@+id/TitleLabel" + android:ems="10" + android:hint="@string/enter_title_string" + android:inputType="textShortMessage" > + + <requestFocus /> + </EditText> + + <!-- Status --> + + <TextView + android:id="@+id/status" + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:layout_alignParentLeft="true" + android:layout_below="@+id/title" + android:layout_marginTop="8dp" + android:text="@string/status_string" + android:textAppearance="?android:attr/textAppearanceLarge" /> + + <RadioGroup + android:id="@+id/statusGroup" + android:layout_width="match_parent" + android:layout_height="wrap_content" + android:layout_alignParentLeft="true" + android:layout_below="@id/status" + android:orientation="horizontal" > + + <RadioButton + android:id="@+id/statusDone" + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:text="@string/done_string" /> + + <RadioButton + android:id="@+id/statusNotDone" + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:checked="true" + android:text="@string/not_done_string" /> + </RadioGroup> + + <!-- Priority --> + + <TextView + android:id="@+id/priority" + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:layout_alignParentLeft="true" + android:layout_below="@id/statusGroup" + android:layout_marginTop="8dp" + android:text="@string/priority_string" + android:textAppearance="?android:attr/textAppearanceLarge" /> + + <RadioGroup + android:id="@+id/priorityGroup" + android:layout_width="match_parent" + android:layout_height="wrap_content" + android:layout_alignParentLeft="true" + android:layout_below="@id/priority" + android:orientation="horizontal" + android:text="@string/priority_string" > + + <RadioButton + android:id="@+id/lowPriority" + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:text="@string/priority_low_string" /> + + <RadioButton + android:id="@+id/medPriority" + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:checked="true" + android:text="@string/priority_medium_string" /> + + <RadioButton + android:id="@+id/highPriority" + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:text="@string/priority_high_string" /> + </RadioGroup> + + <!-- Time and Date --> + + <TextView + android:id="@+id/time_and_date" + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:layout_alignParentLeft="true" + android:layout_below="@id/priorityGroup" + android:layout_marginTop="8dp" + android:text="@string/time_and_date_string" + android:textAppearance="?android:attr/textAppearanceLarge" /> + + <TextView + android:id="@+id/date" + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:layout_alignParentLeft="true" + android:layout_below="@+id/time_and_date" + android:layout_marginTop="8dp" + android:text="@string/no_date_set_string" /> + + <TextView + android:id="@+id/time" + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:layout_alignParentRight="true" + android:layout_below="@+id/time_and_date" + android:layout_marginTop="8dp" + android:text="@string/no_time_set_string" /> + + <Button + android:id="@+id/date_picker_button" + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:layout_alignParentLeft="true" + android:layout_marginTop="8dp" + android:layout_below="@id/date" + android:text="@string/choose_date_string" /> + + <Button + android:id="@+id/time_picker_button" + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:layout_alignParentRight="true" + android:layout_alignTop="@id/date_picker_button" + android:layout_below="@id/time" + android:layout_marginTop="8dp" + android:text="@string/choose_time_string" /> + + <!-- Buttons --> + + <Button + android:id="@+id/cancelButton" + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:layout_alignParentBottom="true" + android:layout_alignParentLeft="true" + android:text="@string/cancel_string" /> + + <Button + android:id="@+id/resetButton" + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:layout_alignParentBottom="true" + android:layout_centerHorizontal="true" + android:text="@string/reset_string" /> + + <Button + android:id="@+id/submitButton" + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:layout_alignParentBottom="true" + android:layout_alignParentRight="true" + android:text="@string/submit_string" /> + +</RelativeLayout> \ No newline at end of file diff --git a/labs/Lab4_UILabs/app/src/main/res/layout/footer_view.xml b/labs/Lab4_UILabs/app/src/main/res/layout/footer_view.xml new file mode 100644 index 0000000000000000000000000000000000000000..311856f59340671e8a5173c8b67ce76c344c919e --- /dev/null +++ b/labs/Lab4_UILabs/app/src/main/res/layout/footer_view.xml @@ -0,0 +1,10 @@ +<?xml version="1.0" encoding="utf-8"?> +<TextView xmlns:android="http://schemas.android.com/apk/res/android" + android:id="@+id/footerView" + android:layout_width="match_parent" + android:layout_height="wrap_content" + android:gravity="center_horizontal" + android:text="@string/add_new_todo_item_string" + android:textSize="24sp" > + +</TextView> \ No newline at end of file diff --git a/labs/Lab4_UILabs/app/src/main/res/layout/todo_item.xml b/labs/Lab4_UILabs/app/src/main/res/layout/todo_item.xml new file mode 100644 index 0000000000000000000000000000000000000000..44ef9fcf470283d7f30cd5a895fd5eaf4842f24b --- /dev/null +++ b/labs/Lab4_UILabs/app/src/main/res/layout/todo_item.xml @@ -0,0 +1,73 @@ +<?xml version="1.0" encoding="utf-8"?> +<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" + android:id="@+id/RelativeLayout1" + android:layout_width="match_parent" + android:layout_height="match_parent" + android:orientation="vertical" > + + <TextView + android:id="@+id/titleView" + android:layout_width="match_parent" + android:layout_height="wrap_content" + android:layout_alignParentLeft="true" + android:layout_alignParentTop="true" + android:textAppearance="?android:attr/textAppearanceLarge" > + </TextView> + + <TextView + android:id="@+id/StatusLabel" + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:layout_alignBaseline="@+id/statusCheckBox" + android:layout_alignParentLeft="true" + android:layout_alignParentTop="true" + android:layout_marginTop="17dp" + android:text="@string/done_string" > + </TextView> + + <CheckBox + android:id="@+id/statusCheckBox" + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:layout_alignParentTop="true" + android:layout_marginTop="52dp" + android:layout_toRightOf="@+id/StatusLabel" > + </CheckBox> + + <TextView + android:id="@+id/PriorityLabel" + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:layout_alignBaseline="@+id/statusCheckBox" + android:layout_alignTop="@+id/StatusLabel" + android:layout_toLeftOf="@+id/priorityView" + android:text="@string/priority_string" > + </TextView> + + <TextView + android:id="@+id/priorityView" + android:layout_width="50dip" + android:layout_height="wrap_content" + android:layout_alignBaseline="@+id/statusCheckBox" + android:layout_alignParentRight="true" + android:layout_alignTop="@+id/StatusLabel" > + </TextView> + + <TextView + android:id="@+id/DateLabel" + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:layout_alignParentLeft="true" + android:layout_below="@+id/statusCheckBox" + android:text="@string/date_string" > + </TextView> + + <TextView + android:id="@+id/dateView" + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:layout_alignBaseline="@+id/DateLabel" + android:layout_toRightOf="@+id/DateLabel" > + </TextView> + +</RelativeLayout> \ No newline at end of file diff --git a/labs/Lab4_UILabs/app/src/main/res/values-sw600dp/dimens.xml b/labs/Lab4_UILabs/app/src/main/res/values-sw600dp/dimens.xml new file mode 100644 index 0000000000000000000000000000000000000000..44f01db75f0fef18081132a9e86517f8d5efa8f6 --- /dev/null +++ b/labs/Lab4_UILabs/app/src/main/res/values-sw600dp/dimens.xml @@ -0,0 +1,8 @@ +<resources> + + <!-- + Customize dimensions originally defined in res/values/dimens.xml (such as + screen margins) for sw600dp devices (e.g. 7" tablets) here. + --> + +</resources> diff --git a/labs/Lab4_UILabs/app/src/main/res/values-sw720dp-land/dimens.xml b/labs/Lab4_UILabs/app/src/main/res/values-sw720dp-land/dimens.xml new file mode 100644 index 0000000000000000000000000000000000000000..d3a17b7ac019232caa63d0b0849f42f43be32646 --- /dev/null +++ b/labs/Lab4_UILabs/app/src/main/res/values-sw720dp-land/dimens.xml @@ -0,0 +1,8 @@ +<resources> + + <!-- + Customize dimensions originally defined in res/values/dimens.xml (such as + screen margins) for sw720dp devices (e.g. 10" tablets) in landscape here. + --> + +</resources> diff --git a/labs/Lab4_UILabs/app/src/main/res/values/dimens.xml b/labs/Lab4_UILabs/app/src/main/res/values/dimens.xml new file mode 100644 index 0000000000000000000000000000000000000000..0e9ce62a515ae5d1c761ff9bbad6b8291a65da36 --- /dev/null +++ b/labs/Lab4_UILabs/app/src/main/res/values/dimens.xml @@ -0,0 +1,5 @@ +<resources> + + <!-- Default screen margins, per the Android Design guidelines. --> + +</resources> diff --git a/labs/Lab4_UILabs/app/src/main/res/values/strings.xml b/labs/Lab4_UILabs/app/src/main/res/values/strings.xml new file mode 100644 index 0000000000000000000000000000000000000000..a6e324c6d983b4ff744f859a1fdeced4bd1b6897 --- /dev/null +++ b/labs/Lab4_UILabs/app/src/main/res/values/strings.xml @@ -0,0 +1,24 @@ +<?xml version="1.0" encoding="utf-8"?> +<resources> + <string name="app_name">UILabs</string> + <string name="done_string">Done:</string> + <string name="priority_string">Priority:</string> + <string name="date_string">Date:</string> + <string name="add_new_todo_item_string">Add New ToDo Item</string> + <string name="title_string">Title</string> + <string name="status_string">Status</string> + <string name="not_done_string">Not Done</string> + <string name="priority_low_string">Low</string> + <string name="priority_medium_string">Medium</string> + <string name="priority_high_string">High</string> + <string name="time_and_date_string">Time and Date</string> + <string name="no_date_set_string">0000–00–00</string> + <string name="no_time_set_string">00:00:00</string> + <string name="choose_date_string">Choose Date</string> + <string name="choose_time_string">Choose Time</string> + <string name="cancel_string">Cancel</string> + <string name="reset_string">Reset</string> + <string name="submit_string">Submit</string> + <string name="enter_title_string">Enter Title</string> + +</resources> diff --git a/labs/Lab4_UILabs/build.gradle b/labs/Lab4_UILabs/build.gradle new file mode 100644 index 0000000000000000000000000000000000000000..fde343b06a3fd82c93354eb609a9e5ec8148bb02 --- /dev/null +++ b/labs/Lab4_UILabs/build.gradle @@ -0,0 +1,18 @@ +// 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:3.1.4' + classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version" + } +} + +allprojects { + repositories { + jcenter() + } +} diff --git a/labs/Lab4_UILabs/gradle/wrapper/gradle-wrapper.jar b/labs/Lab4_UILabs/gradle/wrapper/gradle-wrapper.jar new file mode 100644 index 0000000000000000000000000000000000000000..13372aef5e24af05341d49695ee84e5f9b594659 Binary files /dev/null and b/labs/Lab4_UILabs/gradle/wrapper/gradle-wrapper.jar differ diff --git a/labs/Lab4_UILabs/gradle/wrapper/gradle-wrapper.properties b/labs/Lab4_UILabs/gradle/wrapper/gradle-wrapper.properties new file mode 100644 index 0000000000000000000000000000000000000000..4c568d1e0ba22aef3b2a20a1387f06f7cbb6bbff --- /dev/null +++ b/labs/Lab4_UILabs/gradle/wrapper/gradle-wrapper.properties @@ -0,0 +1,6 @@ +#Mon Sep 24 19:29:38 EDT 2018 +distributionBase=GRADLE_USER_HOME +distributionPath=wrapper/dists +zipStoreBase=GRADLE_USER_HOME +zipStorePath=wrapper/dists +distributionUrl=https\://services.gradle.org/distributions/gradle-4.4-all.zip diff --git a/labs/Lab4_UILabs/gradlew b/labs/Lab4_UILabs/gradlew new file mode 100755 index 0000000000000000000000000000000000000000..9d82f78915133e1c35a6ea51252590fb38efac2f --- /dev/null +++ b/labs/Lab4_UILabs/gradlew @@ -0,0 +1,160 @@ +#!/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 + +# Attempt to set APP_HOME +# Resolve links: $0 may be a link +PRG="$0" +# Need this for relative symlinks. +while [ -h "$PRG" ] ; do + ls=`ls -ld "$PRG"` + link=`expr "$ls" : '.*-> \(.*\)$'` + if expr "$link" : '/.*' > /dev/null; then + PRG="$link" + else + PRG=`dirname "$PRG"`"/$link" + fi +done +SAVED="`pwd`" +cd "`dirname \"$PRG\"`/" >/dev/null +APP_HOME="`pwd -P`" +cd "$SAVED" >/dev/null + +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"` + JAVACMD=`cygpath --unix "$JAVACMD"` + + # We build the pattern for arguments to be converted via cygpath + ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null` + SEP="" + for dir in $ROOTDIRSRAW ; do + ROOTDIRS="$ROOTDIRS$SEP$dir" + SEP="|" + done + OURCYGPATTERN="(^($ROOTDIRS))" + # Add a user-defined pattern to the cygpath arguments + if [ "$GRADLE_CYGPATTERN" != "" ] ; then + OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)" + fi + # Now convert the arguments - kludge to limit ourselves to /bin/sh + i=0 + for arg in "$@" ; do + CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -` + CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option + + if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition + eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"` + else + eval `echo args$i`="\"$arg\"" + fi + i=$((i+1)) + done + case $i in + (0) set -- ;; + (1) set -- "$args0" ;; + (2) set -- "$args0" "$args1" ;; + (3) set -- "$args0" "$args1" "$args2" ;; + (4) set -- "$args0" "$args1" "$args2" "$args3" ;; + (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;; + (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;; + (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;; + (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;; + (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;; + esac +fi + +# 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/Lab4_UILabs/gradlew.bat b/labs/Lab4_UILabs/gradlew.bat new file mode 100644 index 0000000000000000000000000000000000000000..8a0b282aa6885fb573c106b3551f7275c5f17e8e --- /dev/null +++ b/labs/Lab4_UILabs/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/Lab4_UILabs/settings.gradle b/labs/Lab4_UILabs/settings.gradle new file mode 100644 index 0000000000000000000000000000000000000000..e7b4def49cb53d9aa04228dd3edb14c9e635e003 --- /dev/null +++ b/labs/Lab4_UILabs/settings.gradle @@ -0,0 +1 @@ +include ':app'