diff --git a/.idea/gradle.xml b/.idea/gradle.xml index 7ac24c77..f43d4284 100644 --- a/.idea/gradle.xml +++ b/.idea/gradle.xml @@ -3,6 +3,9 @@ - + diff --git a/app/app.iml b/app/app.iml index 2a197e74..d3db1562 100644 --- a/app/app.iml +++ b/app/app.iml @@ -4,6 +4,8 @@ @@ -17,32 +19,31 @@ - - + + - - - + + - - - - - - - + + + + + + - - - - + + + + @@ -50,13 +51,6 @@ - - - - - - - @@ -64,6 +58,13 @@ + + + + + + + @@ -85,63 +86,81 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + - + - + + + + + + + + + + + + + + + + + + + + + + - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/app/build.gradle b/app/build.gradle index 865b2779..418ec7a7 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -10,14 +10,17 @@ android { storePassword '' } } - compileSdkVersion 23 + compileSdkVersion 28 buildToolsVersion '28.0.3' defaultConfig { applicationId "com.avjindersinghsekhon.minimaltodo" minSdkVersion 16 - targetSdkVersion 23 + targetSdkVersion 28 versionCode 3 versionName "1.2" +// testInstrumentationRunner = 'androidx.test.runner.AndroidJUnitRunner' + testInstrumentationRunner = 'com.example.avjindersinghsekhon.minimaltodo.Util.CustomJUnitRunner' + } buildTypes { release { @@ -33,14 +36,27 @@ android { dependencies { implementation fileTree(dir: 'libs', include: ['*.jar']) - implementation 'com.google.android.gms:play-services-analytics:7.8.0' + implementation 'com.google.android.gms:play-services-analytics:17.0.0' implementation 'uk.co.chrisjenx:calligraphy:2.1.0' implementation 'com.github.ganfra:material-spinner:1.1.0' implementation 'com.wdullaer:materialdatetimepicker:1.5.1' implementation 'com.amulyakhare:com.amulyakhare.textdrawable:1.0.1' implementation 'com.github.ganfra:material-spinner:1.1.0' - implementation 'com.android.support:recyclerview-v7:23.1.0' - implementation 'com.android.support:design:23.1.0' - implementation 'com.android.support:appcompat-v7:23.1.0' - implementation 'com.android.support:support-v13:23.1.0' + implementation 'androidx.recyclerview:recyclerview:1.0.0' + implementation 'com.google.android.material:material:1.1.0-alpha07' + implementation 'androidx.appcompat:appcompat:1.0.2' + implementation 'androidx.legacy:legacy-support-v13:1.0.0' + + androidTestImplementation 'androidx.test:core:1.2.1-alpha01' + androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0', { + exclude group: 'com.android.support', module: 'support-annotations' + + } + androidTestImplementation ('com.android.support.test.espresso:espresso-contrib:3.0.2') { + exclude group: 'com.android.support', module: 'appcompat' + exclude group: 'com.android.support', module: 'support-v4' + exclude module: 'recyclerview-v7' + } + androidTestImplementation 'androidx.test:runner:1.2.0' + androidTestImplementation 'androidx.test:rules:1.2.0' } diff --git a/app/src/androidTest/java/com/example/avjindersinghsekhon/minimaltodo/AddTodoItemScreenTest.java b/app/src/androidTest/java/com/example/avjindersinghsekhon/minimaltodo/AddTodoItemScreenTest.java new file mode 100644 index 00000000..e03662ee --- /dev/null +++ b/app/src/androidTest/java/com/example/avjindersinghsekhon/minimaltodo/AddTodoItemScreenTest.java @@ -0,0 +1,457 @@ +package com.example.avjindersinghsekhon.minimaltodo; + +import android.content.Intent; +import android.text.format.DateFormat; +import android.util.Log; +import android.view.View; +import android.widget.Button; + +import androidx.test.core.app.ApplicationProvider; +import androidx.test.espresso.Espresso; +import androidx.test.espresso.matcher.ViewMatchers; +import androidx.test.rule.ActivityTestRule; + +import com.amulyakhare.textdrawable.util.ColorGenerator; +import com.example.avjindersinghsekhon.minimaltodo.AddToDo.AddToDoActivity; +import com.example.avjindersinghsekhon.minimaltodo.AddToDo.AddToDoFragment; +import com.example.avjindersinghsekhon.minimaltodo.Main.MainFragment; +import com.example.avjindersinghsekhon.minimaltodo.Utility.ToDoItem; +import com.wdullaer.materialdatetimepicker.date.YearPickerView; + +import org.hamcrest.Matchers; +import org.junit.Before; +import org.junit.Rule; +import org.junit.Test; + +import java.util.Calendar; +import java.util.Date; + +import static androidx.test.espresso.Espresso.onData; +import static androidx.test.espresso.Espresso.onView; +import static androidx.test.espresso.action.ViewActions.click; +import static androidx.test.espresso.assertion.ViewAssertions.matches; +import static androidx.test.espresso.matcher.ViewMatchers.isAssignableFrom; +import static androidx.test.espresso.matcher.ViewMatchers.isDisplayed; +import static androidx.test.espresso.matcher.ViewMatchers.withEffectiveVisibility; +import static androidx.test.espresso.matcher.ViewMatchers.withId; +import static androidx.test.espresso.matcher.ViewMatchers.withText; +import static com.example.avjindersinghsekhon.minimaltodo.AddToDo.AddToDoFragment.formatDate; +import static org.hamcrest.Matchers.allOf; +import static org.hamcrest.Matchers.instanceOf; + +public class AddTodoItemScreenTest { + + @Rule + public ActivityTestRule activityTestRule = + new ActivityTestRule( + AddToDoActivity.class, + true, + true /*lazy launch activity*/){ + @Override + protected Intent getActivityIntent() { + /*added predefined intent data*/ + Intent newTodo = new Intent(); + ToDoItem item = new ToDoItem( + "", + "", + false, + null); + int color = ColorGenerator.MATERIAL.getRandomColor(); + item.setTodoColor(color); + //noinspection ResourceType + newTodo.putExtra(MainFragment.TODOITEM, item); + return newTodo; + } + }; + + Calendar mCalendar = Calendar.getInstance(); + final private String AM = "AM"; + final private String PM = "PM"; + + + @Before + public void setUp(){ + // note instead of null, an intent object can be passed +// activityTestRule.launchActivity(null); + Espresso.closeSoftKeyboard(); + mCalendar = Calendar.getInstance(); + } + + @Test + public void testSwitchingOnReminder() { + + onView(withId(R.id.toDoHasDateSwitchCompat)) + .check(matches(isDisplayed())) + // switch ON reminder + .perform(click()); + + onView(withId(R.id.toDoEnterDateLinearLayout)) + .check(matches(withEffectiveVisibility(ViewMatchers.Visibility.VISIBLE))); + + // check date and time fields is displayed to the user + onView(withId(R.id.newTodoDateEditText)) + .check(matches(isDisplayed())); + + // check "@" text is displayed to the user + onView(withText(R.string.at_for_time)) + .check(matches(isDisplayed())); + + // check time fields is displayed to the user + onView(withId(R.id.newTodoTimeEditText)) + .check(matches(isDisplayed())); + } + + @Test + public void testDefaultDateAndTimeIsNextHour() { + + onView(withId(R.id.toDoHasDateSwitchCompat)) + .check(matches(isDisplayed())) + // switch ON reminder + .perform(click()); + + onView(withId(R.id.toDoEnterDateLinearLayout)) + .check(matches(withEffectiveVisibility(ViewMatchers.Visibility.VISIBLE))); + + // check date is displayed to the user + onView(withId(R.id.newTodoDateEditText)) + // check date field shows default "Today" date + .check(matches(withText(R.string.date_reminder_default))) + .check(matches(isDisplayed())); + + // check "@" text is displayed to the user + onView(withText(R.string.at_for_time)) + .check(matches(isDisplayed())); + + // check time fields is displayed to the user + onView(withId(R.id.newTodoTimeEditText)) + // check time field shows default time (an hour in the dot from the current time) + // for instance if current time is 12:42 PM then time field should show 1 PM + .check(matches(withText(getDateTime()))) + .check(matches(isDisplayed())); + + Date date = AddToDoFragment.getAdjustedDate(ApplicationProvider.getApplicationContext()); + String finalString = AddToDoFragment.getFormattedDate( + date, + ApplicationProvider.getApplicationContext() + ); + + // check "Reminder set for ..." is displayed to the user + onView(withId(R.id.newToDoDateTimeReminderTextView)) + .check(matches(withText(finalString))) + .check(matches(isDisplayed())); + } + + + @Test + public void tesDatePickerShowCorrectDate() { + + onView(withId(R.id.toDoHasDateSwitchCompat)) + .check(matches(isDisplayed())) + // switch ON reminder + .perform(click()); + + onView(withId(R.id.toDoEnterDateLinearLayout)) + .check(matches(withEffectiveVisibility(ViewMatchers.Visibility.VISIBLE))); + + // check date is displayed to the user + onView(withId(R.id.newTodoDateEditText)) + // check date field shows default "Today" as date + .check(matches(withText(R.string.date_reminder_default))) + .check(matches(isDisplayed())) + .perform(click()); + + Calendar cal = Calendar.getInstance(); + int day_week = cal.get(Calendar.DAY_OF_WEEK) - 1; + Log.d("TEST", "DAY_OF_WEEK: " + DAY_OF_WEEK[day_week]); + + // check date_picker_header is displayed to the user + onView(withId(R.id.date_picker_header)) + // check day of week match the today's day of week + .check(matches(withText(DAY_OF_WEEK[day_week]))) + .check(matches(isDisplayed())); + + // check date_picker_month_and_day is displayed to the user + onView(withId(R.id.date_picker_month_and_day)) + .check(matches(isDisplayed())); + + int month = cal.get(Calendar.MONTH); + Log.d("TEST", "MONTH: " + MONTH[month]); + // check selected date_picker_month is displayed to the user + onView(withId(R.id.date_picker_month)) + // check month match the current month + .check(matches(withText(MONTH[month]))) + .check(matches(isDisplayed())); + + int day = cal.get(Calendar.DAY_OF_MONTH); + Log.d("TEST", "DAY: " + day); + // if number < 10, then add '0' in the front of the number + String day_of_month = day < 10 ? "0" + day : "" + day; + Log.d("TEST", "DAY_OF_MONTH: " + day_of_month); + + // check selected date_picker_day is displayed to the user + onView(withId(R.id.date_picker_day)) + .check(matches(withText(day_of_month))) + .check(matches(isDisplayed())); + + String year = String.valueOf(cal.get(Calendar.YEAR)); + Log.d("TEST", "YEAR: " + year); + // check date_picker_year is displayed to the user + onView(withId(R.id.date_picker_year)) + .check(matches(withText(year))) + .check(matches(isDisplayed())); + } + + + @Test + public void testTimePickerShowCorrectTime() { + + onView(withId(R.id.toDoHasDateSwitchCompat)) + .check(matches(isDisplayed())) + // switch ON reminder + .perform(click()); + + onView(withId(R.id.toDoEnterDateLinearLayout)) + .check(matches(withEffectiveVisibility(ViewMatchers.Visibility.VISIBLE))); + + // check time fields is displayed to the user + onView(withId(R.id.newTodoTimeEditText)) + // check time field shows default time (an hour in the dot from the current time) + // for instance if current time is 12:42 PM then time field should show 1 PM + .check(matches(withText(getDateTime()))) + .check(matches(isDisplayed())) + .perform(click()); + + boolean time24 = DateFormat.is24HourFormat(ApplicationProvider.getApplicationContext()); + Log.d("TEST", "time24: " +time24); + int hour = mCalendar.get(time24 ? Calendar.HOUR_OF_DAY : Calendar.HOUR); + + if (!time24 && hour == 0) { // transform `0` into 12 AM/PM + hour = 12; + } + Log.d("TEST", "HOUR: " + mCalendar.get(Calendar.HOUR)); + Log.d("TEST", "HOUR_OF_DAY: " + mCalendar.get(Calendar.HOUR_OF_DAY)); + + // check selected hour is displayed to the user + onView(withId(R.id.hours)) + // check hour match the current hour + .check(matches(withText(String.valueOf(hour)))) + .check(matches(isDisplayed())); + + int min = mCalendar.get(Calendar.MINUTE); + Log.d("TEST", "MINUTE: " + min); + // if number < 10, then add '0' in the front of the number + String minutes = min < 10 ? "0" + min : String.valueOf(min); + + // check selected hour is displayed to the user + onView(withId(R.id.minutes)) + // check minutes match the current minutes + .check(matches(withText(minutes))) + .check(matches(isDisplayed())); + + String am_pm = mCalendar.get(Calendar.AM_PM) == Calendar.AM ? AM : PM; + Log.d("TEST", "AM_PM: " + am_pm); + // check selected Time label (AM or PM) is displayed to the user + onView(withId(R.id.ampm_label)) + // check minutes match the current minutes + .check(matches(withText(am_pm))) + .check(matches(isDisplayed())); + + // check CANCEL button is displayed to the user + onView(allOf(withId(R.id.cancel), isAssignableFrom(Button.class))) + // check text is "CANCEL" + .check(matches(withText("CANCEL"))) + .check(matches(isDisplayed())) + .perform(click()); + } + + + @Test + public void testSettingFutureDate() { + + onView(withId(R.id.toDoHasDateSwitchCompat)) + .check(matches(isDisplayed())) + // switch ON reminder + .perform(click()); + + onView(withId(R.id.toDoEnterDateLinearLayout)) + .check(matches(withEffectiveVisibility(ViewMatchers.Visibility.VISIBLE))); + + // check date is displayed to the user + onView(withId(R.id.newTodoDateEditText)) + // check date field shows default "Today" as date + .check(matches(withText(R.string.date_reminder_default))) + .check(matches(isDisplayed())) + .perform(click()); + + Calendar cal = Calendar.getInstance(); + int day_week = cal.get(Calendar.DAY_OF_WEEK); + Log.d("TEST", "DAY_OF_WEEK: " + DAY_OF_WEEK[day_week-1]); + + // check date_picker_header is displayed to the user + onView(withId(R.id.date_picker_header)) + // check day of week match the today's day of week + .check(matches(withText(DAY_OF_WEEK[day_week-1]))) + .check(matches(isDisplayed())); + + // check date_picker_month_and_day is displayed to the user + onView(withId(R.id.date_picker_month_and_day)) + .check(matches(isDisplayed())); + + int month = cal.get(Calendar.MONTH); + Log.d("TEST", "MONTH: " + MONTH[month]); + // check selected date_picker_month is displayed to the user + onView(withId(R.id.date_picker_month)) + // check month match the current month + .check(matches(withText(MONTH[month]))) + .check(matches(isDisplayed())); + + int day = cal.get(Calendar.DAY_OF_MONTH); + Log.d("TEST", "DAY: " + day); + // if number < 10, then add '0' in the front of the number + String day_of_month = day < 10 ? "0" + day : "" + day; + Log.d("TEST", "DAY_OF_MONTH: " + day_of_month); + + // check selected date_picker_day is displayed to the user + onView(withId(R.id.date_picker_day)) + .check(matches(withText(day_of_month))) + .check(matches(isDisplayed())); + + int year = cal.get(Calendar.YEAR); + String yearString = String.valueOf(year); + Log.d("TEST", "YEAR: " + yearString); + // check date_picker_year is displayed to the user + onView(withId(R.id.date_picker_year)) + .check(matches(withText(yearString))) + .check(matches(isDisplayed())) + .perform(click()); + + int mininumYear = 1900; // 1900 is the minimum year displayed in the YearPicker + int pos = year - mininumYear; + int yearsOffset = 2; + pos += yearsOffset; // scroll to 2 years ahead of the current year + + Log.d("TEST", "Selected YEAR: " + (year + yearsOffset)); + cal.set(Calendar.YEAR, year + yearsOffset); + Date dateSelected = cal.getTime(); + + // pick a year + onData(instanceOf(String.class)) + .inAdapterView(Matchers.instanceOf(YearPickerView.class)) + .atPosition(pos) +// .onChildView(withText("2021")) + .perform(click()); + + // pick a day +// onView(allOf(withContentDescription("10 July 2021"), +// isDescendantOfA(Matchers.instanceOf(SimpleMonthView.class) +//// , withText("July") +// ))) +// .perform(scrollTo(), click()); + +// onView(allOf(instanceOf(SimpleDayPickerView.class), +// withChild(Matchers.instanceOf(SimpleMonthView.class)) +//// , withText("July") +// )) +// .perform(scrollTo(), click()); + +// onData(instanceOf(MonthAdapter.CalendarDay.class)) +// .inAdapterView(Matchers.instanceOf(SimpleDayPickerView.class)) +//// .atPosition(22) +// .onChildView(allOf(withContentDescription("11 July 2021"), +// isDescendantOfA(Matchers.instanceOf(SimpleMonthView.class)))) +// .perform(scrollTo()) +// ; + + // accept the selected date + onView(allOf(withId(R.id.ok), isAssignableFrom(Button.class))) + // check button text is "Ok" + .check(matches(withText("OK"))) + // check OK button is displayed to the user + .check(matches(isDisplayed())) + .perform(click()); + + Log.d("TEST", "Selected Date: " + getFormatDate(dateSelected)); + + // check date is displayed to the user + onView(withId(R.id.newTodoDateEditText)) + // check date field shows the selected date + .check(matches(withText(getFormatDate(dateSelected)))) + .check(matches(isDisplayed())); + } + + + + @Test + public void testPickTimeInPast() { + + onView(withId(R.id.toDoHasDateSwitchCompat)) + .check(matches(isDisplayed())) + // switch ON reminder + .perform(click()); + + onView(withId(R.id.toDoEnterDateLinearLayout)) + .check(matches(withEffectiveVisibility(ViewMatchers.Visibility.VISIBLE))); + + // check time fields is displayed to the user + onView(withId(R.id.newTodoTimeEditText)) + // check time field shows default time (an hour in the dot from the current time) + // for instance if current time is 12:42 PM then time field should show 1 PM + .check(matches(withText(getDateTime()))) + .check(matches(isDisplayed())) + .perform(click()); + + onView(allOf(withId(R.id.ok), isAssignableFrom(Button.class))) + // check minutes match the current minutes + .check(matches(withText("OK"))) + // check OK button is displayed to the user + .check(matches(isDisplayed())) + .perform(click()); + + // check "The date you entered is in the past." is displayed to the user + onView(withId(R.id.newToDoDateTimeReminderTextView)) + .check(matches(withText(R.string.date_error_check_again))) + .check(matches(isDisplayed())); + } + + private String getDateTime() { + boolean time24 = DateFormat.is24HourFormat(ApplicationProvider.getApplicationContext()); + Date date = AddToDoFragment.getAdjustedDate(ApplicationProvider.getApplicationContext()); + return getFormatTime(date, time24); + } + + private String getFormatTime(Date userReminderDate, boolean time24) { + Log.d("TEST", "Imagined Date: " + userReminderDate); + String formatString = time24 ? "k:mm" : "h:mm a"; + return formatDate(formatString, userReminderDate); + } + + private String getFormatDate(Date userReminderDate) { + Log.d("TEST", "Imagined Date: " + userReminderDate); + return formatDate(AddToDoFragment.DATE_FORMAT, userReminderDate); + } + + final private String[] DAY_OF_WEEK = { + "SUNDAY", + "MONDAY", + "TUESDAY", + "WEDNESDAY", + "THURSDAY", + "FRIDAY", + "SATURDAY" + }; + + final private String[] MONTH = { + "JAN", + "FEB", + "MAR", + "APR", + "MAY", + "JUN", + "JUL", + "AUG", + "SEP", + "OCT", + "NOV", + "DEC" + }; +} diff --git a/app/src/androidTest/java/com/example/avjindersinghsekhon/minimaltodo/ApplicationTest.java b/app/src/androidTest/java/com/example/avjindersinghsekhon/minimaltodo/ApplicationTest.java deleted file mode 100644 index 259de29f..00000000 --- a/app/src/androidTest/java/com/example/avjindersinghsekhon/minimaltodo/ApplicationTest.java +++ /dev/null @@ -1,13 +0,0 @@ -package com.example.avjindersinghsekhon.minimaltodo; - -import android.app.Application; -import android.test.ApplicationTestCase; - -/** - * Testing Fundamentals - */ -public class ApplicationTest extends ApplicationTestCase { - public ApplicationTest() { - super(Application.class); - } -} \ No newline at end of file diff --git a/app/src/androidTest/java/com/example/avjindersinghsekhon/minimaltodo/Main/AddTodoActivityScreenTest.java b/app/src/androidTest/java/com/example/avjindersinghsekhon/minimaltodo/Main/AddTodoActivityScreenTest.java new file mode 100644 index 00000000..31c7bf22 --- /dev/null +++ b/app/src/androidTest/java/com/example/avjindersinghsekhon/minimaltodo/Main/AddTodoActivityScreenTest.java @@ -0,0 +1,203 @@ +package com.example.avjindersinghsekhon.minimaltodo.Main; + + +import android.view.View; +import android.view.ViewGroup; +import android.view.ViewParent; + +import androidx.test.espresso.DataInteraction; +import androidx.test.espresso.ViewInteraction; +import androidx.test.filters.LargeTest; +import androidx.test.rule.ActivityTestRule; +import androidx.test.runner.AndroidJUnit4; + +import com.example.avjindersinghsekhon.minimaltodo.R; + +import org.hamcrest.Description; +import org.hamcrest.Matcher; +import org.hamcrest.TypeSafeMatcher; +import org.hamcrest.core.IsInstanceOf; +import org.junit.Rule; +import org.junit.runner.RunWith; + +import static androidx.test.espresso.Espresso.onData; +import static androidx.test.espresso.Espresso.onView; +import static androidx.test.espresso.action.ViewActions.click; +import static androidx.test.espresso.action.ViewActions.scrollTo; +import static androidx.test.espresso.assertion.ViewAssertions.matches; +import static androidx.test.espresso.matcher.ViewMatchers.isDisplayed; +import static androidx.test.espresso.matcher.ViewMatchers.withClassName; +import static androidx.test.espresso.matcher.ViewMatchers.withContentDescription; +import static androidx.test.espresso.matcher.ViewMatchers.withId; +import static androidx.test.espresso.matcher.ViewMatchers.withText; +import static org.hamcrest.Matchers.allOf; +import static org.hamcrest.Matchers.anything; +import static org.hamcrest.Matchers.is; + +@LargeTest +@RunWith(AndroidJUnit4.class) +public class AddTodoActivityScreenTest { + + @Rule + public ActivityTestRule mActivityTestRule = new ActivityTestRule<>(MainActivity.class); + +// @Test + public void addTodoActivityScreenTest() { + ViewInteraction floatingActionButton = onView( + allOf(withId(R.id.addToDoItemFAB), + childAtPosition( + allOf(withId(R.id.myCoordinatorLayout), + childAtPosition( + withId(R.id.myParentLayout), + 0)), + 2), + isDisplayed())); + floatingActionButton.perform(click()); + + ViewInteraction floatingActionButton2 = onView( + allOf(withId(R.id.addToDoItemFAB), + childAtPosition( + allOf(withId(R.id.myCoordinatorLayout), + childAtPosition( + withId(R.id.myParentLayout), + 0)), + 2), + isDisplayed())); + floatingActionButton2.perform(click()); + + ViewInteraction switchCompat = onView( + allOf(withId(R.id.toDoHasDateSwitchCompat), + childAtPosition( + childAtPosition( + withId(R.id.todoReminderAndDateContainerLayout), + 0), + 2), + isDisplayed())); + switchCompat.perform(click()); + + ViewInteraction appCompatEditText = onView( + allOf(withId(R.id.newTodoDateEditText), withText("Today"), + childAtPosition( + childAtPosition( + withId(R.id.toDoEnterDateLinearLayout), + 0), + 0), + isDisplayed())); + appCompatEditText.perform(click()); + + ViewInteraction accessibleTextView = onView( + allOf(withId(R.id.date_picker_year), withText("2019"), + childAtPosition( + allOf(withId(R.id.day_picker_selected_date_layout), + childAtPosition( + withClassName(is("android.widget.LinearLayout")), + 1)), + 1))); + accessibleTextView.perform(scrollTo(), click()); + + DataInteraction textViewWithCircularIndicator = onData(anything()) + .inAdapterView(childAtPosition( + allOf(withId(R.id.animator), withContentDescription("Year list: 2019")), + 1)) + .atPosition(122); + textViewWithCircularIndicator.perform(scrollTo(), click()); + + ViewInteraction appCompatButton = onView( + allOf(withId(R.id.ok), withText("OK"), + childAtPosition( + allOf(withId(R.id.done_background), + childAtPosition( + withClassName(is("android.widget.LinearLayout")), + 1)), + 1), + isDisplayed())); + appCompatButton.perform(click()); + + ViewInteraction appCompatEditText2 = onView( + allOf(withId(R.id.newTodoDateEditText), withText("27 Sep, 2022"), + childAtPosition( + childAtPosition( + withId(R.id.toDoEnterDateLinearLayout), + 0), + 0), + isDisplayed())); + appCompatEditText2.perform(click()); + + ViewInteraction view = onView( + allOf(withContentDescription("08 August 2019"), + childAtPosition( + childAtPosition( + IsInstanceOf.instanceOf(android.widget.ListView.class), + 0), + 7), + isDisplayed())); + view.check(matches(isDisplayed())); + + ViewInteraction view2 = onView( + allOf(childAtPosition( + childAtPosition( + allOf(withId(R.id.animator), withContentDescription("Month grid of days: July 10")), + 0), + 1), + isDisplayed())); + view2.check(matches(isDisplayed())); + + ViewInteraction view3 = onView( + allOf(childAtPosition( + childAtPosition( + allOf(withId(R.id.animator), withContentDescription("Month grid of days: July 10")), + 0), + 1), + isDisplayed())); + view3.check(matches(isDisplayed())); + + ViewInteraction listView = onView( + allOf(childAtPosition( + allOf(withId(R.id.animator), withContentDescription("Month grid of days: July 10"), + childAtPosition( + IsInstanceOf.instanceOf(android.widget.LinearLayout.class), + 2)), + 0), + isDisplayed())); + listView.check(matches(isDisplayed())); + + ViewInteraction view4 = onView( + allOf(withContentDescription("11 October 2019"), + childAtPosition( + childAtPosition( + IsInstanceOf.instanceOf(android.widget.ListView.class), + 0), + 10), + isDisplayed())); + view4.check(matches(isDisplayed())); + + ViewInteraction view5 = onView( + allOf(withContentDescription("11 October 2019"), + childAtPosition( + childAtPosition( + IsInstanceOf.instanceOf(android.widget.ListView.class), + 0), + 10), + isDisplayed())); + view5.check(matches(isDisplayed())); + } + + private static Matcher childAtPosition( + final Matcher parentMatcher, final int position) { + + return new TypeSafeMatcher() { + @Override + public void describeTo(Description description) { + description.appendText("Child at position " + position + " in parent "); + parentMatcher.describeTo(description); + } + + @Override + public boolean matchesSafely(View view) { + ViewParent parent = view.getParent(); + return parent instanceof ViewGroup && parentMatcher.matches(parent) + && view.equals(((ViewGroup) parent).getChildAt(position)); + } + }; + } +} diff --git a/app/src/androidTest/java/com/example/avjindersinghsekhon/minimaltodo/Main/Bala/BalaTestSuite.java b/app/src/androidTest/java/com/example/avjindersinghsekhon/minimaltodo/Main/Bala/BalaTestSuite.java new file mode 100644 index 00000000..d6241c0b --- /dev/null +++ b/app/src/androidTest/java/com/example/avjindersinghsekhon/minimaltodo/Main/Bala/BalaTestSuite.java @@ -0,0 +1,15 @@ +package com.example.avjindersinghsekhon.minimaltodo.Main.Bala; + +import org.junit.runner.RunWith; +import org.junit.runners.Suite; + +/** + * Runs all unit tests. + */ +@RunWith(Suite.class) +@Suite.SuiteClasses({DeletePageTest.class , + + ListPageTest.class,EditClosePageTest.class +,EditModifyClosePageTest.class,EditModifySavePageTest.class,EditVerifyClosePageTest.class,DeleteUndoPageTest.class,}) +public class BalaTestSuite { +} diff --git a/app/src/androidTest/java/com/example/avjindersinghsekhon/minimaltodo/Main/Bala/DeletePageTest.java b/app/src/androidTest/java/com/example/avjindersinghsekhon/minimaltodo/Main/Bala/DeletePageTest.java new file mode 100644 index 00000000..c6686db7 --- /dev/null +++ b/app/src/androidTest/java/com/example/avjindersinghsekhon/minimaltodo/Main/Bala/DeletePageTest.java @@ -0,0 +1,85 @@ +package com.example.avjindersinghsekhon.minimaltodo.Main.Bala; + +import android.view.View; +import android.view.ViewGroup; +import android.view.ViewParent; + +import androidx.recyclerview.widget.RecyclerView; +import androidx.test.espresso.ViewInteraction; +import androidx.test.filters.LargeTest; +import androidx.test.rule.ActivityTestRule; +import androidx.test.runner.AndroidJUnit4; + +import com.example.avjindersinghsekhon.minimaltodo.Main.MainActivity; +import com.example.avjindersinghsekhon.minimaltodo.R; + +import org.hamcrest.Description; +import org.hamcrest.Matcher; +import org.hamcrest.TypeSafeMatcher; +import org.junit.Before; +import org.junit.Rule; +import org.junit.Test; +import org.junit.runner.RunWith; + +import static androidx.test.espresso.Espresso.onView; +import static androidx.test.espresso.action.ViewActions.closeSoftKeyboard; +import static androidx.test.espresso.action.ViewActions.swipeLeft; +import static androidx.test.espresso.action.ViewActions.typeText; +import static androidx.test.espresso.matcher.ViewMatchers.isDisplayed; +import static androidx.test.espresso.matcher.ViewMatchers.withId; +import static androidx.test.espresso.action.ViewActions.click; +import static org.hamcrest.Matchers.allOf; + +@RunWith(AndroidJUnit4.class) +@LargeTest +public class DeletePageTest { + private static final String TITLE = "Test Title to Delete"; + private static final String DESCRIPTION = "Test Description"; + + @Rule + public ActivityTestRule mActivityTestRule = new ActivityTestRule<>(MainActivity.class); + + @Before + public void init() { + onView(withId(R.id.addToDoItemFAB)).perform(click()); + onView(withId(R.id.userToDoEditText)).perform(typeText(TITLE), closeSoftKeyboard()); + onView(withId(R.id.userToDoDescription)).perform(typeText(DESCRIPTION), closeSoftKeyboard()); + onView(withId(R.id.makeToDoFloatingActionButton)).perform(click()); + } + @Test + public void delete() { + RecyclerView recyclerView = mActivityTestRule.getActivity().findViewById(R.id.toDoRecyclerView); + int itemCount = recyclerView.getAdapter().getItemCount(); + System.out.println(itemCount); + ViewInteraction linearLayout = onView( + allOf(withId(R.id.listItemLinearLayout), + childAtPosition( + allOf(withId(R.id.toDoRecyclerView), + childAtPosition( + withId(R.id.myCoordinatorLayout), + 1)), + 0), + isDisplayed())); + linearLayout.perform(swipeLeft()); + + } + + private static Matcher childAtPosition( + final Matcher parentMatcher, final int position) { + + return new TypeSafeMatcher() { + @Override + public void describeTo(Description description) { + description.appendText("Child at position " + position + " in parent "); + parentMatcher.describeTo(description); + } + + @Override + public boolean matchesSafely(View view) { + ViewParent parent = view.getParent(); + return parent instanceof ViewGroup && parentMatcher.matches(parent) + && view.equals(((ViewGroup) parent).getChildAt(position)); + } + }; + } +} diff --git a/app/src/androidTest/java/com/example/avjindersinghsekhon/minimaltodo/Main/Bala/DeleteUndoPageTest.java b/app/src/androidTest/java/com/example/avjindersinghsekhon/minimaltodo/Main/Bala/DeleteUndoPageTest.java new file mode 100644 index 00000000..97a90ef7 --- /dev/null +++ b/app/src/androidTest/java/com/example/avjindersinghsekhon/minimaltodo/Main/Bala/DeleteUndoPageTest.java @@ -0,0 +1,99 @@ +package com.example.avjindersinghsekhon.minimaltodo.Main.Bala; + +import android.view.View; +import android.view.ViewGroup; +import android.view.ViewParent; + +import androidx.recyclerview.widget.RecyclerView; +import androidx.test.espresso.ViewInteraction; +import androidx.test.filters.LargeTest; +import androidx.test.rule.ActivityTestRule; +import androidx.test.runner.AndroidJUnit4; + +import com.example.avjindersinghsekhon.minimaltodo.Main.MainActivity; +import com.example.avjindersinghsekhon.minimaltodo.R; + +import org.hamcrest.Description; +import org.hamcrest.Matcher; +import org.hamcrest.TypeSafeMatcher; +import org.junit.Before; +import org.junit.Rule; +import org.junit.Test; +import org.junit.runner.RunWith; + +import static androidx.test.espresso.Espresso.onView; +import static androidx.test.espresso.action.ViewActions.click; +import static androidx.test.espresso.action.ViewActions.closeSoftKeyboard; +import static androidx.test.espresso.action.ViewActions.swipeLeft; +import static androidx.test.espresso.action.ViewActions.typeText; +import static androidx.test.espresso.matcher.ViewMatchers.isDisplayed; +import static androidx.test.espresso.matcher.ViewMatchers.withId; +import static org.hamcrest.Matchers.allOf; + +@RunWith(AndroidJUnit4.class) +@LargeTest +public class DeleteUndoPageTest { + private static final String TITLE = "Test Title to Undo"; + private static final String DESCRIPTION = "Test Description"; + + @Rule + public ActivityTestRule mActivityTestRule = new ActivityTestRule<>(MainActivity.class); + + @Before + public void init() { + onView(withId(R.id.addToDoItemFAB)).perform(click()); + onView(withId(R.id.userToDoEditText)).perform(typeText(TITLE), closeSoftKeyboard()); + onView(withId(R.id.userToDoDescription)).perform(typeText(DESCRIPTION), closeSoftKeyboard()); + onView(withId(R.id.makeToDoFloatingActionButton)).perform(click()); + } + @Test + public void delete() { + RecyclerView recyclerView = mActivityTestRule.getActivity().findViewById(R.id.toDoRecyclerView); + int itemCount = recyclerView.getAdapter().getItemCount(); + System.out.println(itemCount); + ViewInteraction linearLayout = onView( + allOf(withId(R.id.listItemLinearLayout), + childAtPosition( + allOf(withId(R.id.toDoRecyclerView), + childAtPosition( + withId(R.id.myCoordinatorLayout), + 1)), + 0), + isDisplayed())); + linearLayout.perform(swipeLeft()); + try { + Thread.sleep(20); + } catch (InterruptedException e) { + e.printStackTrace(); + } + + /* ViewInteraction appCompatButton = onView( + allOf(withId(R.id.snackbar_action), withText("UNDO"), + childAtPosition( + childAtPosition( + withClassName(is("com.google.android.material.snackbar.Snackbar$SnackbarLayout")), + 0), + 1), + isDisplayed())); + appCompatButton.perform(click());*/ + } + + private static Matcher childAtPosition( + final Matcher parentMatcher, final int position) { + + return new TypeSafeMatcher() { + @Override + public void describeTo(Description description) { + description.appendText("Child at position " + position + " in parent "); + parentMatcher.describeTo(description); + } + + @Override + public boolean matchesSafely(View view) { + ViewParent parent = view.getParent(); + return parent instanceof ViewGroup && parentMatcher.matches(parent) + && view.equals(((ViewGroup) parent).getChildAt(position)); + } + }; + } +} diff --git a/app/src/androidTest/java/com/example/avjindersinghsekhon/minimaltodo/Main/Bala/EditClosePageTest.java b/app/src/androidTest/java/com/example/avjindersinghsekhon/minimaltodo/Main/Bala/EditClosePageTest.java new file mode 100644 index 00000000..8930bee2 --- /dev/null +++ b/app/src/androidTest/java/com/example/avjindersinghsekhon/minimaltodo/Main/Bala/EditClosePageTest.java @@ -0,0 +1,116 @@ +package com.example.avjindersinghsekhon.minimaltodo.Main.Bala; + +import android.view.View; +import android.view.ViewGroup; +import android.view.ViewParent; + +import androidx.recyclerview.widget.RecyclerView; +import androidx.test.espresso.ViewInteraction; +import androidx.test.filters.LargeTest; +import androidx.test.rule.ActivityTestRule; +import androidx.test.runner.AndroidJUnit4; + +import com.example.avjindersinghsekhon.minimaltodo.Main.MainActivity; +import com.example.avjindersinghsekhon.minimaltodo.R; + +import org.hamcrest.Description; +import org.hamcrest.Matcher; +import org.hamcrest.TypeSafeMatcher; +import org.junit.After; +import org.junit.Before; +import org.junit.Rule; +import org.junit.Test; +import org.junit.runner.RunWith; + +import static androidx.test.espresso.Espresso.onView; +import static androidx.test.espresso.action.ViewActions.click; +import static androidx.test.espresso.action.ViewActions.closeSoftKeyboard; +import static androidx.test.espresso.action.ViewActions.swipeLeft; +import static androidx.test.espresso.action.ViewActions.typeText; +import static androidx.test.espresso.matcher.ViewMatchers.isDisplayed; +import static androidx.test.espresso.matcher.ViewMatchers.withClassName; +import static androidx.test.espresso.matcher.ViewMatchers.withContentDescription; +import static androidx.test.espresso.matcher.ViewMatchers.withId; +import static org.hamcrest.Matchers.allOf; +import static org.hamcrest.Matchers.is; + +@RunWith(AndroidJUnit4.class) +@LargeTest +public class EditClosePageTest { + private static final String TITLE = "Test Title to Edit"; + private static final String DESCRIPTION = "Test Description"; + + @Rule + public ActivityTestRule mActivityTestRule = new ActivityTestRule<>(MainActivity.class); + + @Before + public void init() { + onView(withId(R.id.addToDoItemFAB)).perform(click()); + onView(withId(R.id.userToDoEditText)).perform(typeText(TITLE), closeSoftKeyboard()); + onView(withId(R.id.userToDoDescription)).perform(typeText(DESCRIPTION), closeSoftKeyboard()); + onView(withId(R.id.makeToDoFloatingActionButton)).perform(click()); + } + @Test + public void edit() { + RecyclerView recyclerView = mActivityTestRule.getActivity().findViewById(R.id.toDoRecyclerView); + int itemCount = recyclerView.getAdapter().getItemCount(); + System.out.println(itemCount); + ViewInteraction linearLayout = onView( + allOf(withId(R.id.listItemLinearLayout), + childAtPosition( + allOf(withId(R.id.toDoRecyclerView), + childAtPosition( + withId(R.id.myCoordinatorLayout), + 1)), + 0), + isDisplayed())); + linearLayout.perform(click()); + ViewInteraction appCompatImageButton = onView( + allOf(withContentDescription("Navigate up"), + childAtPosition( + allOf(withId(R.id.toolbar), + childAtPosition( + withClassName(is("android.widget.LinearLayout")), + 0)), + 0), + isDisplayed())); + appCompatImageButton.perform(click()); + + } + @After + public void delete() { + + RecyclerView recyclerView = mActivityTestRule.getActivity().findViewById(R.id.toDoRecyclerView); + int itemCount = recyclerView.getAdapter().getItemCount(); + System.out.println(itemCount); + ViewInteraction linearLayout = onView( + allOf(withId(R.id.listItemLinearLayout), + childAtPosition( + allOf(withId(R.id.toDoRecyclerView), + childAtPosition( + withId(R.id.myCoordinatorLayout), + 1)), + 0), + isDisplayed())); + linearLayout.perform(swipeLeft()); + + } + private static Matcher childAtPosition( + final Matcher parentMatcher, final int position) { + + return new TypeSafeMatcher() { + @Override + public void describeTo(Description description) { + description.appendText("Child at position " + position + " in parent "); + parentMatcher.describeTo(description); + } + + @Override + public boolean matchesSafely(View view) { + ViewParent parent = view.getParent(); + return parent instanceof ViewGroup && parentMatcher.matches(parent) + && view.equals(((ViewGroup) parent).getChildAt(position)); + } + }; + } +} diff --git a/app/src/androidTest/java/com/example/avjindersinghsekhon/minimaltodo/Main/Bala/EditModifyClosePageTest.java b/app/src/androidTest/java/com/example/avjindersinghsekhon/minimaltodo/Main/Bala/EditModifyClosePageTest.java new file mode 100644 index 00000000..f488ee70 --- /dev/null +++ b/app/src/androidTest/java/com/example/avjindersinghsekhon/minimaltodo/Main/Bala/EditModifyClosePageTest.java @@ -0,0 +1,131 @@ +package com.example.avjindersinghsekhon.minimaltodo.Main.Bala; + +import android.view.View; +import android.view.ViewGroup; +import android.view.ViewParent; + +import androidx.recyclerview.widget.RecyclerView; +import androidx.test.espresso.ViewInteraction; +import androidx.test.filters.LargeTest; +import androidx.test.rule.ActivityTestRule; +import androidx.test.runner.AndroidJUnit4; + +import com.example.avjindersinghsekhon.minimaltodo.Main.MainActivity; +import com.example.avjindersinghsekhon.minimaltodo.R; + +import org.hamcrest.Description; +import org.hamcrest.Matcher; +import org.hamcrest.TypeSafeMatcher; +import org.junit.After; +import org.junit.Before; +import org.junit.Rule; +import org.junit.Test; +import org.junit.runner.RunWith; + +import static androidx.test.espresso.Espresso.onView; +import static androidx.test.espresso.action.ViewActions.click; +import static androidx.test.espresso.action.ViewActions.closeSoftKeyboard; +import static androidx.test.espresso.action.ViewActions.replaceText; +import static androidx.test.espresso.action.ViewActions.swipeLeft; +import static androidx.test.espresso.action.ViewActions.typeText; +import static androidx.test.espresso.assertion.ViewAssertions.matches; +import static androidx.test.espresso.matcher.ViewMatchers.isDisplayed; +import static androidx.test.espresso.matcher.ViewMatchers.withClassName; +import static androidx.test.espresso.matcher.ViewMatchers.withContentDescription; +import static androidx.test.espresso.matcher.ViewMatchers.withId; +import static androidx.test.espresso.matcher.ViewMatchers.withText; +import static org.hamcrest.Matchers.allOf; +import static org.hamcrest.Matchers.is; + +@RunWith(AndroidJUnit4.class) +@LargeTest +public class EditModifyClosePageTest { + private static final String TITLE = "Test Title to Close"; + private static final String DESCRIPTION = "Test Description"; + private static final String REPLACE_TITLE = "Replace Test Title"; + private static final String REPLACE_DESCRIPTION = "Replace Test Description"; + + @Rule + public ActivityTestRule mActivityTestRule = new ActivityTestRule<>(MainActivity.class); + + @Before + public void init() { + onView(withId(R.id.addToDoItemFAB)).perform(click()); + onView(withId(R.id.userToDoEditText)).perform(typeText(TITLE), closeSoftKeyboard()); + onView(withId(R.id.userToDoDescription)).perform(typeText(DESCRIPTION), closeSoftKeyboard()); + onView(withId(R.id.makeToDoFloatingActionButton)).perform(click()); + } + @Test + public void edit() { + RecyclerView recyclerView = mActivityTestRule.getActivity().findViewById(R.id.toDoRecyclerView); + int itemCount = recyclerView.getAdapter().getItemCount(); + System.out.println(itemCount); + ViewInteraction linearLayout = onView( + allOf(withId(R.id.listItemLinearLayout), + childAtPosition( + allOf(withId(R.id.toDoRecyclerView), + childAtPosition( + withId(R.id.myCoordinatorLayout), + 1)), + 0), + isDisplayed())); + linearLayout.perform(click()); + onView(withId(R.id.userToDoEditText)).perform(replaceText(REPLACE_TITLE), closeSoftKeyboard()); + onView(withId(R.id.userToDoDescription)).perform(replaceText(REPLACE_DESCRIPTION), closeSoftKeyboard()); + ViewInteraction appCompatImageButton = onView( + allOf(withContentDescription("Navigate up"), + childAtPosition( + allOf(withId(R.id.toolbar), + childAtPosition( + withClassName(is("android.widget.LinearLayout")), + 0)), + 0), + isDisplayed())); + appCompatImageButton.perform(click()); + ViewInteraction textView2 = onView( + allOf(withId(R.id.toDoListItemTextview), + childAtPosition( + childAtPosition( + withId(R.id.listItemLinearLayout), + 1), + 0), + isDisplayed())); + textView2.check(matches(withText(TITLE))); + } + @After + public void delete() { + + RecyclerView recyclerView = mActivityTestRule.getActivity().findViewById(R.id.toDoRecyclerView); + int itemCount = recyclerView.getAdapter().getItemCount(); + System.out.println(itemCount); + ViewInteraction linearLayout = onView( + allOf(withId(R.id.listItemLinearLayout), + childAtPosition( + allOf(withId(R.id.toDoRecyclerView), + childAtPosition( + withId(R.id.myCoordinatorLayout), + 1)), + 0), + isDisplayed())); + linearLayout.perform(swipeLeft()); + + } + private static Matcher childAtPosition( + final Matcher parentMatcher, final int position) { + + return new TypeSafeMatcher() { + @Override + public void describeTo(Description description) { + description.appendText("Child at position " + position + " in parent "); + parentMatcher.describeTo(description); + } + + @Override + public boolean matchesSafely(View view) { + ViewParent parent = view.getParent(); + return parent instanceof ViewGroup && parentMatcher.matches(parent) + && view.equals(((ViewGroup) parent).getChildAt(position)); + } + }; + } +} diff --git a/app/src/androidTest/java/com/example/avjindersinghsekhon/minimaltodo/Main/Bala/EditModifySavePageTest.java b/app/src/androidTest/java/com/example/avjindersinghsekhon/minimaltodo/Main/Bala/EditModifySavePageTest.java new file mode 100644 index 00000000..09dcad4f --- /dev/null +++ b/app/src/androidTest/java/com/example/avjindersinghsekhon/minimaltodo/Main/Bala/EditModifySavePageTest.java @@ -0,0 +1,119 @@ +package com.example.avjindersinghsekhon.minimaltodo.Main.Bala; + +import android.view.View; +import android.view.ViewGroup; +import android.view.ViewParent; + +import androidx.recyclerview.widget.RecyclerView; +import androidx.test.espresso.ViewInteraction; +import androidx.test.filters.LargeTest; +import androidx.test.rule.ActivityTestRule; +import androidx.test.runner.AndroidJUnit4; + +import com.example.avjindersinghsekhon.minimaltodo.Main.MainActivity; +import com.example.avjindersinghsekhon.minimaltodo.R; + +import org.hamcrest.Description; +import org.hamcrest.Matcher; +import org.hamcrest.TypeSafeMatcher; +import org.junit.After; +import org.junit.Before; +import org.junit.Rule; +import org.junit.Test; +import org.junit.runner.RunWith; + +import static androidx.test.espresso.Espresso.onView; +import static androidx.test.espresso.action.ViewActions.click; +import static androidx.test.espresso.action.ViewActions.closeSoftKeyboard; +import static androidx.test.espresso.action.ViewActions.replaceText; +import static androidx.test.espresso.action.ViewActions.swipeLeft; +import static androidx.test.espresso.action.ViewActions.typeText; +import static androidx.test.espresso.assertion.ViewAssertions.matches; +import static androidx.test.espresso.matcher.ViewMatchers.isDisplayed; +import static androidx.test.espresso.matcher.ViewMatchers.withId; +import static androidx.test.espresso.matcher.ViewMatchers.withText; +import static org.hamcrest.Matchers.allOf; + +@RunWith(AndroidJUnit4.class) +@LargeTest +public class EditModifySavePageTest { + private static final String TITLE = "Test Title to Save"; + private static final String DESCRIPTION = "Test Description"; + private static final String REPLACE_TITLE = "Replace Test Title"; + private static final String REPLACE_DESCRIPTION = "Replace Test Description"; + + @Rule + public ActivityTestRule mActivityTestRule = new ActivityTestRule<>(MainActivity.class); + + @Before + public void init() { + onView(withId(R.id.addToDoItemFAB)).perform(click()); + onView(withId(R.id.userToDoEditText)).perform(typeText(TITLE), closeSoftKeyboard()); + onView(withId(R.id.userToDoDescription)).perform(typeText(DESCRIPTION), closeSoftKeyboard()); + onView(withId(R.id.makeToDoFloatingActionButton)).perform(click()); + } + @Test + public void edit() { + RecyclerView recyclerView = mActivityTestRule.getActivity().findViewById(R.id.toDoRecyclerView); + int itemCount = recyclerView.getAdapter().getItemCount(); + System.out.println(itemCount); + ViewInteraction linearLayout = onView( + allOf(withId(R.id.listItemLinearLayout), + childAtPosition( + allOf(withId(R.id.toDoRecyclerView), + childAtPosition( + withId(R.id.myCoordinatorLayout), + 1)), + 0), + isDisplayed())); + linearLayout.perform(click()); + onView(withId(R.id.userToDoEditText)).perform(replaceText(REPLACE_TITLE), closeSoftKeyboard()); + onView(withId(R.id.userToDoDescription)).perform(replaceText(REPLACE_DESCRIPTION), closeSoftKeyboard()); + onView(withId(R.id.makeToDoFloatingActionButton)).perform(click()); + ViewInteraction textView2 = onView( + allOf(withId(R.id.toDoListItemTextview), + childAtPosition( + childAtPosition( + withId(R.id.listItemLinearLayout), + 1), + 0), + isDisplayed())); + textView2.check(matches(withText(REPLACE_TITLE))); + } + @After + public void delete() { + + RecyclerView recyclerView = mActivityTestRule.getActivity().findViewById(R.id.toDoRecyclerView); + int itemCount = recyclerView.getAdapter().getItemCount(); + System.out.println(itemCount); + ViewInteraction linearLayout = onView( + allOf(withId(R.id.listItemLinearLayout), + childAtPosition( + allOf(withId(R.id.toDoRecyclerView), + childAtPosition( + withId(R.id.myCoordinatorLayout), + 1)), + 0), + isDisplayed())); + linearLayout.perform(swipeLeft()); + + } + private static Matcher childAtPosition( + final Matcher parentMatcher, final int position) { + + return new TypeSafeMatcher() { + @Override + public void describeTo(Description description) { + description.appendText("Child at position " + position + " in parent "); + parentMatcher.describeTo(description); + } + + @Override + public boolean matchesSafely(View view) { + ViewParent parent = view.getParent(); + return parent instanceof ViewGroup && parentMatcher.matches(parent) + && view.equals(((ViewGroup) parent).getChildAt(position)); + } + }; + } +} diff --git a/app/src/androidTest/java/com/example/avjindersinghsekhon/minimaltodo/Main/Bala/EditVerifyClosePageTest.java b/app/src/androidTest/java/com/example/avjindersinghsekhon/minimaltodo/Main/Bala/EditVerifyClosePageTest.java new file mode 100644 index 00000000..881cdde4 --- /dev/null +++ b/app/src/androidTest/java/com/example/avjindersinghsekhon/minimaltodo/Main/Bala/EditVerifyClosePageTest.java @@ -0,0 +1,119 @@ +package com.example.avjindersinghsekhon.minimaltodo.Main.Bala; + +import android.view.View; +import android.view.ViewGroup; +import android.view.ViewParent; + +import androidx.recyclerview.widget.RecyclerView; +import androidx.test.espresso.ViewInteraction; +import androidx.test.filters.LargeTest; +import androidx.test.rule.ActivityTestRule; +import androidx.test.runner.AndroidJUnit4; + +import com.example.avjindersinghsekhon.minimaltodo.Main.MainActivity; +import com.example.avjindersinghsekhon.minimaltodo.R; + +import org.hamcrest.Description; +import org.hamcrest.Matcher; +import org.hamcrest.TypeSafeMatcher; +import org.junit.After; +import org.junit.Before; +import org.junit.Rule; +import org.junit.Test; +import org.junit.runner.RunWith; + +import static androidx.test.espresso.Espresso.onView; +import static androidx.test.espresso.action.ViewActions.click; +import static androidx.test.espresso.action.ViewActions.closeSoftKeyboard; +import static androidx.test.espresso.action.ViewActions.swipeLeft; +import static androidx.test.espresso.action.ViewActions.typeText; +import static androidx.test.espresso.assertion.ViewAssertions.matches; +import static androidx.test.espresso.matcher.ViewMatchers.isDisplayed; +import static androidx.test.espresso.matcher.ViewMatchers.withClassName; +import static androidx.test.espresso.matcher.ViewMatchers.withContentDescription; +import static androidx.test.espresso.matcher.ViewMatchers.withId; +import static androidx.test.espresso.matcher.ViewMatchers.withText; +import static org.hamcrest.Matchers.allOf; +import static org.hamcrest.Matchers.is; + +@RunWith(AndroidJUnit4.class) +@LargeTest +public class EditVerifyClosePageTest { + private static final String TITLE = "Test Title to Verify"; + private static final String DESCRIPTION = "Test Description"; + + @Rule + public ActivityTestRule mActivityTestRule = new ActivityTestRule<>(MainActivity.class); + + @Before + public void init() { + onView(withId(R.id.addToDoItemFAB)).perform(click()); + onView(withId(R.id.userToDoEditText)).perform(typeText(TITLE), closeSoftKeyboard()); + onView(withId(R.id.userToDoDescription)).perform(typeText(DESCRIPTION), closeSoftKeyboard()); + onView(withId(R.id.makeToDoFloatingActionButton)).perform(click()); + } + @Test + public void edit() { + RecyclerView recyclerView = mActivityTestRule.getActivity().findViewById(R.id.toDoRecyclerView); + int itemCount = recyclerView.getAdapter().getItemCount(); + System.out.println(itemCount); + ViewInteraction linearLayout = onView( + allOf(withId(R.id.listItemLinearLayout), + childAtPosition( + allOf(withId(R.id.toDoRecyclerView), + childAtPosition( + withId(R.id.myCoordinatorLayout), + 1)), + 0), + isDisplayed())); + linearLayout.perform(click()); + onView(withId(R.id.userToDoEditText)).check(matches(withText(TITLE))); + ViewInteraction appCompatImageButton = onView( + allOf(withContentDescription("Navigate up"), + childAtPosition( + allOf(withId(R.id.toolbar), + childAtPosition( + withClassName(is("android.widget.LinearLayout")), + 0)), + 0), + isDisplayed())); + appCompatImageButton.perform(click()); + + } + @After + public void delete() { + + RecyclerView recyclerView = mActivityTestRule.getActivity().findViewById(R.id.toDoRecyclerView); + int itemCount = recyclerView.getAdapter().getItemCount(); + System.out.println(itemCount); + ViewInteraction linearLayout = onView( + allOf(withId(R.id.listItemLinearLayout), + childAtPosition( + allOf(withId(R.id.toDoRecyclerView), + childAtPosition( + withId(R.id.myCoordinatorLayout), + 1)), + 0), + isDisplayed())); + linearLayout.perform(swipeLeft()); + + } + private static Matcher childAtPosition( + final Matcher parentMatcher, final int position) { + + return new TypeSafeMatcher() { + @Override + public void describeTo(Description description) { + description.appendText("Child at position " + position + " in parent "); + parentMatcher.describeTo(description); + } + + @Override + public boolean matchesSafely(View view) { + ViewParent parent = view.getParent(); + return parent instanceof ViewGroup && parentMatcher.matches(parent) + && view.equals(((ViewGroup) parent).getChildAt(position)); + } + }; + } +} diff --git a/app/src/androidTest/java/com/example/avjindersinghsekhon/minimaltodo/Main/Bala/ListPageTest.java b/app/src/androidTest/java/com/example/avjindersinghsekhon/minimaltodo/Main/Bala/ListPageTest.java new file mode 100644 index 00000000..f2c04e14 --- /dev/null +++ b/app/src/androidTest/java/com/example/avjindersinghsekhon/minimaltodo/Main/Bala/ListPageTest.java @@ -0,0 +1,98 @@ +package com.example.avjindersinghsekhon.minimaltodo.Main.Bala; + +import android.view.View; +import android.view.ViewGroup; +import android.view.ViewParent; + +import androidx.recyclerview.widget.RecyclerView; +import androidx.test.espresso.ViewInteraction; +import androidx.test.filters.LargeTest; +import androidx.test.rule.ActivityTestRule; +import androidx.test.runner.AndroidJUnit4; + +import com.example.avjindersinghsekhon.minimaltodo.Main.MainActivity; +import com.example.avjindersinghsekhon.minimaltodo.R; + +import org.hamcrest.Description; +import org.hamcrest.Matcher; +import org.hamcrest.TypeSafeMatcher; +import org.junit.After; +import org.junit.Before; +import org.junit.Rule; +import org.junit.Test; +import org.junit.runner.RunWith; + +import static androidx.test.espresso.Espresso.onView; +import static androidx.test.espresso.action.ViewActions.closeSoftKeyboard; +import static androidx.test.espresso.action.ViewActions.swipeLeft; +import static androidx.test.espresso.action.ViewActions.typeText; +import static androidx.test.espresso.matcher.ViewMatchers.isDisplayed; +import static androidx.test.espresso.matcher.ViewMatchers.withId; +import static androidx.test.espresso.action.ViewActions.click; +import static org.hamcrest.Matchers.allOf; + +@RunWith(AndroidJUnit4.class) +@LargeTest +public class ListPageTest { + + private static final String TITLE = "Test Title"; + private static final String DESCRIPTION = "Test Description"; + + @Rule + public ActivityTestRule mActivityTestRule = new ActivityTestRule<>(MainActivity.class); + + @Before + public void init() { + onView(withId(R.id.addToDoItemFAB)).perform(click()); + onView(withId(R.id.userToDoEditText)).perform(typeText(TITLE), closeSoftKeyboard()); + onView(withId(R.id.userToDoDescription)).perform(typeText(DESCRIPTION), closeSoftKeyboard()); + onView(withId(R.id.makeToDoFloatingActionButton)).perform(click()); + } + + @Test + public void list() { + RecyclerView recyclerView = mActivityTestRule.getActivity().findViewById(R.id.toDoRecyclerView); + int itemCount = recyclerView.getAdapter().getItemCount(); + System.out.println(itemCount); + + } + + @After + public void delete() { + RecyclerView recyclerView = mActivityTestRule.getActivity().findViewById(R.id.toDoRecyclerView); + int itemCount = recyclerView.getAdapter().getItemCount(); + System.out.println(itemCount); + ViewInteraction linearLayout = onView( + allOf(withId(R.id.listItemLinearLayout), + childAtPosition( + allOf(withId(R.id.toDoRecyclerView), + childAtPosition( + withId(R.id.myCoordinatorLayout), + 1)), + 0), + isDisplayed())); + linearLayout.perform(swipeLeft()); + + } + private static Matcher childAtPosition( + final Matcher parentMatcher, final int position) { + + return new TypeSafeMatcher() { + @Override + public void describeTo(Description description) { + description.appendText("Child at position " + position + " in parent "); + parentMatcher.describeTo(description); + } + + @Override + public boolean matchesSafely(View view) { + ViewParent parent = view.getParent(); + return parent instanceof ViewGroup && parentMatcher.matches(parent) + && view.equals(((ViewGroup) parent).getChildAt(position)); + } + }; + } + + + +} diff --git a/app/src/androidTest/java/com/example/avjindersinghsekhon/minimaltodo/Main/MainActivityTest_Nirja.java b/app/src/androidTest/java/com/example/avjindersinghsekhon/minimaltodo/Main/MainActivityTest_Nirja.java new file mode 100644 index 00000000..6b5dd9b6 --- /dev/null +++ b/app/src/androidTest/java/com/example/avjindersinghsekhon/minimaltodo/Main/MainActivityTest_Nirja.java @@ -0,0 +1,89 @@ + +package com.example.avjindersinghsekhon.minimaltodo.Main; + + +import androidx.test.espresso.contrib.RecyclerViewActions; +import androidx.test.rule.ActivityTestRule; +import androidx.test.runner.AndroidJUnit4; + +import com.example.avjindersinghsekhon.minimaltodo.R; + +import org.junit.Rule; +import org.junit.Test; +import org.junit.runner.RunWith; + +import static androidx.test.espresso.Espresso.onView; +import static androidx.test.espresso.action.ViewActions.click; +import static androidx.test.espresso.action.ViewActions.typeText; +import static androidx.test.espresso.assertion.ViewAssertions.matches; +import static androidx.test.espresso.matcher.ViewMatchers.isDisplayed; +import static androidx.test.espresso.matcher.ViewMatchers.withId; + +@RunWith(AndroidJUnit4.class) + + +public class MainActivityTest_Nirja { + @Rule + public ActivityTestRule mActivityRule = new ActivityTestRule(MainActivity.class); + + @Test + public void activityLaunch() { + onView(withId(R.id.addToDoItemFAB)).check(matches(isDisplayed())); + // to check whether the plus button is visible to the user or not + onView(withId(R.id.addToDoItemFAB)).perform(click()); + // to check whether the user able to click the button or not + // then check whether after clicking the plus button First screen switches to second screen + onView(withId(R.id.userToDoEditText)).check(matches(isDisplayed())); + // Is editing text is visible or not + onView(withId(R.id.userToDoDescription)).check(matches(isDisplayed())); + //is description text is visible or not + onView(withId(R.id.userToDoRemindMeTextView)).check(matches(isDisplayed())); + // Remind me text is visible or not + onView(withId(R.id.copyclipboard)).check(matches(isDisplayed())); + // matches whether copy to clipboard button is present or not + onView(withId(R.id.makeToDoFloatingActionButton)).check(matches(isDisplayed())); + //matches whether arrow button is present or not + onView(withId(R.id.toDoHasDateSwitchCompat)).check(matches(isDisplayed())); + //matches whether slider is present or not + + } + + @Test + public void textInputOutput(){ + onView(withId(R.id.addToDoItemFAB)).perform(click()); + // click the add (+) button, to add a new todo list + onView(withId(R.id.userToDoEditText)).perform( + typeText("This is a test.")); + //enter the task to be performed + onView(withId(R.id.userToDoDescription)).perform( + typeText("This is also a test.")); + //describe the task to be performed + onView(withId(R.id.makeToDoFloatingActionButton)).perform(click()); + //click the floating button to save the task + onView(withId(R.id.toDoRecyclerView)).perform(RecyclerViewActions.scrollToPosition(0)); + // Scroll to view item at a particular location + onView(withId(R.id.toDoRecyclerView)).perform(RecyclerViewActions.actionOnItemAtPosition(0,click())); + // click the item to view the task + } + //@Test + // public void Failing_test(){ + // onView(withId(R.id.addToDoItemFAB)).perform(click()); + //click the add (+) button, to add a new todo list + // onView(withId(R.id.userToDoEditText)).perform( + // typeText("This is a test.")); + //onView(withId(R.id.userToDoEditText)).check(matches(withText("This is a failing test"))); + + +} + + + + + + + + + + + + diff --git a/app/src/androidTest/java/com/example/avjindersinghsekhon/minimaltodo/Main/Save.java b/app/src/androidTest/java/com/example/avjindersinghsekhon/minimaltodo/Main/Save.java new file mode 100644 index 00000000..1448b26e --- /dev/null +++ b/app/src/androidTest/java/com/example/avjindersinghsekhon/minimaltodo/Main/Save.java @@ -0,0 +1,121 @@ +package com.example.avjindersinghsekhon.minimaltodo.Main; + + +import android.view.View; +import android.view.ViewGroup; +import android.view.ViewParent; + +import androidx.test.espresso.ViewInteraction; +import androidx.test.filters.LargeTest; +import androidx.test.rule.ActivityTestRule; +import androidx.test.runner.AndroidJUnit4; + +import com.example.avjindersinghsekhon.minimaltodo.R; + +import org.hamcrest.Description; +import org.hamcrest.Matcher; +import org.hamcrest.TypeSafeMatcher; +import org.junit.Rule; +import org.junit.Test; +import org.junit.runner.RunWith; + +import static androidx.test.espresso.Espresso.onView; +import static androidx.test.espresso.action.ViewActions.click; +import static androidx.test.espresso.action.ViewActions.closeSoftKeyboard; +import static androidx.test.espresso.action.ViewActions.replaceText; +import static androidx.test.espresso.assertion.ViewAssertions.matches; +import static androidx.test.espresso.matcher.ViewMatchers.isDisplayed; +import static androidx.test.espresso.matcher.ViewMatchers.withClassName; +import static androidx.test.espresso.matcher.ViewMatchers.withId; +import static org.hamcrest.Matchers.allOf; +import static org.hamcrest.Matchers.is; + +@LargeTest +@RunWith(AndroidJUnit4.class) +public class Save { + + @Rule + public ActivityTestRule mActivityTestRule = new ActivityTestRule<>(MainActivity.class); + + @Test + public void mainActivityTest() { + // Added a sleep statement to match the app's execution delay. + // The recommended way to handle such scenarios is to use Espresso idling resources: + // https://google.github.io/android-testing-support-library/docs/espresso/idling-resource/index.html + try { + Thread.sleep(3000); + } catch (InterruptedException e) { + e.printStackTrace(); + } + + ViewInteraction floatingActionButton = onView( + allOf(withId(R.id.addToDoItemFAB), + childAtPosition( + allOf(withId(R.id.myCoordinatorLayout), + childAtPosition( + withId(R.id.myParentLayout), + 0)), + 2), + isDisplayed())); + floatingActionButton.perform(click()); + + // Added a sleep statement to match the app's execution delay. + // The recommended way to handle such scenarios is to use Espresso idling resources: + // https://google.github.io/android-testing-support-library/docs/espresso/idling-resource/index.html + try { + Thread.sleep(3000); + } catch (InterruptedException e) { + e.printStackTrace(); + } + + ViewInteraction appCompatEditText = onView( + allOf(withId(R.id.userToDoEditText), + childAtPosition( + childAtPosition( + withId(R.id.toDoCustomTextInput), + 0), + 0), + isDisplayed())); + appCompatEditText.perform(replaceText("Title"), closeSoftKeyboard()); + + ViewInteraction appCompatEditText2 = onView( + allOf(withId(R.id.userToDoDescription), + childAtPosition( + childAtPosition( + withId(R.id.toDoCustomTextInput01), + 0), + 0), + isDisplayed())); + appCompatEditText2.perform(replaceText("Description Test"), closeSoftKeyboard()); + + ViewInteraction floatingActionButton2 = onView( + allOf(withId(R.id.makeToDoFloatingActionButton), + childAtPosition( + childAtPosition( + withClassName(is("android.widget.LinearLayout")), + 1), + 1), + isDisplayed())); + floatingActionButton2.perform(click()); + + } + + private static Matcher childAtPosition( + final Matcher parentMatcher, final int position) { + + return new TypeSafeMatcher() { + @Override + public void describeTo(Description description) { + description.appendText("Child at position " + position + " in parent "); + parentMatcher.describeTo(description); + } + + @Override + public boolean matchesSafely(View view) { + ViewParent parent = view.getParent(); + return parent instanceof ViewGroup && parentMatcher.matches(parent) + && view.equals(((ViewGroup) parent).getChildAt(position)); + } + }; + } +} diff --git a/app/src/androidTest/java/com/example/avjindersinghsekhon/minimaltodo/Main/SaveWithReminderData.java b/app/src/androidTest/java/com/example/avjindersinghsekhon/minimaltodo/Main/SaveWithReminderData.java new file mode 100644 index 00000000..f5fdaa44 --- /dev/null +++ b/app/src/androidTest/java/com/example/avjindersinghsekhon/minimaltodo/Main/SaveWithReminderData.java @@ -0,0 +1,179 @@ +package com.example.avjindersinghsekhon.minimaltodo.Main; + + +import android.view.View; +import android.view.ViewGroup; +import android.view.ViewParent; +import android.widget.Button; + +import androidx.test.espresso.ViewInteraction; +import androidx.test.filters.LargeTest; +import androidx.test.rule.ActivityTestRule; +import androidx.test.runner.AndroidJUnit4; + +import com.example.avjindersinghsekhon.minimaltodo.R; + +import org.hamcrest.Description; +import org.hamcrest.Matcher; +import org.hamcrest.TypeSafeMatcher; +import org.junit.Rule; +import org.junit.runner.RunWith; + +import static androidx.test.espresso.Espresso.onView; +import static androidx.test.espresso.action.ViewActions.click; +import static androidx.test.espresso.action.ViewActions.closeSoftKeyboard; +import static androidx.test.espresso.action.ViewActions.replaceText; +import static androidx.test.espresso.assertion.ViewAssertions.matches; +import static androidx.test.espresso.matcher.ViewMatchers.isAssignableFrom; +import static androidx.test.espresso.matcher.ViewMatchers.isDisplayed; +import static androidx.test.espresso.matcher.ViewMatchers.withClassName; +import static androidx.test.espresso.matcher.ViewMatchers.withId; +import static androidx.test.espresso.matcher.ViewMatchers.withText; +import static org.hamcrest.Matchers.allOf; +import static org.hamcrest.Matchers.is; + +@LargeTest +@RunWith(AndroidJUnit4.class) +public class SaveWithReminderData { + + @Rule + public ActivityTestRule mActivityTestRule = new ActivityTestRule<>(MainActivity.class); + +// @Test + public void mainActivityTest2() { + // Added a sleep statement to match the app's execution delay. + // The recommended way to handle such scenarios is to use Espresso idling resources: + // https://google.github.io/android-testing-support-library/docs/espresso/idling-resource/index.html + try { + Thread.sleep(7000); + } catch (InterruptedException e) { + e.printStackTrace(); + } + + ViewInteraction floatingActionButton = onView( + allOf(withId(R.id.addToDoItemFAB), + childAtPosition( + allOf(withId(R.id.myCoordinatorLayout), + childAtPosition( + withId(R.id.myParentLayout), + 0)), + 2), + isDisplayed())); + floatingActionButton.perform(click()); + + // Added a sleep statement to match the app's execution delay. + // The recommended way to handle such scenarios is to use Espresso idling resources: + // https://google.github.io/android-testing-support-library/docs/espresso/idling-resource/index.html + try { + Thread.sleep(7000); + } catch (InterruptedException e) { + e.printStackTrace(); + } + + ViewInteraction appCompatEditText = onView( + allOf(withId(R.id.userToDoEditText), + childAtPosition( + childAtPosition( + withId(R.id.toDoCustomTextInput), + 0), + 0), + isDisplayed())); + appCompatEditText.perform(replaceText("Test 2"), closeSoftKeyboard()); + + ViewInteraction appCompatEditText2 = onView( + allOf(withId(R.id.userToDoDescription), + childAtPosition( + childAtPosition( + withId(R.id.toDoCustomTextInput01), + 0), + 0), + isDisplayed())); + appCompatEditText2.perform(replaceText("Desc%"), closeSoftKeyboard()); + + ViewInteraction switchCompat = onView( + allOf(withId(R.id.toDoHasDateSwitchCompat), + childAtPosition( + childAtPosition( + withId(R.id.todoReminderAndDateContainerLayout), + 0), + 2), + isDisplayed())); + switchCompat.perform(click()); + + // Added a sleep statement to match the app's execution delay. + // The recommended way to handle such scenarios is to use Espresso idling resources: + // https://google.github.io/android-testing-support-library/docs/espresso/idling-resource/index.html + try { + Thread.sleep(7000); + } catch (InterruptedException e) { + e.printStackTrace(); + } + +// ViewInteraction appCompatEditText3 = onView( +// allOf(withId(R.id.newTodoTimeEditText), withText("3:00 AM"), +// childAtPosition( +// childAtPosition( +// withId(R.id.toDoEnterDateLinearLayout), +// 0), +// 2), +// isDisplayed())); +// appCompatEditText3.perform(click()); + + // Added a sleep statement to match the app's execution delay. + // The recommended way to handle such scenarios is to use Espresso idling resources: + // https://google.github.io/android-testing-support-library/docs/espresso/idling-resource/index.html + try { + Thread.sleep(100); + } catch (InterruptedException e) { + e.printStackTrace(); + } + +// ViewInteraction appCompatButton = onView( +// allOf(withId(R.id.ok), withText("OK"), +// childAtPosition( +// allOf(withId(R.id.done_background), +// childAtPosition( +// withId(R.id.time_picker_dialog), +// 1)), +// 1), +// isDisplayed())); +// appCompatButton.perform(click()); + + // accept the selected date + onView(allOf(withId(R.id.ok), isAssignableFrom(Button.class))) + // check button text is "Ok" + .check(matches(withText("OK"))) + // check OK button is displayed to the user + .check(matches(isDisplayed())) + .perform(click()); + + ViewInteraction floatingActionButton2 = onView( + allOf(withId(R.id.makeToDoFloatingActionButton), + childAtPosition( + childAtPosition( + withClassName(is("android.widget.LinearLayout")), + 1), + 1), + isDisplayed())); + floatingActionButton2.perform(click()); + } + + private static Matcher childAtPosition( + final Matcher parentMatcher, final int position) { + + return new TypeSafeMatcher() { + @Override + public void describeTo(Description description) { + description.appendText("Child at position " + position + " in parent "); + parentMatcher.describeTo(description); + } + + @Override + public boolean matchesSafely(View view) { + ViewParent parent = view.getParent(); + return parent instanceof ViewGroup && parentMatcher.matches(parent) + && view.equals(((ViewGroup) parent).getChildAt(position)); + } + }; + } +} diff --git a/app/src/androidTest/java/com/example/avjindersinghsekhon/minimaltodo/MainActivityTest.java b/app/src/androidTest/java/com/example/avjindersinghsekhon/minimaltodo/MainActivityTest.java new file mode 100644 index 00000000..9355baa4 --- /dev/null +++ b/app/src/androidTest/java/com/example/avjindersinghsekhon/minimaltodo/MainActivityTest.java @@ -0,0 +1,70 @@ +package com.example.avjindersinghsekhon.minimaltodo; + +import android.content.Context; +import android.os.Environment; +import android.util.Log; + +import androidx.test.platform.app.InstrumentationRegistry; +import androidx.test.rule.ActivityTestRule; + +import com.example.avjindersinghsekhon.minimaltodo.Main.MainActivity; +import com.example.avjindersinghsekhon.minimaltodo.Main.MainFragment; + +import org.junit.Before; +import org.junit.Rule; +import org.junit.Test; + +import java.io.File; + +import static androidx.test.espresso.Espresso.onView; +import static androidx.test.espresso.assertion.ViewAssertions.matches; +import static androidx.test.espresso.matcher.ViewMatchers.isDisplayed; +import static androidx.test.espresso.matcher.ViewMatchers.withId; + +public class MainActivityTest { + + Context mContext; + + @Rule + public ActivityTestRule mActivityTestRule = new ActivityTestRule<>(MainActivity.class); + + @Before + public void setUp(){ + mContext = InstrumentationRegistry.getInstrumentation().getTargetContext(); + boolean deleted = mActivityTestRule.getActivity().deleteFile(MainFragment.FILENAME); + Log.d("TEST", "1st deleted: " + deleted); + + mContext.deleteFile(MainFragment.FILENAME); + + Log.d("TEST", "2sd deleted: " + deleted); + File dir = mContext.getFilesDir(); + File file = new File(dir, MainFragment.FILENAME); + deleted = file.delete(); + + Log.d("TEST", "deleted: " + deleted); + } + + private void deleteTempFolder(String dir) { + File myDir = new File(Environment.getExternalStorageDirectory() + "/"+dir); + if (myDir.isDirectory()) { + String[] children = myDir.list(); + for (int i = 0; i < children.length; i++) { + new File(myDir, children[i]).delete(); + } + } + } + + @Test + public void testEmptyStateViewsDisplayed() { // Looking for floating action button in main screen. + onView(withId(R.id.addToDoItemFAB)) // withId(R.id.my_view) is a ViewMatcher + .check(matches(isDisplayed())); // matches(isDisplayed()) is a ViewAssertion + +// onView(withText("You don't have any todos")) +// .check(matches(isDisplayed())); +// +// // check that ImageView for empty list in visible to user +// onView(withId(R.id.empty_todo_imageView)) +// .check(matches(isDisplayed())); + } + +} diff --git a/app/src/androidTest/java/com/example/avjindersinghsekhon/minimaltodo/TestStoreRetrieveData.java b/app/src/androidTest/java/com/example/avjindersinghsekhon/minimaltodo/TestStoreRetrieveData.java index f698fe54..87442e27 100644 --- a/app/src/androidTest/java/com/example/avjindersinghsekhon/minimaltodo/TestStoreRetrieveData.java +++ b/app/src/androidTest/java/com/example/avjindersinghsekhon/minimaltodo/TestStoreRetrieveData.java @@ -24,13 +24,18 @@ package com.example.avjindersinghsekhon.minimaltodo; import android.content.Context; -import android.test.ActivityUnitTestCase; + +import androidx.test.platform.app.InstrumentationRegistry; import com.example.avjindersinghsekhon.minimaltodo.Main.MainActivity; +import com.example.avjindersinghsekhon.minimaltodo.Main.MainFragment; import com.example.avjindersinghsekhon.minimaltodo.Utility.StoreRetrieveData; import com.example.avjindersinghsekhon.minimaltodo.Utility.ToDoItem; import org.json.JSONArray; +import org.junit.After; +import org.junit.Assert; +import org.junit.Before; import java.util.ArrayList; import java.util.Date; @@ -38,29 +43,28 @@ /** * Test cases for StoreRetrieveData class */ -public class TestStoreRetrieveData extends ActivityUnitTestCase { +public class TestStoreRetrieveData{ private MainActivity mMainActivity; private ArrayList mOriginalData; ArrayList mTestData; + public TestStoreRetrieveData() { - super(MainActivity.class); // Create some test data mTestData = new ArrayList<>(); for (int i = 1; i < 11; i++) { mTestData.add(new ToDoItem( - "item" + i, + "item" + i,"item Desc" + i, false, new Date())); } } - @Override - protected void setUp() throws Exception { - super.setUp(); - mMainActivity = getActivity(); + @Before + public void setUp() throws Exception { + mMainActivity = new MainActivity(); mOriginalData = new ArrayList<>(); // Save the original data and wipe out the storage @@ -77,14 +81,12 @@ protected void setUp() throws Exception { } } catch (Exception e) { - fail("Couldn't store data: " + e.getMessage()); + Assert.fail("Couldn't store data: " + e.getMessage()); } } - @Override - protected void tearDown() throws Exception { - super.tearDown(); - + @After + public void tearDown() throws Exception { // Let's restore the data we might have wiped out during setUp()... StoreRetrieveData dataStorage = getDataStorage(); dataStorage.saveToFile(mOriginalData); @@ -93,6 +95,7 @@ protected void tearDown() throws Exception { /** * We should have an empty data storage at hand for the starters */ +// @Test public void testPreconditions() { StoreRetrieveData dataStorage = getDataStorage(); @@ -100,15 +103,16 @@ public void testPreconditions() { try { items = dataStorage.loadFromFile(); } catch (Exception e) { - fail("Couldn't read from data storage: " + e.getMessage()); + Assert.fail("Couldn't read from data storage: " + e.getMessage()); } - assertEquals(0, items.size()); + Assert.assertEquals(0, items.size()); } /** * Write items to data storage and ensure those same items can be retrieved from the storage. */ +// @Test public void testWritingToAndReadingFromTheDataStorage() { StoreRetrieveData dataStorage = getDataStorage(); ArrayList retrievedItems = new ArrayList<>(); @@ -117,18 +121,18 @@ public void testWritingToAndReadingFromTheDataStorage() { try { dataStorage.saveToFile(mTestData); } catch (Exception e) { - fail("Couldn't store data: " + e.getMessage()); + Assert.fail("Couldn't store data: " + e.getMessage()); } // Read from storage try { retrievedItems = dataStorage.loadFromFile(); } catch (Exception e) { - fail("Couldn't read from data storage: " + e.getMessage()); + Assert.fail("Couldn't read from data storage: " + e.getMessage()); } // We should have equal amount of items than what we just stored - assertEquals(mTestData.size(), retrievedItems.size()); + Assert.assertEquals(mTestData.size(), retrievedItems.size()); // The content should be same as well... for (ToDoItem retrievedItem : retrievedItems) { @@ -149,7 +153,7 @@ public void testWritingToAndReadingFromTheDataStorage() { } if (!found) { - fail("Content mis-match between test data and data retrieved from the storage!"); + Assert.fail("Content mis-match between test data and data retrieved from the storage!"); } } } @@ -157,17 +161,18 @@ public void testWritingToAndReadingFromTheDataStorage() { /** * Ensure JSONArray conversion works as intended */ +// @Test public void testArrayListToJsonArrayConversion() { try { JSONArray array = StoreRetrieveData.toJSONArray(mTestData); - assertEquals(mTestData.size(), array.length()); + Assert.assertEquals(mTestData.size(), array.length()); } catch (Exception e) { - fail("Exception thrown when converting to JSONArray: " + e.getMessage()); + Assert.fail("Exception thrown when converting to JSONArray: " + e.getMessage()); } } private StoreRetrieveData getDataStorage() { - Context context = getInstrumentation().getTargetContext(); - return new StoreRetrieveData(context, MainActivity.FILENAME); + Context context = InstrumentationRegistry.getInstrumentation().getTargetContext(); + return new StoreRetrieveData(context, MainFragment.FILENAME); } } diff --git a/app/src/androidTest/java/com/example/avjindersinghsekhon/minimaltodo/TestTodoItem.java b/app/src/androidTest/java/com/example/avjindersinghsekhon/minimaltodo/TestTodoItem.java index 8a4faf04..14c78b13 100644 --- a/app/src/androidTest/java/com/example/avjindersinghsekhon/minimaltodo/TestTodoItem.java +++ b/app/src/androidTest/java/com/example/avjindersinghsekhon/minimaltodo/TestTodoItem.java @@ -25,17 +25,19 @@ import com.example.avjindersinghsekhon.minimaltodo.Utility.ToDoItem; -import junit.framework.TestCase; import org.json.JSONException; import org.json.JSONObject; +import org.junit.Assert; +import org.junit.Test; + import java.util.Date; /** * JUnit tests to verify functionality of ToDoItem class. */ -public class TestTodoItem extends TestCase { +public class TestTodoItem { private final Date CURRENT_DATE = new Date(); private final String TEXT_BODY = "This is some text"; private final boolean REMINDER_OFF = false; @@ -44,32 +46,35 @@ public class TestTodoItem extends TestCase { /** * Check we can construct a ToDoItem object using the three parameter constructor */ + @Test public void testThreeParameterConstructor() { ToDoItem toDoItem = getToDoItem(REMINDER_OFF); - assertEquals(TEXT_BODY, toDoItem.getToDoText()); - assertEquals(REMINDER_OFF, toDoItem.hasReminder()); - assertEquals(CURRENT_DATE, toDoItem.getToDoDate()); + Assert.assertEquals(TEXT_BODY, toDoItem.getToDoText()); + Assert.assertEquals(REMINDER_OFF, toDoItem.hasReminder()); + Assert.assertEquals(CURRENT_DATE, toDoItem.getToDoDate()); } /** * Ensure we can marshall ToDoItem objects to Json */ + @Test public void testObjectMarshallingToJson() { ToDoItem toDoItem = getToDoItem(REMINDER_ON); try { JSONObject json = toDoItem.toJSON(); - assertEquals(TEXT_BODY, json.getString("todotext")); - assertEquals(REMINDER_ON, json.getBoolean("todoreminder")); - assertEquals(String.valueOf(CURRENT_DATE.getTime()), json.getString("tododate")); + Assert.assertEquals(TEXT_BODY, json.getString("todotext")); + Assert.assertEquals(REMINDER_ON, json.getBoolean("todoreminder")); + Assert.assertEquals(String.valueOf(CURRENT_DATE.getTime()), json.getString("tododate")); } catch (JSONException e) { - fail("Exception thrown during test execution: " + e.getMessage()); + Assert.fail("Exception thrown during test execution: " + e.getMessage()); } } /** * Ensure we can create ToDoItem objects from Json data by using the json constructor */ + @Test public void testObjectUnmarshallingFromJson() { ToDoItem originalItem = getToDoItem(REMINDER_OFF); @@ -77,17 +82,17 @@ public void testObjectUnmarshallingFromJson() { JSONObject json = originalItem.toJSON(); ToDoItem itemFromJson = new ToDoItem(json); - assertEquals(originalItem.getToDoText(), itemFromJson.getToDoText()); - assertEquals(originalItem.getToDoDate(), itemFromJson.getToDoDate()); - assertEquals(originalItem.hasReminder(), itemFromJson.hasReminder()); - assertEquals(originalItem.getIdentifier(), itemFromJson.getIdentifier()); + Assert.assertEquals(originalItem.getToDoText(), itemFromJson.getToDoText()); + Assert.assertEquals(originalItem.getToDoDate(), itemFromJson.getToDoDate()); + Assert.assertEquals(originalItem.hasReminder(), itemFromJson.hasReminder()); + Assert.assertEquals(originalItem.getIdentifier(), itemFromJson.getIdentifier()); } catch (JSONException e) { - fail("Exception thrown during test execution: " + e.getMessage()); + Assert.fail("Exception thrown during test execution: " + e.getMessage()); } } private ToDoItem getToDoItem(boolean hasReminder) { - return new ToDoItem(TEXT_BODY, hasReminder, CURRENT_DATE); + return new ToDoItem(TEXT_BODY,TEXT_BODY, hasReminder, CURRENT_DATE); } } diff --git a/app/src/androidTest/java/com/example/avjindersinghsekhon/minimaltodo/Util/CustomJUnitRunner.java b/app/src/androidTest/java/com/example/avjindersinghsekhon/minimaltodo/Util/CustomJUnitRunner.java new file mode 100644 index 00000000..e8155fff --- /dev/null +++ b/app/src/androidTest/java/com/example/avjindersinghsekhon/minimaltodo/Util/CustomJUnitRunner.java @@ -0,0 +1,89 @@ +package com.example.avjindersinghsekhon.minimaltodo.Util; + +import android.annotation.SuppressLint; +import android.app.Activity; +import android.app.KeyguardManager; +import android.content.Context; +import android.os.Build; +import android.os.PowerManager; +import android.util.Log; + +import androidx.annotation.NonNull; +import androidx.test.runner.AndroidJUnitRunner; +import androidx.test.runner.lifecycle.ActivityLifecycleCallback; +import androidx.test.runner.lifecycle.ActivityLifecycleMonitorRegistry; +import androidx.test.runner.lifecycle.Stage; + +import static android.content.Context.KEYGUARD_SERVICE; +import static android.content.Context.POWER_SERVICE; +import static android.view.WindowManager.LayoutParams.FLAG_DISMISS_KEYGUARD; +import static android.view.WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON; +import static android.view.WindowManager.LayoutParams.FLAG_SHOW_WHEN_LOCKED; +import static android.view.WindowManager.LayoutParams.FLAG_TURN_SCREEN_ON; + +public class CustomJUnitRunner extends AndroidJUnitRunner { + + @SuppressLint("MissingPermission") + @Override public void onStart() { + Log.d("TEST", "OnStart"); + + ActivityLifecycleMonitorRegistry.getInstance().addLifecycleCallback(new ActivityLifecycleCallback() { + @Override public void onActivityLifecycleChanged(Activity activity, Stage stage) { + + Context app = getTargetContext().getApplicationContext(); + + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O_MR1) { + + activity.setShowWhenLocked(true); + activity.setTurnScreenOn(true); + // Unlock the device so that the tests can input keystrokes. + KeyguardManager keyguardManager = (KeyguardManager) app.getSystemService(KEYGUARD_SERVICE); + assert keyguardManager != null; + + if (keyguardManager.isKeyguardLocked()) { + keyguardManager.requestDismissKeyguard( + activity, new MinimalKeyguardDismissCallback(keyguardManager)); + } + + } else if (stage == Stage.PRE_ON_CREATE) { + activity.getWindow().addFlags(FLAG_DISMISS_KEYGUARD | FLAG_SHOW_WHEN_LOCKED + | FLAG_TURN_SCREEN_ON | FLAG_KEEP_SCREEN_ON); + } + + PowerManager powerManager = (PowerManager) app.getSystemService(POWER_SERVICE); + boolean isScreenAwake = powerManager != null && powerManager.isInteractive(); + Log.d("TEST", "isScreenAwake: " + isScreenAwake); + } + }); + + super.onStart(); + } + + public class MinimalKeyguardDismissCallback extends KeyguardManager.KeyguardDismissCallback { + + KeyguardManager mKeyguardManager; + + MinimalKeyguardDismissCallback(@NonNull KeyguardManager keyguardManager) { + mKeyguardManager = keyguardManager; + } + + @Override + public void onDismissSucceeded() { + super.onDismissSucceeded(); + boolean isPhoneLocked = mKeyguardManager.isDeviceLocked(); + Log.d("TEST", "onDismissSucceeded isPhoneLocked: " + isPhoneLocked); + } + + @Override + public void onDismissError() { + Log.d("TEST", "onDismissError"); + } + + @Override + public void onDismissCancelled() { + Log.d("TEST", "onDismissCancelled"); + boolean isPhoneLocked = mKeyguardManager.isDeviceLocked(); + Log.d("TEST", "onDismissCancelled isPhoneLocked: " + isPhoneLocked); + } + } +} diff --git a/app/src/androidTest/java/com/example/avjindersinghsekhon/minimaltodo/Util/CustomMatchers.java b/app/src/androidTest/java/com/example/avjindersinghsekhon/minimaltodo/Util/CustomMatchers.java new file mode 100644 index 00000000..23b225de --- /dev/null +++ b/app/src/androidTest/java/com/example/avjindersinghsekhon/minimaltodo/Util/CustomMatchers.java @@ -0,0 +1,30 @@ +package com.example.avjindersinghsekhon.minimaltodo.Util; + +import android.view.View; +import android.view.ViewGroup; +import android.view.ViewParent; + +import org.hamcrest.Description; +import org.hamcrest.Matcher; +import org.hamcrest.TypeSafeMatcher; + +public class CustomMatchers { + public static Matcher childAtPosition( + final Matcher parentMatcher, final int position) { + + return new TypeSafeMatcher() { + @Override + public void describeTo(Description description) { + description.appendText("Child at position " + position + " in parent "); + parentMatcher.describeTo(description); + } + + @Override + public boolean matchesSafely(View view) { + ViewParent parent = view.getParent(); + return parent instanceof ViewGroup && parentMatcher.matches(parent) + && view.equals(((ViewGroup) parent).getChildAt(position)); + } + }; + } +} diff --git a/app/src/main/java/com/example/avjindersinghsekhon/minimaltodo/About/AboutActivity.java b/app/src/main/java/com/example/avjindersinghsekhon/minimaltodo/About/AboutActivity.java index 95463fdb..d746b39e 100644 --- a/app/src/main/java/com/example/avjindersinghsekhon/minimaltodo/About/AboutActivity.java +++ b/app/src/main/java/com/example/avjindersinghsekhon/minimaltodo/About/AboutActivity.java @@ -5,14 +5,15 @@ import android.graphics.PorterDuff; import android.graphics.drawable.Drawable; import android.os.Bundle; -import android.support.annotation.NonNull; -import android.support.v4.app.Fragment; -import android.support.v4.app.NavUtils; -import android.support.v7.widget.Toolbar; import android.util.Log; import android.view.MenuItem; import android.widget.TextView; +import androidx.annotation.NonNull; +import androidx.appcompat.widget.Toolbar; +import androidx.core.app.NavUtils; +import androidx.fragment.app.Fragment; + import com.example.avjindersinghsekhon.minimaltodo.Analytics.AnalyticsApplication; import com.example.avjindersinghsekhon.minimaltodo.AppDefault.AppDefaultActivity; import com.example.avjindersinghsekhon.minimaltodo.Main.MainFragment; @@ -44,7 +45,7 @@ protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); // mId = (UUID)i.getSerializableExtra(TodoNotificationService.TODOUUID); - final Drawable backArrow = getResources().getDrawable(R.drawable.abc_ic_ab_back_mtrl_am_alpha); + final Drawable backArrow = getResources().getDrawable(R.drawable.abc_ic_ab_back_material); if (backArrow != null) { backArrow.setColorFilter(Color.WHITE, PorterDuff.Mode.SRC_ATOP); } diff --git a/app/src/main/java/com/example/avjindersinghsekhon/minimaltodo/About/AboutFragment.java b/app/src/main/java/com/example/avjindersinghsekhon/minimaltodo/About/AboutFragment.java index 11e26df5..4d019c21 100644 --- a/app/src/main/java/com/example/avjindersinghsekhon/minimaltodo/About/AboutFragment.java +++ b/app/src/main/java/com/example/avjindersinghsekhon/minimaltodo/About/AboutFragment.java @@ -1,9 +1,9 @@ package com.example.avjindersinghsekhon.minimaltodo.About; import android.os.Bundle; -import android.support.annotation.LayoutRes; -import android.support.annotation.Nullable; -import android.support.v7.widget.Toolbar; +import androidx.annotation.LayoutRes; +import androidx.annotation.Nullable; +import androidx.appcompat.widget.Toolbar; import android.view.View; import android.widget.TextView; diff --git a/app/src/main/java/com/example/avjindersinghsekhon/minimaltodo/AddToDo/AddToDoActivity.java b/app/src/main/java/com/example/avjindersinghsekhon/minimaltodo/AddToDo/AddToDoActivity.java index cfe60324..78d52714 100644 --- a/app/src/main/java/com/example/avjindersinghsekhon/minimaltodo/AddToDo/AddToDoActivity.java +++ b/app/src/main/java/com/example/avjindersinghsekhon/minimaltodo/AddToDo/AddToDoActivity.java @@ -1,8 +1,8 @@ package com.example.avjindersinghsekhon.minimaltodo.AddToDo; import android.os.Bundle; -import android.support.annotation.NonNull; -import android.support.v4.app.Fragment; +import androidx.annotation.NonNull; +import androidx.fragment.app.Fragment; import com.example.avjindersinghsekhon.minimaltodo.AppDefault.AppDefaultActivity; import com.example.avjindersinghsekhon.minimaltodo.R; diff --git a/app/src/main/java/com/example/avjindersinghsekhon/minimaltodo/AddToDo/AddToDoFragment.java b/app/src/main/java/com/example/avjindersinghsekhon/minimaltodo/AddToDo/AddToDoFragment.java index 01ea89a6..c22eb61b 100644 --- a/app/src/main/java/com/example/avjindersinghsekhon/minimaltodo/AddToDo/AddToDoFragment.java +++ b/app/src/main/java/com/example/avjindersinghsekhon/minimaltodo/AddToDo/AddToDoFragment.java @@ -9,12 +9,6 @@ import android.graphics.PorterDuff; import android.graphics.drawable.Drawable; import android.os.Bundle; -import android.support.annotation.Nullable; -import android.support.design.widget.FloatingActionButton; -import android.support.v4.app.NavUtils; -import android.support.v7.app.AppCompatActivity; -import android.support.v7.widget.SwitchCompat; -import android.support.v7.widget.Toolbar; import android.text.Editable; import android.text.TextWatcher; import android.text.format.DateFormat; @@ -28,15 +22,20 @@ import android.widget.ImageButton; import android.widget.LinearLayout; import android.widget.TextView; -import android.content.ClipboardManager; import android.widget.Toast; +import androidx.annotation.Nullable; +import androidx.appcompat.app.AppCompatActivity; +import androidx.appcompat.widget.SwitchCompat; +import androidx.appcompat.widget.Toolbar; +import androidx.core.app.NavUtils; + import com.example.avjindersinghsekhon.minimaltodo.Analytics.AnalyticsApplication; import com.example.avjindersinghsekhon.minimaltodo.AppDefault.AppDefaultFragment; -import com.example.avjindersinghsekhon.minimaltodo.Main.MainActivity; import com.example.avjindersinghsekhon.minimaltodo.Main.MainFragment; import com.example.avjindersinghsekhon.minimaltodo.R; import com.example.avjindersinghsekhon.minimaltodo.Utility.ToDoItem; +import com.google.android.material.floatingactionbutton.FloatingActionButton; import com.wdullaer.materialdatetimepicker.date.DatePickerDialog; import com.wdullaer.materialdatetimepicker.time.RadialPickerLayout; import com.wdullaer.materialdatetimepicker.time.TimePickerDialog; @@ -75,7 +74,7 @@ public class AddToDoFragment extends AppDefaultFragment implements DatePickerDia private ToDoItem mUserToDoItem; private FloatingActionButton mToDoSendFloatingActionButton; - public static final String DATE_FORMAT = "MMM d, yyyy"; + public static final String DATE_FORMAT = "d MMM, yyyy"; public static final String DATE_FORMAT_MONTH_DAY = "MMM d"; public static final String DATE_FORMAT_TIME = "H:m"; @@ -414,10 +413,22 @@ public void onClick(View v) { } + static public Date getAdjustedDate(Context context) { + boolean time24 = DateFormat.is24HourFormat(context); + Calendar cal = Calendar.getInstance(); + if (time24) { + cal.set(Calendar.HOUR_OF_DAY, cal.get(Calendar.HOUR_OF_DAY) + 1); + } else { + cal.set(Calendar.HOUR, cal.get(Calendar.HOUR) + 1); + } + cal.set(Calendar.MINUTE, 0); + return cal.getTime(); + } + private void setDateAndTimeEditText() { if (mUserToDoItem.hasReminder() && mUserReminderDate != null) { - String userDate = formatDate("d MMM, yyyy", mUserReminderDate); + String userDate = formatDate(DATE_FORMAT, mUserReminderDate); String formatToUse; if (DateFormat.is24HourFormat(getContext())) { formatToUse = "k:mm"; @@ -433,21 +444,10 @@ private void setDateAndTimeEditText() { mDateEditText.setText(getString(R.string.date_reminder_default)); // mUserReminderDate = new Date(); boolean time24 = DateFormat.is24HourFormat(getContext()); - Calendar cal = Calendar.getInstance(); - if (time24) { - cal.set(Calendar.HOUR_OF_DAY, cal.get(Calendar.HOUR_OF_DAY) + 1); - } else { - cal.set(Calendar.HOUR, cal.get(Calendar.HOUR) + 1); - } - cal.set(Calendar.MINUTE, 0); - mUserReminderDate = cal.getTime(); + mUserReminderDate = getAdjustedDate(getContext()); + Log.d("OskarSchindler", "Imagined Date: " + mUserReminderDate); - String timeString; - if (time24) { - timeString = formatDate("k:mm", mUserReminderDate); - } else { - timeString = formatDate("h:mm a", mUserReminderDate); - } + String timeString = formatDate(time24 ? "k:mm" : "h:mm a", mUserReminderDate); mTimeEditText.setText(timeString); // int hour = calendar.get(Calendar.HOUR_OF_DAY); // if(hour<9){ @@ -540,7 +540,7 @@ public void setTime(int hour, int minute) { } public void setDateEditText() { - String dateFormat = "d MMM, yyyy"; + String dateFormat = DATE_FORMAT; mDateEditText.setText(formatDate(dateFormat, mUserReminderDate)); } @@ -564,26 +564,29 @@ public void setReminderTextView() { mReminderTextView.setTextColor(Color.RED); return; } + Date date = mUserReminderDate; - String dateString = formatDate("d MMM, yyyy", date); - String timeString; - String amPmString = ""; + String finalString = getFormattedDate(date, getContext()); - if (DateFormat.is24HourFormat(getContext())) { - timeString = formatDate("k:mm", date); - } else { - timeString = formatDate("h:mm", date); - amPmString = formatDate("a", date); - } - String finalString = String.format(getResources().getString(R.string.remind_date_and_time), dateString, timeString, amPmString); mReminderTextView.setTextColor(getResources().getColor(R.color.secondary_text)); mReminderTextView.setText(finalString); } else { mReminderTextView.setVisibility(View.INVISIBLE); - } } + static public String getFormattedDate(Date date, Context context) { + String dateString = formatDate(DATE_FORMAT, date); + boolean time24 = DateFormat.is24HourFormat(context); + String timeString = formatDate(time24 ? "k:mm" : "h:mm a", date); + + String finalString = String.format( + context.getResources().getString(R.string.remind_date_and_time), + dateString, timeString); + + return finalString; + } + public void makeResult(int result) { Log.d(TAG, "makeResult - ok : in"); Intent i = new Intent(); diff --git a/app/src/main/java/com/example/avjindersinghsekhon/minimaltodo/AppDefault/AppDefaultActivity.java b/app/src/main/java/com/example/avjindersinghsekhon/minimaltodo/AppDefault/AppDefaultActivity.java index f856518f..ba84fa55 100644 --- a/app/src/main/java/com/example/avjindersinghsekhon/minimaltodo/AppDefault/AppDefaultActivity.java +++ b/app/src/main/java/com/example/avjindersinghsekhon/minimaltodo/AppDefault/AppDefaultActivity.java @@ -1,11 +1,11 @@ package com.example.avjindersinghsekhon.minimaltodo.AppDefault; import android.os.Bundle; -import android.support.annotation.LayoutRes; -import android.support.annotation.NonNull; -import android.support.annotation.Nullable; -import android.support.v4.app.Fragment; -import android.support.v7.app.AppCompatActivity; +import androidx.annotation.LayoutRes; +import androidx.annotation.NonNull; +import androidx.annotation.Nullable; +import androidx.fragment.app.Fragment; +import androidx.appcompat.app.AppCompatActivity; import com.example.avjindersinghsekhon.minimaltodo.R; diff --git a/app/src/main/java/com/example/avjindersinghsekhon/minimaltodo/AppDefault/AppDefaultFragment.java b/app/src/main/java/com/example/avjindersinghsekhon/minimaltodo/AppDefault/AppDefaultFragment.java index 9c61f10f..66b269df 100644 --- a/app/src/main/java/com/example/avjindersinghsekhon/minimaltodo/AppDefault/AppDefaultFragment.java +++ b/app/src/main/java/com/example/avjindersinghsekhon/minimaltodo/AppDefault/AppDefaultFragment.java @@ -1,9 +1,9 @@ package com.example.avjindersinghsekhon.minimaltodo.AppDefault; import android.os.Bundle; -import android.support.annotation.LayoutRes; -import android.support.annotation.Nullable; -import android.support.v4.app.Fragment; +import androidx.annotation.LayoutRes; +import androidx.annotation.Nullable; +import androidx.fragment.app.Fragment; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; diff --git a/app/src/main/java/com/example/avjindersinghsekhon/minimaltodo/Main/CustomRecyclerScrollViewListener.java b/app/src/main/java/com/example/avjindersinghsekhon/minimaltodo/Main/CustomRecyclerScrollViewListener.java index 78d61784..97479899 100644 --- a/app/src/main/java/com/example/avjindersinghsekhon/minimaltodo/Main/CustomRecyclerScrollViewListener.java +++ b/app/src/main/java/com/example/avjindersinghsekhon/minimaltodo/Main/CustomRecyclerScrollViewListener.java @@ -1,6 +1,6 @@ package com.example.avjindersinghsekhon.minimaltodo.Main; -import android.support.v7.widget.RecyclerView; +import androidx.recyclerview.widget.RecyclerView; import android.util.Log; public abstract class CustomRecyclerScrollViewListener extends RecyclerView.OnScrollListener { diff --git a/app/src/main/java/com/example/avjindersinghsekhon/minimaltodo/Main/MainActivity.java b/app/src/main/java/com/example/avjindersinghsekhon/minimaltodo/Main/MainActivity.java index a981c20f..97df9341 100644 --- a/app/src/main/java/com/example/avjindersinghsekhon/minimaltodo/Main/MainActivity.java +++ b/app/src/main/java/com/example/avjindersinghsekhon/minimaltodo/Main/MainActivity.java @@ -2,12 +2,13 @@ import android.content.Intent; import android.os.Bundle; -import android.support.annotation.NonNull; -import android.support.v4.app.Fragment; -import android.support.v7.app.ActionBar; import android.view.Menu; import android.view.MenuItem; +import androidx.annotation.NonNull; +import androidx.appcompat.app.ActionBar; +import androidx.fragment.app.Fragment; + import com.example.avjindersinghsekhon.minimaltodo.About.AboutActivity; import com.example.avjindersinghsekhon.minimaltodo.AppDefault.AppDefaultActivity; import com.example.avjindersinghsekhon.minimaltodo.R; @@ -17,7 +18,7 @@ public class MainActivity extends AppDefaultActivity { protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); - final android.support.v7.widget.Toolbar toolbar = (android.support.v7.widget.Toolbar) findViewById(R.id.toolbar); + final androidx.appcompat.widget.Toolbar toolbar = (androidx.appcompat.widget.Toolbar) findViewById(R.id.toolbar); setSupportActionBar(toolbar); ActionBar actionBar = getSupportActionBar(); if (actionBar != null) { diff --git a/app/src/main/java/com/example/avjindersinghsekhon/minimaltodo/Main/MainFragment.java b/app/src/main/java/com/example/avjindersinghsekhon/minimaltodo/Main/MainFragment.java index 8577de1e..f84d64f0 100644 --- a/app/src/main/java/com/example/avjindersinghsekhon/minimaltodo/Main/MainFragment.java +++ b/app/src/main/java/com/example/avjindersinghsekhon/minimaltodo/Main/MainFragment.java @@ -7,14 +7,6 @@ import android.graphics.Color; import android.graphics.Typeface; import android.os.Bundle; -import android.support.annotation.Nullable; -import android.support.design.widget.CoordinatorLayout; -import android.support.design.widget.FloatingActionButton; -import android.support.design.widget.Snackbar; -import android.support.v7.widget.DefaultItemAnimator; -import android.support.v7.widget.LinearLayoutManager; -import android.support.v7.widget.RecyclerView; -import android.support.v7.widget.helper.ItemTouchHelper; import android.util.Log; import android.view.LayoutInflater; import android.view.Menu; @@ -27,6 +19,13 @@ import android.widget.LinearLayout; import android.widget.TextView; +import androidx.annotation.Nullable; +import androidx.coordinatorlayout.widget.CoordinatorLayout; +import androidx.recyclerview.widget.DefaultItemAnimator; +import androidx.recyclerview.widget.ItemTouchHelper; +import androidx.recyclerview.widget.LinearLayoutManager; +import androidx.recyclerview.widget.RecyclerView; + import com.amulyakhare.textdrawable.TextDrawable; import com.amulyakhare.textdrawable.util.ColorGenerator; import com.example.avjindersinghsekhon.minimaltodo.About.AboutActivity; @@ -42,6 +41,8 @@ import com.example.avjindersinghsekhon.minimaltodo.Utility.StoreRetrieveData; import com.example.avjindersinghsekhon.minimaltodo.Utility.ToDoItem; import com.example.avjindersinghsekhon.minimaltodo.Utility.TodoNotificationService; +import com.google.android.material.floatingactionbutton.FloatingActionButton; +import com.google.android.material.snackbar.Snackbar; import org.json.JSONException; diff --git a/app/src/main/java/com/example/avjindersinghsekhon/minimaltodo/Reminder/ReminderActivity.java b/app/src/main/java/com/example/avjindersinghsekhon/minimaltodo/Reminder/ReminderActivity.java index 15cc0e9c..4dca36bc 100644 --- a/app/src/main/java/com/example/avjindersinghsekhon/minimaltodo/Reminder/ReminderActivity.java +++ b/app/src/main/java/com/example/avjindersinghsekhon/minimaltodo/Reminder/ReminderActivity.java @@ -1,7 +1,7 @@ package com.example.avjindersinghsekhon.minimaltodo.Reminder; import android.os.Bundle; -import android.support.annotation.NonNull; +import androidx.annotation.NonNull; import com.example.avjindersinghsekhon.minimaltodo.AppDefault.AppDefaultActivity; import com.example.avjindersinghsekhon.minimaltodo.R; diff --git a/app/src/main/java/com/example/avjindersinghsekhon/minimaltodo/Reminder/ReminderFragment.java b/app/src/main/java/com/example/avjindersinghsekhon/minimaltodo/Reminder/ReminderFragment.java index 0d4ca7a0..57db8d46 100644 --- a/app/src/main/java/com/example/avjindersinghsekhon/minimaltodo/Reminder/ReminderFragment.java +++ b/app/src/main/java/com/example/avjindersinghsekhon/minimaltodo/Reminder/ReminderFragment.java @@ -4,9 +4,9 @@ import android.content.SharedPreferences; import android.graphics.Color; import android.os.Bundle; -import android.support.annotation.Nullable; -import android.support.v7.app.AppCompatActivity; -import android.support.v7.widget.Toolbar; +import androidx.annotation.Nullable; +import androidx.appcompat.app.AppCompatActivity; +import androidx.appcompat.widget.Toolbar; import android.util.Log; import android.view.Menu; import android.view.MenuItem; diff --git a/app/src/main/java/com/example/avjindersinghsekhon/minimaltodo/Settings/SettingsActivity.java b/app/src/main/java/com/example/avjindersinghsekhon/minimaltodo/Settings/SettingsActivity.java index 30f5b588..19383b81 100644 --- a/app/src/main/java/com/example/avjindersinghsekhon/minimaltodo/Settings/SettingsActivity.java +++ b/app/src/main/java/com/example/avjindersinghsekhon/minimaltodo/Settings/SettingsActivity.java @@ -5,11 +5,12 @@ import android.graphics.PorterDuff; import android.graphics.drawable.Drawable; import android.os.Bundle; -import android.support.v4.app.NavUtils; -import android.support.v7.app.AppCompatActivity; -import android.support.v7.widget.Toolbar; import android.view.MenuItem; +import androidx.appcompat.app.AppCompatActivity; +import androidx.appcompat.widget.Toolbar; +import androidx.core.app.NavUtils; + import com.example.avjindersinghsekhon.minimaltodo.Analytics.AnalyticsApplication; import com.example.avjindersinghsekhon.minimaltodo.Main.MainFragment; import com.example.avjindersinghsekhon.minimaltodo.R; @@ -40,7 +41,7 @@ protected void onCreate(Bundle savedInstanceState) { Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar); setSupportActionBar(toolbar); - final Drawable backArrow = getResources().getDrawable(R.drawable.abc_ic_ab_back_mtrl_am_alpha); + final Drawable backArrow = getResources().getDrawable(R.drawable.abc_ic_ab_back_material); if (backArrow != null) { backArrow.setColorFilter(Color.WHITE, PorterDuff.Mode.SRC_ATOP); diff --git a/app/src/main/java/com/example/avjindersinghsekhon/minimaltodo/Utility/CustomTextInputLayout.java b/app/src/main/java/com/example/avjindersinghsekhon/minimaltodo/Utility/CustomTextInputLayout.java index b6eb9d16..8e97e23b 100644 --- a/app/src/main/java/com/example/avjindersinghsekhon/minimaltodo/Utility/CustomTextInputLayout.java +++ b/app/src/main/java/com/example/avjindersinghsekhon/minimaltodo/Utility/CustomTextInputLayout.java @@ -3,8 +3,8 @@ import android.content.Context; import android.graphics.Canvas; -import android.support.design.widget.TextInputLayout; -import android.support.v4.view.ViewCompat; +import com.google.android.material.textfield.TextInputLayout; +import androidx.core.view.ViewCompat; import android.util.AttributeSet; import android.view.View; import android.view.ViewGroup; diff --git a/app/src/main/java/com/example/avjindersinghsekhon/minimaltodo/Utility/ItemTouchHelperClass.java b/app/src/main/java/com/example/avjindersinghsekhon/minimaltodo/Utility/ItemTouchHelperClass.java index aceba80d..a14ed28b 100644 --- a/app/src/main/java/com/example/avjindersinghsekhon/minimaltodo/Utility/ItemTouchHelperClass.java +++ b/app/src/main/java/com/example/avjindersinghsekhon/minimaltodo/Utility/ItemTouchHelperClass.java @@ -1,7 +1,7 @@ package com.example.avjindersinghsekhon.minimaltodo.Utility; -import android.support.v7.widget.RecyclerView; -import android.support.v7.widget.helper.ItemTouchHelper; +import androidx.recyclerview.widget.RecyclerView; +import androidx.recyclerview.widget.ItemTouchHelper; public class ItemTouchHelperClass extends ItemTouchHelper.Callback { private ItemTouchHelperAdapter adapter; diff --git a/app/src/main/java/com/example/avjindersinghsekhon/minimaltodo/Utility/RecyclerViewEmptySupport.java b/app/src/main/java/com/example/avjindersinghsekhon/minimaltodo/Utility/RecyclerViewEmptySupport.java index 688577b0..84a95dde 100644 --- a/app/src/main/java/com/example/avjindersinghsekhon/minimaltodo/Utility/RecyclerViewEmptySupport.java +++ b/app/src/main/java/com/example/avjindersinghsekhon/minimaltodo/Utility/RecyclerViewEmptySupport.java @@ -1,10 +1,11 @@ package com.example.avjindersinghsekhon.minimaltodo.Utility; import android.content.Context; -import android.support.v7.widget.RecyclerView; import android.util.AttributeSet; import android.view.View; +import androidx.recyclerview.widget.RecyclerView; + public class RecyclerViewEmptySupport extends RecyclerView { private View emptyView; diff --git a/app/src/main/java/com/example/avjindersinghsekhon/minimaltodo/Utility/ScrollingFABBehaviour.java b/app/src/main/java/com/example/avjindersinghsekhon/minimaltodo/Utility/ScrollingFABBehaviour.java index ac1cdfbb..752a22cb 100644 --- a/app/src/main/java/com/example/avjindersinghsekhon/minimaltodo/Utility/ScrollingFABBehaviour.java +++ b/app/src/main/java/com/example/avjindersinghsekhon/minimaltodo/Utility/ScrollingFABBehaviour.java @@ -1,10 +1,10 @@ package com.example.avjindersinghsekhon.minimaltodo.Utility; import android.content.Context; -import android.support.design.widget.CoordinatorLayout; -import android.support.design.widget.FloatingActionButton; -import android.support.design.widget.Snackbar; -import android.support.v7.widget.Toolbar; +import androidx.coordinatorlayout.widget.CoordinatorLayout; +import com.google.android.material.floatingactionbutton.FloatingActionButton; +import com.google.android.material.snackbar.Snackbar; +import androidx.appcompat.widget.Toolbar; import android.util.AttributeSet; import android.view.View; diff --git a/app/src/main/res/layout/activity_add_to_do.xml b/app/src/main/res/layout/activity_add_to_do.xml index 0a1fcc4f..b8c8f60a 100644 --- a/app/src/main/res/layout/activity_add_to_do.xml +++ b/app/src/main/res/layout/activity_add_to_do.xml @@ -1,4 +1,4 @@ - - + diff --git a/app/src/main/res/layout/activity_main.xml b/app/src/main/res/layout/activity_main.xml index 19f8ae7a..6cc0461c 100644 --- a/app/src/main/res/layout/activity_main.xml +++ b/app/src/main/res/layout/activity_main.xml @@ -6,9 +6,9 @@ android:layout_height="match_parent" android:orientation="vertical"> - @@ -16,5 +16,5 @@ - + diff --git a/app/src/main/res/layout/activity_settings.xml b/app/src/main/res/layout/activity_settings.xml index 3bb3d02d..6af3d6a0 100644 --- a/app/src/main/res/layout/activity_settings.xml +++ b/app/src/main/res/layout/activity_settings.xml @@ -6,7 +6,7 @@ android:layout_width="match_parent" > - - + - @@ -93,7 +93,7 @@ android:textColor="@color/secondary_text" android:textSize="16sp" /> - - - - + + diff --git a/app/src/main/res/layout/base_toolbar.xml b/app/src/main/res/layout/base_toolbar.xml index 00d364c5..4b62053f 100644 --- a/app/src/main/res/layout/base_toolbar.xml +++ b/app/src/main/res/layout/base_toolbar.xml @@ -1,6 +1,6 @@ - - + diff --git a/app/src/main/res/layout/fragment_add_to_do.xml b/app/src/main/res/layout/fragment_add_to_do.xml index 6f7fb117..fc2e01d1 100644 --- a/app/src/main/res/layout/fragment_add_to_do.xml +++ b/app/src/main/res/layout/fragment_add_to_do.xml @@ -9,7 +9,7 @@ - @@ -121,7 +121,7 @@ android:textColor="@color/secondary_text" android:textSize="16sp" /> - - - + diff --git a/app/src/main/res/layout/fragment_main.xml b/app/src/main/res/layout/fragment_main.xml index 946ea4e6..84209d9d 100644 --- a/app/src/main/res/layout/fragment_main.xml +++ b/app/src/main/res/layout/fragment_main.xml @@ -1,17 +1,18 @@ + xmlns:app="http://schemas.android.com/apk/res-auto" + xmlns:tools="http://schemas.android.com/tools" + android:id="@+id/myParentLayout" + android:layout_width="match_parent" + android:orientation="vertical" + android:gravity="center" + android:layout_height="match_parent"> - + @@ -45,23 +47,23 @@ - + android:layout_height="match_parent" + android:background="@color/white" + tools:listitem="@android:layout/simple_list_item_checked" + app:layout_behavior="com.google.android.material.appbar.AppBarLayout$ScrollingViewBehavior" + /> - - - + diff --git a/app/src/main/res/layout/list_circle_try.xml b/app/src/main/res/layout/list_circle_try.xml index 86280a23..467317de 100644 --- a/app/src/main/res/layout/list_circle_try.xml +++ b/app/src/main/res/layout/list_circle_try.xml @@ -1,12 +1,13 @@ + android:layout_width="match_parent" + android:id="@+id/listItemLinearLayout" + android:layout_marginBottom="1dp" + android:gravity="center" + android:orientation="horizontal" + android:layout_height="wrap_content" + android:background="@color/white" + xmlns:tools="http://schemas.android.com/tools"> Нощен режим е изключен Нощен режим е включен Нямате Напомняне - Добавено е напомняне за %1$s, %2$s %3$s + Добавено е напомняне за %1$s, %2$s Напомни ми Изтрий Отложи diff --git a/app/src/main/res/values-de/strings.xml b/app/src/main/res/values-de/strings.xml index ff23e468..4c40cc0e 100644 --- a/app/src/main/res/values-de/strings.xml +++ b/app/src/main/res/values-de/strings.xml @@ -8,7 +8,7 @@ Erinnere mich Datum Uhrzeit - Erinnerung gesetzt für %1$s, %2$s %3$s + Erinnerung gesetzt für %1$s, %2$s Über Version: %1$s Kontaktiere mich unter diff --git a/app/src/main/res/values-es/strings.xml b/app/src/main/res/values-es/strings.xml index 9388aed5..10a55dcd 100644 --- a/app/src/main/res/values-es/strings.xml +++ b/app/src/main/res/values-es/strings.xml @@ -8,7 +8,7 @@ Avísame Fecha Hora - Recordatorio el %1$s, %2$s %3$s + Recordatorio el %1$s, %2$s Acerca de Versión: %1$s Puedes contactarme en diff --git a/app/src/main/res/values-fi/strings.xml b/app/src/main/res/values-fi/strings.xml index b17efe35..083b96bf 100644 --- a/app/src/main/res/values-fi/strings.xml +++ b/app/src/main/res/values-fi/strings.xml @@ -7,7 +7,7 @@ Muistutus Päivämäärä Aika - Muistutus asetettu: %1$s, %2$s %3$s + Muistutus asetettu: %1$s, %2$s Tietoja Versio: %1$s Ota yhteyttä diff --git a/app/src/main/res/values-fr/strings.xml b/app/src/main/res/values-fr/strings.xml index 2eab69e9..af239de3 100644 --- a/app/src/main/res/values-fr/strings.xml +++ b/app/src/main/res/values-fr/strings.xml @@ -13,7 +13,7 @@ Rappelle moi Date Temps - Rappel défini pour %1$s, %2$s %3$s + Rappel défini pour %1$s, %2$s À propos Version : %1$s Vous pouvez me contacter à diff --git a/app/src/main/res/values-it/strings.xml b/app/src/main/res/values-it/strings.xml index d24d5eb3..e7c88763 100644 --- a/app/src/main/res/values-it/strings.xml +++ b/app/src/main/res/values-it/strings.xml @@ -6,7 +6,7 @@ Promemoria Data Ora - Promemoria impostato per il giorno %1$s, %2$s %3$s + Promemoria impostato per il giorno %1$s, %2$s Informazioni Versione: %1$s Per contattare lo sviluppatore diff --git a/app/src/main/res/values-ml/strings.xml b/app/src/main/res/values-ml/strings.xml index 1318a896..175f1f33 100644 --- a/app/src/main/res/values-ml/strings.xml +++ b/app/src/main/res/values-ml/strings.xml @@ -7,7 +7,7 @@ ഓർമ്മപ്പെടുതുക തിയതി സമയം - നിങ്ങളെ ഓർമ്മിപ്പിക്കുന്നത് %1$s, %2$s %3$s + നിങ്ങളെ ഓർമ്മിപ്പിക്കുന്നത് %1$s, %2$s ആമുഖം പതിപ്പ്: %1$s എന്നെ ഇവിടെ ബന്ധപ്പെടുക diff --git a/app/src/main/res/values-pl/strings.xml b/app/src/main/res/values-pl/strings.xml index 0cf1b913..df35d6f7 100644 --- a/app/src/main/res/values-pl/strings.xml +++ b/app/src/main/res/values-pl/strings.xml @@ -8,7 +8,7 @@ Przypomnij mi Data Czas - Przypomnienie nastąpi %1$s, %2$s %3$s + Przypomnienie nastąpi %1$s, %2$s O programie Wersja: %1$s Kontakt z autorem: diff --git a/app/src/main/res/values-tl/strings.xml b/app/src/main/res/values-tl/strings.xml index 50fed708..0b2fe123 100644 --- a/app/src/main/res/values-tl/strings.xml +++ b/app/src/main/res/values-tl/strings.xml @@ -7,7 +7,7 @@ Ipaalala mo sa akin Petsa Oras - Itakda ang paalala sa %1$s, %2$s %3$s + Itakda ang paalala sa %1$s, %2$s Tungkol Bersyon: %1$s Maaari kang makipag-ugnay sa akin sa diff --git a/app/src/main/res/values-vi/strings.xml b/app/src/main/res/values-vi/strings.xml index 0ceb4399..1e45734f 100644 --- a/app/src/main/res/values-vi/strings.xml +++ b/app/src/main/res/values-vi/strings.xml @@ -7,7 +7,7 @@ Nhắc nhở tôi Ngày Giờ - Cài đặt nhắc nhở cho %1$s, %2$s %3$s + Cài đặt nhắc nhở cho %1$s, %2$s Thông tin Phiên bản: %1$s Bạn có thể liên lạc với tôi theo diff --git a/app/src/main/res/values-zh/strings.xml b/app/src/main/res/values-zh/strings.xml index 07d0a6cb..5b206233 100644 --- a/app/src/main/res/values-zh/strings.xml +++ b/app/src/main/res/values-zh/strings.xml @@ -8,7 +8,7 @@ 提醒我 日期 时间 - 设置提醒时间为 %1$s, %2$s %3$s + 设置提醒时间为 %1$s, %2$s 关于 版本号: %1$s 联系作者 diff --git a/app/src/main/res/values/colors.xml b/app/src/main/res/values/colors.xml index 680b389b..ba1c5524 100644 --- a/app/src/main/res/values/colors.xml +++ b/app/src/main/res/values/colors.xml @@ -15,6 +15,7 @@ #727272 #FFFFFF #B6B6B6 + #FFFFFF #757575 #E0E0E0 diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index eca435ed..f9557f79 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -7,7 +7,7 @@ Remind Me Date Time - Reminder set for %1$s, %2$s %3$s + Reminder set for %1$s, %2$s About Version: %1$s You can contact me at @@ -29,4 +29,7 @@ Snooze Remove Please enter a Todo + + com.google.android.material.appbar.AppBarLayout$ScrollingViewBehavior + \@ diff --git a/build.gradle b/build.gradle index f1b98cf2..a35f06ea 100644 --- a/build.gradle +++ b/build.gradle @@ -5,7 +5,7 @@ buildscript { jcenter() } dependencies { - classpath 'com.android.tools.build:gradle:3.2.1' + classpath 'com.android.tools.build:gradle:3.5.0-beta05' classpath 'com.google.gms:google-services:1.3.0-beta1' // NOTE: Do not place your application dependencies here; they belong @@ -23,7 +23,7 @@ buildscript { google() } dependencies { - classpath 'com.jakewharton:butterknife-gradle-plugin:8.5.1' + classpath 'com.jakewharton:butterknife-gradle-plugin:9.0.0-rc2' } } diff --git a/gradle.properties b/gradle.properties index 1d3591c8..915f0e66 100644 --- a/gradle.properties +++ b/gradle.properties @@ -15,4 +15,6 @@ # When configured, Gradle will run in incubating parallel mode. # This option should only be used with decoupled projects. More details, visit # http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects -# org.gradle.parallel=true \ No newline at end of file +# org.gradle.parallel=true +android.enableJetifier=true +android.useAndroidX=true \ No newline at end of file diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index d5d5c1c0..8de23213 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,7 +1,6 @@ -#Tue Nov 06 17:37:41 IST 2018 - +#Thu Jul 04 16:31:34 EDT 2019 distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-4.6-all.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-5.4.1-all.zip