├── .gitignore ├── .travis.yml ├── LICENSE ├── README.md ├── app ├── .gitignore ├── build.gradle ├── proguard-rules.pro └── src │ ├── androidTest │ └── java │ │ └── com │ │ └── graffity │ │ └── ApplicationTest.java │ └── main │ ├── AndroidManifest.xml │ ├── kotlin │ └── com │ │ └── graffity │ │ ├── MainActivity.kt │ │ └── User.kt │ └── res │ ├── layout │ └── activity_main.xml │ ├── menu │ └── menu_main.xml │ ├── mipmap-hdpi │ └── ic_launcher.png │ ├── mipmap-mdpi │ └── ic_launcher.png │ ├── mipmap-xhdpi │ └── ic_launcher.png │ ├── mipmap-xxhdpi │ └── ic_launcher.png │ ├── values-v21 │ └── styles.xml │ ├── values-w820dp │ └── dimens.xml │ └── values │ ├── dimens.xml │ ├── strings.xml │ └── styles.xml ├── art ├── kotlin-database.png ├── kotlin-database.svg ├── kotlin-sharedpreferences.png └── kotlin-sharedpreferences.svg ├── build.gradle ├── gradle.properties ├── gradle └── wrapper │ ├── gradle-wrapper.jar │ └── gradle-wrapper.properties ├── gradlew ├── gradlew.bat ├── kotlinx-android-app ├── .gitignore ├── build.gradle ├── proguard-rules.pro └── src │ └── main │ ├── AndroidManifest.xml │ └── kotlin │ └── kotlinx │ └── android │ └── app │ ├── ActivityExt.kt │ └── FragmentExt.kt ├── kotlinx-android-database ├── .gitignore ├── android-javadoc.gradle ├── build.gradle ├── proguard-rules.pro └── src │ └── main │ ├── AndroidManifest.xml │ └── kotlin │ └── kotlinx │ └── android │ └── database │ ├── CursorExt.kt │ └── SQLiteDatabaseExt.kt ├── kotlinx-android-notification ├── .gitignore ├── android-javadoc.gradle ├── build.gradle ├── proguard-rules.pro └── src │ └── main │ ├── AndroidManifest.xml │ └── kotlin │ └── kotlinx │ └── android │ └── notification │ └── NotificationExt.kt ├── kotlinx-android-sharedpreferences ├── .gitignore ├── android-javadoc.gradle ├── build.gradle ├── proguard-rules.pro └── src │ └── main │ ├── AndroidManifest.xml │ └── kotlin │ └── kotlinx │ └── android │ └── sharedpreferences │ ├── Preferences.kt │ └── SharedPreferencesExt.kt ├── kotlinx-android-support-v4 ├── .gitignore ├── build.gradle ├── proguard-rules.pro └── src │ └── main │ ├── AndroidManifest.xml │ └── kotlin │ └── kotlinx │ └── android │ └── support │ └── v4 │ ├── ActivityExt.kt │ └── FragmentExt.kt ├── kotlinx-android-system-services ├── .gitignore ├── android-javadoc.gradle ├── build.gradle ├── proguard-rules.pro └── src │ └── main │ ├── AndroidManifest.xml │ └── kotlin │ └── kotlinx │ └── android │ └── system │ └── services │ └── SystemServicesExt.kt ├── kotlinx-android-view ├── .gitignore ├── android-javadoc.gradle ├── build.gradle ├── proguard-rules.pro └── src │ └── main │ ├── AndroidManifest.xml │ └── kotlin │ └── kotlinx │ └── android │ └── view │ ├── Traces.kt │ ├── ViewGroups.kt │ └── Views.kt ├── kotlinx-gson ├── .gitignore ├── build.gradle ├── proguard-rules.pro └── src │ └── main │ └── kotlin │ └── kotlinx │ └── gson │ └── GsonExt.kt ├── kotlinx-math ├── .gitignore ├── build.gradle ├── proguard-rules.pro └── src │ └── main │ └── kotlin │ └── kotlinx │ └── java │ └── lang │ └── MathExt.kt ├── kotlinx-threetenbp ├── .gitignore ├── build.gradle ├── proguard-rules.pro └── src │ └── main │ └── kotlin │ └── kotlinx │ └── threeten │ └── bp │ └── ThreeTenExt.kt └── settings.gradle /.gitignore: -------------------------------------------------------------------------------- 1 | .gradle 2 | /local.properties 3 | /.idea/workspace.xml 4 | /.idea/libraries 5 | .DS_Store 6 | /build 7 | 8 | .idea 9 | *.iml 10 | 11 | .*.sw? 12 | -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | language: android 2 | jdk: 3 | - oraclejdk7 4 | - oraclejdk8 5 | android: 6 | components: 7 | - build-tools-26.0.2 8 | - android-26 9 | - extra-android-support 10 | - extra-android-m2repository 11 | licenses: 12 | - '.+' 13 | 14 | before_install: 15 | - export JAVA7_HOME=/usr/lib/jvm/java-7-oracle 16 | - export JAVA8_HOME=/usr/lib/jvm/java-8-oracle 17 | - export JAVA_HOME=$JAVA8_HOME 18 | - echo yes | android update sdk --all --filter build-tools-26.0.2 --no-ui --force > /dev/null 19 | - android-update-sdk --accept-licenses='android-sdk-license-.+' --components=extra-android-m2repository 20 | - android-update-sdk --accept-licenses='android-sdk-license-.+' --components=extra-google-m2repository 21 | 22 | script: 23 | - ./gradlew clean assemble check 24 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | 2 | Apache License 3 | Version 2.0, January 2004 4 | http://www.apache.org/licenses/ 5 | 6 | TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 7 | 8 | 1. Definitions. 9 | 10 | "License" shall mean the terms and conditions for use, reproduction, 11 | and distribution as defined by Sections 1 through 9 of this document. 12 | 13 | "Licensor" shall mean the copyright owner or entity authorized by 14 | the copyright owner that is granting the License. 15 | 16 | "Legal Entity" shall mean the union of the acting entity and all 17 | other entities that control, are controlled by, or are under common 18 | control with that entity. For the purposes of this definition, 19 | "control" means (i) the power, direct or indirect, to cause the 20 | direction or management of such entity, whether by contract or 21 | otherwise, or (ii) ownership of fifty percent (50%) or more of the 22 | outstanding shares, or (iii) beneficial ownership of such entity. 23 | 24 | "You" (or "Your") shall mean an individual or Legal Entity 25 | exercising permissions granted by this License. 26 | 27 | "Source" form shall mean the preferred form for making modifications, 28 | including but not limited to software source code, documentation 29 | source, and configuration files. 30 | 31 | "Object" form shall mean any form resulting from mechanical 32 | transformation or translation of a Source form, including but 33 | not limited to compiled object code, generated documentation, 34 | and conversions to other media types. 35 | 36 | "Work" shall mean the work of authorship, whether in Source or 37 | Object form, made available under the License, as indicated by a 38 | copyright notice that is included in or attached to the work 39 | (an example is provided in the Appendix below). 40 | 41 | "Derivative Works" shall mean any work, whether in Source or Object 42 | form, that is based on (or derived from) the Work and for which the 43 | editorial revisions, annotations, elaborations, or other modifications 44 | represent, as a whole, an original work of authorship. For the purposes 45 | of this License, Derivative Works shall not include works that remain 46 | separable from, or merely link (or bind by name) to the interfaces of, 47 | the Work and Derivative Works thereof. 48 | 49 | "Contribution" shall mean any work of authorship, including 50 | the original version of the Work and any modifications or additions 51 | to that Work or Derivative Works thereof, that is intentionally 52 | submitted to Licensor for inclusion in the Work by the copyright owner 53 | or by an individual or Legal Entity authorized to submit on behalf of 54 | the copyright owner. For the purposes of this definition, "submitted" 55 | means any form of electronic, verbal, or written communication sent 56 | to the Licensor or its representatives, including but not limited to 57 | communication on electronic mailing lists, source code control systems, 58 | and issue tracking systems that are managed by, or on behalf of, the 59 | Licensor for the purpose of discussing and improving the Work, but 60 | excluding communication that is conspicuously marked or otherwise 61 | designated in writing by the copyright owner as "Not a Contribution." 62 | 63 | "Contributor" shall mean Licensor and any individual or Legal Entity 64 | on behalf of whom a Contribution has been received by Licensor and 65 | subsequently incorporated within the Work. 66 | 67 | 2. Grant of Copyright License. Subject to the terms and conditions of 68 | this License, each Contributor hereby grants to You a perpetual, 69 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 70 | copyright license to reproduce, prepare Derivative Works of, 71 | publicly display, publicly perform, sublicense, and distribute the 72 | Work and such Derivative Works in Source or Object form. 73 | 74 | 3. Grant of Patent License. Subject to the terms and conditions of 75 | this License, each Contributor hereby grants to You a perpetual, 76 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 77 | (except as stated in this section) patent license to make, have made, 78 | use, offer to sell, sell, import, and otherwise transfer the Work, 79 | where such license applies only to those patent claims licensable 80 | by such Contributor that are necessarily infringed by their 81 | Contribution(s) alone or by combination of their Contribution(s) 82 | with the Work to which such Contribution(s) was submitted. If You 83 | institute patent litigation against any entity (including a 84 | cross-claim or counterclaim in a lawsuit) alleging that the Work 85 | or a Contribution incorporated within the Work constitutes direct 86 | or contributory patent infringement, then any patent licenses 87 | granted to You under this License for that Work shall terminate 88 | as of the date such litigation is filed. 89 | 90 | 4. Redistribution. You may reproduce and distribute copies of the 91 | Work or Derivative Works thereof in any medium, with or without 92 | modifications, and in Source or Object form, provided that You 93 | meet the following conditions: 94 | 95 | (a) You must give any other recipients of the Work or 96 | Derivative Works a copy of this License; and 97 | 98 | (b) You must cause any modified files to carry prominent notices 99 | stating that You changed the files; and 100 | 101 | (c) You must retain, in the Source form of any Derivative Works 102 | that You distribute, all copyright, patent, trademark, and 103 | attribution notices from the Source form of the Work, 104 | excluding those notices that do not pertain to any part of 105 | the Derivative Works; and 106 | 107 | (d) If the Work includes a "NOTICE" text file as part of its 108 | distribution, then any Derivative Works that You distribute must 109 | include a readable copy of the attribution notices contained 110 | within such NOTICE file, excluding those notices that do not 111 | pertain to any part of the Derivative Works, in at least one 112 | of the following places: within a NOTICE text file distributed 113 | as part of the Derivative Works; within the Source form or 114 | documentation, if provided along with the Derivative Works; or, 115 | within a display generated by the Derivative Works, if and 116 | wherever such third-party notices normally appear. The contents 117 | of the NOTICE file are for informational purposes only and 118 | do not modify the License. You may add Your own attribution 119 | notices within Derivative Works that You distribute, alongside 120 | or as an addendum to the NOTICE text from the Work, provided 121 | that such additional attribution notices cannot be construed 122 | as modifying the License. 123 | 124 | You may add Your own copyright statement to Your modifications and 125 | may provide additional or different license terms and conditions 126 | for use, reproduction, or distribution of Your modifications, or 127 | for any such Derivative Works as a whole, provided Your use, 128 | reproduction, and distribution of the Work otherwise complies with 129 | the conditions stated in this License. 130 | 131 | 5. Submission of Contributions. Unless You explicitly state otherwise, 132 | any Contribution intentionally submitted for inclusion in the Work 133 | by You to the Licensor shall be under the terms and conditions of 134 | this License, without any additional terms or conditions. 135 | Notwithstanding the above, nothing herein shall supersede or modify 136 | the terms of any separate license agreement you may have executed 137 | with Licensor regarding such Contributions. 138 | 139 | 6. Trademarks. This License does not grant permission to use the trade 140 | names, trademarks, service marks, or product names of the Licensor, 141 | except as required for reasonable and customary use in describing the 142 | origin of the Work and reproducing the content of the NOTICE file. 143 | 144 | 7. Disclaimer of Warranty. Unless required by applicable law or 145 | agreed to in writing, Licensor provides the Work (and each 146 | Contributor provides its Contributions) on an "AS IS" BASIS, 147 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 148 | implied, including, without limitation, any warranties or conditions 149 | of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A 150 | PARTICULAR PURPOSE. You are solely responsible for determining the 151 | appropriateness of using or redistributing the Work and assume any 152 | risks associated with Your exercise of permissions under this License. 153 | 154 | 8. Limitation of Liability. In no event and under no legal theory, 155 | whether in tort (including negligence), contract, or otherwise, 156 | unless required by applicable law (such as deliberate and grossly 157 | negligent acts) or agreed to in writing, shall any Contributor be 158 | liable to You for damages, including any direct, indirect, special, 159 | incidental, or consequential damages of any character arising as a 160 | result of this License or out of the use or inability to use the 161 | Work (including but not limited to damages for loss of goodwill, 162 | work stoppage, computer failure or malfunction, or any and all 163 | other commercial damages or losses), even if such Contributor 164 | has been advised of the possibility of such damages. 165 | 166 | 9. Accepting Warranty or Additional Liability. While redistributing 167 | the Work or Derivative Works thereof, You may choose to offer, 168 | and charge a fee for, acceptance of support, warranty, indemnity, 169 | or other liability obligations and/or rights consistent with this 170 | License. However, in accepting such obligations, You may act only 171 | on Your own behalf and on Your sole responsibility, not on behalf 172 | of any other Contributor, and only if You agree to indemnify, 173 | defend, and hold each Contributor harmless for any liability 174 | incurred by, or claims asserted against, such Contributor by reason 175 | of your accepting any such warranty or additional liability. 176 | 177 | END OF TERMS AND CONDITIONS 178 | 179 | APPENDIX: How to apply the Apache License to your work. 180 | 181 | To apply the Apache License to your work, attach the following 182 | boilerplate notice, with the fields enclosed by brackets "[]" 183 | replaced with your own identifying information. (Don't include 184 | the brackets!) The text should be enclosed in the appropriate 185 | comment syntax for the file format. We also recommend that a 186 | file or class name and description of purpose be included on the 187 | same "printed page" as the copyright notice for easier 188 | identification within third-party archives. 189 | 190 | Copyright 2015 8tory, Inc. 191 | 192 | Licensed under the Apache License, Version 2.0 (the "License"); 193 | you may not use this file except in compliance with the License. 194 | You may obtain a copy of the License at 195 | 196 | http://www.apache.org/licenses/LICENSE-2.0 197 | 198 | Unless required by applicable law or agreed to in writing, software 199 | distributed under the License is distributed on an "AS IS" BASIS, 200 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 201 | See the License for the specific language governing permissions and 202 | limitations under the License. 203 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # kotlin-extensions 2 | 3 | 4 | 5 | [![JitPack](https://img.shields.io/github/tag/yongjhih/kotlin-extensions.svg?label=JitPack)](https://jitpack.io/#yongjhih/kotlin-extensions) 6 | [![javadoc](https://img.shields.io/github/tag/yongjhih/kotlin-extensions.svg?label=javadoc)](https://jitpack.io/com/github/yongjhih/kotlin-extensions/-SNAPSHOT/javadoc/) 7 | [![Build Status](https://travis-ci.org/yongjhih/kotlin-extensions.svg)](https://travis-ci.org/yongjhih/kotlin-extensions) 8 | [![Join the chat at https://gitter.im/yongjhih/kotlin-android-extensions](https://badges.gitter.im/Join%20Chat.svg)](https://gitter.im/yongjhih/kotlin-extensions?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge) 9 | [![Kotlin](https://img.shields.io/maven-central/v/org.jetbrains.kotlin/kotlin-maven-plugin.svg?label=Kotlin)](http://search.maven.org/#search%7Cga%7C1%7Cg%3A%22org.jetbrains.kotlin%22) 10 | 11 | ![](art/kotlin-database.png) 12 | 13 | ## Usage 14 | 15 | ## Database 16 | 17 | Before: 18 | 19 | ```java 20 | db.beginTransaction(); 21 | try { 22 | db.delete("users", "first_name = ?", new String[] { "Andrew" }); 23 | db.setTransactionSuccessful(); 24 | } finally { 25 | db.endTransaction() 26 | } 27 | ``` 28 | 29 | or 30 | 31 | ```java 32 | Databases.from(db).inTransaction(it -> { 33 | it.delete("users", "first_name = ?", new String[] { "Andrew" }); 34 | }); 35 | ``` 36 | 37 | After: 38 | 39 | ```kotlin 40 | db.inTransation { 41 | delete("users", "first_name = ?", arrayOf("Andrew")) 42 | } 43 | ``` 44 | 45 | Before: 46 | 47 | ```java 48 | String firstName = cursor.getString(cursor.getColumnIndexOrThrow("first_name")); 49 | ``` 50 | 51 | After: 52 | 53 | ```kotlin 54 | val firstName = cursor.getString("first_name"); 55 | ``` 56 | 57 | Before: 58 | 59 | ```java 60 | String firstName = null; 61 | int firstNameColumnIndex = cursor.getColumnIndexOrThrow("first_name"); 62 | if (!cursor.isNull(firstNameColumnIndex)) { 63 | firstName = cursor.getString(firstNameColumnIndex); 64 | } 65 | firstNameView.setText(firstName != null ? firstName : "Andrew"); 66 | ``` 67 | 68 | After: 69 | 70 | ```kotlin 71 | val firstName = cursor.getStringOrNull("first_name") 72 | firstNameView.setText(firstName ?: "Andrew") 73 | ``` 74 | 75 | ## SharedPreferences 76 | 77 | Before: 78 | 79 | ```java 80 | SharePreferences prefs = PreferenceManager.getDefaultSharedPreferences(context); 81 | SharePreferences.Editor editor = prefs.edit(); 82 | editor.putString("name", "Andrew Chen"); 83 | editor.putInt("age", 18, 14); 84 | editor.apply(); 85 | ``` 86 | 87 | After: 88 | 89 | ```kotlin 90 | 91 | User(context).edit { 92 | name = "Andrew Chen" 93 | age = "18" 94 | } 95 | 96 | public class User(context: Context) : Preferences(context) { 97 | var name: String by Preference() 98 | var age: Int by Preference(default = 14) 99 | } 100 | ``` 101 | 102 | or 103 | 104 | ```kotlin 105 | User user = User(context) 106 | user.name = "Andrew Chen" 107 | user.age = 18 108 | user.apply() 109 | ``` 110 | 111 | ### Bonus - SharedPreferences Extension: 112 | 113 | Before: 114 | 115 | ```java 116 | SharedPreferences.Editor editor = prefs.edit(); 117 | 118 | editor.putString("first_name", "Andrew"); 119 | editor.putString("last_name", "Chen"); 120 | editor.remove("age"); 121 | 122 | editor.apply(); 123 | ``` 124 | 125 | or 126 | 127 | ```java 128 | SharedPreferencesUtils.from(prefs).apply(editor -> { 129 | editor.putString("first_name", "Andrew"); 130 | editor.putString("last_name", "Chen"); 131 | editor.remove("age"); 132 | }); 133 | ``` 134 | 135 | After: 136 | 137 | ```kotlin 138 | prefs.edit { 139 | putString("first_name", "Andrew") 140 | putString("last_name", "Chen") 141 | remove("age") 142 | } 143 | ``` 144 | 145 | ## System Services 146 | 147 | Before: 148 | 149 | ```java 150 | NotificationManager notificationManager = (NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE); 151 | ``` 152 | 153 | After: 154 | 155 | ```kotlin 156 | val notificationManager = context.getNotificationManager() 157 | ``` 158 | 159 | ## Notification 160 | 161 | Before: 162 | 163 | ```java 164 | Notification notification = new NotificationCompat.Builder(context) 165 | .setContentTitle("Hello") 166 | .setSubText("World") 167 | .build(); 168 | ``` 169 | 170 | After: 171 | 172 | ```kotlin 173 | val notification = Notification.build(context) { 174 | setContentTitle("Hello") 175 | setSubText("World") 176 | } 177 | ``` 178 | 179 | ## Query 180 | 181 | ## Math 182 | 183 | Import from [MichaelRocks/MathExtensions.kt](https://gist.github.com/MichaelRocks/f8f66230707bcd88a239) 184 | 185 | ## ThreeTen Backport (JSR-310) 186 | 187 | ```kt 188 | LocalDateTime.now().toDate() 189 | ``` 190 | 191 | ```kt 192 | new Date().toLocalDateTime() 193 | ``` 194 | 195 | ## View 196 | 197 | ```kt 198 | view.fadeOut() 199 | ``` 200 | 201 | ```kt 202 | view.fadeIn() 203 | ``` 204 | 205 | ```kt 206 | for (view in views.children()) 207 | ``` 208 | 209 | ```kt 210 | if (view in views) { 211 | // .. 212 | } 213 | ``` 214 | 215 | ```kt 216 | views += view 217 | ``` 218 | 219 | ```kt 220 | views -= view 221 | ``` 222 | 223 | ```kt 224 | views.forEach {} 225 | ``` 226 | 227 | ```kt 228 | views.filter {} 229 | ``` 230 | 231 | ## Misc 232 | 233 | * https://gist.github.com/yongjhih/35e7474351e73d26ad26432901101902 234 | 235 | ## Installation 236 | 237 | jitpack: 238 | 239 | ```gradle 240 | repositories { 241 | // ... 242 | maven { url "https://jitpack.io" } 243 | } 244 | 245 | dependencies { 246 | compile 'com.github.yongjhih.kotlin-extensions:kotlinx-android-sharedpreferences:-SNAPSHOT' 247 | compile 'com.github.yongjhih.kotlin-extensions:kotlinx-android-database:-SNAPSHOT' 248 | compile 'com.github.yongjhih.kotlin-extensions:kotlinx-android-system-services:-SNAPSHOT' 249 | compile 'com.github.yongjhih.kotlin-extensions:kotlinx-android-notification:-SNAPSHOT' 250 | compile 'com.github.yongjhih.kotlin-extensions:kotlinx-math:-SNAPSHOT' 251 | compile 'com.github.yongjhih.kotlin-extensions:kotlinx-threetenbp:-SNAPSHOT' 252 | compile 'com.github.yongjhih.kotlin-extensions:kotlinx-android-view:-SNAPSHOT' 253 | } 254 | ``` 255 | 256 | jcenter (not ready yet): 257 | 258 | ```gradle 259 | dependencies { 260 | compile 'com.infstory:kotlinx-android-sharedpreferences:1.0.0' 261 | compile 'com.infstory:kotlinx-android-database:1.0.0' 262 | compile 'com.infstory:kotlinx-android-system-services:1.0.0' 263 | compile 'com.infstory:kotlinx-android-notification:1.0.0' 264 | compile 'com.infstory:kotlinx-math:1.0.0' 265 | compile 'com.infstory:kotlinx-android-view:1.0.0' 266 | } 267 | ``` 268 | 269 | ## License 270 | 271 | ``` 272 | Copyright 2015 8tory, Inc. 273 | 274 | Licensed under the Apache License, Version 2.0 (the "License"); 275 | you may not use this file except in compliance with the License. 276 | You may obtain a copy of the License at 277 | 278 | http://www.apache.org/licenses/LICENSE-2.0 279 | 280 | Unless required by applicable law or agreed to in writing, software 281 | distributed under the License is distributed on an "AS IS" BASIS, 282 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 283 | See the License for the specific language governing permissions and 284 | limitations under the License. 285 | ``` 286 | -------------------------------------------------------------------------------- /app/.gitignore: -------------------------------------------------------------------------------- 1 | /build 2 | -------------------------------------------------------------------------------- /app/build.gradle: -------------------------------------------------------------------------------- 1 | apply plugin: 'com.android.application' 2 | apply plugin: 'kotlin-android' 3 | apply plugin: 'kotlin-android-extensions' 4 | 5 | android { 6 | compileSdkVersion rootProject.ext.compileSdkVersion 7 | buildToolsVersion rootProject.ext.buildToolsVersion 8 | defaultConfig { 9 | applicationId 'com.graffity' 10 | minSdkVersion 15 11 | targetSdkVersion rootProject.ext.targetSdkVersion 12 | } 13 | buildTypes { 14 | release { 15 | minifyEnabled false 16 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' 17 | } 18 | } 19 | productFlavors { 20 | } 21 | lintOptions { 22 | abortOnError false 23 | } 24 | sourceSets { 25 | main.java.srcDirs += 'src/main/kotlin' 26 | } 27 | } 28 | 29 | dependencies { 30 | compile fileTree(include: ['*.jar'], dir: 'libs') 31 | compile project(':kotlinx-android-sharedpreferences') 32 | //compile 'com.github.yongjhih.kotlin-android-extensions:kotlinx-sharedpreferences:-SNAPSHOT' 33 | compile 'com.facebook.android:facebook-android-sdk:4.7.0' 34 | compile "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version" 35 | compile "org.jetbrains.kotlin:kotlin-reflect:$kotlin_version" 36 | 37 | compile "com.android.support:appcompat-v7:$support_version" 38 | compile "org.jetbrains.anko:anko-sdk15:$anko_version" 39 | compile "org.jetbrains.anko:anko-support-v4:$anko_version" 40 | compile "org.jetbrains.anko:anko-appcompat-v7:$anko_version" 41 | //compile 'org.jetbrains.anko:anko-sdk15:0.8' 42 | //compile 'org.jetbrains.anko:anko-support-v4:0.8' 43 | //compile 'org.jetbrains.anko:anko-appcompat-v7:0.8' 44 | 45 | compile 'io.reactivex:rxkotlin:0.30.1' 46 | 47 | // testCompile mockito 48 | // testCompile assertj-android 49 | // testCompile expresso 50 | // testCompile junit 51 | } 52 | -------------------------------------------------------------------------------- /app/proguard-rules.pro: -------------------------------------------------------------------------------- 1 | # Add project specific ProGuard rules here. 2 | # By default, the flags in this file are appended to flags specified 3 | # in /Users/rondouchen/Library/Android/sdk/tools/proguard/proguard-android.txt 4 | # You can edit the include path and order by changing the proguardFiles 5 | # directive in build.gradle. 6 | # 7 | # For more details, see 8 | # http://developer.android.com/guide/developing/tools/proguard.html 9 | 10 | # Add any project specific keep options here: 11 | 12 | # If your project uses WebView with JS, uncomment the following 13 | # and specify the fully qualified class name to the JavaScript interface 14 | # class: 15 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview { 16 | # public *; 17 | #} 18 | -------------------------------------------------------------------------------- /app/src/androidTest/java/com/graffity/ApplicationTest.java: -------------------------------------------------------------------------------- 1 | package com.graffity; 2 | 3 | import android.app.Application; 4 | import android.test.ApplicationTestCase; 5 | 6 | /** 7 | * Testing Fundamentals 8 | */ 9 | public class ApplicationTest extends ApplicationTestCase { 10 | public ApplicationTest() { 11 | super(Application.class); 12 | } 13 | } -------------------------------------------------------------------------------- /app/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 6 | 11 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 26 | 27 | 28 | 31 | 32 | 33 | 34 | 35 | 36 | -------------------------------------------------------------------------------- /app/src/main/kotlin/com/graffity/MainActivity.kt: -------------------------------------------------------------------------------- 1 | package com.graffity 2 | 3 | import android.app.Activity 4 | import android.os.Bundle 5 | import android.util.Log 6 | import android.view.Menu 7 | import android.view.MenuItem 8 | 9 | import com.facebook.appevents.AppEventsLogger 10 | //import kotlinx.android.synthetic.activity_main.hello as helloView 11 | //import org.jetbrains.anko.* 12 | 13 | class MainActivity : Activity() { 14 | 15 | override fun onCreate(savedInstanceState: Bundle?) { 16 | super.onCreate(savedInstanceState) 17 | setContentView(R.layout.activity_main) 18 | //helloView.setText("yo") 19 | //relativeLayout { 20 | // textView(R.string.hello_world) { 21 | // } 22 | //} 23 | /* 24 | var user = User(this) 25 | user.name = "Andrew Chen" 26 | user.age = 18 27 | user.apply() 28 | */ 29 | val user = User(this) 30 | user.edit { 31 | name = "Andrew Chen" 32 | age = 18 33 | } 34 | Log.d("Andrew", "name: " + user.name); 35 | Log.d("Andrew", "age: " + user.age); 36 | user.edit { 37 | name = "Andrew Chen2" 38 | age = 14 39 | } 40 | Log.d("Andrew", "name: " + user.name); 41 | Log.d("Andrew", "age: " + user.age); 42 | } 43 | 44 | override fun onCreateOptionsMenu(menu: Menu): Boolean { 45 | // Inflate the menu; this adds items to the action bar if it is present. 46 | menuInflater.inflate(R.menu.menu_main, menu) 47 | return true 48 | } 49 | 50 | override fun onOptionsItemSelected(item: MenuItem): Boolean { 51 | // Handle action bar item clicks here. The action bar will 52 | // automatically handle clicks on the Home/Up button, so long 53 | // as you specify a parent activity in AndroidManifest.xml. 54 | val id = item.itemId 55 | 56 | //noinspection SimplifiableIfStatement 57 | if (id == R.id.action_settings) { 58 | return true 59 | } 60 | 61 | return super.onOptionsItemSelected(item) 62 | } 63 | 64 | override fun onResume() { 65 | super.onResume() 66 | 67 | AppEventsLogger.activateApp(this) 68 | } 69 | 70 | override fun onPause() { 71 | super.onPause() 72 | 73 | AppEventsLogger.deactivateApp(this) 74 | } 75 | } 76 | -------------------------------------------------------------------------------- /app/src/main/kotlin/com/graffity/User.kt: -------------------------------------------------------------------------------- 1 | package com.graffity 2 | 3 | import android.content.Context 4 | import kotlinx.android.sharedpreferences.Preferences 5 | 6 | /** 7 | * Created by andrew on 11/28/15. 8 | */ 9 | public class User(context: Context) : Preferences(context) { 10 | var name: String? by Preference() 11 | var age: Int? by Preference() 12 | 13 | fun edit(func: User.() -> Unit) { 14 | func() 15 | editor.apply() 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /app/src/main/res/layout/activity_main.xml: -------------------------------------------------------------------------------- 1 | 8 | 9 | 15 | 16 | 17 | -------------------------------------------------------------------------------- /app/src/main/res/menu/menu_main.xml: -------------------------------------------------------------------------------- 1 | 3 | 5 | 6 | -------------------------------------------------------------------------------- /app/src/main/res/mipmap-hdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yongjhih/kotlin-extensions/e809bbd3240107efe9297598ac3558dc4b01d69d/app/src/main/res/mipmap-hdpi/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-mdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yongjhih/kotlin-extensions/e809bbd3240107efe9297598ac3558dc4b01d69d/app/src/main/res/mipmap-mdpi/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yongjhih/kotlin-extensions/e809bbd3240107efe9297598ac3558dc4b01d69d/app/src/main/res/mipmap-xhdpi/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yongjhih/kotlin-extensions/e809bbd3240107efe9297598ac3558dc4b01d69d/app/src/main/res/mipmap-xxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/res/values-v21/styles.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 5 | 6 | -------------------------------------------------------------------------------- /app/src/main/res/values-w820dp/dimens.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 64dp 6 | 7 | -------------------------------------------------------------------------------- /app/src/main/res/values/dimens.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 16dp 4 | 16dp 5 | 6 | -------------------------------------------------------------------------------- /app/src/main/res/values/strings.xml: -------------------------------------------------------------------------------- 1 | 2 | Graffity 3 | 4 | Hello world! 5 | Settings 6 | 7 | 189633601379625 8 | 9 | -------------------------------------------------------------------------------- /app/src/main/res/values/styles.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /art/kotlin-database.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yongjhih/kotlin-extensions/e809bbd3240107efe9297598ac3558dc4b01d69d/art/kotlin-database.png -------------------------------------------------------------------------------- /art/kotlin-database.svg: -------------------------------------------------------------------------------- 1 | 2 | 21 | 23 | 24 | 26 | image/svg+xml 27 | 29 | 30 | 31 | 32 | 33 | 35 | 59 | 62 | 65 | 70 | 75 | 80 | 85 | 86 | 89 | 94 | 99 | 104 | 109 | 110 | 113 | 118 | 124 | 125 | 126 | 127 | -------------------------------------------------------------------------------- /art/kotlin-sharedpreferences.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yongjhih/kotlin-extensions/e809bbd3240107efe9297598ac3558dc4b01d69d/art/kotlin-sharedpreferences.png -------------------------------------------------------------------------------- /art/kotlin-sharedpreferences.svg: -------------------------------------------------------------------------------- 1 | 2 | 21 | 23 | 24 | 26 | image/svg+xml 27 | 29 | 30 | 31 | 32 | 33 | 35 | 59 | 61 | 64 | 69 | 74 | 79 | 84 | 85 | SharedPreferences 100 | 103 | 108 | 113 | 118 | 123 | 124 | Shared 135 | 136 | 137 | -------------------------------------------------------------------------------- /build.gradle: -------------------------------------------------------------------------------- 1 | // Top-level build file where you can add configuration options common to all sub-projects/modules. 2 | buildscript { 3 | ext { 4 | anko_version = "0.9" 5 | kotlin_version = "1.1.51" 6 | support_version = '26.0.2' 7 | compileSdkVersion = 26 8 | buildToolsVersion = '26.0.2' 9 | targetSdkVersion = compileSdkVersion 10 | androidGradleBuildToolsVersion = "3.0.0" 11 | } 12 | 13 | repositories { 14 | jcenter() 15 | google() 16 | } 17 | 18 | dependencies { 19 | classpath "com.android.tools.build:gradle:$androidGradleBuildToolsVersion" 20 | classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version" 21 | classpath "org.jetbrains.kotlin:kotlin-android-extensions:$kotlin_version" 22 | classpath 'com.github.dcendents:android-maven-gradle-plugin:1.5' 23 | } 24 | } 25 | 26 | allprojects { 27 | 28 | repositories { 29 | jcenter() 30 | google() 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /gradle.properties: -------------------------------------------------------------------------------- 1 | # Project-wide Gradle settings. 2 | 3 | # IDE (e.g. Android Studio) users: 4 | # Gradle settings configured through the IDE *will override* 5 | # any settings specified in this file. 6 | 7 | # For more details on how to configure your build environment visit 8 | # http://www.gradle.org/docs/current/userguide/build_environment.html 9 | 10 | # Specifies the JVM arguments used for the daemon process. 11 | # The setting is particularly useful for tweaking memory settings. 12 | # Default value: -Xmx10248m -XX:MaxPermSize=256m 13 | # org.gradle.jvmargs=-Xmx2048m -XX:MaxPermSize=512m -XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF-8 14 | 15 | # When configured, Gradle will run in incubating parallel mode. 16 | # This option should only be used with decoupled projects. More details, visit 17 | # http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects 18 | # org.gradle.parallel=true -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yongjhih/kotlin-extensions/e809bbd3240107efe9297598ac3558dc4b01d69d/gradle/wrapper/gradle-wrapper.jar -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.properties: -------------------------------------------------------------------------------- 1 | #Mon Nov 06 16:34:54 CET 2017 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-4.1-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 | # For Cygwin, ensure paths are in UNIX format before anything is touched. 46 | if $cygwin ; then 47 | [ -n "$JAVA_HOME" ] && JAVA_HOME=`cygpath --unix "$JAVA_HOME"` 48 | fi 49 | 50 | # Attempt to set APP_HOME 51 | # Resolve links: $0 may be a link 52 | PRG="$0" 53 | # Need this for relative symlinks. 54 | while [ -h "$PRG" ] ; do 55 | ls=`ls -ld "$PRG"` 56 | link=`expr "$ls" : '.*-> \(.*\)$'` 57 | if expr "$link" : '/.*' > /dev/null; then 58 | PRG="$link" 59 | else 60 | PRG=`dirname "$PRG"`"/$link" 61 | fi 62 | done 63 | SAVED="`pwd`" 64 | cd "`dirname \"$PRG\"`/" >&- 65 | APP_HOME="`pwd -P`" 66 | cd "$SAVED" >&- 67 | 68 | CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar 69 | 70 | # Determine the Java command to use to start the JVM. 71 | if [ -n "$JAVA_HOME" ] ; then 72 | if [ -x "$JAVA_HOME/jre/sh/java" ] ; then 73 | # IBM's JDK on AIX uses strange locations for the executables 74 | JAVACMD="$JAVA_HOME/jre/sh/java" 75 | else 76 | JAVACMD="$JAVA_HOME/bin/java" 77 | fi 78 | if [ ! -x "$JAVACMD" ] ; then 79 | die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME 80 | 81 | Please set the JAVA_HOME variable in your environment to match the 82 | location of your Java installation." 83 | fi 84 | else 85 | JAVACMD="java" 86 | which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 87 | 88 | Please set the JAVA_HOME variable in your environment to match the 89 | location of your Java installation." 90 | fi 91 | 92 | # Increase the maximum file descriptors if we can. 93 | if [ "$cygwin" = "false" -a "$darwin" = "false" ] ; then 94 | MAX_FD_LIMIT=`ulimit -H -n` 95 | if [ $? -eq 0 ] ; then 96 | if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then 97 | MAX_FD="$MAX_FD_LIMIT" 98 | fi 99 | ulimit -n $MAX_FD 100 | if [ $? -ne 0 ] ; then 101 | warn "Could not set maximum file descriptor limit: $MAX_FD" 102 | fi 103 | else 104 | warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT" 105 | fi 106 | fi 107 | 108 | # For Darwin, add options to specify how the application appears in the dock 109 | if $darwin; then 110 | GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\"" 111 | fi 112 | 113 | # For Cygwin, switch paths to Windows format before running java 114 | if $cygwin ; then 115 | APP_HOME=`cygpath --path --mixed "$APP_HOME"` 116 | CLASSPATH=`cygpath --path --mixed "$CLASSPATH"` 117 | 118 | # We build the pattern for arguments to be converted via cygpath 119 | ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null` 120 | SEP="" 121 | for dir in $ROOTDIRSRAW ; do 122 | ROOTDIRS="$ROOTDIRS$SEP$dir" 123 | SEP="|" 124 | done 125 | OURCYGPATTERN="(^($ROOTDIRS))" 126 | # Add a user-defined pattern to the cygpath arguments 127 | if [ "$GRADLE_CYGPATTERN" != "" ] ; then 128 | OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)" 129 | fi 130 | # Now convert the arguments - kludge to limit ourselves to /bin/sh 131 | i=0 132 | for arg in "$@" ; do 133 | CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -` 134 | CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option 135 | 136 | if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition 137 | eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"` 138 | else 139 | eval `echo args$i`="\"$arg\"" 140 | fi 141 | i=$((i+1)) 142 | done 143 | case $i in 144 | (0) set -- ;; 145 | (1) set -- "$args0" ;; 146 | (2) set -- "$args0" "$args1" ;; 147 | (3) set -- "$args0" "$args1" "$args2" ;; 148 | (4) set -- "$args0" "$args1" "$args2" "$args3" ;; 149 | (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;; 150 | (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;; 151 | (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;; 152 | (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;; 153 | (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;; 154 | esac 155 | fi 156 | 157 | # Split up the JVM_OPTS And GRADLE_OPTS values into an array, following the shell quoting and substitution rules 158 | function splitJvmOpts() { 159 | JVM_OPTS=("$@") 160 | } 161 | eval splitJvmOpts $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS 162 | JVM_OPTS[${#JVM_OPTS[*]}]="-Dorg.gradle.appname=$APP_BASE_NAME" 163 | 164 | exec "$JAVACMD" "${JVM_OPTS[@]}" -classpath "$CLASSPATH" org.gradle.wrapper.GradleWrapperMain "$@" 165 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /kotlinx-android-app/.gitignore: -------------------------------------------------------------------------------- 1 | /build 2 | -------------------------------------------------------------------------------- /kotlinx-android-app/build.gradle: -------------------------------------------------------------------------------- 1 | apply plugin: 'com.android.library' 2 | apply plugin: 'kotlin-android' 3 | apply plugin: 'kotlin-android-extensions' 4 | 5 | android { 6 | compileSdkVersion 26 7 | 8 | defaultConfig { 9 | minSdkVersion 15 10 | targetSdkVersion rootProject.ext.targetSdkVersion 11 | } 12 | 13 | buildTypes { 14 | release { 15 | minifyEnabled false 16 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' 17 | } 18 | } 19 | 20 | sourceSets { 21 | main.java.srcDirs += 'src/main/kotlin' 22 | } 23 | } 24 | 25 | dependencies { 26 | 27 | } 28 | -------------------------------------------------------------------------------- /kotlinx-android-app/proguard-rules.pro: -------------------------------------------------------------------------------- 1 | # Add project specific ProGuard rules here. 2 | # You can control the set of applied configuration files using the 3 | # proguardFiles setting in build.gradle. 4 | # 5 | # For more details, see 6 | # http://developer.android.com/guide/developing/tools/proguard.html 7 | 8 | # If your project uses WebView with JS, uncomment the following 9 | # and specify the fully qualified class name to the JavaScript interface 10 | # class: 11 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview { 12 | # public *; 13 | #} 14 | 15 | # Uncomment this to preserve the line number information for 16 | # debugging stack traces. 17 | #-keepattributes SourceFile,LineNumberTable 18 | 19 | # If you keep the line number information, uncomment this to 20 | # hide the original source file name. 21 | #-renamesourcefileattribute SourceFile 22 | -------------------------------------------------------------------------------- /kotlinx-android-app/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /kotlinx-android-app/src/main/kotlin/kotlinx/android/app/ActivityExt.kt: -------------------------------------------------------------------------------- 1 | package kotlinx.android.app 2 | 3 | import android.app.Activity 4 | import android.app.FragmentTransaction 5 | import android.widget.Toast 6 | 7 | fun Activity.toast(resourceId: Int, length: Int = Toast.LENGTH_SHORT) { 8 | toast(getString(resourceId), length) 9 | } 10 | 11 | fun Activity.toast(message: String, length: Int = Toast.LENGTH_SHORT) { 12 | Toast.makeText(this, message, length).show() 13 | } 14 | 15 | inline fun Activity.fragmentTransaction(function: FragmentTransaction.() -> FragmentTransaction) { 16 | fragmentManager.beginTransaction() 17 | .function() 18 | .commit() 19 | } 20 | -------------------------------------------------------------------------------- /kotlinx-android-app/src/main/kotlin/kotlinx/android/app/FragmentExt.kt: -------------------------------------------------------------------------------- 1 | package kotlinx.android.app 2 | 3 | import android.app.Fragment 4 | import android.widget.Toast 5 | 6 | fun Fragment.toast(resourceId: Int, length: Int = Toast.LENGTH_SHORT) { 7 | activity.toast(resourceId, length) 8 | } 9 | 10 | fun Fragment.toast(message: String, length: Int = Toast.LENGTH_SHORT) { 11 | activity.toast(message, length) 12 | } 13 | 14 | inline fun Fragment.fragmentTransaction(function: android.app.FragmentTransaction.() -> android.app.FragmentTransaction) { 15 | fragmentManager.beginTransaction() 16 | .function() 17 | .commit() 18 | } 19 | -------------------------------------------------------------------------------- /kotlinx-android-database/.gitignore: -------------------------------------------------------------------------------- 1 | /build 2 | -------------------------------------------------------------------------------- /kotlinx-android-database/android-javadoc.gradle: -------------------------------------------------------------------------------- 1 | // build a jar with source files 2 | task sourcesJar(type: Jar) { 3 | from android.sourceSets.main.java.srcDirs 4 | classifier = 'sources' 5 | } 6 | 7 | task javadoc(type: Javadoc) { 8 | failOnError false 9 | source = android.sourceSets.main.java.sourceFiles 10 | classpath += project.files(android.getBootClasspath().join(File.pathSeparator)) 11 | } 12 | 13 | // build a jar with javadoc 14 | task javadocJar(type: Jar, dependsOn: javadoc) { 15 | classifier = 'javadoc' 16 | from javadoc.destinationDir 17 | } 18 | 19 | artifacts { 20 | archives sourcesJar 21 | archives javadocJar 22 | } 23 | -------------------------------------------------------------------------------- /kotlinx-android-database/build.gradle: -------------------------------------------------------------------------------- 1 | apply plugin: 'com.android.library' 2 | apply plugin: 'kotlin-android' 3 | apply plugin: 'kotlin-android-extensions' 4 | 5 | android { 6 | compileSdkVersion rootProject.ext.compileSdkVersion 7 | buildToolsVersion rootProject.ext.buildToolsVersion 8 | defaultConfig { 9 | minSdkVersion 15 10 | targetSdkVersion rootProject.ext.targetSdkVersion 11 | } 12 | buildTypes { 13 | release { 14 | minifyEnabled false 15 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' 16 | } 17 | } 18 | productFlavors { 19 | } 20 | 21 | sourceSets { 22 | main.java.srcDirs += 'src/main/kotlin' 23 | } 24 | } 25 | 26 | dependencies { 27 | compile "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version" 28 | 29 | // testCompile mockito 30 | // testCompile assertj-android 31 | // testCompile expresso 32 | // testCompile junit 33 | } 34 | 35 | apply plugin: 'com.github.dcendents.android-maven' 36 | apply from: 'android-javadoc.gradle' 37 | -------------------------------------------------------------------------------- /kotlinx-android-database/proguard-rules.pro: -------------------------------------------------------------------------------- 1 | # Add project specific ProGuard rules here. 2 | # By default, the flags in this file are appended to flags specified 3 | # in /Users/rondouchen/Library/Android/sdk/tools/proguard/proguard-android.txt 4 | # You can edit the include path and order by changing the proguardFiles 5 | # directive in build.gradle. 6 | # 7 | # For more details, see 8 | # http://developer.android.com/guide/developing/tools/proguard.html 9 | 10 | # Add any project specific keep options here: 11 | 12 | # If your project uses WebView with JS, uncomment the following 13 | # and specify the fully qualified class name to the JavaScript interface 14 | # class: 15 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview { 16 | # public *; 17 | #} 18 | -------------------------------------------------------------------------------- /kotlinx-android-database/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | -------------------------------------------------------------------------------- /kotlinx-android-database/src/main/kotlin/kotlinx/android/database/CursorExt.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2015 8tory, Inc 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package kotlinx.android.database 18 | 19 | import android.database.Cursor 20 | 21 | inline fun Cursor.getString(columnName: String): String = 22 | getStringOrNull(columnName)!! 23 | 24 | inline fun Cursor.getStringOrNull(columnName: String): String? { 25 | val index = getColumnIndexOrThrow(columnName) 26 | return if (isNull(index)) null else getString(index) 27 | } 28 | -------------------------------------------------------------------------------- /kotlinx-android-database/src/main/kotlin/kotlinx/android/database/SQLiteDatabaseExt.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2015 8tory, Inc 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package kotlinx.android.database 18 | 19 | import android.database.sqlite.SQLiteDatabase 20 | 21 | inline fun SQLiteDatabase.inTransaction(func: SQLiteDatabase.() -> Unit) { 22 | beginTransaction() 23 | try { 24 | func() 25 | setTransactionSuccessful() 26 | } finally { 27 | endTransaction() 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /kotlinx-android-notification/.gitignore: -------------------------------------------------------------------------------- 1 | /build 2 | -------------------------------------------------------------------------------- /kotlinx-android-notification/android-javadoc.gradle: -------------------------------------------------------------------------------- 1 | // build a jar with source files 2 | task sourcesJar(type: Jar) { 3 | from android.sourceSets.main.java.srcDirs 4 | classifier = 'sources' 5 | } 6 | 7 | task javadoc(type: Javadoc) { 8 | failOnError false 9 | source = android.sourceSets.main.java.sourceFiles 10 | classpath += project.files(android.getBootClasspath().join(File.pathSeparator)) 11 | } 12 | 13 | // build a jar with javadoc 14 | task javadocJar(type: Jar, dependsOn: javadoc) { 15 | classifier = 'javadoc' 16 | from javadoc.destinationDir 17 | } 18 | 19 | artifacts { 20 | archives sourcesJar 21 | archives javadocJar 22 | } 23 | -------------------------------------------------------------------------------- /kotlinx-android-notification/build.gradle: -------------------------------------------------------------------------------- 1 | apply plugin: 'com.android.library' 2 | apply plugin: 'kotlin-android' 3 | apply plugin: 'kotlin-android-extensions' 4 | 5 | android { 6 | compileSdkVersion rootProject.ext.compileSdkVersion 7 | buildToolsVersion rootProject.ext.buildToolsVersion 8 | defaultConfig { 9 | minSdkVersion 15 10 | targetSdkVersion rootProject.ext.targetSdkVersion 11 | } 12 | buildTypes { 13 | release { 14 | minifyEnabled false 15 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' 16 | } 17 | } 18 | productFlavors { 19 | } 20 | 21 | sourceSets { 22 | main.java.srcDirs += 'src/main/kotlin' 23 | } 24 | } 25 | 26 | dependencies { 27 | compile "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version" 28 | compile "com.android.support:support-v4:$support_version" 29 | 30 | // testCompile mockito 31 | // testCompile assertj-android 32 | // testCompile expresso 33 | // testCompile junit 34 | } 35 | 36 | apply plugin: 'com.github.dcendents.android-maven' 37 | apply from: 'android-javadoc.gradle' 38 | -------------------------------------------------------------------------------- /kotlinx-android-notification/proguard-rules.pro: -------------------------------------------------------------------------------- 1 | # Add project specific ProGuard rules here. 2 | # By default, the flags in this file are appended to flags specified 3 | # in /Users/rondouchen/Library/Android/sdk/tools/proguard/proguard-android.txt 4 | # You can edit the include path and order by changing the proguardFiles 5 | # directive in build.gradle. 6 | # 7 | # For more details, see 8 | # http://developer.android.com/guide/developing/tools/proguard.html 9 | 10 | # Add any project specific keep options here: 11 | 12 | # If your project uses WebView with JS, uncomment the following 13 | # and specify the fully qualified class name to the JavaScript interface 14 | # class: 15 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview { 16 | # public *; 17 | #} 18 | -------------------------------------------------------------------------------- /kotlinx-android-notification/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | -------------------------------------------------------------------------------- /kotlinx-android-notification/src/main/kotlin/kotlinx/android/notification/NotificationExt.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2015 8tory, Inc 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package kotlinx.android.notification 18 | 19 | import android.app.Notification 20 | import android.support.v4.app.NotificationCompat 21 | import android.content.Context 22 | 23 | inline fun Notification.build(context: Context, func: NotificationCompat.Builder.() -> Unit): Notification { 24 | val builder = NotificationCompat.Builder(context) 25 | builder.func() 26 | return builder.build() 27 | } 28 | -------------------------------------------------------------------------------- /kotlinx-android-sharedpreferences/.gitignore: -------------------------------------------------------------------------------- 1 | /build 2 | -------------------------------------------------------------------------------- /kotlinx-android-sharedpreferences/android-javadoc.gradle: -------------------------------------------------------------------------------- 1 | // build a jar with source files 2 | task sourcesJar(type: Jar) { 3 | from android.sourceSets.main.java.srcDirs 4 | classifier = 'sources' 5 | } 6 | 7 | task javadoc(type: Javadoc) { 8 | failOnError false 9 | source = android.sourceSets.main.java.sourceFiles 10 | classpath += project.files(android.getBootClasspath().join(File.pathSeparator)) 11 | } 12 | 13 | // build a jar with javadoc 14 | task javadocJar(type: Jar, dependsOn: javadoc) { 15 | classifier = 'javadoc' 16 | from javadoc.destinationDir 17 | } 18 | 19 | artifacts { 20 | archives sourcesJar 21 | archives javadocJar 22 | } 23 | -------------------------------------------------------------------------------- /kotlinx-android-sharedpreferences/build.gradle: -------------------------------------------------------------------------------- 1 | apply plugin: 'com.android.library' 2 | apply plugin: 'kotlin-android' 3 | apply plugin: 'kotlin-android-extensions' 4 | 5 | android { 6 | compileSdkVersion rootProject.ext.compileSdkVersion 7 | buildToolsVersion rootProject.ext.buildToolsVersion 8 | defaultConfig { 9 | minSdkVersion 15 10 | targetSdkVersion rootProject.ext.targetSdkVersion 11 | } 12 | buildTypes { 13 | release { 14 | minifyEnabled false 15 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' 16 | } 17 | } 18 | productFlavors { 19 | } 20 | 21 | sourceSets { 22 | main.java.srcDirs += 'src/main/kotlin' 23 | } 24 | } 25 | 26 | dependencies { 27 | compile fileTree(include: ['*.jar'], dir: 'libs') 28 | compile "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version" 29 | compile "org.jetbrains.kotlin:kotlin-reflect:$kotlin_version" 30 | 31 | // testCompile mockito 32 | // testCompile assertj-android 33 | // testCompile expresso 34 | // testCompile junit 35 | } 36 | 37 | apply plugin: 'com.github.dcendents.android-maven' 38 | apply from: 'android-javadoc.gradle' 39 | -------------------------------------------------------------------------------- /kotlinx-android-sharedpreferences/proguard-rules.pro: -------------------------------------------------------------------------------- 1 | # Add project specific ProGuard rules here. 2 | # By default, the flags in this file are appended to flags specified 3 | # in /Users/rondouchen/Library/Android/sdk/tools/proguard/proguard-android.txt 4 | # You can edit the include path and order by changing the proguardFiles 5 | # directive in build.gradle. 6 | # 7 | # For more details, see 8 | # http://developer.android.com/guide/developing/tools/proguard.html 9 | 10 | # Add any project specific keep options here: 11 | 12 | # If your project uses WebView with JS, uncomment the following 13 | # and specify the fully qualified class name to the JavaScript interface 14 | # class: 15 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview { 16 | # public *; 17 | #} 18 | -------------------------------------------------------------------------------- /kotlinx-android-sharedpreferences/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | -------------------------------------------------------------------------------- /kotlinx-android-sharedpreferences/src/main/kotlin/kotlinx/android/sharedpreferences/Preferences.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2015 8tory, Inc 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package kotlinx.android.sharedpreferences 18 | 19 | import android.content.Context 20 | import android.content.SharedPreferences 21 | import android.preference.PreferenceManager 22 | import android.util.Log 23 | import kotlin.properties.ReadWriteProperty 24 | import kotlin.reflect.KProperty 25 | import kotlin.reflect.KType 26 | import kotlin.reflect.jvm.javaType 27 | 28 | /** 29 | * Created by andrew on 11/28/15. 30 | */ 31 | public open class Preferences(prefs: SharedPreferences): SharedPreferences by prefs { 32 | val TAG = "Preferences" 33 | val editor: SharedPreferences.Editor by lazy { edit() } 34 | 35 | constructor(context: Context) : this(prefs = PreferenceManager.getDefaultSharedPreferences(context)) { 36 | } 37 | 38 | public inner class Preference: ReadWriteProperty { 39 | //val type: T? = null 40 | @Suppress("UNCHECKED_CAST", "IMPLICIT_CAST_TO_UNIT_OR_ANY") 41 | override fun getValue(thisRef: SharedPreferences, property: KProperty<*>): T { 42 | return when (property.returnType.toString()) { 43 | "kotlin.Int?" -> thisRef.getInt(property.name, 0) 44 | "kotlin.Boolean?" -> thisRef.getBoolean(property.name, false) 45 | "kotlin.String?" -> thisRef.getString(property.name, null) 46 | "kotlin.Float?" -> thisRef.getFloat(property.name, 0f) 47 | "kotlin.Long?" -> thisRef.getLong(property.name, 0L) 48 | else -> null 49 | } as T 50 | 51 | /* 52 | return when (type) { 53 | is Int -> { 54 | Log.d(TAG, "is Int"); 55 | thisRef.getInt(property.name, 0) 56 | } 57 | is Boolean -> thisRef.getBoolean(property.name, false) 58 | is String -> { 59 | Log.d(TAG, "is String"); 60 | thisRef.getString(property.name, null) 61 | } 62 | is Float -> thisRef.getFloat(property.name, 0f) 63 | is Long -> thisRef.getLong(property.name, 0L) 64 | else -> { 65 | Log.d(TAG, "is ?"); 66 | null 67 | } 68 | } as T 69 | return when (property.returnType) { 70 | kotlin.Boolean::class.java -> thisRef.getBoolean(property.name, false) 71 | kotlin.Float::class.java -> thisRef.getFloat(property.name, 0f) 72 | kotlin.Int::class.java -> thisRef.getInt(property.name, 0) 73 | kotlin.Long::class.java -> thisRef.getLong(property.name, 0L) 74 | kotlin.String::class.java -> thisRef.getString(property.name, null) 75 | java.lang.Boolean::class.java -> thisRef.getBoolean(property.name, false) 76 | java.lang.Float::class.java -> thisRef.getFloat(property.name, 0f) 77 | java.lang.Integer::class.java -> thisRef.getInt(property.name, 0) 78 | java.lang.Long::class.java -> thisRef.getLong(property.name, 0L) 79 | java.lang.String::class.java -> thisRef.getString(property.name, null) 80 | } as T 81 | */ 82 | } 83 | 84 | override fun setValue(thisRef: SharedPreferences, property: KProperty<*>, value: T) { 85 | when (value) { 86 | is Int -> editor.putInt(property.name, value) 87 | is Boolean -> editor.putBoolean(property.name, value) 88 | is String -> editor.putString(property.name, value) 89 | is Float -> editor.putFloat(property.name, value) 90 | is Long -> editor.putLong(property.name, value) 91 | else -> null!! 92 | } 93 | } 94 | } 95 | 96 | public inner class IntPreference: ReadWriteProperty { 97 | override fun getValue(thisRef: SharedPreferences, property: KProperty<*>): Int { 98 | return thisRef.getInt(property.name, 0) 99 | } 100 | 101 | override fun setValue(thisRef: SharedPreferences, property: KProperty<*>, value: Int) { 102 | editor.putInt(property.name, value) 103 | } 104 | } 105 | 106 | public inner class StringPreference: ReadWriteProperty { 107 | override fun getValue(thisRef: SharedPreferences, property: KProperty<*>): String { 108 | return thisRef.getString(property.name, null) 109 | } 110 | 111 | override fun setValue(thisRef: SharedPreferences, property: KProperty<*>, value: String) { 112 | editor.putString(property.name, value) 113 | } 114 | } 115 | 116 | /* 117 | TODO 118 | fun edit(func: T?.() -> Unit) { 119 | func() 120 | editor.apply() 121 | } 122 | */ 123 | } 124 | -------------------------------------------------------------------------------- /kotlinx-android-sharedpreferences/src/main/kotlin/kotlinx/android/sharedpreferences/SharedPreferencesExt.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2015 8tory, Inc 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package kotlinx.android.sharedpreferences 18 | 19 | import android.content.SharedPreferences 20 | 21 | /** 22 | * Created by andrew on 11/28/15. 23 | */ 24 | inline fun SharedPreferences.edit(func: SharedPreferences.Editor.() -> Unit) { 25 | val editor = edit() 26 | editor.func() 27 | editor.apply() 28 | } 29 | -------------------------------------------------------------------------------- /kotlinx-android-support-v4/.gitignore: -------------------------------------------------------------------------------- 1 | /build 2 | -------------------------------------------------------------------------------- /kotlinx-android-support-v4/build.gradle: -------------------------------------------------------------------------------- 1 | apply plugin: 'com.android.library' 2 | apply plugin: 'kotlin-android' 3 | apply plugin: 'kotlin-android-extensions' 4 | 5 | android { 6 | compileSdkVersion 26 7 | 8 | defaultConfig { 9 | minSdkVersion 15 10 | targetSdkVersion rootProject.ext.targetSdkVersion 11 | } 12 | 13 | buildTypes { 14 | release { 15 | minifyEnabled false 16 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' 17 | } 18 | } 19 | 20 | sourceSets { 21 | main.java.srcDirs += 'src/main/kotlin' 22 | } 23 | } 24 | 25 | dependencies { 26 | implementation "com.android.support:support-v4:$support_version" 27 | } -------------------------------------------------------------------------------- /kotlinx-android-support-v4/proguard-rules.pro: -------------------------------------------------------------------------------- 1 | # Add project specific ProGuard rules here. 2 | # You can control the set of applied configuration files using the 3 | # proguardFiles setting in build.gradle. 4 | # 5 | # For more details, see 6 | # http://developer.android.com/guide/developing/tools/proguard.html 7 | 8 | # If your project uses WebView with JS, uncomment the following 9 | # and specify the fully qualified class name to the JavaScript interface 10 | # class: 11 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview { 12 | # public *; 13 | #} 14 | 15 | # Uncomment this to preserve the line number information for 16 | # debugging stack traces. 17 | #-keepattributes SourceFile,LineNumberTable 18 | 19 | # If you keep the line number information, uncomment this to 20 | # hide the original source file name. 21 | #-renamesourcefileattribute SourceFile 22 | -------------------------------------------------------------------------------- /kotlinx-android-support-v4/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /kotlinx-android-support-v4/src/main/kotlin/kotlinx/android/support/v4/ActivityExt.kt: -------------------------------------------------------------------------------- 1 | package kotlinx.android.support.v4 2 | 3 | import android.content.Context 4 | import android.support.annotation.ColorRes 5 | import android.support.annotation.StringRes 6 | import android.support.v4.app.FragmentActivity 7 | import android.support.v4.app.FragmentTransaction 8 | import android.support.v4.content.ContextCompat 9 | import android.widget.Toast 10 | 11 | fun FragmentActivity.toast(@StringRes resourceId: Int, length: Int = Toast.LENGTH_SHORT) { 12 | toast(getString(resourceId), length) 13 | } 14 | 15 | fun FragmentActivity.toast(message: String, length: Int = Toast.LENGTH_SHORT) { 16 | Toast.makeText(this, message, length).show() 17 | } 18 | 19 | fun Context.color(@ColorRes colorResource: Int): Int { 20 | return ContextCompat.getColor(this, colorResource) 21 | } 22 | 23 | inline fun FragmentActivity.fragmentTransaction(function: FragmentTransaction.() -> FragmentTransaction) { 24 | supportFragmentManager.beginTransaction() 25 | .function() 26 | .commit() 27 | } 28 | -------------------------------------------------------------------------------- /kotlinx-android-support-v4/src/main/kotlin/kotlinx/android/support/v4/FragmentExt.kt: -------------------------------------------------------------------------------- 1 | package kotlinx.android.support.v4 2 | 3 | import android.support.annotation.ColorRes 4 | import android.support.annotation.StringRes 5 | import android.support.v4.app.Fragment 6 | import android.support.v4.app.FragmentTransaction 7 | import android.support.v4.content.ContextCompat 8 | import android.widget.Toast 9 | 10 | fun Fragment.toast(@StringRes resourceId: Int, length: Int = Toast.LENGTH_SHORT) { 11 | activity.toast(resourceId, length) 12 | } 13 | 14 | fun Fragment.toast(message: String, length: Int = Toast.LENGTH_SHORT) { 15 | activity.toast(message, length) 16 | } 17 | 18 | fun Fragment.colorFromResource(@ColorRes colorResource: Int): Int { 19 | return ContextCompat.getColor(activity, colorResource) 20 | } 21 | 22 | inline fun Fragment.fragmentTransaction(function: FragmentTransaction.() -> FragmentTransaction) { 23 | fragmentManager.beginTransaction() 24 | .function() 25 | .commit() 26 | } 27 | -------------------------------------------------------------------------------- /kotlinx-android-system-services/.gitignore: -------------------------------------------------------------------------------- 1 | /build 2 | -------------------------------------------------------------------------------- /kotlinx-android-system-services/android-javadoc.gradle: -------------------------------------------------------------------------------- 1 | // build a jar with source files 2 | task sourcesJar(type: Jar) { 3 | from android.sourceSets.main.java.srcDirs 4 | classifier = 'sources' 5 | } 6 | 7 | task javadoc(type: Javadoc) { 8 | failOnError false 9 | source = android.sourceSets.main.java.sourceFiles 10 | classpath += project.files(android.getBootClasspath().join(File.pathSeparator)) 11 | } 12 | 13 | // build a jar with javadoc 14 | task javadocJar(type: Jar, dependsOn: javadoc) { 15 | classifier = 'javadoc' 16 | from javadoc.destinationDir 17 | } 18 | 19 | artifacts { 20 | archives sourcesJar 21 | archives javadocJar 22 | } 23 | -------------------------------------------------------------------------------- /kotlinx-android-system-services/build.gradle: -------------------------------------------------------------------------------- 1 | apply plugin: 'com.android.library' 2 | apply plugin: 'kotlin-android' 3 | apply plugin: 'kotlin-android-extensions' 4 | 5 | android { 6 | compileSdkVersion rootProject.ext.compileSdkVersion 7 | buildToolsVersion rootProject.ext.buildToolsVersion 8 | defaultConfig { 9 | minSdkVersion 15 10 | targetSdkVersion rootProject.ext.targetSdkVersion 11 | } 12 | buildTypes { 13 | release { 14 | minifyEnabled false 15 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' 16 | } 17 | } 18 | productFlavors { 19 | } 20 | 21 | sourceSets { 22 | main.java.srcDirs += 'src/main/kotlin' 23 | } 24 | } 25 | 26 | dependencies { 27 | compile "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version" 28 | 29 | // testCompile mockito 30 | // testCompile assertj-android 31 | // testCompile expresso 32 | // testCompile junit 33 | } 34 | 35 | apply plugin: 'com.github.dcendents.android-maven' 36 | apply from: 'android-javadoc.gradle' 37 | -------------------------------------------------------------------------------- /kotlinx-android-system-services/proguard-rules.pro: -------------------------------------------------------------------------------- 1 | # Add project specific ProGuard rules here. 2 | # By default, the flags in this file are appended to flags specified 3 | # in /Users/rondouchen/Library/Android/sdk/tools/proguard/proguard-android.txt 4 | # You can edit the include path and order by changing the proguardFiles 5 | # directive in build.gradle. 6 | # 7 | # For more details, see 8 | # http://developer.android.com/guide/developing/tools/proguard.html 9 | 10 | # Add any project specific keep options here: 11 | 12 | # If your project uses WebView with JS, uncomment the following 13 | # and specify the fully qualified class name to the JavaScript interface 14 | # class: 15 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview { 16 | # public *; 17 | #} 18 | -------------------------------------------------------------------------------- /kotlinx-android-system-services/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | -------------------------------------------------------------------------------- /kotlinx-android-system-services/src/main/kotlin/kotlinx/android/system/services/SystemServicesExt.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2015 8tory, Inc 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package kotlinx.android.system.services 18 | 19 | import android.accounts.AccountManager 20 | import android.app.ActivityManager 21 | import android.app.AlarmManager 22 | import android.app.AppOpsManager 23 | import android.app.DownloadManager 24 | import android.app.KeyguardManager 25 | import android.app.NotificationManager 26 | import android.app.SearchManager 27 | import android.app.UiModeManager 28 | import android.app.admin.DevicePolicyManager 29 | import android.app.job.JobScheduler 30 | import android.app.usage.NetworkStatsManager 31 | import android.app.usage.UsageStatsManager 32 | import android.appwidget.AppWidgetManager 33 | import android.bluetooth.BluetoothManager 34 | import android.content.ClipboardManager 35 | import android.content.Context 36 | import android.content.RestrictionsManager 37 | import android.content.pm.LauncherApps 38 | import android.hardware.ConsumerIrManager 39 | import android.hardware.SensorManager 40 | import android.hardware.camera2.CameraManager 41 | import android.hardware.display.DisplayManager 42 | import android.hardware.fingerprint.FingerprintManager 43 | import android.hardware.input.InputManager 44 | import android.hardware.usb.UsbManager 45 | import android.location.LocationManager 46 | import android.media.AudioManager 47 | import android.media.MediaRouter 48 | import android.media.midi.MidiManager 49 | import android.media.projection.MediaProjectionManager 50 | import android.media.session.MediaSessionManager 51 | import android.media.tv.TvInputManager 52 | import android.net.ConnectivityManager 53 | import android.net.nsd.NsdManager 54 | import android.net.wifi.WifiManager 55 | import android.net.wifi.p2p.WifiP2pManager 56 | import android.nfc.NfcManager 57 | import android.os.BatteryManager 58 | import android.os.DropBoxManager 59 | import android.os.PowerManager 60 | import android.os.UserManager 61 | import android.os.Vibrator 62 | import android.os.storage.StorageManager 63 | import android.print.PrintManager 64 | import android.service.wallpaper.WallpaperService 65 | import android.telecom.TelecomManager 66 | import android.telephony.CarrierConfigManager 67 | import android.telephony.SubscriptionManager 68 | import android.telephony.TelephonyManager 69 | import android.view.LayoutInflater 70 | import android.view.WindowManager 71 | import android.view.accessibility.AccessibilityManager 72 | import android.view.accessibility.CaptioningManager 73 | import android.view.inputmethod.InputMethodManager 74 | import android.view.textservice.TextServicesManager 75 | 76 | fun Context.getActivityManager() = getSystemService(Context.ACTIVITY_SERVICE) as ActivityManager 77 | fun Context.getAlarmManager() = getSystemService(Context.ALARM_SERVICE) as AlarmManager 78 | fun Context.getAudioManager() = getSystemService(Context.AUDIO_SERVICE) as AudioManager 79 | fun Context.getClipboardManager() = getSystemService(Context.CLIPBOARD_SERVICE) as ClipboardManager 80 | fun Context.getConnectivityManager() = getSystemService(Context.CONNECTIVITY_SERVICE) as ConnectivityManager 81 | fun Context.getKeyguardManager() = getSystemService(Context.KEYGUARD_SERVICE) as KeyguardManager 82 | fun Context.getLayoutInflater() = getSystemService(Context.LAYOUT_INFLATER_SERVICE) as LayoutInflater 83 | fun Context.getLocationManager() = getSystemService(Context.LOCATION_SERVICE) as LocationManager 84 | fun Context.getNotificationManager() = getSystemService(Context.NOTIFICATION_SERVICE) as NotificationManager 85 | fun Context.getPowerManager() = getSystemService(Context.POWER_SERVICE) as PowerManager 86 | fun Context.getSearchManager() = getSystemService(Context.SEARCH_SERVICE) as SearchManager 87 | fun Context.getSensorManager() = getSystemService(Context.SENSOR_SERVICE) as SensorManager 88 | fun Context.getTelephonyManager() = getSystemService(Context.TELEPHONY_SERVICE) as TelephonyManager 89 | fun Context.getVibrator() = getSystemService(Context.VIBRATOR_SERVICE) as Vibrator 90 | fun Context.getWallpaperService() = getSystemService(Context.WALLPAPER_SERVICE) as WallpaperService 91 | fun Context.getWifiManager() = getSystemService(Context.WIFI_SERVICE) as WifiManager 92 | fun Context.getWindowManager() = getSystemService(Context.WINDOW_SERVICE) as WindowManager 93 | fun Context.getInputMethodManager() = getSystemService(Context.INPUT_METHOD_SERVICE) as InputMethodManager 94 | fun Context.getAccessibilityManager() = getSystemService(Context.ACCESSIBILITY_SERVICE) as AccessibilityManager 95 | fun Context.getAccountManager() = getSystemService(Context.ACCOUNT_SERVICE) as AccountManager 96 | fun Context.getDevicePolicyManager() = getSystemService(Context.DEVICE_POLICY_SERVICE) as DevicePolicyManager 97 | fun Context.getDropBoxManager() = getSystemService(Context.DROPBOX_SERVICE) as DropBoxManager 98 | fun Context.getUiModeManager() = getSystemService(Context.UI_MODE_SERVICE) as UiModeManager 99 | fun Context.getDownloadManager() = getSystemService(Context.DOWNLOAD_SERVICE) as DownloadManager 100 | fun Context.getStorageManager() = getSystemService(Context.STORAGE_SERVICE) as StorageManager 101 | fun Context.getNfcManager() = getSystemService(Context.NFC_SERVICE) as NfcManager 102 | fun Context.getUsbManager() = getSystemService(Context.USB_SERVICE) as UsbManager 103 | fun Context.getTextServicesManager() = getSystemService(Context.TEXT_SERVICES_MANAGER_SERVICE) as TextServicesManager 104 | fun Context.getWifiP2pManager() = getSystemService(Context.WIFI_P2P_SERVICE) as WifiP2pManager 105 | fun Context.getInputManager() = getSystemService(Context.INPUT_SERVICE) as InputManager 106 | fun Context.getMediaRouter() = getSystemService(Context.MEDIA_ROUTER_SERVICE) as MediaRouter 107 | fun Context.getNsdManager() = getSystemService(Context.NSD_SERVICE) as NsdManager 108 | fun Context.getDisplayManager() = getSystemService(Context.DISPLAY_SERVICE) as DisplayManager 109 | fun Context.getUserManager() = getSystemService(Context.USER_SERVICE) as UserManager 110 | fun Context.getBluetoothManager() = getSystemService(Context.BLUETOOTH_SERVICE) as BluetoothManager 111 | fun Context.getAppOpsManager() = getSystemService(Context.APP_OPS_SERVICE) as AppOpsManager 112 | fun Context.getCaptioningManager() = getSystemService(Context.CAPTIONING_SERVICE) as CaptioningManager 113 | fun Context.getConsumerIrManager() = getSystemService(Context.CONSUMER_IR_SERVICE) as ConsumerIrManager 114 | fun Context.getPrintManager() = getSystemService(Context.PRINT_SERVICE) as PrintManager 115 | fun Context.getAppWidgetManager() = getSystemService(Context.APPWIDGET_SERVICE) as AppWidgetManager 116 | fun Context.getBatteryManager() = getSystemService(Context.BATTERY_SERVICE) as BatteryManager 117 | fun Context.getCameraManager() = getSystemService(Context.CAMERA_SERVICE) as CameraManager 118 | fun Context.getJobScheduler() = getSystemService(Context.JOB_SCHEDULER_SERVICE) as JobScheduler 119 | fun Context.getLauncherApps() = getSystemService(Context.LAUNCHER_APPS_SERVICE) as LauncherApps 120 | fun Context.getMediaProjectionManager() = getSystemService(Context.MEDIA_PROJECTION_SERVICE) as MediaProjectionManager 121 | fun Context.getMediaSessionManager() = getSystemService(Context.MEDIA_SESSION_SERVICE) as MediaSessionManager 122 | fun Context.getRestrictionsManager() = getSystemService(Context.RESTRICTIONS_SERVICE) as RestrictionsManager 123 | fun Context.getTelecomManager() = getSystemService(Context.TELECOM_SERVICE) as TelecomManager 124 | fun Context.getTvInputManager() = getSystemService(Context.TV_INPUT_SERVICE) as TvInputManager 125 | fun Context.getSubscriptionManager() = getSystemService(Context.TELEPHONY_SUBSCRIPTION_SERVICE) as SubscriptionManager 126 | fun Context.getUsageStatsManager() = getSystemService(Context.USAGE_STATS_SERVICE) as UsageStatsManager 127 | fun Context.getCarrierConfigManager() = getSystemService(Context.CARRIER_CONFIG_SERVICE) as CarrierConfigManager 128 | fun Context.getFingerprintManager() = getSystemService(Context.FINGERPRINT_SERVICE) as FingerprintManager 129 | fun Context.getMidiManager() = getSystemService(Context.MIDI_SERVICE) as MidiManager 130 | fun Context.getNetworkStatsManager() = getSystemService(Context.NETWORK_STATS_SERVICE) as NetworkStatsManager 131 | /* 132 | inline fun Context.activityManager() = getSystemService(ActivityManager.class) 133 | inline fun Context.alarmManager() = getSystemService(AlarmManager.class) 134 | inline fun Context.audioManager() = getSystemService(AudioManager.class) 135 | inline fun Context.clipboardManager() = getSystemService(ClipboardManager.class) 136 | inline fun Context.connectivityManager() = getSystemService(ConnectivityManager.class) 137 | inline fun Context.keyguardManager() = getSystemService(KeyguardManager.class) 138 | inline fun Context.layoutInflater() = getSystemService(LayoutInflater.class) 139 | inline fun Context.locationManager() = getSystemService(LocationManager.class) 140 | inline fun Context.notificationManager() = getSystemService(NotificationManager.class) 141 | inline fun Context.powerManager() = getSystemService(PowerManager.class) 142 | inline fun Context.searchManager() = getSystemService(SearchManager.class) 143 | inline fun Context.sensorManager() = getSystemService(SensorManager.class) 144 | inline fun Context.telephonyManager() = getSystemService(TelephonyManager.class) 145 | inline fun Context.vibrator() = getSystemService(Vibrator.class) 146 | inline fun Context.wallpaperService() = getSystemService(WallpaperService.class) 147 | inline fun Context.wifiManager() = getSystemService(WifiManager.class) 148 | inline fun Context.windowManager() = getSystemService(WindowManager.class) 149 | inline fun Context.inputMethodManager() = getSystemService(InputMethodManager.class) 150 | inline fun Context.accessibilityManager() = getSystemService(AccessibilityManager.class) 151 | inline fun Context.accountManager() = getSystemService(AccountManager.class) 152 | inline fun Context.devicePolicyManager() = getSystemService(DevicePolicyManager.class) 153 | inline fun Context.dropBoxManager() = getSystemService(DropBoxManager.class) 154 | inline fun Context.uiModeManager() = getSystemService(UiModeManager.class) 155 | inline fun Context.downloadManager() = getSystemService(DownloadManager.class) 156 | inline fun Context.storageManager() = getSystemService(StorageManager.class) 157 | inline fun Context.nfcManager() = getSystemService(NfcManager.class) 158 | inline fun Context.usbManager() = getSystemService(UsbManager.class) 159 | inline fun Context.textServicesManager() = getSystemService(TextServicesManager.class) 160 | inline fun Context.wifiP2pManager() = getSystemService(WifiP2pManager.class) 161 | inline fun Context.inputManager() = getSystemService(InputManager.class) 162 | inline fun Context.mediaRouter() = getSystemService(MediaRouter.class) 163 | inline fun Context.nsdManager() = getSystemService(NsdManager.class) 164 | inline fun Context.displayManager() = getSystemService(DisplayManager.class) 165 | inline fun Context.userManager() = getSystemService(UserManager.class) 166 | inline fun Context.bluetoothManager() = getSystemService(BluetoothManager.class) 167 | inline fun Context.appOpsManager() = getSystemService(AppOpsManager.class) 168 | inline fun Context.captioningManager() = getSystemService(CaptioningManager.class) 169 | inline fun Context.consumerIrManager() = getSystemService(ConsumerIrManager.class) 170 | inline fun Context.printManager() = getSystemService(PrintManager.class) 171 | inline fun Context.appWidgetManager() = getSystemService(AppWidgetManager.class) 172 | inline fun Context.batteryManager() = getSystemService(BatteryManager.class) 173 | inline fun Context.cameraManager() = getSystemService(CameraManager.class) 174 | inline fun Context.jobScheduler() = getSystemService(JobScheduler.class) 175 | inline fun Context.launcherApps() = getSystemService(LauncherApps.class) 176 | inline fun Context.mediaProjectionManager() = getSystemService(MediaProjectionManager.class) 177 | inline fun Context.mediaSessionManager() = getSystemService(MediaSessionManager.class) 178 | inline fun Context.restrictionsManager() = getSystemService(RestrictionsManager.class) 179 | inline fun Context.telecomManager() = getSystemService(TelecomManager.class) 180 | inline fun Context.tvInputManager() = getSystemService(TvInputManager.class) 181 | inline fun Context.subscriptionManager() = getSystemService(SubscriptionManager.class) 182 | inline fun Context.usageStatsManager() = getSystemService(UsageStatsManager.class) 183 | inline fun Context.carrierConfigManager() = getSystemService(CarrierConfigManager.class) 184 | inline fun Context.fingerprintManager() = getSystemService(FingerprintManager.class) 185 | inline fun Context.midiManager() = getSystemService(MidiManager.class) 186 | inline fun Context.networkStatsManager() = getSystemService(NetworkStatsManager.class) 187 | */ 188 | -------------------------------------------------------------------------------- /kotlinx-android-view/.gitignore: -------------------------------------------------------------------------------- 1 | /build 2 | -------------------------------------------------------------------------------- /kotlinx-android-view/android-javadoc.gradle: -------------------------------------------------------------------------------- 1 | // build a jar with source files 2 | task sourcesJar(type: Jar) { 3 | from android.sourceSets.main.java.srcDirs 4 | classifier = 'sources' 5 | } 6 | 7 | task javadoc(type: Javadoc) { 8 | failOnError false 9 | source = android.sourceSets.main.java.sourceFiles 10 | classpath += project.files(android.getBootClasspath().join(File.pathSeparator)) 11 | } 12 | 13 | // build a jar with javadoc 14 | task javadocJar(type: Jar, dependsOn: javadoc) { 15 | classifier = 'javadoc' 16 | from javadoc.destinationDir 17 | } 18 | 19 | artifacts { 20 | archives sourcesJar 21 | archives javadocJar 22 | } 23 | -------------------------------------------------------------------------------- /kotlinx-android-view/build.gradle: -------------------------------------------------------------------------------- 1 | apply plugin: 'com.android.library' 2 | apply plugin: 'kotlin-android' 3 | apply plugin: 'kotlin-android-extensions' 4 | 5 | android { 6 | compileSdkVersion rootProject.ext.compileSdkVersion 7 | buildToolsVersion rootProject.ext.buildToolsVersion 8 | defaultConfig { 9 | minSdkVersion 15 10 | targetSdkVersion rootProject.ext.targetSdkVersion 11 | } 12 | buildTypes { 13 | release { 14 | minifyEnabled false 15 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' 16 | } 17 | } 18 | productFlavors { 19 | } 20 | 21 | sourceSets { 22 | main.java.srcDirs += 'src/main/kotlin' 23 | } 24 | } 25 | 26 | dependencies { 27 | compile "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version" 28 | //compile "com.android.support:support-v4:$support_version" 29 | compile "com.android.support:support-annotations:$support_version" 30 | 31 | // testCompile mockito 32 | // testCompile assertj-android 33 | // testCompile expresso 34 | // testCompile junit 35 | } 36 | 37 | apply plugin: 'com.github.dcendents.android-maven' 38 | apply from: 'android-javadoc.gradle' 39 | -------------------------------------------------------------------------------- /kotlinx-android-view/proguard-rules.pro: -------------------------------------------------------------------------------- 1 | # Add project specific ProGuard rules here. 2 | # By default, the flags in this file are appended to flags specified 3 | # in /Users/rondouchen/Library/Android/sdk/tools/proguard/proguard-android.txt 4 | # You can edit the include path and order by changing the proguardFiles 5 | # directive in build.gradle. 6 | # 7 | # For more details, see 8 | # http://developer.android.com/guide/developing/tools/proguard.html 9 | 10 | # Add any project specific keep options here: 11 | 12 | # If your project uses WebView with JS, uncomment the following 13 | # and specify the fully qualified class name to the JavaScript interface 14 | # class: 15 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview { 16 | # public *; 17 | #} 18 | -------------------------------------------------------------------------------- /kotlinx-android-view/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | -------------------------------------------------------------------------------- /kotlinx-android-view/src/main/kotlin/kotlinx/android/view/Traces.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2017 Andrew Chen 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package kotlinx.android.trace 18 | 19 | import android.os.Trace 20 | 21 | inline fun trace(sectionName: String, body: () -> T): T { 22 | Trace.beginSection(sectionName) 23 | try { 24 | return body() 25 | } finally { 26 | Trace.endSection() 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /kotlinx-android-view/src/main/kotlin/kotlinx/android/view/ViewGroups.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2017 Andrew Chen 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package kotlinx.android.view 18 | 19 | import android.support.annotation.LayoutRes 20 | import android.view.LayoutInflater 21 | import android.view.View 22 | import android.view.ViewGroup 23 | 24 | /** 25 | * ref. https://www.youtube.com/watch?v=fPzxfeDJDzY 26 | */ 27 | 28 | inline fun ViewGroup.inflate(@LayoutRes l: Int): View = 29 | LayoutInflater.from(context).inflate(l, this, false) 30 | 31 | inline operator fun ViewGroup.get(i: Int): View? = getChildAt(i) 32 | 33 | /** 34 | * -= 35 | */ 36 | inline operator fun ViewGroup.minusAssign(child: View) = removeView(child) 37 | 38 | /** 39 | * += 40 | */ 41 | inline operator fun ViewGroup.plusAssign(child: View) = addView(child) 42 | 43 | /** 44 | * if (viwe in views) 45 | */ 46 | inline fun ViewGroup.contains(child: View) = indexOfChild(child) != -1 47 | 48 | inline fun ViewGroup.first(): View? = this[0] 49 | 50 | inline fun ViewGroup.forEach(action: (View) -> Unit) { 51 | for (i in 0 until childCount) { 52 | action(getChildAt(i)) 53 | } 54 | } 55 | 56 | inline fun ViewGroup.forEachIndexed(action: (Int, View) -> Unit) { 57 | for (i in 0 until childCount) { 58 | action(i, getChildAt(i)) 59 | } 60 | } 61 | 62 | /** 63 | * for (view in views.children()) 64 | */ 65 | inline fun ViewGroup.children() = object : Iterable { 66 | override fun iterator() = object : Iterator { 67 | var index = 0 68 | override fun hasNext() = index < childCount 69 | override fun next() = getChildAt(index++) 70 | } 71 | } 72 | -------------------------------------------------------------------------------- /kotlinx-android-view/src/main/kotlin/kotlinx/android/view/Views.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2017 Andrew Chen 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package kotlinx.android.view 18 | 19 | import android.graphics.Color 20 | import android.os.Bundle 21 | //import android.support.annotation.MainThread 22 | import android.support.annotation.UiThread 23 | import android.text.Editable 24 | import android.text.TextWatcher 25 | import android.view.LayoutInflater 26 | import android.view.View 27 | import android.view.ViewGroup 28 | import android.view.animation.AlphaAnimation 29 | import android.view.animation.Animation 30 | import android.widget.TextView 31 | 32 | @UiThread 33 | inline fun View.fadeOut() { 34 | fadeOut(500) 35 | } 36 | 37 | @UiThread 38 | inline fun View.fadeIn() { 39 | fadeIn(500) 40 | } 41 | 42 | @UiThread 43 | inline fun View.fadeIn(duration: Long) { 44 | this.clearAnimation() 45 | val anim = AlphaAnimation(this.alpha, 1.0f) 46 | anim.duration = duration 47 | this.startAnimation(anim) 48 | } 49 | 50 | @UiThread 51 | inline fun View.fadeOut(duration: Long) { 52 | this.clearAnimation() 53 | val anim = AlphaAnimation(this.alpha, 0.0f) 54 | anim.duration = duration 55 | this.startAnimation(anim) 56 | } 57 | -------------------------------------------------------------------------------- /kotlinx-gson/.gitignore: -------------------------------------------------------------------------------- 1 | /build 2 | -------------------------------------------------------------------------------- /kotlinx-gson/build.gradle: -------------------------------------------------------------------------------- 1 | buildscript { 2 | repositories { 3 | jcenter() 4 | } 5 | dependencies { 6 | classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version" 7 | } 8 | } 9 | 10 | apply plugin: 'kotlin' 11 | 12 | dependencies { 13 | compile "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version" 14 | compile "com.google.code.gson:gson:2.8.1" 15 | 16 | // testCompile mockito 17 | // testCompile assertj-android 18 | // testCompile expresso 19 | // testCompile junit 20 | } 21 | 22 | apply plugin: 'maven' 23 | -------------------------------------------------------------------------------- /kotlinx-gson/proguard-rules.pro: -------------------------------------------------------------------------------- 1 | # Add project specific ProGuard rules here. 2 | # By default, the flags in this file are appended to flags specified 3 | # in /Users/rondouchen/Library/Android/sdk/tools/proguard/proguard-android.txt 4 | # You can edit the include path and order by changing the proguardFiles 5 | # directive in build.gradle. 6 | # 7 | # For more details, see 8 | # http://developer.android.com/guide/developing/tools/proguard.html 9 | 10 | # Add any project specific keep options here: 11 | 12 | # If your project uses WebView with JS, uncomment the following 13 | # and specify the fully qualified class name to the JavaScript interface 14 | # class: 15 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview { 16 | # public *; 17 | #} 18 | -------------------------------------------------------------------------------- /kotlinx-gson/src/main/kotlin/kotlinx/gson/GsonExt.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2017 Andrew Chen 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | @file:Suppress("NOTHING_TO_INLINE") 18 | package kotlinx.gson 19 | 20 | import com.google.gson.Gson 21 | 22 | inline fun Gson.fromJson(json: String): T = this.fromJson(json, T::class.java) 23 | -------------------------------------------------------------------------------- /kotlinx-math/.gitignore: -------------------------------------------------------------------------------- 1 | /build 2 | -------------------------------------------------------------------------------- /kotlinx-math/build.gradle: -------------------------------------------------------------------------------- 1 | buildscript { 2 | repositories { 3 | jcenter() 4 | } 5 | dependencies { 6 | classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version" 7 | } 8 | } 9 | 10 | apply plugin: 'kotlin' 11 | 12 | dependencies { 13 | compile "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version" 14 | 15 | // testCompile mockito 16 | // testCompile assertj-android 17 | // testCompile expresso 18 | // testCompile junit 19 | } 20 | 21 | apply plugin: 'maven' 22 | -------------------------------------------------------------------------------- /kotlinx-math/proguard-rules.pro: -------------------------------------------------------------------------------- 1 | # Add project specific ProGuard rules here. 2 | # By default, the flags in this file are appended to flags specified 3 | # in /Users/rondouchen/Library/Android/sdk/tools/proguard/proguard-android.txt 4 | # You can edit the include path and order by changing the proguardFiles 5 | # directive in build.gradle. 6 | # 7 | # For more details, see 8 | # http://developer.android.com/guide/developing/tools/proguard.html 9 | 10 | # Add any project specific keep options here: 11 | 12 | # If your project uses WebView with JS, uncomment the following 13 | # and specify the fully qualified class name to the JavaScript interface 14 | # class: 15 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview { 16 | # public *; 17 | #} 18 | -------------------------------------------------------------------------------- /kotlinx-math/src/main/kotlin/kotlinx/java/lang/MathExt.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2015 Michael Rozumyanskiy 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | @file:Suppress("NOTHING_TO_INLINE") 18 | inline fun Double.sin(): Double = Math.sin(this) 19 | inline fun Double.cos(): Double = Math.cos(this) 20 | inline fun Double.tan(): Double = Math.tan(this) 21 | inline fun Double.asin(): Double = Math.asin(this) 22 | inline fun Double.acos(): Double = Math.acos(this) 23 | inline fun Double.atan(): Double = Math.atan(this) 24 | inline fun Double.toRadians(): Double = Math.toRadians(this) 25 | inline fun Double.toDegrees(): Double = Math.toDegrees(this) 26 | inline fun Double.exp(): Double = Math.exp(this) 27 | inline fun Double.log(): Double = Math.log(this) 28 | inline fun Double.log10(): Double = Math.log10(this) 29 | inline fun Double.sqrt(): Double = Math.sqrt(this) 30 | inline fun Double.cbrt(): Double = Math.cbrt(this) 31 | inline fun Double.IEEEremainder(divisor: Double): Double = Math.IEEEremainder(this, divisor) 32 | inline fun Double.ceil(): Double = Math.ceil(this) 33 | inline fun Double.floor(): Double = Math.floor(this) 34 | inline fun Double.rint(): Double = Math.rint(this) 35 | inline fun Double.atan2(x: Double): Double = Math.atan2(this, x) 36 | inline fun Double.pow(exp: Double): Double = Math.pow(this, exp) 37 | inline fun Double.round(): Long = Math.round(this) 38 | inline fun Double.abs(): Double = Math.abs(this) 39 | inline fun Double.ulp(): Double = Math.ulp(this) 40 | inline fun Double.signum(): Double = Math.signum(this) 41 | inline fun Double.sinh(): Double = Math.sinh(this) 42 | inline fun Double.cosh(): Double = Math.cosh(this) 43 | inline fun Double.tanh(): Double = Math.tanh(this) 44 | inline fun Double.expm1(): Double = Math.expm1(this) 45 | inline fun Double.log1p(): Double = Math.log1p(this) 46 | inline fun Double.copySign(sign: Double): Double = Math.copySign(this, sign) 47 | inline fun Double.exponent(): Int = Math.getExponent(this) 48 | inline fun Double.next(direction: Double): Double = Math.nextAfter(this, direction) 49 | inline fun Double.nextUp(): Double = Math.nextUp(this) 50 | inline fun Double.scalb(scaleFactor: Int): Double = Math.scalb(this, scaleFactor) 51 | inline fun Double.clamp(min: Double, max: Double): Double = Math.max(min, Math.min(this, max)) 52 | 53 | inline fun Float.sin(): Float = FloatMath.sin(this) 54 | inline fun Float.cos(): Float = FloatMath.cos(this) 55 | inline fun Float.tan(): Float = FloatMath.tan(this) 56 | inline fun Float.asin(): Float = FloatMath.asin(this) 57 | inline fun Float.acos(): Float = FloatMath.acos(this) 58 | inline fun Float.atan(): Float = FloatMath.atan(this) 59 | inline fun Float.toRadians(): Float = FloatMath.toRadians(this) 60 | inline fun Float.toDegrees(): Float = FloatMath.toDegrees(this) 61 | inline fun Float.exp(): Float = FloatMath.exp(this) 62 | inline fun Float.log(): Float = FloatMath.log(this) 63 | inline fun Float.log10(): Float = FloatMath.log10(this) 64 | inline fun Float.sqrt(): Float = FloatMath.sqrt(this) 65 | inline fun Float.cbrt(): Float = FloatMath.cbrt(this) 66 | inline fun Float.IEEEremainder(divisor: Float): Float = FloatMath.IEEEremainder(this, divisor) 67 | inline fun Float.ceil(): Float = FloatMath.ceil(this) 68 | inline fun Float.floor(): Float = FloatMath.floor(this) 69 | inline fun Float.rint(): Float = FloatMath.rint(this) 70 | inline fun Float.atan2(x: Float): Float = FloatMath.atan2(this, x) 71 | inline fun Float.pow(exp: Float): Float = FloatMath.pow(this, exp) 72 | inline fun Float.round(): Int = Math.round(this) 73 | inline fun Float.abs(): Float = Math.abs(this) 74 | inline fun Float.ulp(): Float = Math.ulp(this) 75 | inline fun Float.signum(): Float = Math.signum(this) 76 | inline fun Float.sinh(): Float = FloatMath.sinh(this) 77 | inline fun Float.cosh(): Float = FloatMath.cosh(this) 78 | inline fun Float.tanh(): Float = FloatMath.tanh(this) 79 | inline fun Float.expm1(): Float = FloatMath.expm1(this) 80 | inline fun Float.log1p(): Float = FloatMath.log1p(this) 81 | inline fun Float.copySign(sign: Float): Float = Math.copySign(this, sign) 82 | inline fun Float.exponent(): Int = Math.getExponent(this) 83 | inline fun Float.next(direction: Float): Float = FloatMath.nextAfter(this, direction) 84 | inline fun Float.next(direction: Double): Float = Math.nextAfter(this, direction) 85 | inline fun Float.nextUp(): Float = Math.nextUp(this) 86 | inline fun Float.scalb(scaleFactor: Int): Float = Math.scalb(this, scaleFactor) 87 | inline fun Float.clamp(min: Float, max: Float): Float = Math.max(min, Math.min(this, max)) 88 | 89 | object FloatMath { 90 | val PI: Float = Math.PI.toFloat() 91 | val E: Float = Math.E.toFloat() 92 | 93 | inline fun sin(value: Float): Float = Math.sin(value.toDouble()).toFloat() 94 | inline fun cos(value: Float): Float = Math.cos(value.toDouble()).toFloat() 95 | inline fun tan(value: Float): Float = Math.tan(value.toDouble()).toFloat() 96 | inline fun sqrt(value: Float): Float = Math.sqrt(value.toDouble()).toFloat() 97 | inline fun acos(value: Float): Float = Math.acos(value.toDouble()).toFloat() 98 | inline fun asin(value: Float): Float = Math.asin(value.toDouble()).toFloat() 99 | inline fun atan(value: Float): Float = Math.atan(value.toDouble()).toFloat() 100 | inline fun atan2(x: Float, y: Float): Float = Math.atan2(x.toDouble(), y.toDouble()).toFloat() 101 | inline fun pow(x: Float, y: Float): Float = Math.pow(x.toDouble(), y.toDouble()).toFloat() 102 | inline fun ceil(x: Float): Float = Math.ceil(x.toDouble()).toFloat() 103 | inline fun floor(x: Float): Float = Math.floor(x.toDouble()).toFloat() 104 | inline fun toRadians(angdeg: Float): Float = Math.toRadians(angdeg.toDouble()).toFloat() 105 | inline fun toDegrees(angrad: Float): Float = Math.toDegrees(angrad.toDouble()).toFloat() 106 | inline fun exp(x: Float): Float = Math.exp(x.toDouble()).toFloat() 107 | inline fun log(x: Float): Float = Math.log(x.toDouble()).toFloat() 108 | inline fun log10(x: Float): Float = Math.log10(x.toDouble()).toFloat() 109 | inline fun cbrt(x: Float): Float = Math.cbrt(x.toDouble()).toFloat() 110 | inline fun IEEEremainder(x: Float, y: Float): Float = Math.IEEEremainder(x.toDouble(), y.toDouble()).toFloat() 111 | inline fun rint(x: Float): Float = Math.rint(x.toDouble()).toFloat() 112 | inline fun sinh(x: Float): Float = Math.sinh(x.toDouble()).toFloat() 113 | inline fun cosh(x: Float): Float = Math.cosh(x.toDouble()).toFloat() 114 | inline fun tanh(x: Float): Float = Math.tanh(x.toDouble()).toFloat() 115 | inline fun expm1(x: Float): Float = Math.expm1(x.toDouble()).toFloat() 116 | inline fun log1p(x: Float): Float = Math.log1p(x.toDouble()).toFloat() 117 | inline fun nextAfter(start: Float, direction: Float): Float = Math.nextAfter(start, direction.toDouble()) 118 | inline fun clamp(value: Float, min: Float, max: Float): Float = Math.max(min, Math.min(value, max)) 119 | } 120 | -------------------------------------------------------------------------------- /kotlinx-threetenbp/.gitignore: -------------------------------------------------------------------------------- 1 | /build 2 | -------------------------------------------------------------------------------- /kotlinx-threetenbp/build.gradle: -------------------------------------------------------------------------------- 1 | buildscript { 2 | repositories { 3 | jcenter() 4 | } 5 | dependencies { 6 | classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version" 7 | } 8 | } 9 | 10 | apply plugin: 'kotlin' 11 | 12 | dependencies { 13 | compile "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version" 14 | 15 | compile group: 'org.threeten', name: 'threetenbp', version: '1.3.3', classifier: 'no-tzdb' 16 | 17 | testCompile 'junit:junit:4.12' 18 | //testCompile 'org.mockito:mockito-core:2.2.9' 19 | //testCompile 'org.amshove.kluent:kluent:1.10' 20 | //testCompile "org.jetbrains.spek:spek:1.0.+" 21 | testCompile 'org.threeten:threetenbp:1.3.3' 22 | } 23 | 24 | apply plugin: 'maven' 25 | -------------------------------------------------------------------------------- /kotlinx-threetenbp/proguard-rules.pro: -------------------------------------------------------------------------------- 1 | # Add project specific ProGuard rules here. 2 | # By default, the flags in this file are appended to flags specified 3 | # in /Users/rondouchen/Library/Android/sdk/tools/proguard/proguard-android.txt 4 | # You can edit the include path and order by changing the proguardFiles 5 | # directive in build.gradle. 6 | # 7 | # For more details, see 8 | # http://developer.android.com/guide/developing/tools/proguard.html 9 | 10 | # Add any project specific keep options here: 11 | 12 | # If your project uses WebView with JS, uncomment the following 13 | # and specify the fully qualified class name to the JavaScript interface 14 | # class: 15 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview { 16 | # public *; 17 | #} 18 | -------------------------------------------------------------------------------- /kotlinx-threetenbp/src/main/kotlin/kotlinx/threeten/bp/ThreeTenExt.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2017 Andrew Chen 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | @file:Suppress("NOTHING_TO_INLINE") 18 | 19 | package kotlinx.threeten.bp 20 | 21 | import org.threeten.bp.DateTimeUtils 22 | import org.threeten.bp.ZoneId 23 | import org.threeten.bp.LocalDateTime 24 | import java.util.Date 25 | 26 | inline fun Date.toLocalDateTime() = 27 | DateTimeUtils.toInstant(this).atZone(ZoneId.systemDefault()).toLocalDateTime() 28 | 29 | inline fun LocalDateTime.toDate() = 30 | DateTimeUtils.toDate(this.atZone(ZoneId.systemDefault()).toInstant()) 31 | 32 | //val LocalDateTime.epochSecond: Long 33 | inline fun LocalDateTime.toEpochSecond() = this.atZone(ZoneId.systemDefault()).toInstant().epochSecond 34 | -------------------------------------------------------------------------------- /settings.gradle: -------------------------------------------------------------------------------- 1 | include ':app' 2 | include ':kotlinx-android-app' 3 | include ':kotlinx-android-support-v4' 4 | include ':kotlinx-android-sharedpreferences' 5 | include ':kotlinx-android-database' 6 | include ':kotlinx-android-system-services' 7 | include ':kotlinx-android-notification' 8 | include ':kotlinx-math' 9 | include ':kotlinx-threetenbp' 10 | include ':kotlinx-android-view' 11 | include ':kotlinx-gson' 12 | --------------------------------------------------------------------------------