├── .gitignore ├── LICENSE ├── README.md ├── app ├── build.gradle ├── proguard-rules.pro └── src │ ├── androidTest │ └── java │ │ └── io │ │ └── github │ │ └── mthli │ │ └── type │ │ └── ApplicationTest.java │ └── main │ ├── AndroidManifest.xml │ ├── java │ └── io │ │ └── github │ │ └── mthli │ │ └── type │ │ ├── app │ │ ├── LinkActivity.java │ │ ├── MainActivity.java │ │ └── SettingsActivity.java │ │ ├── event │ │ ├── BlockEvent.java │ │ ├── BoldEvent.java │ │ ├── BulletEvent.java │ │ ├── DeleteEvent.java │ │ ├── DotsEvent.java │ │ ├── FormatEvent.java │ │ ├── ImageEvent.java │ │ ├── InsertEvent.java │ │ ├── ItalicEvent.java │ │ ├── LinkEvent.java │ │ ├── QuoteEvent.java │ │ ├── StrikethroughEvent.java │ │ └── UnderlineEvent.java │ │ ├── util │ │ ├── DisplayUtils.java │ │ ├── ImageUtils.java │ │ ├── RxBus.java │ │ └── SharedPreferenceUtils.java │ │ └── widget │ │ ├── DotsView.java │ │ ├── StatusImageButton.java │ │ ├── adapter │ │ └── TypeAdapter.java │ │ ├── holder │ │ ├── TypeBlockHolder.java │ │ ├── TypeDotsHolder.java │ │ ├── TypeImageHolder.java │ │ └── TypeTitleHolder.java │ │ ├── model │ │ ├── Type.java │ │ ├── TypeBlock.java │ │ ├── TypeDots.java │ │ ├── TypeImage.java │ │ └── TypeTitle.java │ │ └── text │ │ ├── KnifePart.java │ │ └── KnifeText.java │ └── res │ ├── drawable-hdpi │ ├── ic_attachment.png │ ├── ic_bold_activated.png │ ├── ic_bold_default.png │ ├── ic_bullet_activated.png │ ├── ic_bullet_default.png │ ├── ic_dots.png │ ├── ic_italic_activated.png │ ├── ic_italic_default.png │ ├── ic_link_activated.png │ ├── ic_link_default.png │ ├── ic_play.png │ ├── ic_quote_activated.png │ ├── ic_quote_default.png │ ├── ic_strikethrough_activated.png │ ├── ic_strikethrough_default.png │ ├── ic_underline_activated.png │ └── ic_underline_default.png │ ├── drawable-mdpi │ ├── ic_attachment.png │ ├── ic_bold_activated.png │ ├── ic_bold_default.png │ ├── ic_bullet_activated.png │ ├── ic_bullet_default.png │ ├── ic_dots.png │ ├── ic_italic_activated.png │ ├── ic_italic_default.png │ ├── ic_link_activated.png │ ├── ic_link_default.png │ ├── ic_play.png │ ├── ic_quote_activated.png │ ├── ic_quote_default.png │ ├── ic_strikethrough_activated.png │ ├── ic_strikethrough_default.png │ ├── ic_underline_activated.png │ └── ic_underline_default.png │ ├── drawable-xhdpi │ ├── ic_attachment.png │ ├── ic_bold_activated.png │ ├── ic_bold_default.png │ ├── ic_bullet_activated.png │ ├── ic_bullet_default.png │ ├── ic_dots.png │ ├── ic_italic_activated.png │ ├── ic_italic_default.png │ ├── ic_link_activated.png │ ├── ic_link_default.png │ ├── ic_play.png │ ├── ic_quote_activated.png │ ├── ic_quote_default.png │ ├── ic_strikethrough_activated.png │ ├── ic_strikethrough_default.png │ ├── ic_underline_activated.png │ └── ic_underline_default.png │ ├── drawable-xxhdpi │ ├── ic_attachment.png │ ├── ic_bold_activated.png │ ├── ic_bold_default.png │ ├── ic_bullet_activated.png │ ├── ic_bullet_default.png │ ├── ic_dots.png │ ├── ic_italic_activated.png │ ├── ic_italic_default.png │ ├── ic_link_activated.png │ ├── ic_link_default.png │ ├── ic_play.png │ ├── ic_quote_activated.png │ ├── ic_quote_default.png │ ├── ic_strikethrough_activated.png │ ├── ic_strikethrough_default.png │ ├── ic_underline_activated.png │ └── ic_underline_default.png │ ├── drawable-xxxhdpi │ ├── ic_attachment.png │ ├── ic_bold_activated.png │ ├── ic_bold_default.png │ ├── ic_bullet_activated.png │ ├── ic_bullet_default.png │ ├── ic_dots.png │ ├── ic_italic_activated.png │ ├── ic_italic_default.png │ ├── ic_link_activated.png │ ├── ic_link_default.png │ ├── ic_play.png │ ├── ic_quote_activated.png │ ├── ic_quote_default.png │ ├── ic_strikethrough_activated.png │ ├── ic_strikethrough_default.png │ ├── ic_underline_activated.png │ └── ic_underline_default.png │ ├── drawable │ └── shape_bullet.xml │ ├── layout │ ├── activity_main.xml │ ├── recycler_item_block.xml │ ├── recycler_item_dots.xml │ ├── recycler_item_image.xml │ └── recycler_item_title.xml │ ├── mipmap-hdpi │ └── ic_launcher.png │ ├── mipmap-mdpi │ └── ic_launcher.png │ ├── mipmap-xhdpi │ └── ic_launcher.png │ ├── mipmap-xxhdpi │ └── ic_launcher.png │ ├── mipmap-xxxhdpi │ └── ic_launcher.png │ └── values │ ├── attrs.xml │ ├── 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 /.gitignore: -------------------------------------------------------------------------------- 1 | # Built application files 2 | *.apk 3 | *.ap_ 4 | 5 | # Files for the Dalvik VM 6 | *.dex 7 | 8 | # Java class files 9 | *.class 10 | 11 | # Generated files 12 | bin/ 13 | gen/ 14 | 15 | # Gradle files 16 | .gradle/ 17 | build/ 18 | 19 | # Local configuration file (sdk path, etc) 20 | local.properties 21 | 22 | # Proguard folder generated by Eclipse 23 | proguard/ 24 | 25 | # Log Files 26 | *.log 27 | 28 | # Android Studio Navigation editor temp files 29 | .navigation/ 30 | 31 | # Android Studio captures folder 32 | captures/ 33 | 34 | # Others 35 | .idea/ 36 | *.directory 37 | *.iml 38 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Apache License 2 | Version 2.0, January 2004 3 | http://www.apache.org/licenses/ 4 | 5 | TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 6 | 7 | 1. Definitions. 8 | 9 | "License" shall mean the terms and conditions for use, reproduction, 10 | and distribution as defined by Sections 1 through 9 of this document. 11 | 12 | "Licensor" shall mean the copyright owner or entity authorized by 13 | the copyright owner that is granting the License. 14 | 15 | "Legal Entity" shall mean the union of the acting entity and all 16 | other entities that control, are controlled by, or are under common 17 | control with that entity. For the purposes of this definition, 18 | "control" means (i) the power, direct or indirect, to cause the 19 | direction or management of such entity, whether by contract or 20 | otherwise, or (ii) ownership of fifty percent (50%) or more of the 21 | outstanding shares, or (iii) beneficial ownership of such entity. 22 | 23 | "You" (or "Your") shall mean an individual or Legal Entity 24 | exercising permissions granted by this License. 25 | 26 | "Source" form shall mean the preferred form for making modifications, 27 | including but not limited to software source code, documentation 28 | source, and configuration files. 29 | 30 | "Object" form shall mean any form resulting from mechanical 31 | transformation or translation of a Source form, including but 32 | not limited to compiled object code, generated documentation, 33 | and conversions to other media types. 34 | 35 | "Work" shall mean the work of authorship, whether in Source or 36 | Object form, made available under the License, as indicated by a 37 | copyright notice that is included in or attached to the work 38 | (an example is provided in the Appendix below). 39 | 40 | "Derivative Works" shall mean any work, whether in Source or Object 41 | form, that is based on (or derived from) the Work and for which the 42 | editorial revisions, annotations, elaborations, or other modifications 43 | represent, as a whole, an original work of authorship. For the purposes 44 | of this License, Derivative Works shall not include works that remain 45 | separable from, or merely link (or bind by name) to the interfaces of, 46 | the Work and Derivative Works thereof. 47 | 48 | "Contribution" shall mean any work of authorship, including 49 | the original version of the Work and any modifications or additions 50 | to that Work or Derivative Works thereof, that is intentionally 51 | submitted to Licensor for inclusion in the Work by the copyright owner 52 | or by an individual or Legal Entity authorized to submit on behalf of 53 | the copyright owner. For the purposes of this definition, "submitted" 54 | means any form of electronic, verbal, or written communication sent 55 | to the Licensor or its representatives, including but not limited to 56 | communication on electronic mailing lists, source code control systems, 57 | and issue tracking systems that are managed by, or on behalf of, the 58 | Licensor for the purpose of discussing and improving the Work, but 59 | excluding communication that is conspicuously marked or otherwise 60 | designated in writing by the copyright owner as "Not a Contribution." 61 | 62 | "Contributor" shall mean Licensor and any individual or Legal Entity 63 | on behalf of whom a Contribution has been received by Licensor and 64 | subsequently incorporated within the Work. 65 | 66 | 2. Grant of Copyright License. Subject to the terms and conditions of 67 | this License, each Contributor hereby grants to You a perpetual, 68 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 69 | copyright license to reproduce, prepare Derivative Works of, 70 | publicly display, publicly perform, sublicense, and distribute the 71 | Work and such Derivative Works in Source or Object form. 72 | 73 | 3. Grant of Patent License. Subject to the terms and conditions of 74 | this License, each Contributor hereby grants to You a perpetual, 75 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 76 | (except as stated in this section) patent license to make, have made, 77 | use, offer to sell, sell, import, and otherwise transfer the Work, 78 | where such license applies only to those patent claims licensable 79 | by such Contributor that are necessarily infringed by their 80 | Contribution(s) alone or by combination of their Contribution(s) 81 | with the Work to which such Contribution(s) was submitted. If You 82 | institute patent litigation against any entity (including a 83 | cross-claim or counterclaim in a lawsuit) alleging that the Work 84 | or a Contribution incorporated within the Work constitutes direct 85 | or contributory patent infringement, then any patent licenses 86 | granted to You under this License for that Work shall terminate 87 | as of the date such litigation is filed. 88 | 89 | 4. Redistribution. You may reproduce and distribute copies of the 90 | Work or Derivative Works thereof in any medium, with or without 91 | modifications, and in Source or Object form, provided that You 92 | meet the following conditions: 93 | 94 | (a) You must give any other recipients of the Work or 95 | Derivative Works a copy of this License; and 96 | 97 | (b) You must cause any modified files to carry prominent notices 98 | stating that You changed the files; and 99 | 100 | (c) You must retain, in the Source form of any Derivative Works 101 | that You distribute, all copyright, patent, trademark, and 102 | attribution notices from the Source form of the Work, 103 | excluding those notices that do not pertain to any part of 104 | the Derivative Works; and 105 | 106 | (d) If the Work includes a "NOTICE" text file as part of its 107 | distribution, then any Derivative Works that You distribute must 108 | include a readable copy of the attribution notices contained 109 | within such NOTICE file, excluding those notices that do not 110 | pertain to any part of the Derivative Works, in at least one 111 | of the following places: within a NOTICE text file distributed 112 | as part of the Derivative Works; within the Source form or 113 | documentation, if provided along with the Derivative Works; or, 114 | within a display generated by the Derivative Works, if and 115 | wherever such third-party notices normally appear. The contents 116 | of the NOTICE file are for informational purposes only and 117 | do not modify the License. You may add Your own attribution 118 | notices within Derivative Works that You distribute, alongside 119 | or as an addendum to the NOTICE text from the Work, provided 120 | that such additional attribution notices cannot be construed 121 | as modifying the License. 122 | 123 | You may add Your own copyright statement to Your modifications and 124 | may provide additional or different license terms and conditions 125 | for use, reproduction, or distribution of Your modifications, or 126 | for any such Derivative Works as a whole, provided Your use, 127 | reproduction, and distribution of the Work otherwise complies with 128 | the conditions stated in this License. 129 | 130 | 5. Submission of Contributions. Unless You explicitly state otherwise, 131 | any Contribution intentionally submitted for inclusion in the Work 132 | by You to the Licensor shall be under the terms and conditions of 133 | this License, without any additional terms or conditions. 134 | Notwithstanding the above, nothing herein shall supersede or modify 135 | the terms of any separate license agreement you may have executed 136 | with Licensor regarding such Contributions. 137 | 138 | 6. Trademarks. This License does not grant permission to use the trade 139 | names, trademarks, service marks, or product names of the Licensor, 140 | except as required for reasonable and customary use in describing the 141 | origin of the Work and reproducing the content of the NOTICE file. 142 | 143 | 7. Disclaimer of Warranty. Unless required by applicable law or 144 | agreed to in writing, Licensor provides the Work (and each 145 | Contributor provides its Contributions) on an "AS IS" BASIS, 146 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 147 | implied, including, without limitation, any warranties or conditions 148 | of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A 149 | PARTICULAR PURPOSE. You are solely responsible for determining the 150 | appropriateness of using or redistributing the Work and assume any 151 | risks associated with Your exercise of permissions under this License. 152 | 153 | 8. Limitation of Liability. In no event and under no legal theory, 154 | whether in tort (including negligence), contract, or otherwise, 155 | unless required by applicable law (such as deliberate and grossly 156 | negligent acts) or agreed to in writing, shall any Contributor be 157 | liable to You for damages, including any direct, indirect, special, 158 | incidental, or consequential damages of any character arising as a 159 | result of this License or out of the use or inability to use the 160 | Work (including but not limited to damages for loss of goodwill, 161 | work stoppage, computer failure or malfunction, or any and all 162 | other commercial damages or losses), even if such Contributor 163 | has been advised of the possibility of such damages. 164 | 165 | 9. Accepting Warranty or Additional Liability. While redistributing 166 | the Work or Derivative Works thereof, You may choose to offer, 167 | and charge a fee for, acceptance of support, warranty, indemnity, 168 | or other liability obligations and/or rights consistent with this 169 | License. However, in accepting such obligations, You may act only 170 | on Your own behalf and on Your sole responsibility, not on behalf 171 | of any other Contributor, and only if You agree to indemnify, 172 | defend, and hold each Contributor harmless for any liability 173 | incurred by, or claims asserted against, such Contributor by reason 174 | of your accepting any such warranty or additional liability. 175 | 176 | END OF TERMS AND CONDITIONS 177 | 178 | APPENDIX: How to apply the Apache License to your work. 179 | 180 | To apply the Apache License to your work, attach the following 181 | boilerplate notice, with the fields enclosed by brackets "{}" 182 | replaced with your own identifying information. (Don't include 183 | the brackets!) The text should be enclosed in the appropriate 184 | comment syntax for the file format. We also recommend that a 185 | file or class name and description of purpose be included on the 186 | same "printed page" as the copyright notice for easier 187 | identification within third-party archives. 188 | 189 | Copyright 2016 Matthew Lee 190 | 191 | Licensed under the Apache License, Version 2.0 (the "License"); 192 | you may not use this file except in compliance with the License. 193 | You may obtain a copy of the License at 194 | 195 | http://www.apache.org/licenses/LICENSE-2.0 196 | 197 | Unless required by applicable law or agreed to in writing, software 198 | distributed under the License is distributed on an "AS IS" BASIS, 199 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 200 | See the License for the specific language governing permissions and 201 | limitations under the License. 202 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | Type 2 | ==== 3 | 4 | Typing experiment on Android. 5 | 6 | Support Android 5.0+. 7 | 8 | **UNDER DEVELOPMENT**. 9 | 10 | ## License 11 | 12 | Copyright (C) 2016 Matthew Lee 13 | 14 | Licensed under the Apache License, Version 2.0 (the "License"); 15 | you may not use this file except in compliance with the License. 16 | You may obtain a copy of the License at 17 | 18 | http://www.apache.org/licenses/LICENSE-2.0 19 | 20 | Unless required by applicable law or agreed to in writing, software 21 | distributed under the License is distributed on an "AS IS" BASIS, 22 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 23 | See the License for the specific language governing permissions and 24 | limitations under the License. 25 | -------------------------------------------------------------------------------- /app/build.gradle: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016 Matthew Lee 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except 5 | * in compliance with the License. You may obtain a copy of the License at 6 | * 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software distributed under the License 10 | * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 11 | * or implied. See the License for the specific language governing permissions and limitations under 12 | * the License. 13 | */ 14 | 15 | apply plugin: 'com.android.application' 16 | 17 | android { 18 | compileSdkVersion 23 19 | buildToolsVersion "23.0.2" 20 | 21 | defaultConfig { 22 | applicationId "io.github.mthli.type" 23 | minSdkVersion 21 24 | targetSdkVersion 23 25 | versionCode 1 26 | versionName "0.1" 27 | } 28 | 29 | buildTypes { 30 | release { 31 | minifyEnabled false 32 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' 33 | } 34 | } 35 | } 36 | 37 | dependencies { 38 | compile fileTree(include: ['*.jar'], dir: 'libs') 39 | compile 'com.android.support:appcompat-v7:23.3.0' 40 | compile 'com.android.support:recyclerview-v7:23.3.0' 41 | compile 'com.tbruyelle.rxpermissions:rxpermissions:0.7.0@aar' 42 | compile 'com.trello:rxlifecycle-components:0.5.0' 43 | compile 'io.reactivex:rxandroid:1.1.0' 44 | } 45 | -------------------------------------------------------------------------------- /app/proguard-rules.pro: -------------------------------------------------------------------------------- 1 | # Copyright 2016 Matthew Lee 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except 4 | # in compliance with the License. You may obtain a copy of the License at 5 | # 6 | # http://www.apache.org/licenses/LICENSE-2.0 7 | # 8 | # Unless required by applicable law or agreed to in writing, software distributed under the License 9 | # is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 10 | # or implied. See the License for the specific language governing permissions and limitations under 11 | # the License. 12 | 13 | # Add project specific ProGuard rules here. 14 | # By default, the flags in this file are appended to flags specified 15 | # in /home/matthew/Android/Sdk/tools/proguard/proguard-android.txt 16 | # You can edit the include path and order by changing the proguardFiles 17 | # directive in build.gradle. 18 | # 19 | # For more details, see 20 | # http://developer.android.com/guide/developing/tools/proguard.html 21 | 22 | # Add any project specific keep options here: 23 | 24 | # If your project uses WebView with JS, uncomment the following 25 | # and specify the fully qualified class name to the JavaScript interface 26 | # class: 27 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview { 28 | # public *; 29 | #} 30 | -------------------------------------------------------------------------------- /app/src/androidTest/java/io/github/mthli/type/ApplicationTest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016 Matthew Lee 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except 5 | * in compliance with the License. You may obtain a copy of the License at 6 | * 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software distributed under the License 10 | * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 11 | * or implied. See the License for the specific language governing permissions and limitations under 12 | * the License. 13 | */ 14 | 15 | package io.github.mthli.type; 16 | 17 | import android.app.Application; 18 | import android.test.ApplicationTestCase; 19 | 20 | /** 21 | * Testing Fundamentals 22 | */ 23 | public class ApplicationTest extends ApplicationTestCase { 24 | public ApplicationTest() { 25 | super(Application.class); 26 | } 27 | } -------------------------------------------------------------------------------- /app/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 16 | 17 | 19 | 20 | 21 | 22 | 23 | 28 | 29 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | -------------------------------------------------------------------------------- /app/src/main/java/io/github/mthli/type/app/LinkActivity.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016 Matthew Lee 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except 5 | * in compliance with the License. You may obtain a copy of the License at 6 | * 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software distributed under the License 10 | * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 11 | * or implied. See the License for the specific language governing permissions and limitations under 12 | * the License. 13 | */ 14 | 15 | package io.github.mthli.type.app; 16 | 17 | public class LinkActivity { 18 | } 19 | -------------------------------------------------------------------------------- /app/src/main/java/io/github/mthli/type/app/MainActivity.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016 Matthew Lee 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except 5 | * in compliance with the License. You may obtain a copy of the License at 6 | * 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software distributed under the License 10 | * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 11 | * or implied. See the License for the specific language governing permissions and limitations under 12 | * the License. 13 | */ 14 | 15 | package io.github.mthli.type.app; 16 | 17 | import android.animation.Animator; 18 | import android.animation.AnimatorListenerAdapter; 19 | import android.content.Intent; 20 | import android.graphics.Bitmap; 21 | import android.graphics.drawable.Drawable; 22 | import android.os.Bundle; 23 | import android.provider.MediaStore; 24 | import android.support.v7.widget.AppCompatImageButton; 25 | import android.support.v7.widget.DefaultItemAnimator; 26 | import android.support.v7.widget.LinearLayoutCompat; 27 | import android.support.v7.widget.LinearLayoutManager; 28 | import android.support.v7.widget.RecyclerView; 29 | import android.support.v7.widget.helper.ItemTouchHelper; 30 | import android.view.ActionMode; 31 | import android.view.View; 32 | import android.view.animation.LinearInterpolator; 33 | import android.widget.Toast; 34 | 35 | import com.jakewharton.rxbinding.view.RxView; 36 | import com.jakewharton.rxbinding.view.ViewLayoutChangeEvent; 37 | import com.trello.rxlifecycle.ActivityEvent; 38 | import com.trello.rxlifecycle.components.support.RxAppCompatActivity; 39 | 40 | import java.io.IOException; 41 | import java.util.Collections; 42 | import java.util.LinkedList; 43 | import java.util.List; 44 | import java.util.concurrent.TimeUnit; 45 | 46 | import io.github.mthli.type.R; 47 | import io.github.mthli.type.event.BlockEvent; 48 | import io.github.mthli.type.event.BoldEvent; 49 | import io.github.mthli.type.event.BulletEvent; 50 | import io.github.mthli.type.event.DeleteEvent; 51 | import io.github.mthli.type.event.DotsEvent; 52 | import io.github.mthli.type.event.ImageEvent; 53 | import io.github.mthli.type.event.InsertEvent; 54 | import io.github.mthli.type.event.FormatEvent; 55 | import io.github.mthli.type.event.ItalicEvent; 56 | import io.github.mthli.type.event.QuoteEvent; 57 | import io.github.mthli.type.event.StrikethroughEvent; 58 | import io.github.mthli.type.event.UnderlineEvent; 59 | import io.github.mthli.type.util.ImageUtils; 60 | import io.github.mthli.type.util.RxBus; 61 | import io.github.mthli.type.widget.StatusImageButton; 62 | import io.github.mthli.type.widget.adapter.TypeAdapter; 63 | import io.github.mthli.type.widget.holder.TypeDotsHolder; 64 | import io.github.mthli.type.widget.holder.TypeImageHolder; 65 | import io.github.mthli.type.widget.holder.TypeTitleHolder; 66 | import io.github.mthli.type.widget.model.Type; 67 | import io.github.mthli.type.widget.model.TypeBlock; 68 | import io.github.mthli.type.widget.model.TypeDots; 69 | import io.github.mthli.type.widget.model.TypeImage; 70 | import io.github.mthli.type.widget.model.TypeTitle; 71 | import io.github.mthli.type.widget.text.KnifeText; 72 | import rx.Observable; 73 | import rx.Subscriber; 74 | import rx.android.schedulers.AndroidSchedulers; 75 | import rx.functions.Action1; 76 | import rx.schedulers.Schedulers; 77 | 78 | public class MainActivity extends RxAppCompatActivity implements View.OnClickListener, View.OnLongClickListener, 79 | RecyclerView.OnChildAttachStateChangeListener { 80 | 81 | private static final long SYSTEM_UI_DELAY = 1000l; // ms 82 | private static final int REQUEST_IMAGE = 0x01; 83 | 84 | private RecyclerView recyclerView; 85 | private LinearLayoutManager layoutManager; 86 | private TypeAdapter typeAdapter; 87 | private List typeList; 88 | private int targetPosition = -1; 89 | 90 | private LinearLayoutCompat controlPanel; 91 | private StatusImageButton bulletButton; 92 | private StatusImageButton quoteButton; 93 | private AppCompatImageButton attachmentButton; 94 | private AppCompatImageButton dotsButton; 95 | private AppCompatImageButton playButton; 96 | 97 | private LinearLayoutCompat stylePanel; 98 | private StatusImageButton boldButton; 99 | private StatusImageButton italicButton; 100 | private StatusImageButton underlineButton; 101 | private StatusImageButton strikethroughButton; 102 | private StatusImageButton linkButton; 103 | 104 | @Override 105 | protected void onCreate(Bundle savedInstanceState) { 106 | super.onCreate(savedInstanceState); 107 | setContentView(R.layout.activity_main); 108 | 109 | setupRootLayout(); 110 | setupRecyclerView(); 111 | setupItemTouchHelper(); 112 | setupControlPanel(); 113 | setupStylePanel(); 114 | setupReactiveX(); 115 | } 116 | 117 | private void setupRootLayout() { 118 | RxView.layoutChangeEvents(findViewById(R.id.root)) 119 | .delay(SYSTEM_UI_DELAY, TimeUnit.MILLISECONDS, AndroidSchedulers.mainThread()) 120 | .compose(this.bindUntilEvent(ActivityEvent.DESTROY)) 121 | .subscribe(new Action1() { 122 | @Override 123 | public void call(ViewLayoutChangeEvent viewLayoutChangeEvent) { 124 | int oldHeight = viewLayoutChangeEvent.oldBottom() - viewLayoutChangeEvent.oldTop(); 125 | int newHeight = viewLayoutChangeEvent.bottom() - viewLayoutChangeEvent.top(); 126 | if (newHeight > oldHeight) { 127 | getWindow().getDecorView().setSystemUiVisibility(View.SYSTEM_UI_FLAG_LOW_PROFILE); 128 | } 129 | } 130 | }); 131 | } 132 | 133 | private void setupRecyclerView() { 134 | recyclerView = (RecyclerView) findViewById(R.id.recycler); 135 | layoutManager = new LinearLayoutManager(this); 136 | recyclerView.setLayoutManager(layoutManager); 137 | 138 | // TODO 139 | typeList = new LinkedList<>(); 140 | typeList.add(new TypeTitle(null)); 141 | typeList.add(new TypeBlock(null)); 142 | 143 | typeAdapter = new TypeAdapter(this, typeList); 144 | recyclerView.setAdapter(typeAdapter); 145 | recyclerView.setItemAnimator(new DefaultItemAnimator()); 146 | recyclerView.addOnChildAttachStateChangeListener(this); 147 | } 148 | 149 | private void setupItemTouchHelper() { 150 | ItemTouchHelper.SimpleCallback callback = new ItemTouchHelper.SimpleCallback(ItemTouchHelper.UP | ItemTouchHelper.DOWN, ItemTouchHelper.START | ItemTouchHelper.END) { 151 | @Override 152 | public int getDragDirs(RecyclerView recyclerView, RecyclerView.ViewHolder holder) { 153 | if (holder instanceof TypeDotsHolder || holder instanceof TypeImageHolder) { 154 | return ItemTouchHelper.UP | ItemTouchHelper.DOWN; 155 | } else { 156 | return 0; 157 | } 158 | } 159 | 160 | @Override 161 | public int getSwipeDirs(RecyclerView recyclerView, RecyclerView.ViewHolder holder) { 162 | if (holder instanceof TypeDotsHolder || holder instanceof TypeImageHolder) { 163 | return ItemTouchHelper.START | ItemTouchHelper.END; 164 | } else { 165 | return 0; 166 | } 167 | } 168 | 169 | @Override 170 | public boolean onMove(RecyclerView recyclerView, RecyclerView.ViewHolder source, RecyclerView.ViewHolder target) { 171 | if (target instanceof TypeTitleHolder) { 172 | return false; 173 | } 174 | 175 | int from = source.getAdapterPosition(); 176 | int to = target.getAdapterPosition(); 177 | Collections.swap(typeList, from, to); 178 | typeAdapter.notifyItemMoved(from, to); 179 | return true; 180 | } 181 | 182 | @Override 183 | public void onSwiped(RecyclerView.ViewHolder holder, int direction) { 184 | int position = holder.getAdapterPosition(); 185 | typeList.remove(position); 186 | typeAdapter.notifyItemRemoved(position); 187 | } 188 | }; 189 | 190 | ItemTouchHelper helper = new ItemTouchHelper(callback); 191 | helper.attachToRecyclerView(recyclerView); 192 | } 193 | 194 | private void setupControlPanel() { 195 | controlPanel = (LinearLayoutCompat) findViewById(R.id.control); 196 | bulletButton = (StatusImageButton) findViewById(R.id.bullet); 197 | quoteButton = (StatusImageButton) findViewById(R.id.quote); 198 | attachmentButton = (AppCompatImageButton) findViewById(R.id.attachment); 199 | dotsButton = (AppCompatImageButton) findViewById(R.id.dots); 200 | playButton = (AppCompatImageButton) findViewById(R.id.play); 201 | 202 | bulletButton.setOnClickListener(this); 203 | quoteButton.setOnClickListener(this); 204 | attachmentButton.setOnClickListener(this); 205 | dotsButton.setOnClickListener(this); 206 | playButton.setOnClickListener(this); 207 | 208 | bulletButton.setOnLongClickListener(this); 209 | quoteButton.setOnLongClickListener(this); 210 | attachmentButton.setOnLongClickListener(this); 211 | dotsButton.setOnLongClickListener(this); 212 | playButton.setOnLongClickListener(this); 213 | 214 | RxBus.getInstance().toObservable(BlockEvent.class) 215 | .subscribe(new Action1() { 216 | @Override 217 | public void call(BlockEvent event) { 218 | bulletButton.setActivated(event.isBullet()); 219 | quoteButton.setActivated(event.isQuote()); 220 | } 221 | }); 222 | } 223 | 224 | private void setupStylePanel() { 225 | stylePanel = (LinearLayoutCompat) findViewById(R.id.style); 226 | boldButton = (StatusImageButton) findViewById(R.id.bold); 227 | italicButton = (StatusImageButton) findViewById(R.id.italic); 228 | underlineButton = (StatusImageButton) findViewById(R.id.underline); 229 | strikethroughButton = (StatusImageButton) findViewById(R.id.strikethrough); 230 | linkButton = (StatusImageButton) findViewById(R.id.link); 231 | 232 | boldButton.setOnClickListener(this); 233 | italicButton.setOnClickListener(this); 234 | underlineButton.setOnClickListener(this); 235 | strikethroughButton.setOnClickListener(this); 236 | linkButton.setOnClickListener(this); 237 | 238 | boldButton.setOnLongClickListener(this); 239 | italicButton.setOnLongClickListener(this); 240 | underlineButton.setOnLongClickListener(this); 241 | strikethroughButton.setOnLongClickListener(this); 242 | linkButton.setOnLongClickListener(this); 243 | 244 | RxBus.getInstance().toObservable(FormatEvent.class) 245 | .subscribe(new Action1() { 246 | @Override 247 | public void call(FormatEvent event) { 248 | boldButton.setActivated(event.isBold()); 249 | italicButton.setActivated(event.isItalic()); 250 | underlineButton.setActivated(event.isUnderline()); 251 | strikethroughButton.setActivated(event.isStrikethrough()); 252 | linkButton.setActivated(event.isLink()); 253 | } 254 | }); 255 | } 256 | 257 | private void setupReactiveX() { 258 | RxBus.getInstance().toObservable(DeleteEvent.class) 259 | .compose(this.bindUntilEvent(ActivityEvent.DESTROY)) 260 | .subscribe(new Action1() { 261 | @Override 262 | public void call(DeleteEvent event) { 263 | onDeleteEvent(event); 264 | } 265 | }); 266 | 267 | RxBus.getInstance().toObservable(InsertEvent.class) 268 | .compose(this.bindUntilEvent(ActivityEvent.DESTROY)) 269 | .subscribe(new Action1() { 270 | @Override 271 | public void call(InsertEvent event) { 272 | onInsertEvent(event); 273 | } 274 | }); 275 | } 276 | 277 | private void onInsertEvent(InsertEvent event) { 278 | int position = event.getPosition(); 279 | if (position < 1 || position >= typeList.size()) { 280 | return; 281 | } 282 | 283 | switch (event.getType()) { 284 | case Type.TYPE_BLOCK: 285 | onInsertBlock(event); 286 | break; 287 | case Type.TYPE_DOTS: 288 | onInsertDots(event); 289 | break; 290 | case Type.TYPE_IMAGE: 291 | onInsertImage(event); 292 | break; 293 | default: 294 | return; 295 | } 296 | 297 | int first = layoutManager.findFirstCompletelyVisibleItemPosition(); 298 | int last = layoutManager.findLastCompletelyVisibleItemPosition(); 299 | if (targetPosition > last) { 300 | recyclerView.scrollToPosition(targetPosition); 301 | } else if (first <= targetPosition && targetPosition <= last) { 302 | recyclerView.scrollToPosition(first); 303 | } 304 | } 305 | 306 | private void onInsertBlock(InsertEvent event) { 307 | targetPosition = event.getPosition() + 1; 308 | typeList.add(targetPosition, new TypeBlock(event.getSuffix())); 309 | typeAdapter.notifyItemInserted(targetPosition); 310 | } 311 | 312 | private void onInsertDots(InsertEvent event) { 313 | if (event.getPrefix().length() <= 0) { 314 | targetPosition = event.getPosition(); 315 | typeList.set(targetPosition, new TypeDots()); 316 | typeList.add(++targetPosition, new TypeBlock(event.getSuffix())); 317 | typeAdapter.notifyDataSetChanged(); 318 | } else { 319 | targetPosition = event.getPosition() + 1; 320 | typeList.add(targetPosition, new TypeDots()); 321 | typeList.add(++targetPosition, new TypeBlock(event.getSuffix())); 322 | typeAdapter.notifyItemRangeInserted(event.getPosition() + 1, 2); 323 | } 324 | } 325 | 326 | private void onInsertImage(InsertEvent event) { 327 | if (event.getPrefix().length() <= 0) { 328 | targetPosition = event.getPosition(); 329 | typeList.set(targetPosition, new TypeImage(event.getBitmap())); 330 | typeList.add(++targetPosition, new TypeBlock(event.getSuffix())); 331 | typeAdapter.notifyDataSetChanged(); 332 | } else { 333 | targetPosition = event.getPosition() + 1; 334 | typeList.add(targetPosition, new TypeImage(event.getBitmap())); 335 | typeList.add(++targetPosition, new TypeBlock(event.getSuffix())); 336 | typeAdapter.notifyItemRangeInserted(event.getPosition() + 1, 2); 337 | } 338 | } 339 | 340 | @Override 341 | public void onChildViewAttachedToWindow(View view) { 342 | if (layoutManager.getPosition(view) == targetPosition) { 343 | targetPosition = -1; 344 | 345 | KnifeText knifeText = (KnifeText) view.findViewById(R.id.content); 346 | if (knifeText != null) { 347 | knifeText.requestFocus(); 348 | knifeText.setSelection(0); 349 | } else { 350 | view.requestFocus(); 351 | } 352 | } 353 | } 354 | 355 | @Override 356 | public void onChildViewDetachedFromWindow(View view) { 357 | // DO NOTHING HERE 358 | } 359 | 360 | @Override 361 | public void onPause() { 362 | super.onPause(); 363 | // TODO 364 | } 365 | 366 | @Override 367 | public void onDestroy() { 368 | super.onDestroy(); 369 | recyclerView.clearOnChildAttachStateChangeListeners(); 370 | } 371 | 372 | @Override 373 | protected void onActivityResult(int requestCode, int resultCode, Intent data) { 374 | super.onActivityResult(requestCode, resultCode, data); 375 | 376 | if (requestCode != REQUEST_IMAGE) { 377 | return; 378 | } 379 | 380 | if (resultCode != RESULT_OK || data == null || data.getData() == null) { 381 | Toast.makeText(this, R.string.toast_attachment_failed, Toast.LENGTH_SHORT).show(); 382 | return; 383 | } 384 | 385 | try { 386 | Bitmap bitmap = MediaStore.Images.Media.getBitmap(getContentResolver(), data.getData()); 387 | insertImageAsync(bitmap); 388 | } catch (IOException i) { 389 | Toast.makeText(this, R.string.toast_attachment_failed, Toast.LENGTH_SHORT).show(); 390 | } 391 | } 392 | 393 | private void insertImageAsync(final Bitmap bitmap) { 394 | Observable.create(new Observable.OnSubscribe() { 395 | @Override 396 | public void call(Subscriber subscriber) { 397 | Bitmap fix = ImageUtils.fixBitmap(MainActivity.this, bitmap); 398 | Drawable inset = ImageUtils.insetBitmap(MainActivity.this, fix); 399 | Bitmap result = ImageUtils.drawable2Bitmap(inset); 400 | subscriber.onNext(result); 401 | } 402 | }).subscribeOn(Schedulers.newThread()).observeOn(AndroidSchedulers.mainThread()).subscribe(new Action1() { 403 | @Override 404 | public void call(Bitmap result) { 405 | RxBus.getInstance().post(new ImageEvent(result)); 406 | } 407 | }); 408 | } 409 | 410 | @Override 411 | public void onActionModeStarted(ActionMode actionMode) { 412 | super.onActionModeStarted(actionMode); 413 | switchToStylePanel(); 414 | } 415 | 416 | @Override 417 | public void onActionModeFinished(ActionMode actionMode) { 418 | super.onActionModeFinished(actionMode); 419 | switchToControlPanel(); 420 | } 421 | 422 | private void switchToControlPanel() { 423 | stylePanel.animate().alpha(0.0f) 424 | .setDuration(getResources().getInteger(android.R.integer.config_shortAnimTime)) 425 | .setInterpolator(new LinearInterpolator()) 426 | .setListener(new AnimatorListenerAdapter() { 427 | @Override 428 | public void onAnimationStart(Animator animator) { 429 | stylePanel.setAlpha(1.0f); 430 | stylePanel.setVisibility(View.VISIBLE); 431 | } 432 | 433 | @Override 434 | public void onAnimationEnd(Animator animator) { 435 | stylePanel.setAlpha(0.0f); 436 | stylePanel.setVisibility(View.GONE); 437 | } 438 | }).start(); 439 | 440 | controlPanel.animate().alpha(1.0f) 441 | .setDuration(getResources().getInteger(android.R.integer.config_shortAnimTime)) 442 | .setInterpolator(new LinearInterpolator()) 443 | .setListener(new AnimatorListenerAdapter() { 444 | @Override 445 | public void onAnimationStart(Animator animator) { 446 | controlPanel.setAlpha(0.0f); 447 | controlPanel.setVisibility(View.VISIBLE); 448 | } 449 | 450 | @Override 451 | public void onAnimationEnd (Animator animator){ 452 | controlPanel.setAlpha(1.0f); 453 | controlPanel.setVisibility(View.VISIBLE); 454 | } 455 | }).start(); 456 | } 457 | 458 | private void switchToStylePanel() { 459 | controlPanel.animate().alpha(0.0f) 460 | .setDuration(getResources().getInteger(android.R.integer.config_shortAnimTime)) 461 | .setInterpolator(new LinearInterpolator()) 462 | .setListener(new AnimatorListenerAdapter() { 463 | @Override 464 | public void onAnimationStart(Animator animator) { 465 | controlPanel.setAlpha(1.0f); 466 | controlPanel.setVisibility(View.VISIBLE); 467 | } 468 | 469 | @Override 470 | public void onAnimationEnd(Animator animator) { 471 | controlPanel.setAlpha(0.0f); 472 | controlPanel.setVisibility(View.GONE); 473 | } 474 | }).start(); 475 | 476 | stylePanel.animate().alpha(1.0f) 477 | .setDuration(getResources().getInteger(android.R.integer.config_shortAnimTime)) 478 | .setInterpolator(new LinearInterpolator()) 479 | .setListener(new AnimatorListenerAdapter() { 480 | @Override 481 | public void onAnimationStart(Animator animator) { 482 | stylePanel.setAlpha(0.0f); 483 | stylePanel.setVisibility(View.VISIBLE); 484 | } 485 | 486 | @Override 487 | public void onAnimationEnd(Animator animator) { 488 | stylePanel.setAlpha(1.0f); 489 | stylePanel.setVisibility(View.VISIBLE); 490 | } 491 | }).start(); 492 | } 493 | 494 | @Override 495 | public void onClick(View view) { 496 | if (view == bulletButton) { 497 | RxBus.getInstance().post(new BulletEvent()); 498 | } else if (view == quoteButton) { 499 | RxBus.getInstance().post(new QuoteEvent()); 500 | } else if (view == attachmentButton) { 501 | onClickAttachment(); 502 | } else if (view == dotsButton) { 503 | RxBus.getInstance().post(new DotsEvent()); 504 | } else if (view == playButton) { 505 | // TODO 506 | } else if (view == boldButton) { 507 | RxBus.getInstance().post(new BoldEvent()); 508 | } else if (view == italicButton) { 509 | RxBus.getInstance().post(new ItalicEvent()); 510 | } else if (view == underlineButton) { 511 | RxBus.getInstance().post(new UnderlineEvent()); 512 | } else if (view == strikethroughButton) { 513 | RxBus.getInstance().post(new StrikethroughEvent()); 514 | } else if (view == linkButton) { 515 | // TODO 516 | } 517 | } 518 | 519 | private void onClickAttachment() { 520 | Intent intent = new Intent(); 521 | intent.setType("image/*"); 522 | intent.setAction(Intent.ACTION_GET_CONTENT); 523 | startActivityForResult(intent, REQUEST_IMAGE); 524 | } 525 | 526 | @Override 527 | public boolean onLongClick(View view) { 528 | int stringResId = 0; 529 | 530 | if (view == bulletButton) { 531 | stringResId = R.string.toast_bullet; 532 | } else if (view == quoteButton) { 533 | stringResId = R.string.toast_quote; 534 | } else if (view == attachmentButton) { 535 | stringResId = R.string.toast_attachment; 536 | } else if (view == dotsButton) { 537 | stringResId = R.string.toast_dots; 538 | } else if (view == playButton) { 539 | stringResId = R.string.toast_play; 540 | } else if (view == boldButton) { 541 | stringResId = R.string.toast_bold; 542 | } else if (view == italicButton) { 543 | stringResId = R.string.toast_italic; 544 | } else if (view == underlineButton) { 545 | stringResId = R.string.toast_underline; 546 | } else if (view == strikethroughButton) { 547 | stringResId = R.string.toast_strikethrough; 548 | } else if (view == linkButton) { 549 | stringResId = R.string.toast_link; 550 | } 551 | 552 | if (stringResId != 0) { 553 | Toast.makeText(this, stringResId, Toast.LENGTH_SHORT).show(); 554 | } 555 | 556 | return true; 557 | } 558 | 559 | private void onDeleteEvent(DeleteEvent event) { 560 | int position = event.getPosition(); 561 | int type = event.getType(); 562 | if (position <= 1 || position >= typeList.size() || type != Type.TYPE_BLOCK) { 563 | return; 564 | } 565 | 566 | // TODO 567 | } 568 | } 569 | -------------------------------------------------------------------------------- /app/src/main/java/io/github/mthli/type/app/SettingsActivity.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016 Matthew Lee 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except 5 | * in compliance with the License. You may obtain a copy of the License at 6 | * 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software distributed under the License 10 | * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 11 | * or implied. See the License for the specific language governing permissions and limitations under 12 | * the License. 13 | */ 14 | 15 | package io.github.mthli.type.app; 16 | 17 | public class SettingsActivity { 18 | } 19 | -------------------------------------------------------------------------------- /app/src/main/java/io/github/mthli/type/event/BlockEvent.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016 Matthew Lee 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except 5 | * in compliance with the License. You may obtain a copy of the License at 6 | * 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software distributed under the License 10 | * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 11 | * or implied. See the License for the specific language governing permissions and limitations under 12 | * the License. 13 | */ 14 | 15 | package io.github.mthli.type.event; 16 | 17 | public class BlockEvent { 18 | private boolean isBullet; 19 | private boolean isQuote; 20 | 21 | public BlockEvent() {} 22 | 23 | public BlockEvent(boolean isBullet, boolean isQuote) { 24 | this.isBullet = isBullet; 25 | this.isQuote = isQuote; 26 | } 27 | 28 | public boolean isBullet() { 29 | return isBullet; 30 | } 31 | 32 | public void setBullet(boolean isBullet) { 33 | this.isBullet = isBullet; 34 | } 35 | 36 | public boolean isQuote() { 37 | return isQuote; 38 | } 39 | 40 | public void setQuote(boolean isQuote) { 41 | this.isQuote = isQuote; 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /app/src/main/java/io/github/mthli/type/event/BoldEvent.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016 Matthew Lee 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except 5 | * in compliance with the License. You may obtain a copy of the License at 6 | * 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software distributed under the License 10 | * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 11 | * or implied. See the License for the specific language governing permissions and limitations under 12 | * the License. 13 | */ 14 | 15 | package io.github.mthli.type.event; 16 | 17 | public class BoldEvent {} 18 | -------------------------------------------------------------------------------- /app/src/main/java/io/github/mthli/type/event/BulletEvent.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016 Matthew Lee 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except 5 | * in compliance with the License. You may obtain a copy of the License at 6 | * 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software distributed under the License 10 | * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 11 | * or implied. See the License for the specific language governing permissions and limitations under 12 | * the License. 13 | */ 14 | 15 | package io.github.mthli.type.event; 16 | 17 | public class BulletEvent {} 18 | -------------------------------------------------------------------------------- /app/src/main/java/io/github/mthli/type/event/DeleteEvent.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016 Matthew Lee 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except 5 | * in compliance with the License. You may obtain a copy of the License at 6 | * 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software distributed under the License 10 | * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 11 | * or implied. See the License for the specific language governing permissions and limitations under 12 | * the License. 13 | */ 14 | 15 | package io.github.mthli.type.event; 16 | 17 | import io.github.mthli.type.widget.model.Type; 18 | 19 | public class DeleteEvent { 20 | private int type; 21 | private int position; 22 | 23 | public DeleteEvent(@Type.TypeValue int type, int position) { 24 | this.type = type; 25 | this.position = position; 26 | } 27 | 28 | @Type.TypeValue 29 | public int getType() { 30 | return type; 31 | } 32 | 33 | public int getPosition() { 34 | return position; 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /app/src/main/java/io/github/mthli/type/event/DotsEvent.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016 Matthew Lee 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except 5 | * in compliance with the License. You may obtain a copy of the License at 6 | * 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software distributed under the License 10 | * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 11 | * or implied. See the License for the specific language governing permissions and limitations under 12 | * the License. 13 | */ 14 | 15 | package io.github.mthli.type.event; 16 | 17 | public class DotsEvent {} 18 | -------------------------------------------------------------------------------- /app/src/main/java/io/github/mthli/type/event/FormatEvent.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016 Matthew Lee 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except 5 | * in compliance with the License. You may obtain a copy of the License at 6 | * 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software distributed under the License 10 | * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 11 | * or implied. See the License for the specific language governing permissions and limitations under 12 | * the License. 13 | */ 14 | 15 | package io.github.mthli.type.event; 16 | 17 | public class FormatEvent { 18 | private boolean isBold; 19 | private boolean isItalic; 20 | private boolean isUnderline; 21 | private boolean isStrikethrough; 22 | private boolean isLink; 23 | 24 | public FormatEvent() {} 25 | 26 | public FormatEvent(boolean isBold, boolean isItalic, boolean isUnderline, boolean isStrikethrough, boolean isLink) { 27 | this.isBold = isBold; 28 | this.isItalic = isItalic; 29 | this.isUnderline = isUnderline; 30 | this.isStrikethrough = isStrikethrough; 31 | this.isLink = isLink; 32 | } 33 | 34 | public boolean isBold() { 35 | return isBold; 36 | } 37 | 38 | public void setBold(boolean isBold) { 39 | this.isBold = isBold; 40 | } 41 | 42 | public boolean isItalic() { 43 | return isItalic; 44 | } 45 | 46 | public void setItalic(boolean isItalic) { 47 | this.isItalic = isItalic; 48 | } 49 | 50 | public boolean isUnderline() { 51 | return isUnderline; 52 | } 53 | 54 | public void setUnderline(boolean isUnderline) { 55 | this.isUnderline = isUnderline; 56 | } 57 | 58 | public boolean isStrikethrough() { 59 | return isStrikethrough; 60 | } 61 | 62 | public void setStrikethrough(boolean isStrikethrough) { 63 | this.isStrikethrough = isStrikethrough; 64 | } 65 | 66 | public boolean isLink() { 67 | return isLink; 68 | } 69 | 70 | public void setLink(boolean isLink) { 71 | this.isLink = isLink; 72 | } 73 | } 74 | -------------------------------------------------------------------------------- /app/src/main/java/io/github/mthli/type/event/ImageEvent.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016 Matthew Lee 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except 5 | * in compliance with the License. You may obtain a copy of the License at 6 | * 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software distributed under the License 10 | * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 11 | * or implied. See the License for the specific language governing permissions and limitations under 12 | * the License. 13 | */ 14 | 15 | package io.github.mthli.type.event; 16 | 17 | import android.graphics.Bitmap; 18 | import android.support.annotation.NonNull; 19 | 20 | public class ImageEvent { 21 | private Bitmap bitmap; 22 | 23 | public ImageEvent(@NonNull Bitmap bitmap) { 24 | this.bitmap = bitmap; 25 | } 26 | 27 | public Bitmap getBitmap() { 28 | return bitmap; 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /app/src/main/java/io/github/mthli/type/event/InsertEvent.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016 Matthew Lee 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except 5 | * in compliance with the License. You may obtain a copy of the License at 6 | * 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software distributed under the License 10 | * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 11 | * or implied. See the License for the specific language governing permissions and limitations under 12 | * the License. 13 | */ 14 | 15 | package io.github.mthli.type.event; 16 | 17 | import android.graphics.Bitmap; 18 | import android.support.annotation.NonNull; 19 | import android.support.annotation.Nullable; 20 | import android.text.SpannableString; 21 | import android.text.Spanned; 22 | 23 | import io.github.mthli.type.widget.model.Type; 24 | 25 | public class InsertEvent { 26 | private int type; 27 | private int position; 28 | private Spanned prefix; 29 | private Spanned suffix; 30 | private Bitmap bitmap; 31 | 32 | public InsertEvent(@Type.TypeValue int type, int position, @Nullable Spanned prefix, @Nullable Spanned suffix, @Nullable Bitmap bitmap) { 33 | this.type = type; 34 | this.position = position; 35 | this.prefix = prefix != null ? prefix : new SpannableString(""); 36 | this.suffix = suffix != null ? suffix : new SpannableString(""); 37 | this.bitmap = bitmap; 38 | } 39 | 40 | @Type.TypeValue 41 | public int getType() { 42 | return type; 43 | } 44 | 45 | public int getPosition() { 46 | return position; 47 | } 48 | 49 | @NonNull 50 | public Spanned getPrefix() { 51 | return prefix; 52 | } 53 | 54 | @NonNull 55 | public Spanned getSuffix() { 56 | return suffix; 57 | } 58 | 59 | @Nullable 60 | public Bitmap getBitmap() { 61 | return bitmap; 62 | } 63 | } 64 | -------------------------------------------------------------------------------- /app/src/main/java/io/github/mthli/type/event/ItalicEvent.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016 Matthew Lee 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except 5 | * in compliance with the License. You may obtain a copy of the License at 6 | * 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software distributed under the License 10 | * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 11 | * or implied. See the License for the specific language governing permissions and limitations under 12 | * the License. 13 | */ 14 | 15 | package io.github.mthli.type.event; 16 | 17 | public class ItalicEvent {} 18 | -------------------------------------------------------------------------------- /app/src/main/java/io/github/mthli/type/event/LinkEvent.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016 Matthew Lee 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except 5 | * in compliance with the License. You may obtain a copy of the License at 6 | * 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software distributed under the License 10 | * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 11 | * or implied. See the License for the specific language governing permissions and limitations under 12 | * the License. 13 | */ 14 | 15 | package io.github.mthli.type.event; 16 | 17 | public class LinkEvent {} 18 | -------------------------------------------------------------------------------- /app/src/main/java/io/github/mthli/type/event/QuoteEvent.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016 Matthew Lee 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except 5 | * in compliance with the License. You may obtain a copy of the License at 6 | * 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software distributed under the License 10 | * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 11 | * or implied. See the License for the specific language governing permissions and limitations under 12 | * the License. 13 | */ 14 | 15 | package io.github.mthli.type.event; 16 | 17 | public class QuoteEvent {} 18 | -------------------------------------------------------------------------------- /app/src/main/java/io/github/mthli/type/event/StrikethroughEvent.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016 Matthew Lee 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except 5 | * in compliance with the License. You may obtain a copy of the License at 6 | * 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software distributed under the License 10 | * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 11 | * or implied. See the License for the specific language governing permissions and limitations under 12 | * the License. 13 | */ 14 | 15 | package io.github.mthli.type.event; 16 | 17 | public class StrikethroughEvent {} 18 | -------------------------------------------------------------------------------- /app/src/main/java/io/github/mthli/type/event/UnderlineEvent.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016 Matthew Lee 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except 5 | * in compliance with the License. You may obtain a copy of the License at 6 | * 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software distributed under the License 10 | * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 11 | * or implied. See the License for the specific language governing permissions and limitations under 12 | * the License. 13 | */ 14 | 15 | package io.github.mthli.type.event; 16 | 17 | public class UnderlineEvent {} 18 | -------------------------------------------------------------------------------- /app/src/main/java/io/github/mthli/type/util/DisplayUtils.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016 Matthew Lee 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except 5 | * in compliance with the License. You may obtain a copy of the License at 6 | * 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software distributed under the License 10 | * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 11 | * or implied. See the License for the specific language governing permissions and limitations under 12 | * the License. 13 | */ 14 | 15 | package io.github.mthli.type.util; 16 | 17 | import android.content.Context; 18 | import android.content.res.Resources; 19 | import android.support.annotation.FloatRange; 20 | import android.support.annotation.NonNull; 21 | import android.util.DisplayMetrics; 22 | import android.util.TypedValue; 23 | 24 | public class DisplayUtils { 25 | public static float dp2px(@NonNull Context context, @FloatRange(from = 0.0f, to = Float.MAX_VALUE) float dp) { 26 | DisplayMetrics metrics = context.getResources().getDisplayMetrics(); 27 | return TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, dp, metrics); 28 | } 29 | 30 | public static float getDensity(@NonNull Context context) { 31 | return context.getResources().getDisplayMetrics().density; 32 | } 33 | 34 | public static int getScreenHeight(@NonNull Context context) { 35 | return context.getResources().getDisplayMetrics().heightPixels; 36 | } 37 | 38 | public static int getScreenWidth(@NonNull Context context) { 39 | return context.getResources().getDisplayMetrics().widthPixels; 40 | } 41 | 42 | public static int getStatusBarHeight(@NonNull Context context) { 43 | Resources resources = context.getResources(); 44 | int resourceId = resources.getIdentifier("status_bar_height", "dimen", "android"); 45 | if (resourceId > 0) { 46 | return resources.getDimensionPixelSize(resourceId); 47 | } 48 | 49 | return 0; 50 | } 51 | } 52 | -------------------------------------------------------------------------------- /app/src/main/java/io/github/mthli/type/util/ImageUtils.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016 Matthew Lee 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except 5 | * in compliance with the License. You may obtain a copy of the License at 6 | * 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software distributed under the License 10 | * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 11 | * or implied. See the License for the specific language governing permissions and limitations under 12 | * the License. 13 | */ 14 | 15 | package io.github.mthli.type.util; 16 | 17 | import android.content.Context; 18 | import android.graphics.Bitmap; 19 | import android.graphics.Canvas; 20 | import android.graphics.Matrix; 21 | import android.graphics.drawable.BitmapDrawable; 22 | import android.graphics.drawable.Drawable; 23 | import android.graphics.drawable.InsetDrawable; 24 | import android.support.annotation.NonNull; 25 | import android.util.DisplayMetrics; 26 | import android.view.WindowManager; 27 | 28 | public class ImageUtils { 29 | // http://stackoverflow.com/questions/3035692/how-to-convert-a-drawable-to-a-bitmap 30 | public static Bitmap drawable2Bitmap(@NonNull Drawable drawable) { 31 | Bitmap bitmap; 32 | 33 | if (drawable instanceof BitmapDrawable) { 34 | BitmapDrawable bitmapDrawable = (BitmapDrawable) drawable; 35 | if (bitmapDrawable.getBitmap() != null) { 36 | return bitmapDrawable.getBitmap(); 37 | } 38 | } 39 | 40 | if(drawable.getIntrinsicWidth() <= 0 || drawable.getIntrinsicHeight() <= 0) { 41 | // Single color bitmap will be created of 1x1 pixel 42 | bitmap = Bitmap.createBitmap(1, 1, Bitmap.Config.ARGB_8888); 43 | } else { 44 | bitmap = Bitmap.createBitmap(drawable.getIntrinsicWidth(), drawable.getIntrinsicHeight(), Bitmap.Config.ARGB_8888); 45 | } 46 | 47 | Canvas canvas = new Canvas(bitmap); 48 | drawable.setBounds(0, 0, canvas.getWidth(), canvas.getHeight()); 49 | drawable.draw(canvas); 50 | return bitmap; 51 | } 52 | 53 | // https://github.com/mthli/Tweetin/blob/master/Tweetin/src/io/github/mthli/Tweetin/Picture/PictureUnit.java 54 | public static Bitmap fixBitmap(@NonNull Context context, @NonNull Bitmap bitmap) { 55 | WindowManager manager = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE); 56 | DisplayMetrics metrics = new DisplayMetrics(); 57 | manager.getDefaultDisplay().getMetrics(metrics); 58 | 59 | int screenWidth = metrics.widthPixels; 60 | int screenHeight = metrics.heightPixels; 61 | int bitmapWidth = bitmap.getWidth(); 62 | int bitmapHeight = bitmap.getHeight(); 63 | 64 | if (bitmapWidth > screenWidth || bitmapHeight > screenHeight) { 65 | float percentW = ((float) screenWidth) / ((float) bitmapWidth); 66 | float percentH = ((float) screenHeight) / ((float) bitmapHeight); 67 | float percent = percentW < percentH ? percentW : percentH; 68 | Matrix matrix = new Matrix(); 69 | matrix.postScale(percent, percent); 70 | bitmap = Bitmap.createBitmap(bitmap, 0, 0, bitmapWidth, bitmapHeight, matrix, true); 71 | } 72 | 73 | return bitmap; 74 | } 75 | 76 | public static Drawable insetBitmap(@NonNull Context context, @NonNull Bitmap bitmap) { 77 | BitmapDrawable bitmapDrawable = new BitmapDrawable(context.getResources(), bitmap); 78 | bitmapDrawable.setBounds(0, 0, bitmapDrawable.getIntrinsicWidth(), bitmapDrawable.getIntrinsicHeight()); 79 | 80 | int inset = (DisplayUtils.getScreenWidth(context) - bitmapDrawable.getBounds().right) / 2; 81 | if (inset <= 0) { 82 | return bitmapDrawable; 83 | } 84 | 85 | InsetDrawable insetDrawable = new InsetDrawable(bitmapDrawable, inset, 0, inset, 0); 86 | insetDrawable.setBounds(0, 0, DisplayUtils.getScreenWidth(context), bitmapDrawable.getIntrinsicHeight()); 87 | return insetDrawable; 88 | } 89 | } 90 | -------------------------------------------------------------------------------- /app/src/main/java/io/github/mthli/type/util/RxBus.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016 Matthew Lee 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except 5 | * in compliance with the License. You may obtain a copy of the License at 6 | * 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software distributed under the License 10 | * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 11 | * or implied. See the License for the specific language governing permissions and limitations under 12 | * the License. 13 | */ 14 | 15 | package io.github.mthli.type.util; 16 | 17 | import rx.Observable; 18 | import rx.subjects.PublishSubject; 19 | import rx.subjects.SerializedSubject; 20 | import rx.subjects.Subject; 21 | 22 | public class RxBus { 23 | private static final RxBus sRxBus = new RxBus(); 24 | 25 | public static RxBus getInstance() { 26 | return sRxBus; 27 | } 28 | 29 | private Subject mSubject = new SerializedSubject<>(PublishSubject.create()); 30 | 31 | private RxBus() {} 32 | 33 | public void post(Object object) { 34 | mSubject.onNext(object); 35 | } 36 | 37 | public Observable toObservable(Class eventType) { 38 | return mSubject.ofType(eventType); 39 | } 40 | 41 | public boolean hasObservers() { 42 | return mSubject.hasObservers(); 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /app/src/main/java/io/github/mthli/type/util/SharedPreferenceUtils.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016 Matthew Lee 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except 5 | * in compliance with the License. You may obtain a copy of the License at 6 | * 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software distributed under the License 10 | * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 11 | * or implied. See the License for the specific language governing permissions and limitations under 12 | * the License. 13 | */ 14 | 15 | package io.github.mthli.type.util; 16 | 17 | public class SharedPreferenceUtils { 18 | } 19 | -------------------------------------------------------------------------------- /app/src/main/java/io/github/mthli/type/widget/DotsView.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016 Matthew Lee 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except 5 | * in compliance with the License. You may obtain a copy of the License at 6 | * 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software distributed under the License 10 | * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 11 | * or implied. See the License for the specific language governing permissions and limitations under 12 | * the License. 13 | */ 14 | 15 | package io.github.mthli.type.widget; 16 | 17 | import android.content.Context; 18 | import android.content.res.TypedArray; 19 | import android.graphics.Canvas; 20 | import android.graphics.Paint; 21 | import android.util.AttributeSet; 22 | import android.view.View; 23 | 24 | import io.github.mthli.type.R; 25 | 26 | public class DotsView extends View { 27 | private int dotColor; 28 | private int dotSize; 29 | private int dotSpacing; 30 | 31 | private Paint paint; 32 | 33 | public DotsView(Context context) { 34 | super(context); 35 | init(null); 36 | } 37 | 38 | public DotsView(Context context, AttributeSet attrs) { 39 | super(context, attrs); 40 | init(attrs); 41 | } 42 | 43 | public DotsView(Context context, AttributeSet attrs, int defStyleAttr) { 44 | super(context, attrs, defStyleAttr); 45 | init(attrs); 46 | } 47 | 48 | private void init(AttributeSet attrs) { 49 | if (attrs == null) { 50 | return; 51 | } 52 | 53 | TypedArray array = getContext().obtainStyledAttributes(attrs, R.styleable.DotsView); 54 | dotColor = array.getColor(R.styleable.DotsView_dotColor, 0); 55 | dotSize = array.getDimensionPixelSize(R.styleable.DotsView_dotSize, 0); 56 | dotSpacing = array.getDimensionPixelSize(R.styleable.DotsView_dotSpacing, 0); 57 | array.recycle(); 58 | 59 | paint = new Paint(); 60 | paint.setStyle(Paint.Style.FILL); 61 | paint.setColor(dotColor); 62 | } 63 | 64 | @Override 65 | public void onDraw(Canvas canvas) { 66 | if (dotColor == 0 || dotSize == 0 || dotSpacing == 0) { 67 | return; 68 | } 69 | 70 | float centerX = canvas.getWidth() / 2; 71 | float centerY = canvas.getHeight() / 2; 72 | 73 | centerX -= dotSpacing; 74 | canvas.drawOval(centerX - dotSize / 2, centerY - dotSize / 2, centerX + dotSize / 2, centerY + dotSize / 2, paint); 75 | 76 | centerX += dotSpacing; 77 | canvas.drawOval(centerX - dotSize / 2, centerY - dotSize / 2, centerX + dotSize / 2, centerY + dotSize / 2, paint); 78 | 79 | centerX += dotSpacing; 80 | canvas.drawOval(centerX - dotSize / 2, centerY - dotSize / 2, centerX + dotSize / 2, centerY + dotSize / 2, paint); 81 | } 82 | } 83 | -------------------------------------------------------------------------------- /app/src/main/java/io/github/mthli/type/widget/StatusImageButton.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016 Matthew Lee 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except 5 | * in compliance with the License. You may obtain a copy of the License at 6 | * 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software distributed under the License 10 | * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 11 | * or implied. See the License for the specific language governing permissions and limitations under 12 | * the License. 13 | */ 14 | 15 | package io.github.mthli.type.widget; 16 | 17 | import android.content.Context; 18 | import android.content.res.TypedArray; 19 | import android.graphics.drawable.Drawable; 20 | import android.support.v7.widget.AppCompatImageButton; 21 | import android.util.AttributeSet; 22 | 23 | import io.github.mthli.type.R; 24 | 25 | public class StatusImageButton extends AppCompatImageButton { 26 | private Drawable activated; 27 | private Drawable defauls; 28 | private boolean isActivated; 29 | 30 | public StatusImageButton(Context context) { 31 | super(context); 32 | init(null); 33 | } 34 | 35 | public StatusImageButton(Context context, AttributeSet attrs) { 36 | super(context, attrs); 37 | init(attrs); 38 | } 39 | 40 | public StatusImageButton(Context context, AttributeSet attrs, int defStyleAttr) { 41 | super(context, attrs, defStyleAttr); 42 | init(attrs); 43 | } 44 | 45 | private void init(AttributeSet attrs) { 46 | if (attrs == null) { 47 | return; 48 | } 49 | 50 | TypedArray array = getContext().obtainStyledAttributes(attrs, R.styleable.StatusImageButton); 51 | activated = array.getDrawable(R.styleable.StatusImageButton_activated); 52 | defauls = array.getDrawable(R.styleable.StatusImageButton_defauls); 53 | isActivated = array.getBoolean(R.styleable.StatusImageButton_status, false); 54 | array.recycle(); 55 | 56 | setActivated(isActivated); 57 | } 58 | 59 | public boolean isActivated() { 60 | return isActivated; 61 | } 62 | 63 | public void setActivated(boolean isActivated) { 64 | this.isActivated = isActivated; 65 | setImageDrawable(isActivated ? activated : defauls); 66 | } 67 | } 68 | -------------------------------------------------------------------------------- /app/src/main/java/io/github/mthli/type/widget/adapter/TypeAdapter.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016 Matthew Lee 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except 5 | * in compliance with the License. You may obtain a copy of the License at 6 | * 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software distributed under the License 10 | * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 11 | * or implied. See the License for the specific language governing permissions and limitations under 12 | * the License. 13 | */ 14 | 15 | package io.github.mthli.type.widget.adapter; 16 | 17 | import android.content.Context; 18 | import android.support.annotation.NonNull; 19 | import android.support.v7.widget.RecyclerView; 20 | import android.view.LayoutInflater; 21 | import android.view.ViewGroup; 22 | 23 | import java.util.List; 24 | 25 | import io.github.mthli.type.R; 26 | import io.github.mthli.type.widget.holder.TypeBlockHolder; 27 | import io.github.mthli.type.widget.holder.TypeDotsHolder; 28 | import io.github.mthli.type.widget.holder.TypeImageHolder; 29 | import io.github.mthli.type.widget.holder.TypeTitleHolder; 30 | import io.github.mthli.type.widget.model.Type; 31 | import io.github.mthli.type.widget.model.TypeBlock; 32 | import io.github.mthli.type.widget.model.TypeImage; 33 | import io.github.mthli.type.widget.model.TypeTitle; 34 | 35 | public class TypeAdapter extends RecyclerView.Adapter { 36 | private LayoutInflater inflater; 37 | private List list; 38 | 39 | public TypeAdapter(@NonNull Context context, @NonNull List list) { 40 | this.inflater = LayoutInflater.from(context); 41 | this.list = list; 42 | } 43 | 44 | @Override 45 | public int getItemCount() { 46 | return list.size(); 47 | } 48 | 49 | @Override 50 | @Type.TypeValue 51 | public int getItemViewType(int position) { 52 | return list.get(position).getType(); 53 | } 54 | 55 | @Override 56 | public RecyclerView.ViewHolder onCreateViewHolder(ViewGroup parent, @Type.TypeValue int type) { 57 | switch (type) { 58 | case Type.TYPE_BLOCK: 59 | return new TypeBlockHolder(inflater.inflate(R.layout.recycler_item_block, parent, false)); 60 | case Type.TYPE_DOTS: 61 | return new TypeDotsHolder(inflater.inflate(R.layout.recycler_item_dots, parent, false)); 62 | case Type.TYPE_IMAGE: 63 | return new TypeImageHolder(inflater.inflate(R.layout.recycler_item_image, parent, false)); 64 | case Type.TYPE_TITLE: 65 | return new TypeTitleHolder(inflater.inflate(R.layout.recycler_item_title, parent, false)); 66 | default: 67 | return new TypeBlockHolder(inflater.inflate(R.layout.recycler_item_block, parent, false)); 68 | } 69 | } 70 | 71 | @Override 72 | public void onBindViewHolder(RecyclerView.ViewHolder holder, int position) { 73 | Type type = list.get(position); 74 | 75 | if (holder instanceof TypeBlockHolder && type instanceof TypeBlock) { 76 | ((TypeBlockHolder) holder).inject((TypeBlock) type); 77 | } else if (holder instanceof TypeImageHolder && type instanceof TypeImage) { 78 | ((TypeImageHolder) holder).inject((TypeImage) type); 79 | } else if (holder instanceof TypeTitleHolder && type instanceof TypeTitle) { 80 | ((TypeTitleHolder) holder).inject((TypeTitle) type); 81 | } 82 | } 83 | } 84 | -------------------------------------------------------------------------------- /app/src/main/java/io/github/mthli/type/widget/holder/TypeBlockHolder.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016 Matthew Lee 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except 5 | * in compliance with the License. You may obtain a copy of the License at 6 | * 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software distributed under the License 10 | * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 11 | * or implied. See the License for the specific language governing permissions and limitations under 12 | * the License. 13 | */ 14 | 15 | package io.github.mthli.type.widget.holder; 16 | 17 | import android.graphics.Bitmap; 18 | import android.support.annotation.NonNull; 19 | import android.support.v7.widget.RecyclerView; 20 | import android.text.Editable; 21 | import android.text.SpannableString; 22 | import android.text.Spanned; 23 | import android.view.KeyEvent; 24 | import android.view.View; 25 | 26 | import com.jakewharton.rxbinding.view.RxView; 27 | import com.jakewharton.rxbinding.widget.RxTextView; 28 | import com.jakewharton.rxbinding.widget.TextViewAfterTextChangeEvent; 29 | 30 | import io.github.mthli.type.R; 31 | import io.github.mthli.type.event.BlockEvent; 32 | import io.github.mthli.type.event.BoldEvent; 33 | import io.github.mthli.type.event.BulletEvent; 34 | import io.github.mthli.type.event.DotsEvent; 35 | import io.github.mthli.type.event.ImageEvent; 36 | import io.github.mthli.type.event.InsertEvent; 37 | import io.github.mthli.type.event.FormatEvent; 38 | import io.github.mthli.type.event.ItalicEvent; 39 | import io.github.mthli.type.event.QuoteEvent; 40 | import io.github.mthli.type.event.StrikethroughEvent; 41 | import io.github.mthli.type.event.UnderlineEvent; 42 | import io.github.mthli.type.util.RxBus; 43 | import io.github.mthli.type.widget.model.Type; 44 | import io.github.mthli.type.widget.model.TypeBlock; 45 | import io.github.mthli.type.widget.text.KnifeText; 46 | import rx.functions.Action1; 47 | 48 | public class TypeBlockHolder extends RecyclerView.ViewHolder { 49 | private View quote; 50 | private View bullet; 51 | private KnifeText content; 52 | private TypeBlock type; 53 | 54 | public TypeBlockHolder(@NonNull View view) { 55 | super(view); 56 | this.quote = view.findViewById(R.id.quote); 57 | this.bullet = view.findViewById(R.id.bullet); 58 | this.content = (KnifeText) view.findViewById(R.id.content); 59 | bind(); 60 | } 61 | 62 | public void inject(TypeBlock type) { 63 | this.type = type; 64 | quote.setVisibility(type.isQuote() ? View.VISIBLE : View.GONE); 65 | bullet.setVisibility(type.isBullet() ? View.VISIBLE : View.GONE); 66 | content.setText(type.getContent()); 67 | } 68 | 69 | private void bind() { 70 | RxView.focusChanges(content).subscribe(new Action1() { 71 | @Override 72 | public void call(Boolean hasFocus) { 73 | if (hasFocus) { 74 | postBlockEvent(); 75 | } 76 | } 77 | }); 78 | 79 | RxTextView.afterTextChangeEvents(content).subscribe(new Action1() { 80 | @Override 81 | public void call(TextViewAfterTextChangeEvent event) { 82 | if (type != null) { 83 | type.setContent(event.editable()); 84 | } 85 | } 86 | }); 87 | 88 | content.setOnKeyListener(new View.OnKeyListener() { 89 | @Override 90 | public boolean onKey(View view, int keyCode, KeyEvent event) { 91 | if (keyCode == KeyEvent.KEYCODE_ENTER) { 92 | if (event.getAction() == KeyEvent.ACTION_DOWN) { 93 | postInsertEvent(Type.TYPE_BLOCK); 94 | } 95 | 96 | return true; 97 | } 98 | 99 | // TODO 100 | 101 | return false; 102 | } 103 | }); 104 | 105 | RxBus.getInstance().toObservable(QuoteEvent.class) 106 | .subscribe(new Action1() { 107 | @Override 108 | public void call(QuoteEvent event) { 109 | if (content.hasFocus()) { 110 | type.setBullet(type.isBullet() ? !type.isBullet() : type.isBullet()); 111 | type.setQuote(!type.isQuote()); 112 | inject(type); 113 | postBlockEvent(); 114 | } 115 | } 116 | }); 117 | 118 | RxBus.getInstance().toObservable(BulletEvent.class) 119 | .subscribe(new Action1() { 120 | @Override 121 | public void call(BulletEvent event) { 122 | if (content.hasFocus()) { 123 | type.setQuote(type.isQuote() ? !type.isQuote() : type.isQuote()); 124 | type.setBullet(!type.isBullet()); 125 | inject(type); 126 | postBlockEvent(); 127 | } 128 | } 129 | }); 130 | 131 | RxBus.getInstance().toObservable(BoldEvent.class) 132 | .subscribe(new Action1() { 133 | @Override 134 | public void call(BoldEvent event) { 135 | if (content.hasFocus()) { 136 | content.bold(!content.contains(KnifeText.FORMAT_BOLD)); 137 | type.setContent(content.getEditableText()); 138 | postFormatEvent(); 139 | } 140 | } 141 | }); 142 | 143 | RxBus.getInstance().toObservable(ItalicEvent.class) 144 | .subscribe(new Action1() { 145 | @Override 146 | public void call(ItalicEvent event) { 147 | if (content.hasFocus()) { 148 | content.italic(!content.contains(KnifeText.FORMAT_ITALIC)); 149 | type.setContent(content.getEditableText()); 150 | postFormatEvent(); 151 | } 152 | } 153 | }); 154 | 155 | RxBus.getInstance().toObservable(UnderlineEvent.class) 156 | .subscribe(new Action1() { 157 | @Override 158 | public void call(UnderlineEvent event) { 159 | if (content.hasFocus()) { 160 | content.underline(!content.contains(KnifeText.FORMAT_UNDERLINE)); 161 | type.setContent(content.getEditableText()); 162 | postFormatEvent(); 163 | } 164 | } 165 | }); 166 | 167 | RxBus.getInstance().toObservable(StrikethroughEvent.class) 168 | .subscribe(new Action1() { 169 | @Override 170 | public void call(StrikethroughEvent event) { 171 | if (content.hasFocus()) { 172 | content.strikethrough(!content.contains(KnifeText.FORMAT_STRIKETHROUGH)); 173 | type.setContent(content.getEditableText()); 174 | postFormatEvent(); 175 | } 176 | } 177 | }); 178 | 179 | // TODO link 180 | 181 | RxBus.getInstance().toObservable(DotsEvent.class) 182 | .subscribe(new Action1() { 183 | @Override 184 | public void call(DotsEvent event) { 185 | if (content.hasFocus()) { 186 | postInsertEvent(Type.TYPE_DOTS); 187 | } 188 | } 189 | }); 190 | 191 | RxBus.getInstance().toObservable(ImageEvent.class) 192 | .subscribe(new Action1() { 193 | @Override 194 | public void call(ImageEvent event) { 195 | if (content.hasFocus()) { 196 | postInsertEvent(Type.TYPE_IMAGE, event.getBitmap()); 197 | } 198 | } 199 | }); 200 | } 201 | 202 | private void postBlockEvent() { 203 | BlockEvent event = new BlockEvent(); 204 | event.setBullet(type.isBullet()); 205 | event.setQuote(type.isQuote()); 206 | RxBus.getInstance().post(event); 207 | } 208 | 209 | private void postFormatEvent() { 210 | FormatEvent event = new FormatEvent(); 211 | event.setBold(content.contains(KnifeText.FORMAT_BOLD)); 212 | event.setItalic(content.contains(KnifeText.FORMAT_ITALIC)); 213 | event.setUnderline(content.contains(KnifeText.FORMAT_UNDERLINE)); 214 | event.setStrikethrough(content.contains(KnifeText.FORMAT_STRIKETHROUGH)); 215 | event.setLink(content.contains(KnifeText.FORMAT_LINK)); 216 | RxBus.getInstance().post(event); 217 | } 218 | 219 | private void postInsertEvent(@Type.TypeValue int type) { 220 | postInsertEvent(type, null); 221 | } 222 | 223 | private void postInsertEvent(@Type.TypeValue int type, Bitmap bitmap) { 224 | Editable editable = content.getEditableText(); 225 | int selectionStart = content.getSelectionStart(); 226 | int selectionEnd = content.getSelectionEnd(); 227 | int length = editable.length(); 228 | Spanned prefix = new SpannableString(editable.subSequence(0, selectionStart)); 229 | Spanned suffix = new SpannableString(editable.subSequence(selectionEnd, length)); 230 | content.setText(prefix); 231 | RxBus.getInstance().post(new InsertEvent(type, getAdapterPosition(), prefix, suffix, bitmap)); 232 | } 233 | } 234 | -------------------------------------------------------------------------------- /app/src/main/java/io/github/mthli/type/widget/holder/TypeDotsHolder.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016 Matthew Lee 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except 5 | * in compliance with the License. You may obtain a copy of the License at 6 | * 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software distributed under the License 10 | * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 11 | * or implied. See the License for the specific language governing permissions and limitations under 12 | * the License. 13 | */ 14 | 15 | package io.github.mthli.type.widget.holder; 16 | 17 | import android.support.annotation.NonNull; 18 | import android.support.v7.widget.RecyclerView; 19 | import android.view.View; 20 | 21 | public class TypeDotsHolder extends RecyclerView.ViewHolder { 22 | public TypeDotsHolder(@NonNull View view) { 23 | super(view); 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /app/src/main/java/io/github/mthli/type/widget/holder/TypeImageHolder.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016 Matthew Lee 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except 5 | * in compliance with the License. You may obtain a copy of the License at 6 | * 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software distributed under the License 10 | * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 11 | * or implied. See the License for the specific language governing permissions and limitations under 12 | * the License. 13 | */ 14 | 15 | package io.github.mthli.type.widget.holder; 16 | 17 | import android.support.annotation.NonNull; 18 | import android.support.v7.widget.AppCompatImageView; 19 | import android.support.v7.widget.RecyclerView; 20 | import android.view.View; 21 | 22 | import io.github.mthli.type.R; 23 | import io.github.mthli.type.widget.model.TypeImage; 24 | 25 | public class TypeImageHolder extends RecyclerView.ViewHolder { 26 | private AppCompatImageView image; 27 | 28 | public TypeImageHolder(@NonNull View view) { 29 | super(view); 30 | image = (AppCompatImageView) view.findViewById(R.id.image); 31 | } 32 | 33 | public void inject(TypeImage type) { 34 | image.setImageBitmap(type.getBitmap()); 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /app/src/main/java/io/github/mthli/type/widget/holder/TypeTitleHolder.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016 Matthew Lee 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except 5 | * in compliance with the License. You may obtain a copy of the License at 6 | * 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software distributed under the License 10 | * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 11 | * or implied. See the License for the specific language governing permissions and limitations under 12 | * the License. 13 | */ 14 | 15 | package io.github.mthli.type.widget.holder; 16 | 17 | import android.support.annotation.NonNull; 18 | import android.support.v7.widget.AppCompatEditText; 19 | import android.support.v7.widget.RecyclerView; 20 | import android.view.View; 21 | 22 | import com.jakewharton.rxbinding.widget.RxTextView; 23 | import com.jakewharton.rxbinding.widget.TextViewAfterTextChangeEvent; 24 | 25 | import io.github.mthli.type.R; 26 | import io.github.mthli.type.widget.model.TypeTitle; 27 | import rx.functions.Action1; 28 | 29 | public class TypeTitleHolder extends RecyclerView.ViewHolder { 30 | private AppCompatEditText title; 31 | private TypeTitle type; 32 | 33 | public TypeTitleHolder(@NonNull View view) { 34 | super(view); 35 | this.title = (AppCompatEditText) view.findViewById(R.id.title); 36 | bind(); 37 | } 38 | 39 | public void inject(TypeTitle type) { 40 | this.type = type; 41 | title.setText(type.getTitle()); 42 | } 43 | 44 | private void bind() { 45 | RxTextView.afterTextChangeEvents(title).subscribe(new Action1() { 46 | @Override 47 | public void call(TextViewAfterTextChangeEvent event) { 48 | if (type != null) { 49 | type.setTitle(event.editable().toString()); 50 | } 51 | } 52 | }); 53 | } 54 | } 55 | -------------------------------------------------------------------------------- /app/src/main/java/io/github/mthli/type/widget/model/Type.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016 Matthew Lee 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except 5 | * in compliance with the License. You may obtain a copy of the License at 6 | * 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software distributed under the License 10 | * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 11 | * or implied. See the License for the specific language governing permissions and limitations under 12 | * the License. 13 | */ 14 | 15 | package io.github.mthli.type.widget.model; 16 | 17 | import android.support.annotation.IntDef; 18 | 19 | import java.lang.annotation.Retention; 20 | import java.lang.annotation.RetentionPolicy; 21 | 22 | public class Type { 23 | public static final int TYPE_BLOCK = 0x100; 24 | public static final int TYPE_DOTS = 0x101; 25 | public static final int TYPE_IMAGE = 0x102; 26 | public static final int TYPE_TITLE = 0x103; 27 | 28 | @IntDef({TYPE_BLOCK, TYPE_DOTS, TYPE_IMAGE, TYPE_TITLE}) 29 | @Retention(RetentionPolicy.SOURCE) 30 | public @interface TypeValue {} 31 | 32 | private int type; 33 | 34 | public Type(@TypeValue int type) { 35 | this.type = type; 36 | } 37 | 38 | @TypeValue 39 | public final int getType() { 40 | return type; 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /app/src/main/java/io/github/mthli/type/widget/model/TypeBlock.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016 Matthew Lee 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except 5 | * in compliance with the License. You may obtain a copy of the License at 6 | * 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software distributed under the License 10 | * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 11 | * or implied. See the License for the specific language governing permissions and limitations under 12 | * the License. 13 | */ 14 | 15 | package io.github.mthli.type.widget.model; 16 | 17 | import android.support.annotation.NonNull; 18 | import android.support.annotation.Nullable; 19 | import android.text.SpannableString; 20 | import android.text.Spanned; 21 | 22 | public class TypeBlock extends Type { 23 | private Spanned content; 24 | private boolean isBullet; 25 | private boolean isQuote; 26 | 27 | public TypeBlock(@Nullable Spanned content) { 28 | super(TYPE_BLOCK); 29 | setContent(content); 30 | } 31 | 32 | @NonNull 33 | public Spanned getContent() { 34 | return content; 35 | } 36 | 37 | public void setContent(@Nullable Spanned content) { 38 | this.content = content != null ? content : new SpannableString(""); 39 | } 40 | 41 | public boolean isBullet() { 42 | return isBullet; 43 | } 44 | 45 | public void setBullet(boolean isBullet) { 46 | this.isBullet = isBullet; 47 | } 48 | 49 | public boolean isQuote() { 50 | return isQuote; 51 | } 52 | 53 | public void setQuote(boolean isQuote) { 54 | this.isQuote = isQuote; 55 | } 56 | } 57 | -------------------------------------------------------------------------------- /app/src/main/java/io/github/mthli/type/widget/model/TypeDots.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016 Matthew Lee 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except 5 | * in compliance with the License. You may obtain a copy of the License at 6 | * 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software distributed under the License 10 | * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 11 | * or implied. See the License for the specific language governing permissions and limitations under 12 | * the License. 13 | */ 14 | 15 | package io.github.mthli.type.widget.model; 16 | 17 | public class TypeDots extends Type { 18 | public TypeDots() { 19 | super(TYPE_DOTS); 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /app/src/main/java/io/github/mthli/type/widget/model/TypeImage.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016 Matthew Lee 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except 5 | * in compliance with the License. You may obtain a copy of the License at 6 | * 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software distributed under the License 10 | * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 11 | * or implied. See the License for the specific language governing permissions and limitations under 12 | * the License. 13 | */ 14 | 15 | package io.github.mthli.type.widget.model; 16 | 17 | import android.graphics.Bitmap; 18 | import android.support.annotation.NonNull; 19 | 20 | public class TypeImage extends Type { 21 | private Bitmap bitmap; 22 | 23 | public TypeImage(@NonNull Bitmap bitmap) { 24 | super(TYPE_IMAGE); 25 | this.bitmap = bitmap; 26 | } 27 | 28 | public Bitmap getBitmap() { 29 | return bitmap; 30 | } 31 | 32 | public void setBitmap(@NonNull Bitmap bitmap) { 33 | this.bitmap = bitmap; 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /app/src/main/java/io/github/mthli/type/widget/model/TypeTitle.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016 Matthew Lee 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except 5 | * in compliance with the License. You may obtain a copy of the License at 6 | * 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software distributed under the License 10 | * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 11 | * or implied. See the License for the specific language governing permissions and limitations under 12 | * the License. 13 | */ 14 | 15 | package io.github.mthli.type.widget.model; 16 | 17 | import android.support.annotation.NonNull; 18 | import android.support.annotation.Nullable; 19 | 20 | public class TypeTitle extends Type { 21 | private String title; 22 | 23 | public TypeTitle(@Nullable String title) { 24 | super(TYPE_TITLE); 25 | setTitle(title); 26 | } 27 | 28 | @NonNull 29 | public String getTitle() { 30 | return title; 31 | } 32 | 33 | public void setTitle(@Nullable String title) { 34 | this.title = title != null ? title : ""; 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /app/src/main/java/io/github/mthli/type/widget/text/KnifePart.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016 Matthew Lee 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except 5 | * in compliance with the License. You may obtain a copy of the License at 6 | * 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software distributed under the License 10 | * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 11 | * or implied. See the License for the specific language governing permissions and limitations under 12 | * the License. 13 | */ 14 | 15 | package io.github.mthli.type.widget.text; 16 | 17 | public class KnifePart { 18 | private int start; 19 | private int end; 20 | 21 | public KnifePart(int start, int end) { 22 | this.start = start; 23 | this.end = end; 24 | } 25 | 26 | public int getStart() { 27 | return start; 28 | } 29 | 30 | public int getEnd() { 31 | return end; 32 | } 33 | 34 | public boolean isValid() { 35 | return start < end; 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /app/src/main/java/io/github/mthli/type/widget/text/KnifeText.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016 Matthew Lee 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except 5 | * in compliance with the License. You may obtain a copy of the License at 6 | * 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software distributed under the License 10 | * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 11 | * or implied. See the License for the specific language governing permissions and limitations under 12 | * the License. 13 | */ 14 | 15 | package io.github.mthli.type.widget.text; 16 | 17 | import android.content.Context; 18 | import android.graphics.Typeface; 19 | import android.support.annotation.IntDef; 20 | import android.support.v7.widget.AppCompatEditText; 21 | import android.text.Spanned; 22 | import android.text.style.StrikethroughSpan; 23 | import android.text.style.StyleSpan; 24 | import android.text.style.UnderlineSpan; 25 | import android.util.AttributeSet; 26 | 27 | import java.lang.annotation.Retention; 28 | import java.lang.annotation.RetentionPolicy; 29 | import java.util.ArrayList; 30 | import java.util.List; 31 | 32 | import io.github.mthli.type.event.FormatEvent; 33 | import io.github.mthli.type.util.RxBus; 34 | 35 | public class KnifeText extends AppCompatEditText { 36 | public static final int FORMAT_BOLD = 0x01; 37 | public static final int FORMAT_ITALIC = 0x02; 38 | public static final int FORMAT_UNDERLINE = 0x03; 39 | public static final int FORMAT_STRIKETHROUGH = 0x04; 40 | public static final int FORMAT_LINK = 0x05; 41 | 42 | @IntDef({FORMAT_BOLD, FORMAT_ITALIC, FORMAT_UNDERLINE, FORMAT_STRIKETHROUGH, FORMAT_LINK}) 43 | @Retention(RetentionPolicy.SOURCE) 44 | public @interface FormatValue {} 45 | 46 | public KnifeText(Context context) { 47 | super(context); 48 | } 49 | 50 | public KnifeText(Context context, AttributeSet attrs) { 51 | super(context, attrs); 52 | } 53 | 54 | public KnifeText(Context context, AttributeSet attrs, int defStyleAttr) { 55 | super(context, attrs, defStyleAttr); 56 | } 57 | 58 | public void bold(boolean valid) { 59 | if (valid) { 60 | styleValid(Typeface.BOLD, getSelectionStart(), getSelectionEnd()); 61 | } else { 62 | styleInvalid(Typeface.BOLD, getSelectionStart(), getSelectionEnd()); 63 | } 64 | } 65 | 66 | public void italic(boolean valid) { 67 | if (valid) { 68 | styleValid(Typeface.ITALIC, getSelectionStart(), getSelectionEnd()); 69 | } else { 70 | styleInvalid(Typeface.ITALIC, getSelectionStart(), getSelectionEnd()); 71 | } 72 | } 73 | 74 | private void styleValid(int style, int start, int end) { 75 | switch (style) { 76 | case Typeface.NORMAL: 77 | case Typeface.BOLD: 78 | case Typeface.ITALIC: 79 | case Typeface.BOLD_ITALIC: 80 | break; 81 | default: 82 | return; 83 | } 84 | 85 | if (start < end) { 86 | getEditableText().setSpan(new StyleSpan(style), start, end, Spanned.SPAN_EXCLUSIVE_EXCLUSIVE); 87 | } 88 | } 89 | 90 | private void styleInvalid(int style, int start, int end) { 91 | switch (style) { 92 | case Typeface.NORMAL: 93 | case Typeface.BOLD: 94 | case Typeface.ITALIC: 95 | case Typeface.BOLD_ITALIC: 96 | break; 97 | default: 98 | return; 99 | } 100 | 101 | if (start >= end) { 102 | return; 103 | } 104 | 105 | StyleSpan[] spans = getEditableText().getSpans(start, end, StyleSpan.class); 106 | List list = new ArrayList<>(); 107 | 108 | for (StyleSpan span : spans) { 109 | if (span.getStyle() == style) { 110 | list.add(new KnifePart(getEditableText().getSpanStart(span), getEditableText().getSpanEnd(span))); 111 | getEditableText().removeSpan(span); 112 | } 113 | } 114 | 115 | for (KnifePart part : list) { 116 | if (part.isValid()) { 117 | if (part.getStart() < start) { 118 | styleValid(style, part.getStart(), start); 119 | } 120 | 121 | if (part.getEnd() > end) { 122 | styleValid(style, end, part.getEnd()); 123 | } 124 | } 125 | } 126 | } 127 | 128 | private boolean containStyle(int style, int start, int end) { 129 | switch (style) { 130 | case Typeface.NORMAL: 131 | case Typeface.BOLD: 132 | case Typeface.ITALIC: 133 | case Typeface.BOLD_ITALIC: 134 | break; 135 | default: 136 | return false; 137 | } 138 | 139 | if (start > end) { 140 | return false; 141 | } 142 | 143 | if (start == end) { 144 | if (start - 1 < 0 || start + 1 > getEditableText().length()) { 145 | return false; 146 | } else { 147 | StyleSpan[] before = getEditableText().getSpans(start - 1, start, StyleSpan.class); 148 | StyleSpan[] after = getEditableText().getSpans(start, start + 1, StyleSpan.class); 149 | return before.length > 0 && after.length > 0 && before[0].getStyle() == style && after[0].getStyle() == style; 150 | } 151 | } else { 152 | StringBuilder builder = new StringBuilder(); 153 | 154 | // Make sure no duplicate characters be added 155 | for (int i = start; i < end; i++) { 156 | StyleSpan[] spans = getEditableText().getSpans(i, i + 1, StyleSpan.class); 157 | for (StyleSpan span : spans) { 158 | if (span.getStyle() == style) { 159 | builder.append(getEditableText().subSequence(i, i + 1).toString()); 160 | break; 161 | } 162 | } 163 | } 164 | 165 | return getEditableText().subSequence(start, end).toString().equals(builder.toString()); 166 | } 167 | } 168 | 169 | public void underline(boolean valid) { 170 | if (valid) { 171 | underlineValid(getSelectionStart(), getSelectionEnd()); 172 | } else { 173 | underlineInvalid(getSelectionStart(), getSelectionEnd()); 174 | } 175 | } 176 | 177 | private void underlineValid(int start, int end) { 178 | if (start < end) { 179 | getEditableText().setSpan(new UnderlineSpan(), start, end, Spanned.SPAN_EXCLUSIVE_EXCLUSIVE); 180 | } 181 | } 182 | 183 | private void underlineInvalid(int start, int end) { 184 | if (start >= end) { 185 | return; 186 | } 187 | 188 | UnderlineSpan[] spans = getEditableText().getSpans(start, end, UnderlineSpan.class); 189 | List list = new ArrayList<>(); 190 | 191 | for (UnderlineSpan span : spans) { 192 | list.add(new KnifePart(getEditableText().getSpanStart(span), getEditableText().getSpanEnd(span))); 193 | getEditableText().removeSpan(span); 194 | } 195 | 196 | for (KnifePart part : list) { 197 | if (part.isValid()) { 198 | if (part.getStart() < start) { 199 | underlineValid(part.getStart(), start); 200 | } 201 | 202 | if (part.getEnd() > end) { 203 | underlineValid(end, part.getEnd()); 204 | } 205 | } 206 | } 207 | } 208 | 209 | private boolean containUnderline(int start, int end) { 210 | if (start > end) { 211 | return false; 212 | } 213 | 214 | if (start == end) { 215 | if (start - 1 < 0 || start + 1 > getEditableText().length()) { 216 | return false; 217 | } else { 218 | UnderlineSpan[] before = getEditableText().getSpans(start - 1, start, UnderlineSpan.class); 219 | UnderlineSpan[] after = getEditableText().getSpans(start, start + 1, UnderlineSpan.class); 220 | return before.length > 0 && after.length > 0; 221 | } 222 | } else { 223 | StringBuilder builder = new StringBuilder(); 224 | 225 | for (int i = start; i < end; i++) { 226 | if (getEditableText().getSpans(i, i + 1, UnderlineSpan.class).length > 0) { 227 | builder.append(getEditableText().subSequence(i, i + 1).toString()); 228 | } 229 | } 230 | 231 | return getEditableText().subSequence(start, end).toString().equals(builder.toString()); 232 | } 233 | } 234 | 235 | public void strikethrough(boolean valid) { 236 | if (valid) { 237 | strikethroughValid(getSelectionStart(), getSelectionEnd()); 238 | } else { 239 | strikethroughInvalid(getSelectionStart(), getSelectionEnd()); 240 | } 241 | } 242 | 243 | private void strikethroughValid(int start, int end) { 244 | if (start < end) { 245 | getEditableText().setSpan(new StrikethroughSpan(), start, end, Spanned.SPAN_EXCLUSIVE_EXCLUSIVE); 246 | } 247 | } 248 | 249 | private void strikethroughInvalid(int start, int end) { 250 | if (start >= end) { 251 | return; 252 | } 253 | 254 | StrikethroughSpan[] spans = getEditableText().getSpans(start, end, StrikethroughSpan.class); 255 | List list = new ArrayList<>(); 256 | 257 | for (StrikethroughSpan span : spans) { 258 | list.add(new KnifePart(getEditableText().getSpanStart(span), getEditableText().getSpanEnd(span))); 259 | getEditableText().removeSpan(span); 260 | } 261 | 262 | for (KnifePart part : list) { 263 | if (part.isValid()) { 264 | if (part.getStart() < start) { 265 | strikethroughValid(part.getStart(), start); 266 | } 267 | 268 | if (part.getEnd() > end) { 269 | strikethroughValid(end, part.getEnd()); 270 | } 271 | } 272 | } 273 | } 274 | 275 | private boolean containStrikethrough(int start, int end) { 276 | if (start > end) { 277 | return false; 278 | } 279 | 280 | if (start == end) { 281 | if (start - 1 < 0 || start + 1 > getEditableText().length()) { 282 | return false; 283 | } else { 284 | StrikethroughSpan[] before = getEditableText().getSpans(start - 1, start, StrikethroughSpan.class); 285 | StrikethroughSpan[] after = getEditableText().getSpans(start, start + 1, StrikethroughSpan.class); 286 | return before.length > 0 && after.length > 0; 287 | } 288 | } else { 289 | StringBuilder builder = new StringBuilder(); 290 | 291 | for (int i = start; i < end; i++) { 292 | if (getEditableText().getSpans(i, i + 1, StrikethroughSpan.class).length > 0) { 293 | builder.append(getEditableText().subSequence(i, i + 1).toString()); 294 | } 295 | } 296 | 297 | return getEditableText().subSequence(start, end).toString().equals(builder.toString()); 298 | } 299 | } 300 | 301 | // TODO link 302 | 303 | public boolean contains(@FormatValue int format) { 304 | switch (format) { 305 | case FORMAT_BOLD: 306 | return containStyle(Typeface.BOLD, getSelectionStart(), getSelectionEnd()); 307 | case FORMAT_ITALIC: 308 | return containStyle(Typeface.ITALIC, getSelectionStart(), getSelectionEnd()); 309 | case FORMAT_UNDERLINE: 310 | return containUnderline(getSelectionStart(), getSelectionEnd()); 311 | case FORMAT_STRIKETHROUGH: 312 | return containStrikethrough(getSelectionStart(), getSelectionEnd()); 313 | case FORMAT_LINK: 314 | // TODO 315 | return false; 316 | default: 317 | return false; 318 | } 319 | } 320 | 321 | public void clearFormats() { 322 | setText(getEditableText().toString()); 323 | setSelection(getEditableText().length()); 324 | } 325 | 326 | @Override 327 | protected void onSelectionChanged(int start, int end) { 328 | if (start >= end) { 329 | return; 330 | } 331 | 332 | FormatEvent event = new FormatEvent(); 333 | event.setBold(contains(FORMAT_BOLD)); 334 | event.setItalic(contains(FORMAT_ITALIC)); 335 | event.setUnderline(contains(FORMAT_UNDERLINE)); 336 | event.setStrikethrough(contains(FORMAT_STRIKETHROUGH)); 337 | event.setLink(contains(FORMAT_LINK)); 338 | RxBus.getInstance().post(event); 339 | } 340 | } 341 | -------------------------------------------------------------------------------- /app/src/main/res/drawable-hdpi/ic_attachment.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mthli/Type/bec0caee307e1be7042df5672a4fc27a945fb755/app/src/main/res/drawable-hdpi/ic_attachment.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-hdpi/ic_bold_activated.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mthli/Type/bec0caee307e1be7042df5672a4fc27a945fb755/app/src/main/res/drawable-hdpi/ic_bold_activated.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-hdpi/ic_bold_default.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mthli/Type/bec0caee307e1be7042df5672a4fc27a945fb755/app/src/main/res/drawable-hdpi/ic_bold_default.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-hdpi/ic_bullet_activated.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mthli/Type/bec0caee307e1be7042df5672a4fc27a945fb755/app/src/main/res/drawable-hdpi/ic_bullet_activated.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-hdpi/ic_bullet_default.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mthli/Type/bec0caee307e1be7042df5672a4fc27a945fb755/app/src/main/res/drawable-hdpi/ic_bullet_default.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-hdpi/ic_dots.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mthli/Type/bec0caee307e1be7042df5672a4fc27a945fb755/app/src/main/res/drawable-hdpi/ic_dots.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-hdpi/ic_italic_activated.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mthli/Type/bec0caee307e1be7042df5672a4fc27a945fb755/app/src/main/res/drawable-hdpi/ic_italic_activated.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-hdpi/ic_italic_default.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mthli/Type/bec0caee307e1be7042df5672a4fc27a945fb755/app/src/main/res/drawable-hdpi/ic_italic_default.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-hdpi/ic_link_activated.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mthli/Type/bec0caee307e1be7042df5672a4fc27a945fb755/app/src/main/res/drawable-hdpi/ic_link_activated.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-hdpi/ic_link_default.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mthli/Type/bec0caee307e1be7042df5672a4fc27a945fb755/app/src/main/res/drawable-hdpi/ic_link_default.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-hdpi/ic_play.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mthli/Type/bec0caee307e1be7042df5672a4fc27a945fb755/app/src/main/res/drawable-hdpi/ic_play.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-hdpi/ic_quote_activated.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mthli/Type/bec0caee307e1be7042df5672a4fc27a945fb755/app/src/main/res/drawable-hdpi/ic_quote_activated.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-hdpi/ic_quote_default.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mthli/Type/bec0caee307e1be7042df5672a4fc27a945fb755/app/src/main/res/drawable-hdpi/ic_quote_default.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-hdpi/ic_strikethrough_activated.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mthli/Type/bec0caee307e1be7042df5672a4fc27a945fb755/app/src/main/res/drawable-hdpi/ic_strikethrough_activated.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-hdpi/ic_strikethrough_default.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mthli/Type/bec0caee307e1be7042df5672a4fc27a945fb755/app/src/main/res/drawable-hdpi/ic_strikethrough_default.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-hdpi/ic_underline_activated.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mthli/Type/bec0caee307e1be7042df5672a4fc27a945fb755/app/src/main/res/drawable-hdpi/ic_underline_activated.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-hdpi/ic_underline_default.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mthli/Type/bec0caee307e1be7042df5672a4fc27a945fb755/app/src/main/res/drawable-hdpi/ic_underline_default.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-mdpi/ic_attachment.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mthli/Type/bec0caee307e1be7042df5672a4fc27a945fb755/app/src/main/res/drawable-mdpi/ic_attachment.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-mdpi/ic_bold_activated.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mthli/Type/bec0caee307e1be7042df5672a4fc27a945fb755/app/src/main/res/drawable-mdpi/ic_bold_activated.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-mdpi/ic_bold_default.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mthli/Type/bec0caee307e1be7042df5672a4fc27a945fb755/app/src/main/res/drawable-mdpi/ic_bold_default.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-mdpi/ic_bullet_activated.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mthli/Type/bec0caee307e1be7042df5672a4fc27a945fb755/app/src/main/res/drawable-mdpi/ic_bullet_activated.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-mdpi/ic_bullet_default.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mthli/Type/bec0caee307e1be7042df5672a4fc27a945fb755/app/src/main/res/drawable-mdpi/ic_bullet_default.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-mdpi/ic_dots.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mthli/Type/bec0caee307e1be7042df5672a4fc27a945fb755/app/src/main/res/drawable-mdpi/ic_dots.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-mdpi/ic_italic_activated.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mthli/Type/bec0caee307e1be7042df5672a4fc27a945fb755/app/src/main/res/drawable-mdpi/ic_italic_activated.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-mdpi/ic_italic_default.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mthli/Type/bec0caee307e1be7042df5672a4fc27a945fb755/app/src/main/res/drawable-mdpi/ic_italic_default.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-mdpi/ic_link_activated.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mthli/Type/bec0caee307e1be7042df5672a4fc27a945fb755/app/src/main/res/drawable-mdpi/ic_link_activated.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-mdpi/ic_link_default.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mthli/Type/bec0caee307e1be7042df5672a4fc27a945fb755/app/src/main/res/drawable-mdpi/ic_link_default.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-mdpi/ic_play.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mthli/Type/bec0caee307e1be7042df5672a4fc27a945fb755/app/src/main/res/drawable-mdpi/ic_play.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-mdpi/ic_quote_activated.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mthli/Type/bec0caee307e1be7042df5672a4fc27a945fb755/app/src/main/res/drawable-mdpi/ic_quote_activated.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-mdpi/ic_quote_default.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mthli/Type/bec0caee307e1be7042df5672a4fc27a945fb755/app/src/main/res/drawable-mdpi/ic_quote_default.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-mdpi/ic_strikethrough_activated.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mthli/Type/bec0caee307e1be7042df5672a4fc27a945fb755/app/src/main/res/drawable-mdpi/ic_strikethrough_activated.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-mdpi/ic_strikethrough_default.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mthli/Type/bec0caee307e1be7042df5672a4fc27a945fb755/app/src/main/res/drawable-mdpi/ic_strikethrough_default.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-mdpi/ic_underline_activated.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mthli/Type/bec0caee307e1be7042df5672a4fc27a945fb755/app/src/main/res/drawable-mdpi/ic_underline_activated.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-mdpi/ic_underline_default.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mthli/Type/bec0caee307e1be7042df5672a4fc27a945fb755/app/src/main/res/drawable-mdpi/ic_underline_default.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-xhdpi/ic_attachment.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mthli/Type/bec0caee307e1be7042df5672a4fc27a945fb755/app/src/main/res/drawable-xhdpi/ic_attachment.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-xhdpi/ic_bold_activated.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mthli/Type/bec0caee307e1be7042df5672a4fc27a945fb755/app/src/main/res/drawable-xhdpi/ic_bold_activated.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-xhdpi/ic_bold_default.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mthli/Type/bec0caee307e1be7042df5672a4fc27a945fb755/app/src/main/res/drawable-xhdpi/ic_bold_default.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-xhdpi/ic_bullet_activated.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mthli/Type/bec0caee307e1be7042df5672a4fc27a945fb755/app/src/main/res/drawable-xhdpi/ic_bullet_activated.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-xhdpi/ic_bullet_default.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mthli/Type/bec0caee307e1be7042df5672a4fc27a945fb755/app/src/main/res/drawable-xhdpi/ic_bullet_default.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-xhdpi/ic_dots.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mthli/Type/bec0caee307e1be7042df5672a4fc27a945fb755/app/src/main/res/drawable-xhdpi/ic_dots.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-xhdpi/ic_italic_activated.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mthli/Type/bec0caee307e1be7042df5672a4fc27a945fb755/app/src/main/res/drawable-xhdpi/ic_italic_activated.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-xhdpi/ic_italic_default.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mthli/Type/bec0caee307e1be7042df5672a4fc27a945fb755/app/src/main/res/drawable-xhdpi/ic_italic_default.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-xhdpi/ic_link_activated.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mthli/Type/bec0caee307e1be7042df5672a4fc27a945fb755/app/src/main/res/drawable-xhdpi/ic_link_activated.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-xhdpi/ic_link_default.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mthli/Type/bec0caee307e1be7042df5672a4fc27a945fb755/app/src/main/res/drawable-xhdpi/ic_link_default.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-xhdpi/ic_play.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mthli/Type/bec0caee307e1be7042df5672a4fc27a945fb755/app/src/main/res/drawable-xhdpi/ic_play.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-xhdpi/ic_quote_activated.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mthli/Type/bec0caee307e1be7042df5672a4fc27a945fb755/app/src/main/res/drawable-xhdpi/ic_quote_activated.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-xhdpi/ic_quote_default.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mthli/Type/bec0caee307e1be7042df5672a4fc27a945fb755/app/src/main/res/drawable-xhdpi/ic_quote_default.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-xhdpi/ic_strikethrough_activated.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mthli/Type/bec0caee307e1be7042df5672a4fc27a945fb755/app/src/main/res/drawable-xhdpi/ic_strikethrough_activated.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-xhdpi/ic_strikethrough_default.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mthli/Type/bec0caee307e1be7042df5672a4fc27a945fb755/app/src/main/res/drawable-xhdpi/ic_strikethrough_default.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-xhdpi/ic_underline_activated.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mthli/Type/bec0caee307e1be7042df5672a4fc27a945fb755/app/src/main/res/drawable-xhdpi/ic_underline_activated.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-xhdpi/ic_underline_default.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mthli/Type/bec0caee307e1be7042df5672a4fc27a945fb755/app/src/main/res/drawable-xhdpi/ic_underline_default.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-xxhdpi/ic_attachment.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mthli/Type/bec0caee307e1be7042df5672a4fc27a945fb755/app/src/main/res/drawable-xxhdpi/ic_attachment.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-xxhdpi/ic_bold_activated.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mthli/Type/bec0caee307e1be7042df5672a4fc27a945fb755/app/src/main/res/drawable-xxhdpi/ic_bold_activated.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-xxhdpi/ic_bold_default.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mthli/Type/bec0caee307e1be7042df5672a4fc27a945fb755/app/src/main/res/drawable-xxhdpi/ic_bold_default.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-xxhdpi/ic_bullet_activated.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mthli/Type/bec0caee307e1be7042df5672a4fc27a945fb755/app/src/main/res/drawable-xxhdpi/ic_bullet_activated.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-xxhdpi/ic_bullet_default.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mthli/Type/bec0caee307e1be7042df5672a4fc27a945fb755/app/src/main/res/drawable-xxhdpi/ic_bullet_default.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-xxhdpi/ic_dots.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mthli/Type/bec0caee307e1be7042df5672a4fc27a945fb755/app/src/main/res/drawable-xxhdpi/ic_dots.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-xxhdpi/ic_italic_activated.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mthli/Type/bec0caee307e1be7042df5672a4fc27a945fb755/app/src/main/res/drawable-xxhdpi/ic_italic_activated.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-xxhdpi/ic_italic_default.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mthli/Type/bec0caee307e1be7042df5672a4fc27a945fb755/app/src/main/res/drawable-xxhdpi/ic_italic_default.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-xxhdpi/ic_link_activated.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mthli/Type/bec0caee307e1be7042df5672a4fc27a945fb755/app/src/main/res/drawable-xxhdpi/ic_link_activated.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-xxhdpi/ic_link_default.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mthli/Type/bec0caee307e1be7042df5672a4fc27a945fb755/app/src/main/res/drawable-xxhdpi/ic_link_default.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-xxhdpi/ic_play.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mthli/Type/bec0caee307e1be7042df5672a4fc27a945fb755/app/src/main/res/drawable-xxhdpi/ic_play.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-xxhdpi/ic_quote_activated.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mthli/Type/bec0caee307e1be7042df5672a4fc27a945fb755/app/src/main/res/drawable-xxhdpi/ic_quote_activated.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-xxhdpi/ic_quote_default.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mthli/Type/bec0caee307e1be7042df5672a4fc27a945fb755/app/src/main/res/drawable-xxhdpi/ic_quote_default.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-xxhdpi/ic_strikethrough_activated.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mthli/Type/bec0caee307e1be7042df5672a4fc27a945fb755/app/src/main/res/drawable-xxhdpi/ic_strikethrough_activated.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-xxhdpi/ic_strikethrough_default.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mthli/Type/bec0caee307e1be7042df5672a4fc27a945fb755/app/src/main/res/drawable-xxhdpi/ic_strikethrough_default.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-xxhdpi/ic_underline_activated.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mthli/Type/bec0caee307e1be7042df5672a4fc27a945fb755/app/src/main/res/drawable-xxhdpi/ic_underline_activated.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-xxhdpi/ic_underline_default.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mthli/Type/bec0caee307e1be7042df5672a4fc27a945fb755/app/src/main/res/drawable-xxhdpi/ic_underline_default.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-xxxhdpi/ic_attachment.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mthli/Type/bec0caee307e1be7042df5672a4fc27a945fb755/app/src/main/res/drawable-xxxhdpi/ic_attachment.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-xxxhdpi/ic_bold_activated.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mthli/Type/bec0caee307e1be7042df5672a4fc27a945fb755/app/src/main/res/drawable-xxxhdpi/ic_bold_activated.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-xxxhdpi/ic_bold_default.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mthli/Type/bec0caee307e1be7042df5672a4fc27a945fb755/app/src/main/res/drawable-xxxhdpi/ic_bold_default.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-xxxhdpi/ic_bullet_activated.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mthli/Type/bec0caee307e1be7042df5672a4fc27a945fb755/app/src/main/res/drawable-xxxhdpi/ic_bullet_activated.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-xxxhdpi/ic_bullet_default.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mthli/Type/bec0caee307e1be7042df5672a4fc27a945fb755/app/src/main/res/drawable-xxxhdpi/ic_bullet_default.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-xxxhdpi/ic_dots.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mthli/Type/bec0caee307e1be7042df5672a4fc27a945fb755/app/src/main/res/drawable-xxxhdpi/ic_dots.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-xxxhdpi/ic_italic_activated.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mthli/Type/bec0caee307e1be7042df5672a4fc27a945fb755/app/src/main/res/drawable-xxxhdpi/ic_italic_activated.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-xxxhdpi/ic_italic_default.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mthli/Type/bec0caee307e1be7042df5672a4fc27a945fb755/app/src/main/res/drawable-xxxhdpi/ic_italic_default.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-xxxhdpi/ic_link_activated.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mthli/Type/bec0caee307e1be7042df5672a4fc27a945fb755/app/src/main/res/drawable-xxxhdpi/ic_link_activated.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-xxxhdpi/ic_link_default.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mthli/Type/bec0caee307e1be7042df5672a4fc27a945fb755/app/src/main/res/drawable-xxxhdpi/ic_link_default.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-xxxhdpi/ic_play.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mthli/Type/bec0caee307e1be7042df5672a4fc27a945fb755/app/src/main/res/drawable-xxxhdpi/ic_play.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-xxxhdpi/ic_quote_activated.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mthli/Type/bec0caee307e1be7042df5672a4fc27a945fb755/app/src/main/res/drawable-xxxhdpi/ic_quote_activated.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-xxxhdpi/ic_quote_default.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mthli/Type/bec0caee307e1be7042df5672a4fc27a945fb755/app/src/main/res/drawable-xxxhdpi/ic_quote_default.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-xxxhdpi/ic_strikethrough_activated.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mthli/Type/bec0caee307e1be7042df5672a4fc27a945fb755/app/src/main/res/drawable-xxxhdpi/ic_strikethrough_activated.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-xxxhdpi/ic_strikethrough_default.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mthli/Type/bec0caee307e1be7042df5672a4fc27a945fb755/app/src/main/res/drawable-xxxhdpi/ic_strikethrough_default.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-xxxhdpi/ic_underline_activated.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mthli/Type/bec0caee307e1be7042df5672a4fc27a945fb755/app/src/main/res/drawable-xxxhdpi/ic_underline_activated.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-xxxhdpi/ic_underline_default.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mthli/Type/bec0caee307e1be7042df5672a4fc27a945fb755/app/src/main/res/drawable-xxxhdpi/ic_underline_default.png -------------------------------------------------------------------------------- /app/src/main/res/drawable/shape_bullet.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 16 | 17 | 19 | 20 | 21 | 22 | -------------------------------------------------------------------------------- /app/src/main/res/layout/activity_main.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 16 | 17 | 22 | 23 | 27 | 28 | 33 | 34 | 43 | 44 | 45 | 54 | 55 | 56 | 64 | 65 | 66 | 74 | 75 | 76 | 84 | 85 | 86 | 87 | 88 | 94 | 95 | 104 | 105 | 106 | 115 | 116 | 117 | 126 | 127 | 128 | 137 | 138 | 139 | 148 | 149 | 150 | 151 | 152 | 153 | 154 | 160 | 161 | 162 | 163 | -------------------------------------------------------------------------------- /app/src/main/res/layout/recycler_item_block.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 16 | 17 | 20 | 21 | 26 | 27 | 28 | 32 | 33 | 41 | 42 | 43 | 52 | 53 | 54 | 55 | 56 | -------------------------------------------------------------------------------- /app/src/main/res/layout/recycler_item_dots.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 16 | 17 | 21 | 22 | 29 | 30 | 31 | -------------------------------------------------------------------------------- /app/src/main/res/layout/recycler_item_image.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 16 | 17 | 20 | 21 | 29 | 30 | 31 | -------------------------------------------------------------------------------- /app/src/main/res/layout/recycler_item_title.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 16 | 17 | 20 | 21 | 31 | 32 | 33 | -------------------------------------------------------------------------------- /app/src/main/res/mipmap-hdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mthli/Type/bec0caee307e1be7042df5672a4fc27a945fb755/app/src/main/res/mipmap-hdpi/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-mdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mthli/Type/bec0caee307e1be7042df5672a4fc27a945fb755/app/src/main/res/mipmap-mdpi/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mthli/Type/bec0caee307e1be7042df5672a4fc27a945fb755/app/src/main/res/mipmap-xhdpi/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mthli/Type/bec0caee307e1be7042df5672a4fc27a945fb755/app/src/main/res/mipmap-xxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xxxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mthli/Type/bec0caee307e1be7042df5672a4fc27a945fb755/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/res/values/attrs.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | -------------------------------------------------------------------------------- /app/src/main/res/values/colors.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 16 | 17 | 18 | 19 | @android:color/black 20 | @android:color/white 21 | @android:color/transparent 22 | 23 | @color/white 24 | @color/text_hint 25 | @color/white 26 | 27 | @color/text_primary 28 | 29 | #DE000000 30 | #8A000000 31 | #61000000 32 | 33 | 34 | -------------------------------------------------------------------------------- /app/src/main/res/values/dimens.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 16 | 17 | 18 | 19 | 3dp 20 | 24dp 21 | 22 | 44dp 23 | 36dp 24 | 8dp 25 | 4dp 26 | 27 | 16dp 28 | 8dp 29 | 30 | 20dp 31 | 16dp 32 | 12dp 33 | 6dp 34 | 35 | 40dp 36 | 8dp 37 | 4dp 38 | 3dp 39 | 40 | -------------------------------------------------------------------------------- /app/src/main/res/values/strings.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 16 | 17 | 18 | 19 | 20 | Type 21 | 22 | 23 | Title 24 | 25 | 26 | Bullet 27 | Quote 28 | Attachment 29 | Dots 30 | Play 31 | Bold 32 | Italic 33 | Underline 34 | Strikethrough 35 | Link 36 | 37 | Add image failed. 38 | 39 | 40 | 41 | -------------------------------------------------------------------------------- /app/src/main/res/values/styles.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 16 | 17 | 18 | 19 | 24 | 25 | 28 | 29 | 32 | 33 | 43 | 44 | 56 | 57 | 61 | 62 | 63 | -------------------------------------------------------------------------------- /build.gradle: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016 Matthew Lee 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except 5 | * in compliance with the License. You may obtain a copy of the License at 6 | * 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software distributed under the License 10 | * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 11 | * or implied. See the License for the specific language governing permissions and limitations under 12 | * the License. 13 | */ 14 | 15 | buildscript { 16 | repositories { 17 | jcenter() 18 | maven { url 'https://jitpack.io' } 19 | } 20 | 21 | dependencies { 22 | classpath 'com.android.tools.build:gradle:2.0.0' 23 | } 24 | } 25 | 26 | allprojects { 27 | repositories { 28 | jcenter() 29 | maven { url 'https://jitpack.io' } 30 | } 31 | } 32 | 33 | task clean(type: Delete) { 34 | delete rootProject.buildDir 35 | } 36 | -------------------------------------------------------------------------------- /gradle.properties: -------------------------------------------------------------------------------- 1 | # Copyright 2016 Matthew Lee 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except 4 | # in compliance with the License. You may obtain a copy of the License at 5 | # 6 | # http://www.apache.org/licenses/LICENSE-2.0 7 | # 8 | # Unless required by applicable law or agreed to in writing, software distributed under the License 9 | # is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 10 | # or implied. See the License for the specific language governing permissions and limitations under 11 | # the License. 12 | 13 | # Project-wide Gradle settings. 14 | 15 | # IDE (e.g. Android Studio) users: 16 | # Gradle settings configured through the IDE *will override* 17 | # any settings specified in this file. 18 | 19 | # For more details on how to configure your build environment visit 20 | # http://www.gradle.org/docs/current/userguide/build_environment.html 21 | 22 | # Specifies the JVM arguments used for the daemon process. 23 | # The setting is particularly useful for tweaking memory settings. 24 | # Default value: -Xmx10248m -XX:MaxPermSize=256m 25 | # org.gradle.jvmargs=-Xmx2048m -XX:MaxPermSize=512m -XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF-8 26 | 27 | # When configured, Gradle will run in incubating parallel mode. 28 | # This option should only be used with decoupled projects. More details, visit 29 | # http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects 30 | # org.gradle.parallel=true -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mthli/Type/bec0caee307e1be7042df5672a4fc27a945fb755/gradle/wrapper/gradle-wrapper.jar -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.properties: -------------------------------------------------------------------------------- 1 | #Fri Apr 08 09:17:42 CST 2016 2 | distributionBase=GRADLE_USER_HOME 3 | distributionPath=wrapper/dists 4 | zipStoreBase=GRADLE_USER_HOME 5 | zipStorePath=wrapper/dists 6 | distributionUrl=https\://services.gradle.org/distributions/gradle-2.10-all.zip 7 | -------------------------------------------------------------------------------- /gradlew: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | ############################################################################## 4 | ## 5 | ## Gradle start up script for UN*X 6 | ## 7 | ############################################################################## 8 | 9 | # Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. 10 | DEFAULT_JVM_OPTS="" 11 | 12 | APP_NAME="Gradle" 13 | APP_BASE_NAME=`basename "$0"` 14 | 15 | # Use the maximum available, or set MAX_FD != -1 to use that value. 16 | MAX_FD="maximum" 17 | 18 | warn ( ) { 19 | echo "$*" 20 | } 21 | 22 | die ( ) { 23 | echo 24 | echo "$*" 25 | echo 26 | exit 1 27 | } 28 | 29 | # OS specific support (must be 'true' or 'false'). 30 | cygwin=false 31 | msys=false 32 | darwin=false 33 | case "`uname`" in 34 | CYGWIN* ) 35 | cygwin=true 36 | ;; 37 | Darwin* ) 38 | darwin=true 39 | ;; 40 | MINGW* ) 41 | msys=true 42 | ;; 43 | esac 44 | 45 | # Attempt to set APP_HOME 46 | # Resolve links: $0 may be a link 47 | PRG="$0" 48 | # Need this for relative symlinks. 49 | while [ -h "$PRG" ] ; do 50 | ls=`ls -ld "$PRG"` 51 | link=`expr "$ls" : '.*-> \(.*\)$'` 52 | if expr "$link" : '/.*' > /dev/null; then 53 | PRG="$link" 54 | else 55 | PRG=`dirname "$PRG"`"/$link" 56 | fi 57 | done 58 | SAVED="`pwd`" 59 | cd "`dirname \"$PRG\"`/" >/dev/null 60 | APP_HOME="`pwd -P`" 61 | cd "$SAVED" >/dev/null 62 | 63 | CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar 64 | 65 | # Determine the Java command to use to start the JVM. 66 | if [ -n "$JAVA_HOME" ] ; then 67 | if [ -x "$JAVA_HOME/jre/sh/java" ] ; then 68 | # IBM's JDK on AIX uses strange locations for the executables 69 | JAVACMD="$JAVA_HOME/jre/sh/java" 70 | else 71 | JAVACMD="$JAVA_HOME/bin/java" 72 | fi 73 | if [ ! -x "$JAVACMD" ] ; then 74 | die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME 75 | 76 | Please set the JAVA_HOME variable in your environment to match the 77 | location of your Java installation." 78 | fi 79 | else 80 | JAVACMD="java" 81 | which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 82 | 83 | Please set the JAVA_HOME variable in your environment to match the 84 | location of your Java installation." 85 | fi 86 | 87 | # Increase the maximum file descriptors if we can. 88 | if [ "$cygwin" = "false" -a "$darwin" = "false" ] ; then 89 | MAX_FD_LIMIT=`ulimit -H -n` 90 | if [ $? -eq 0 ] ; then 91 | if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then 92 | MAX_FD="$MAX_FD_LIMIT" 93 | fi 94 | ulimit -n $MAX_FD 95 | if [ $? -ne 0 ] ; then 96 | warn "Could not set maximum file descriptor limit: $MAX_FD" 97 | fi 98 | else 99 | warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT" 100 | fi 101 | fi 102 | 103 | # For Darwin, add options to specify how the application appears in the dock 104 | if $darwin; then 105 | GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\"" 106 | fi 107 | 108 | # For Cygwin, switch paths to Windows format before running java 109 | if $cygwin ; then 110 | APP_HOME=`cygpath --path --mixed "$APP_HOME"` 111 | CLASSPATH=`cygpath --path --mixed "$CLASSPATH"` 112 | JAVACMD=`cygpath --unix "$JAVACMD"` 113 | 114 | # We build the pattern for arguments to be converted via cygpath 115 | ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null` 116 | SEP="" 117 | for dir in $ROOTDIRSRAW ; do 118 | ROOTDIRS="$ROOTDIRS$SEP$dir" 119 | SEP="|" 120 | done 121 | OURCYGPATTERN="(^($ROOTDIRS))" 122 | # Add a user-defined pattern to the cygpath arguments 123 | if [ "$GRADLE_CYGPATTERN" != "" ] ; then 124 | OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)" 125 | fi 126 | # Now convert the arguments - kludge to limit ourselves to /bin/sh 127 | i=0 128 | for arg in "$@" ; do 129 | CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -` 130 | CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option 131 | 132 | if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition 133 | eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"` 134 | else 135 | eval `echo args$i`="\"$arg\"" 136 | fi 137 | i=$((i+1)) 138 | done 139 | case $i in 140 | (0) set -- ;; 141 | (1) set -- "$args0" ;; 142 | (2) set -- "$args0" "$args1" ;; 143 | (3) set -- "$args0" "$args1" "$args2" ;; 144 | (4) set -- "$args0" "$args1" "$args2" "$args3" ;; 145 | (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;; 146 | (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;; 147 | (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;; 148 | (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;; 149 | (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;; 150 | esac 151 | fi 152 | 153 | # Split up the JVM_OPTS And GRADLE_OPTS values into an array, following the shell quoting and substitution rules 154 | function splitJvmOpts() { 155 | JVM_OPTS=("$@") 156 | } 157 | eval splitJvmOpts $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS 158 | JVM_OPTS[${#JVM_OPTS[*]}]="-Dorg.gradle.appname=$APP_BASE_NAME" 159 | 160 | exec "$JAVACMD" "${JVM_OPTS[@]}" -classpath "$CLASSPATH" org.gradle.wrapper.GradleWrapperMain "$@" 161 | -------------------------------------------------------------------------------- /gradlew.bat: -------------------------------------------------------------------------------- 1 | @if "%DEBUG%" == "" @echo off 2 | @rem ########################################################################## 3 | @rem 4 | @rem Gradle startup script for Windows 5 | @rem 6 | @rem ########################################################################## 7 | 8 | @rem Set local scope for the variables with windows NT shell 9 | if "%OS%"=="Windows_NT" setlocal 10 | 11 | @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. 12 | set DEFAULT_JVM_OPTS= 13 | 14 | set DIRNAME=%~dp0 15 | if "%DIRNAME%" == "" set DIRNAME=. 16 | set APP_BASE_NAME=%~n0 17 | set APP_HOME=%DIRNAME% 18 | 19 | @rem Find java.exe 20 | if defined JAVA_HOME goto findJavaFromJavaHome 21 | 22 | set JAVA_EXE=java.exe 23 | %JAVA_EXE% -version >NUL 2>&1 24 | if "%ERRORLEVEL%" == "0" goto init 25 | 26 | echo. 27 | echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 28 | echo. 29 | echo Please set the JAVA_HOME variable in your environment to match the 30 | echo location of your Java installation. 31 | 32 | goto fail 33 | 34 | :findJavaFromJavaHome 35 | set JAVA_HOME=%JAVA_HOME:"=% 36 | set JAVA_EXE=%JAVA_HOME%/bin/java.exe 37 | 38 | if exist "%JAVA_EXE%" goto init 39 | 40 | echo. 41 | echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% 42 | echo. 43 | echo Please set the JAVA_HOME variable in your environment to match the 44 | echo location of your Java installation. 45 | 46 | goto fail 47 | 48 | :init 49 | @rem Get command-line arguments, handling Windowz variants 50 | 51 | if not "%OS%" == "Windows_NT" goto win9xME_args 52 | if "%@eval[2+2]" == "4" goto 4NT_args 53 | 54 | :win9xME_args 55 | @rem Slurp the command line arguments. 56 | set CMD_LINE_ARGS= 57 | set _SKIP=2 58 | 59 | :win9xME_args_slurp 60 | if "x%~1" == "x" goto execute 61 | 62 | set CMD_LINE_ARGS=%* 63 | goto execute 64 | 65 | :4NT_args 66 | @rem Get arguments from the 4NT Shell from JP Software 67 | set CMD_LINE_ARGS=%$ 68 | 69 | :execute 70 | @rem Setup the command line 71 | 72 | set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar 73 | 74 | @rem Execute Gradle 75 | "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS% 76 | 77 | :end 78 | @rem End local scope for the variables with windows NT shell 79 | if "%ERRORLEVEL%"=="0" goto mainEnd 80 | 81 | :fail 82 | rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of 83 | rem the _cmd.exe /c_ return code! 84 | if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1 85 | exit /b 1 86 | 87 | :mainEnd 88 | if "%OS%"=="Windows_NT" endlocal 89 | 90 | :omega 91 | -------------------------------------------------------------------------------- /settings.gradle: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016 Matthew Lee 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except 5 | * in compliance with the License. You may obtain a copy of the License at 6 | * 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software distributed under the License 10 | * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 11 | * or implied. See the License for the specific language governing permissions and limitations under 12 | * the License. 13 | */ 14 | 15 | include ':app' 16 | --------------------------------------------------------------------------------