├── .gitignore ├── .gitmodules ├── .travis.yml ├── LICENSE ├── README.md ├── app ├── .gitignore ├── build.gradle ├── proguard-rules.pro └── src │ ├── androidTest │ └── java │ │ └── com │ │ └── ms_square │ │ └── android │ │ └── design │ │ └── overlay │ │ └── ApplicationTest.java │ └── main │ ├── AndroidManifest.xml │ ├── java │ └── com │ │ └── ms_square │ │ └── android │ │ └── design │ │ └── overlay │ │ ├── activity │ │ ├── SettingsActivity.java │ │ └── base │ │ │ └── BaseActivity.java │ │ ├── app │ │ ├── AppEnvironment.java │ │ └── DesignOverlayApplication.java │ │ ├── event │ │ └── OverlayServiceEvent.java │ │ ├── fragment │ │ └── SettingsFragment.java │ │ ├── service │ │ └── DesignOverlayService.java │ │ ├── task │ │ └── SafeAsyncTask.java │ │ ├── util │ │ ├── ImageUtil.java │ │ └── PrefUtil.java │ │ └── view │ │ ├── GridView.java │ │ ├── ImagePreference.java │ │ └── SeekBarPreference.java │ └── res │ ├── drawable-xhdpi │ ├── ic_action_clear.png │ ├── ic_launcher.png │ └── ic_notification.png │ ├── drawable-xxhdpi │ ├── ic_action_clear.png │ ├── ic_launcher.png │ └── ic_notification.png │ ├── drawable-xxxhdpi │ ├── ic_launcher.png │ └── ic_notification.png │ ├── layout │ ├── activity_settings.xml │ ├── pref_layout_seekbar.xml │ ├── pref_widget_layout_image.xml │ └── service_design_overlay.xml │ ├── values-ja │ └── strings.xml │ ├── values-land │ └── dimens.xml │ ├── values-large │ └── dimens.xml │ ├── values-sw720dp │ └── dimens.xml │ ├── values-w820dp │ └── dimens.xml │ ├── values │ ├── arrays.xml │ ├── attrs.xml │ ├── colors.xml │ ├── dimens.xml │ ├── strings.xml │ ├── styles.xml │ └── template-dimens.xml │ └── xml │ └── preferences.xml ├── appium ├── README.md ├── android_sauce_labs.py └── config_sauce_labs.json ├── art ├── app_screenshot.png ├── screenshot_1.png └── screenshot_2.png ├── build.gradle ├── gradle.properties ├── gradle └── wrapper │ ├── gradle-wrapper.jar │ └── gradle-wrapper.properties ├── gradlew ├── gradlew.bat ├── requirements.txt └── settings.gradle /.gitignore: -------------------------------------------------------------------------------- 1 | # Local configuration file (sdk path, etc) 2 | local.properties 3 | keystore.properties 4 | 5 | # Gradle 6 | .gradle 7 | build/ 8 | 9 | # Android Studio Project files 10 | *.iml 11 | .idea 12 | 13 | # Python 14 | __pycache__/ 15 | *.py[cod] 16 | appium/pytestdebug.log 17 | 18 | # Windows thumbnail db 19 | .DS_Store -------------------------------------------------------------------------------- /.gitmodules: -------------------------------------------------------------------------------- 1 | [submodule "app/libs/android-ColorPickerPreference"] 2 | path = app/libs/android-ColorPickerPreference 3 | url = https://github.com/attenzione/android-ColorPickerPreference.git 4 | ignore = dirty 5 | -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | language: android 2 | 3 | android: 4 | components: 5 | # The BuildTools version used by your project 6 | - build-tools-22.0.1 7 | 8 | # The SDK version used to compile your project 9 | - android-22 10 | 11 | # Additional components 12 | - extra-android-m2repository 13 | 14 | # command to install dependencies 15 | install: 16 | - sudo pip install -r requirements.txt 17 | 18 | # command to build and run tests 19 | script: 20 | - ./gradlew sauceLabsDebug 21 | 22 | addons: 23 | sauce_connect: true 24 | 25 | env: 26 | global: 27 | - secure: A1jbSplRPc7lRcjT6yY3Z33ynAEmiSzub5ADEXys4VtzjhenRCejkYAyLmNLm4ywbWWhmmZqXT70YPJQTBr5tbZlfHx5P2GRU1MtBvcXSUO+5RJ3swc80UOVvllhfHNuiiraqwSNcWl7skPHxDfBPBe8QOLp4A17JpJEJ8nFqpc= 28 | - secure: fFmQjyp/tTloQmWFnNb7CZQsk92kZV7a78J0y0XW1kW+NPauxQ7MHsI9GAsOrEByyGF4xz2eKq37Z+LoMZtvcCgPWz5mt62QFQ2jXDxXckVeYr6JQW6gnXMcCR96V7RYLPHW9HbfOYcchiS2lu5ytogNh3NU35OgAscOTfO0Gtc= -------------------------------------------------------------------------------- /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 2015 Manabu Shimobe 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. -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | DesignOverlay - for developers and designers 2 | =============== 3 | 4 | [![Build Status](https://travis-ci.org/Manabu-GT/DesignOverlay-Android.svg?branch=master)](https://travis-ci.org/Manabu-GT/DesignOverlay-Android) 5 | [![Sauce Test Status](https://saucelabs.com/buildstatus/design-overlay)](https://saucelabs.com/u/design-overlay) 6 | [![Android Arsenal](https://img.shields.io/badge/Android%20Arsenal-DesignOverlay-brightgreen.svg?style=flat)](http://android-arsenal.com/details/3/1654) 7 | 8 | DesignOverlay is an android app which displays a design image with grid lines to facilitate the tedious layout process. 9 | The grid is especially useful to align to baseline grids as described in [Android Design Guidelines][1]. 10 | 11 | Download from Google Play 12 | ------------------------- 13 | 14 | 15 | Android app on Google Play 17 | 18 | 19 | Requirements 20 | ------------- 21 | API Level 14 (ICS) and above. 22 | 23 | Why is this useful? 24 | --------------------- 25 | ### Designers 26 | Just share pixel-perfect design images with a developer, no longer need to create a redline document which specifies layout parameters of every UI element. 27 | 28 | Note: 29 | Developers probably also need font styling information to implement your design since font style is hard to guess based on just images. 30 | 31 | ### Developers 32 | With the design images shared by a designer, you can easily tweak the layout parameters using design image and grid overlay this app provides and verify design implementation. During that process, I highly recommend using [Mirror Plugin for Android Studio][2] provided by jimulabs to even facilitate the process. 33 | 34 | How to use 35 | ------------ 36 | - Start the app and enable the switch on the top right. 37 | - Select an image to overlay. 38 | - Go to your app and see if the layout matches with the design image. 39 | 40 | app screenshot 41 | 42 | [Live Demo] (https://appetize.io/app/x736nfpb8hzjuqrdt3bgzhddh0) 43 | 44 | These are just examples of how the overlay will look over an Etsy app. 45 | (I'm using Etsy as an example since it's a great app.) 46 | 47 | screenshot1 48 | screenshot2 49 | 50 | Available settings 51 | --------------------- 52 | - Show/Hide of Image/Grid 53 | - Image to overlay 54 | - Image transparency 55 | - Grid size in dp (default is 4dp) 56 | - Grid line color and transparency 57 | - Fullscreen mode (if enabled, it will draw overlay from the top of the screen -> draws over status bar) 58 | 59 | How to build 60 | ------------- 61 | 62 | ``` 63 | git submodule update --init 64 | ./gradlew assembleDebug 65 | ``` 66 | 67 | Contributors 68 | ------------- 69 | [Atsushi Ienaka][3] - application icons and play store images 70 | 71 | License 72 | ---------- 73 | 74 | Copyright 2015 Manabu Shimobe 75 | 76 | Licensed under the Apache License, Version 2.0 (the "License"); 77 | you may not use this file except in compliance with the License. 78 | You may obtain a copy of the License at 79 | 80 | http://www.apache.org/licenses/LICENSE-2.0 81 | 82 | Unless required by applicable law or agreed to in writing, software 83 | distributed under the License is distributed on an "AS IS" BASIS, 84 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 85 | See the License for the specific language governing permissions and 86 | limitations under the License. 87 | 88 | [1]: http://www.google.com/design/spec/layout/metrics-keylines.html# 89 | [2]: http://jimulabs.com/ 90 | [3]: https://dribbble.com/ATSUBOYYY 91 | -------------------------------------------------------------------------------- /app/.gitignore: -------------------------------------------------------------------------------- 1 | /build 2 | ms_square-release-key.keystore 3 | 4 | # Fabric Plugin API Key 5 | /src/release/AndroidManifest.xml -------------------------------------------------------------------------------- /app/build.gradle: -------------------------------------------------------------------------------- 1 | apply plugin: 'com.android.application' 2 | apply plugin: 'android-apt' 3 | apply plugin: 'saucelabs' 4 | 5 | configurations.all { 6 | // check for updates every build for changing modules 7 | resolutionStrategy.cacheChangingModulesFor 0, 'seconds' 8 | } 9 | 10 | android { 11 | compileSdkVersion project.ANDROID_BUILD_SDK_VERSION 12 | buildToolsVersion project.ANDROID_BUILD_TOOLS_VERSION 13 | 14 | // Gets the revision number from the Git 15 | def getRevision = { -> 16 | try { 17 | def stdout = new ByteArrayOutputStream() 18 | exec { 19 | commandLine 'git', 'rev-parse', 'HEAD' 20 | standardOutput = stdout 21 | } 22 | // pick first six characters 23 | return stdout.toString().trim().substring(0, 6) 24 | } catch (Exception e) { 25 | return "" 26 | } 27 | } 28 | 29 | defaultConfig { 30 | applicationId "com.ms_square.android.design.overlay" 31 | minSdkVersion project.ANDROID_BUILD_MIN_SDK_VERSION 32 | targetSdkVersion project.ANDROID_BUILD_TARGET_SDK_VERSION 33 | versionCode 5 34 | versionName "1.0.4" 35 | } 36 | 37 | signingConfigs { 38 | release { 39 | def Properties keyProps = new Properties() 40 | // double check if keystore.properties exists to avoid exception 41 | if (file("../keystore.properties").exists()) { 42 | keyProps.load(new FileInputStream(file('../keystore.properties'))) 43 | } 44 | storeFile keyProps["storeFile"] != null ? file(keyProps["storeFile"]) : null 45 | storePassword keyProps["storePassword"] 46 | keyAlias keyProps["keyAlias"] 47 | keyPassword keyProps["keyPassword"] 48 | } 49 | } 50 | 51 | buildTypes { 52 | debug { 53 | buildConfigField "String", "BUILD_NUMBER", "\"" + getRevision() + "\"" 54 | 55 | zipAlignEnabled true 56 | minifyEnabled false 57 | } 58 | release { 59 | buildConfigField "String", "BUILD_NUMBER", "\"" + getRevision() + "(R)\"" 60 | 61 | minifyEnabled false 62 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' 63 | 64 | // check if keystore.properties exists in the root 65 | if (file("../keystore.properties").exists()) { 66 | signingConfig signingConfigs.release 67 | } 68 | } 69 | } 70 | 71 | sauceLabsConfig { 72 | testCommand "py.test -s appium/android_sauce_labs.py" 73 | } 74 | } 75 | 76 | dependencies { 77 | compile fileTree(dir: 'libs', include: ['*.jar']) 78 | compile project(":ColorPickerPreference") 79 | 80 | // Support libraries 81 | compile "com.android.support:support-v4:${supportPackageVersion}" 82 | compile "com.android.support:appcompat-v7:${supportPackageVersion}" 83 | // to support annotations such as @NonNull 84 | compile "com.android.support:support-annotations:${supportPackageVersion}" 85 | 86 | // Android Annotaions Library 87 | compile "org.androidannotations:androidannotations-api:${project.androidAnnotationsVersion}" 88 | apt "org.androidannotations:androidannotations:${project.androidAnnotationsVersion}" 89 | 90 | // EventBus 91 | compile "de.greenrobot:eventbus:${project.eventBusVersion}" 92 | 93 | // Timber for logging 94 | compile "com.jakewharton.timber:timber:${project.timberVersion}" 95 | 96 | // Android Utility Library 97 | compile "com.ms-square:android-util:${project.androidUtilVersion}" 98 | } 99 | 100 | // for Android Annotations 101 | apt { 102 | arguments { 103 | androidManifestFile variant.outputs[0].processResources.manifestFile 104 | // to use android product flavors to change packageName 105 | resourcePackageName android.defaultConfig.applicationId 106 | } 107 | } -------------------------------------------------------------------------------- /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/manabu/Documents/android-sdk-macosx/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/ms_square/android/design/overlay/ApplicationTest.java: -------------------------------------------------------------------------------- 1 | package com.ms_square.android.design.overlay; 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 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 19 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | -------------------------------------------------------------------------------- /app/src/main/java/com/ms_square/android/design/overlay/activity/SettingsActivity.java: -------------------------------------------------------------------------------- 1 | package com.ms_square.android.design.overlay.activity; 2 | 3 | import android.content.Context; 4 | import android.content.Intent; 5 | import android.widget.CompoundButton; 6 | import android.widget.Switch; 7 | 8 | import com.ms_square.android.design.overlay.R; 9 | import com.ms_square.android.design.overlay.activity.base.BaseActivity; 10 | import com.ms_square.android.design.overlay.app.AppEnvironment; 11 | import com.ms_square.android.design.overlay.event.OverlayServiceEvent; 12 | import com.ms_square.android.design.overlay.service.DesignOverlayService; 13 | 14 | import org.androidannotations.annotations.AfterViews; 15 | import org.androidannotations.annotations.EActivity; 16 | import org.androidannotations.annotations.ViewById; 17 | 18 | @EActivity(R.layout.activity_settings) 19 | public class SettingsActivity extends BaseActivity { 20 | 21 | @ViewById(R.id.grid_switch) 22 | Switch mGridSwitch; 23 | 24 | public static Intent createIntent(Context context) { 25 | Intent intent = new Intent(context, SettingsActivity_.class); 26 | return intent; 27 | } 28 | 29 | @AfterViews 30 | void afterViews() { 31 | mGridSwitch.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() { 32 | @Override 33 | public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) { 34 | if (isChecked) { 35 | startService(DesignOverlayService.createIntent(SettingsActivity.this)); 36 | } else { 37 | stopService(DesignOverlayService.createIntent(SettingsActivity.this)); 38 | } 39 | } 40 | }); 41 | } 42 | 43 | @Override 44 | protected boolean shouldRegisterToEventBus() { 45 | return true; 46 | } 47 | 48 | public void onEventMainThread(OverlayServiceEvent event) { 49 | if (mGridSwitch != null) { 50 | mGridSwitch.setChecked(event.isRunning); 51 | } 52 | } 53 | 54 | @Override 55 | protected void onResume() { 56 | super.onResume(); 57 | mGridSwitch.setChecked(AppEnvironment.INSTANCE.isOverlayServiceRunning()); 58 | } 59 | } -------------------------------------------------------------------------------- /app/src/main/java/com/ms_square/android/design/overlay/activity/base/BaseActivity.java: -------------------------------------------------------------------------------- 1 | package com.ms_square.android.design.overlay.activity.base; 2 | 3 | import android.os.Bundle; 4 | import android.support.v7.app.ActionBarActivity; 5 | 6 | import de.greenrobot.event.EventBus; 7 | 8 | public abstract class BaseActivity extends ActionBarActivity { 9 | 10 | private boolean mVisible; 11 | private boolean mStopped; 12 | 13 | @Override 14 | protected void onCreate(Bundle savedInstanceState) { 15 | super.onCreate(savedInstanceState); 16 | if (shouldRegisterToEventBus()) { 17 | EventBus.getDefault().register(this); 18 | } 19 | } 20 | 21 | @Override 22 | protected void onResume() { 23 | super.onResume(); 24 | mVisible = true; 25 | mStopped = false; 26 | } 27 | 28 | @Override 29 | protected void onPause() { 30 | super.onPause(); 31 | mVisible = false; 32 | } 33 | 34 | @Override 35 | protected void onStop() { 36 | super.onStop(); 37 | mStopped = true; 38 | } 39 | 40 | @Override 41 | protected void onDestroy() { 42 | if (EventBus.getDefault().isRegistered(this)) { 43 | EventBus.getDefault().unregister(this); 44 | } 45 | super.onDestroy(); 46 | } 47 | 48 | public boolean isVisible() { 49 | return mVisible; 50 | } 51 | 52 | public boolean isStopped() { 53 | return mStopped; 54 | } 55 | 56 | protected boolean shouldRegisterToEventBus() { 57 | return false; 58 | } 59 | } -------------------------------------------------------------------------------- /app/src/main/java/com/ms_square/android/design/overlay/app/AppEnvironment.java: -------------------------------------------------------------------------------- 1 | package com.ms_square.android.design.overlay.app; 2 | 3 | import com.ms_square.android.design.overlay.event.OverlayServiceEvent; 4 | 5 | import de.greenrobot.event.EventBus; 6 | 7 | public enum AppEnvironment { 8 | INSTANCE; 9 | 10 | private boolean mOverlayServiceRunning; 11 | 12 | public void setOverlayServiceRunning(boolean isRunning) { 13 | mOverlayServiceRunning = isRunning; 14 | EventBus.getDefault().post(new OverlayServiceEvent(isRunning)); 15 | } 16 | 17 | public boolean isOverlayServiceRunning() { 18 | return mOverlayServiceRunning; 19 | } 20 | } -------------------------------------------------------------------------------- /app/src/main/java/com/ms_square/android/design/overlay/app/DesignOverlayApplication.java: -------------------------------------------------------------------------------- 1 | package com.ms_square.android.design.overlay.app; 2 | 3 | import android.app.Application; 4 | import android.preference.PreferenceManager; 5 | 6 | import com.ms_square.android.design.overlay.BuildConfig; 7 | import com.ms_square.android.design.overlay.R; 8 | 9 | import timber.log.Timber; 10 | 11 | public class DesignOverlayApplication extends Application { 12 | 13 | @Override 14 | public void onCreate() { 15 | super.onCreate(); 16 | 17 | if (BuildConfig.DEBUG) { 18 | // set up Timber for logging 19 | Timber.plant(new Timber.DebugTree()); 20 | } 21 | 22 | // set default values for the app preference 23 | PreferenceManager.setDefaultValues(this, R.xml.preferences, false); 24 | } 25 | } -------------------------------------------------------------------------------- /app/src/main/java/com/ms_square/android/design/overlay/event/OverlayServiceEvent.java: -------------------------------------------------------------------------------- 1 | package com.ms_square.android.design.overlay.event; 2 | 3 | public class OverlayServiceEvent { 4 | 5 | public final boolean isRunning; 6 | 7 | public OverlayServiceEvent(boolean isRunning) { 8 | this.isRunning = isRunning; 9 | } 10 | } -------------------------------------------------------------------------------- /app/src/main/java/com/ms_square/android/design/overlay/fragment/SettingsFragment.java: -------------------------------------------------------------------------------- 1 | package com.ms_square.android.design.overlay.fragment; 2 | 3 | import android.app.Activity; 4 | import android.content.Context; 5 | import android.content.Intent; 6 | import android.graphics.Bitmap; 7 | import android.net.Uri; 8 | import android.os.Build; 9 | import android.os.Bundle; 10 | import android.preference.ListPreference; 11 | import android.preference.Preference; 12 | import android.preference.PreferenceFragment; 13 | import android.preference.PreferenceManager; 14 | import android.util.TypedValue; 15 | import android.widget.Toast; 16 | 17 | import com.ms_square.android.design.overlay.BuildConfig; 18 | import com.ms_square.android.design.overlay.R; 19 | import com.ms_square.android.design.overlay.task.SafeAsyncTask; 20 | import com.ms_square.android.design.overlay.util.ImageUtil; 21 | import com.ms_square.android.design.overlay.util.PrefUtil; 22 | import com.ms_square.android.design.overlay.view.ImagePreference; 23 | import com.ms_square.android.util.AppUtil; 24 | import com.ms_square.android.util.ToastMaster; 25 | 26 | import java.io.FileNotFoundException; 27 | import java.io.IOException; 28 | import java.io.InputStream; 29 | 30 | import timber.log.Timber; 31 | 32 | public class SettingsFragment extends PreferenceFragment implements Preference.OnPreferenceClickListener { 33 | 34 | private static final int REQUEST_CODE_IMAGE = 10000; 35 | 36 | private Context mAppContext; 37 | 38 | private ImagePreference mImagePreference; 39 | 40 | private int mImageSize; 41 | 42 | public static SettingsFragment newInstance() { 43 | SettingsFragment fragment = new SettingsFragment(); 44 | //Bundle args = new Bundle(); 45 | //fragment.setArguments(args); 46 | return fragment; 47 | } 48 | 49 | @Override 50 | public void onCreate(Bundle savedInstanceState) { 51 | super.onCreate(savedInstanceState); 52 | addPreferencesFromResource(R.xml.preferences); 53 | 54 | // Bind the summaries of EditText/List/Dialog/Ringtone preferences 55 | // to their values. When their values change, their summaries are 56 | // updated to reflect the new value, per the Android Design 57 | // guidelines. 58 | bindPreferenceSummaryToValue(findPreference(PrefUtil.PREF_GRID_SIZE)); 59 | 60 | mAppContext = getActivity().getApplicationContext(); 61 | 62 | // get listPreferredItemHeight value in pixel and set it to mImageSize 63 | TypedValue value = new TypedValue(); 64 | getActivity().getTheme().resolveAttribute(android.R.attr.listPreferredItemHeight, value, true); 65 | mImageSize = (int) value.getDimension(getResources().getDisplayMetrics()); 66 | 67 | mImagePreference = (ImagePreference) findPreference(PrefUtil.PREF_DESIGN_IMAGE_URI); 68 | mImagePreference.setOnPreferenceClickListener(this); 69 | // load image if already set 70 | Uri imageUri = PrefUtil.getDesignImageUri(mAppContext); 71 | if (imageUri != null) { 72 | loadDesignImage(imageUri); 73 | } 74 | 75 | // Set application version 76 | Preference appVer = findPreference("pref_app_version"); 77 | appVer.setSummary(AppUtil.getVersion(mAppContext) + " - " + BuildConfig.BUILD_NUMBER); 78 | } 79 | 80 | @Override 81 | public void onActivityResult(int requestCode, int resultCode, Intent data) { 82 | if (requestCode == REQUEST_CODE_IMAGE) { 83 | if (resultCode == Activity.RESULT_OK && data != null) { 84 | final Uri uri = data.getData(); 85 | if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) { 86 | // needs to take the persistable permission for post kitkat devices 87 | mAppContext.getContentResolver().takePersistableUriPermission(uri, 88 | Intent.FLAG_GRANT_READ_URI_PERMISSION); 89 | } 90 | loadDesignImage(uri); 91 | } 92 | } else { 93 | super.onActivityResult(requestCode, resultCode, data); 94 | } 95 | } 96 | 97 | @Override 98 | public boolean onPreferenceClick(Preference preference) { 99 | if (PrefUtil.PREF_DESIGN_IMAGE_URI.equals(preference.getKey())) { 100 | if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) { 101 | Intent intent = new Intent(Intent.ACTION_OPEN_DOCUMENT); 102 | intent.addCategory(Intent.CATEGORY_OPENABLE); 103 | intent.setFlags(Intent.FLAG_GRANT_PERSISTABLE_URI_PERMISSION); 104 | intent.setType("image/*"); 105 | startActivityForResult(intent, REQUEST_CODE_IMAGE); 106 | } else { 107 | Intent intent = new Intent(Intent.ACTION_GET_CONTENT); 108 | intent.setType("image/*"); 109 | startActivityForResult(Intent.createChooser(intent, 110 | getString(R.string.intent_chooser_choose_image)), REQUEST_CODE_IMAGE); 111 | } 112 | return true; 113 | } 114 | return false; 115 | } 116 | 117 | private void loadDesignImage(final Uri uri) { 118 | new SafeAsyncTask(getActivity()) { 119 | @Override 120 | protected Bitmap onRun(Uri... params) { 121 | Bitmap bitmap = null; 122 | InputStream stream = null; 123 | try { 124 | stream = mAppContext.getContentResolver().openInputStream(params[0]); 125 | bitmap = ImageUtil.decodeSampledBitmapFromStream(stream, mImageSize, mImageSize); 126 | } catch (FileNotFoundException fe) { 127 | Timber.w("File was not found: %s", fe.toString()); 128 | } catch (SecurityException se) { 129 | Timber.w("Probably no longer have access permission to the uri: %s", se.toString()); 130 | // clear stored image Uri 131 | PrefUtil.setDesignImageUri(mAppContext, null); 132 | } finally { 133 | try { 134 | if (stream != null) { 135 | stream.close(); 136 | } 137 | } catch (IOException ignore) {} 138 | } 139 | return bitmap; 140 | } 141 | @Override 142 | protected void onSuccess(Bitmap bitmap) { 143 | if (bitmap != null) { 144 | PrefUtil.setDesignImageUri(mAppContext, uri); 145 | mImagePreference.updateImage(bitmap); 146 | } else { 147 | ToastMaster.showToast(mAppContext, getString(R.string.toast_bitmap_not_found), Toast.LENGTH_LONG); 148 | } 149 | } 150 | }.execute(uri); 151 | } 152 | 153 | /** 154 | * Binds a preference's summary to its value. More specifically, when the 155 | * preference's value is changed, its summary (line of text below the 156 | * preference title) is updated to reflect the value. The summary is also 157 | * immediately updated upon calling this method. The exact display format is 158 | * dependent on the type of preference. 159 | * 160 | * @see #sBindPreferenceSummaryToValueListener 161 | */ 162 | private static void bindPreferenceSummaryToValue(Preference preference) { 163 | // Set the listener to watch for value changes. 164 | preference.setOnPreferenceChangeListener(sBindPreferenceSummaryToValueListener); 165 | 166 | // Trigger the listener immediately with the preference's current value. 167 | sBindPreferenceSummaryToValueListener.onPreferenceChange(preference, PreferenceManager 168 | .getDefaultSharedPreferences(preference.getContext()) 169 | .getString(preference.getKey(), "")); 170 | } 171 | 172 | /** 173 | * A preference value change listener that updates the preference's summary 174 | * to reflect its new value. 175 | */ 176 | private static final Preference.OnPreferenceChangeListener sBindPreferenceSummaryToValueListener = new Preference.OnPreferenceChangeListener() { 177 | @Override 178 | public boolean onPreferenceChange(Preference preference, Object value) { 179 | String stringValue = value.toString(); 180 | 181 | if (preference instanceof ListPreference) { 182 | // For list preferences, look up the correct display value in 183 | // the preference's 'entries' list. 184 | ListPreference listPreference = (ListPreference) preference; 185 | int index = listPreference.findIndexOfValue(stringValue); 186 | 187 | // Set the summary to reflect the new value. 188 | preference.setSummary(index >= 0 189 | ? listPreference.getEntries()[index] 190 | : null); 191 | } else { 192 | // For all other preferences, set the summary to the value's 193 | // simple string representation. 194 | preference.setSummary(stringValue); 195 | } 196 | 197 | return true; 198 | } 199 | }; 200 | } -------------------------------------------------------------------------------- /app/src/main/java/com/ms_square/android/design/overlay/service/DesignOverlayService.java: -------------------------------------------------------------------------------- 1 | package com.ms_square.android.design.overlay.service; 2 | 3 | import android.annotation.TargetApi; 4 | import android.app.NotificationManager; 5 | import android.app.PendingIntent; 6 | import android.app.Service; 7 | import android.content.BroadcastReceiver; 8 | import android.content.Context; 9 | import android.content.Intent; 10 | import android.content.IntentFilter; 11 | import android.content.SharedPreferences; 12 | import android.graphics.Bitmap; 13 | import android.graphics.BitmapFactory; 14 | import android.graphics.PixelFormat; 15 | import android.net.Uri; 16 | import android.os.AsyncTask; 17 | import android.os.Build; 18 | import android.os.IBinder; 19 | import android.support.v4.app.NotificationCompat; 20 | import android.view.LayoutInflater; 21 | import android.view.View; 22 | import android.view.WindowManager; 23 | import android.widget.ImageView; 24 | 25 | import com.ms_square.android.design.overlay.R; 26 | import com.ms_square.android.design.overlay.activity.SettingsActivity; 27 | import com.ms_square.android.design.overlay.app.AppEnvironment; 28 | import com.ms_square.android.design.overlay.util.PrefUtil; 29 | import com.ms_square.android.design.overlay.view.GridView; 30 | 31 | import java.io.FileNotFoundException; 32 | import java.io.IOException; 33 | import java.io.InputStream; 34 | 35 | import timber.log.Timber; 36 | 37 | public class DesignOverlayService extends Service { 38 | 39 | private static final int NOTIFICATION_ID = 10000; 40 | 41 | private static final String ACTION_DISMISS = "com.ms_square.android.design.overlay.ACTION_DISMISS"; 42 | 43 | private WindowManager mWindowManager; 44 | 45 | private NotificationManager mNotificationManager; 46 | 47 | private View mRootView; 48 | 49 | private ImageView mDesignImgView; 50 | 51 | private GridView mGridView; 52 | 53 | public static Intent createIntent(Context context) { 54 | return new Intent(context, DesignOverlayService.class); 55 | } 56 | 57 | @Override 58 | public void onCreate() { 59 | super.onCreate(); 60 | 61 | AppEnvironment.INSTANCE.setOverlayServiceRunning(true); 62 | 63 | mNotificationManager = (NotificationManager) getSystemService(NOTIFICATION_SERVICE); 64 | 65 | mWindowManager = (WindowManager) getSystemService(Context.WINDOW_SERVICE); 66 | 67 | showOverlay(); 68 | 69 | registerReceiver(mReceiver, new IntentFilter(ACTION_DISMISS)); 70 | 71 | PrefUtil.registerOnSharedPreferenceChangeListener(this, mPrefListener); 72 | 73 | showNotification(); 74 | } 75 | 76 | @Override 77 | public int onStartCommand(Intent intent, int flags, int startId) { 78 | return Service.START_NOT_STICKY; 79 | } 80 | 81 | @Override 82 | public void onDestroy() { 83 | AppEnvironment.INSTANCE.setOverlayServiceRunning(false); 84 | PrefUtil.unregisterOnSharedPreferenceChangeListener(this, mPrefListener); 85 | unregisterReceiver(mReceiver); 86 | dismissOverlay(); 87 | cancelNotification(); 88 | super.onDestroy(); 89 | } 90 | 91 | @Override 92 | public IBinder onBind(Intent intent) { 93 | return null; 94 | } 95 | 96 | private void showOverlay() { 97 | mRootView = LayoutInflater.from(this).inflate(R.layout.service_design_overlay, null, false); 98 | mDesignImgView = (ImageView) mRootView.findViewById(R.id.design_image_view); 99 | mGridView = (GridView) mRootView.findViewById(R.id.grid_view); 100 | updateImageVisibility(); 101 | updateImageAlpha(); 102 | updateImage(); 103 | updateGridSize(); 104 | updateGridColor(); 105 | updateGridVisibility(); 106 | mWindowManager.addView(mRootView, createDefaultSystemWindowParams(PrefUtil.isFullScreen(this))); 107 | } 108 | 109 | private void dismissOverlay() { 110 | mWindowManager.removeView(mRootView); 111 | mRootView = null; 112 | mDesignImgView = null; 113 | mGridView = null; 114 | } 115 | 116 | private void updateImage() { 117 | if (mDesignImgView != null) { 118 | final Uri uri = PrefUtil.getDesignImageUri(this); 119 | if (uri != null) { 120 | new AsyncTask() { 121 | @Override 122 | protected Bitmap doInBackground(Uri... params) { 123 | Bitmap bitmap = null; 124 | InputStream stream = null; 125 | try { 126 | stream = getContentResolver().openInputStream(params[0]); 127 | bitmap = BitmapFactory.decodeStream(stream); 128 | } catch (FileNotFoundException fe) { 129 | Timber.w("File was not found: %s", fe.toString()); 130 | } catch (SecurityException se) { 131 | Timber.w("No longer have access permission to the uri: %s", se.toString()); 132 | // clear stored image Uri 133 | PrefUtil.setDesignImageUri(getApplicationContext(), null); 134 | } finally { 135 | try { 136 | if (stream != null) { 137 | stream.close(); 138 | } 139 | } catch (IOException ignore) {} 140 | } 141 | return bitmap; 142 | } 143 | 144 | @Override 145 | protected void onPostExecute(Bitmap bitmap) { 146 | if (mDesignImgView != null) { 147 | mDesignImgView.setImageBitmap(bitmap); 148 | } 149 | } 150 | }.execute(uri); 151 | } 152 | } 153 | } 154 | 155 | @TargetApi(Build.VERSION_CODES.JELLY_BEAN) 156 | private void updateImageAlpha() { 157 | if (mDesignImgView != null) { 158 | final int alpha = PrefUtil.getDesignImageAlpha(this); // 0 - 255 159 | if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) { 160 | mDesignImgView.setImageAlpha(alpha); 161 | } else { 162 | mDesignImgView.setAlpha(alpha); 163 | } 164 | } 165 | } 166 | 167 | private void updateImageVisibility() { 168 | if (mDesignImgView != null) { 169 | mDesignImgView.setVisibility(PrefUtil.isDesignImageEnabled(DesignOverlayService.this) ? 170 | View.VISIBLE : View.INVISIBLE); 171 | } 172 | } 173 | 174 | private void updateGridSize() { 175 | if (mGridView != null) { 176 | final int gridSize = PrefUtil.getGridSize(DesignOverlayService.this); 177 | final boolean alignRight = PrefUtil.isAlignRight(DesignOverlayService.this); 178 | final boolean alignBottom = PrefUtil.isAlignBottom(DesignOverlayService.this); 179 | mGridView.updateGridSize(gridSize, alignRight, alignBottom); 180 | } 181 | } 182 | 183 | private void updateGridColor() { 184 | if (mGridView != null) { 185 | mGridView.updateGridColor(PrefUtil.getGridColor(DesignOverlayService.this)); 186 | } 187 | } 188 | 189 | private void updateGridVisibility() { 190 | if (mGridView != null) { 191 | mGridView.setVisibility(PrefUtil.isGridEnabled(DesignOverlayService.this) ? 192 | View.VISIBLE : View.INVISIBLE); 193 | } 194 | } 195 | 196 | private void showNotification() { 197 | NotificationCompat.Builder mBuilder = new NotificationCompat.Builder(this) 198 | .setStyle(new NotificationCompat.BigTextStyle().bigText(getString(R.string.notification_big_text))) 199 | .setSmallIcon(R.drawable.ic_notification) 200 | .setOngoing(true) 201 | .setContentTitle(getString(R.string.notification_title)) 202 | .setContentText(getString(R.string.notification_small_text)) 203 | .setContentIntent(getNotificationIntent(null)); 204 | 205 | mBuilder.addAction(R.drawable.ic_action_clear, getString(R.string.notification_action_dismiss), 206 | getNotificationIntent(ACTION_DISMISS)); 207 | 208 | // show the notification 209 | startForeground(NOTIFICATION_ID, mBuilder.build()); 210 | } 211 | 212 | private void cancelNotification() { 213 | mNotificationManager.cancel(NOTIFICATION_ID); 214 | } 215 | 216 | private PendingIntent getNotificationIntent(String action) { 217 | if (action == null) { 218 | Intent intent = SettingsActivity.createIntent(this); 219 | return PendingIntent.getActivity(this, 0, intent, PendingIntent.FLAG_CANCEL_CURRENT); 220 | } else { 221 | Intent intent = new Intent(action); 222 | return PendingIntent.getBroadcast(this, 0, intent, PendingIntent.FLAG_CANCEL_CURRENT); 223 | } 224 | } 225 | 226 | private final BroadcastReceiver mReceiver = new BroadcastReceiver() { 227 | @Override 228 | public void onReceive(Context context, Intent intent) { 229 | final String action = intent.getAction(); 230 | switch (action) { 231 | case ACTION_DISMISS: 232 | stopSelf(); 233 | break; 234 | } 235 | } 236 | }; 237 | 238 | private final SharedPreferences.OnSharedPreferenceChangeListener mPrefListener = new SharedPreferences.OnSharedPreferenceChangeListener() { 239 | @Override 240 | public void onSharedPreferenceChanged(SharedPreferences sharedPreferences, String key) { 241 | switch (key) { 242 | case PrefUtil.PREF_FULLSCREEN: { 243 | dismissOverlay(); 244 | showOverlay(); 245 | break; 246 | } 247 | case PrefUtil.PREF_DESIGN_IMAGE_ENABLED: { 248 | updateImageVisibility(); 249 | break; 250 | } 251 | case PrefUtil.PREF_DESIGN_IMAGE_URI: { 252 | updateImage(); 253 | break; 254 | } 255 | case PrefUtil.PREF_DESIGN_IMAGE_ALPHA: { 256 | updateImageAlpha(); 257 | break; 258 | } 259 | case PrefUtil.PREF_GRID_ENABLED: { 260 | updateGridVisibility(); 261 | break; 262 | } 263 | case PrefUtil.PREF_GRID_SIZE: { 264 | updateGridSize(); 265 | break; 266 | } 267 | case PrefUtil.PREF_ALIGN_RIGHT: { 268 | updateGridSize(); 269 | break; 270 | } 271 | case PrefUtil.PREF_ALIGN_BOTTOM: { 272 | updateGridSize(); 273 | break; 274 | } 275 | case PrefUtil.PREF_GRID_COLOR: { 276 | updateGridColor(); 277 | break; 278 | } 279 | } 280 | } 281 | }; 282 | 283 | private static WindowManager.LayoutParams createDefaultSystemWindowParams(boolean isFullScreen) { 284 | WindowManager.LayoutParams params = new WindowManager.LayoutParams( 285 | WindowManager.LayoutParams.MATCH_PARENT, 286 | WindowManager.LayoutParams.MATCH_PARENT, 287 | WindowManager.LayoutParams.TYPE_SYSTEM_OVERLAY, 288 | isFullScreen ? WindowManager.LayoutParams.FLAG_LAYOUT_IN_SCREEN : 0, 289 | PixelFormat.TRANSLUCENT); 290 | params.format = PixelFormat.RGBA_8888; 291 | return params; 292 | } 293 | } -------------------------------------------------------------------------------- /app/src/main/java/com/ms_square/android/design/overlay/task/SafeAsyncTask.java: -------------------------------------------------------------------------------- 1 | package com.ms_square.android.design.overlay.task; 2 | 3 | import android.app.Activity; 4 | import android.os.AsyncTask; 5 | 6 | import java.lang.ref.WeakReference; 7 | 8 | public abstract class SafeAsyncTask extends AsyncTask { 9 | 10 | /** 11 | * Keep a weak reference to the activity to cancel automatically 12 | * if the activity is stopped 13 | */ 14 | private final WeakReference mWeakActivity; 15 | 16 | public SafeAsyncTask(Activity activity) { 17 | mWeakActivity = new WeakReference<>(activity); 18 | } 19 | 20 | @SafeVarargs 21 | @Override 22 | protected final Result doInBackground(Params... params) { 23 | return onRun(params); 24 | } 25 | 26 | @SafeVarargs 27 | @Override 28 | protected final void onProgressUpdate(Progress... values) { 29 | onProgress(values); 30 | } 31 | 32 | @Override 33 | protected final void onPostExecute(Result result) { 34 | if(canContinue()) { 35 | onSuccess(result); 36 | } 37 | } 38 | 39 | private boolean canContinue() { 40 | Activity activity = mWeakActivity.get(); 41 | return activity != null && !activity.isFinishing(); 42 | } 43 | 44 | @SuppressWarnings("unchecked") 45 | protected void onProgress(Progress... values) {} 46 | 47 | @SuppressWarnings("unchecked") 48 | protected abstract Result onRun(Params... params); 49 | 50 | @SuppressWarnings("unchecked") 51 | protected abstract void onSuccess(Result result); 52 | } -------------------------------------------------------------------------------- /app/src/main/java/com/ms_square/android/design/overlay/util/ImageUtil.java: -------------------------------------------------------------------------------- 1 | package com.ms_square.android.design.overlay.util; 2 | 3 | import android.graphics.Bitmap; 4 | import android.graphics.BitmapFactory; 5 | 6 | import java.io.BufferedInputStream; 7 | import java.io.IOException; 8 | import java.io.InputStream; 9 | 10 | import timber.log.Timber; 11 | 12 | public class ImageUtil { 13 | 14 | public static int calculateInSampleSize(BitmapFactory.Options options, int reqWidth, int reqHeight) { 15 | 16 | // Raw height and width of image 17 | final int height = options.outHeight; 18 | final int width = options.outWidth; 19 | int inSampleSize = 1; 20 | 21 | if (height > reqHeight || width > reqWidth) { 22 | 23 | final int halfHeight = height / 2; 24 | final int halfWidth = width / 2; 25 | 26 | // Calculate the largest inSampleSize value that is a power of 2 and keeps both 27 | // height and width larger than the requested height and width. 28 | while ((halfHeight / inSampleSize) > reqHeight 29 | && (halfWidth / inSampleSize) > reqWidth) { 30 | inSampleSize *= 2; 31 | } 32 | } 33 | 34 | return inSampleSize; 35 | } 36 | 37 | public static Bitmap decodeSampledBitmapFromStream(InputStream inputStream, 38 | int reqWidth, int reqHeight) { 39 | final BufferedInputStream bufferedInputStream = new BufferedInputStream(inputStream); 40 | bufferedInputStream.mark(Integer.MAX_VALUE); 41 | 42 | // First decode with inJustDecodeBounds = true to check dimensions 43 | final BitmapFactory.Options options = new BitmapFactory.Options(); 44 | options.inJustDecodeBounds = true; 45 | BitmapFactory.decodeStream(bufferedInputStream, null, options); 46 | 47 | // Calculate inSampleSize 48 | options.inSampleSize = calculateInSampleSize(options, reqWidth, reqHeight); 49 | 50 | try { 51 | bufferedInputStream.reset(); 52 | } catch (IOException e) { 53 | Timber.w("Could not reposition the stream:" + e); 54 | } 55 | 56 | // Decode bitmap with inSampleSize set 57 | options.inJustDecodeBounds = false; 58 | return BitmapFactory.decodeStream(bufferedInputStream, null, options); 59 | } 60 | } -------------------------------------------------------------------------------- /app/src/main/java/com/ms_square/android/design/overlay/util/PrefUtil.java: -------------------------------------------------------------------------------- 1 | package com.ms_square.android.design.overlay.util; 2 | 3 | import android.content.Context; 4 | import android.content.SharedPreferences; 5 | import android.net.Uri; 6 | import android.preference.PreferenceManager; 7 | 8 | import com.ms_square.android.util.DimenUtil; 9 | 10 | public class PrefUtil { 11 | 12 | public static final String PREF_FULLSCREEN = "pref_fullscreen"; 13 | 14 | public static final String PREF_DESIGN_IMAGE_ENABLED = "pref_design_image_enabled"; 15 | 16 | public static final String PREF_DESIGN_IMAGE_URI = "pref_design_image_uri"; 17 | 18 | public static final String PREF_DESIGN_IMAGE_ALPHA = "pref_design_image_alpha"; 19 | 20 | public static final String PREF_GRID_ENABLED = "pref_grid_enabled"; 21 | 22 | public static final String PREF_ALIGN_RIGHT = "pref_align_right"; 23 | 24 | public static final String PREF_ALIGN_BOTTOM = "pref_align_bottom"; 25 | 26 | public static final String PREF_GRID_SIZE = "pref_grid_size"; 27 | 28 | public static final String PREF_GRID_COLOR = "pref_grid_color"; 29 | 30 | /** Long indicating when a preference was last updated */ 31 | private static final String PREF_TIME_STAMP = "pref_time_stamp"; 32 | 33 | public static boolean isFullScreen(Context context) { 34 | return getSharedPrefs(context).getBoolean(PREF_FULLSCREEN, false); 35 | } 36 | 37 | public static boolean isDesignImageEnabled(Context context) { 38 | return getSharedPrefs(context).getBoolean(PREF_DESIGN_IMAGE_ENABLED, true); 39 | } 40 | 41 | public static Uri getDesignImageUri(Context context) { 42 | String uriString = getSharedPrefs(context).getString(PREF_DESIGN_IMAGE_URI, null); 43 | if (uriString != null) { 44 | return Uri.parse(uriString); 45 | } 46 | return null; 47 | } 48 | 49 | public static void setDesignImageUri(Context context, Uri uri) { 50 | SharedPreferences.Editor editor = getEditor(context); 51 | if (uri != null) { 52 | editor.putString(PREF_DESIGN_IMAGE_URI, uri.toString()); 53 | } else { 54 | editor.remove(PREF_DESIGN_IMAGE_URI); 55 | } 56 | apply(editor); 57 | } 58 | 59 | public static int getDesignImageAlpha(Context context) { 60 | return getSharedPrefs(context).getInt(PREF_DESIGN_IMAGE_ALPHA, 100); 61 | } 62 | 63 | public static boolean isGridEnabled(Context context) { 64 | return getSharedPrefs(context).getBoolean(PREF_GRID_ENABLED, true); 65 | } 66 | 67 | public static int getGridSize(Context context) { 68 | return (int) DimenUtil.convertToPixelFromDip(context, 69 | Float.parseFloat(getSharedPrefs(context).getString(PREF_GRID_SIZE, "4"))); 70 | } 71 | 72 | public static boolean isAlignRight(Context context) { 73 | return getSharedPrefs(context).getBoolean(PREF_ALIGN_RIGHT, false); 74 | } 75 | 76 | public static boolean isAlignBottom(Context context) { 77 | return getSharedPrefs(context).getBoolean(PREF_ALIGN_BOTTOM, false); 78 | } 79 | 80 | public static int getGridColor(Context context) { 81 | return getSharedPrefs(context).getInt(PREF_GRID_COLOR, 0x7732cd32); 82 | } 83 | 84 | public static void registerOnSharedPreferenceChangeListener(Context context, 85 | SharedPreferences.OnSharedPreferenceChangeListener listener) { 86 | getSharedPrefs(context).registerOnSharedPreferenceChangeListener(listener); 87 | } 88 | 89 | public static void unregisterOnSharedPreferenceChangeListener(Context context, 90 | SharedPreferences.OnSharedPreferenceChangeListener listener) { 91 | getSharedPrefs(context).unregisterOnSharedPreferenceChangeListener(listener); 92 | } 93 | 94 | private static SharedPreferences getSharedPrefs(Context context) { 95 | return PreferenceManager.getDefaultSharedPreferences(context); 96 | } 97 | 98 | private static SharedPreferences.Editor getEditor(Context context) { 99 | return getSharedPrefs(context).edit(); 100 | } 101 | 102 | // if you do not care about the result and calling from the main thread 103 | private static void apply(SharedPreferences.Editor editor) { 104 | editor.putLong(PREF_TIME_STAMP, getCurrentTime()); 105 | editor.apply(); 106 | } 107 | 108 | private static void commit(SharedPreferences.Editor editor) { 109 | editor.putLong(PREF_TIME_STAMP, getCurrentTime()); 110 | editor.commit(); 111 | } 112 | 113 | private static long getCurrentTime() { 114 | return System.currentTimeMillis(); 115 | } 116 | } -------------------------------------------------------------------------------- /app/src/main/java/com/ms_square/android/design/overlay/view/GridView.java: -------------------------------------------------------------------------------- 1 | package com.ms_square.android.design.overlay.view; 2 | 3 | import android.content.Context; 4 | import android.content.res.TypedArray; 5 | import android.graphics.Canvas; 6 | import android.graphics.Paint; 7 | import android.util.AttributeSet; 8 | import android.view.View; 9 | 10 | import com.ms_square.android.design.overlay.R; 11 | import com.ms_square.android.util.DimenUtil; 12 | 13 | import timber.log.Timber; 14 | 15 | public class GridView extends View { 16 | 17 | private final Paint mPaint = new Paint(); 18 | 19 | private int mGridSize; 20 | 21 | private float[] mPoints; 22 | private boolean mAlignBottom; 23 | private boolean mAlignRight; 24 | 25 | public GridView(Context context) { 26 | this(context, null); 27 | } 28 | 29 | public GridView(Context context, AttributeSet attrs) { 30 | this(context, attrs, 0); 31 | } 32 | 33 | public GridView(Context context, AttributeSet attrs, int defStyleAttr) { 34 | super(context, attrs, defStyleAttr); 35 | 36 | final float defaultLineWidth = DimenUtil.convertToPixelFromDip(context, 1f); // 1dp 37 | 38 | TypedArray typedArray = context.obtainStyledAttributes(attrs, R.styleable.GridView); 39 | mPaint.setColor(typedArray.getColor(R.styleable.GridView_lineColor, 0x7732cd32)); 40 | mPaint.setStrokeWidth(typedArray.getDimension(R.styleable.GridView_lineWidth, defaultLineWidth)); 41 | typedArray.recycle(); 42 | 43 | mPaint.setStyle(Paint.Style.STROKE); 44 | } 45 | 46 | /** 47 | * 48 | * @param newGridSize - in pixels 49 | */ 50 | public void updateGridSize(int newGridSize, boolean alignRight, boolean alignBottom) { 51 | mGridSize = newGridSize; 52 | mAlignRight = alignRight; 53 | mAlignBottom = alignBottom; 54 | 55 | updateGrid(getWidth(), getHeight()); 56 | invalidate(); 57 | } 58 | 59 | public void updateGridColor(int newColor) { 60 | mPaint.setColor(newColor); 61 | invalidate(); 62 | } 63 | 64 | private void updateGrid(int width, int height) { 65 | int numHorizontalLines = height / mGridSize; 66 | int numVerticalLines = width / mGridSize; 67 | 68 | int numHorizontalPoints = numHorizontalLines > 0 ? (numHorizontalLines + 1) * 4 : 0; 69 | int numVerticalPoints = numVerticalLines > 0 ? (numVerticalLines + 1) * 4 : 0; 70 | 71 | if (numHorizontalPoints + numVerticalPoints > 0) { 72 | mPoints = new float[numHorizontalPoints + numVerticalPoints]; 73 | 74 | int positionShift = 0; 75 | if (mAlignBottom) { 76 | positionShift = - (mGridSize - height % mGridSize); 77 | } 78 | 79 | // set up horizontal lines 80 | float gap = mGridSize; 81 | for (int i = 0; i <= numHorizontalLines; i++) { 82 | int base = i * 4; 83 | mPoints[base] = 0f; 84 | mPoints[base + 1] = gap + positionShift; 85 | mPoints[base + 2] = (float) width; 86 | mPoints[base + 3] = gap + positionShift; 87 | gap = gap + mGridSize; 88 | } 89 | 90 | positionShift = 0; 91 | if (mAlignRight) { 92 | positionShift = - (mGridSize - width % mGridSize); 93 | } 94 | 95 | // set up vertical lines 96 | gap = mGridSize; 97 | for (int i = 0; i <= numVerticalLines; i++) { 98 | int base = i * 4 + numHorizontalPoints; 99 | mPoints[base] = gap + positionShift; 100 | mPoints[base + 1] = 0f; 101 | mPoints[base + 2] = gap + positionShift; 102 | mPoints[base + 3] = (float) height; 103 | gap = gap + mGridSize; 104 | } 105 | } else { 106 | mPoints = null; 107 | } 108 | } 109 | 110 | @Override 111 | protected void onSizeChanged(int w, int h, int oldw, int oldh) { 112 | super.onSizeChanged(w, h, oldw, oldh); 113 | Timber.d("SizeChanged: %d, %d, %d, %d", w, h, oldw, oldh); 114 | updateGrid(w, h); 115 | } 116 | 117 | @Override 118 | public void onDraw(Canvas canvas) { 119 | if (mPoints != null) { 120 | canvas.drawLines(mPoints, mPaint); 121 | } 122 | } 123 | } -------------------------------------------------------------------------------- /app/src/main/java/com/ms_square/android/design/overlay/view/ImagePreference.java: -------------------------------------------------------------------------------- 1 | package com.ms_square.android.design.overlay.view; 2 | 3 | import android.content.Context; 4 | import android.graphics.Bitmap; 5 | import android.preference.Preference; 6 | import android.util.AttributeSet; 7 | import android.view.View; 8 | import android.widget.ImageView; 9 | 10 | import com.ms_square.android.design.overlay.R; 11 | 12 | public class ImagePreference extends Preference { 13 | 14 | private ImageView mImageView; 15 | 16 | private Bitmap mBitmap; 17 | 18 | // this is the one used when inflating preference from XML 19 | public ImagePreference(Context context, AttributeSet attrs) { 20 | super(context, attrs); 21 | } 22 | 23 | @Override 24 | protected void onBindView(View view) { 25 | super.onBindView(view); 26 | mImageView = (ImageView) view.findViewById(R.id.image_view); 27 | mImageView.setImageBitmap(mBitmap); 28 | } 29 | 30 | public void updateImage(Bitmap bitmap) { 31 | // onBindView might not have been called 32 | if (mImageView != null) { 33 | mImageView.setImageBitmap(bitmap); 34 | } 35 | mBitmap = bitmap; 36 | } 37 | } -------------------------------------------------------------------------------- /app/src/main/java/com/ms_square/android/design/overlay/view/SeekBarPreference.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2011 The Android Open Source Project 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.ms_square.android.design.overlay.view; 18 | 19 | import android.content.Context; 20 | import android.content.res.TypedArray; 21 | import android.os.Parcel; 22 | import android.os.Parcelable; 23 | import android.preference.Preference; 24 | import android.util.AttributeSet; 25 | import android.view.View; 26 | import android.widget.SeekBar; 27 | import android.widget.SeekBar.OnSeekBarChangeListener; 28 | 29 | import com.ms_square.android.design.overlay.R; 30 | 31 | public class SeekBarPreference extends Preference 32 | implements OnSeekBarChangeListener { 33 | 34 | private static final int SEEK_MAX = 230; 35 | 36 | private int mProgress; 37 | private int mMax; 38 | private boolean mTrackingTouch; 39 | 40 | public SeekBarPreference(Context context, AttributeSet attrs) { 41 | super(context, attrs); 42 | 43 | setLayoutResource(R.layout.pref_layout_seekbar); 44 | 45 | setProgress(getPersistedInt(100)); 46 | setMax(SEEK_MAX); 47 | } 48 | 49 | @Override 50 | protected void onBindView(View view) { 51 | super.onBindView(view); 52 | SeekBar seekBar = (SeekBar) view.findViewById(R.id.seekbar); 53 | seekBar.setOnSeekBarChangeListener(this); 54 | seekBar.setMax(mMax); 55 | seekBar.setProgress(mProgress); 56 | seekBar.setEnabled(isEnabled()); 57 | } 58 | 59 | @Override 60 | public CharSequence getSummary() { 61 | return null; 62 | } 63 | 64 | @Override 65 | protected void onSetInitialValue(boolean restoreValue, Object defaultValue) { 66 | setProgress(restoreValue ? getPersistedInt(mProgress) 67 | : (Integer) defaultValue); 68 | } 69 | 70 | @Override 71 | protected Object onGetDefaultValue(TypedArray a, int index) { 72 | return a.getInt(index, 0); 73 | } 74 | 75 | public void setMax(int max) { 76 | if (max != mMax) { 77 | mMax = max; 78 | notifyChanged(); 79 | } 80 | } 81 | 82 | public void setProgress(int progress) { 83 | setProgress(progress, true); 84 | } 85 | 86 | private void setProgress(int progress, boolean notifyChanged) { 87 | if (progress > mMax) { 88 | progress = mMax; 89 | } 90 | if (progress < 0) { 91 | progress = 0; 92 | } 93 | if (progress != mProgress) { 94 | mProgress = progress; 95 | persistInt(progress); 96 | if (notifyChanged) { 97 | notifyChanged(); 98 | } 99 | } 100 | } 101 | 102 | public int getProgress() { 103 | return mProgress; 104 | } 105 | 106 | /** 107 | * Persist the seekBar's progress value if callChangeListener 108 | * returns true, otherwise set the seekBar's progress to the stored value 109 | */ 110 | void syncProgress(SeekBar seekBar) { 111 | int progress = seekBar.getProgress(); 112 | if (progress != mProgress) { 113 | if (callChangeListener(progress)) { 114 | setProgress(progress, false); 115 | } else { 116 | seekBar.setProgress(mProgress); 117 | } 118 | } 119 | } 120 | 121 | @Override 122 | public void onProgressChanged( 123 | SeekBar seekBar, int progress, boolean fromUser) { 124 | if (fromUser && !mTrackingTouch) { 125 | syncProgress(seekBar); 126 | } 127 | } 128 | 129 | @Override 130 | public void onStartTrackingTouch(SeekBar seekBar) { 131 | mTrackingTouch = true; 132 | } 133 | 134 | @Override 135 | public void onStopTrackingTouch(SeekBar seekBar) { 136 | mTrackingTouch = false; 137 | if (seekBar.getProgress() != mProgress) { 138 | syncProgress(seekBar); 139 | } 140 | } 141 | 142 | @Override 143 | protected Parcelable onSaveInstanceState() { 144 | /* 145 | * Suppose a client uses this preference type without persisting. We 146 | * must save the instance state so it is able to, for example, survive 147 | * orientation changes. 148 | */ 149 | 150 | final Parcelable superState = super.onSaveInstanceState(); 151 | if (isPersistent()) { 152 | // No need to save instance state since it's persistent 153 | return superState; 154 | } 155 | 156 | // Save the instance state 157 | final SavedState myState = new SavedState(superState); 158 | myState.progress = mProgress; 159 | myState.max = mMax; 160 | return myState; 161 | } 162 | 163 | @Override 164 | protected void onRestoreInstanceState(Parcelable state) { 165 | if (!state.getClass().equals(SavedState.class)) { 166 | // Didn't save state for us in onSaveInstanceState 167 | super.onRestoreInstanceState(state); 168 | return; 169 | } 170 | 171 | // Restore the instance state 172 | SavedState myState = (SavedState) state; 173 | super.onRestoreInstanceState(myState.getSuperState()); 174 | mProgress = myState.progress; 175 | mMax = myState.max; 176 | notifyChanged(); 177 | } 178 | 179 | /** 180 | * SavedState, a subclass of {@link BaseSavedState}, will store the state 181 | * of MyPreference, a subclass of Preference. 182 | *

183 | * It is important to always call through to super methods. 184 | */ 185 | private static class SavedState extends BaseSavedState { 186 | int progress; 187 | int max; 188 | 189 | public SavedState(Parcel source) { 190 | super(source); 191 | 192 | // Restore the click counter 193 | progress = source.readInt(); 194 | max = source.readInt(); 195 | } 196 | 197 | @Override 198 | public void writeToParcel(Parcel dest, int flags) { 199 | super.writeToParcel(dest, flags); 200 | 201 | // Save the click counter 202 | dest.writeInt(progress); 203 | dest.writeInt(max); 204 | } 205 | 206 | public SavedState(Parcelable superState) { 207 | super(superState); 208 | } 209 | 210 | @SuppressWarnings("unused") 211 | public static final Parcelable.Creator CREATOR = 212 | new Parcelable.Creator() { 213 | public SavedState createFromParcel(Parcel in) { 214 | return new SavedState(in); 215 | } 216 | 217 | public SavedState[] newArray(int size) { 218 | return new SavedState[size]; 219 | } 220 | }; 221 | } 222 | } -------------------------------------------------------------------------------- /app/src/main/res/drawable-xhdpi/ic_action_clear.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Manabu-GT/DesignOverlay-Android/43e7171395b2ca48d03120bc56a7e32206512bea/app/src/main/res/drawable-xhdpi/ic_action_clear.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-xhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Manabu-GT/DesignOverlay-Android/43e7171395b2ca48d03120bc56a7e32206512bea/app/src/main/res/drawable-xhdpi/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-xhdpi/ic_notification.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Manabu-GT/DesignOverlay-Android/43e7171395b2ca48d03120bc56a7e32206512bea/app/src/main/res/drawable-xhdpi/ic_notification.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-xxhdpi/ic_action_clear.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Manabu-GT/DesignOverlay-Android/43e7171395b2ca48d03120bc56a7e32206512bea/app/src/main/res/drawable-xxhdpi/ic_action_clear.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-xxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Manabu-GT/DesignOverlay-Android/43e7171395b2ca48d03120bc56a7e32206512bea/app/src/main/res/drawable-xxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-xxhdpi/ic_notification.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Manabu-GT/DesignOverlay-Android/43e7171395b2ca48d03120bc56a7e32206512bea/app/src/main/res/drawable-xxhdpi/ic_notification.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-xxxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Manabu-GT/DesignOverlay-Android/43e7171395b2ca48d03120bc56a7e32206512bea/app/src/main/res/drawable-xxxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-xxxhdpi/ic_notification.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Manabu-GT/DesignOverlay-Android/43e7171395b2ca48d03120bc56a7e32206512bea/app/src/main/res/drawable-xxxhdpi/ic_notification.png -------------------------------------------------------------------------------- /app/src/main/res/layout/activity_settings.xml: -------------------------------------------------------------------------------- 1 | 2 | 8 | 9 | 15 | 26 | 33 | 40 | 41 | 42 | 47 | -------------------------------------------------------------------------------- /app/src/main/res/layout/pref_layout_seekbar.xml: -------------------------------------------------------------------------------- 1 | 15 | 16 | 17 | 24 | 25 | 31 | 32 | 38 | 39 | 40 | 50 | 51 | 60 | 61 | 71 | 72 | 73 | 83 | 84 | 93 | 94 | 95 | 96 | -------------------------------------------------------------------------------- /app/src/main/res/layout/pref_widget_layout_image.xml: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /app/src/main/res/layout/service_design_overlay.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 10 | 14 | -------------------------------------------------------------------------------- /app/src/main/res/values-ja/strings.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | DesignOverlay 5 | 6 | DesignOverlay 7 | タップするとアプリの設定画面に遷移します 8 | タップするとアプリの設定画面に遷移します 9 | 終了 10 | 11 | デザイン 12 | グリッド線 13 | このアプリについて 14 | 15 | 全画面表示 16 | 17 | 表示 18 | 画像 19 | オーバーレイ表示する画像を選択 20 | 透明度 21 | 透明度: %1$s % 22 | 23 | 表示 24 | サイズ 25 | サイズ: %1$s dp 26 | 27 | 右に揃える 28 | 下に揃える 29 | 30 | 31 | グリッド線の色を選択 32 | 33 | 作者 34 | Manabu 35 | 36 | バージョン 37 | 38 | オーバーレイ表示する画像を選択してください 39 | 40 | エラー!画像が取得できませんでした。 41 | このアプリはデザイン画像やグリッド線をAndroidのシステムレイヤ上にオーバーレイ表示することで、開発者がデザインイメージにアプリのレイアウトを合わせる作業を助けてくれます 42 | -------------------------------------------------------------------------------- /app/src/main/res/values-land/dimens.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 72dp 4 | -------------------------------------------------------------------------------- /app/src/main/res/values-large/dimens.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 56dp 5 | -------------------------------------------------------------------------------- /app/src/main/res/values-sw720dp/dimens.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 6 | 56dp 7 | -------------------------------------------------------------------------------- /app/src/main/res/values-w820dp/dimens.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 64dp 6 | 7 | -------------------------------------------------------------------------------- /app/src/main/res/values/arrays.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 4dp 5 | 8dp 6 | 16dp 7 | 32dp 8 | 9 | 10 | 4 11 | 8 12 | 16 13 | 32 14 | 15 | -------------------------------------------------------------------------------- /app/src/main/res/values/attrs.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | -------------------------------------------------------------------------------- /app/src/main/res/values/colors.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | #2c363f 5 | #000000 6 | 7 | #7732cd32 8 | -------------------------------------------------------------------------------- /app/src/main/res/values/dimens.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 6 | 0dp 7 | 8 | 48dp 9 | -------------------------------------------------------------------------------- /app/src/main/res/values/strings.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | DesignOverlay 5 | DesignOverlay will show design and grid overlay over application windows to help you verify your application layout and design. 6 | 7 | DesignOverlay 8 | Touch for Settings 9 | Touch for Settings 10 | Dismiss 11 | 12 | Design 13 | Grid 14 | About 15 | 16 | FullScreen 17 | 18 | Enabled 19 | Image 20 | Choose a design image to overlay 21 | Alpha 22 | Alpha: %1$s % 23 | 24 | Enabled 25 | Size 26 | Size: %1$s dp 27 | Align right 28 | Align bottom 29 | Color 30 | Choose grid line color 31 | 32 | Author 33 | Manabu 34 | 35 | Version 36 | 37 | Choose an image to overlay 38 | 39 | Error! Could not retrieve image. 40 | -------------------------------------------------------------------------------- /app/src/main/res/values/styles.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 13 | 14 | -------------------------------------------------------------------------------- /app/src/main/res/values/template-dimens.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 6 | 7 | 8 | 16dp 9 | 16dp 10 | 11 | 12 | 24dp 13 | 14 | 15 | 8dp 16 | 20sp 17 | 18 | 22 | 304dp 23 | 24 | 25 | 56dp 26 | 8dp 27 | 9dp 28 | 29 | 30 | 12sp 31 | 14sp 32 | 16sp 33 | 20sp 34 | 34sp 35 | 36 | 37 | 38 | 39 | 48dp 40 | 56dp 41 | 16dp 42 | 8dp 43 | 72dp 44 | 45 | 46 | 24dp 47 | 16dp 48 | 49 | 50 | 2dp 51 | 8dp 52 | 8dp 53 | 16dp 54 | 6dp 55 | 2dp 56 | 57 | 58 | 1dp 59 | 60 | 61 | 4dp 62 | 4dp 63 | 8dp 64 | 8dp 65 | 16dp 66 | 16dp 67 | 24dp 68 | 24dp 69 | 70 | 4dp 71 | 4dp 72 | 8dp 73 | 8dp 74 | 16dp 75 | 16dp 76 | 24dp 77 | 24dp 78 | 79 | 6dp 80 | 81 | -------------------------------------------------------------------------------- /app/src/main/res/xml/preferences.xml: -------------------------------------------------------------------------------- 1 | 2 | 6 | 7 | 11 | 16 | 20 | 21 | 22 | 26 | 32 | 36 | 40 | 46 | 47 | 48 | 51 | 53 | 54 | 59 | 60 | -------------------------------------------------------------------------------- /appium/README.md: -------------------------------------------------------------------------------- 1 | # DesignOverlay UI Test 2 | 3 | ## Set up 4 | 5 | Install sauce labs client library: 6 | 7 | ```shell 8 | pip install sauceclient 9 | ``` 10 | 11 | Install appium client library: 12 | 13 | ```shell 14 | pip install Appium-Python-Client 15 | pip install pytest 16 | ``` 17 | 18 | ## how to run (SauceLabs) 19 | For configuration, look at the config_sauce_labs.json. 20 | 21 | ```shell 22 | ./gradlew sauceLabsDebug 23 | ``` -------------------------------------------------------------------------------- /appium/android_sauce_labs.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | # -*- coding: utf-8 -*- 3 | 4 | """ 5 | 6 | Author : Manabu Shimobe 7 | 8 | """ 9 | __author__ = "Manabu Shimobe" 10 | 11 | from appium import webdriver 12 | from appium import SauceTestCase, on_platforms 13 | 14 | from time import sleep 15 | from logging import getLogger, StreamHandler, Formatter, DEBUG 16 | from os import environ 17 | import json 18 | 19 | # load default platform configurations 20 | json_file = open('appium/config_sauce_labs.json') 21 | platforms = json.load(json_file) 22 | for platform in platforms: 23 | platform['app'] = "sauce-storage:%s" % environ.get('SAUCE_APK_FILE') 24 | platform['customData'] = {'commit': environ.get('TRAVIS_COMMIT', environ.get('SAUCE_COMMIT')), 25 | 'versionName': environ.get('SAUCE_APK_VERSION_NAME'), 26 | 'versionCode': environ.get('SAUCE_APK_VERSION_CODE')} 27 | platform['build'] = "build-%s" % environ.get('TRAVIS_BUILD_NUMBER', 'local') 28 | json_file.close() 29 | 30 | # set up logger 31 | logger = getLogger(__name__) 32 | logger.setLevel(DEBUG) 33 | handler = StreamHandler() 34 | handler.setFormatter(Formatter('%(asctime)s- %(name)s - %(levelname)s - %(message)s')) 35 | handler.setLevel(DEBUG) 36 | logger.addHandler(handler) 37 | 38 | # the emulator is sometimes slow 39 | SLEEP_TIME = 1 40 | 41 | @on_platforms(platforms) 42 | class SimpleAndroidSauceTests(SauceTestCase): 43 | 44 | def test_settings(self): 45 | sleep(SLEEP_TIME) 46 | 47 | # Check if successfully started SettingsActivity 48 | self.assertEqual('.activity.SettingsActivity_', self.driver.current_activity) 49 | 50 | el_switch = self.driver.find_element_by_accessibility_id('Grid Switch') 51 | self.assertIsNotNone(el_switch) 52 | 53 | # Grid should be shown now 54 | el_switch.click() 55 | logger.info('Clicked Grid Switch') 56 | 57 | sleep(SLEEP_TIME) -------------------------------------------------------------------------------- /appium/config_sauce_labs.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "platformName":"Android", 4 | "platformVersion":"4.2", 5 | "deviceName":"Android Emulator", 6 | "appPackage":"com.ms_square.android.design.overlay", 7 | "appActivity":".activity.SettingsActivity_", 8 | "appiumVersion":"1.3.6" 9 | }, 10 | { 11 | "platformName":"Android", 12 | "platformVersion":"4.3", 13 | "deviceName":"Android Emulator", 14 | "appPackage":"com.ms_square.android.design.overlay", 15 | "appActivity":".activity.SettingsActivity_", 16 | "appiumVersion":"1.3.6" 17 | }, 18 | { 19 | "platformName":"Android", 20 | "platformVersion":"4.4", 21 | "deviceName":"Android Emulator", 22 | "appPackage":"com.ms_square.android.design.overlay", 23 | "appActivity":".activity.SettingsActivity_", 24 | "appiumVersion":"1.3.6" 25 | }, 26 | { 27 | "platformName":"Android", 28 | "platformVersion":"5.0", 29 | "deviceName":"Android Emulator", 30 | "appPackage":"com.ms_square.android.design.overlay", 31 | "appActivity":".activity.SettingsActivity_", 32 | "appiumVersion":"1.3.6" 33 | } 34 | ] -------------------------------------------------------------------------------- /art/app_screenshot.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Manabu-GT/DesignOverlay-Android/43e7171395b2ca48d03120bc56a7e32206512bea/art/app_screenshot.png -------------------------------------------------------------------------------- /art/screenshot_1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Manabu-GT/DesignOverlay-Android/43e7171395b2ca48d03120bc56a7e32206512bea/art/screenshot_1.png -------------------------------------------------------------------------------- /art/screenshot_2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Manabu-GT/DesignOverlay-Android/43e7171395b2ca48d03120bc56a7e32206512bea/art/screenshot_2.png -------------------------------------------------------------------------------- /build.gradle: -------------------------------------------------------------------------------- 1 | // Top-level build file where you can add configuration options common to all sub-projects/modules. 2 | 3 | buildscript { 4 | repositories { 5 | jcenter() 6 | } 7 | dependencies { 8 | classpath 'com.android.tools.build:gradle:1.1.0' 9 | 10 | // NOTE: Do not place your application dependencies here; they belong 11 | // in the individual module build.gradle files 12 | classpath 'com.neenbedankt.gradle.plugins:android-apt:1.4+' 13 | 14 | classpath 'com.ms-square:saucelabs-gradle-plugin:1.0.0' 15 | } 16 | } 17 | 18 | allprojects { 19 | repositories { 20 | jcenter() 21 | } 22 | } 23 | 24 | // http://www.gradle.org/docs/current/dsl/org.gradle.api.plugins.ExtraPropertiesExtension.html 25 | project.ext { 26 | ANDROID_BUILD_SDK_VERSION = 22 27 | ANDROID_BUILD_TOOLS_VERSION = "22.0.1" 28 | 29 | ANDROID_BUILD_MIN_SDK_VERSION = 14 30 | ANDROID_BUILD_TARGET_SDK_VERSION = 22 31 | 32 | // Google Stuffs 33 | supportPackageVersion = "22.0.0" 34 | 35 | // APT plugin and Android Annotations 36 | daggerVersion = "1.2.1" 37 | androidAnnotationsVersion = "3.2" 38 | 39 | // EventBus 40 | eventBusVersion = "2.4.0" 41 | 42 | // Timber 43 | timberVersion = "2.5.1" 44 | 45 | androidUtilVersion = "0.1.1" 46 | 47 | // http://tools.android.com/tech-docs/new-build-system/tips 48 | preDexLibs = !project.hasProperty('disablePreDex') 49 | } 50 | 51 | task wrapper(type: Wrapper) { 52 | gradleVersion = '2.21' 53 | } -------------------------------------------------------------------------------- /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/Manabu-GT/DesignOverlay-Android/43e7171395b2ca48d03120bc56a7e32206512bea/gradle/wrapper/gradle-wrapper.jar -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.properties: -------------------------------------------------------------------------------- 1 | #Wed Apr 10 15:27:10 PDT 2013 2 | distributionBase=GRADLE_USER_HOME 3 | distributionPath=wrapper/dists 4 | zipStoreBase=GRADLE_USER_HOME 5 | zipStorePath=wrapper/dists 6 | distributionUrl=https\://services.gradle.org/distributions/gradle-2.2.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 | -------------------------------------------------------------------------------- /requirements.txt: -------------------------------------------------------------------------------- 1 | # requirements.txt for pip install 2 | sauceclient 3 | Appium-Python-Client 4 | pytest -------------------------------------------------------------------------------- /settings.gradle: -------------------------------------------------------------------------------- 1 | include ':app', ':ColorPickerPreference' 2 | project(':ColorPickerPreference').projectDir = new File('app/libs/android-ColorPickerPreference/ColorPickerPreference') --------------------------------------------------------------------------------