├── .gitignore ├── .idea ├── checkstyle-idea.xml └── copyright │ ├── Apache_2_0.xml │ └── profiles_settings.xml ├── LICENSE ├── README.md ├── app ├── .gitignore ├── build.gradle ├── proguard-rules.pro └── src │ ├── androidTest │ └── java │ │ └── com │ │ └── adriangl │ │ └── devquicktiles │ │ └── ExampleInstrumentedTest.java │ ├── main │ ├── AndroidManifest.xml │ ├── kotlin │ │ └── com │ │ │ └── adriangl │ │ │ └── devquicktiles │ │ │ ├── MainActivity.kt │ │ │ ├── base │ │ │ └── BaseApplication.kt │ │ │ ├── tiles │ │ │ ├── DevelopmentTileService.kt │ │ │ ├── animatorduration │ │ │ │ └── AnimatorDurationTileService.kt │ │ │ ├── demomode │ │ │ │ ├── DemoMode.kt │ │ │ │ └── DemoModeTileService.kt │ │ │ ├── finishactivities │ │ │ │ └── FinishActivitiesTileService.kt │ │ │ ├── screenon │ │ │ │ └── KeepScreenOnTileService.kt │ │ │ ├── show_taps │ │ │ │ └── ShowTapsTileService.kt │ │ │ ├── usbdebug │ │ │ │ └── UsbDebuggingTileService.kt │ │ │ └── views │ │ │ │ ├── QsDescriptionsItem.kt │ │ │ │ ├── QsDescriptionsRecyclerViewAdapter.kt │ │ │ │ └── QsDescriptionsRecyclerViewHolder.kt │ │ │ └── utils │ │ │ ├── PermissionUtils.kt │ │ │ └── SettingsUtils.kt │ └── res │ │ ├── drawable │ │ ├── ic_qs_animator_duration_10x.xml │ │ ├── ic_qs_animator_duration_1_5x.xml │ │ ├── ic_qs_animator_duration_1x.xml │ │ ├── ic_qs_animator_duration_2x.xml │ │ ├── ic_qs_animator_duration_5x.xml │ │ ├── ic_qs_animator_duration_disabled.xml │ │ ├── ic_qs_animator_duration_enabled.xml │ │ ├── ic_qs_animator_duration_half_x.xml │ │ ├── ic_qs_demo_mode_disabled.xml │ │ ├── ic_qs_demo_mode_enabled.xml │ │ ├── ic_qs_finish_activities_disabled.xml │ │ ├── ic_qs_finish_activities_enabled.xml │ │ ├── ic_qs_keep_screen_on_disabled.xml │ │ ├── ic_qs_keep_screen_on_enabled.xml │ │ ├── ic_qs_show_taps_disabled.xml │ │ ├── ic_qs_show_taps_enabled.xml │ │ ├── ic_qs_usb_debugging_disabled.xml │ │ └── ic_qs_usb_debugging_enabled.xml │ │ ├── layout │ │ ├── activity_main.xml │ │ ├── grant_permissions_dialog.xml │ │ └── qs_description_item.xml │ │ ├── menu │ │ └── activity_main.xml │ │ ├── mipmap-hdpi │ │ ├── ic_launcher.png │ │ └── ic_launcher_round.png │ │ ├── mipmap-mdpi │ │ ├── ic_launcher.png │ │ └── ic_launcher_round.png │ │ ├── mipmap-xhdpi │ │ ├── ic_launcher.png │ │ └── ic_launcher_round.png │ │ ├── mipmap-xxhdpi │ │ ├── ic_launcher.png │ │ └── ic_launcher_round.png │ │ ├── mipmap-xxxhdpi │ │ ├── ic_launcher.png │ │ └── ic_launcher_round.png │ │ ├── values-es │ │ └── strings.xml │ │ ├── values-w820dp │ │ └── dimens.xml │ │ └── values │ │ ├── colors.xml │ │ ├── dimens.xml │ │ ├── donottranslate.xml │ │ ├── strings.xml │ │ └── styles.xml │ └── test │ └── java │ └── com │ └── adriangl │ └── devquicktiles │ └── ExampleUnitTest.java ├── build.gradle ├── common.gradle ├── gradle.properties ├── gradle └── wrapper │ ├── gradle-wrapper.jar │ └── gradle-wrapper.properties ├── gradlew ├── gradlew.bat ├── graphics ├── art │ ├── banner.psd │ ├── web_hi_res_512.png │ └── web_hi_res_512_round.png ├── icons │ ├── ic_qs_demo_mode_disabled.sketch │ ├── ic_qs_finish_activities_disabled.sketch │ ├── ic_qs_keep_screen_on_disabled.sketch │ ├── ic_qs_show_taps.sketch │ ├── ic_qs_usb_debugging_disabled.sketch │ └── ic_qs_usb_debugging_enabled.sketch └── screenshots │ ├── en-US_example.png │ ├── en-US_main.png │ ├── es-ES_example.png │ └── es-ES_main.png └── settings.gradle /.gitignore: -------------------------------------------------------------------------------- 1 | # Generated files 2 | bin/ 3 | gen/ 4 | out/ 5 | 6 | # Gradle files 7 | .gradle/ 8 | build/ 9 | 10 | # Local configuration file (sdk path, etc) 11 | local.properties 12 | 13 | # Proguard folder generated by Eclipse 14 | proguard/ 15 | 16 | # Log Files 17 | *.log 18 | 19 | # Android Studio Navigation editor temp files 20 | .navigation/ 21 | 22 | # Android Studio captures folder 23 | captures/ 24 | 25 | # Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm, CLion, Android Studio and Webstorm 26 | # Reference: https://intellij-support.jetbrains.com/hc/en-us/articles/206544839 27 | 28 | # User-specific stuff: 29 | *.iml 30 | .idea/**/workspace.xml 31 | .idea/**/compiler.xml 32 | .idea/**/encodings.xml 33 | .idea/**/misc.xml 34 | .idea/**/modules.xml 35 | .idea/**/runConfigurations.xml 36 | .idea/**/vcs.xml 37 | .idea/**/tasks.xml 38 | .idea/**/dictionaries 39 | 40 | # Sensitive or high-churn files: 41 | .idea/**/dataSources/ 42 | .idea/**/dataSources.ids 43 | .idea/**/dataSources.xml 44 | .idea/**/dataSources.local.xml 45 | .idea/**/sqlDataSources.xml 46 | .idea/**/dynamic.xml 47 | .idea/**/uiDesigner.xml 48 | 49 | # Gradle: 50 | .idea/**/gradle.xml 51 | .idea/**/libraries 52 | 53 | # Mongo Explorer plugin: 54 | .idea/**/mongoSettings.xml 55 | 56 | # Markdown-Navigator plugin 57 | .idea/**/markdown-navigator/ 58 | .idea/**/markdown-navigator.xml 59 | 60 | # External native build folder generated in Android Studio 2.2 and later 61 | .externalNativeBuild 62 | 63 | # Google Services (e.g. APIs or Firebase) 64 | google-services.json 65 | 66 | # Freeline 67 | freeline.py 68 | freeline/ 69 | freeline_project_description.json 70 | 71 | ## File-based project format: 72 | *.iws 73 | 74 | ## Plugin-specific files: 75 | 76 | # IntelliJ 77 | /out/ 78 | 79 | # mpeltonen/sbt-idea plugin 80 | .idea_modules/ 81 | 82 | # JIRA plugin 83 | atlassian-ide-plugin.xml 84 | 85 | # Cursive Clojure plugin 86 | .idea/replstate.xml 87 | 88 | # Crashlytics plugin (for Android Studio and IntelliJ) 89 | com_crashlytics_export_strings.xml 90 | crashlytics.properties 91 | crashlytics-build.properties 92 | fabric.properties 93 | 94 | # Keystore files 95 | *.jks -------------------------------------------------------------------------------- /.idea/checkstyle-idea.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 9 | 10 | -------------------------------------------------------------------------------- /.idea/copyright/Apache_2_0.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 6 | -------------------------------------------------------------------------------- /.idea/copyright/profiles_settings.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Apache License 2 | Version 2.0, January 2004 3 | http://www.apache.org/licenses/ 4 | 5 | TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 6 | 7 | 1. Definitions. 8 | 9 | "License" shall mean the terms and conditions for use, reproduction, 10 | and distribution as defined by Sections 1 through 9 of this document. 11 | 12 | "Licensor" shall mean the copyright owner or entity authorized by 13 | the copyright owner that is granting the License. 14 | 15 | "Legal Entity" shall mean the union of the acting entity and all 16 | other entities that control, are controlled by, or are under common 17 | control with that entity. For the purposes of this definition, 18 | "control" means (i) the power, direct or indirect, to cause the 19 | direction or management of such entity, whether by contract or 20 | otherwise, or (ii) ownership of fifty percent (50%) or more of the 21 | outstanding shares, or (iii) beneficial ownership of such entity. 22 | 23 | "You" (or "Your") shall mean an individual or Legal Entity 24 | exercising permissions granted by this License. 25 | 26 | "Source" form shall mean the preferred form for making modifications, 27 | including but not limited to software source code, documentation 28 | source, and configuration files. 29 | 30 | "Object" form shall mean any form resulting from mechanical 31 | transformation or translation of a Source form, including but 32 | not limited to compiled object code, generated documentation, 33 | and conversions to other media types. 34 | 35 | "Work" shall mean the work of authorship, whether in Source or 36 | Object form, made available under the License, as indicated by a 37 | copyright notice that is included in or attached to the work 38 | (an example is provided in the Appendix below). 39 | 40 | "Derivative Works" shall mean any work, whether in Source or Object 41 | form, that is based on (or derived from) the Work and for which the 42 | editorial revisions, annotations, elaborations, or other modifications 43 | represent, as a whole, an original work of authorship. For the purposes 44 | of this License, Derivative Works shall not include works that remain 45 | separable from, or merely link (or bind by name) to the interfaces of, 46 | the Work and Derivative Works thereof. 47 | 48 | "Contribution" shall mean any work of authorship, including 49 | the original version of the Work and any modifications or additions 50 | to that Work or Derivative Works thereof, that is intentionally 51 | submitted to Licensor for inclusion in the Work by the copyright owner 52 | or by an individual or Legal Entity authorized to submit on behalf of 53 | the copyright owner. For the purposes of this definition, "submitted" 54 | means any form of electronic, verbal, or written communication sent 55 | to the Licensor or its representatives, including but not limited to 56 | communication on electronic mailing lists, source code control systems, 57 | and issue tracking systems that are managed by, or on behalf of, the 58 | Licensor for the purpose of discussing and improving the Work, but 59 | excluding communication that is conspicuously marked or otherwise 60 | designated in writing by the copyright owner as "Not a Contribution." 61 | 62 | "Contributor" shall mean Licensor and any individual or Legal Entity 63 | on behalf of whom a Contribution has been received by Licensor and 64 | subsequently incorporated within the Work. 65 | 66 | 2. Grant of Copyright License. Subject to the terms and conditions of 67 | this License, each Contributor hereby grants to You a perpetual, 68 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 69 | copyright license to reproduce, prepare Derivative Works of, 70 | publicly display, publicly perform, sublicense, and distribute the 71 | Work and such Derivative Works in Source or Object form. 72 | 73 | 3. Grant of Patent License. Subject to the terms and conditions of 74 | this License, each Contributor hereby grants to You a perpetual, 75 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 76 | (except as stated in this section) patent license to make, have made, 77 | use, offer to sell, sell, import, and otherwise transfer the Work, 78 | where such license applies only to those patent claims licensable 79 | by such Contributor that are necessarily infringed by their 80 | Contribution(s) alone or by combination of their Contribution(s) 81 | with the Work to which such Contribution(s) was submitted. If You 82 | institute patent litigation against any entity (including a 83 | cross-claim or counterclaim in a lawsuit) alleging that the Work 84 | or a Contribution incorporated within the Work constitutes direct 85 | or contributory patent infringement, then any patent licenses 86 | granted to You under this License for that Work shall terminate 87 | as of the date such litigation is filed. 88 | 89 | 4. Redistribution. You may reproduce and distribute copies of the 90 | Work or Derivative Works thereof in any medium, with or without 91 | modifications, and in Source or Object form, provided that You 92 | meet the following conditions: 93 | 94 | (a) You must give any other recipients of the Work or 95 | Derivative Works a copy of this License; and 96 | 97 | (b) You must cause any modified files to carry prominent notices 98 | stating that You changed the files; and 99 | 100 | (c) You must retain, in the Source form of any Derivative Works 101 | that You distribute, all copyright, patent, trademark, and 102 | attribution notices from the Source form of the Work, 103 | excluding those notices that do not pertain to any part of 104 | the Derivative Works; and 105 | 106 | (d) If the Work includes a "NOTICE" text file as part of its 107 | distribution, then any Derivative Works that You distribute must 108 | include a readable copy of the attribution notices contained 109 | within such NOTICE file, excluding those notices that do not 110 | pertain to any part of the Derivative Works, in at least one 111 | of the following places: within a NOTICE text file distributed 112 | as part of the Derivative Works; within the Source form or 113 | documentation, if provided along with the Derivative Works; or, 114 | within a display generated by the Derivative Works, if and 115 | wherever such third-party notices normally appear. The contents 116 | of the NOTICE file are for informational purposes only and 117 | do not modify the License. You may add Your own attribution 118 | notices within Derivative Works that You distribute, alongside 119 | or as an addendum to the NOTICE text from the Work, provided 120 | that such additional attribution notices cannot be construed 121 | as modifying the License. 122 | 123 | You may add Your own copyright statement to Your modifications and 124 | may provide additional or different license terms and conditions 125 | for use, reproduction, or distribution of Your modifications, or 126 | for any such Derivative Works as a whole, provided Your use, 127 | reproduction, and distribution of the Work otherwise complies with 128 | the conditions stated in this License. 129 | 130 | 5. Submission of Contributions. Unless You explicitly state otherwise, 131 | any Contribution intentionally submitted for inclusion in the Work 132 | by You to the Licensor shall be under the terms and conditions of 133 | this License, without any additional terms or conditions. 134 | Notwithstanding the above, nothing herein shall supersede or modify 135 | the terms of any separate license agreement you may have executed 136 | with Licensor regarding such Contributions. 137 | 138 | 6. Trademarks. This License does not grant permission to use the trade 139 | names, trademarks, service marks, or product names of the Licensor, 140 | except as required for reasonable and customary use in describing the 141 | origin of the Work and reproducing the content of the NOTICE file. 142 | 143 | 7. Disclaimer of Warranty. Unless required by applicable law or 144 | agreed to in writing, Licensor provides the Work (and each 145 | Contributor provides its Contributions) on an "AS IS" BASIS, 146 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 147 | implied, including, without limitation, any warranties or conditions 148 | of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A 149 | PARTICULAR PURPOSE. You are solely responsible for determining the 150 | appropriateness of using or redistributing the Work and assume any 151 | risks associated with Your exercise of permissions under this License. 152 | 153 | 8. Limitation of Liability. In no event and under no legal theory, 154 | whether in tort (including negligence), contract, or otherwise, 155 | unless required by applicable law (such as deliberate and grossly 156 | negligent acts) or agreed to in writing, shall any Contributor be 157 | liable to You for damages, including any direct, indirect, special, 158 | incidental, or consequential damages of any character arising as a 159 | result of this License or out of the use or inability to use the 160 | Work (including but not limited to damages for loss of goodwill, 161 | work stoppage, computer failure or malfunction, or any and all 162 | other commercial damages or losses), even if such Contributor 163 | has been advised of the possibility of such damages. 164 | 165 | 9. Accepting Warranty or Additional Liability. While redistributing 166 | the Work or Derivative Works thereof, You may choose to offer, 167 | and charge a fee for, acceptance of support, warranty, indemnity, 168 | or other liability obligations and/or rights consistent with this 169 | License. However, in accepting such obligations, You may act only 170 | on Your own behalf and on Your sole responsibility, not on behalf 171 | of any other Contributor, and only if You agree to indemnify, 172 | defend, and hold each Contributor harmless for any liability 173 | incurred by, or claims asserted against, such Contributor by reason 174 | of your accepting any such warranty or additional liability. 175 | 176 | END OF TERMS AND CONDITIONS 177 | 178 | APPENDIX: How to apply the Apache License to your work. 179 | 180 | To apply the Apache License to your work, attach the following 181 | boilerplate notice, with the fields enclosed by brackets "{}" 182 | replaced with your own identifying information. (Don't include 183 | the brackets!) The text should be enclosed in the appropriate 184 | comment syntax for the file format. We also recommend that a 185 | file or class name and description of purpose be included on the 186 | same "printed page" as the copyright notice for easier 187 | identification within third-party archives. 188 | 189 | Copyright {yyyy} {name of copyright owner} 190 | 191 | Licensed under the Apache License, Version 2.0 (the "License"); 192 | you may not use this file except in compliance with the License. 193 | You may obtain a copy of the License at 194 | 195 | http://www.apache.org/licenses/LICENSE-2.0 196 | 197 | Unless required by applicable law or agreed to in writing, software 198 | distributed under the License is distributed on an "AS IS" BASIS, 199 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 200 | See the License for the specific language governing permissions and 201 | limitations under the License. 202 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Dev-QuickSettings 2 | ## What is this? 3 | Android Quick Settings Tiles for Android development written in [Kotlin](https://kotlinlang.org/). 4 | 5 | Main image Example image 6 | 7 | The app is based on the work of [Nick Butcher](https://github.com/nickbutcher) and his [Animator Duration Quick Settings Tile](https://github.com/nickbutcher/AnimatorDurationTile) which I borrowed for the animation duration tile. 8 | 9 | ### Requirements 10 | * An Android device, obviously :) 11 | * Android 7.0 (Nougat) or greater, API 24+ 12 | 13 | ### Current features 14 | The app provides a few Quick Settings tiles that act as shortcut to Development Options in the Android device: 15 | * USB Debugging 16 | * Demo mode 17 | * Keep screen on 18 | * Animator duration scale 19 | * Show taps on screen 20 | * Destroy activities 21 | 22 | ## Where can I get it? 23 | You can get it from [Google Play](https://play.google.com/store/apps/details?id=com.adriangl.devquicksettings) or you can download the APK file from the [Releases](https://github.com/adriangl/Android-Dev-QuickSettings/releases) page. 24 | 25 | Get it on Google Play 26 | 27 | ## License 28 | ``` 29 | Copyright (C) 2017 Adrián García 30 | 31 | Licensed under the Apache License, Version 2.0 (the "License"); 32 | you may not use this file except in compliance with the License. 33 | You may obtain a copy of the License at 34 | 35 | http://www.apache.org/licenses/LICENSE-2.0 36 | 37 | Unless required by applicable law or agreed to in writing, software 38 | distributed under the License is distributed on an "AS IS" BASIS, 39 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 40 | See the License for the specific language governing permissions and 41 | limitations under the License. 42 | ``` 43 | -------------------------------------------------------------------------------- /app/.gitignore: -------------------------------------------------------------------------------- 1 | # Generated files 2 | bin/ 3 | gen/ 4 | out/ 5 | 6 | # Gradle files 7 | .gradle/ 8 | build/ 9 | 10 | # Local configuration file (sdk path, etc) 11 | local.properties 12 | 13 | # Proguard folder generated by Eclipse 14 | proguard/ 15 | 16 | # Log Files 17 | *.log 18 | 19 | # Android Studio Navigation editor temp files 20 | .navigation/ 21 | 22 | # Android Studio captures folder 23 | captures/ 24 | 25 | # Intellij 26 | *.iml 27 | .idea/workspace.xml 28 | .idea/tasks.xml 29 | .idea/gradle.xml 30 | .idea/libraries 31 | 32 | # Keystore files 33 | *.jks 34 | 35 | # External native build folder generated in Android Studio 2.2 and later 36 | .externalNativeBuild 37 | 38 | # Google Services (e.g. APIs or Firebase) 39 | google-services.json 40 | 41 | # Freeline 42 | freeline.py 43 | freeline/ 44 | freeline_project_description.json -------------------------------------------------------------------------------- /app/build.gradle: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2017 Adrián García 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 | apply plugin: "com.android.application" 18 | apply plugin: "kotlin-android" 19 | apply from: "$rootDir/common.gradle" 20 | 21 | android { 22 | compileSdkVersion 25 23 | buildToolsVersion "25.0.2" 24 | defaultConfig { 25 | applicationId "com.adriangl.devquicksettings" 26 | minSdkVersion 24 27 | targetSdkVersion 22 28 | versionCode computeVersionCode() 29 | versionName computeVersionName() 30 | testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner" 31 | } 32 | buildTypes { 33 | release { 34 | minifyEnabled false 35 | proguardFiles getDefaultProguardFile("proguard-android.txt"), "proguard-rules.pro" 36 | } 37 | } 38 | sourceSets { 39 | main.java.srcDirs += "src/main/kotlin" 40 | } 41 | } 42 | 43 | dependencies { 44 | compile fileTree(dir: "libs", include: ["*.jar"]) 45 | 46 | compile "com.android.support:appcompat-v7:$support_version" 47 | compile "com.android.support:recyclerview-v7:$support_version" 48 | compile "com.android.support:cardview-v7:$support_version" 49 | compile "com.jakewharton.timber:timber:4.5.1" 50 | compile('com.mikepenz:aboutlibraries:5.9.5@aar') { 51 | transitive = true 52 | } 53 | compile "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version" 54 | 55 | testCompile "junit:junit:4.12" 56 | 57 | androidTestCompile("com.android.support.test.espresso:espresso-core:2.2.2", { 58 | exclude group: "com.android.support", module: "support-annotations" 59 | }) 60 | } 61 | repositories { 62 | mavenCentral() 63 | } 64 | -------------------------------------------------------------------------------- /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/adrian-macbook/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/adriangl/devquicktiles/ExampleInstrumentedTest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2017 Adrián García 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 com.adriangl.devquicktiles; 18 | 19 | import android.content.Context; 20 | import android.support.test.InstrumentationRegistry; 21 | import android.support.test.runner.AndroidJUnit4; 22 | 23 | import org.junit.Test; 24 | import org.junit.runner.RunWith; 25 | 26 | import static org.junit.Assert.assertEquals; 27 | 28 | /** 29 | * Instrumentation test, which will execute on an Android device. 30 | * 31 | * @see Testing documentation 32 | */ 33 | @RunWith(AndroidJUnit4.class) 34 | public class ExampleInstrumentedTest { 35 | @Test 36 | public void useAppContext() throws Exception { 37 | // Context of the app under test. 38 | Context appContext = InstrumentationRegistry.getTargetContext(); 39 | 40 | assertEquals("com.adriangl.devquicktiles", appContext.getPackageName()); 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /app/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 16 | 17 | 20 | 21 | 25 | 28 | 29 | 33 | 36 | 37 | 41 | 44 | 45 | 53 | 54 | 59 | 60 | 61 | 62 | 63 | 64 | 69 | 70 | 71 | 72 | 73 | 74 | 79 | 80 | 81 | 82 | 83 | 84 | 89 | 90 | 91 | 92 | 93 | 94 | 99 | 100 | 101 | 102 | 103 | 104 | 109 | 110 | 111 | 112 | 113 | 114 | 115 | 116 | 117 | 118 | 119 | 120 | 121 | 122 | 123 | -------------------------------------------------------------------------------- /app/src/main/kotlin/com/adriangl/devquicktiles/MainActivity.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2017 Adrián García 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 com.adriangl.devquicktiles 18 | 19 | import android.content.Intent 20 | import android.os.Bundle 21 | import android.support.v7.app.AppCompatActivity 22 | import android.support.v7.widget.LinearLayoutManager 23 | import android.support.v7.widget.RecyclerView 24 | import android.view.Menu 25 | import android.view.MenuItem 26 | import android.view.View 27 | import android.widget.Button 28 | import android.widget.TextView 29 | import com.adriangl.devquicktiles.tiles.views.QsDescriptionsItem 30 | import com.adriangl.devquicktiles.tiles.views.QsDescriptionsRecyclerViewAdapter 31 | import com.adriangl.devquicktiles.utils.PermissionUtils 32 | import com.mikepenz.aboutlibraries.Libs 33 | import com.mikepenz.aboutlibraries.LibsBuilder 34 | 35 | 36 | class MainActivity : AppCompatActivity() { 37 | 38 | lateinit var qsDescriptionsRecyclerView: RecyclerView 39 | lateinit var grantPermissionsView: View 40 | lateinit var grantPermissionsText: TextView 41 | lateinit var permissionsShareButton: Button 42 | 43 | override fun onCreate(savedInstanceState: Bundle?) { 44 | super.onCreate(savedInstanceState) 45 | setContentView(R.layout.activity_main) 46 | 47 | qsDescriptionsRecyclerView = findViewById(R.id.qs_tile_descriptions_recyclerview) as RecyclerView 48 | grantPermissionsView = findViewById(R.id.grant_permissions_container) 49 | grantPermissionsText = findViewById(R.id.grant_permissions_text) as TextView 50 | permissionsShareButton = findViewById(R.id.permissions_share) as Button 51 | 52 | permissionsShareButton.setOnClickListener { sharePermissions() } 53 | } 54 | 55 | override fun onResume() { 56 | super.onResume() 57 | val layoutManager = LinearLayoutManager(this, LinearLayoutManager.VERTICAL, false) 58 | qsDescriptionsRecyclerView.setHasFixedSize(true) 59 | qsDescriptionsRecyclerView.isNestedScrollingEnabled = false 60 | qsDescriptionsRecyclerView.layoutManager = layoutManager 61 | 62 | val adapter = QsDescriptionsRecyclerViewAdapter() 63 | adapter.setItems(getDescriptionItems()) 64 | qsDescriptionsRecyclerView.adapter = adapter 65 | 66 | grantPermissionsText.text = getFormattedPermissions() 67 | 68 | if (hasNeededPermissions()) grantPermissionsView.visibility = View.GONE 69 | } 70 | 71 | override fun onCreateOptionsMenu(menu: Menu?): Boolean { 72 | menuInflater.inflate(R.menu.activity_main, menu) 73 | return super.onCreateOptionsMenu(menu) 74 | } 75 | 76 | override fun onOptionsItemSelected(item: MenuItem?): Boolean { 77 | when { 78 | item?.itemId == R.id.menu_about -> showAbout() 79 | } 80 | return true 81 | } 82 | 83 | private fun showAbout() { 84 | LibsBuilder() 85 | .withFields(R.string::class.java.fields) 86 | .withActivityStyle(Libs.ActivityStyle.LIGHT_DARK_TOOLBAR) 87 | .withActivityTitle(getString(R.string.menu_about)) 88 | .withAboutIconShown(true) 89 | .withAboutAppName(getString(R.string.app_name)) 90 | .withAboutVersionShownName(true) 91 | .withAboutVersionShownCode(false) 92 | .withAutoDetect(true) 93 | .withExcludedLibraries("AndroidIconics", "fastadapter") 94 | .start(this) 95 | } 96 | 97 | private fun getDescriptionItems(): List { 98 | return listOf( 99 | QsDescriptionsItem( 100 | R.drawable.ic_qs_usb_debugging_enabled, 101 | getString(R.string.qs_usb_debugging), 102 | getString(R.string.qs_usb_debugging_description)), 103 | QsDescriptionsItem( 104 | R.drawable.ic_qs_demo_mode_enabled, 105 | getString(R.string.qs_demo_mode), 106 | getString(R.string.qs_demo_mode_description)), 107 | QsDescriptionsItem( 108 | R.drawable.ic_qs_keep_screen_on_enabled, 109 | getString(R.string.qs_keep_screen_on), 110 | getString(R.string.qs_keep_screen_on_description)), 111 | QsDescriptionsItem( 112 | R.drawable.ic_qs_animator_duration_enabled, 113 | getString(R.string.qs_animator_duration), 114 | getString(R.string.qs_animator_duration_description)), 115 | QsDescriptionsItem( 116 | R.drawable.ic_qs_show_taps_enabled, 117 | getString(R.string.qs_show_taps), 118 | getString(R.string.qs_show_taps_description)), 119 | QsDescriptionsItem( 120 | R.drawable.ic_qs_finish_activities_enabled, 121 | getString(R.string.qs_finish_activities), 122 | getString(R.string.qs_finish_activities_description)) 123 | ) 124 | } 125 | 126 | private fun getFormattedPermissions() = getString(R.string.permissions_to_grant, BuildConfig.APPLICATION_ID) 127 | 128 | private fun sharePermissions() { 129 | val sharingIntent = Intent(android.content.Intent.ACTION_SEND) 130 | sharingIntent.type = "text/plain" 131 | sharingIntent.putExtra(android.content.Intent.EXTRA_SUBJECT, 132 | getString(R.string.share_permissions_subject, getString(R.string.app_name))) 133 | sharingIntent.putExtra(android.content.Intent.EXTRA_TEXT, getFormattedPermissions()) 134 | startActivity(Intent.createChooser(sharingIntent, resources.getString(R.string.share_using))) 135 | } 136 | 137 | private fun hasNeededPermissions(): Boolean { 138 | return (PermissionUtils.checkSelfPermissionIsGranted(this, android.Manifest.permission.WRITE_SECURE_SETTINGS) 139 | and (PermissionUtils.checkSelfPermissionIsGranted(this, android.Manifest.permission.DUMP))) 140 | } 141 | } 142 | -------------------------------------------------------------------------------- /app/src/main/kotlin/com/adriangl/devquicktiles/base/BaseApplication.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2017 Adrián García 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 com.adriangl.devquicktiles.base 18 | 19 | import android.app.Application 20 | import com.adriangl.devquicktiles.BuildConfig 21 | import timber.log.Timber 22 | 23 | class BaseApplication : Application() { 24 | override fun onCreate() { 25 | super.onCreate() 26 | 27 | // Init Timber in debug builds 28 | if (BuildConfig.DEBUG) Timber.plant(Timber.DebugTree()) 29 | } 30 | } -------------------------------------------------------------------------------- /app/src/main/kotlin/com/adriangl/devquicktiles/tiles/DevelopmentTileService.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2017 Adrián García 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 com.adriangl.devquicktiles.tiles 18 | 19 | import android.graphics.drawable.Icon 20 | import android.service.quicksettings.Tile 21 | import android.service.quicksettings.TileService 22 | import android.widget.Toast 23 | import com.adriangl.devquicktiles.R 24 | import timber.log.Timber 25 | 26 | abstract class DevelopmentTileService : TileService() { 27 | 28 | lateinit var value: T 29 | 30 | override fun onStartListening() { 31 | Timber.d("Tile started listening: {label=%s, state=%s}", qsTile.label, qsTile.state) 32 | value = queryValue() 33 | updateState() 34 | } 35 | 36 | override fun onClick() { 37 | Timber.d("Tile clicked: {label=%s, state=%s}", qsTile.label, qsTile.state) 38 | setNextValue() 39 | } 40 | 41 | private fun setNextValue() { 42 | val newIndex = ((getValueList().indexOf(value) + 1) % getValueList().size) 43 | val newValue = getValueList()[newIndex] 44 | Timber.d("New value: %s, Tile: {label=%s, state=%s}", value, qsTile.label, qsTile.state) 45 | 46 | // Disable tile while setting the value 47 | qsTile.state = Tile.STATE_UNAVAILABLE 48 | qsTile.updateTile() 49 | 50 | try { 51 | if (saveValue(newValue)) { 52 | value = newValue 53 | } 54 | } catch (e: Exception) { 55 | val permissionNotGrantedString = getString(R.string.qs_permissions_not_granted) 56 | Toast.makeText(applicationContext, permissionNotGrantedString, Toast.LENGTH_LONG) 57 | .show() 58 | Timber.e(e, permissionNotGrantedString) 59 | } 60 | 61 | updateState() 62 | } 63 | 64 | private fun updateState() { 65 | qsTile.state = if (isActive(value)) Tile.STATE_ACTIVE else Tile.STATE_INACTIVE 66 | qsTile.label = getLabel(value) 67 | qsTile.icon = getIcon(value) 68 | 69 | qsTile.updateTile() 70 | 71 | Timber.d("Tile updated: {label=%s, state=%s}", qsTile.label, qsTile.state) 72 | } 73 | 74 | abstract fun isActive(value: T): Boolean 75 | 76 | abstract fun getValueList(): List 77 | 78 | abstract fun queryValue(): T 79 | 80 | abstract fun saveValue(value: T): Boolean 81 | 82 | abstract fun getIcon(value: T): Icon? 83 | 84 | abstract fun getLabel(value: T): CharSequence? 85 | 86 | } 87 | -------------------------------------------------------------------------------- /app/src/main/kotlin/com/adriangl/devquicktiles/tiles/animatorduration/AnimatorDurationTileService.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2017 Adrián García 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 com.adriangl.devquicktiles.tiles.animatorduration 18 | 19 | import android.graphics.drawable.Icon 20 | import android.provider.Settings 21 | import com.adriangl.devquicktiles.R 22 | import com.adriangl.devquicktiles.tiles.DevelopmentTileService 23 | import com.adriangl.devquicktiles.utils.SettingsUtils 24 | 25 | class AnimatorDurationTileService : DevelopmentTileService() { 26 | companion object { 27 | val SETTING = Settings.Global.ANIMATOR_DURATION_SCALE 28 | } 29 | 30 | override fun isActive(value: Float): Boolean { 31 | return value != 0f 32 | } 33 | 34 | override fun queryValue(): Float { 35 | return SettingsUtils.getFloatFromGlobalSettings(contentResolver, SETTING) 36 | } 37 | 38 | override fun saveValue(value: Float): Boolean { 39 | return SettingsUtils.setFloatToGlobalSettings(contentResolver, SETTING, value) 40 | } 41 | 42 | override fun getValueList(): List { 43 | return listOf(0f, 0.5f, 1f, 1.5f, 2f, 5f, 10f) 44 | } 45 | 46 | override fun getIcon(value: Float): Icon? { 47 | var iconResource = R.drawable.ic_qs_animator_duration_enabled 48 | if (value <= 0f) { 49 | iconResource = R.drawable.ic_qs_animator_duration_disabled 50 | } else if (value <= 0.5f) { 51 | iconResource = R.drawable.ic_qs_animator_duration_half_x 52 | } else if (value <= 1f) { 53 | iconResource = R.drawable.ic_qs_animator_duration_1x 54 | } else if (value <= 1.5f) { 55 | iconResource = R.drawable.ic_qs_animator_duration_1_5x 56 | } else if (value <= 2f) { 57 | iconResource = R.drawable.ic_qs_animator_duration_2x 58 | } else if (value <= 5f) { 59 | iconResource = R.drawable.ic_qs_animator_duration_5x 60 | } else if (value <= 10f) { 61 | iconResource = R.drawable.ic_qs_animator_duration_10x 62 | } 63 | 64 | return Icon.createWithResource(applicationContext, iconResource) 65 | } 66 | 67 | override fun getLabel(value: Float): CharSequence? { 68 | var stringResource = R.string.qs_animator_duration 69 | if (value <= 0f) { 70 | stringResource = R.string.qs_animator_off 71 | } else if (value <= 0.5f) { 72 | stringResource = R.string.qs_animator_scale_0_5x 73 | } else if (value <= 1f) { 74 | stringResource = R.string.qs_animator_scale_1x 75 | } else if (value <= 1.5f) { 76 | stringResource = R.string.qs_animator_scale_1_5x 77 | } else if (value <= 2f) { 78 | stringResource = R.string.qs_animator_scale_2x 79 | } else if (value <= 5f) { 80 | stringResource = R.string.qs_animator_scale_5x 81 | } else if (value <= 10f) { 82 | stringResource = R.string.qs_animator_scale_10x 83 | } 84 | 85 | return getString(stringResource) 86 | } 87 | } -------------------------------------------------------------------------------- /app/src/main/kotlin/com/adriangl/devquicktiles/tiles/demomode/DemoMode.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2017 Adrián García 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 com.adriangl.devquicktiles.tiles.demomode 18 | 19 | import android.content.Context 20 | import android.content.Intent 21 | 22 | /** 23 | * Code adapted from AOSP: 24 | * https://github.com/android/platform_frameworks_base/blob/marshmallow-mr3-release/packages/SystemUI/src/com/android/systemui/DemoMode.java 25 | */ 26 | class DemoMode { 27 | companion object { 28 | // Indicates that the demo mode is allowed, but it doesn't mean that it's active 29 | val DEMO_MODE_ALLOWED = "sysui_demo_allowed" 30 | // Activates demo mode if allowed 31 | val DEMO_MODE_ON = "sysui_tuner_demo_on" 32 | 33 | // Broadcast action for demo mode 34 | val ACTION_DEMO = "com.android.systemui.demo" 35 | 36 | // Various commands to use to control demo mode 37 | val EXTRA_COMMAND = "command" 38 | 39 | val COMMAND_ENTER = "enter" 40 | val COMMAND_EXIT = "exit" 41 | val COMMAND_CLOCK = "clock" 42 | val COMMAND_BATTERY = "battery" 43 | val COMMAND_NETWORK = "network" 44 | val COMMAND_BARS = "bars" 45 | val COMMAND_STATUS = "status" 46 | val COMMAND_NOTIFICATIONS = "notifications" 47 | val COMMAND_VOLUME = "volume" 48 | 49 | val STATUS_ICONS = arrayOf( 50 | "volume", 51 | "bluetooth", 52 | "location", 53 | "alarm", 54 | "zen", 55 | "sync", 56 | "tty", 57 | "eri", 58 | "mute", 59 | "speakerphone", 60 | "managed_profile") 61 | 62 | fun sendCommand(context: Context, command: String, intentBuilder: (Intent) -> Unit = {}) { 63 | // Prepare intent and command to send 64 | val intent = Intent(DemoMode.ACTION_DEMO) 65 | intent.putExtra(DemoMode.EXTRA_COMMAND, command) 66 | // Apply extras if they exist 67 | intent.apply(intentBuilder) 68 | // Send broadcast to system demo mode receiver 69 | context.sendBroadcast(intent) 70 | } 71 | } 72 | } -------------------------------------------------------------------------------- /app/src/main/kotlin/com/adriangl/devquicktiles/tiles/demomode/DemoModeTileService.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2017 Adrián García 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 com.adriangl.devquicktiles.tiles.demomode 18 | 19 | import android.graphics.drawable.Icon 20 | import android.os.Build 21 | import com.adriangl.devquicktiles.R 22 | import com.adriangl.devquicktiles.tiles.DevelopmentTileService 23 | import com.adriangl.devquicktiles.utils.SettingsUtils 24 | 25 | /** 26 | * Code adapted from AOSP: 27 | * https://github.com/android/platform_frameworks_base/blob/marshmallow-mr3-release/packages/SystemUI/src/com/android/systemui/tuner/DemoModeFragment.java 28 | * 29 | * Check protocol here: https://github.com/android/platform_frameworks_base/blob/master/packages/SystemUI/docs/demo_mode.md 30 | */ 31 | class DemoModeTileService : DevelopmentTileService() { 32 | 33 | override fun isActive(value: Int): Boolean { 34 | return value != 0 35 | } 36 | 37 | override fun getValueList(): List { 38 | return listOf(0, 1) 39 | } 40 | 41 | override fun queryValue(): Int { 42 | return listOf(DemoMode.DEMO_MODE_ALLOWED, DemoMode.DEMO_MODE_ON) 43 | .fold(1, { current, key -> SettingsUtils.getIntFromGlobalSettings(contentResolver, key) and current }) 44 | } 45 | 46 | override fun saveValue(value: Int): Boolean { 47 | val isSettingEnabled = 48 | listOf(DemoMode.DEMO_MODE_ALLOWED, DemoMode.DEMO_MODE_ON) 49 | .fold(true) { 50 | initial, setting -> initial && SettingsUtils.setIntToGlobalSettings(contentResolver, setting, value) 51 | } 52 | if (isSettingEnabled) { 53 | if (value != 0) { 54 | startDemoMode() 55 | } else { 56 | stopDemoMode() 57 | } 58 | return true 59 | } else { 60 | return false 61 | } 62 | } 63 | 64 | override fun getIcon(value: Int): Icon? { 65 | return Icon.createWithResource(applicationContext, 66 | if (value != 0) R.drawable.ic_qs_demo_mode_enabled else R.drawable.ic_qs_demo_mode_disabled) 67 | } 68 | 69 | override fun getLabel(value: Int): CharSequence? { 70 | return getString(R.string.qs_demo_mode) 71 | } 72 | 73 | private fun startDemoMode() { 74 | // Enable Demo mode (as per documentation, this is optional) 75 | DemoMode.sendCommand(applicationContext, DemoMode.COMMAND_ENTER) 76 | 77 | // Set fixed time (use Android's major version for hours) 78 | DemoMode.sendCommand(applicationContext, DemoMode.COMMAND_CLOCK) { intent -> 79 | intent.putExtra("hhmm", "0${Build.VERSION.RELEASE.split(".")[0]}00") 80 | } 81 | 82 | // Set fixed network-related notification icons 83 | DemoMode.sendCommand(applicationContext, DemoMode.COMMAND_NETWORK) { intent -> 84 | intent.putExtra("wifi", "show") 85 | intent.putExtra("mobile", "show") 86 | intent.putExtra("sims", "1") 87 | intent.putExtra("nosim", "false") 88 | intent.putExtra("level", "4") 89 | intent.putExtra("datatype", "") 90 | } 91 | 92 | // Sets MCS state to fully connected (true, false) 93 | // Need to send this after so that the sim controller already exists. 94 | DemoMode.sendCommand(applicationContext, DemoMode.COMMAND_NETWORK) { intent -> 95 | intent.putExtra("fully", "true") 96 | } 97 | 98 | // Set fixed battery options 99 | DemoMode.sendCommand(applicationContext, DemoMode.COMMAND_BATTERY) { intent -> 100 | intent.putExtra("level", "100") 101 | intent.putExtra("plugged", "false") 102 | } 103 | 104 | // Hide other icons 105 | DemoMode.sendCommand(applicationContext, DemoMode.COMMAND_STATUS) { intent -> 106 | DemoMode.STATUS_ICONS.forEach { icon -> 107 | intent.putExtra(icon, "hide") 108 | } 109 | } 110 | 111 | // Hide notifications 112 | DemoMode.sendCommand(applicationContext, DemoMode.COMMAND_NOTIFICATIONS) { intent -> 113 | intent.putExtra("visible", "false") 114 | } 115 | } 116 | 117 | private fun stopDemoMode() { 118 | // Exit demo mode 119 | DemoMode.sendCommand(applicationContext, DemoMode.COMMAND_EXIT) 120 | } 121 | } -------------------------------------------------------------------------------- /app/src/main/kotlin/com/adriangl/devquicktiles/tiles/finishactivities/FinishActivitiesTileService.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2017 Adrián García 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 com.adriangl.devquicktiles.tiles.finishactivities 18 | 19 | import android.graphics.drawable.Icon 20 | import android.provider.Settings 21 | import com.adriangl.devquicktiles.R 22 | import com.adriangl.devquicktiles.tiles.DevelopmentTileService 23 | import com.adriangl.devquicktiles.utils.SettingsUtils 24 | 25 | class FinishActivitiesTileService : DevelopmentTileService() { 26 | companion object { 27 | val SETTING = Settings.Global.ALWAYS_FINISH_ACTIVITIES 28 | } 29 | 30 | override fun isActive(value: Int): Boolean { 31 | return value != 0 32 | } 33 | 34 | override fun queryValue(): Int { 35 | var value = SettingsUtils.getIntFromGlobalSettings(contentResolver, SETTING) 36 | if (value > 1) value = 1 37 | return value 38 | } 39 | 40 | override fun saveValue(value: Int) : Boolean { 41 | return SettingsUtils.setIntToGlobalSettings(contentResolver, SETTING, value) 42 | } 43 | 44 | override fun getValueList(): List { 45 | return listOf(0, 1) 46 | } 47 | 48 | override fun getIcon(value: Int): Icon? { 49 | return Icon.createWithResource(applicationContext, 50 | if (value != 0) R.drawable.ic_qs_finish_activities_enabled 51 | else R.drawable.ic_qs_finish_activities_disabled) 52 | } 53 | 54 | override fun getLabel(value: Int): CharSequence? { 55 | return getString(R.string.qs_finish_activities) 56 | } 57 | } -------------------------------------------------------------------------------- /app/src/main/kotlin/com/adriangl/devquicktiles/tiles/screenon/KeepScreenOnTileService.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2017 Adrián García 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 com.adriangl.devquicktiles.tiles.screenon 18 | 19 | import android.graphics.drawable.Icon 20 | import android.os.BatteryManager 21 | import android.provider.Settings 22 | import com.adriangl.devquicktiles.R 23 | import com.adriangl.devquicktiles.tiles.DevelopmentTileService 24 | import com.adriangl.devquicktiles.utils.SettingsUtils 25 | 26 | class KeepScreenOnTileService : DevelopmentTileService() { 27 | companion object { 28 | val SETTING = Settings.Global.STAY_ON_WHILE_PLUGGED_IN 29 | } 30 | 31 | override fun isActive(value: Int): Boolean { 32 | return value != 0 33 | } 34 | 35 | override fun queryValue(): Int { 36 | return SettingsUtils.getIntFromGlobalSettings(contentResolver, SETTING) 37 | } 38 | 39 | override fun saveValue(value: Int) : Boolean { 40 | return SettingsUtils.setIntToGlobalSettings(contentResolver, SETTING, value) 41 | } 42 | 43 | override fun getValueList(): List { 44 | //TODO: Get the proper value from settings so the user can change its value 45 | return listOf(0, BatteryManager.BATTERY_PLUGGED_AC or BatteryManager.BATTERY_PLUGGED_USB) 46 | } 47 | 48 | override fun getIcon(value: Int): Icon? { 49 | return Icon.createWithResource(applicationContext, 50 | if (value != 0) R.drawable.ic_qs_keep_screen_on_enabled else R.drawable.ic_qs_keep_screen_on_disabled) 51 | } 52 | 53 | override fun getLabel(value: Int): CharSequence? { 54 | return getString(R.string.qs_keep_screen_on) 55 | } 56 | 57 | } -------------------------------------------------------------------------------- /app/src/main/kotlin/com/adriangl/devquicktiles/tiles/show_taps/ShowTapsTileService.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2017 Adrián García 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 com.adriangl.devquicktiles.tiles.show_taps 18 | 19 | import android.graphics.drawable.Icon 20 | import com.adriangl.devquicktiles.R 21 | import com.adriangl.devquicktiles.tiles.DevelopmentTileService 22 | import com.adriangl.devquicktiles.utils.SettingsUtils 23 | 24 | 25 | class ShowTapsTileService : DevelopmentTileService() { 26 | companion object { 27 | val SETTING = "show_touches" // This is hidden for developers, so we use the string resource 28 | } 29 | 30 | override fun isActive(value: Int): Boolean { 31 | return value != 0 32 | } 33 | 34 | override fun queryValue(): Int { 35 | var value = SettingsUtils.getIntFromSystemSettings(contentResolver, SETTING) 36 | if (value > 1) value = 1 37 | return value 38 | } 39 | 40 | override fun saveValue(value: Int): Boolean { 41 | /* 42 | * The proper way to do this would be to check Settings.System.canWrite(). 43 | * If we can write there then write the setting and if we can't, then launch an Intent to 44 | * Settings.ACTION_MANAGE_WRITE_SETTINGS to enable the app to write system settings. 45 | * 46 | * The problem is that from API 23+ we can't do that with the "show_touches" setting 47 | * (and others I suppose) as it throws an IllegalArgumentException: 48 | * You cannot change private secure settings. 49 | * 50 | * So we have to fall back to use a targetSdkVersion of 22 so we can write the setting. 51 | * Kinda hacky, but it works ¯\_(ツ)_/¯. 52 | */ 53 | 54 | return SettingsUtils.setIntToSystemSettings(contentResolver, SETTING, value) 55 | } 56 | 57 | override fun getValueList(): List { 58 | return listOf(0, 1) 59 | } 60 | 61 | override fun getIcon(value: Int): Icon? { 62 | return Icon.createWithResource(applicationContext, 63 | if (value != 0) R.drawable.ic_qs_show_taps_enabled else R.drawable.ic_qs_show_taps_disabled) 64 | } 65 | 66 | override fun getLabel(value: Int): CharSequence? { 67 | return getString(R.string.qs_show_taps) 68 | } 69 | } 70 | -------------------------------------------------------------------------------- /app/src/main/kotlin/com/adriangl/devquicktiles/tiles/usbdebug/UsbDebuggingTileService.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2017 Adrián García 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 com.adriangl.devquicktiles.tiles.usbdebug 18 | 19 | import android.graphics.drawable.Icon 20 | import android.provider.Settings 21 | import com.adriangl.devquicktiles.R 22 | import com.adriangl.devquicktiles.tiles.DevelopmentTileService 23 | import com.adriangl.devquicktiles.utils.SettingsUtils 24 | 25 | class UsbDebuggingTileService : DevelopmentTileService() { 26 | companion object { 27 | val SETTING = Settings.Global.ADB_ENABLED 28 | } 29 | 30 | override fun isActive(value: Int): Boolean { 31 | return value != 0 32 | } 33 | 34 | override fun queryValue(): Int { 35 | var value = SettingsUtils.getIntFromGlobalSettings(contentResolver, SETTING) 36 | if (value > 1) value = 1 37 | return value 38 | } 39 | 40 | override fun saveValue(value: Int) : Boolean { 41 | return SettingsUtils.setIntToGlobalSettings(contentResolver, SETTING, value) 42 | } 43 | 44 | override fun getValueList(): List { 45 | return listOf(0, 1) 46 | } 47 | 48 | override fun getIcon(value: Int): Icon? { 49 | return Icon.createWithResource(applicationContext, 50 | if (value != 0) R.drawable.ic_qs_usb_debugging_enabled else R.drawable.ic_qs_usb_debugging_disabled) 51 | } 52 | 53 | override fun getLabel(value: Int): CharSequence? { 54 | return getString(R.string.qs_usb_debugging) 55 | } 56 | } 57 | -------------------------------------------------------------------------------- /app/src/main/kotlin/com/adriangl/devquicktiles/tiles/views/QsDescriptionsItem.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2017 Adrián García 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 com.adriangl.devquicktiles.tiles.views 18 | 19 | import android.support.annotation.DrawableRes 20 | 21 | data class QsDescriptionsItem(@DrawableRes val iconResource: Int, val title: String, val description: String) 22 | -------------------------------------------------------------------------------- /app/src/main/kotlin/com/adriangl/devquicktiles/tiles/views/QsDescriptionsRecyclerViewAdapter.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2017 Adrián García 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 com.adriangl.devquicktiles.tiles.views 18 | 19 | import android.support.v7.widget.RecyclerView 20 | import android.view.LayoutInflater 21 | import android.view.View 22 | import android.view.ViewGroup 23 | import com.adriangl.devquicktiles.R 24 | import java.util.* 25 | 26 | class QsDescriptionsRecyclerViewAdapter : RecyclerView.Adapter() { 27 | val items = ArrayList() 28 | 29 | fun setItems(list: List) { 30 | items.clear() 31 | items.addAll(list) 32 | } 33 | 34 | override fun getItemCount(): Int { 35 | return items.size 36 | } 37 | 38 | override fun onCreateViewHolder(parent: ViewGroup?, viewType: Int): QsDescriptionsRecyclerViewHolder { 39 | val itemView: View = LayoutInflater.from(parent?.context).inflate(R.layout.qs_description_item, parent, false) 40 | return QsDescriptionsRecyclerViewHolder(itemView) 41 | } 42 | 43 | override fun onBindViewHolder(holder: QsDescriptionsRecyclerViewHolder?, position: Int) { 44 | holder?.itemTitle?.text = items[position].title 45 | holder?.itemDescription?.text = items[position].description 46 | holder?.itemIcon?.setImageResource(items[position].iconResource) 47 | } 48 | 49 | } 50 | -------------------------------------------------------------------------------- /app/src/main/kotlin/com/adriangl/devquicktiles/tiles/views/QsDescriptionsRecyclerViewHolder.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2017 Adrián García 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 com.adriangl.devquicktiles.tiles.views 18 | 19 | import android.support.v7.widget.RecyclerView 20 | import android.view.View 21 | import android.widget.ImageView 22 | import android.widget.TextView 23 | import com.adriangl.devquicktiles.R 24 | 25 | class QsDescriptionsRecyclerViewHolder(itemView: View?) : RecyclerView.ViewHolder(itemView) { 26 | val itemTitle: TextView = itemView?.findViewById(R.id.qs_title) as TextView 27 | val itemDescription: TextView = itemView?.findViewById(R.id.qs_description) as TextView 28 | val itemIcon: ImageView = itemView?.findViewById(R.id.qs_icon) as ImageView 29 | } -------------------------------------------------------------------------------- /app/src/main/kotlin/com/adriangl/devquicktiles/utils/PermissionUtils.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2017 Adrián García 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 com.adriangl.devquicktiles.utils 18 | 19 | import android.content.Context 20 | import android.content.pm.PackageManager 21 | import android.support.v4.app.ActivityCompat 22 | 23 | class PermissionUtils { 24 | companion object { 25 | fun checkSelfPermissionIsGranted(context: Context, permission: String): Boolean { 26 | return ActivityCompat.checkSelfPermission(context, permission) == PackageManager.PERMISSION_GRANTED 27 | } 28 | } 29 | } -------------------------------------------------------------------------------- /app/src/main/kotlin/com/adriangl/devquicktiles/utils/SettingsUtils.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2017 Adrián García 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 com.adriangl.devquicktiles.utils 18 | 19 | import android.content.ContentResolver 20 | import android.provider.Settings 21 | 22 | class SettingsUtils { 23 | companion object { 24 | fun getIntFromGlobalSettings(contentResolver: ContentResolver, key: String): Int { 25 | return Settings.Global.getInt(contentResolver, key, 0) 26 | } 27 | 28 | fun setIntToGlobalSettings(contentResolver: ContentResolver, key: String, value: Int): Boolean { 29 | return Settings.Global.putInt(contentResolver, key, value) 30 | } 31 | 32 | fun getFloatFromGlobalSettings(contentResolver: ContentResolver, key: String): Float { 33 | return Settings.Global.getFloat(contentResolver, key, 0f) 34 | } 35 | 36 | fun setFloatToGlobalSettings(contentResolver: ContentResolver, key: String, value: Float): Boolean { 37 | return Settings.Global.putFloat(contentResolver, key, value) 38 | } 39 | 40 | fun getIntFromSystemSettings(contentResolver: ContentResolver, key: String): Int { 41 | return Settings.System.getInt(contentResolver, key, 0) 42 | } 43 | 44 | fun setIntToSystemSettings(contentResolver: ContentResolver, key: String, value: Int): Boolean { 45 | return Settings.System.putInt(contentResolver, key, value) 46 | } 47 | } 48 | } 49 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/ic_qs_animator_duration_10x.xml: -------------------------------------------------------------------------------- 1 | 16 | 17 | 22 | 23 | 27 | 28 | 32 | 33 | 36 | 37 | 40 | 41 | 42 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/ic_qs_animator_duration_1_5x.xml: -------------------------------------------------------------------------------- 1 | 16 | 17 | 22 | 23 | 27 | 28 | 32 | 33 | 36 | 37 | 40 | 41 | 44 | 45 | 46 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/ic_qs_animator_duration_1x.xml: -------------------------------------------------------------------------------- 1 | 16 | 17 | 22 | 23 | 27 | 28 | 32 | 33 | 36 | 37 | 40 | 41 | 42 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/ic_qs_animator_duration_2x.xml: -------------------------------------------------------------------------------- 1 | 16 | 17 | 22 | 23 | 27 | 28 | 32 | 33 | 36 | 37 | 40 | 41 | 42 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/ic_qs_animator_duration_5x.xml: -------------------------------------------------------------------------------- 1 | 16 | 17 | 22 | 23 | 27 | 28 | 32 | 33 | 36 | 37 | 40 | 41 | 42 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/ic_qs_animator_duration_disabled.xml: -------------------------------------------------------------------------------- 1 | 16 | 17 | 22 | 23 | 27 | 28 | 31 | 32 | 36 | 37 | 41 | 42 | 45 | 46 | 51 | 52 | 53 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/ic_qs_animator_duration_enabled.xml: -------------------------------------------------------------------------------- 1 | 16 | 17 | 22 | 23 | 27 | 28 | 32 | 33 | 36 | 37 | 38 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/ic_qs_animator_duration_half_x.xml: -------------------------------------------------------------------------------- 1 | 16 | 17 | 22 | 23 | 27 | 28 | 32 | 33 | 36 | 37 | 40 | 41 | 42 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/ic_qs_demo_mode_disabled.xml: -------------------------------------------------------------------------------- 1 | 16 | 17 | 22 | 25 | 26 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/ic_qs_demo_mode_enabled.xml: -------------------------------------------------------------------------------- 1 | 16 | 17 | 22 | 25 | 26 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/ic_qs_finish_activities_disabled.xml: -------------------------------------------------------------------------------- 1 | 16 | 17 | 22 | 25 | 26 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/ic_qs_finish_activities_enabled.xml: -------------------------------------------------------------------------------- 1 | 16 | 17 | 22 | 25 | 26 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/ic_qs_keep_screen_on_disabled.xml: -------------------------------------------------------------------------------- 1 | 16 | 17 | 22 | 25 | 26 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/ic_qs_keep_screen_on_enabled.xml: -------------------------------------------------------------------------------- 1 | 16 | 17 | 22 | 25 | 26 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/ic_qs_show_taps_disabled.xml: -------------------------------------------------------------------------------- 1 | 16 | 17 | 22 | 25 | 26 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/ic_qs_show_taps_enabled.xml: -------------------------------------------------------------------------------- 1 | 16 | 17 | 22 | 25 | 26 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/ic_qs_usb_debugging_disabled.xml: -------------------------------------------------------------------------------- 1 | 16 | 17 | 22 | 25 | 26 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/ic_qs_usb_debugging_enabled.xml: -------------------------------------------------------------------------------- 1 | 16 | 17 | 22 | 25 | 26 | -------------------------------------------------------------------------------- /app/src/main/res/layout/activity_main.xml: -------------------------------------------------------------------------------- 1 | 2 | 17 | 18 | 24 | 25 | 28 | 29 | 37 | 38 | 39 | 40 | 41 | 47 | 48 | 49 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | -------------------------------------------------------------------------------- /app/src/main/res/layout/grant_permissions_dialog.xml: -------------------------------------------------------------------------------- 1 | 16 | 17 | 23 | 24 | 31 | 32 | 38 | 39 | 44 | 45 | 51 | 52 |