├── .github └── PULL_REQUEST_TEMPLATE.md ├── .gitignore ├── .idea ├── caches │ └── build_file_checksums.ser ├── codeStyles │ └── Project.xml ├── gradle.xml ├── markdown-navigator.xml ├── markdown-navigator │ └── profiles_settings.xml ├── misc.xml ├── modules.xml ├── runConfigurations.xml └── vcs.xml ├── CODE_OF_CONDUCT.md ├── CONTRIBUTING.md ├── LICENSE ├── NOTICE.txt ├── README.md ├── app ├── .gitignore ├── build.gradle ├── proguard-rules.pro └── src │ └── main │ ├── AndroidManifest.xml │ ├── java │ └── com │ │ └── amazonaws │ │ └── mobile │ │ └── samples │ │ └── mynotes │ │ ├── Injection.java │ │ ├── NotesApp.java │ │ ├── models │ │ ├── Note.java │ │ ├── OnClickCallback.java │ │ ├── PagedListConnectionResponse.java │ │ ├── RemoveCallback.java │ │ └── ResultCallback.java │ │ ├── repository │ │ ├── NotesDataSource.java │ │ ├── NotesDataSourceFactory.java │ │ └── NotesRepository.java │ │ ├── services │ │ ├── AnalyticsService.java │ │ ├── DataService.java │ │ └── mock │ │ │ ├── MockAnalyticsService.java │ │ │ └── MockDataService.java │ │ ├── ui │ │ ├── NoteDetailActivity.java │ │ ├── NoteDetailFragment.java │ │ ├── NoteListActivity.java │ │ ├── NoteListAdapter.java │ │ ├── NoteListViewHolder.java │ │ └── SwipeToDelete.java │ │ └── viewmodels │ │ ├── NoteDetailViewModel.java │ │ └── NoteListViewModel.java │ └── res │ ├── drawable-v24 │ └── ic_launcher_foreground.xml │ ├── drawable │ ├── ic_clear_24dp.xml │ └── ic_launcher_background.xml │ ├── layout-w900dp │ └── note_list.xml │ ├── layout │ ├── activity_note_detail.xml │ ├── activity_note_list.xml │ ├── note_detail.xml │ ├── note_list.xml │ └── note_list_content.xml │ ├── mipmap-hdpi │ ├── ic_launcher.png │ └── ic_launcher_round.png │ ├── mipmap-mdpi │ ├── ic_launcher.png │ └── ic_launcher_round.png │ ├── mipmap-xhdpi │ ├── ic_launcher.png │ └── ic_launcher_round.png │ ├── mipmap-xxhdpi │ ├── ic_launcher.png │ └── ic_launcher_round.png │ ├── mipmap-xxxhdpi │ ├── ic_launcher.png │ └── ic_launcher_round.png │ └── values │ ├── colors.xml │ ├── dimens.xml │ ├── strings.xml │ └── styles.xml ├── build.gradle ├── gradle.properties ├── gradle └── wrapper │ ├── gradle-wrapper.jar │ └── gradle-wrapper.properties ├── gradlew ├── gradlew.bat ├── settings.gradle └── tutorial ├── analytics.md ├── auth.md ├── data.md ├── index.md ├── open-project.png ├── pinpoint-addnote.png ├── pinpoint-demographics.png ├── pinpoint-overview.png ├── tutorial-notes-app-anim.gif └── tutorial-notes-authentication-anim.gif /.github/PULL_REQUEST_TEMPLATE.md: -------------------------------------------------------------------------------- 1 | *Issue #, if available:* 2 | 3 | *Description of changes:* 4 | 5 | 6 | By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice. -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | *.iml 2 | .gradle 3 | /local.properties 4 | /.idea/libraries 5 | /.idea/modules.xml 6 | /.idea/workspace.xml 7 | .DS_Store 8 | /build 9 | /captures 10 | .externalNativeBuild 11 | -------------------------------------------------------------------------------- /.idea/caches/build_file_checksums.ser: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/amazon-archives/aws-mobile-android-notes-tutorial/59c5b1085949d04daa73ab630ce2bb28dbd00833/.idea/caches/build_file_checksums.ser -------------------------------------------------------------------------------- /.idea/codeStyles/Project.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 15 | 16 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | -------------------------------------------------------------------------------- /.idea/gradle.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 17 | 18 | -------------------------------------------------------------------------------- /.idea/markdown-navigator.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 36 | 37 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | -------------------------------------------------------------------------------- /.idea/markdown-navigator/profiles_settings.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | -------------------------------------------------------------------------------- /.idea/misc.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 17 | 27 | 28 | 29 | 30 | 31 | 32 | 34 | -------------------------------------------------------------------------------- /.idea/modules.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /.idea/runConfigurations.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 11 | 12 | -------------------------------------------------------------------------------- /.idea/vcs.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /CODE_OF_CONDUCT.md: -------------------------------------------------------------------------------- 1 | ## Code of Conduct 2 | This project has adopted the [Amazon Open Source Code of Conduct](https://aws.github.io/code-of-conduct). 3 | For more information see the [Code of Conduct FAQ](https://aws.github.io/code-of-conduct-faq) or contact 4 | opensource-codeofconduct@amazon.com with any additional questions or comments. 5 | -------------------------------------------------------------------------------- /CONTRIBUTING.md: -------------------------------------------------------------------------------- 1 | # Contributing Guidelines 2 | 3 | Thank you for your interest in contributing to our project. Whether it's a bug report, new feature, correction, or additional 4 | documentation, we greatly value feedback and contributions from our community. 5 | 6 | Please read through this document before submitting any issues or pull requests to ensure we have all the necessary 7 | information to effectively respond to your bug report or contribution. 8 | 9 | 10 | ## Reporting Bugs/Feature Requests 11 | 12 | We welcome you to use the GitHub issue tracker to report bugs or suggest features. 13 | 14 | When filing an issue, please check [existing open](https://github.com/aws-samples/aws-mobile-android-kotlin-notes/issues), or [recently closed](https://github.com/aws-samples/aws-mobile-android-kotlin-notes/issues?utf8=%E2%9C%93&q=is%3Aissue%20is%3Aclosed%20), issues to make sure somebody else hasn't already 15 | reported the issue. Please try to include as much information as you can. Details like these are incredibly useful: 16 | 17 | * A reproducible test case or series of steps 18 | * The version of our code being used 19 | * Any modifications you've made relevant to the bug 20 | * Anything unusual about your environment or deployment 21 | 22 | 23 | ## Contributing via Pull Requests 24 | Contributions via pull requests are much appreciated. Before sending us a pull request, please ensure that: 25 | 26 | 1. You are working against the latest source on the *master* branch. 27 | 2. You check existing open, and recently merged, pull requests to make sure someone else hasn't addressed the problem already. 28 | 3. You open an issue to discuss any significant work - we would hate for your time to be wasted. 29 | 30 | To send us a pull request, please: 31 | 32 | 1. Fork the repository. 33 | 2. Modify the source; please focus on the specific change you are contributing. If you also reformat all the code, it will be hard for us to focus on your change. 34 | 3. Ensure local tests pass. 35 | 4. Commit to your fork using clear commit messages. 36 | 5. Send us a pull request, answering any default questions in the pull request interface. 37 | 6. Pay attention to any automated CI failures reported in the pull request, and stay involved in the conversation. 38 | 39 | GitHub provides additional document on [forking a repository](https://help.github.com/articles/fork-a-repo/) and 40 | [creating a pull request](https://help.github.com/articles/creating-a-pull-request/). 41 | 42 | 43 | ## Finding contributions to work on 44 | Looking at the existing issues is a great way to find something to contribute on. As our projects, by default, use the default GitHub issue labels ((enhancement/bug/duplicate/help wanted/invalid/question/wontfix), looking at any ['help wanted'](https://github.com/aws-samples/aws-mobile-android-kotlin-notes/labels/help%20wanted) issues is a great place to start. 45 | 46 | 47 | ## Code of Conduct 48 | This project has adopted the [Amazon Open Source Code of Conduct](https://aws.github.io/code-of-conduct). 49 | For more information see the [Code of Conduct FAQ](https://aws.github.io/code-of-conduct-faq) or contact 50 | opensource-codeofconduct@amazon.com with any additional questions or comments. 51 | 52 | 53 | ## Security issue notifications 54 | If you discover a potential security issue in this project we ask that you notify AWS/Amazon Security via our [vulnerability reporting page](http://aws.amazon.com/security/vulnerability-reporting/). Please do **not** create a public github issue. 55 | 56 | 57 | ## Licensing 58 | 59 | See the [LICENSE](https://github.com/aws-samples/aws-mobile-android-kotlin-notes/blob/master/LICENSE) file for our project's licensing. We will ask you to confirm the licensing of your contribution. 60 | 61 | We may ask you to sign a [Contributor License Agreement (CLA)](http://en.wikipedia.org/wiki/Contributor_License_Agreement) for larger changes. -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Copyright 2018 Amazon.com, Inc. or its affiliates. All Rights Reserved. 2 | 3 | Permission is hereby granted, free of charge, to any person obtaining a copy of this 4 | software and associated documentation files (the "Software"), to deal in the Software 5 | without restriction, including without limitation the rights to use, copy, modify, 6 | merge, publish, distribute, sublicense, and/or sell copies of the Software, and to 7 | permit persons to whom the Software is furnished to do so. 8 | 9 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, 10 | INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A 11 | PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT 12 | HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 13 | OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE 14 | SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -------------------------------------------------------------------------------- /NOTICE.txt: -------------------------------------------------------------------------------- 1 | ** Android Architecture Components; version 1.1.1 -- https://developer.android.com 2 | ** Android Support Library; version 27.1.1 -- https://developer.android.com 3 | 4 | Apache License 5 | Version 2.0, January 2004 6 | http://www.apache.org/licenses/ 7 | 8 | TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 9 | 10 | 1. Definitions. 11 | 12 | "License" shall mean the terms and conditions for use, reproduction, and 13 | distribution as defined by Sections 1 through 9 of this document. 14 | 15 | "Licensor" shall mean the copyright owner or entity authorized by the copyright 16 | owner that is granting the License. 17 | 18 | "Legal Entity" shall mean the union of the acting entity and all other entities 19 | that control, are controlled by, or are under common control with that entity. 20 | For the purposes of this definition, "control" means (i) the power, direct or 21 | indirect, to cause the direction or management of such entity, whether by 22 | contract or otherwise, or (ii) ownership of fifty percent (50%) or more of the 23 | outstanding shares, or (iii) beneficial ownership of such entity. 24 | 25 | "You" (or "Your") shall mean an individual or Legal Entity exercising 26 | permissions granted by this License. 27 | 28 | "Source" form shall mean the preferred form for making modifications, including 29 | but not limited to software source code, documentation source, and 30 | configuration files. 31 | 32 | "Object" form shall mean any form resulting from mechanical transformation or 33 | translation of a Source form, including but not limited to compiled object 34 | code, generated documentation, and conversions to other media types. 35 | 36 | "Work" shall mean the work of authorship, whether in Source or Object form, 37 | made available under the License, as indicated by a copyright notice that is 38 | included in or attached to the work (an example is provided in the Appendix 39 | below). 40 | 41 | "Derivative Works" shall mean any work, whether in Source or Object form, that 42 | is based on (or derived from) the Work and for which the editorial revisions, 43 | annotations, elaborations, or other modifications represent, as a whole, an 44 | original work of authorship. For the purposes of this License, Derivative Works 45 | shall not include works that remain separable from, or merely link (or bind by 46 | name) to the interfaces of, the Work and Derivative Works thereof. 47 | 48 | "Contribution" shall mean any work of authorship, including the original 49 | version of the Work and any modifications or additions to that Work or 50 | Derivative Works thereof, that is intentionally submitted to Licensor for 51 | inclusion in the Work by the copyright owner or by an individual or Legal 52 | Entity authorized to submit on behalf of the copyright owner. For the purposes 53 | of this definition, "submitted" means any form of electronic, verbal, or 54 | written communication sent to the Licensor or its representatives, including 55 | but not limited to communication on electronic mailing lists, source code 56 | control systems, and issue tracking systems that are managed by, or on behalf 57 | of, the Licensor for the purpose of discussing and improving the Work, but 58 | excluding communication that is conspicuously marked or otherwise designated in 59 | writing by the copyright owner as "Not a Contribution." 60 | 61 | "Contributor" shall mean Licensor and any individual or Legal Entity on behalf 62 | of whom a Contribution has been received by Licensor and subsequently 63 | incorporated within the Work. 64 | 65 | 2. Grant of Copyright License. Subject to the terms and conditions of this 66 | License, each Contributor hereby grants to You a perpetual, worldwide, 67 | non-exclusive, no-charge, royalty-free, irrevocable copyright license to 68 | reproduce, prepare Derivative Works of, publicly display, publicly perform, 69 | sublicense, and distribute the Work and such Derivative Works in Source or 70 | Object form. 71 | 72 | 3. Grant of Patent License. Subject to the terms and conditions of this 73 | License, each Contributor hereby grants to You a perpetual, worldwide, 74 | non-exclusive, no-charge, royalty-free, irrevocable (except as stated in this 75 | section) patent license to make, have made, use, offer to sell, sell, import, 76 | and otherwise transfer the Work, where such license applies only to those 77 | patent claims licensable by such Contributor that are necessarily infringed by 78 | their Contribution(s) alone or by combination of their Contribution(s) with the 79 | Work to which such Contribution(s) was submitted. If You institute patent 80 | litigation against any entity (including a cross-claim or counterclaim in a 81 | lawsuit) alleging that the Work or a Contribution incorporated within the Work 82 | constitutes direct or contributory patent infringement, then any patent 83 | licenses granted to You under this License for that Work shall terminate as of 84 | the date such litigation is filed. 85 | 86 | 4. Redistribution. You may reproduce and distribute copies of the Work or 87 | Derivative Works thereof in any medium, with or without modifications, and in 88 | Source or Object form, provided that You meet the following conditions: 89 | 90 | (a) You must give any other recipients of the Work or Derivative Works a copy 91 | of this License; and 92 | 93 | (b) You must cause any modified files to carry prominent notices stating that 94 | You changed the files; and 95 | 96 | (c) You must retain, in the Source form of any Derivative Works that You 97 | distribute, all copyright, patent, trademark, and attribution notices from the 98 | Source form of the Work, excluding those notices that do not pertain to any 99 | part of the Derivative Works; and 100 | 101 | (d) If the Work includes a "NOTICE" text file as part of its distribution, then 102 | any Derivative Works that You distribute must include a readable copy of the 103 | attribution notices contained within such NOTICE file, excluding those notices 104 | that do not pertain to any part of the Derivative Works, in at least one of the 105 | following places: within a NOTICE text file distributed as part of the 106 | Derivative Works; within the Source form or documentation, if provided along 107 | with the Derivative Works; or, within a display generated by the Derivative 108 | Works, if and wherever such third-party notices normally appear. The contents 109 | of the NOTICE file are for informational purposes only and do not modify the 110 | License. You may add Your own attribution notices within Derivative Works that 111 | You distribute, alongside or as an addendum to the NOTICE text from the Work, 112 | provided that such additional attribution notices cannot be construed as 113 | modifying the License. 114 | 115 | You may add Your own copyright statement to Your modifications and may provide 116 | additional or different license terms and conditions for use, reproduction, or 117 | distribution of Your modifications, or for any such Derivative Works as a 118 | whole, provided Your use, reproduction, and distribution of the Work otherwise 119 | complies with the conditions stated in this License. 120 | 121 | 5. Submission of Contributions. Unless You explicitly state otherwise, any 122 | Contribution intentionally submitted for inclusion in the Work by You to the 123 | Licensor shall be under the terms and conditions of this License, without any 124 | additional terms or conditions. Notwithstanding the above, nothing herein shall 125 | supersede or modify the terms of any separate license agreement you may have 126 | executed with Licensor regarding such Contributions. 127 | 128 | 6. Trademarks. This License does not grant permission to use the trade names, 129 | trademarks, service marks, or product names of the Licensor, except as required 130 | for reasonable and customary use in describing the origin of the Work and 131 | reproducing the content of the NOTICE file. 132 | 133 | 7. Disclaimer of Warranty. Unless required by applicable law or agreed to in 134 | writing, Licensor provides the Work (and each Contributor provides its 135 | Contributions) on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 136 | KIND, either express or implied, including, without limitation, any warranties 137 | or conditions of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A 138 | PARTICULAR PURPOSE. You are solely responsible for determining the 139 | appropriateness of using or redistributing the Work and assume any risks 140 | associated with Your exercise of permissions under this License. 141 | 142 | 8. Limitation of Liability. In no event and under no legal theory, whether in 143 | tort (including negligence), contract, or otherwise, unless required by 144 | applicable law (such as deliberate and grossly negligent acts) or agreed to in 145 | writing, shall any Contributor be liable to You for damages, including any 146 | direct, indirect, special, incidental, or consequential damages of any 147 | character arising as a result of this License or out of the use or inability to 148 | use the Work (including but not limited to damages for loss of goodwill, work 149 | stoppage, computer failure or malfunction, or any and all other commercial 150 | damages or losses), even if such Contributor has been advised of the 151 | possibility of such damages. 152 | 153 | 9. Accepting Warranty or Additional Liability. While redistributing the Work or 154 | Derivative Works thereof, You may choose to offer, and charge a fee for, 155 | acceptance of support, warranty, indemnity, or other liability obligations 156 | and/or rights consistent with this License. However, in accepting such 157 | obligations, You may act only on Your own behalf and on Your sole 158 | responsibility, not on behalf of any other Contributor, and only if You agree 159 | to indemnify, defend, and hold each Contributor harmless for any liability 160 | incurred by, or claims asserted against, such Contributor by reason of your 161 | accepting any such warranty or additional liability. 162 | 163 | END OF TERMS AND CONDITIONS 164 | 165 | APPENDIX: How to apply the Apache License to your work. 166 | 167 | To apply the Apache License to your work, attach the following boilerplate 168 | notice, with the fields enclosed by brackets "[]" replaced with your own 169 | identifying information. (Don't include the brackets!) The text should be 170 | enclosed in the appropriate comment syntax for the file format. We also 171 | recommend that a file or class name and description of purpose be included on 172 | the same "printed page" as the copyright notice for easier identification 173 | within third-party archives. 174 | 175 | Copyright [yyyy] [name of copyright owner] 176 | 177 | Licensed under the Apache License, Version 2.0 (the "License"); 178 | you may not use this file except in compliance with the License. 179 | You may obtain a copy of the License at 180 | 181 | http://www.apache.org/licenses/LICENSE-2.0 182 | 183 | Unless required by applicable law or agreed to in writing, software 184 | distributed under the License is distributed on an "AS IS" BASIS, 185 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 186 | See the License for the specific language governing permissions and 187 | limitations under the License. 188 | 189 | * For Android Architecture Components see also this required NOTICE: 190 | Copyright 2018 The Android Open Source Project, Inc. 191 | * For Android Support Library see also this required NOTICE: 192 | Copyright (C) 2011 The Android Open Source Project 193 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | ## AWS Mobile Android Kotlin Notes 2 | 3 | The AWS Mobile Notes Tutorial code for Android / Java. You can start the tutorial by looking 4 | in the [tutorial directory](./tutorial/index.md) 5 | 6 | ## License Summary 7 | 8 | This sample code is made available under a modified MIT license. See the [LICENSE](./LICENSE) file. 9 | -------------------------------------------------------------------------------- /app/.gitignore: -------------------------------------------------------------------------------- 1 | /build 2 | -------------------------------------------------------------------------------- /app/build.gradle: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2018 Amazon.com, Inc. or its affiliates. All Rights Reserved. 3 | Permission is hereby granted, free of charge, to any person obtaining a copy of this 4 | software and associated documentation files (the "Software"), to deal in the Software 5 | without restriction, including without limitation the rights to use, copy, modify, 6 | merge, publish, distribute, sublicense, and/or sell copies of the Software, and to 7 | permit persons to whom the Software is furnished to do so. 8 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, 9 | INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A 10 | PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT 11 | HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 12 | OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE 13 | SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 14 | */ 15 | apply plugin: 'com.android.application' 16 | 17 | android { 18 | compileSdkVersion 27 19 | buildToolsVersion '27.0.3' 20 | 21 | defaultConfig { 22 | applicationId "com.amazonaws.mobile.samples.notes" 23 | minSdkVersion 23 24 | targetSdkVersion 27 25 | versionCode 1 26 | versionName "1.0" 27 | } 28 | 29 | buildTypes { 30 | release { 31 | minifyEnabled true 32 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' 33 | } 34 | 35 | debug { 36 | minifyEnabled false 37 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' 38 | } 39 | } 40 | 41 | compileOptions { 42 | sourceCompatibility JavaVersion.VERSION_1_8 43 | targetCompatibility JavaVersion.VERSION_1_8 44 | } 45 | } 46 | 47 | dependencies { 48 | def support_version = '27.1.1' 49 | def constraint_version = '1.1.2' 50 | def lifecycle_version = '1.1.1' 51 | def paging_version = '1.0.1' 52 | 53 | implementation fileTree(dir: 'libs', include: ['*.jar']) 54 | implementation "com.android.support:appcompat-v7:$support_version" 55 | implementation "com.android.support:support-v4:$support_version" 56 | implementation "com.android.support:cardview-v7:$support_version" 57 | implementation "com.android.support:recyclerview-v7:$support_version" 58 | implementation "com.android.support:design:$support_version" 59 | implementation "com.android.support.constraint:constraint-layout:$constraint_version" 60 | 61 | // Android Architecture Components 62 | implementation "android.arch.lifecycle:extensions:$lifecycle_version" 63 | implementation "android.arch.paging:runtime:$paging_version" 64 | } 65 | -------------------------------------------------------------------------------- /app/proguard-rules.pro: -------------------------------------------------------------------------------- 1 | # Add project specific ProGuard rules here. 2 | # By default, the flags in this file are appended to flags specified 3 | # in /Users/adrianha/Library/Android/sdk/tools/proguard/proguard-android.txt 4 | # You can edit the include path and order by changing the proguardFiles 5 | # directive in build.gradle. 6 | # 7 | # For more details, see 8 | # http://developer.android.com/guide/developing/tools/proguard.html 9 | 10 | # Add any project specific keep options here: 11 | 12 | # If your project uses WebView with JS, uncomment the following 13 | # and specify the fully qualified class name to the JavaScript interface 14 | # class: 15 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview { 16 | # public *; 17 | #} 18 | 19 | # Uncomment this to preserve the line number information for 20 | # debugging stack traces. 21 | #-keepattributes SourceFile,LineNumberTable 22 | 23 | # If you keep the line number information, uncomment this to 24 | # hide the original source file name. 25 | #-renamesourcefileattribute SourceFile 26 | -------------------------------------------------------------------------------- /app/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 2 | 18 | 20 | 21 | 29 | 30 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 47 | 48 | 51 | 52 | 53 | 54 | 55 | 56 | -------------------------------------------------------------------------------- /app/src/main/java/com/amazonaws/mobile/samples/mynotes/Injection.java: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2018 Amazon.com, Inc. or its affiliates. All Rights Reserved. 3 | 4 | Permission is hereby granted, free of charge, to any person obtaining a copy of this 5 | software and associated documentation files (the "Software"), to deal in the Software 6 | without restriction, including without limitation the rights to use, copy, modify, 7 | merge, publish, distribute, sublicense, and/or sell copies of the Software, and to 8 | permit persons to whom the Software is furnished to do so. 9 | 10 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, 11 | INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A 12 | PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT 13 | HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 14 | OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE 15 | SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 16 | */ 17 | package com.amazonaws.mobile.samples.mynotes; 18 | 19 | import android.content.Context; 20 | 21 | import com.amazonaws.mobile.samples.mynotes.repository.NotesRepository; 22 | import com.amazonaws.mobile.samples.mynotes.services.AnalyticsService; 23 | import com.amazonaws.mobile.samples.mynotes.services.DataService; 24 | import com.amazonaws.mobile.samples.mynotes.services.mock.MockAnalyticsService; 25 | import com.amazonaws.mobile.samples.mynotes.services.mock.MockDataService; 26 | 27 | /** 28 | * This is a "fake" dependency injection system. 29 | */ 30 | public class Injection { 31 | private static DataService dataService = null; 32 | private static AnalyticsService analyticsService = null; 33 | private static NotesRepository notesRepository = null; 34 | 35 | public static synchronized DataService getDataService() { 36 | return dataService; 37 | } 38 | 39 | public static synchronized AnalyticsService getAnalyticsService() { 40 | return analyticsService; 41 | } 42 | 43 | public static synchronized NotesRepository getNotesRepository() { 44 | return notesRepository; 45 | } 46 | 47 | public static synchronized void initialize(Context context) { 48 | if (analyticsService == null) { 49 | analyticsService = new MockAnalyticsService(); 50 | } 51 | 52 | if (dataService == null) { 53 | dataService = new MockDataService(); 54 | } 55 | 56 | if (notesRepository == null) { 57 | notesRepository = new NotesRepository(dataService); 58 | } 59 | } 60 | } 61 | -------------------------------------------------------------------------------- /app/src/main/java/com/amazonaws/mobile/samples/mynotes/NotesApp.java: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2018 Amazon.com, Inc. or its affiliates. All Rights Reserved. 3 | 4 | Permission is hereby granted, free of charge, to any person obtaining a copy of this 5 | software and associated documentation files (the "Software"), to deal in the Software 6 | without restriction, including without limitation the rights to use, copy, modify, 7 | merge, publish, distribute, sublicense, and/or sell copies of the Software, and to 8 | permit persons to whom the Software is furnished to do so. 9 | 10 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, 11 | INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A 12 | PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT 13 | HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 14 | OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE 15 | SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 16 | */ 17 | package com.amazonaws.mobile.samples.mynotes; 18 | 19 | import android.app.Application; 20 | 21 | /** 22 | * Application class responsible for initializing singletons and other 23 | * common components 24 | */ 25 | public class NotesApp extends Application { 26 | /** 27 | * The name of the field used to hold the ID of the note when information is passed 28 | * internally between activities. 29 | */ 30 | public static String ITEM_ID = "noteId"; 31 | 32 | @Override 33 | public void onCreate() { 34 | super.onCreate(); 35 | Injection.initialize(getApplicationContext()); 36 | } 37 | } 38 | 39 | -------------------------------------------------------------------------------- /app/src/main/java/com/amazonaws/mobile/samples/mynotes/models/Note.java: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2018 Amazon.com, Inc. or its affiliates. All Rights Reserved. 3 | 4 | Permission is hereby granted, free of charge, to any person obtaining a copy of this 5 | software and associated documentation files (the "Software"), to deal in the Software 6 | without restriction, including without limitation the rights to use, copy, modify, 7 | merge, publish, distribute, sublicense, and/or sell copies of the Software, and to 8 | permit persons to whom the Software is furnished to do so. 9 | 10 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, 11 | INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A 12 | PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT 13 | HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 14 | OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE 15 | SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 16 | */ 17 | package com.amazonaws.mobile.samples.mynotes.models; 18 | 19 | import java.util.UUID; 20 | 21 | /** 22 | * Model for a single note 23 | */ 24 | public class Note { 25 | private String noteId; 26 | private String title; 27 | private String content; 28 | 29 | public Note() { 30 | noteId = UUID.randomUUID().toString(); 31 | title = ""; 32 | content = ""; 33 | } 34 | 35 | public Note(String noteId) { 36 | this.noteId = noteId; 37 | title = ""; 38 | content = ""; 39 | } 40 | 41 | public Note(String noteId, String title, String content) { 42 | this.noteId = noteId; 43 | this.title = title; 44 | this.content = content; 45 | } 46 | 47 | public String getNoteId() { 48 | return noteId; 49 | } 50 | 51 | public void setNoteId(String noteId) { 52 | this.noteId = noteId; 53 | } 54 | 55 | public String getTitle() { 56 | return title; 57 | } 58 | 59 | public void setTitle(String title) { 60 | this.title = title; 61 | } 62 | 63 | public String getContent() { 64 | return content; 65 | } 66 | 67 | public void setContent(String content) { 68 | this.content = content; 69 | } 70 | } 71 | -------------------------------------------------------------------------------- /app/src/main/java/com/amazonaws/mobile/samples/mynotes/models/OnClickCallback.java: -------------------------------------------------------------------------------- 1 | package com.amazonaws.mobile.samples.mynotes.models; 2 | 3 | public interface OnClickCallback { 4 | void onClick(Note item); 5 | } 6 | -------------------------------------------------------------------------------- /app/src/main/java/com/amazonaws/mobile/samples/mynotes/models/PagedListConnectionResponse.java: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2018 Amazon.com, Inc. or its affiliates. All Rights Reserved. 3 | 4 | Permission is hereby granted, free of charge, to any person obtaining a copy of this 5 | software and associated documentation files (the "Software"), to deal in the Software 6 | without restriction, including without limitation the rights to use, copy, modify, 7 | merge, publish, distribute, sublicense, and/or sell copies of the Software, and to 8 | permit persons to whom the Software is furnished to do so. 9 | 10 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, 11 | INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A 12 | PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT 13 | HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 14 | OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE 15 | SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 16 | */ 17 | package com.amazonaws.mobile.samples.mynotes.models; 18 | 19 | import java.util.List; 20 | 21 | /** 22 | * Model class used as the response to an API call. In this particular instance, it's 23 | * a paged list response where the next page is denoted by a nextToken - ostensibly a 24 | * string, but really an opaque blob that you should not mess with - just submit it along 25 | * with the API call to get the next page. 26 | * @param the type of elements within the response 27 | */ 28 | public class PagedListConnectionResponse { 29 | private List items; 30 | private String nextToken; 31 | 32 | public PagedListConnectionResponse(List items, String nextToken) { 33 | this.items = items; 34 | this.nextToken = nextToken; 35 | } 36 | 37 | public List getItems() { 38 | return items; 39 | } 40 | 41 | public String getNextToken() { 42 | return nextToken; 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /app/src/main/java/com/amazonaws/mobile/samples/mynotes/models/RemoveCallback.java: -------------------------------------------------------------------------------- 1 | package com.amazonaws.mobile.samples.mynotes.models; 2 | 3 | public interface RemoveCallback { 4 | void onRemove(Note item); 5 | } 6 | -------------------------------------------------------------------------------- /app/src/main/java/com/amazonaws/mobile/samples/mynotes/models/ResultCallback.java: -------------------------------------------------------------------------------- 1 | package com.amazonaws.mobile.samples.mynotes.models; 2 | 3 | public interface ResultCallback { 4 | void onResult(T result); 5 | } 6 | -------------------------------------------------------------------------------- /app/src/main/java/com/amazonaws/mobile/samples/mynotes/repository/NotesDataSource.java: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2018 Amazon.com, Inc. or its affiliates. All Rights Reserved. 3 | 4 | Permission is hereby granted, free of charge, to any person obtaining a copy of this 5 | software and associated documentation files (the "Software"), to deal in the Software 6 | without restriction, including without limitation the rights to use, copy, modify, 7 | merge, publish, distribute, sublicense, and/or sell copies of the Software, and to 8 | permit persons to whom the Software is furnished to do so. 9 | 10 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, 11 | INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A 12 | PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT 13 | HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 14 | OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE 15 | SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 16 | */ 17 | package com.amazonaws.mobile.samples.mynotes.repository; 18 | 19 | import android.arch.paging.PageKeyedDataSource; 20 | import android.support.annotation.NonNull; 21 | import android.util.Log; 22 | 23 | import com.amazonaws.mobile.samples.mynotes.models.Note; 24 | import com.amazonaws.mobile.samples.mynotes.models.PagedListConnectionResponse; 25 | import com.amazonaws.mobile.samples.mynotes.models.ResultCallback; 26 | import com.amazonaws.mobile.samples.mynotes.services.DataService; 27 | 28 | import javax.xml.transform.Result; 29 | 30 | /** 31 | * A DataSource implements a paging system for a RecyclerView. This one uses the DataService 32 | * to provide a paged view into the Notes API. 33 | */ 34 | public class NotesDataSource extends PageKeyedDataSource { 35 | private static final String TAG = "NotesDataSource"; 36 | private DataService dataService; 37 | 38 | NotesDataSource(DataService dataService) { 39 | this.dataService = dataService; 40 | } 41 | 42 | /** 43 | * Part of the PageKeyedDataSource - load the first page of a list. This is called when 44 | * the data source is first created or invalidated and assumes no nextToken has been 45 | * provided 46 | * @param params information about what to load 47 | * @param callback callback that receives the response 48 | */ 49 | @Override 50 | public void loadInitial(@NonNull LoadInitialParams params, @NonNull final LoadInitialCallback callback) { 51 | Log.d(TAG, String.format("loadInitial(%d)", params.requestedLoadSize)); 52 | dataService.loadNotes(params.requestedLoadSize, null, (PagedListConnectionResponse result) -> { 53 | callback.onResult(result.getItems(), null, result.getNextToken()); 54 | }); 55 | } 56 | 57 | /** 58 | * Part of the PageKeyedDataSource - load the next page of a list. This is called after 59 | * the loadInitial() has returned a response that includes a nextToken to load the next 60 | * page of items. 61 | */ 62 | @Override 63 | public void loadBefore(@NonNull LoadParams params, @NonNull final LoadCallback callback) { 64 | Log.d(TAG, String.format("loadAfter(%d, %s)", params.requestedLoadSize, params.key)); 65 | dataService.loadNotes(params.requestedLoadSize, params.key, (PagedListConnectionResponse result) -> { 66 | callback.onResult(result.getItems(), result.getNextToken()); 67 | }); 68 | } 69 | 70 | /** 71 | * Part of the PageKeyedDataSource - normally used to load the previous page, but this 72 | * version does not support paging backwards, so it becomes an invalidation. 73 | */ 74 | @Override 75 | public void loadAfter(@NonNull LoadParams params, @NonNull LoadCallback callback) { 76 | Log.d(TAG, String.format("loadBefore(%d, %s)", params.requestedLoadSize, params.key)); 77 | invalidate(); 78 | } 79 | 80 | /** 81 | * The notes repository needs to do non-paged list type operations as well. These operations 82 | * are passed through directly to the data service. However, deletions (and saves) affect 83 | * the list, so we must ensure that the list is invalidated when they succeed. This call is 84 | * to delete an item. 85 | */ 86 | public void deleteItem(String noteId, @NonNull final ResultCallback callback) { 87 | dataService.deleteNote(noteId, (Boolean result) -> { 88 | if (result) invalidate(); 89 | callback.onResult(result); 90 | }); 91 | } 92 | 93 | /** 94 | * Obtain a single item from the data service. 95 | */ 96 | public void getItem(String noteId, @NonNull ResultCallback callback) { 97 | dataService.getNote(noteId, callback); 98 | } 99 | 100 | /** 101 | * The notes repository needs to do non-paged list type operations as well. These operations 102 | * are passed through directly to the data service. However, deletions (and saves) affect 103 | * the list, so we must ensure that the list is invalidated when they succeed. This call is 104 | * to save an item. 105 | */ 106 | public void createItem(@NonNull String title, @NonNull String content, @NonNull final ResultCallback callback) { 107 | dataService.createNote(title, content, (Note result) -> { 108 | if (result != null) invalidate(); 109 | callback.onResult(result); 110 | }); 111 | } 112 | 113 | public void updateItem(@NonNull Note note, @NonNull final ResultCallback callback) { 114 | dataService.updateNote(note, (Note result) -> { 115 | if (result != null) invalidate(); 116 | callback.onResult(result); 117 | }); 118 | } 119 | } 120 | -------------------------------------------------------------------------------- /app/src/main/java/com/amazonaws/mobile/samples/mynotes/repository/NotesDataSourceFactory.java: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2018 Amazon.com, Inc. or its affiliates. All Rights Reserved. 3 | 4 | Permission is hereby granted, free of charge, to any person obtaining a copy of this 5 | software and associated documentation files (the "Software"), to deal in the Software 6 | without restriction, including without limitation the rights to use, copy, modify, 7 | merge, publish, distribute, sublicense, and/or sell copies of the Software, and to 8 | permit persons to whom the Software is furnished to do so. 9 | 10 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, 11 | INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A 12 | PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT 13 | HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 14 | OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE 15 | SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 16 | */ 17 | package com.amazonaws.mobile.samples.mynotes.repository; 18 | 19 | import android.arch.lifecycle.LiveData; 20 | import android.arch.lifecycle.MutableLiveData; 21 | import android.arch.paging.DataSource; 22 | 23 | import com.amazonaws.mobile.samples.mynotes.models.Note; 24 | import com.amazonaws.mobile.samples.mynotes.services.DataService; 25 | 26 | /** 27 | * Factory for creating data sources. When the NotesDataSource is invalidated (because 28 | * of reverse paging or because the list has been altered), we have to create a new 29 | * data source. 30 | */ 31 | public class NotesDataSourceFactory extends DataSource.Factory { 32 | private DataService dataService; 33 | private MutableLiveData mDataSource; 34 | private LiveData currentDataSource; 35 | 36 | NotesDataSourceFactory(DataService dataService) { 37 | this.dataService = dataService; 38 | mDataSource = new MutableLiveData<>(); 39 | currentDataSource = mDataSource; 40 | } 41 | 42 | public LiveData getCurrentDataSource() { 43 | return currentDataSource; 44 | } 45 | 46 | @Override 47 | public DataSource create() { 48 | NotesDataSource dataSource = new NotesDataSource(dataService); 49 | mDataSource.postValue(dataSource); 50 | return dataSource; 51 | } 52 | } 53 | -------------------------------------------------------------------------------- /app/src/main/java/com/amazonaws/mobile/samples/mynotes/repository/NotesRepository.java: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2018 Amazon.com, Inc. or its affiliates. All Rights Reserved. 3 | 4 | Permission is hereby granted, free of charge, to any person obtaining a copy of this 5 | software and associated documentation files (the "Software"), to deal in the Software 6 | without restriction, including without limitation the rights to use, copy, modify, 7 | merge, publish, distribute, sublicense, and/or sell copies of the Software, and to 8 | permit persons to whom the Software is furnished to do so. 9 | 10 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, 11 | INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A 12 | PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT 13 | HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 14 | OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE 15 | SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 16 | */ 17 | package com.amazonaws.mobile.samples.mynotes.repository; 18 | 19 | import android.arch.lifecycle.LiveData; 20 | import android.arch.paging.LivePagedListBuilder; 21 | import android.arch.paging.PagedList; 22 | 23 | import com.amazonaws.mobile.samples.mynotes.models.Note; 24 | import com.amazonaws.mobile.samples.mynotes.models.ResultCallback; 25 | import com.amazonaws.mobile.samples.mynotes.services.DataService; 26 | 27 | public class NotesRepository { 28 | private LiveData> pagedList; 29 | private LiveData dataSource; 30 | 31 | public NotesRepository(DataService dataService) { 32 | NotesDataSourceFactory factory = new NotesDataSourceFactory(dataService); 33 | dataSource = factory.getCurrentDataSource(); 34 | pagedList = new LivePagedListBuilder<>(factory, 20).build(); 35 | } 36 | 37 | /** 38 | * An observable lifecycle-aware version of the paged list of notes. This is used 39 | * to render a RecyclerView of all the notes. 40 | */ 41 | public LiveData> getPagedList() { 42 | return pagedList; 43 | } 44 | 45 | /** 46 | * API operation to create an item in the data store 47 | */ 48 | public void create(String title, String content, ResultCallback callback) { 49 | dataSource.getValue().createItem(title, content, callback); 50 | } 51 | 52 | /** 53 | * API operation to update an item in the data store 54 | */ 55 | public void update(Note note, ResultCallback callback) { 56 | dataSource.getValue().updateItem(note, callback); 57 | } 58 | 59 | /** 60 | * API operation to delete an item from the data store 61 | */ 62 | public void delete(String noteId, ResultCallback callback) { 63 | dataSource.getValue().deleteItem(noteId, callback); 64 | } 65 | 66 | /** 67 | * API operation to get an item from the data store 68 | */ 69 | public void get(String noteId, ResultCallback callback) { 70 | dataSource.getValue().getItem(noteId, callback); 71 | } 72 | } 73 | -------------------------------------------------------------------------------- /app/src/main/java/com/amazonaws/mobile/samples/mynotes/services/AnalyticsService.java: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2018 Amazon.com, Inc. or its affiliates. All Rights Reserved. 3 | 4 | Permission is hereby granted, free of charge, to any person obtaining a copy of this 5 | software and associated documentation files (the "Software"), to deal in the Software 6 | without restriction, including without limitation the rights to use, copy, modify, 7 | merge, publish, distribute, sublicense, and/or sell copies of the Software, and to 8 | permit persons to whom the Software is furnished to do so. 9 | 10 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, 11 | INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A 12 | PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT 13 | HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 14 | OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE 15 | SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 16 | */ 17 | package com.amazonaws.mobile.samples.mynotes.services; 18 | 19 | import java.util.Map; 20 | 21 | public interface AnalyticsService { 22 | /** 23 | * Records a start session event into the analytics stream 24 | */ 25 | void startSession(); 26 | 27 | /** 28 | * Records a stop session event into the analytics stream 29 | */ 30 | void stopSession(); 31 | 32 | /** 33 | * Record a custom event into the analytics stream 34 | * 35 | * @param eventName the custom event name 36 | * @param attributes a list of key-value pairs for recording string attributes 37 | * @param metrics a list of key-value pairs for recording numeric metrics 38 | */ 39 | void recordEvent(String eventName, Map attributes, Map metrics); 40 | } 41 | -------------------------------------------------------------------------------- /app/src/main/java/com/amazonaws/mobile/samples/mynotes/services/DataService.java: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2018 Amazon.com, Inc. or its affiliates. All Rights Reserved. 3 | 4 | Permission is hereby granted, free of charge, to any person obtaining a copy of this 5 | software and associated documentation files (the "Software"), to deal in the Software 6 | without restriction, including without limitation the rights to use, copy, modify, 7 | merge, publish, distribute, sublicense, and/or sell copies of the Software, and to 8 | permit persons to whom the Software is furnished to do so. 9 | 10 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, 11 | INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A 12 | PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT 13 | HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 14 | OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE 15 | SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 16 | */ 17 | package com.amazonaws.mobile.samples.mynotes.services; 18 | 19 | import com.amazonaws.mobile.samples.mynotes.models.Note; 20 | import com.amazonaws.mobile.samples.mynotes.models.PagedListConnectionResponse; 21 | import com.amazonaws.mobile.samples.mynotes.models.ResultCallback; 22 | 23 | /** 24 | * Definition of a data service. This maps to an API definition on the cloud backend. 25 | * Each call should be async and run on a background thread. 26 | */ 27 | public interface DataService { 28 | /** 29 | * Load a single page of notes. 30 | * 31 | * @param limit the requested number of items 32 | * @param after the "next token" from a prior call 33 | * @param callback the response from the server 34 | */ 35 | void loadNotes(int limit, String after, ResultCallback> callback); 36 | 37 | /** 38 | * Load a single note 39 | * 40 | * @param noteId the request ID 41 | * @param callback the response from the server 42 | */ 43 | void getNote(String noteId, ResultCallback callback); 44 | 45 | /** 46 | * Create a new note a note to the backing store 47 | * 48 | * @param title the title of the new note 49 | * @param content the content for the new note 50 | * @param callback the response from the server (null would indicate that the operation failed) 51 | */ 52 | void createNote(String title, String content, ResultCallback callback); 53 | 54 | /** 55 | * Update an existing note in the backing store 56 | * 57 | * @param note the new contents of the note 58 | * @param callback the response from the server (null would indicate that the operation failed) 59 | */ 60 | void updateNote(Note note, ResultCallback callback); 61 | 62 | /** 63 | * Delete a note from the backing store 64 | * 65 | * @param noteId the ID of the note to be deleted 66 | * @param callback the response from the server (Boolean = true indicates success) 67 | */ 68 | void deleteNote(String noteId, ResultCallback callback); 69 | 70 | } 71 | -------------------------------------------------------------------------------- /app/src/main/java/com/amazonaws/mobile/samples/mynotes/services/mock/MockAnalyticsService.java: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2018 Amazon.com, Inc. or its affiliates. All Rights Reserved. 3 | 4 | Permission is hereby granted, free of charge, to any person obtaining a copy of this 5 | software and associated documentation files (the "Software"), to deal in the Software 6 | without restriction, including without limitation the rights to use, copy, modify, 7 | merge, publish, distribute, sublicense, and/or sell copies of the Software, and to 8 | permit persons to whom the Software is furnished to do so. 9 | 10 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, 11 | INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A 12 | PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT 13 | HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 14 | OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE 15 | SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 16 | */ 17 | package com.amazonaws.mobile.samples.mynotes.services.mock; 18 | 19 | import android.util.Log; 20 | 21 | import com.amazonaws.mobile.samples.mynotes.services.AnalyticsService; 22 | 23 | import java.util.Locale; 24 | import java.util.Map; 25 | 26 | public class MockAnalyticsService implements AnalyticsService { 27 | private static final String TAG = "MockAnalyticsService"; 28 | 29 | @Override 30 | public void startSession() { 31 | Log.v(TAG, "startSession()"); 32 | } 33 | 34 | @Override 35 | public void stopSession() { 36 | Log.v(TAG, "stopSession()"); 37 | 38 | } 39 | 40 | @Override 41 | public void recordEvent(String eventName, Map attributes, Map metrics) { 42 | StringBuilder event = new StringBuilder(""); 43 | if (attributes != null) { 44 | for (Map.Entry entry : attributes.entrySet()) { 45 | event.append(String.format(Locale.US, ", %s=\"%s\"", entry.getKey(), entry.getValue())); 46 | } 47 | } 48 | if (metrics != null) { 49 | for (Map.Entry entry : metrics.entrySet()) { 50 | event.append(String.format(Locale.US, ", %s=%.2f", entry.getKey(), entry.getValue())); 51 | } 52 | } 53 | if (!event.toString().isEmpty()) { 54 | event.setCharAt(0, ':'); 55 | } 56 | Log.v(TAG, String.format(Locale.US, "recordEvent(%s)%s", eventName, event.toString())); 57 | } 58 | } 59 | -------------------------------------------------------------------------------- /app/src/main/java/com/amazonaws/mobile/samples/mynotes/services/mock/MockDataService.java: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2018 Amazon.com, Inc. or its affiliates. All Rights Reserved. 3 | 4 | Permission is hereby granted, free of charge, to any person obtaining a copy of this 5 | software and associated documentation files (the "Software"), to deal in the Software 6 | without restriction, including without limitation the rights to use, copy, modify, 7 | merge, publish, distribute, sublicense, and/or sell copies of the Software, and to 8 | permit persons to whom the Software is furnished to do so. 9 | 10 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, 11 | INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A 12 | PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT 13 | HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 14 | OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE 15 | SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 16 | */ 17 | package com.amazonaws.mobile.samples.mynotes.services.mock; 18 | 19 | import com.amazonaws.mobile.samples.mynotes.models.Note; 20 | import com.amazonaws.mobile.samples.mynotes.models.PagedListConnectionResponse; 21 | import com.amazonaws.mobile.samples.mynotes.models.ResultCallback; 22 | import com.amazonaws.mobile.samples.mynotes.services.DataService; 23 | 24 | import java.util.ArrayList; 25 | import java.util.Collections; 26 | import java.util.List; 27 | import java.util.Locale; 28 | 29 | /** 30 | * A mock data store. This will create 30 notes so you can see the scrolling action, but 31 | * otherwise acts as a data service. This should be easily rewritten to use an actual cloud API 32 | */ 33 | public class MockDataService implements DataService { 34 | private ArrayList items; 35 | 36 | public MockDataService() { 37 | items = new ArrayList<>(); 38 | for (int i = 0 ; i < 30 ; i++) { 39 | Note item = new Note(); 40 | item.setTitle(String.format(Locale.US, "Note %d", i)); 41 | item.setContent(String.format(Locale.US, "Content for note %d", i)); 42 | items.add(item); 43 | } 44 | } 45 | 46 | /** 47 | * Simulate an API call to a network service that returns paged data. 48 | * 49 | * @param limit the requested number of items 50 | * @param after the "next token" from a prior call 51 | * @param callback the response from the server 52 | */ 53 | @Override 54 | public void loadNotes(int limit, String after, ResultCallback> callback) { 55 | if (limit < 1 || limit > 100) throw new IllegalArgumentException("Limit must be between 1 and 100"); 56 | 57 | int firstItem = 0; 58 | if (after != null) { 59 | firstItem = indexOfFirst(after); 60 | if (firstItem < 0) { 61 | callback.onResult(new PagedListConnectionResponse<>(Collections.emptyList(), null)); 62 | return; 63 | } 64 | firstItem++; 65 | } 66 | if (firstItem > items.size() - 1) { 67 | callback.onResult(new PagedListConnectionResponse<>(Collections.emptyList(), null)); 68 | return; 69 | } 70 | int nItems = Math.min(limit, items.size() - firstItem); 71 | if (nItems == 0) { 72 | callback.onResult(new PagedListConnectionResponse<>(Collections.emptyList(), null)); 73 | return; 74 | } 75 | 76 | List sublist = new ArrayList<>(items.subList(firstItem, firstItem + nItems)); 77 | String nextToken = (firstItem + nItems - 1 == items.size()) ? null : sublist.get(sublist.size() - 1).getNoteId(); 78 | callback.onResult(new PagedListConnectionResponse<>(sublist, nextToken)); 79 | } 80 | 81 | /** 82 | * Load a single note from the current list of notes 83 | * 84 | * @param noteId the request ID 85 | * @param callback the response from the server 86 | */ 87 | @Override 88 | public void getNote(String noteId, ResultCallback callback) { 89 | if (noteId == null || noteId.isEmpty()) throw new IllegalArgumentException(); 90 | 91 | int idx = indexOfFirst(noteId); 92 | callback.onResult(idx >= 0 ? items.get(idx) : null); 93 | } 94 | 95 | /** 96 | * Create a new note a note to the backing store 97 | * 98 | * @param title the title of the new note 99 | * @param content the content for the new note 100 | * @param callback the response from the server (null would indicate that the operation failed) 101 | */ 102 | @Override 103 | public void createNote(String title, String content, ResultCallback callback) { 104 | Note note = new Note(); 105 | note.setTitle(title); 106 | note.setContent(content); 107 | items.add(note); 108 | callback.onResult(note); 109 | } 110 | 111 | /** 112 | * Update an existing note in the backing store 113 | * 114 | * @param note the new contents of the note 115 | * @param callback the response from the server (null would indicate that the operation failed) 116 | */ 117 | @Override 118 | public void updateNote(Note note, ResultCallback callback) { 119 | int idx = indexOfFirst(note.getNoteId()); 120 | if (idx >= 0) { 121 | items.set(idx, note); 122 | callback.onResult(note); 123 | } else { 124 | callback.onResult(null); 125 | } 126 | } 127 | 128 | /** 129 | * Delete a note from the backing store 130 | * 131 | * @param noteId the ID of the note to be deleted 132 | * @param callback the response from the server (Boolean = true indicates success) 133 | */ 134 | @Override 135 | public void deleteNote(String noteId, ResultCallback callback) { 136 | if (noteId == null || noteId.isEmpty()) throw new IllegalArgumentException(); 137 | 138 | int idx = indexOfFirst(noteId); 139 | if (idx >= 0) items.remove(idx); 140 | callback.onResult(idx >= 0); 141 | } 142 | 143 | /** 144 | * Returns the index of the first note that matches 145 | * @param noteId the note to match 146 | * @return the index of the note, or -1 if not found 147 | */ 148 | private int indexOfFirst(String noteId) { 149 | if (items.isEmpty()) throw new IndexOutOfBoundsException(); 150 | for (int i = 0 ; i < items.size() ; i++) { 151 | if (items.get(i).getNoteId().equals(noteId)) 152 | return i; 153 | } 154 | return -1; 155 | } 156 | } 157 | -------------------------------------------------------------------------------- /app/src/main/java/com/amazonaws/mobile/samples/mynotes/ui/NoteDetailActivity.java: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2018 Amazon.com, Inc. or its affiliates. All Rights Reserved. 3 | 4 | Permission is hereby granted, free of charge, to any person obtaining a copy of this 5 | software and associated documentation files (the "Software"), to deal in the Software 6 | without restriction, including without limitation the rights to use, copy, modify, 7 | merge, publish, distribute, sublicense, and/or sell copies of the Software, and to 8 | permit persons to whom the Software is furnished to do so. 9 | 10 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, 11 | INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A 12 | PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT 13 | HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 14 | OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE 15 | SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 16 | */ 17 | package com.amazonaws.mobile.samples.mynotes.ui; 18 | 19 | import android.content.Intent; 20 | import android.os.Bundle; 21 | import android.support.v7.app.AppCompatActivity; 22 | import android.support.v7.widget.Toolbar; 23 | import android.view.MenuItem; 24 | 25 | import com.amazonaws.mobile.samples.mynotes.Injection; 26 | import com.amazonaws.mobile.samples.mynotes.NotesApp; 27 | import com.amazonaws.mobile.samples.mynotes.R; 28 | import com.amazonaws.mobile.samples.mynotes.services.AnalyticsService; 29 | 30 | public class NoteDetailActivity extends AppCompatActivity { 31 | /** 32 | * Injection of the Analytics Service 33 | */ 34 | private AnalyticsService analyticsService = Injection.getAnalyticsService(); 35 | 36 | @Override 37 | public void onCreate(Bundle savedInstanceState) { 38 | super.onCreate(savedInstanceState); 39 | setContentView(R.layout.activity_note_detail); 40 | 41 | // Set up the action bar so that it has a back button 42 | Toolbar detail_toolbar = findViewById(R.id.detail_toolbar); 43 | setSupportActionBar(detail_toolbar); 44 | getSupportActionBar().setDisplayHomeAsUpEnabled(true); 45 | 46 | // Load the fragment 47 | NoteDetailFragment fragment = new NoteDetailFragment(); 48 | Bundle arguments = new Bundle(); 49 | arguments.putString(NotesApp.ITEM_ID, getIntent().getStringExtra(NotesApp.ITEM_ID)); 50 | fragment.setArguments(arguments); 51 | 52 | // Add the fragment to the UI 53 | getSupportFragmentManager() 54 | .beginTransaction() 55 | .add(R.id.note_detail_container, fragment) 56 | .commit(); 57 | } 58 | 59 | @Override 60 | public void onResume() { 61 | super.onResume(); 62 | analyticsService.recordEvent("NoteDetailActivity", null, null); 63 | } 64 | 65 | @Override 66 | public boolean onOptionsItemSelected(MenuItem item) { 67 | switch (item.getItemId()) { 68 | case android.R.id.home: 69 | Intent intent = new Intent(this, NoteListActivity.class); 70 | navigateUpTo(intent); 71 | return true; 72 | default: 73 | return super.onOptionsItemSelected(item); 74 | } 75 | } 76 | } 77 | -------------------------------------------------------------------------------- /app/src/main/java/com/amazonaws/mobile/samples/mynotes/ui/NoteDetailFragment.java: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2018 Amazon.com, Inc. or its affiliates. All Rights Reserved. 3 | 4 | Permission is hereby granted, free of charge, to any person obtaining a copy of this 5 | software and associated documentation files (the "Software"), to deal in the Software 6 | without restriction, including without limitation the rights to use, copy, modify, 7 | merge, publish, distribute, sublicense, and/or sell copies of the Software, and to 8 | permit persons to whom the Software is furnished to do so. 9 | 10 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, 11 | INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A 12 | PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT 13 | HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 14 | OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE 15 | SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 16 | */ 17 | package com.amazonaws.mobile.samples.mynotes.ui; 18 | 19 | import android.arch.lifecycle.ViewModelProviders; 20 | import android.os.Bundle; 21 | import android.support.annotation.NonNull; 22 | import android.support.v4.app.Fragment; 23 | import android.text.Editable; 24 | import android.text.TextWatcher; 25 | import android.view.LayoutInflater; 26 | import android.view.View; 27 | import android.view.ViewGroup; 28 | import android.widget.EditText; 29 | 30 | import com.amazonaws.mobile.samples.mynotes.NotesApp; 31 | import com.amazonaws.mobile.samples.mynotes.R; 32 | import com.amazonaws.mobile.samples.mynotes.models.Note; 33 | import com.amazonaws.mobile.samples.mynotes.viewmodels.NoteDetailViewModel; 34 | 35 | public class NoteDetailFragment extends Fragment { 36 | NoteDetailViewModel viewModel; 37 | String noteId; 38 | 39 | @Override 40 | public void onCreate(Bundle savedInstanceState) { 41 | super.onCreate(savedInstanceState); 42 | 43 | Bundle arguments = getArguments(); 44 | if (arguments != null) { 45 | String noteId = arguments.getString(NotesApp.ITEM_ID); 46 | this.noteId = (noteId.equals("new")) ? null : noteId; 47 | } 48 | } 49 | 50 | @Override 51 | public View onCreateView(@NonNull LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { 52 | View view = inflater.inflate(R.layout.note_detail, container, false); 53 | 54 | final EditText titleField = view.findViewById(R.id.edit_title); 55 | titleField.setEnabled(false); // Disable the field by default 56 | 57 | final EditText contentField = view.findViewById(R.id.edit_content); 58 | contentField.setEnabled(false); 59 | 60 | viewModel = ViewModelProviders.of(this).get(NoteDetailViewModel.class); 61 | // Observe the view model values. Once we receive the value, enable the field. 62 | viewModel.getTitle().observe(this, (String title) -> { 63 | titleField.setText(title); 64 | titleField.setEnabled(true); 65 | }); 66 | viewModel.getContent().observe(this, (String content) -> { 67 | contentField.setText(content); 68 | contentField.setEnabled(true); 69 | }); 70 | 71 | // If this is a new note, create the note, then enable the fields. Otherwise just load the fields 72 | // - the fields are received via observables 73 | if (noteId == null) { 74 | viewModel.create("", "", (Note result) -> { 75 | titleField.setEnabled(true); 76 | contentField.setEnabled(true); 77 | }); 78 | } else { 79 | viewModel.setNoteId(noteId); 80 | } 81 | 82 | TextWatcher saveHandler = new TextWatcher() { 83 | @Override public void beforeTextChanged(CharSequence s, int start, int count, int after) { } 84 | @Override public void onTextChanged(CharSequence s, int start, int before, int count) { } 85 | @Override public void afterTextChanged(Editable s) { 86 | String title = titleField.getText().toString(); 87 | String content = contentField.getText().toString(); 88 | viewModel.update(title, content); 89 | } 90 | }; 91 | 92 | titleField.addTextChangedListener(saveHandler); 93 | contentField.addTextChangedListener(saveHandler); 94 | 95 | return view; 96 | } 97 | } 98 | -------------------------------------------------------------------------------- /app/src/main/java/com/amazonaws/mobile/samples/mynotes/ui/NoteListActivity.java: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2018 Amazon.com, Inc. or its affiliates. All Rights Reserved. 3 | 4 | Permission is hereby granted, free of charge, to any person obtaining a copy of this 5 | software and associated documentation files (the "Software"), to deal in the Software 6 | without restriction, including without limitation the rights to use, copy, modify, 7 | merge, publish, distribute, sublicense, and/or sell copies of the Software, and to 8 | permit persons to whom the Software is furnished to do so. 9 | 10 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, 11 | INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A 12 | PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT 13 | HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 14 | OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE 15 | SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 16 | */ 17 | package com.amazonaws.mobile.samples.mynotes.ui; 18 | 19 | import android.arch.lifecycle.ViewModelProviders; 20 | import android.content.Intent; 21 | import android.os.Bundle; 22 | import android.support.design.widget.FloatingActionButton; 23 | import android.support.v4.app.Fragment; 24 | import android.support.v7.app.AppCompatActivity; 25 | import android.support.v7.widget.RecyclerView; 26 | import android.support.v7.widget.Toolbar; 27 | import android.support.v7.widget.helper.ItemTouchHelper; 28 | import android.view.View; 29 | 30 | import com.amazonaws.mobile.samples.mynotes.Injection; 31 | import com.amazonaws.mobile.samples.mynotes.NotesApp; 32 | import com.amazonaws.mobile.samples.mynotes.R; 33 | import com.amazonaws.mobile.samples.mynotes.models.Note; 34 | import com.amazonaws.mobile.samples.mynotes.services.AnalyticsService; 35 | import com.amazonaws.mobile.samples.mynotes.viewmodels.NoteListViewModel; 36 | 37 | import java.util.HashMap; 38 | 39 | public class NoteListActivity extends AppCompatActivity { 40 | /** 41 | * If the device is running in two-pane mode, then this is set to true. In two-pane mode, 42 | * the UI is a side-by-side, with the list on the left and the details on the right. In one 43 | * pane mode, the list and details are separate pages. 44 | */ 45 | private boolean twoPane = false; 46 | 47 | /** 48 | * The view model 49 | */ 50 | private NoteListViewModel viewModel; 51 | 52 | /** 53 | * The analytics service 54 | */ 55 | private AnalyticsService analyticsService = Injection.getAnalyticsService(); 56 | 57 | @Override 58 | public void onCreate(Bundle savedInstanceState) { 59 | super.onCreate(savedInstanceState); 60 | 61 | viewModel = ViewModelProviders.of(this).get(NoteListViewModel.class); 62 | setContentView(R.layout.activity_note_list); 63 | if (findViewById(R.id.note_detail_container) != null) twoPane = true; 64 | 65 | // Configure the action bar 66 | Toolbar toolbar = findViewById(R.id.toolbar); 67 | toolbar.setTitle(getTitle()); 68 | 69 | // Add an item click handler to the floating action button for adding a note 70 | FloatingActionButton fab = findViewById(R.id.fab); 71 | fab.setOnClickListener((View v) -> loadNoteDetailFragment("new")); 72 | 73 | // Create the adapter that will be used to load items into the recycler view 74 | final NoteListAdapter adapter = new NoteListAdapter((Note item) -> loadNoteDetailFragment(item.getNoteId())); 75 | 76 | // Create the swipe-to-delete handler 77 | SwipeToDelete swipeHandler = new SwipeToDelete(this, (Note item) -> viewModel.removeNote(item.getNoteId())); 78 | ItemTouchHelper swipeToDelete = new ItemTouchHelper(swipeHandler); 79 | 80 | // Configure the note list 81 | RecyclerView note_list = findViewById(R.id.note_list); 82 | swipeToDelete.attachToRecyclerView(note_list); 83 | note_list.setAdapter(adapter); 84 | 85 | // Ensure the note list is updated whenever the repository is updated 86 | viewModel.getNotesList().observe(this, adapter::submitList); 87 | } 88 | 89 | @Override 90 | public void onResume() { 91 | super.onResume(); 92 | HashMap attributes = new HashMap<>(); 93 | attributes.put("twoPane", twoPane ? "true" : "false"); 94 | analyticsService.recordEvent("NoteListActivity", attributes, null); 95 | } 96 | 97 | /** 98 | * Loads the note details the right way, depending on if this is two-pane mode. 99 | * 100 | * @param noteId the ID of the note to load 101 | */ 102 | private void loadNoteDetailFragment(String noteId) { 103 | if (twoPane) { 104 | Fragment fragment = new NoteDetailFragment(); 105 | Bundle arguments = new Bundle(); 106 | arguments.putString(NotesApp.ITEM_ID, noteId); 107 | fragment.setArguments(arguments); 108 | getSupportFragmentManager() 109 | .beginTransaction() 110 | .replace(R.id.note_detail_container, fragment) 111 | .commit(); 112 | } else { 113 | Intent intent = new Intent(this, NoteDetailActivity.class); 114 | intent.putExtra(NotesApp.ITEM_ID, noteId); 115 | startActivity(intent); 116 | } 117 | } 118 | } 119 | -------------------------------------------------------------------------------- /app/src/main/java/com/amazonaws/mobile/samples/mynotes/ui/NoteListAdapter.java: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2018 Amazon.com, Inc. or its affiliates. All Rights Reserved. 3 | 4 | Permission is hereby granted, free of charge, to any person obtaining a copy of this 5 | software and associated documentation files (the "Software"), to deal in the Software 6 | without restriction, including without limitation the rights to use, copy, modify, 7 | merge, publish, distribute, sublicense, and/or sell copies of the Software, and to 8 | permit persons to whom the Software is furnished to do so. 9 | 10 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, 11 | INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A 12 | PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT 13 | HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 14 | OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE 15 | SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 16 | */ 17 | package com.amazonaws.mobile.samples.mynotes.ui; 18 | 19 | import android.arch.paging.PagedListAdapter; 20 | import android.support.annotation.NonNull; 21 | import android.support.v7.util.DiffUtil; 22 | import android.view.LayoutInflater; 23 | import android.view.View; 24 | import android.view.ViewGroup; 25 | 26 | import com.amazonaws.mobile.samples.mynotes.R; 27 | import com.amazonaws.mobile.samples.mynotes.models.Note; 28 | import com.amazonaws.mobile.samples.mynotes.models.OnClickCallback; 29 | 30 | public class NoteListAdapter extends PagedListAdapter { 31 | private static DiffUtil.ItemCallback DIFF_CALLBACK = new DiffUtil.ItemCallback() { 32 | @Override 33 | public boolean areItemsTheSame(Note oldItem, Note newItem) { 34 | return oldItem.getNoteId().equals(newItem.getNoteId()); 35 | } 36 | 37 | @Override 38 | public boolean areContentsTheSame(Note oldItem, Note newItem) { 39 | return oldItem.getNoteId().equals(newItem.getNoteId()) && 40 | oldItem.getTitle().equals(newItem.getTitle()) && 41 | oldItem.getContent().equals(newItem.getContent()); 42 | } 43 | }; 44 | 45 | private OnClickCallback callback; 46 | 47 | public NoteListAdapter(OnClickCallback callback) { 48 | super(DIFF_CALLBACK); 49 | this.callback = callback; 50 | } 51 | 52 | @NonNull 53 | @Override 54 | public NoteListViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) { 55 | LayoutInflater layoutInflater = LayoutInflater.from(parent.getContext()); 56 | View view = layoutInflater.inflate(R.layout.note_list_content, parent, false); 57 | return new NoteListViewHolder(view); 58 | } 59 | 60 | @Override 61 | public void onBindViewHolder(@NonNull final NoteListViewHolder holder, int position) { 62 | holder.setNote(getItem(position)); 63 | holder.itemView.setOnClickListener(new View.OnClickListener() { 64 | @Override 65 | public void onClick(View v) { 66 | callback.onClick(holder.getNote()); 67 | } 68 | }); 69 | } 70 | } 71 | -------------------------------------------------------------------------------- /app/src/main/java/com/amazonaws/mobile/samples/mynotes/ui/NoteListViewHolder.java: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2018 Amazon.com, Inc. or its affiliates. All Rights Reserved. 3 | 4 | Permission is hereby granted, free of charge, to any person obtaining a copy of this 5 | software and associated documentation files (the "Software"), to deal in the Software 6 | without restriction, including without limitation the rights to use, copy, modify, 7 | merge, publish, distribute, sublicense, and/or sell copies of the Software, and to 8 | permit persons to whom the Software is furnished to do so. 9 | 10 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, 11 | INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A 12 | PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT 13 | HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 14 | OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE 15 | SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 16 | */ 17 | package com.amazonaws.mobile.samples.mynotes.ui; 18 | 19 | import android.support.v7.widget.RecyclerView; 20 | import android.view.View; 21 | import android.widget.TextView; 22 | 23 | import com.amazonaws.mobile.samples.mynotes.R; 24 | import com.amazonaws.mobile.samples.mynotes.models.Note; 25 | 26 | public class NoteListViewHolder extends RecyclerView.ViewHolder { 27 | private TextView titleField; 28 | private TextView idField; 29 | private Note note; 30 | 31 | public NoteListViewHolder(View view) { 32 | super(view); 33 | 34 | titleField = view.findViewById(R.id.list_title); 35 | idField = view.findViewById(R.id.list_id); 36 | } 37 | 38 | public Note getNote() { 39 | return note; 40 | } 41 | 42 | public void setNote(Note note) { 43 | this.note = note; 44 | String title = note.getTitle(); 45 | titleField.setText(title == null ? "null" : title); 46 | idField.setText(note.getNoteId()); 47 | } 48 | } 49 | -------------------------------------------------------------------------------- /app/src/main/java/com/amazonaws/mobile/samples/mynotes/ui/SwipeToDelete.java: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2018 Amazon.com, Inc. or its affiliates. All Rights Reserved. 3 | 4 | Permission is hereby granted, free of charge, to any person obtaining a copy of this 5 | software and associated documentation files (the "Software"), to deal in the Software 6 | without restriction, including without limitation the rights to use, copy, modify, 7 | merge, publish, distribute, sublicense, and/or sell copies of the Software, and to 8 | permit persons to whom the Software is furnished to do so. 9 | 10 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, 11 | INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A 12 | PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT 13 | HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 14 | OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE 15 | SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 16 | */ 17 | package com.amazonaws.mobile.samples.mynotes.ui; 18 | 19 | import android.content.Context; 20 | import android.graphics.Canvas; 21 | import android.graphics.Color; 22 | import android.graphics.PorterDuff; 23 | import android.graphics.drawable.ColorDrawable; 24 | import android.graphics.drawable.Drawable; 25 | import android.support.v4.content.ContextCompat; 26 | import android.support.v7.widget.RecyclerView; 27 | import android.support.v7.widget.helper.ItemTouchHelper; 28 | import com.amazonaws.mobile.samples.mynotes.R; 29 | import com.amazonaws.mobile.samples.mynotes.models.RemoveCallback; 30 | 31 | public class SwipeToDelete extends ItemTouchHelper.SimpleCallback { 32 | private RemoveCallback callback; 33 | private Drawable background, xMark; 34 | private int xMarkMargin; 35 | 36 | SwipeToDelete(Context context, RemoveCallback callback) { 37 | super(0, ItemTouchHelper.LEFT); 38 | 39 | this.callback = callback; 40 | this.background = new ColorDrawable(Color.RED); 41 | this.xMark = ContextCompat.getDrawable(context, R.drawable.ic_clear_24dp); 42 | this.xMark.setColorFilter(Color.WHITE, PorterDuff.Mode.SRC_ATOP); 43 | this.xMarkMargin = (int) context.getResources().getDimension(R.dimen.ic_clear_margin); 44 | } 45 | 46 | @Override 47 | public boolean onMove(RecyclerView recyclerView, RecyclerView.ViewHolder viewHolder, RecyclerView.ViewHolder target) { 48 | return false; 49 | } 50 | 51 | @Override 52 | public void onSwiped(RecyclerView.ViewHolder viewHolder, int direction) { 53 | callback.onRemove(((NoteListViewHolder) viewHolder).getNote()); 54 | } 55 | 56 | @Override 57 | public void onChildDraw(Canvas c, RecyclerView recyclerView, RecyclerView.ViewHolder viewHolder, float dX, float dY, int actionState, boolean isCurrentlyActive) { 58 | if (viewHolder != null) { 59 | // If the item has already been swiped away,ignore it 60 | if (viewHolder.getAdapterPosition() == -1) return; 61 | 62 | int vr = viewHolder.itemView.getRight(); 63 | int vt = viewHolder.itemView.getTop(); 64 | int vb = viewHolder.itemView.getBottom(); 65 | int vh = vb - vt; 66 | int iw = xMark.getIntrinsicWidth(); 67 | int ih = xMark.getIntrinsicHeight(); 68 | background.setBounds(vr + (int)dX, vt, vr, vb); 69 | background.draw(c); 70 | 71 | int xml = vr - xMarkMargin - iw; 72 | int xmr = vr - xMarkMargin; 73 | int xmt = vt + (vh - ih) / 2; 74 | int xmb = xmt + ih; 75 | xMark.setBounds(xml, xmt, xmr, xmb); 76 | xMark.draw(c); 77 | } 78 | 79 | super.onChildDraw(c, recyclerView, viewHolder, dX, dY, actionState, isCurrentlyActive); 80 | } 81 | } 82 | -------------------------------------------------------------------------------- /app/src/main/java/com/amazonaws/mobile/samples/mynotes/viewmodels/NoteDetailViewModel.java: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2018 Amazon.com, Inc. or its affiliates. All Rights Reserved. 3 | 4 | Permission is hereby granted, free of charge, to any person obtaining a copy of this 5 | software and associated documentation files (the "Software"), to deal in the Software 6 | without restriction, including without limitation the rights to use, copy, modify, 7 | merge, publish, distribute, sublicense, and/or sell copies of the Software, and to 8 | permit persons to whom the Software is furnished to do so. 9 | 10 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, 11 | INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A 12 | PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT 13 | HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 14 | OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE 15 | SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 16 | */ 17 | package com.amazonaws.mobile.samples.mynotes.viewmodels; 18 | 19 | import android.arch.lifecycle.LiveData; 20 | import android.arch.lifecycle.MutableLiveData; 21 | import android.arch.lifecycle.ViewModel; 22 | 23 | import com.amazonaws.mobile.samples.mynotes.Injection; 24 | import com.amazonaws.mobile.samples.mynotes.models.Note; 25 | import com.amazonaws.mobile.samples.mynotes.models.ResultCallback; 26 | import com.amazonaws.mobile.samples.mynotes.repository.NotesRepository; 27 | 28 | public class NoteDetailViewModel extends ViewModel { 29 | private String noteId; 30 | private MutableLiveData mTitle; 31 | private MutableLiveData mContent; 32 | private NotesRepository notesRepository; 33 | 34 | public NoteDetailViewModel() { 35 | this.notesRepository = Injection.getNotesRepository(); 36 | this.mTitle = new MutableLiveData<>(); 37 | this.mContent = new MutableLiveData<>(); 38 | } 39 | 40 | public void setNoteId(final String noteId) { 41 | this.noteId = noteId; 42 | notesRepository.get(noteId, (Note result) -> { 43 | if (result != null) 44 | mTitle.postValue(result.getTitle()); 45 | mContent.postValue(result.getContent()); 46 | this.noteId = result.getNoteId(); 47 | }); 48 | } 49 | 50 | public LiveData getTitle() { 51 | return mTitle; 52 | } 53 | 54 | public LiveData getContent() { 55 | return mContent; 56 | } 57 | 58 | public synchronized void create(String title, String content, ResultCallback callback) { 59 | notesRepository.create(title, content, (Note result) -> { 60 | if (result != null) { 61 | noteId = result.getNoteId(); 62 | callback.onResult(result); 63 | } 64 | }); 65 | } 66 | 67 | public synchronized void update(String title, String content) { 68 | Note newNote = new Note(noteId, title, content); 69 | notesRepository.update(newNote, (Note result) -> { 70 | /* Do Nothing */ 71 | }); 72 | } 73 | } 74 | -------------------------------------------------------------------------------- /app/src/main/java/com/amazonaws/mobile/samples/mynotes/viewmodels/NoteListViewModel.java: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2018 Amazon.com, Inc. or its affiliates. All Rights Reserved. 3 | 4 | Permission is hereby granted, free of charge, to any person obtaining a copy of this 5 | software and associated documentation files (the "Software"), to deal in the Software 6 | without restriction, including without limitation the rights to use, copy, modify, 7 | merge, publish, distribute, sublicense, and/or sell copies of the Software, and to 8 | permit persons to whom the Software is furnished to do so. 9 | 10 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, 11 | INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A 12 | PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT 13 | HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 14 | OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE 15 | SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 16 | */ 17 | package com.amazonaws.mobile.samples.mynotes.viewmodels; 18 | 19 | import android.arch.lifecycle.LiveData; 20 | import android.arch.lifecycle.ViewModel; 21 | import android.arch.paging.PagedList; 22 | 23 | import com.amazonaws.mobile.samples.mynotes.Injection; 24 | import com.amazonaws.mobile.samples.mynotes.models.Note; 25 | import com.amazonaws.mobile.samples.mynotes.models.ResultCallback; 26 | import com.amazonaws.mobile.samples.mynotes.repository.NotesRepository; 27 | 28 | public class NoteListViewModel extends ViewModel { 29 | private NotesRepository notesRepository; 30 | 31 | public NoteListViewModel() { 32 | this.notesRepository = Injection.getNotesRepository(); 33 | } 34 | 35 | public LiveData> getNotesList() { 36 | return notesRepository.getPagedList(); 37 | } 38 | 39 | public void removeNote(String noteId) { 40 | notesRepository.delete(noteId, new ResultCallback() { 41 | @Override 42 | public void onResult(Boolean result) { 43 | /* Do nothing */ 44 | } 45 | }); 46 | } 47 | } 48 | -------------------------------------------------------------------------------- /app/src/main/res/drawable-v24/ic_launcher_foreground.xml: -------------------------------------------------------------------------------- 1 | 7 | 12 | 13 | 19 | 22 | 25 | 26 | 27 | 28 | 34 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/ic_clear_24dp.xml: -------------------------------------------------------------------------------- 1 | 6 | 9 | 10 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/ic_launcher_background.xml: -------------------------------------------------------------------------------- 1 | 2 | 7 | 10 | 15 | 20 | 25 | 30 | 35 | 40 | 45 | 50 | 55 | 60 | 65 | 70 | 75 | 80 | 85 | 90 | 95 | 100 | 105 | 110 | 115 | 120 | 125 | 130 | 135 | 140 | 145 | 150 | 155 | 160 | 165 | 170 | -------------------------------------------------------------------------------- /app/src/main/res/layout-w900dp/note_list.xml: -------------------------------------------------------------------------------- 1 | 2 | 14 | 26 | 27 | 31 | 32 | 42 | 43 | 48 | 49 | -------------------------------------------------------------------------------- /app/src/main/res/layout/activity_note_detail.xml: -------------------------------------------------------------------------------- 1 | 2 | 18 | 26 | 27 | 33 | 34 | 42 | 43 | 49 | 50 | 51 | 52 | 53 | 54 | 59 | 60 | -------------------------------------------------------------------------------- /app/src/main/res/layout/activity_note_list.xml: -------------------------------------------------------------------------------- 1 | 2 | 18 | 25 | 26 | 31 | 32 | 37 | 38 | 39 | 40 | 45 | 46 | 47 | 48 | 49 | 57 | 58 | 59 | -------------------------------------------------------------------------------- /app/src/main/res/layout/note_detail.xml: -------------------------------------------------------------------------------- 1 | 2 | 18 | 26 | 27 | 40 | 41 | 51 | 52 | -------------------------------------------------------------------------------- /app/src/main/res/layout/note_list.xml: -------------------------------------------------------------------------------- 1 | 2 | 16 | -------------------------------------------------------------------------------- /app/src/main/res/layout/note_list_content.xml: -------------------------------------------------------------------------------- 1 | 2 | 18 | 26 | 27 | 32 | 33 | 45 | 46 | 56 | 57 | -------------------------------------------------------------------------------- /app/src/main/res/mipmap-hdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/amazon-archives/aws-mobile-android-notes-tutorial/59c5b1085949d04daa73ab630ce2bb28dbd00833/app/src/main/res/mipmap-hdpi/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-hdpi/ic_launcher_round.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/amazon-archives/aws-mobile-android-notes-tutorial/59c5b1085949d04daa73ab630ce2bb28dbd00833/app/src/main/res/mipmap-hdpi/ic_launcher_round.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-mdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/amazon-archives/aws-mobile-android-notes-tutorial/59c5b1085949d04daa73ab630ce2bb28dbd00833/app/src/main/res/mipmap-mdpi/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-mdpi/ic_launcher_round.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/amazon-archives/aws-mobile-android-notes-tutorial/59c5b1085949d04daa73ab630ce2bb28dbd00833/app/src/main/res/mipmap-mdpi/ic_launcher_round.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/amazon-archives/aws-mobile-android-notes-tutorial/59c5b1085949d04daa73ab630ce2bb28dbd00833/app/src/main/res/mipmap-xhdpi/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xhdpi/ic_launcher_round.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/amazon-archives/aws-mobile-android-notes-tutorial/59c5b1085949d04daa73ab630ce2bb28dbd00833/app/src/main/res/mipmap-xhdpi/ic_launcher_round.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/amazon-archives/aws-mobile-android-notes-tutorial/59c5b1085949d04daa73ab630ce2bb28dbd00833/app/src/main/res/mipmap-xxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/amazon-archives/aws-mobile-android-notes-tutorial/59c5b1085949d04daa73ab630ce2bb28dbd00833/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xxxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/amazon-archives/aws-mobile-android-notes-tutorial/59c5b1085949d04daa73ab630ce2bb28dbd00833/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/amazon-archives/aws-mobile-android-notes-tutorial/59c5b1085949d04daa73ab630ce2bb28dbd00833/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png -------------------------------------------------------------------------------- /app/src/main/res/values/colors.xml: -------------------------------------------------------------------------------- 1 | 2 | 16 | 17 | #3F51B5 18 | #303F9F 19 | #FF4081 20 | 21 | -------------------------------------------------------------------------------- /app/src/main/res/values/dimens.xml: -------------------------------------------------------------------------------- 1 | 2 | 16 | 17 | 16dp 18 | 200dp 19 | 200dp 20 | 16dp 21 | 16dp 22 | 23 | -------------------------------------------------------------------------------- /app/src/main/res/values/strings.xml: -------------------------------------------------------------------------------- 1 | 2 | 16 | 17 | AWSome Notes 18 | Note Detail 19 | Note Title 20 | Content 21 | 22 | 23 | 24 | 89dd210b–4493–439f–b895–cb1dd300e985 25 | Sample Title 26 | 27 | -------------------------------------------------------------------------------- /app/src/main/res/values/styles.xml: -------------------------------------------------------------------------------- 1 | 2 | 16 | 17 | 22 | 26 |