Statistics
7
Views
0
Downloads
0
Donations
Support
Share
Uploader

高宏飞

Shared on 2026-02-17

AuthorMark L. Murphy

No description

Tags
No tags
Publish Year: 2020
Language: 英文
File Format: PDF
File Size: 8.5 MB
Support Statistics
¥.00 · 0times
Text Preview (First 20 pages)
Registered users can read the full content for free

Register as a Gaohf Library member to read the complete e-book online for free and enjoy a better reading experience.

(This page has no text content)
Exploring Android by Mark L. Murphy
Exploring Android by Mark L. Murphy Copyright © 2017-2020 CommonsWare, LLC. All Rights Reserved. Printed in the United States of America. Printing History: December 2020: Version 2.0 The CommonsWare name and logo, “Busy Coder's Guide”, and related trade dress are trademarks of CommonsWare, LLC. All other trademarks referenced in this book are trademarks of their respective firms. The publisher and author(s) assume no responsibility for errors or omissions or for damages resulting from the use of the information contained herein.
Table of Contents Headings formatted in bold-italic have changed since the last version. • Preface ◦ How the Book Is Structured ................................................................. ix ◦ Second-Generation Book ...................................................................... x ◦ Prerequisites ........................................................................................... x ◦ About the Updates ................................................................................. x ◦ What’s New in Version 2.0? ........................................................ xi ◦ Copying Code From This Book ............................................................ xi ◦ Warescription ..................................................................................... xii ◦ Book Bug Bounty ............................................................................... xiii ◦ Source Code and Its License ............................................................. xiii ◦ Creative Commons and the Four-to-Free (42F) Guarantee ..... xiv • What We Are Building ◦ The Purpose ........................................................................................... 1 ◦ The Core UI ............................................................................................ 1 • Installing the Tools ◦ Step #1: Checking Your Hardware ....................................................... 9 ◦ Step #2: Install Android Studio .......................................................... 10 ◦ Step #3: Run Android Studio ............................................................... 11 • Creating a Starter Project ◦ Step #1: Importing the Project ............................................................ 19 ◦ Step #2: Setting Up the Emulator AVD .............................................. 23 ◦ Step #3: Setting Up the Device ........................................................... 29 ◦ Step #4: Running the Project .............................................................. 32 • Modifying the Manifest ◦ Some Notes About Relative Paths ...................................................... 35 ◦ Step #1: Supporting Screens ................................................................ 36 ◦ Step #2: Blocking Backups .................................................................. 37 ◦ Final Results ......................................................................................... 37 ◦ What We Changed .................................................................... 38 • Changing Our Icon ◦ Step #1: Getting the Replacement Artwork ........................................ 39 ◦ Step #2: Changing the Icon ................................................................ 40 ◦ Step #3: Running the Result ................................................................ 50 ◦ What We Changed .............................................................................. 50 • Adding a Library i
◦ Step #1: Removing Unnecessary Cruft ................................................ 51 ◦ Step #2: Adding Support for RecyclerView ........................................ 52 ◦ Final Results ......................................................................................... 53 ◦ What We Changed .................................................................... 54 • Constructing a Layout ◦ Step #1: Examining What We Have And What We Want ................. 55 ◦ Step #2: Adding a RecyclerView ......................................................... 58 ◦ Step #3: Adjusting the TextView ........................................................ 66 ◦ Final Results ......................................................................................... 72 ◦ What We Changed .................................................................... 73 • Integrating Fragments ◦ But First, Some Notes About Working with Kotlin ........................... 75 ◦ Step #1: Creating a Fragment .............................................................. 77 ◦ Step #2: Renaming Our Layout ........................................................... 78 ◦ Step #3: Inflating Our Layout ............................................................. 81 ◦ Step #4: Dealing with Crashes ........................................................... 84 ◦ Final Results ........................................................................................ 86 ◦ What We Changed .................................................................... 86 • Wiring In Navigation ◦ Step #1: Defining the Version .............................................................. 87 ◦ Step #2: Adding the Plugin Dependency .......................................... 89 ◦ Step #3: Requesting the Plugins ........................................................ 89 ◦ Step #4: Augmenting Our Dependencies ......................................... 90 ◦ Step #5: Defining Our Navigation Graph ........................................... 91 ◦ Step #6: Setting Up a New Activity Layout Resource ....................... 94 ◦ Step #7: Wiring in the Navigation ..................................................... 96 ◦ Final Results ......................................................................................... 97 ◦ What We Changed .................................................................. 100 • Setting Up the App Bar ◦ Step #1: Defining Some Colors .......................................................... 102 ◦ Step #2: Adjusting Our Theme ......................................................... 105 ◦ Step #3: Adding a Toolbar ................................................................. 108 ◦ Step #4: Adding an Icon ..................................................................... 112 ◦ Step #5: Defining an Item .................................................................. 114 ◦ Step #6: Enabling View Binding ....................................................... 124 ◦ Step #7: Using View Binding in Our Activity ................................... 125 ◦ Step #8: Loading Our Options ......................................................... 126 ◦ Step #9: Trying It Out ......................................................................... 127 ◦ Final Results ....................................................................................... 128 ◦ What We Changed ................................................................... 131 • Setting Up an Activity ii
◦ Step #1: Creating the Stub Activity Class and Manifest Entry ......... 133 ◦ Step #2: Adding a Toolbar and a WebView ..................................... 136 ◦ Step #3: Launching Our Activity ....................................................... 143 ◦ Step #4: Defining Some About Text ................................................. 144 ◦ Step #5: Populating the Toolbar and WebView ............................... 146 ◦ Final Results ....................................................................................... 147 ◦ What We Changed ................................................................... 149 • Defining a Model ◦ Step #1: Adding a Stub POJO ............................................................. 151 ◦ Step #2: Switching to a data Class ..................................................... 151 ◦ Step #3: Adding the Constructor ....................................................... 152 ◦ Step #4: Supporting Instant on Older Devices ................................. 153 ◦ Final Results ....................................................................................... 154 ◦ What We Changed ................................................................... 156 • Setting Up a Repository ◦ Step #1: Adding the Repository Class ............................................... 158 ◦ Step #2: Creating Some Fake Data .................................................... 158 ◦ Final Results ....................................................................................... 159 ◦ What We Changed ................................................................... 159 • Inverting Our Dependencies ◦ Step #1: Adding the Dependencies ................................................... 162 ◦ Step #2: Creating a Custom Application .......................................... 163 ◦ Step #3: Defining Our Module .......................................................... 164 ◦ Final Results ....................................................................................... 166 ◦ What We Changed ................................................................... 169 • Incorporating a ViewModel ◦ Step #1: Adding the Dependencies .................................................... 172 ◦ Step #2: Creating a Stub ViewModel ................................................. 172 ◦ Step #3: Getting and Using Our Repository ..................................... 173 ◦ Step #4: Depositing a Koin ................................................................. 173 ◦ Step #5: Injecting the Motor .............................................................. 174 ◦ Final Results ........................................................................................ 175 ◦ What We Changed ................................................................... 177 • Populating Our RecyclerView ◦ Step #1: Defining a Row Layout ........................................................ 179 ◦ Step #2: Adding a Stub ViewHolder ................................................. 186 ◦ Step #3: Creating a Stub Adapter ...................................................... 186 ◦ Step #4: Comparing Our Models ...................................................... 189 ◦ Step #5: Completing the Adapter and ViewHolder .......................... 191 ◦ Step #6: Wiring Up the RecyclerView .............................................. 193 ◦ Final Results ....................................................................................... 195 iii
◦ What We Changed ................................................................... 198 • Tracking the Completion Status ◦ Step #1: Registering for Events .......................................................... 201 ◦ Step #2: Passing the Event Up the Chain ......................................... 202 ◦ Step #3: Saving the Change ............................................................... 204 ◦ Final Results ....................................................................................... 205 ◦ What We Changed .................................................................. 209 • Displaying an Item ◦ Step #1: Creating the Fragment .......................................................... 211 ◦ Step #2: Updating the Navigation Graph .......................................... 212 ◦ Step #3: Responding to List Clicks ................................................... 216 ◦ Step #4: Teaching Navigation About the App Bar ........................... 219 ◦ Step #5: Creating an Empty Layout .................................................. 220 ◦ Step #6: Adding the Completed Icon ................................................ 221 ◦ Step #7: Displaying the Description ................................................. 227 ◦ Step #8: Showing the Created-On Date ........................................... 229 ◦ Step #9: Adding the Notes ................................................................ 233 ◦ Step #10: Adding Navigation Arguments ......................................... 235 ◦ Step #11: Displaying the Layout ......................................................... 238 ◦ Step #12: Making Another Motor ...................................................... 239 ◦ Step #13: Populating the Layout ........................................................ 241 ◦ Final Results ....................................................................................... 242 ◦ What We Changed ................................................................... 251 • Editing an Item ◦ Step #1: Creating the Fragment ......................................................... 254 ◦ Step #2: Setting Up the Navigation .................................................. 254 ◦ Step #3: Setting Up a Menu Resource .............................................. 256 ◦ Step #4: Showing the App Bar Item ................................................ 260 ◦ Step #5: Displaying the (Empty) Fragment ..................................... 262 ◦ Step #6: Creating an Empty Layout .................................................. 263 ◦ Step #7: Adding the CheckBox ......................................................... 263 ◦ Step #8: Creating the Description Field ........................................... 264 ◦ Step #9: Adding the Notes Field ...................................................... 268 ◦ Step #10: Populating the Layout ....................................................... 270 ◦ Final Results ....................................................................................... 272 ◦ What We Changed ................................................................... 277 • Saving an Item ◦ Step #1: Adding the App Bar Item .................................................... 279 ◦ Step #2: Improving the Motor .......................................................... 282 ◦ Step #3: Replacing the Item .............................................................. 283 ◦ Step #4: Returning to the Display Fragment ................................... 284 iv
◦ Step #5: Getting Updated Items ....................................................... 286 ◦ Final Results ....................................................................................... 287 ◦ What We Changed ................................................................... 291 • Adding and Deleting Items ◦ Step #1: Trimming Our Repository ................................................... 293 ◦ Step #2: Showing an Empty View ..................................................... 294 ◦ Step #3: Adding an Add App Bar Item ............................................ 296 ◦ Step #4: Launching the EditFragment for Adds ............................. 299 ◦ Step #5: Hiding the Empty View ...................................................... 305 ◦ Step #6: Adding a Delete App Bar Item ........................................... 306 ◦ Step #7: Deleting the Item ................................................................ 307 ◦ Step #8: Fixing the Delete-on-Add Problem ................................... 309 ◦ Final Results ....................................................................................... 310 ◦ What We Changed ................................................................... 317 • Interlude: So, What’s Wrong? ◦ Issues With What We Have .............................................................. 319 ◦ We Can Do Better .............................................................................. 320 • Refactoring Our Code ◦ Step #1: Creating Some Packages ...................................................... 325 ◦ Step #2: Moving Our Classes ............................................................ 326 ◦ What We Changed ............................................................................ 329 • Getting a Room (And Some Coroutines) ◦ Step #1: Requesting More Dependencies ......................................... 332 ◦ Step #2: Defining an Entity ............................................................... 333 ◦ Step #3: Crafting a DAO .................................................................... 334 ◦ Step #4: Adding a Database .............................................................. 337 ◦ Step #5: Creating a Transmogrifier ................................................... 338 ◦ Step #6: Add Our Database to Koin ................................................. 340 ◦ Step #7: Adding a Store to the Repository ............................... 341 ◦ Step #8: Fixing the Repository .......................................................... 342 ◦ Final Results ....................................................................................... 344 ◦ What We Changed .................................................................. 349 • Completing the Reactive Architecture ◦ Step #1: Adding the Dependency ...................................................... 352 ◦ Step #2: Defining a Roster View State .............................................. 353 ◦ Step #3: Emitting View States ........................................................... 354 ◦ Step #4: Consuming Roster View States .......................................... 354 ◦ Step #5: Wrapping the suspend Functions ...................................... 356 ◦ Step #6: Updating SingleModelMotor ............................................. 357 ◦ Step #7: Adapting DisplayFragment ................................................. 358 ◦ Step #8: Adapting EditFragment ...................................................... 358 v
◦ Final Results ....................................................................................... 361 ◦ What We Changed .................................................................. 370 • Testing a Motor ◦ Step #1: Examine Our Existing Tests ................................................ 373 ◦ Step #2: Decide on Instrumented Tests vs. Unit Tests .................... 375 ◦ Step #3: Adding Some Unit Test Dependencies .............................. 376 ◦ Step #4: Renaming Our Unit Test .................................................... 377 ◦ Step #5: Running the Stub Unit Test ................................................ 379 ◦ Step #6: Adding a MainDispatcherRule ........................................... 382 ◦ Step #7: Setting Up a Mock Repository ............................................ 384 ◦ Step #8: Adding a Test Function ....................................................... 387 ◦ Step #9: Adding Another Test Function .......................................... 388 ◦ Final Results ....................................................................................... 389 ◦ What We Changed .................................................................. 392 • Testing the Repository ◦ Step #1: Renaming Our Instrumented Test ...................................... 394 ◦ Step #2: Adding Some Instrumented Test Dependencies .............. 394 ◦ Step #3: Supporting a Test Database ................................................ 395 ◦ Step #4: Testing Adds ........................................................................ 395 ◦ Step #5: Writing and Running More Tests ....................................... 399 ◦ Final Results ....................................................................................... 401 ◦ What We Changed .................................................................. 405 • Testing a UI ◦ Step #1: Adding a New Test Class .................................................... 407 ◦ Step #2: Initializing Our Repository ................................................ 408 ◦ Step #3: Testing Our List .................................................................. 409 ◦ Final Results ........................................................................................ 411 ◦ What We Changed ................................................................... 412 • Tracking Our Load Status ◦ Step #1: Adjusting Our Layout .......................................................... 415 ◦ Step #2: Reacting to the Loaded Status ............................................ 418 ◦ Final Results ....................................................................................... 419 ◦ What We Changed .................................................................. 422 • Filtering Our Items ◦ Step #1: Adding a Query .................................................................... 423 ◦ Step #2: Defining a FilterMode ......................................................... 424 ◦ Step #3: Consuming a FilterMode .................................................... 424 ◦ Step #4: Augmenting Our Motor ..................................................... 425 ◦ Step #5: Adding a Checkable Submenu ........................................... 427 ◦ Step #6: Getting Control on Filter Choices ...................................... 433 ◦ Step #7: Fixing the Empty Text ......................................................... 435 vi
◦ Step #8: Addressing the Menu Problem .......................................... 438 ◦ Final Results ...................................................................................... 440 ◦ What We Changed .................................................................. 448 • Generating a Report ◦ Step #1: Adding a Save App Bar Item ............................................... 449 ◦ Step #2: Making a Save ...................................................................... 451 ◦ Step #3: Adding Some Handlebars ................................................... 457 ◦ Step #4: Creating the Report ............................................................ 458 ◦ Step #5: Writing Where the User Asked ......................................... 460 ◦ Step #6: Saving the Report ................................................................ 461 ◦ Step #7: Viewing the Report ............................................................. 462 ◦ Final Results ....................................................................................... 465 ◦ What We Changed .................................................................. 476 • Sharing the Report ◦ Step #1: Adding a Share App Bar Item .............................................. 477 ◦ Step #2: Adding FileProvider ............................................................ 479 ◦ Step #3: Caching the Report ............................................................ 484 ◦ Step #4: Sharing the Report ............................................................. 486 ◦ Final Results ....................................................................................... 487 ◦ What We Changed .................................................................. 497 • Collecting a Preference ◦ Step #1: Adding a Dependency ........................................................ 499 ◦ Step #2: Defining a Preference Screen ............................................. 501 ◦ Step #3: Displaying Our Preference Screen ..................................... 502 ◦ Step #4: Adding PrefsFragment to Our Navigation Graph ............. 503 ◦ Step #5: Navigating to Our Preference Screen ................................ 506 ◦ Final Results ........................................................................................ 511 ◦ What We Changed ................................................................... 517 • Contacting a Web Service ◦ Step #1: Adding Some Dependencies ............................................... 519 ◦ Step #2: Requesting a Permission ..................................................... 520 ◦ Step #3: Defining Our Response ........................................................ 521 ◦ Step #4: Retrieving the Items ............................................................ 523 ◦ Step #5: Updating the Local Items ................................................... 525 ◦ Step #6: Fixing the Existing Tests ..................................................... 528 ◦ Step #7: Retrieving Our Preference .................................................. 529 ◦ Step #8: Offering the Download Option .......................................... 530 ◦ Final Results ....................................................................................... 532 ◦ What We Changed ................................................................... 553 • Showing a Dialog ◦ Step #1: Adding a Stub Fragment ...................................................... 556 vii
◦ Step #2: Updating the Navigation Graph ......................................... 556 ◦ Step #3: Defining the Dialog Content .............................................. 558 ◦ Step #4: Emitting Errors From the Motor ........................................ 559 ◦ Step #5: Reacting to Errors ................................................................ 560 ◦ Step #6: Responding to Input ........................................................... 561 ◦ Step #7: Trying It Out ........................................................................ 564 ◦ Final Results ....................................................................................... 565 ◦ What We Changed .................................................................. 576 • Scheduling Work ◦ Step #1: Defining a SwitchPreference ............................................... 577 ◦ Step #2: Observing Preference Changes ................................. 579 ◦ Step #3: Adding the Dependency ............................................ 580 ◦ Step #4: Creating a Stub Worker ...................................................... 580 ◦ Step #5: Injecting Into the Worker ................................................... 581 ◦ Step #6: Doing the Work ................................................................... 582 ◦ Step #7: Scheduling the Work .......................................................... 582 ◦ Step #8: Trying It Out ........................................................................ 585 ◦ Final Results ...................................................................................... 586 ◦ What We Changed ................................................................... 593 viii
Preface Thanks! First, thanks for your interest in Android app development! Android is the world’s most popular operating system, but its value comes from apps written by developers like you. Also, thanks for your interest in this book! Hopefully, it can help “spin you up” on how to create Android applications that meet your needs and those of your users. And thanks for your interest in CommonsWare! The Warescription program makes this book and others available, to help developers like you craft the apps that your users need. How the Book Is Structured Many books — such as Elements of Android Jetpack, — present programming topics, showing you how to use different APIs, tools, and so on. This book is different. This book has you build an app from the beginning. Whereas traditional programming guides are focused on breadth and depth, this book is focused on being “hands-on”, guiding you through the steps to build the app. It provides some details on the underlying concepts, but it relies on other resources — such as Elements of Android Jetpack — for the full explanation of those details. Instead, this book provides step-by-step instructions for building the app. If you are the sort of person who “learns by doing”, then this book is for you! ix
Second-Generation Book Android app development can be divided into two generations: • First-generation app development uses Java as the programming language and leverages the Android Support Library and the android.arch edition of the Architecture Components • Second-generation app development more often uses Kotlin as the programming language and leverages AndroidX and the rest of Jetpack (which includes an AndroidX edition of the Architecture Components) This book is a second-generation book. It will show you step-by-step how to build a Kotlin-based Android app, using AndroidX libraries. Prerequisites This book is targeted at developers starting out with Android app development. You will want another educational resource to go along with this book. The book will cross-reference Elements of Android Jetpack, but you can use other programming guides as well. This book shows you each step for building an app, but you will need to turn to other resources for answers to questions like “why do we need to do X?” or “what other options do we have than Y?”. The app that you will build will be written in Kotlin, so you will need to have a bit of familiarity with that language. Elements of Kotlin covers this language and will be cross-referenced in a few places in this book. Also, the app that you will create in this book works on Android 5.0+ devices and emulators. You will either need a suitable device or be in position to use the Android SDK emulator in order to build and run the app. About the Updates This book will be updated a few times per year, to reflect new advances with Android, the libraries used by the sample app, and the development tools. If you obtained this book through the Warescription, you will be able to download updates as they become available, for the duration of your subscription period. PREFACE x
If you obtained this book through other channels… um, well, it’s still a really nice book! Each release has notations to show what is new or changed compared with the immediately preceding release: • The Table of Contents in the ebook formats (PDF, EPUB, MOBI/Kindle) shows sections with changes in bold-italic font • Those sections have changebars on the right to denote specific paragraphs that are new or modified And, there is the “What’s New” section, just below this paragraph. What’s New in Version 2.0? As with all of the CommonsWare x.0 releases, this is the same as the previous release (1.9), other than some bug fixes. Copying Code From This Book You are welcome to copy the code as you see in the book itself, as part of working through the tutorials. However, copying from the PDF version of the book can be troublesome, depending on your PDF viewer. Some PDF viewers do not handle the syntax highlighting used in this book very well. Recommended PDF viewers include: • Adobe Reader (Windows, macOS) • Foxit Reader (Windows, macOS, Linux) • Google Chrome (Windows, macOS) • Google Chromium (Linux) Also, once we start modifying files, you will find “Final Results” sections towards the end of each chapter. Those will contain the full listings of the source files that were modified in that chapter’s tutorial. And, these listings will not have syntax highlighting, making them suitable copy sources for a wider range of PDF viewers. PREFACE xi
Warescription If you purchased the Warescription, read on! If you obtained this book from other channels, feel free to jump ahead. The Warescription entitles you, for the duration of your subscription, to digital editions of this book and its updates, in PDF, EPUB, and Kindle (MOBI/KF8) formats. You also have access to other books that CommonsWare publishes during that subscription period, such as the aforementioned Elements of Android Jetpack. You also get access to first-generation Android books, such as the legendary The Busy Coder’s Guide to Android Development. Each subscriber gets personalized editions of all editions of each book. That way, your books are never out of date for long, and you can take advantage of new material as it is made available. However, you can only download the books while you have an active Warescription. There is a grace period after your Warescription ends: you can still download the book until the next book update comes out after your Warescription ends. After that, you can no longer download the book. Hence, please download your updates as they come out. You can find out when new releases of this book are available via: 1. The CommonsBlog 2. The CommonsWare Twitter feed 3. Opting into emails announcing each book release — log into the Warescription site and choose Configure from the nav bar 4. Just check back on the Warescription site every month or two Subscribers also have access to other benefits, including: • “Office hours” — online chats to help you get answers to your Android application development questions. You will find a calendar for these on your Warescription page. • A Stack Overflow “bump” service, to get additional attention for a question that you have posted there that does not have an adequate answer. • A discussion board for asking arbitrary questions about Android app development. PREFACE xii
Book Bug Bounty Find a problem in the book? Let CommonsWare know! Be the first to report a unique concrete problem in the current digital edition, and CommonsWare will extend your Warescription by six months as a bounty for helping CommonsWare deliver a better product. By “concrete” problem, we mean things like: 1. Typographical errors 2. Sample applications that do not work as advertised, in the environment described in the book 3. Factual errors that cannot be open to interpretation By “unique”, we mean ones not yet reported. Be sure to check the book’s errata page, though, to see if your issue has already been reported. One coupon is given per email containing valid bug reports. We appreciate hearing about “softer” issues as well, such as: 1. Places where you think we are in error, but where we feel our interpretation is reasonable 2. Places where you think we could add sample applications, or expand upon the existing material 3. Samples that do not work due to “shifting sands” of the underlying environment (e.g., changed APIs with new releases of an SDK) However, those “softer” issues do not qualify for the formal bounty program. Questions about the bug bounty, or problems you wish to report for bounty consideration, should be sent to bounty@commonsware.com. Source Code and Its License The source code samples shown in this book are available for download from the book’s GitLab repository. All of the Android projects are licensed under the Apache 2.0 License, in case you have the desire to reuse any of it. Copying source code directly from the book, in the PDF editions, works best with PREFACE xiii
Adobe Reader, though it may also work with other PDF viewers. Some PDF viewers, for reasons that remain unclear, foul up copying the source code to the clipboard when it is selected. Creative Commons and the Four-to-Free (42F) Guarantee Each CommonsWare book edition will be available for use under the Creative Commons Attribution-Noncommercial-ShareAlike 4.0 license as of the fourth anniversary of its publication date, or when 4,000 copies of the edition have been sold, whichever comes first. That means that, once four years have elapsed (perhaps sooner!), you can use this prose for non-commercial purposes. That is our Four-to- Free Guarantee to our readers and the broader community. For the purposes of this guarantee, new Warescriptions and renewals will be counted as sales of this edition, starting from the time the edition is published. This edition of this book will be available under the aforementioned Creative Commons license on 1 December 2024. Of course, watch the CommonsWare Web site, as this edition might be relicensed sooner based on sales. For more details on the Creative Commons Attribution-Noncommercial-ShareAlike 4.0 license, visit the Creative Commons Web site Note that future editions of this book will become free on later dates, each four years from the publication of that edition or based on sales of that specific edition. Releasing one edition under the Creative Commons license does not automatically release all editions under that license. PREFACE xiv
What We Are Building By following the instructions in this book, you will build an Android app. But first, let’s see what the app is that you are building. The Purpose Everybody has stuff to do. Ever since we have had “digital assistants” — such as the venerable Palm line of PDAs — a common use has been for tracking tasks to be done. So-called “to-do lists” are a popular sort of app, whether on the Web, on the desktop, or on mobile devices. The world has more than enough to-do list apps. Google themselves have published a long list of sample apps that use a to-do list as a way of exploring various GUI architectures. So, let’s build another one! Ours is not a fork of Google’s, but rather a “cleanroom” implementation of a to-do list with similar functionality. The Core UI There are three main screens that the user will spend time in: the roster of to-do items, a screen with details of a particular item, and a screen for either adding a new item or editing an existing one. There is also an “about” screen for displaying information about the app. 1
The Roster When initially launched, the app will show a roster of the recorded to-do items, if there are any. Hence, on the first run, it will show just an “empty view”, prompting the user to click the “add” app bar item to add a new item: Figure 1: ToDo App, As Initially Launched, with No Items WHAT WE ARE BUILDING 2
Once there are some items in the database, the roster will show those items, in alphabetical order by description, with a checkbox indicating whether or not they have been completed: Figure 2: ToDo App, Showing Some Items From here, the user can tap the checkbox to quickly mark an item as completed (or un-mark it if needed). WHAT WE ARE BUILDING 3