diff --git a/Lab4_UILabs/.gitignore b/Lab4_UILabs/.gitignore new file mode 100644 index 0000000000000000000000000000000000000000..ceff37eff0e621e8f96607f26a6bced4727fb5a5 --- /dev/null +++ b/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/Lab4_UILabs/Lab-UserInterface.pdf b/Lab4_UILabs/Lab-UserInterface.pdf new file mode 100644 index 0000000000000000000000000000000000000000..5258d7e495c0828074387f653193885e6f712f38 Binary files /dev/null and b/Lab4_UILabs/Lab-UserInterface.pdf differ diff --git a/Lab4_UILabs/UILabs.mp4 b/Lab4_UILabs/UILabs.mp4 new file mode 100755 index 0000000000000000000000000000000000000000..f7422b83694bc475a7675a877832b13021aa8471 Binary files /dev/null and b/Lab4_UILabs/UILabs.mp4 differ diff --git a/Lab4_UILabs/app/build.gradle b/Lab4_UILabs/app/build.gradle new file mode 100644 index 0000000000000000000000000000000000000000..5b0cc2952589942e33ff270f88d606bf8b2e5959 --- /dev/null +++ b/Lab4_UILabs/app/build.gradle @@ -0,0 +1,26 @@ +apply plugin: 'com.android.application' + +android { + compileSdkVersion 26 + buildToolsVersion "26.0.1" + + 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 { + androidTestCompile 'com.jayway.android.robotium:robotium-solo:5.6.3' +} diff --git a/Lab4_UILabs/app/src/androidTest/java/course/labs/todomanager/tests/Test1_SubmitTest.java b/Lab4_UILabs/app/src/androidTest/java/course/labs/todomanager/tests/Test1_SubmitTest.java new file mode 100644 index 0000000000000000000000000000000000000000..7d6627222508fd00e09b266a3dda6ff3e3dc9a49 --- /dev/null +++ b/Lab4_UILabs/app/src/androidTest/java/course/labs/todomanager/tests/Test1_SubmitTest.java @@ -0,0 +1,101 @@ +package course.labs.todomanager.tests; + +import android.test.ActivityInstrumentationTestCase2; + +import com.robotium.solo.Solo; + +import course.labs.todomanager.ToDoManagerActivity; + +public class Test1_SubmitTest extends + ActivityInstrumentationTestCase2<ToDoManagerActivity> { + + private Solo solo; + + public Test1_SubmitTest() { + super(ToDoManagerActivity.class); + } + + protected void setUp() throws Exception { + solo = new Solo(getInstrumentation(), getActivity()); + } + + protected void tearDown() throws Exception { + solo.finishOpenedActivities(); + } + + // Execute the SubmitTest + public void testRun() { + + int delay = 2000; + + // ============= Section One =============== + // Wait for activity: 'course.labs.todomanager.ToDoManagerActivity' + assertTrue( + "SubmitTest failed:" + "Section One:" + + "ToDoManagerActivity did not load correctly.", + solo.waitForActivity(course.labs.todomanager.ToDoManagerActivity.class)); + + // Click on action bar item to delete all items + solo.clickOnActionBarItem(0x1); + + solo.sleep(delay); + + // Get footer view + 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' + assertTrue( + "Submit Test failed:" + "Section One:" + + "AddToDoActivity did not correctly load.", + solo.waitForActivity(course.labs.todomanager.AddToDoActivity.class)); + + // Hide the soft keyboard + solo.hideSoftKeyboard(); + + // Enter the text: 't4' + solo.clearEditText((android.widget.EditText) solo + .getView(course.labs.todomanager.R.id.title)); + + solo.enterText((android.widget.EditText) solo + .getView(course.labs.todomanager.R.id.title), "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' + assertTrue( + "SubmitTest failed:" + + "Section Two:" + + "ToDoManagerActivity did not load correctly after pressing submit.", + solo.waitForActivity(course.labs.todomanager.ToDoManagerActivity.class)); + + assertTrue("SubmitTest failed:" + "Section Two:" + + "Title was not correctly entered in the ToDoManager", + solo.searchText("t4")); + + assertTrue("SubmitTest failed:" + "Section Two:" + + "Priority was not correctly entered in the ToDoManager", + solo.searchText("[lL][oO][wW]")); + + assertTrue("SubmitTest failed:" + "Section Two:" + + "Did not correctly set completion status.", + solo.isCheckBoxChecked(0)); + + } + +} diff --git a/Lab4_UILabs/app/src/androidTest/java/course/labs/todomanager/tests/Test2_DateTimeTest.java b/Lab4_UILabs/app/src/androidTest/java/course/labs/todomanager/tests/Test2_DateTimeTest.java new file mode 100644 index 0000000000000000000000000000000000000000..d7fcffa02c3a04ccc13a998b57d60465ca3de44c --- /dev/null +++ b/Lab4_UILabs/app/src/androidTest/java/course/labs/todomanager/tests/Test2_DateTimeTest.java @@ -0,0 +1,144 @@ +package course.labs.todomanager.tests; + +import android.test.ActivityInstrumentationTestCase2; + +import com.robotium.solo.Solo; + +import course.labs.todomanager.ToDoManagerActivity; + +public class Test2_DateTimeTest extends + ActivityInstrumentationTestCase2<ToDoManagerActivity> { + + private Solo solo; + + public Test2_DateTimeTest() { + super(ToDoManagerActivity.class); + } + + protected void setUp() throws Exception { + solo = new Solo(getInstrumentation()); + getActivity(); + } + + protected void tearDown() throws Exception { + solo.finishOpenedActivities(); + } + + // Executes DateTimeTest + public void testRun() { + + int delay = 2000; + + // ============== Section One ================ + + // Wait for activity: 'course.labs.todomanager.ToDoManagerActivity' + assertTrue( + "DateTimeTest failed:" + "Section One:" + + "ToDoManagerActivity did not correctly load.", + solo.waitForActivity(course.labs.todomanager.ToDoManagerActivity.class)); + + // Click on action bar item to delete all items + solo.clickOnActionBarItem(0x1); + + solo.sleep(delay); + + // Get footer view + 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' + assertTrue( + "DateTimeTest failed:" + "Section One:" + + "AddToDoActivity did not correctly load.", + solo.waitForActivity(course.labs.todomanager.AddToDoActivity.class)); + + // Hide the soft keyboard + solo.hideSoftKeyboard(); + + // Enter the text: 't1' + solo.clearEditText((android.widget.EditText) solo + .getView(course.labs.todomanager.R.id.title)); + + solo.enterText((android.widget.EditText) solo + .getView(course.labs.todomanager.R.id.title), "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' + assertTrue( + "DateTimeTest failed:" + "Section One:" + + "ToDoManagerActivity did not load correctly", + solo.waitForActivity(course.labs.todomanager.ToDoManagerActivity.class)); + + // ============== Section Two ============= + + // Makes sure the title was changed correctly + assertTrue("DateTimeTest failed:" + "Section Two:" + + "Did not modify title correctly", solo.searchText("t1")); + + // Checks to see if the status was changed correctly + assertTrue("DateTimeTest failed:" + "Section Two:" + + "Did not change status correctly", solo.isCheckBoxChecked(0)); + + // Checks to make sure the priority was correctly set + assertTrue("DateTimeTest failed:" + "Section Two:" + + "Did not correctly set priority", + solo.searchText("[lL][oO][wW]")); + + // Checks to make sure the Date was correctly set + 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 + 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/Lab4_UILabs/app/src/androidTest/java/course/labs/todomanager/tests/Test3_CancelTest.java b/Lab4_UILabs/app/src/androidTest/java/course/labs/todomanager/tests/Test3_CancelTest.java new file mode 100644 index 0000000000000000000000000000000000000000..583243f01549b5effdb172de31e12fe2cd27d941 --- /dev/null +++ b/Lab4_UILabs/app/src/androidTest/java/course/labs/todomanager/tests/Test3_CancelTest.java @@ -0,0 +1,140 @@ +package course.labs.todomanager.tests; + +import android.test.ActivityInstrumentationTestCase2; + +import com.robotium.solo.Solo; + +import course.labs.todomanager.ToDoManagerActivity; + +public class Test3_CancelTest extends + ActivityInstrumentationTestCase2<ToDoManagerActivity> { + private Solo solo; + + public Test3_CancelTest() { + super(ToDoManagerActivity.class); + } + + public void setUp() throws Exception { + solo = new Solo(getInstrumentation(), getActivity()); + } + + @Override + public void tearDown() throws Exception { + solo.finishOpenedActivities(); + } + + // Executes the CancelTest + public void testRun() { + + int delay = 2000; + + // Wait for activity: 'course.labs.todomanager.ToDoManagerActivity' + assertTrue( + "CancelTest failed:" + "Section One:" + + "ToDoManagerActivity did not load correctly.", + solo.waitForActivity(course.labs.todomanager.ToDoManagerActivity.class)); + + // Click on action bar item + solo.clickOnActionBarItem(0x1); + + solo.sleep(delay); + + // Get footer view + 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' + assertTrue( + "CancelTest failed:" + "Section One:" + + "AddToDoActivity did not load correctly.", + solo.waitForActivity(course.labs.todomanager.AddToDoActivity.class)); + + // Hide the soft keyboard + solo.hideSoftKeyboard(); + + // Enter the text: 't3' + solo.clearEditText((android.widget.EditText) solo + .getView(course.labs.todomanager.R.id.title)); + + solo.enterText((android.widget.EditText) solo + .getView(course.labs.todomanager.R.id.title), "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' + assertTrue( + "Cancel test failed:" + "Section One:" + + "AddToDoActivity did not correctly load.", + solo.waitForActivity(course.labs.todomanager.AddToDoActivity.class)); + + // Click on Add New ToDo Item + solo.clickOnView(solo.getView(course.labs.todomanager.R.id.footerView)); + + // Wait for activity: 'course.labs.todomanager.AddToDoActivity' + assertTrue( + "CancelTest failed:" + "Section One:" + + "AddToDoActivity did not load correctly.", + solo.waitForActivity(course.labs.todomanager.AddToDoActivity.class)); + + // Hide the soft keyboard + solo.hideSoftKeyboard(); + + // Enter the text: 't4' + solo.clearEditText((android.widget.EditText) solo + .getView(course.labs.todomanager.R.id.title)); + + solo.enterText((android.widget.EditText) solo + .getView(course.labs.todomanager.R.id.title), "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' + assertTrue( + "CancelTest failed:" + "Section Two:" + + "ToDoManagerActivity did not load correctly.", + solo.waitForActivity(course.labs.todomanager.ToDoManagerActivity.class)); + + assertFalse("CancelTest failed:" + "Section Two:" + + "Did not correctly cancel the creation of a ToDo Task.", + solo.searchText("t3")); + + assertTrue("CancelTest failed:" + "Section Two:" + + "Did not correctly set title of ToDo Task following cancel.", + solo.searchText("t4")); + + assertTrue( + "CancelTest failed:" + + "Section Two:" + + "Did not correctly set priority of ToDo Task following cancel.", + solo.searchText("[lL][oO][wW]")); + + } +} diff --git a/Lab4_UILabs/app/src/androidTest/java/course/labs/todomanager/tests/Test4_ResetTest.java b/Lab4_UILabs/app/src/androidTest/java/course/labs/todomanager/tests/Test4_ResetTest.java new file mode 100644 index 0000000000000000000000000000000000000000..880c082db28a4594285a6b57b4e1d7d64919a6c7 --- /dev/null +++ b/Lab4_UILabs/app/src/androidTest/java/course/labs/todomanager/tests/Test4_ResetTest.java @@ -0,0 +1,120 @@ +package course.labs.todomanager.tests; + +import android.test.ActivityInstrumentationTestCase2; + +import com.robotium.solo.Solo; + +import course.labs.todomanager.ToDoManagerActivity; + +public class Test4_ResetTest extends + ActivityInstrumentationTestCase2<ToDoManagerActivity> { + private Solo solo; + + public Test4_ResetTest() { + super(ToDoManagerActivity.class); + } + + public void setUp() throws Exception { + solo = new Solo(getInstrumentation(), getActivity()); + } + + @Override + public void tearDown() throws Exception { + solo.finishOpenedActivities(); + } + + // Executes the ResetTest + public void testRun() { + + int delay = 2000; + + // ============= Section One ============== + // Wait for activity: 'course.labs.todomanager.ToDoManagerActivity' + assertTrue( + "ResetTest failed:" + "Section One:" + + "ToDoManagerActivity did not correctly load.", + solo.waitForActivity(course.labs.todomanager.ToDoManagerActivity.class)); + + // Click on action bar item + solo.clickOnActionBarItem(0x1); + + solo.sleep(delay); + + // Get footer view + 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' + assertTrue( + "ResetTest failed:" + "Section One:" + + "AddToDoActivity did not correctly load.", + solo.waitForActivity(course.labs.todomanager.AddToDoActivity.class)); + + // Hide the soft keyboard + solo.hideSoftKeyboard(); + + // Enter the text: 't2' + solo.clearEditText((android.widget.EditText) solo + .getView(course.labs.todomanager.R.id.title)); + + solo.enterText((android.widget.EditText) solo + .getView(course.labs.todomanager.R.id.title), "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' + assertTrue( + "ResetTest failed:" + "Section Two:" + + "AddToDoActivity did not correctly load.", + solo.waitForActivity(course.labs.todomanager.AddToDoActivity.class)); + + 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 + 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 + 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 + 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/Lab4_UILabs/app/src/androidTest/res/drawable/.gitignore b/Lab4_UILabs/app/src/androidTest/res/drawable/.gitignore new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git a/Lab4_UILabs/app/src/main/AndroidManifest.xml b/Lab4_UILabs/app/src/main/AndroidManifest.xml new file mode 100644 index 0000000000000000000000000000000000000000..e5b11df3179c1772022fc4094b0563131406cc2f --- /dev/null +++ b/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/Lab4_UILabs/app/src/main/java/course/labs/todomanager/AddToDoActivity.java b/Lab4_UILabs/app/src/main/java/course/labs/todomanager/AddToDoActivity.java new file mode 100644 index 0000000000000000000000000000000000000000..f7b8d5aa74f13ebe5216b75faad41f8f76155207 --- /dev/null +++ b/Lab4_UILabs/app/src/main/java/course/labs/todomanager/AddToDoActivity.java @@ -0,0 +1,261 @@ +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; + +public class AddToDoActivity extends Activity { + + // 7 days in milliseconds - 7 * 24 * 60 * 60 * 1000 + private static final int SEVEN_DAYS = 604800000; + + private static final String TAG = "Lab-UserInterface"; + + private static String timeString; + private static String dateString; + private static TextView dateView; + private static TextView timeView; + + private Date mDate; + private RadioGroup mPriorityRadioGroup; + private RadioGroup mStatusRadioGroup; + private EditText mTitleText; + private RadioButton mDefaultStatusButton; + private RadioButton mDefaultPriorityButton; + + @Override + protected void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + setContentView(R.layout.add_todo); + + mTitleText = (EditText) findViewById(R.id.title); + mDefaultStatusButton = (RadioButton) findViewById(R.id.statusNotDone); + mDefaultPriorityButton = (RadioButton) findViewById(R.id.medPriority); + mPriorityRadioGroup = (RadioGroup) findViewById(R.id.priorityGroup); + mStatusRadioGroup = (RadioGroup) findViewById(R.id.statusGroup); + dateView = (TextView) findViewById(R.id.date); + timeView = (TextView) findViewById(R.id.time); + + // Set the default date and time + + setDefaultDateTime(); + + // OnClickListener for the Date button, calls showDatePickerDialog() to + // show + // the Date dialog + + final Button datePickerButton = (Button) findViewById(R.id.date_picker_button); + datePickerButton.setOnClickListener(new OnClickListener() { + + @Override + public void onClick(View v) { + showDatePickerDialog(); + } + }); + + // OnClickListener for the Time button, calls showTimePickerDialog() to + // show + // the Time Dialog + + final Button timePickerButton = (Button) findViewById(R.id.time_picker_button); + timePickerButton.setOnClickListener(new OnClickListener() { + + @Override + public void onClick(View v) { + showTimePickerDialog(); + } + }); + + // OnClickListener for the Cancel Button, + + final Button cancelButton = (Button) findViewById(R.id.cancelButton); + cancelButton.setOnClickListener(new OnClickListener() { + @Override + public void onClick(View v) { + + Log.i(TAG, "Entered cancelButton.OnClickListener.onClick()"); + + + } + }); + + // TODO - Set up OnClickListener for the Reset Button + + + + + // Set up OnClickListener for the Submit Button + + final Button submitButton = (Button) findViewById(R.id.submitButton); + submitButton.setOnClickListener(new OnClickListener() { + @Override + public void onClick(View v) { + Log.i(TAG, "Entered submitButton.OnClickListener.onClick()"); + + // TODO - gather ToDoItem data + + + + // TODO - return data Intent and finish + + + } + }); + } + + private void setDefaultDateTime() { + + // Default is current time + 7 days + mDate = new Date(); + mDate = new Date(mDate.getTime() + SEVEN_DAYS); + + Calendar c = Calendar.getInstance(); + c.setTime(mDate); + + setDateString(c.get(Calendar.YEAR), c.get(Calendar.MONTH), + c.get(Calendar.DAY_OF_MONTH)); + + dateView.setText(dateString); + + setTimeString(c.get(Calendar.HOUR_OF_DAY), c.get(Calendar.MINUTE), + c.get(Calendar.MILLISECOND)); + + timeView.setText(timeString); + } + + private static void setDateString(int year, int monthOfYear, int dayOfMonth) { + + // Increment monthOfYear for Calendar/Date -> Time Format setting + monthOfYear++; + String mon = "" + monthOfYear; + String day = "" + dayOfMonth; + + if (monthOfYear < 10) + mon = "0" + monthOfYear; + if (dayOfMonth < 10) + day = "0" + dayOfMonth; + + dateString = year + "-" + mon + "-" + day; + } + + private static void setTimeString(int hourOfDay, int minute, int mili) { + String hour = "" + hourOfDay; + String min = "" + minute; + + if (hourOfDay < 10) + hour = "0" + hourOfDay; + if (minute < 10) + min = "0" + minute; + + timeString = hour + ":" + min + ":00"; + } + + private Priority getPriority() { + + switch (mPriorityRadioGroup.getCheckedRadioButtonId()) { + case R.id.lowPriority: { + return Priority.LOW; + } + case R.id.highPriority: { + return Priority.HIGH; + } + default: { + return Priority.MED; + } + } + } + + private Status getStatus() { + + switch (mStatusRadioGroup.getCheckedRadioButtonId()) { + case R.id.statusDone: { + return Status.DONE; + } + default: { + return Status.NOTDONE; + } + } + } + + // DialogFragment used to pick a ToDoItem deadline date + + public static class DatePickerFragment extends DialogFragment implements + DatePickerDialog.OnDateSetListener { + + @Override + public Dialog onCreateDialog(Bundle savedInstanceState) { + + // Use the current date as the default date in the picker + + final Calendar c = Calendar.getInstance(); + int year = c.get(Calendar.YEAR); + int month = c.get(Calendar.MONTH); + int day = c.get(Calendar.DAY_OF_MONTH); + + // Create a new instance of DatePickerDialog and return it + return new DatePickerDialog(getActivity(), this, year, month, day); + } + + @Override + public void onDateSet(DatePicker view, int year, int monthOfYear, + int dayOfMonth) { + setDateString(year, monthOfYear, dayOfMonth); + + dateView.setText(dateString); + } + + } + + // DialogFragment used to pick a ToDoItem deadline time + + public static class TimePickerFragment extends DialogFragment implements + TimePickerDialog.OnTimeSetListener { + + @Override + public Dialog onCreateDialog(Bundle savedInstanceState) { + + // Use the current time as the default values for the picker + final Calendar c = Calendar.getInstance(); + int hour = c.get(Calendar.HOUR_OF_DAY); + int minute = c.get(Calendar.MINUTE); + + // Create a new instance of TimePickerDialog and return + return new TimePickerDialog(getActivity(), this, hour, minute, true); + } + + public void onTimeSet(TimePicker view, int hourOfDay, int minute) { + setTimeString(hourOfDay, minute, 0); + + timeView.setText(timeString); + } + } + + private void showDatePickerDialog() { + DialogFragment newFragment = new DatePickerFragment(); + newFragment.show(getFragmentManager(), "datePicker"); + } + + private void showTimePickerDialog() { + DialogFragment newFragment = new TimePickerFragment(); + newFragment.show(getFragmentManager(), "timePicker"); + } +} diff --git a/Lab4_UILabs/app/src/main/java/course/labs/todomanager/ToDoItem.java b/Lab4_UILabs/app/src/main/java/course/labs/todomanager/ToDoItem.java new file mode 100644 index 0000000000000000000000000000000000000000..bd63cd30dd51bb1219cc40b764a6a95c0ab07f88 --- /dev/null +++ b/Lab4_UILabs/app/src/main/java/course/labs/todomanager/ToDoItem.java @@ -0,0 +1,114 @@ +package course.labs.todomanager; + +import java.text.ParseException; +import java.text.SimpleDateFormat; +import java.util.Date; +import java.util.Locale; + +import android.content.Intent; + +public class ToDoItem { + + public static final String ITEM_SEP = System.getProperty("line.separator"); + + public enum Priority { + LOW, MED, HIGH + }; + + public enum Status { + NOTDONE, DONE + }; + + public final static String TITLE = "title"; + public final static String PRIORITY = "priority"; + public final static String STATUS = "status"; + public final static String DATE = "date"; + public final static String FILENAME = "filename"; + + public final static SimpleDateFormat FORMAT = new SimpleDateFormat( + "yyyy-MM-dd HH:mm:ss", Locale.US); + + private String mTitle = new String(); + private Priority mPriority = Priority.LOW; + private Status mStatus = Status.NOTDONE; + private Date mDate = new Date(); + + ToDoItem(String title, Priority priority, Status status, Date date) { + this.mTitle = title; + this.mPriority = priority; + this.mStatus = status; + this.mDate = date; + } + + // Create a new ToDoItem from data packaged in an Intent + + ToDoItem(Intent intent) { + + mTitle = intent.getStringExtra(ToDoItem.TITLE); + mPriority = Priority.valueOf(intent.getStringExtra(ToDoItem.PRIORITY)); + mStatus = Status.valueOf(intent.getStringExtra(ToDoItem.STATUS)); + + try { + mDate = ToDoItem.FORMAT.parse(intent.getStringExtra(ToDoItem.DATE)); + } catch (ParseException e) { + mDate = new Date(); + } + } + + public String getTitle() { + return mTitle; + } + + public void setTitle(String title) { + mTitle = title; + } + + public Priority getPriority() { + return mPriority; + } + + public void setPriority(Priority priority) { + mPriority = priority; + } + + public Status getStatus() { + return mStatus; + } + + public void setStatus(Status status) { + mStatus = status; + } + + public Date getDate() { + return mDate; + } + + public void setDate(Date date) { + mDate = date; + } + + // Take a set of String data values and + // package them for transport in an Intent + + public static void packageIntent(Intent intent, String title, + Priority priority, Status status, String date) { + + intent.putExtra(ToDoItem.TITLE, title); + intent.putExtra(ToDoItem.PRIORITY, priority.toString()); + intent.putExtra(ToDoItem.STATUS, status.toString()); + intent.putExtra(ToDoItem.DATE, date); + + } + + public String toString() { + return mTitle + ITEM_SEP + mPriority + ITEM_SEP + mStatus + ITEM_SEP + + FORMAT.format(mDate); + } + + public String toLog() { + return "Title:" + mTitle + ITEM_SEP + "Priority:" + mPriority + + ITEM_SEP + "Status:" + mStatus + ITEM_SEP + "Date:" + + FORMAT.format(mDate) + "\n"; + } + +} diff --git a/Lab4_UILabs/app/src/main/java/course/labs/todomanager/ToDoListAdapter.java b/Lab4_UILabs/app/src/main/java/course/labs/todomanager/ToDoListAdapter.java new file mode 100644 index 0000000000000000000000000000000000000000..55ff26ce6b10958cbcaeac2db7c08f0e10c86b4e --- /dev/null +++ b/Lab4_UILabs/app/src/main/java/course/labs/todomanager/ToDoListAdapter.java @@ -0,0 +1,102 @@ +package course.labs.todomanager; + +import java.util.ArrayList; +import java.util.List; + +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; + +public class ToDoListAdapter extends BaseAdapter { + + private final List<ToDoItem> mItems = new ArrayList<ToDoItem>(); + private final Context mContext; + + private static final String TAG = "Lab-UserInterface"; + + public ToDoListAdapter(Context context) { + + mContext = context; + + } + + // Add a ToDoItem to the adapter + // Notify observers that the data set has changed + + public void add(ToDoItem item) { + + mItems.add(item); + notifyDataSetChanged(); + + } + + // Clears the list adapter of all items. + + public void clear() { + + mItems.clear(); + notifyDataSetChanged(); + + } + + // Returns the number of ToDoItems + + @Override + public int getCount() { + + return mItems.size(); + + } + + // Retrieve the number of ToDoItems + + @Override + public Object getItem(int pos) { + + return mItems.get(pos); + + } + + // Get the ID for the ToDoItem + // In this case it's just the position + + @Override + public long getItemId(int pos) { + + return pos; + + } + + // 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 + public View getView(int position, View convertView, ViewGroup parent) { + + + + + + } + + static class ViewHolder { + int position; + RelativeLayout mItemLayout; + TextView mTitleView; + CheckBox mStatusView; + TextView mPriorityView; + TextView mDateView; + } +} diff --git a/Lab4_UILabs/app/src/main/java/course/labs/todomanager/ToDoManagerActivity.java b/Lab4_UILabs/app/src/main/java/course/labs/todomanager/ToDoManagerActivity.java new file mode 100644 index 0000000000000000000000000000000000000000..2b59e34600ae5c3c4f9b54d536fcd9c9f1a10bb8 --- /dev/null +++ b/Lab4_UILabs/app/src/main/java/course/labs/todomanager/ToDoManagerActivity.java @@ -0,0 +1,188 @@ +package course.labs.todomanager; + +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.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; + +public class ToDoManagerActivity extends ListActivity { + + private static final int ADD_TODO_ITEM_REQUEST = 0; + private static final String FILE_NAME = "TodoManagerActivityData.txt"; + private static final String TAG = "Lab-UserInterface"; + + // IDs for menu items + private static final int MENU_DELETE = Menu.FIRST; + private static final int MENU_DUMP = Menu.FIRST + 1; + + ToDoListAdapter mAdapter; + + @Override + public void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + + // Create a new TodoListAdapter for this ListActivity's ListView + mAdapter = new ToDoListAdapter(getApplicationContext()); + + // Put divider between ToDoItems and FooterView + getListView().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 + protected void onActivityResult(int requestCode, int resultCode, Intent data) { + + 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 + + @Override + public void onResume() { + super.onResume(); + + // Load saved ToDoItems, if necessary + + if (mAdapter.getCount() == 0) + loadItems(); + } + + @Override + protected void onPause() { + super.onPause(); + + // Save ToDoItems + + saveItems(); + + } + + @Override + public boolean onCreateOptionsMenu(Menu menu) { + 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 + public boolean onOptionsItemSelected(MenuItem item) { + switch (item.getItemId()) { + case MENU_DELETE: + mAdapter.clear(); + return true; + case MENU_DUMP: + dump(); + return true; + default: + return super.onOptionsItemSelected(item); + } + } + + public void dump() { + for (int i = 0; i < mAdapter.getCount(); i++) { + String data = ((ToDoItem) mAdapter.getItem(i)).toLog(); + Log.i(TAG, + "Item " + i + ": " + data.replace(ToDoItem.ITEM_SEP, ",")); + } + } + + // Load stored ToDoItems + private void loadItems() { + BufferedReader reader = null; + try { + FileInputStream fis = openFileInput(FILE_NAME); + reader = new BufferedReader(new InputStreamReader(fis)); + + String title = null; + String priority = null; + String status = null; + Date date = null; + + while (null != (title = reader.readLine())) { + priority = reader.readLine(); + status = reader.readLine(); + date = ToDoItem.FORMAT.parse(reader.readLine()); + mAdapter.add(new ToDoItem(title, Priority.valueOf(priority), + Status.valueOf(status), date)); + } + + } catch (FileNotFoundException e) { + e.printStackTrace(); + } catch (IOException e) { + e.printStackTrace(); + } catch (ParseException e) { + e.printStackTrace(); + } finally { + if (null != reader) { + try { + reader.close(); + } catch (IOException e) { + e.printStackTrace(); + } + } + } + } + + // Save ToDoItems to file + private void saveItems() { + PrintWriter writer = null; + try { + FileOutputStream fos = openFileOutput(FILE_NAME, MODE_PRIVATE); + writer = new PrintWriter(new BufferedWriter(new OutputStreamWriter( + fos))); + + for (int idx = 0; idx < mAdapter.getCount(); idx++) { + + writer.println(mAdapter.getItem(idx)); + + } + } catch (IOException e) { + e.printStackTrace(); + } finally { + if (null != writer) { + writer.close(); + } + } + } +} \ No newline at end of file diff --git a/Lab4_UILabs/app/src/main/res/drawable-hdpi/ic_launcher.png b/Lab4_UILabs/app/src/main/res/drawable-hdpi/ic_launcher.png new file mode 100644 index 0000000000000000000000000000000000000000..0e79b184fcf8cc47dede6d7ccde00d1a1e2d9c23 Binary files /dev/null and b/Lab4_UILabs/app/src/main/res/drawable-hdpi/ic_launcher.png differ diff --git a/Lab4_UILabs/app/src/main/res/drawable-ldpi/ic_launcher.png b/Lab4_UILabs/app/src/main/res/drawable-ldpi/ic_launcher.png new file mode 100644 index 0000000000000000000000000000000000000000..ebfac7d78b9e17c113f734d10af74bd2b100beba Binary files /dev/null and b/Lab4_UILabs/app/src/main/res/drawable-ldpi/ic_launcher.png differ diff --git a/Lab4_UILabs/app/src/main/res/drawable-mdpi/ic_launcher.png b/Lab4_UILabs/app/src/main/res/drawable-mdpi/ic_launcher.png new file mode 100644 index 0000000000000000000000000000000000000000..1183441937efcae0151b75099bec444d034886e9 Binary files /dev/null and b/Lab4_UILabs/app/src/main/res/drawable-mdpi/ic_launcher.png differ diff --git a/Lab4_UILabs/app/src/main/res/drawable-xhdpi/ic_launcher.png b/Lab4_UILabs/app/src/main/res/drawable-xhdpi/ic_launcher.png new file mode 100644 index 0000000000000000000000000000000000000000..c8ab2a114716b712ec0c5122f9e9524afaa60b52 Binary files /dev/null and b/Lab4_UILabs/app/src/main/res/drawable-xhdpi/ic_launcher.png differ diff --git a/Lab4_UILabs/app/src/main/res/layout/add_todo.xml b/Lab4_UILabs/app/src/main/res/layout/add_todo.xml new file mode 100644 index 0000000000000000000000000000000000000000..c20cc47cdbdd8165523074a9cb0be3d5acb4aafd --- /dev/null +++ b/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/Lab4_UILabs/app/src/main/res/layout/footer_view.xml b/Lab4_UILabs/app/src/main/res/layout/footer_view.xml new file mode 100644 index 0000000000000000000000000000000000000000..311856f59340671e8a5173c8b67ce76c344c919e --- /dev/null +++ b/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/Lab4_UILabs/app/src/main/res/layout/todo_item.xml b/Lab4_UILabs/app/src/main/res/layout/todo_item.xml new file mode 100644 index 0000000000000000000000000000000000000000..44ef9fcf470283d7f30cd5a895fd5eaf4842f24b --- /dev/null +++ b/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/Lab4_UILabs/app/src/main/res/values-sw600dp/dimens.xml b/Lab4_UILabs/app/src/main/res/values-sw600dp/dimens.xml new file mode 100644 index 0000000000000000000000000000000000000000..44f01db75f0fef18081132a9e86517f8d5efa8f6 --- /dev/null +++ b/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/Lab4_UILabs/app/src/main/res/values-sw720dp-land/dimens.xml b/Lab4_UILabs/app/src/main/res/values-sw720dp-land/dimens.xml new file mode 100644 index 0000000000000000000000000000000000000000..d3a17b7ac019232caa63d0b0849f42f43be32646 --- /dev/null +++ b/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/Lab4_UILabs/app/src/main/res/values/dimens.xml b/Lab4_UILabs/app/src/main/res/values/dimens.xml new file mode 100644 index 0000000000000000000000000000000000000000..0e9ce62a515ae5d1c761ff9bbad6b8291a65da36 --- /dev/null +++ b/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/Lab4_UILabs/app/src/main/res/values/strings.xml b/Lab4_UILabs/app/src/main/res/values/strings.xml new file mode 100644 index 0000000000000000000000000000000000000000..a6e324c6d983b4ff744f859a1fdeced4bd1b6897 --- /dev/null +++ b/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/Lab4_UILabs/build.gradle b/Lab4_UILabs/build.gradle new file mode 100644 index 0000000000000000000000000000000000000000..8674409cc64f09406fc5792870881826b40393f3 --- /dev/null +++ b/Lab4_UILabs/build.gradle @@ -0,0 +1,15 @@ +// Top-level build file where you can add configuration options common to all sub-projects/modules. +buildscript { + repositories { + jcenter() + } + dependencies { + classpath 'com.android.tools.build:gradle:2.3.3' + } +} + +allprojects { + repositories { + jcenter() + } +} diff --git a/Lab4_UILabs/gradle/wrapper/gradle-wrapper.jar b/Lab4_UILabs/gradle/wrapper/gradle-wrapper.jar new file mode 100644 index 0000000000000000000000000000000000000000..13372aef5e24af05341d49695ee84e5f9b594659 Binary files /dev/null and b/Lab4_UILabs/gradle/wrapper/gradle-wrapper.jar differ diff --git a/Lab4_UILabs/gradle/wrapper/gradle-wrapper.properties b/Lab4_UILabs/gradle/wrapper/gradle-wrapper.properties new file mode 100644 index 0000000000000000000000000000000000000000..feffd58b73b53c954c185d8becfa8ad1b5280528 --- /dev/null +++ b/Lab4_UILabs/gradle/wrapper/gradle-wrapper.properties @@ -0,0 +1,6 @@ +#Sun Sep 24 10:58:47 EDT 2017 +distributionBase=GRADLE_USER_HOME +distributionPath=wrapper/dists +zipStoreBase=GRADLE_USER_HOME +zipStorePath=wrapper/dists +distributionUrl=https\://services.gradle.org/distributions/gradle-4.1-all.zip diff --git a/Lab4_UILabs/gradlew b/Lab4_UILabs/gradlew new file mode 100755 index 0000000000000000000000000000000000000000..9d82f78915133e1c35a6ea51252590fb38efac2f --- /dev/null +++ b/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/Lab4_UILabs/gradlew.bat b/Lab4_UILabs/gradlew.bat new file mode 100644 index 0000000000000000000000000000000000000000..8a0b282aa6885fb573c106b3551f7275c5f17e8e --- /dev/null +++ b/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/Lab4_UILabs/settings.gradle b/Lab4_UILabs/settings.gradle new file mode 100644 index 0000000000000000000000000000000000000000..e7b4def49cb53d9aa04228dd3edb14c9e635e003 --- /dev/null +++ b/Lab4_UILabs/settings.gradle @@ -0,0 +1 @@ +include ':app'