Skip to content

Commit f99e9a0

Browse files
committed
Cleanup resource ids
1 parent ae3252a commit f99e9a0

File tree

15 files changed

+100
-100
lines changed

15 files changed

+100
-100
lines changed

app/src/androidTest/java/com/example/android/architecture/blueprints/todoapp/tasks/AppNavigationTest.kt

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -102,21 +102,21 @@ class AppNavigationTest {
102102

103103
// Start statistics screen.
104104
onView(withId(R.id.nav_view))
105-
.perform(navigateTo(R.id.statisticsFragment))
105+
.perform(navigateTo(R.id.statistics_fragment_dest))
106106

107107
// Check that statistics screen was opened.
108-
onView(withId(R.id.statistics)).check(matches(isDisplayed()))
108+
onView(withId(R.id.statistics_layout)).check(matches(isDisplayed()))
109109

110110
onView(withId(R.id.drawer_layout))
111111
.check(matches(isClosed(Gravity.START))) // Left Drawer should be closed.
112112
.perform(open()) // Open Drawer
113113

114114
// Start tasks screen.
115115
onView(withId(R.id.nav_view))
116-
.perform(navigateTo(R.id.tasksFragment))
116+
.perform(navigateTo(R.id.tasks_fragment_dest))
117117

118118
// Check that tasks screen was opened.
119-
onView(withId(R.id.tasksContainer)).check(matches(isDisplayed()))
119+
onView(withId(R.id.tasks_container_layout)).check(matches(isDisplayed()))
120120
}
121121

122122
@Test
@@ -150,7 +150,7 @@ class AppNavigationTest {
150150

151151
// When the user navigates to the stats screen
152152
activityScenario.onActivity {
153-
it.findNavController(R.id.nav_host_fragment).navigate(R.id.statisticsFragment)
153+
it.findNavController(R.id.nav_host_fragment).navigate(R.id.statistics_fragment_dest)
154154
}
155155

156156
// Then check that left drawer is closed at startup
@@ -182,7 +182,7 @@ class AppNavigationTest {
182182
// Click on the task on the list
183183
onView(withText("UI <- button")).perform(click())
184184
// Click on the edit task button
185-
onView(withId(R.id.fab_edit_task)).perform(click())
185+
onView(withId(R.id.edit_task_fab)).perform(click())
186186

187187
// Confirm that if we click "<-" once, we end up back at the task details page
188188
onView(
@@ -191,7 +191,7 @@ class AppNavigationTest {
191191
.getToolbarNavigationContentDescription()
192192
)
193193
).perform(click())
194-
onView(withId(R.id.task_detail_title)).check(matches(isDisplayed()))
194+
onView(withId(R.id.task_detail_title_text)).check(matches(isDisplayed()))
195195

196196
// Confirm that if we click "<-" a second time, we end up back at the home screen
197197
onView(
@@ -200,7 +200,7 @@ class AppNavigationTest {
200200
.getToolbarNavigationContentDescription()
201201
)
202202
).perform(click())
203-
onView(withId(R.id.tasksContainer)).check(matches(isDisplayed()))
203+
onView(withId(R.id.tasks_container_layout)).check(matches(isDisplayed()))
204204
}
205205

206206
@Test
@@ -215,14 +215,14 @@ class AppNavigationTest {
215215
// Click on the task on the list
216216
onView(withText("Back button")).perform(click())
217217
// Click on the edit task button
218-
onView(withId(R.id.fab_edit_task)).perform(click())
218+
onView(withId(R.id.edit_task_fab)).perform(click())
219219

220220
// Confirm that if we click back once, we end up back at the task details page
221221
pressBack()
222-
onView(withId(R.id.task_detail_title)).check(matches(isDisplayed()))
222+
onView(withId(R.id.task_detail_title_text)).check(matches(isDisplayed()))
223223

224224
// Confirm that if we click back a second time, we end up back at the home screen
225225
pressBack()
226-
onView(withId(R.id.tasksContainer)).check(matches(isDisplayed()))
226+
onView(withId(R.id.tasks_container_layout)).check(matches(isDisplayed()))
227227
}
228228
}

app/src/androidTest/java/com/example/android/architecture/blueprints/todoapp/tasks/TasksActivityTest.kt

Lines changed: 25 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -102,15 +102,15 @@ class TasksActivityTest {
102102

103103
// Click on the task on the list and verify that all the data is correct
104104
onView(withText("TITLE1")).perform(click())
105-
onView(withId(R.id.task_detail_title)).check(matches(withText("TITLE1")))
106-
onView(withId(R.id.task_detail_description)).check(matches(withText("DESCRIPTION")))
107-
onView(withId(R.id.task_detail_complete)).check(matches(not(isChecked())))
105+
onView(withId(R.id.task_detail_title_text)).check(matches(withText("TITLE1")))
106+
onView(withId(R.id.task_detail_description_text)).check(matches(withText("DESCRIPTION")))
107+
onView(withId(R.id.task_detail_complete_checkbox)).check(matches(not(isChecked())))
108108

109109
// Click on the edit button, edit, and save
110-
onView(withId(R.id.fab_edit_task)).perform(click())
111-
onView(withId(R.id.add_task_title)).perform(replaceText("NEW TITLE"))
112-
onView(withId(R.id.add_task_description)).perform(replaceText("NEW DESCRIPTION"))
113-
onView(withId(R.id.fab_save_task)).perform(click())
110+
onView(withId(R.id.edit_task_fab)).perform(click())
111+
onView(withId(R.id.add_task_title_edit_text)).perform(replaceText("NEW TITLE"))
112+
onView(withId(R.id.add_task_description_edit_text)).perform(replaceText("NEW DESCRIPTION"))
113+
onView(withId(R.id.save_task_fab)).perform(click())
114114

115115
// Verify task is displayed on screen in the task list.
116116
onView(withText("NEW TITLE")).check(matches(isDisplayed()))
@@ -126,10 +126,10 @@ class TasksActivityTest {
126126
dataBindingIdlingResource.monitorActivity(activityScenario)
127127

128128
// Add active task
129-
onView(withId(R.id.fab_add_task)).perform(click())
130-
onView(withId(R.id.add_task_title)).perform(typeText("TITLE1"), closeSoftKeyboard())
131-
onView(withId(R.id.add_task_description)).perform(typeText("DESCRIPTION"))
132-
onView(withId(R.id.fab_save_task)).perform(click())
129+
onView(withId(R.id.add_task_fab)).perform(click())
130+
onView(withId(R.id.add_task_title_edit_text)).perform(typeText("TITLE1"), closeSoftKeyboard())
131+
onView(withId(R.id.add_task_description_edit_text)).perform(typeText("DESCRIPTION"))
132+
onView(withId(R.id.save_task_fab)).perform(click())
133133

134134
// Open it in details view
135135
onView(withText("TITLE1")).perform(click())
@@ -177,7 +177,7 @@ class TasksActivityTest {
177177
onView(withText(taskTitle)).perform(click())
178178

179179
// Click on the checkbox in task details screen
180-
onView(withId(R.id.task_detail_complete)).perform(click())
180+
onView(withId(R.id.task_detail_complete_checkbox)).perform(click())
181181

182182
// Click on the navigation up button to go back to the list
183183
onView(
@@ -187,7 +187,7 @@ class TasksActivityTest {
187187
).perform(click())
188188

189189
// Check that the task is marked as completed
190-
onView(allOf(withId(R.id.complete), hasSibling(withText(taskTitle))))
190+
onView(allOf(withId(R.id.complete_checkbox), hasSibling(withText(taskTitle))))
191191
.check(matches(isChecked()))
192192
}
193193

@@ -204,7 +204,7 @@ class TasksActivityTest {
204204
// Click on the task on the list
205205
onView(withText(taskTitle)).perform(click())
206206
// Click on the checkbox in task details screen
207-
onView(withId(R.id.task_detail_complete)).perform(click())
207+
onView(withId(R.id.task_detail_complete_checkbox)).perform(click())
208208

209209
// Click on the navigation up button to go back to the list
210210
onView(
@@ -214,7 +214,7 @@ class TasksActivityTest {
214214
).perform(click())
215215

216216
// Check that the task is marked as active
217-
onView(allOf(withId(R.id.complete), hasSibling(withText(taskTitle))))
217+
onView(allOf(withId(R.id.complete_checkbox), hasSibling(withText(taskTitle))))
218218
.check(matches(not(isChecked())))
219219
}
220220

@@ -231,9 +231,9 @@ class TasksActivityTest {
231231
// Click on the task on the list
232232
onView(withText(taskTitle)).perform(click())
233233
// Click on the checkbox in task details screen
234-
onView(withId(R.id.task_detail_complete)).perform(click())
234+
onView(withId(R.id.task_detail_complete_checkbox)).perform(click())
235235
// Click again to restore it to original state
236-
onView(withId(R.id.task_detail_complete)).perform(click())
236+
onView(withId(R.id.task_detail_complete_checkbox)).perform(click())
237237

238238
// Click on the navigation up button to go back to the list
239239
onView(
@@ -243,7 +243,7 @@ class TasksActivityTest {
243243
).perform(click())
244244

245245
// Check that the task is marked as active
246-
onView(allOf(withId(R.id.complete), hasSibling(withText(taskTitle))))
246+
onView(allOf(withId(R.id.complete_checkbox), hasSibling(withText(taskTitle))))
247247
.check(matches(not(isChecked())))
248248
}
249249

@@ -260,9 +260,9 @@ class TasksActivityTest {
260260
// Click on the task on the list
261261
onView(withText(taskTitle)).perform(click())
262262
// Click on the checkbox in task details screen
263-
onView(withId(R.id.task_detail_complete)).perform(click())
263+
onView(withId(R.id.task_detail_complete_checkbox)).perform(click())
264264
// Click again to restore it to original state
265-
onView(withId(R.id.task_detail_complete)).perform(click())
265+
onView(withId(R.id.task_detail_complete_checkbox)).perform(click())
266266

267267
// Click on the navigation up button to go back to the list
268268
onView(
@@ -272,7 +272,7 @@ class TasksActivityTest {
272272
).perform(click())
273273

274274
// Check that the task is marked as active
275-
onView(allOf(withId(R.id.complete), hasSibling(withText(taskTitle))))
275+
onView(allOf(withId(R.id.complete_checkbox), hasSibling(withText(taskTitle))))
276276
.check(matches(isChecked()))
277277
}
278278

@@ -283,10 +283,10 @@ class TasksActivityTest {
283283
dataBindingIdlingResource.monitorActivity(activityScenario)
284284

285285
// Click on the "+" button, add details, and save
286-
onView(withId(R.id.fab_add_task)).perform(click())
287-
onView(withId(R.id.add_task_title)).perform(typeText("title"), closeSoftKeyboard())
288-
onView(withId(R.id.add_task_description)).perform(typeText("description"))
289-
onView(withId(R.id.fab_save_task)).perform(click())
286+
onView(withId(R.id.add_task_fab)).perform(click())
287+
onView(withId(R.id.add_task_title_edit_text)).perform(typeText("title"), closeSoftKeyboard())
288+
onView(withId(R.id.add_task_description_edit_text)).perform(typeText("description"))
289+
onView(withId(R.id.save_task_fab)).perform(click())
290290

291291
// Then verify task is displayed on screen
292292
onView(withText("title")).check(matches(isDisplayed()))

app/src/main/java/com/example/android/architecture/blueprints/todoapp/taskdetail/TaskDetailFragment.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ class TaskDetailFragment : Fragment() {
7070
}
7171

7272
private fun setupFab() {
73-
activity?.findViewById<View>(R.id.fab_edit_task)?.setOnClickListener {
73+
activity?.findViewById<View>(R.id.edit_task_fab)?.setOnClickListener {
7474
viewModel.editTask()
7575
}
7676
}

app/src/main/java/com/example/android/architecture/blueprints/todoapp/tasks/TasksActivity.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ class TasksActivity : AppCompatActivity() {
4444

4545
val navController: NavController = findNavController(R.id.nav_host_fragment)
4646
appBarConfiguration =
47-
AppBarConfiguration.Builder(R.id.tasksFragment, R.id.statisticsFragment)
47+
AppBarConfiguration.Builder(R.id.tasks_fragment_dest, R.id.statistics_fragment_dest)
4848
.setDrawerLayout(drawerLayout)
4949
.build()
5050
setupActionBarWithNavController(navController, appBarConfiguration)

app/src/main/java/com/example/android/architecture/blueprints/todoapp/tasks/TasksFragment.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,7 @@ class TasksFragment : Fragment() {
137137
}
138138

139139
private fun setupFab() {
140-
activity?.findViewById<FloatingActionButton>(R.id.fab_add_task)?.let {
140+
activity?.findViewById<FloatingActionButton>(R.id.add_task_fab)?.let {
141141
it.setOnClickListener {
142142
navigateToAddNewTask()
143143
}

app/src/main/res/layout/addtask_frag.xml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727
</data>
2828

2929
<androidx.coordinatorlayout.widget.CoordinatorLayout
30-
android:id="@+id/coordinatorLayout"
30+
android:id="@+id/coordinator_layout"
3131
android:layout_width="match_parent"
3232
android:layout_height="match_parent">
3333

@@ -53,7 +53,7 @@
5353
android:visibility="@{viewmodel.dataLoading ? View.GONE : View.VISIBLE}">
5454

5555
<EditText
56-
android:id="@+id/add_task_title"
56+
android:id="@+id/add_task_title_edit_text"
5757
android:background="@null"
5858
android:layout_width="match_parent"
5959
android:layout_height="wrap_content"
@@ -65,7 +65,7 @@
6565
android:textAppearance="@style/TextAppearance.AppCompat.Title" />
6666

6767
<EditText
68-
android:id="@+id/add_task_description"
68+
android:id="@+id/add_task_description_edit_text"
6969
android:background="@null"
7070
android:layout_width="match_parent"
7171
android:layout_height="350dp"
@@ -79,7 +79,7 @@
7979
</com.example.android.architecture.blueprints.todoapp.ScrollChildSwipeRefreshLayout>
8080

8181
<com.google.android.material.floatingactionbutton.FloatingActionButton
82-
android:id="@+id/fab_save_task"
82+
android:id="@+id/save_task_fab"
8383
android:layout_width="wrap_content"
8484
android:layout_height="wrap_content"
8585
android:layout_margin="@dimen/fab_margin"

app/src/main/res/layout/statistics_frag.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@
4242
android:paddingBottom="@dimen/activity_vertical_margin">
4343

4444
<LinearLayout
45-
android:id="@+id/statistics"
45+
android:id="@+id/statistics_layout"
4646
android:layout_width="match_parent"
4747
android:layout_height="match_parent"
4848
android:orientation="vertical"

app/src/main/res/layout/task_item.xml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,15 +40,15 @@
4040
android:onClick="@{() -> viewmodel.openTask(task.id)}">
4141

4242
<CheckBox
43-
android:id="@+id/complete"
43+
android:id="@+id/complete_checkbox"
4444
android:layout_width="wrap_content"
4545
android:layout_height="wrap_content"
4646
android:layout_gravity="center_vertical"
4747
android:onClick="@{(view) -> viewmodel.completeTask(task, ((CompoundButton)view).isChecked())}"
4848
android:checked="@{task.completed}" />
4949

5050
<TextView
51-
android:id="@+id/title"
51+
android:id="@+id/title_text"
5252
android:layout_width="match_parent"
5353
android:layout_height="wrap_content"
5454
android:layout_gravity="center_vertical"

app/src/main/res/layout/taskdetail_frag.xml

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828
</data>
2929

3030
<androidx.coordinatorlayout.widget.CoordinatorLayout
31-
android:id="@+id/coordinatorLayout"
31+
android:id="@+id/coordinator_layout"
3232
android:layout_width="match_parent"
3333
android:layout_height="match_parent">
3434

@@ -80,7 +80,7 @@
8080
<!-- android:paddingTop specified to temporarily work around -->
8181
<!-- https://github.com/robolectric/robolectric/issues/4588 -->
8282
<CheckBox
83-
android:id="@+id/task_detail_complete"
83+
android:id="@+id/task_detail_complete_checkbox"
8484
android:layout_width="wrap_content"
8585
android:layout_height="wrap_content"
8686
android:layout_gravity="center_vertical"
@@ -90,20 +90,20 @@
9090
android:paddingTop="1dp" />
9191

9292
<TextView
93-
android:id="@+id/task_detail_title"
93+
android:id="@+id/task_detail_title_text"
9494
android:layout_width="match_parent"
9595
android:layout_height="wrap_content"
96-
android:layout_toRightOf="@id/task_detail_complete"
96+
android:layout_toRightOf="@id/task_detail_complete_checkbox"
9797
android:paddingTop="1dp"
9898
android:text="@{viewmodel.task.title}"
9999
android:textAppearance="?android:attr/textAppearanceLarge" />
100100

101101
<TextView
102-
android:id="@+id/task_detail_description"
102+
android:id="@+id/task_detail_description_text"
103103
android:layout_width="match_parent"
104104
android:layout_height="wrap_content"
105-
android:layout_below="@id/task_detail_title"
106-
android:layout_toRightOf="@id/task_detail_complete"
105+
android:layout_below="@id/task_detail_title_text"
106+
android:layout_toRightOf="@id/task_detail_complete_checkbox"
107107
android:paddingTop="1dp"
108108
android:text="@{viewmodel.task.description}"
109109
android:textAppearance="?android:attr/textAppearanceMedium" />
@@ -113,7 +113,7 @@
113113
</com.example.android.architecture.blueprints.todoapp.ScrollChildSwipeRefreshLayout>
114114

115115
<com.google.android.material.floatingactionbutton.FloatingActionButton
116-
android:id="@+id/fab_edit_task"
116+
android:id="@+id/edit_task_fab"
117117
android:layout_width="wrap_content"
118118
android:layout_height="wrap_content"
119119
android:layout_margin="@dimen/fab_margin"

0 commit comments

Comments
 (0)