├── .gitignore ├── .idea ├── compiler.xml ├── copyright │ └── profiles_settings.xml ├── gradle.xml ├── kotlinc.xml ├── libraries │ ├── animated_vector_drawable_25_2_0.xml │ ├── appcompat_v7_25_2_0.xml │ ├── library_1_4_0.xml │ ├── multidex_1_0_1.xml │ ├── multidex_instrumentation_1_0_1.xml │ ├── rxandroid_1_2_1.xml │ ├── rxjava_1_1_6.xml │ ├── support_annotations_25_2_0.xml │ ├── support_compat_25_2_0.xml │ ├── support_core_ui_25_2_0.xml │ ├── support_core_utils_25_2_0.xml │ ├── support_fragment_25_2_0.xml │ ├── support_media_compat_25_2_0.xml │ ├── support_v4_25_2_0.xml │ └── support_vector_drawable_25_2_0.xml ├── misc.xml ├── modules.xml ├── runConfigurations.xml ├── vcs.xml └── workspace.xml ├── Android-LockScreenSample-DisableHomeButtonKey.iml ├── LICENSE ├── LockScreenSample.iml ├── README.md ├── app ├── .gitignore ├── app.iml ├── build.gradle ├── proguard-rules.pro └── src │ ├── androidTest │ └── java │ │ └── com │ │ └── github │ │ └── dubu │ │ └── lockscreensample │ │ └── ApplicationTest.java │ └── main │ ├── AndroidManifest.xml │ ├── java │ └── com │ │ └── github │ │ └── mugku │ │ └── lockscreensample │ │ └── MainActivity.java │ └── res │ ├── layout │ └── activity_main.xml │ ├── menu │ └── menu_main.xml │ ├── mipmap-hdpi │ └── ic_launcher.png │ ├── mipmap-mdpi │ └── ic_launcher.png │ ├── mipmap-xhdpi │ └── ic_launcher.png │ ├── mipmap-xxhdpi │ └── ic_launcher.png │ ├── values-w820dp │ └── dimens.xml │ └── values │ ├── color.xml │ ├── dimens.xml │ ├── strings.xml │ └── styles.xml ├── build.gradle ├── dependecies-variable.gradle ├── downloadapk └── LockscreenSample.apk ├── gradle.properties ├── gradle └── wrapper │ ├── gradle-wrapper.jar │ └── gradle-wrapper.properties ├── gradlew ├── gradlew.bat ├── lockscreenusingservice ├── .gitignore ├── build.gradle ├── lockscreenusingservice.iml ├── proguard-rules.pro └── src │ ├── androidTest │ └── java │ │ └── com │ │ └── github │ │ └── dubu │ │ └── lockscreenusingservice │ │ └── ApplicationTest.java │ └── main │ ├── AndroidManifest.xml │ ├── java │ └── com │ │ └── github │ │ └── dubu │ │ └── lockscreenusingservice │ │ ├── LockScreenView.java │ │ ├── Lockscreen.java │ │ ├── LockscreenActivity.java │ │ ├── LockscreenUtil.java │ │ ├── PermissionActivity.java │ │ ├── RemoveViewUtil.java │ │ ├── SharedPreferencesUtil.java │ │ └── service │ │ ├── LockscreenService.java │ │ └── LockscreenViewService.java │ └── res │ ├── drawable │ ├── images.jpeg │ ├── lock.png │ └── unlock.png │ ├── layout │ ├── activity_lockscreen.xml │ └── view_locokscreen.xml │ ├── menu │ └── menu_main.xml │ ├── values-w820dp │ ├── color.xml │ └── dimens.xml │ └── values │ ├── color.xml │ ├── dimens.xml │ └── strings.xml ├── rawimg ├── softkey_lock_lg.gif ├── softkey_unlock_lg.gif ├── softkey_unlock_nexus5.gif ├── unsoftkey_lock_samsung.gif └── unsoftkey_unlock_samsung.gif └── settings.gradle /.gitignore: -------------------------------------------------------------------------------- 1 | # Built application files 2 | #*.apk 3 | *.ap_ 4 | 5 | # Files for the Dalvik VM 6 | *.dex 7 | 8 | # Java class files 9 | *.class 10 | 11 | # Generated files 12 | bin/ 13 | gen/ 14 | 15 | # Gradle files 16 | .gradle/ 17 | build/ 18 | /*/build/ 19 | 20 | # Local configuration file (sdk path, etc) 21 | local.properties 22 | 23 | # Proguard folder generated by Eclipse 24 | proguard/ 25 | 26 | # Log Files 27 | *.log 28 | -------------------------------------------------------------------------------- /.idea/compiler.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | -------------------------------------------------------------------------------- /.idea/copyright/profiles_settings.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | -------------------------------------------------------------------------------- /.idea/gradle.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 19 | 20 | -------------------------------------------------------------------------------- /.idea/kotlinc.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 7 | -------------------------------------------------------------------------------- /.idea/libraries/animated_vector_drawable_25_2_0.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /.idea/libraries/appcompat_v7_25_2_0.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /.idea/libraries/library_1_4_0.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /.idea/libraries/multidex_1_0_1.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | -------------------------------------------------------------------------------- /.idea/libraries/multidex_instrumentation_1_0_1.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | -------------------------------------------------------------------------------- /.idea/libraries/rxandroid_1_2_1.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /.idea/libraries/rxjava_1_1_6.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /.idea/libraries/support_annotations_25_2_0.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /.idea/libraries/support_compat_25_2_0.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /.idea/libraries/support_core_ui_25_2_0.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /.idea/libraries/support_core_utils_25_2_0.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /.idea/libraries/support_fragment_25_2_0.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /.idea/libraries/support_media_compat_25_2_0.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /.idea/libraries/support_v4_25_2_0.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | -------------------------------------------------------------------------------- /.idea/libraries/support_vector_drawable_25_2_0.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /.idea/misc.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 19 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 46 | -------------------------------------------------------------------------------- /.idea/modules.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | -------------------------------------------------------------------------------- /.idea/runConfigurations.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 11 | 12 | -------------------------------------------------------------------------------- /.idea/vcs.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /Android-LockScreenSample-DisableHomeButtonKey.iml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 9 | 10 | 11 | 12 | 13 | 14 | 20 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Apache License 2 | Version 2.0, January 2004 3 | http://www.apache.org/licenses/ 4 | 5 | TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 6 | 7 | 1. Definitions. 8 | 9 | "License" shall mean the terms and conditions for use, reproduction, 10 | and distribution as defined by Sections 1 through 9 of this document. 11 | 12 | "Licensor" shall mean the copyright owner or entity authorized by 13 | the copyright owner that is granting the License. 14 | 15 | "Legal Entity" shall mean the union of the acting entity and all 16 | other entities that control, are controlled by, or are under common 17 | control with that entity. For the purposes of this definition, 18 | "control" means (i) the power, direct or indirect, to cause the 19 | direction or management of such entity, whether by contract or 20 | otherwise, or (ii) ownership of fifty percent (50%) or more of the 21 | outstanding shares, or (iii) beneficial ownership of such entity. 22 | 23 | "You" (or "Your") shall mean an individual or Legal Entity 24 | exercising permissions granted by this License. 25 | 26 | "Source" form shall mean the preferred form for making modifications, 27 | including but not limited to software source code, documentation 28 | source, and configuration files. 29 | 30 | "Object" form shall mean any form resulting from mechanical 31 | transformation or translation of a Source form, including but 32 | not limited to compiled object code, generated documentation, 33 | and conversions to other media types. 34 | 35 | "Work" shall mean the work of authorship, whether in Source or 36 | Object form, made available under the License, as indicated by a 37 | copyright notice that is included in or attached to the work 38 | (an example is provided in the Appendix below). 39 | 40 | "Derivative Works" shall mean any work, whether in Source or Object 41 | form, that is based on (or derived from) the Work and for which the 42 | editorial revisions, annotations, elaborations, or other modifications 43 | represent, as a whole, an original work of authorship. For the purposes 44 | of this License, Derivative Works shall not include works that remain 45 | separable from, or merely link (or bind by name) to the interfaces of, 46 | the Work and Derivative Works thereof. 47 | 48 | "Contribution" shall mean any work of authorship, including 49 | the original version of the Work and any modifications or additions 50 | to that Work or Derivative Works thereof, that is intentionally 51 | submitted to Licensor for inclusion in the Work by the copyright owner 52 | or by an individual or Legal Entity authorized to submit on behalf of 53 | the copyright owner. For the purposes of this definition, "submitted" 54 | means any form of electronic, verbal, or written communication sent 55 | to the Licensor or its representatives, including but not limited to 56 | communication on electronic mailing lists, source code control systems, 57 | and issue tracking systems that are managed by, or on behalf of, the 58 | Licensor for the purpose of discussing and improving the Work, but 59 | excluding communication that is conspicuously marked or otherwise 60 | designated in writing by the copyright owner as "Not a Contribution." 61 | 62 | "Contributor" shall mean Licensor and any individual or Legal Entity 63 | on behalf of whom a Contribution has been received by Licensor and 64 | subsequently incorporated within the Work. 65 | 66 | 2. Grant of Copyright License. Subject to the terms and conditions of 67 | this License, each Contributor hereby grants to You a perpetual, 68 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 69 | copyright license to reproduce, prepare Derivative Works of, 70 | publicly display, publicly perform, sublicense, and distribute the 71 | Work and such Derivative Works in Source or Object form. 72 | 73 | 3. Grant of Patent License. Subject to the terms and conditions of 74 | this License, each Contributor hereby grants to You a perpetual, 75 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 76 | (except as stated in this section) patent license to make, have made, 77 | use, offer to sell, sell, import, and otherwise transfer the Work, 78 | where such license applies only to those patent claims licensable 79 | by such Contributor that are necessarily infringed by their 80 | Contribution(s) alone or by combination of their Contribution(s) 81 | with the Work to which such Contribution(s) was submitted. If You 82 | institute patent litigation against any entity (including a 83 | cross-claim or counterclaim in a lawsuit) alleging that the Work 84 | or a Contribution incorporated within the Work constitutes direct 85 | or contributory patent infringement, then any patent licenses 86 | granted to You under this License for that Work shall terminate 87 | as of the date such litigation is filed. 88 | 89 | 4. Redistribution. You may reproduce and distribute copies of the 90 | Work or Derivative Works thereof in any medium, with or without 91 | modifications, and in Source or Object form, provided that You 92 | meet the following conditions: 93 | 94 | (a) You must give any other recipients of the Work or 95 | Derivative Works a copy of this License; and 96 | 97 | (b) You must cause any modified files to carry prominent notices 98 | stating that You changed the files; and 99 | 100 | (c) You must retain, in the Source form of any Derivative Works 101 | that You distribute, all copyright, patent, trademark, and 102 | attribution notices from the Source form of the Work, 103 | excluding those notices that do not pertain to any part of 104 | the Derivative Works; and 105 | 106 | (d) If the Work includes a "NOTICE" text file as part of its 107 | distribution, then any Derivative Works that You distribute must 108 | include a readable copy of the attribution notices contained 109 | within such NOTICE file, excluding those notices that do not 110 | pertain to any part of the Derivative Works, in at least one 111 | of the following places: within a NOTICE text file distributed 112 | as part of the Derivative Works; within the Source form or 113 | documentation, if provided along with the Derivative Works; or, 114 | within a display generated by the Derivative Works, if and 115 | wherever such third-party notices normally appear. The contents 116 | of the NOTICE file are for informational purposes only and 117 | do not modify the License. You may add Your own attribution 118 | notices within Derivative Works that You distribute, alongside 119 | or as an addendum to the NOTICE text from the Work, provided 120 | that such additional attribution notices cannot be construed 121 | as modifying the License. 122 | 123 | You may add Your own copyright statement to Your modifications and 124 | may provide additional or different license terms and conditions 125 | for use, reproduction, or distribution of Your modifications, or 126 | for any such Derivative Works as a whole, provided Your use, 127 | reproduction, and distribution of the Work otherwise complies with 128 | the conditions stated in this License. 129 | 130 | 5. Submission of Contributions. Unless You explicitly state otherwise, 131 | any Contribution intentionally submitted for inclusion in the Work 132 | by You to the Licensor shall be under the terms and conditions of 133 | this License, without any additional terms or conditions. 134 | Notwithstanding the above, nothing herein shall supersede or modify 135 | the terms of any separate license agreement you may have executed 136 | with Licensor regarding such Contributions. 137 | 138 | 6. Trademarks. This License does not grant permission to use the trade 139 | names, trademarks, service marks, or product names of the Licensor, 140 | except as required for reasonable and customary use in describing the 141 | origin of the Work and reproducing the content of the NOTICE file. 142 | 143 | 7. Disclaimer of Warranty. Unless required by applicable law or 144 | agreed to in writing, Licensor provides the Work (and each 145 | Contributor provides its Contributions) on an "AS IS" BASIS, 146 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 147 | implied, including, without limitation, any warranties or conditions 148 | of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A 149 | PARTICULAR PURPOSE. You are solely responsible for determining the 150 | appropriateness of using or redistributing the Work and assume any 151 | risks associated with Your exercise of permissions under this License. 152 | 153 | 8. Limitation of Liability. In no event and under no legal theory, 154 | whether in tort (including negligence), contract, or otherwise, 155 | unless required by applicable law (such as deliberate and grossly 156 | negligent acts) or agreed to in writing, shall any Contributor be 157 | liable to You for damages, including any direct, indirect, special, 158 | incidental, or consequential damages of any character arising as a 159 | result of this License or out of the use or inability to use the 160 | Work (including but not limited to damages for loss of goodwill, 161 | work stoppage, computer failure or malfunction, or any and all 162 | other commercial damages or losses), even if such Contributor 163 | has been advised of the possibility of such damages. 164 | 165 | 9. Accepting Warranty or Additional Liability. While redistributing 166 | the Work or Derivative Works thereof, You may choose to offer, 167 | and charge a fee for, acceptance of support, warranty, indemnity, 168 | or other liability obligations and/or rights consistent with this 169 | License. However, in accepting such obligations, You may act only 170 | on Your own behalf and on Your sole responsibility, not on behalf 171 | of any other Contributor, and only if You agree to indemnify, 172 | defend, and hold each Contributor harmless for any liability 173 | incurred by, or claims asserted against, such Contributor by reason 174 | of your accepting any such warranty or additional liability. 175 | 176 | END OF TERMS AND CONDITIONS 177 | 178 | APPENDIX: How to apply the Apache License to your work. 179 | 180 | To apply the Apache License to your work, attach the following 181 | boilerplate notice, with the fields enclosed by brackets "{}" 182 | replaced with your own identifying information. (Don't include 183 | the brackets!) The text should be enclosed in the appropriate 184 | comment syntax for the file format. We also recommend that a 185 | file or class name and description of purpose be included on the 186 | same "printed page" as the copyright notice for easier 187 | identification within third-party archives. 188 | 189 | Copyright {yyyy} {name of copyright owner} 190 | 191 | Licensed under the Apache License, Version 2.0 (the "License"); 192 | you may not use this file except in compliance with the License. 193 | You may obtain a copy of the License at 194 | 195 | http://www.apache.org/licenses/LICENSE-2.0 196 | 197 | Unless required by applicable law or agreed to in writing, software 198 | distributed under the License is distributed on an "AS IS" BASIS, 199 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 200 | See the License for the specific language governing permissions and 201 | limitations under the License. 202 | -------------------------------------------------------------------------------- /LockScreenSample.iml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # LockScreenSample-Disable HomeButton or HomeKey Event 2 | Android LockScreenSample Using Service - Disable HomeButton Key Event 3 | LockScreenSample use Android Service. So, Ignores HomeButton Key Event. 4 | 5 | Download 6 | -------- 7 | 8 | Current version: [1.0.2] 9 | 10 | Gradle: 11 | ```groovy 12 | compile 'com.github.dubulee:lockscreendiablehomebuttonkey:1.0.2' 13 | ``` 14 | 15 | As there are a lot questions about "how to disable home button in android?" on `Stack Overflow`, such as 16 | 17 | * [how to disable home button in android?](http://stackoverflow.com/questions/17183905/how-to-disable-home-button-in-android) 18 | * [Android - Is It possible to disable the click of home button](http://stackoverflow.com/questions/2162182/android-is-it-possible-to-disable-the-click-of-home-button) 19 | * [How to disable Home and other system buttons in Android?](http://stackoverflow.com/questions/17549478/how-to-disable-home-and-other-system-buttons-in-android) 20 | 21 | 22 | This Sample support UnSoft Home Key(UnVirtual Home Key) like Samsung Galaxy 23 | And Soft Home Key(Virtual Home Key) like LG G, Google Nexus. 24 | 25 | This Sample is similar to Microsoft corp. - Next Lock Screen, KaKao corp. - KaKaoTalk Notification Cover 26 | 27 | Test Samsung Galaxy,LG G, Nexus5 28 | 29 | ###UnSoftKey - Test Samsung 30 | 31 | ![ScreenShot](rawimg/unsoftkey_unlock_samsung.gif)![ScreenShot](rawimg/unsoftkey_lock_samsung.gif) 32 | 33 | ###SoftKey - Test LG G, Nexus5 34 | 35 | ![ScreenShot](rawimg/softkey_unlock_lg.gif)![ScreenShot](rawimg/softkey_lock_lg.gif) ![ScreenShot](rawimg/softkey_unlock_nexus5.gif) 36 | 37 | 38 | 39 | 40 | ## How to use 41 | 42 | Test Start 43 | ```java 44 | Lockscreen.getInstance(ContextInstance).startLockscreenService(); 45 | ``` 46 | 47 | Test Stop 48 | ```java 49 | Lockscreen.getInstance(ContextInstance).stopLockscreenService(); 50 | ``` 51 | 52 | -------------------------------------------------------------------------------- /app/.gitignore: -------------------------------------------------------------------------------- 1 | /build 2 | -------------------------------------------------------------------------------- /app/app.iml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 8 | 9 | 10 | 11 | 23 | 24 | 25 | 26 | 27 | 28 | 34 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | 101 | 102 | 103 | 104 | 105 | 106 | 107 | 108 | 109 | 110 | 111 | 112 | 113 | 114 | 115 | 116 | 117 | 118 | 119 | 120 | 121 | 122 | 123 | 124 | 125 | 126 | 127 | 128 | 129 | 130 | 131 | 132 | 133 | 134 | 135 | 136 | 137 | 138 | 139 | 140 | 141 | 142 | 143 | 144 | 145 | -------------------------------------------------------------------------------- /app/build.gradle: -------------------------------------------------------------------------------- 1 | apply plugin: 'com.android.application' 2 | apply plugin: 'kotlin-android' 3 | apply plugin: 'kotlin-android-extensions' 4 | 5 | 6 | android { 7 | compileSdkVersion 25 8 | buildToolsVersion "25.0.2" 9 | 10 | defaultConfig { 11 | applicationId "${base_application_name}.lockscreensample" 12 | minSdkVersion 16 13 | targetSdkVersion 23 14 | versionCode 3 15 | versionName "1.0.2" 16 | multiDexEnabled true 17 | } 18 | buildTypes { 19 | release { 20 | minifyEnabled false 21 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' 22 | } 23 | } 24 | 25 | sourceSets { 26 | main.java.srcDirs += 'src/main/kotlin' // src/main/kotlin 디렉터리를 소스 디렉터리에 추가합니다. 27 | test.java.srcDirs += 'src/test/kotlin' 28 | } 29 | } 30 | 31 | dependencies { 32 | compile fileTree(dir: 'libs', include: ['*.jar']) 33 | compile support_appcompat 34 | compile project(':lockscreenusingservice') 35 | } 36 | -------------------------------------------------------------------------------- /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/leejaegil/androidsdk/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/github/dubu/lockscreensample/ApplicationTest.java: -------------------------------------------------------------------------------- 1 | package com.github.dubu.lockscreensample; 2 | 3 | import android.app.Application; 4 | import android.test.ApplicationTestCase; 5 | 6 | /** 7 | * Testing Fundamentals 8 | */ 9 | public class ApplicationTest extends ApplicationTestCase { 10 | public ApplicationTest() { 11 | super(Application.class); 12 | } 13 | } -------------------------------------------------------------------------------- /app/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 10 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | -------------------------------------------------------------------------------- /app/src/main/java/com/github/mugku/lockscreensample/MainActivity.java: -------------------------------------------------------------------------------- 1 | package com.github.mugku.lockscreensample; 2 | 3 | import android.content.Context; 4 | import android.content.Intent; 5 | import android.net.Uri; 6 | import android.os.Bundle; 7 | import android.provider.Settings; 8 | import android.support.v7.app.ActionBarActivity; 9 | import android.support.v7.widget.SwitchCompat; 10 | import android.view.Menu; 11 | import android.view.MenuItem; 12 | import android.widget.CompoundButton; 13 | 14 | import com.github.dubu.lockscreensample.R; 15 | import com.github.dubu.lockscreenusingservice.Lockscreen; 16 | import com.github.dubu.lockscreenusingservice.SharedPreferencesUtil; 17 | 18 | import rx.functions.Action1; 19 | 20 | public class MainActivity extends ActionBarActivity { 21 | private SwitchCompat mSwitchd = null; 22 | private Context mContext = null; 23 | 24 | @Override 25 | protected void onCreate(Bundle savedInstanceState) { 26 | super.onCreate(savedInstanceState); 27 | mContext = this; 28 | setContentView(R.layout.activity_main); 29 | SharedPreferencesUtil.init(mContext); 30 | 31 | mSwitchd = (SwitchCompat) this.findViewById(R.id.switch_locksetting); 32 | mSwitchd.setTextOn("yes"); 33 | mSwitchd.setTextOff("no"); 34 | boolean lockState = SharedPreferencesUtil.get(Lockscreen.ISLOCK); 35 | if (lockState) { 36 | mSwitchd.setChecked(true); 37 | 38 | } else { 39 | mSwitchd.setChecked(false); 40 | 41 | } 42 | 43 | mSwitchd.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() { 44 | @Override 45 | public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) { 46 | if (isChecked) { 47 | SharedPreferencesUtil.setBoolean(Lockscreen.ISLOCK, true); 48 | Lockscreen.getInstance(mContext).startLockscreenService(); 49 | } else { 50 | SharedPreferencesUtil.setBoolean(Lockscreen.ISLOCK, false); 51 | Lockscreen.getInstance(mContext).stopLockscreenService(); 52 | } 53 | 54 | } 55 | }); 56 | } 57 | 58 | @Override 59 | protected void onResume() { 60 | super.onResume(); 61 | 62 | } 63 | 64 | @Override 65 | public boolean onCreateOptionsMenu(Menu menu) { 66 | // Inflate the menu; this adds items to the action bar if it is present. 67 | getMenuInflater().inflate(R.menu.menu_main, menu); 68 | return true; 69 | } 70 | 71 | @Override 72 | public boolean onOptionsItemSelected(MenuItem item) { 73 | // Handle action bar item clicks here. The action bar will 74 | // automatically handle clicks on the Home/Up button, so long 75 | // as you specify a parent activity in AndroidManifest.xml. 76 | int id = item.getItemId(); 77 | 78 | //noinspection SimplifiableIfStatement 79 | if (id == R.id.action_settings) { 80 | return true; 81 | } 82 | 83 | return super.onOptionsItemSelected(item); 84 | } 85 | } 86 | -------------------------------------------------------------------------------- /app/src/main/res/layout/activity_main.xml: -------------------------------------------------------------------------------- 1 | 7 | 8 | 10 | 11 | 19 | 20 | 21 | -------------------------------------------------------------------------------- /app/src/main/res/menu/menu_main.xml: -------------------------------------------------------------------------------- 1 | 4 | 6 | 7 | -------------------------------------------------------------------------------- /app/src/main/res/mipmap-hdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hmm-umm/Android-LockScreenSample-DisableHomeButtonKey/0453ae5bbee10099e88a24f1c13f475790d4cb2a/app/src/main/res/mipmap-hdpi/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-mdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hmm-umm/Android-LockScreenSample-DisableHomeButtonKey/0453ae5bbee10099e88a24f1c13f475790d4cb2a/app/src/main/res/mipmap-mdpi/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hmm-umm/Android-LockScreenSample-DisableHomeButtonKey/0453ae5bbee10099e88a24f1c13f475790d4cb2a/app/src/main/res/mipmap-xhdpi/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hmm-umm/Android-LockScreenSample-DisableHomeButtonKey/0453ae5bbee10099e88a24f1c13f475790d4cb2a/app/src/main/res/mipmap-xxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/res/values-w820dp/dimens.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 64dp 6 | 7 | -------------------------------------------------------------------------------- /app/src/main/res/values/color.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | #222222 4 | 5 | -------------------------------------------------------------------------------- /app/src/main/res/values/dimens.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 16dp 4 | 16dp 5 | 6 | -------------------------------------------------------------------------------- /app/src/main/res/values/strings.xml: -------------------------------------------------------------------------------- 1 | 2 | LockScreenSample 3 | 4 | Hello world! 5 | Settings 6 | 7 | -------------------------------------------------------------------------------- /app/src/main/res/values/styles.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /build.gradle: -------------------------------------------------------------------------------- 1 | // Top-level build file where you can add configuration options common to all sub-projects/modules. 2 | 3 | buildscript { 4 | apply from: "dependecies-variable.gradle" 5 | ext.kotlin_version = '1.1.2' 6 | 7 | repositories { 8 | jcenter() 9 | } 10 | dependencies { 11 | classpath 'com.android.tools.build:gradle:2.3.0' 12 | classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version" 13 | // NOTE: Do not place your application dependencies here; they belong 14 | // in the individual module build.gradle files 15 | } 16 | } 17 | 18 | allprojects { 19 | repositories { 20 | jcenter() 21 | } 22 | } 23 | 24 | task clean(type: Delete) { 25 | delete rootProject.buildDir 26 | } 27 | -------------------------------------------------------------------------------- /dependecies-variable.gradle: -------------------------------------------------------------------------------- 1 | ext { 2 | 3 | base_application_name = "com.github.dubu" 4 | 5 | compileSdkVersion = 25 6 | buildToolsVersion = "25.0.2" 7 | minSdkVersion = 16 8 | targetSdkVersion = 23 9 | supportLibraryVersion = '23.4.0' 10 | v4SupportLibraryVersion = supportLibraryVersion 11 | 12 | ver_android_support = "25.2.0" 13 | 14 | support_appcompat = "com.android.support:appcompat-v7:$ver_android_support" 15 | support_recyclerview = "com.android.support:recyclerview-v7:$ver_android_support" 16 | 17 | } -------------------------------------------------------------------------------- /downloadapk/LockscreenSample.apk: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hmm-umm/Android-LockScreenSample-DisableHomeButtonKey/0453ae5bbee10099e88a24f1c13f475790d4cb2a/downloadapk/LockscreenSample.apk -------------------------------------------------------------------------------- /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 19 | # 백그라운드 빌드 20 | org.gradle.daemon=true 21 | # 동시 빌드 22 | org.gradle.parallel=true 23 | # jvm heap size 24 | org.gradle.jvmargs=-Xmx4346m 25 | org.gradle.java.home=/Library/Java/JavaVirtualMachines/jdk1.8.0_121.jdk/Contents/Home 26 | -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hmm-umm/Android-LockScreenSample-DisableHomeButtonKey/0453ae5bbee10099e88a24f1c13f475790d4cb2a/gradle/wrapper/gradle-wrapper.jar -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.properties: -------------------------------------------------------------------------------- 1 | #Fri Apr 07 16:20:27 KST 2017 2 | distributionBase=GRADLE_USER_HOME 3 | distributionPath=wrapper/dists 4 | zipStoreBase=GRADLE_USER_HOME 5 | zipStorePath=wrapper/dists 6 | distributionUrl=https\://services.gradle.org/distributions/gradle-3.3-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 | -------------------------------------------------------------------------------- /lockscreenusingservice/.gitignore: -------------------------------------------------------------------------------- 1 | /build 2 | -------------------------------------------------------------------------------- /lockscreenusingservice/build.gradle: -------------------------------------------------------------------------------- 1 | buildscript { 2 | repositories { 3 | jcenter() 4 | } 5 | dependencies { 6 | classpath 'com.novoda:bintray-release:0.4.0' 7 | } 8 | } 9 | 10 | apply plugin: 'com.android.library' 11 | apply plugin: 'kotlin-android' 12 | apply plugin: 'kotlin-android-extensions' 13 | 14 | apply plugin: 'com.novoda.bintray-release' 15 | 16 | publish { 17 | userOrg = 'dubulee' 18 | groupId = 'com.github.dubulee' 19 | artifactId = 'lockscreendiablehomebuttonkey' 20 | publishVersion = '1.0.2' 21 | desc = 'Android LockScreenSample Using Service - Disable HomeButton Key Event LockScreenSample use Android Service. So, Ignores HomeButton Key Event.' 22 | website = 'https://github.com/mugku/Android-LockScreenSample-DisableHomeButtonKey' 23 | issueTracker = "${website}/issues" 24 | repository = "${website}.git" 25 | } 26 | 27 | 28 | 29 | android { 30 | compileSdkVersion 25 31 | buildToolsVersion "25.0.2" 32 | 33 | defaultConfig { 34 | minSdkVersion 16 35 | targetSdkVersion 23 36 | versionCode 3 37 | versionName "1.0.2" 38 | } 39 | buildTypes { 40 | release { 41 | minifyEnabled false 42 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' 43 | } 44 | } 45 | 46 | lintOptions { 47 | abortOnError false 48 | } 49 | 50 | sourceSets { 51 | main.java.srcDirs += 'src/main/kotlin' // src/main/kotlin 디렉터리를 소스 디렉터리에 추가합니다. 52 | test.java.srcDirs += 'src/test/kotlin' 53 | } 54 | } 55 | 56 | dependencies { 57 | compile fileTree(dir: 'libs', include: ['*.jar']) 58 | compile support_appcompat 59 | compile 'com.romainpiel.shimmer:library:1.4.0@aar' 60 | compile 'io.reactivex:rxandroid:1.2.1' 61 | compile 'io.reactivex:rxjava:1.1.6' 62 | // compile 'org.jetbrains.kotlin:kotlin-stdlib:1.1.2' 63 | } 64 | -------------------------------------------------------------------------------- /lockscreenusingservice/lockscreenusingservice.iml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 8 | 9 | 10 | 11 | 24 | 25 | 26 | 27 | 28 | 29 | 35 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | 101 | 102 | 103 | 104 | 105 | 106 | 107 | 108 | 109 | 110 | 111 | 112 | 113 | 114 | 115 | 116 | 117 | 118 | 119 | 120 | 121 | 122 | 123 | 124 | 125 | 126 | 127 | 128 | 129 | 130 | 131 | 132 | 133 | 134 | 135 | 136 | 137 | -------------------------------------------------------------------------------- /lockscreenusingservice/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/leejaegil/androidsdk/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 | -------------------------------------------------------------------------------- /lockscreenusingservice/src/androidTest/java/com/github/dubu/lockscreenusingservice/ApplicationTest.java: -------------------------------------------------------------------------------- 1 | package com.github.dubu.lockscreenusingservice; 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 | } -------------------------------------------------------------------------------- /lockscreenusingservice/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 17 | 19 | 20 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | -------------------------------------------------------------------------------- /lockscreenusingservice/src/main/java/com/github/dubu/lockscreenusingservice/LockScreenView.java: -------------------------------------------------------------------------------- 1 | package com.github.dubu.lockscreenusingservice; 2 | 3 | import android.annotation.TargetApi; 4 | import android.content.Context; 5 | import android.util.AttributeSet; 6 | import android.view.View; 7 | import android.widget.RelativeLayout; 8 | 9 | public class LockScreenView extends RelativeLayout { 10 | private Context mActivityContext = null; 11 | private View mLayoutView = null; 12 | 13 | public LockScreenView(Context context) { 14 | super(context); 15 | mActivityContext = context; 16 | initView(); 17 | } 18 | 19 | public LockScreenView(Context context, AttributeSet attrs) { 20 | super(context, attrs); 21 | mActivityContext = context; 22 | initView(); 23 | } 24 | 25 | public LockScreenView(Context context, AttributeSet attrs, int defStyleAttr) { 26 | super(context, attrs, defStyleAttr); 27 | mActivityContext = context; 28 | initView(); 29 | } 30 | 31 | @TargetApi(21) 32 | public LockScreenView(Context context, AttributeSet attrs, int defStyleAttr, int defStyleRes) { 33 | super(context, attrs, defStyleAttr, defStyleRes); 34 | mActivityContext = context; 35 | initView(); 36 | } 37 | 38 | private void initView() { 39 | 40 | } 41 | 42 | } 43 | -------------------------------------------------------------------------------- /lockscreenusingservice/src/main/java/com/github/dubu/lockscreenusingservice/Lockscreen.java: -------------------------------------------------------------------------------- 1 | package com.github.dubu.lockscreenusingservice; 2 | 3 | import android.content.Context; 4 | import android.content.Intent; 5 | 6 | import com.github.dubu.lockscreenusingservice.service.LockscreenService; 7 | import com.github.dubu.lockscreenusingservice.service.LockscreenViewService; 8 | 9 | public class Lockscreen { 10 | private Context mContext = null; 11 | public static final String ISSOFTKEY = "ISSOFTKEY"; 12 | public static final String ISLOCK = "ISLOCK"; 13 | private static Lockscreen mLockscreenInstance; 14 | 15 | public static Lockscreen getInstance(Context context) { 16 | if (mLockscreenInstance == null) { 17 | if (null != context) { 18 | mLockscreenInstance = new Lockscreen(context); 19 | } else { 20 | mLockscreenInstance = new Lockscreen(); 21 | } 22 | } 23 | return mLockscreenInstance; 24 | } 25 | 26 | private Lockscreen() { 27 | mContext = null; 28 | } 29 | 30 | private Lockscreen(Context context) { 31 | mContext = context; 32 | } 33 | 34 | public void startLockscreenService() { 35 | SharedPreferencesUtil.init(mContext); 36 | Intent startLockscreenIntent = new Intent(mContext, LockscreenService.class); 37 | // startLockscreenIntent.putExtra(LockscreenService.LOCKSCREENSERVICE_FIRST_START, true); 38 | mContext.startService(startLockscreenIntent); 39 | 40 | } 41 | 42 | public void stopLockscreenService() { 43 | Intent stopLockscreenViewIntent = new Intent(mContext, LockscreenViewService.class); 44 | mContext.stopService(stopLockscreenViewIntent); 45 | Intent stopLockscreenIntent = new Intent(mContext, LockscreenService.class); 46 | mContext.stopService(stopLockscreenIntent); 47 | } 48 | } 49 | -------------------------------------------------------------------------------- /lockscreenusingservice/src/main/java/com/github/dubu/lockscreenusingservice/LockscreenActivity.java: -------------------------------------------------------------------------------- 1 | package com.github.dubu.lockscreenusingservice; 2 | 3 | import android.app.Activity; 4 | import android.content.Context; 5 | import android.content.Intent; 6 | import android.os.Build; 7 | import android.os.Bundle; 8 | import android.os.Message; 9 | import android.telephony.PhoneStateListener; 10 | import android.telephony.TelephonyManager; 11 | import android.view.MotionEvent; 12 | import android.view.WindowManager; 13 | import android.widget.RelativeLayout; 14 | 15 | import com.github.dubu.lockscreenusingservice.service.LockscreenViewService; 16 | 17 | public class LockscreenActivity extends Activity { 18 | private final String TAG = "LockscreenActivity"; 19 | private static Context sLockscreenActivityContext = null; 20 | 21 | private RelativeLayout mLockscreenMainLayout = null; 22 | 23 | public static SendMassgeHandler mMainHandler = null; 24 | 25 | public PhoneStateListener phoneStateListener = new PhoneStateListener() { 26 | public void onCallStateChanged(int state, String incomingNumber) { 27 | 28 | switch (state) { 29 | case TelephonyManager.CALL_STATE_IDLE: 30 | break; 31 | case TelephonyManager.CALL_STATE_RINGING: 32 | break; 33 | default: 34 | break; 35 | } 36 | } 37 | 38 | ; 39 | }; 40 | 41 | 42 | @Override 43 | protected void onCreate(Bundle arg0) { 44 | super.onCreate(arg0); 45 | sLockscreenActivityContext = this; 46 | mMainHandler = new SendMassgeHandler(); 47 | // getWindow().setType(2004); 48 | // getWindow().addFlags(524288); 49 | // getWindow().addFlags(4194304); 50 | /// 51 | getWindow().setType(WindowManager.LayoutParams.FLAG_FULLSCREEN); 52 | // getWindow().addFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN); 53 | getWindow().addFlags(WindowManager.LayoutParams.FLAG_SHOW_WHEN_LOCKED); 54 | getWindow().addFlags(WindowManager.LayoutParams.FLAG_DISMISS_KEYGUARD); 55 | 56 | 57 | if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { 58 | getWindow().addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS); 59 | } else { 60 | getWindow().addFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS); 61 | } 62 | TelephonyManager manager = (TelephonyManager) getSystemService(Context.TELEPHONY_SERVICE); 63 | manager.listen(phoneStateListener, PhoneStateListener.LISTEN_CALL_STATE); 64 | 65 | initLockScreenUi(); 66 | 67 | setLockGuard(); 68 | } 69 | 70 | private class SendMassgeHandler extends android.os.Handler { 71 | @Override 72 | public void handleMessage(Message msg) { 73 | super.handleMessage(msg); 74 | finishLockscreenAct(); 75 | } 76 | } 77 | 78 | private void finishLockscreenAct() { 79 | finish(); 80 | } 81 | 82 | 83 | private void initLockScreenUi() { 84 | setContentView(R.layout.activity_lockscreen); 85 | mLockscreenMainLayout = (RelativeLayout) findViewById(R.id.lockscreen_main_layout); 86 | mLockscreenMainLayout.getBackground().setAlpha(15); 87 | } 88 | 89 | 90 | @Override 91 | public boolean dispatchTouchEvent(MotionEvent ev) { 92 | return super.dispatchTouchEvent(ev); 93 | } 94 | 95 | private void setLockGuard() { 96 | boolean isLockEnable = false; 97 | if (!LockscreenUtil.getInstance(sLockscreenActivityContext).isStandardKeyguardState()) { 98 | isLockEnable = false; 99 | } else { 100 | isLockEnable = true; 101 | } 102 | 103 | Intent startLockscreenIntent = new Intent(this, LockscreenViewService.class); 104 | startService(startLockscreenIntent); 105 | 106 | boolean isSoftkeyEnable = LockscreenUtil.getInstance(sLockscreenActivityContext).isSoftKeyAvail(this); 107 | SharedPreferencesUtil.setBoolean(Lockscreen.ISSOFTKEY, isSoftkeyEnable); 108 | if (!isSoftkeyEnable) { 109 | mMainHandler.sendEmptyMessage(0); 110 | } else if (isSoftkeyEnable) { 111 | if (isLockEnable) { 112 | mMainHandler.sendEmptyMessage(0); 113 | } 114 | } 115 | } 116 | 117 | @Override 118 | protected void onResume() { 119 | super.onResume(); 120 | 121 | 122 | } 123 | 124 | 125 | @Override 126 | protected void onDestroy() { 127 | super.onDestroy(); 128 | } 129 | 130 | 131 | @Override 132 | protected void onPostResume() { 133 | super.onPostResume(); 134 | } 135 | 136 | } 137 | -------------------------------------------------------------------------------- /lockscreenusingservice/src/main/java/com/github/dubu/lockscreenusingservice/LockscreenUtil.java: -------------------------------------------------------------------------------- 1 | package com.github.dubu.lockscreenusingservice; 2 | 3 | import android.app.Activity; 4 | import android.app.KeyguardManager; 5 | import android.content.Context; 6 | import android.view.View; 7 | import android.view.ViewTreeObserver; 8 | 9 | import rx.subjects.PublishSubject; 10 | 11 | public class LockscreenUtil { 12 | private Context mContext = null; 13 | private static LockscreenUtil mLockscreenUtilInstance; 14 | 15 | private PublishSubject permissionCheckSubject; 16 | 17 | public static LockscreenUtil getInstance(Context context) { 18 | if (mLockscreenUtilInstance == null) { 19 | if (null != context) { 20 | mLockscreenUtilInstance = new LockscreenUtil(context); 21 | } else { 22 | mLockscreenUtilInstance = new LockscreenUtil(); 23 | } 24 | } 25 | return mLockscreenUtilInstance; 26 | } 27 | 28 | private LockscreenUtil() { 29 | mContext = null; 30 | } 31 | 32 | private LockscreenUtil(Context context) { 33 | mContext = context; 34 | } 35 | 36 | public boolean isStandardKeyguardState() { 37 | boolean isStandardKeyguqrd = false; 38 | KeyguardManager keyManager = (KeyguardManager) mContext.getSystemService(mContext.KEYGUARD_SERVICE); 39 | if (null != keyManager) { 40 | isStandardKeyguqrd = keyManager.isKeyguardSecure(); 41 | } 42 | 43 | return isStandardKeyguqrd; 44 | } 45 | 46 | public boolean isSoftKeyAvail(Context context) { 47 | final boolean[] isSoftkey = {false}; 48 | final View activityRootView = ((Activity) context).getWindow().getDecorView().findViewById(android.R.id.content); 49 | activityRootView.getViewTreeObserver().addOnGlobalLayoutListener(new ViewTreeObserver.OnGlobalLayoutListener() { 50 | @Override 51 | public void onGlobalLayout() { 52 | int rootViewHeight = activityRootView.getRootView().getHeight(); 53 | int viewHeight = activityRootView.getHeight(); 54 | int heightDiff = rootViewHeight - viewHeight; 55 | if (heightDiff > 100) { // 99% of the time the height diff will be due to a keyboard. 56 | isSoftkey[0] = true; 57 | } 58 | } 59 | }); 60 | return isSoftkey[0]; 61 | } 62 | 63 | public int getStatusBarHeight() { 64 | int result = 0; 65 | int resourceId = mContext.getResources().getIdentifier("status_bar_height", "dimen", "android"); 66 | if (resourceId > 0) 67 | result = mContext.getResources().getDimensionPixelSize(resourceId); 68 | 69 | return result; 70 | } 71 | 72 | public PublishSubject getPermissionCheckSubject() { 73 | if (null == permissionCheckSubject) { 74 | permissionCheckSubject = PublishSubject.create(); 75 | } 76 | 77 | return permissionCheckSubject; 78 | } 79 | } 80 | -------------------------------------------------------------------------------- /lockscreenusingservice/src/main/java/com/github/dubu/lockscreenusingservice/PermissionActivity.java: -------------------------------------------------------------------------------- 1 | package com.github.dubu.lockscreenusingservice; 2 | 3 | import android.annotation.TargetApi; 4 | import android.app.Activity; 5 | import android.content.Intent; 6 | import android.net.Uri; 7 | import android.os.Build; 8 | import android.os.Bundle; 9 | import android.provider.Settings; 10 | import android.support.annotation.Nullable; 11 | 12 | public class PermissionActivity extends Activity { 13 | 14 | @Override 15 | protected void onCreate(@Nullable Bundle savedInstanceState) { 16 | super.onCreate(savedInstanceState); 17 | Intent intent = new Intent(Settings.ACTION_MANAGE_OVERLAY_PERMISSION, 18 | Uri.parse("package:" + getPackageName())); 19 | startActivityForResult(intent, 123); 20 | 21 | } 22 | 23 | @TargetApi(Build.VERSION_CODES.M) 24 | @Override 25 | protected void onActivityResult(int requestCode, int resultCode, Intent data) { 26 | 27 | switch (requestCode) { 28 | case 123: 29 | if (Settings.canDrawOverlays(this)) { 30 | LockscreenUtil.getInstance(this).getPermissionCheckSubject() 31 | .onNext(true); 32 | finish(); 33 | } else { 34 | // 35 | } 36 | break; 37 | } 38 | } 39 | 40 | } 41 | -------------------------------------------------------------------------------- /lockscreenusingservice/src/main/java/com/github/dubu/lockscreenusingservice/RemoveViewUtil.java: -------------------------------------------------------------------------------- 1 | package com.github.dubu.lockscreenusingservice; 2 | 3 | import android.view.View; 4 | import android.view.ViewGroup; 5 | import android.widget.AdapterView; 6 | 7 | public class RemoveViewUtil { 8 | private static final String TAG = "RemoveViewUtil"; 9 | 10 | private volatile static RemoveViewUtil RemoveViewUtilUniqueInstance; 11 | 12 | public static RemoveViewUtil getInstance() { 13 | if (RemoveViewUtilUniqueInstance == null) { 14 | synchronized (RemoveViewUtil.class) { 15 | if (RemoveViewUtilUniqueInstance == null) { 16 | RemoveViewUtilUniqueInstance = new RemoveViewUtil(); 17 | } 18 | } 19 | } 20 | return RemoveViewUtilUniqueInstance; 21 | } 22 | 23 | private RemoveViewUtil() { 24 | } 25 | 26 | public void unbindDrawables(View view) { 27 | if (null != view) { 28 | if (view.getBackground() != null) { 29 | view.getBackground().setCallback(null); 30 | } 31 | if (view instanceof ViewGroup && !(view instanceof AdapterView)) { 32 | for (int i = 0; i < ((ViewGroup) view).getChildCount(); i++) { 33 | unbindDrawables(((ViewGroup) view).getChildAt(i)); 34 | } 35 | ((ViewGroup) view).removeAllViews(); 36 | } 37 | } 38 | } 39 | } 40 | 41 | -------------------------------------------------------------------------------- /lockscreenusingservice/src/main/java/com/github/dubu/lockscreenusingservice/SharedPreferencesUtil.java: -------------------------------------------------------------------------------- 1 | package com.github.dubu.lockscreenusingservice; 2 | 3 | import android.content.Context; 4 | import android.content.SharedPreferences; 5 | 6 | public class SharedPreferencesUtil { 7 | private static final String NAME = "LOCKSCREEN"; 8 | 9 | public enum Cmd { 10 | INIT("null"); 11 | 12 | private String mDefault; 13 | 14 | private Cmd(String def) { 15 | this.mDefault = def; 16 | } 17 | 18 | public String getDefault() { 19 | return mDefault; 20 | } 21 | } 22 | 23 | private static SharedPreferences mPref = null; 24 | 25 | public static void init(Context context) { 26 | mPref = context.getSharedPreferences(NAME, Context.MODE_PRIVATE); 27 | } 28 | 29 | public static String get(Cmd cmd) { 30 | if (mPref == null || !mPref.contains(cmd.name())) { 31 | SharedPreferences.Editor edit = mPref.edit(); 32 | edit.putString(cmd.toString(), cmd.getDefault()); 33 | edit.commit(); 34 | } 35 | 36 | return mPref.getString(cmd.toString(), "null"); 37 | } 38 | 39 | public static void set(Cmd cmd, String data) { 40 | if (mPref != null) { 41 | SharedPreferences.Editor edit = mPref.edit(); 42 | edit.putString(cmd.toString(), data); 43 | edit.commit(); 44 | } 45 | } 46 | 47 | public static void setBoolean(String _key, boolean _value) { 48 | if (_key == null) { 49 | return; 50 | } 51 | 52 | if (mPref != null) { 53 | SharedPreferences.Editor edit = mPref.edit(); 54 | edit.putBoolean(_key, _value); 55 | edit.commit(); 56 | } 57 | } 58 | 59 | public static boolean get(String _key) { 60 | if (mPref == null || !mPref.contains(_key)) { 61 | SharedPreferences.Editor edit = mPref.edit(); 62 | edit.putBoolean(_key, false); 63 | edit.commit(); 64 | } 65 | 66 | return mPref.getBoolean(_key, false); 67 | } 68 | } 69 | -------------------------------------------------------------------------------- /lockscreenusingservice/src/main/java/com/github/dubu/lockscreenusingservice/service/LockscreenService.java: -------------------------------------------------------------------------------- 1 | package com.github.dubu.lockscreenusingservice.service; 2 | 3 | import android.app.KeyguardManager; 4 | import android.app.Service; 5 | import android.content.BroadcastReceiver; 6 | import android.content.Context; 7 | import android.content.Intent; 8 | import android.content.IntentFilter; 9 | import android.os.IBinder; 10 | import android.telephony.TelephonyManager; 11 | import android.util.Log; 12 | 13 | import com.github.dubu.lockscreenusingservice.LockscreenActivity; 14 | import com.github.dubu.lockscreenusingservice.LockscreenUtil; 15 | 16 | public class LockscreenService extends Service { 17 | private final String TAG = "LockscreenService"; 18 | // public static final String LOCKSCREENSERVICE_FIRST_START = "LOCKSCREENSERVICE_FIRST_START"; 19 | private int mServiceStartId = 0; 20 | private Context mContext = null; 21 | 22 | 23 | private BroadcastReceiver mLockscreenReceiver = new BroadcastReceiver() { 24 | @Override 25 | public void onReceive(Context context, Intent intent) { 26 | if (null != context) { 27 | if (intent.getAction().equals(Intent.ACTION_SCREEN_OFF)) { 28 | Intent startLockscreenIntent = new Intent(mContext, LockscreenViewService.class); 29 | stopService(startLockscreenIntent); 30 | TelephonyManager tManager = (TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE); 31 | boolean isPhoneIdle = tManager.getCallState() == TelephonyManager.CALL_STATE_IDLE; 32 | if (isPhoneIdle) { 33 | startLockscreenActivity(); 34 | } 35 | } 36 | } 37 | } 38 | }; 39 | 40 | private void stateRecever(boolean isStartRecever) { 41 | if (isStartRecever) { 42 | IntentFilter filter = new IntentFilter(); 43 | filter.addAction(Intent.ACTION_SCREEN_OFF); 44 | registerReceiver(mLockscreenReceiver, filter); 45 | } else { 46 | if (null != mLockscreenReceiver) { 47 | unregisterReceiver(mLockscreenReceiver); 48 | } 49 | } 50 | } 51 | 52 | 53 | @Override 54 | public void onCreate() { 55 | super.onCreate(); 56 | mContext = this; 57 | } 58 | 59 | 60 | @Override 61 | public int onStartCommand(Intent intent, int flags, int startId) { 62 | mServiceStartId = startId; 63 | stateRecever(true); 64 | Intent bundleIntet = intent; 65 | if (null != bundleIntet) { 66 | startLockscreenActivity(); 67 | } else { 68 | Log.d(TAG, TAG + " onStartCommand intent NOT existed"); 69 | } 70 | setLockGuard(); 71 | return LockscreenService.START_STICKY; 72 | } 73 | 74 | 75 | private void setLockGuard() { 76 | initKeyguardService(); 77 | if (!LockscreenUtil.getInstance(mContext).isStandardKeyguardState()) { 78 | setStandardKeyguardState(false); 79 | } else { 80 | setStandardKeyguardState(true); 81 | } 82 | } 83 | 84 | private KeyguardManager mKeyManager = null; 85 | private KeyguardManager.KeyguardLock mKeyLock = null; 86 | 87 | private void initKeyguardService() { 88 | if (null != mKeyManager) { 89 | mKeyManager = null; 90 | } 91 | mKeyManager = (KeyguardManager) getSystemService(mContext.KEYGUARD_SERVICE); 92 | if (null != mKeyManager) { 93 | if (null != mKeyLock) { 94 | mKeyLock = null; 95 | } 96 | mKeyLock = mKeyManager.newKeyguardLock(mContext.KEYGUARD_SERVICE); 97 | } 98 | } 99 | 100 | private void setStandardKeyguardState(boolean isStart) { 101 | if (isStart) { 102 | if (null != mKeyLock) { 103 | mKeyLock.reenableKeyguard(); 104 | } 105 | } else { 106 | 107 | if (null != mKeyManager) { 108 | mKeyLock.disableKeyguard(); 109 | } 110 | } 111 | } 112 | 113 | 114 | @Override 115 | public IBinder onBind(Intent intent) { 116 | return null; 117 | } 118 | 119 | 120 | @Override 121 | public void onDestroy() { 122 | stateRecever(false); 123 | setStandardKeyguardState(true); 124 | } 125 | 126 | private void startLockscreenActivity() { 127 | Intent startLockscreenActIntent = new Intent(mContext, LockscreenActivity.class); 128 | startLockscreenActIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); 129 | startActivity(startLockscreenActIntent); 130 | } 131 | 132 | } 133 | -------------------------------------------------------------------------------- /lockscreenusingservice/src/main/java/com/github/dubu/lockscreenusingservice/service/LockscreenViewService.java: -------------------------------------------------------------------------------- 1 | package com.github.dubu.lockscreenusingservice.service; 2 | 3 | import android.annotation.TargetApi; 4 | import android.app.Service; 5 | import android.content.Context; 6 | import android.content.Intent; 7 | import android.graphics.PixelFormat; 8 | import android.os.Build; 9 | import android.os.IBinder; 10 | import android.os.Message; 11 | import android.provider.Settings; 12 | import android.util.DisplayMetrics; 13 | import android.view.LayoutInflater; 14 | import android.view.MotionEvent; 15 | import android.view.View; 16 | import android.view.WindowManager; 17 | import android.view.animation.AlphaAnimation; 18 | import android.view.animation.Animation; 19 | import android.view.animation.TranslateAnimation; 20 | import android.widget.ImageView; 21 | import android.widget.RelativeLayout; 22 | 23 | import com.github.dubu.lockscreenusingservice.Lockscreen; 24 | import com.github.dubu.lockscreenusingservice.LockscreenUtil; 25 | import com.github.dubu.lockscreenusingservice.PermissionActivity; 26 | import com.github.dubu.lockscreenusingservice.R; 27 | import com.github.dubu.lockscreenusingservice.SharedPreferencesUtil; 28 | import com.romainpiel.shimmer.Shimmer; 29 | import com.romainpiel.shimmer.ShimmerTextView; 30 | 31 | import rx.android.schedulers.AndroidSchedulers; 32 | import rx.functions.Action1; 33 | 34 | public class LockscreenViewService extends Service { 35 | private final int LOCK_OPEN_OFFSET_VALUE = 50; 36 | private Context mContext = null; 37 | private LayoutInflater mInflater = null; 38 | private View mLockscreenView = null; 39 | private WindowManager mWindowManager; 40 | private WindowManager.LayoutParams mParams; 41 | private RelativeLayout mBackgroundLayout = null; 42 | private RelativeLayout mBackgroundInLayout = null; 43 | private ImageView mBackgroundLockImageView = null; 44 | private RelativeLayout mForgroundLayout = null; 45 | private RelativeLayout mStatusBackgruondDummyView = null; 46 | private RelativeLayout mStatusForgruondDummyView = null; 47 | private ShimmerTextView mShimmerTextView = null; 48 | private boolean mIsLockEnable = false; 49 | private boolean mIsSoftkeyEnable = false; 50 | private int mDeviceWidth = 0; 51 | private int mDevideDeviceWidth = 0; 52 | private float mLastLayoutX = 0; 53 | private int mServiceStartId = 0; 54 | private SendMassgeHandler mMainHandler = null; 55 | // private boolean sIsSoftKeyEnable = false; 56 | 57 | private class SendMassgeHandler extends android.os.Handler { 58 | @Override 59 | public void handleMessage(Message msg) { 60 | super.handleMessage(msg); 61 | changeBackGroundLockView(mLastLayoutX); 62 | } 63 | } 64 | 65 | @Override 66 | public IBinder onBind(Intent intent) { 67 | return null; 68 | } 69 | 70 | 71 | @Override 72 | public void onCreate() { 73 | super.onCreate(); 74 | mContext = this; 75 | SharedPreferencesUtil.init(mContext); 76 | // sIsSoftKeyEnable = SharedPreferencesUtil.get(Lockscreen.ISSOFTKEY); 77 | } 78 | 79 | 80 | @Override 81 | public int onStartCommand(Intent intent, int flags, int startId) { 82 | mMainHandler = new SendMassgeHandler(); 83 | if (isLockScreenAble()) { 84 | if (null != mWindowManager) { 85 | if (null != mLockscreenView) { 86 | mWindowManager.removeView(mLockscreenView); 87 | } 88 | mWindowManager = null; 89 | mParams = null; 90 | mInflater = null; 91 | mLockscreenView = null; 92 | } 93 | initState(); 94 | initView(); 95 | attachLockScreenView(); 96 | } 97 | return LockscreenViewService.START_NOT_STICKY; 98 | } 99 | 100 | @Override 101 | public void onDestroy() { 102 | dettachLockScreenView(); 103 | } 104 | 105 | 106 | private void initState() { 107 | 108 | mIsLockEnable = LockscreenUtil.getInstance(mContext).isStandardKeyguardState(); 109 | if (mIsLockEnable) { 110 | mParams = new WindowManager.LayoutParams( 111 | WindowManager.LayoutParams.MATCH_PARENT, 112 | WindowManager.LayoutParams.MATCH_PARENT, 113 | WindowManager.LayoutParams.TYPE_SYSTEM_ERROR, 114 | WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE, 115 | PixelFormat.TRANSLUCENT); 116 | } else { 117 | mParams = new WindowManager.LayoutParams( 118 | WindowManager.LayoutParams.MATCH_PARENT, 119 | WindowManager.LayoutParams.MATCH_PARENT, 120 | WindowManager.LayoutParams.TYPE_PHONE, 121 | WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE 122 | | WindowManager.LayoutParams.FLAG_SHOW_WHEN_LOCKED 123 | | WindowManager.LayoutParams.FLAG_DISMISS_KEYGUARD, 124 | PixelFormat.TRANSLUCENT); 125 | } 126 | if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { 127 | if (mIsLockEnable && mIsSoftkeyEnable) { 128 | mParams.flags = WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS; 129 | } else { 130 | mParams.flags = WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS; 131 | } 132 | } else { 133 | mParams.flags = WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS; 134 | } 135 | 136 | if (null == mWindowManager) { 137 | mWindowManager = ((WindowManager) mContext.getSystemService(WINDOW_SERVICE)); 138 | } 139 | } 140 | 141 | private void initView() { 142 | if (null == mInflater) { 143 | mInflater = (LayoutInflater) getBaseContext().getSystemService(Context.LAYOUT_INFLATER_SERVICE); 144 | } 145 | 146 | if (null == mLockscreenView) { 147 | mLockscreenView = mInflater.inflate(R.layout.view_locokscreen, null); 148 | 149 | } 150 | } 151 | 152 | private boolean isLockScreenAble() { 153 | boolean isLock = SharedPreferencesUtil.get(Lockscreen.ISLOCK); 154 | if (isLock) { 155 | isLock = true; 156 | } else { 157 | isLock = false; 158 | } 159 | return isLock; 160 | } 161 | 162 | 163 | private void attachLockScreenView() { 164 | if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.M) { 165 | if (!Settings.canDrawOverlays(mContext)) { 166 | Intent permissionActivityIntent = new Intent(mContext, PermissionActivity.class); 167 | permissionActivityIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); 168 | startActivity(permissionActivityIntent); 169 | 170 | LockscreenUtil.getInstance(mContext).getPermissionCheckSubject() 171 | .subscribeOn(AndroidSchedulers.mainThread()) 172 | .subscribe( 173 | new Action1() { 174 | @Override 175 | public void call(Boolean aBoolean) { 176 | addLockScreenView(); 177 | } 178 | } 179 | ); 180 | } else { 181 | addLockScreenView(); 182 | } 183 | } else { 184 | addLockScreenView(); 185 | } 186 | 187 | } 188 | 189 | private void addLockScreenView() { 190 | if (null != mWindowManager && null != mLockscreenView && null != mParams) { 191 | mLockscreenView.setOnTouchListener(new View.OnTouchListener() { 192 | @Override 193 | public boolean onTouch(View v, MotionEvent event) { 194 | return false; 195 | } 196 | }); 197 | mWindowManager.addView(mLockscreenView, mParams); 198 | settingLockView(); 199 | } 200 | } 201 | 202 | 203 | private boolean dettachLockScreenView() { 204 | if (null != mWindowManager && null != mLockscreenView && isAttachedToWindow()) { 205 | mWindowManager.removeView(mLockscreenView); 206 | mLockscreenView = null; 207 | mWindowManager = null; 208 | stopSelf(mServiceStartId); 209 | return true; 210 | } else { 211 | return false; 212 | } 213 | } 214 | 215 | @TargetApi(Build.VERSION_CODES.M) 216 | private boolean isAttachedToWindow() { 217 | return mLockscreenView.isAttachedToWindow(); 218 | } 219 | 220 | private void settingLockView() { 221 | mBackgroundLayout = (RelativeLayout) mLockscreenView.findViewById(R.id.lockscreen_background_layout); 222 | mBackgroundInLayout = (RelativeLayout) mLockscreenView.findViewById(R.id.lockscreen_background_in_layout); 223 | mBackgroundLockImageView = (ImageView) mLockscreenView.findViewById(R.id.lockscreen_background_image); 224 | mForgroundLayout = (RelativeLayout) mLockscreenView.findViewById(R.id.lockscreen_forground_layout); 225 | mShimmerTextView = (ShimmerTextView) mLockscreenView.findViewById(R.id.shimmer_tv); 226 | (new Shimmer()).start(mShimmerTextView); 227 | mForgroundLayout.setOnTouchListener(mViewTouchListener); 228 | 229 | mStatusBackgruondDummyView = (RelativeLayout) mLockscreenView.findViewById(R.id.lockscreen_background_status_dummy); 230 | mStatusForgruondDummyView = (RelativeLayout) mLockscreenView.findViewById(R.id.lockscreen_forground_status_dummy); 231 | setBackGroundLockView(); 232 | 233 | DisplayMetrics displayMetrics = mContext.getResources().getDisplayMetrics(); 234 | mDeviceWidth = displayMetrics.widthPixels; 235 | mDevideDeviceWidth = (mDeviceWidth / 2); 236 | mBackgroundLockImageView.setX((int) (((mDevideDeviceWidth) * -1))); 237 | 238 | //kitkat 239 | if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) { 240 | int val = LockscreenUtil.getInstance(mContext).getStatusBarHeight(); 241 | RelativeLayout.LayoutParams forgroundParam = (RelativeLayout.LayoutParams) mStatusForgruondDummyView.getLayoutParams(); 242 | forgroundParam.height = val; 243 | mStatusForgruondDummyView.setLayoutParams(forgroundParam); 244 | AlphaAnimation alpha = new AlphaAnimation(0.5F, 0.5F); 245 | alpha.setDuration(0); // Make animation instant 246 | alpha.setFillAfter(true); // Tell it to persist after the animation ends 247 | mStatusForgruondDummyView.startAnimation(alpha); 248 | RelativeLayout.LayoutParams backgroundParam = (RelativeLayout.LayoutParams) mStatusBackgruondDummyView.getLayoutParams(); 249 | backgroundParam.height = val; 250 | mStatusBackgruondDummyView.setLayoutParams(backgroundParam); 251 | } 252 | } 253 | 254 | private void setBackGroundLockView() { 255 | if (mIsLockEnable) { 256 | mBackgroundInLayout.setBackgroundColor(getResources().getColor(R.color.lock_background_color)); 257 | mBackgroundLockImageView.setVisibility(View.VISIBLE); 258 | 259 | } else { 260 | mBackgroundInLayout.setBackgroundColor(getResources().getColor(android.R.color.transparent)); 261 | mBackgroundLockImageView.setVisibility(View.GONE); 262 | } 263 | } 264 | 265 | 266 | private void changeBackGroundLockView(float forgroundX) { 267 | if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) { 268 | if (forgroundX < mDeviceWidth) { 269 | mBackgroundLockImageView.setBackground(getResources().getDrawable(R.drawable.lock)); 270 | } else { 271 | mBackgroundLockImageView.setBackground(getResources().getDrawable(R.drawable.unlock)); 272 | } 273 | } else { 274 | if (forgroundX < mDeviceWidth) { 275 | mBackgroundLockImageView.setBackgroundDrawable(getResources().getDrawable(R.drawable.lock)); 276 | } else { 277 | mBackgroundLockImageView.setBackgroundDrawable(getResources().getDrawable(R.drawable.unlock)); 278 | } 279 | } 280 | } 281 | 282 | 283 | private View.OnTouchListener mViewTouchListener = new View.OnTouchListener() { 284 | private float firstTouchX = 0; 285 | private float layoutPrevX = 0; 286 | private float lastLayoutX = 0; 287 | private float layoutInPrevX = 0; 288 | private boolean isLockOpen = false; 289 | private int touchMoveX = 0; 290 | private int touchInMoveX = 0; 291 | 292 | @Override 293 | public boolean onTouch(View v, MotionEvent event) { 294 | 295 | switch (event.getAction() & MotionEvent.ACTION_MASK) { 296 | case MotionEvent.ACTION_DOWN: {// 0 297 | firstTouchX = event.getX(); 298 | layoutPrevX = mForgroundLayout.getX(); 299 | layoutInPrevX = mBackgroundLockImageView.getX(); 300 | if (firstTouchX <= LOCK_OPEN_OFFSET_VALUE) { 301 | isLockOpen = true; 302 | } 303 | } 304 | break; 305 | case MotionEvent.ACTION_MOVE: { // 2 306 | if (isLockOpen) { 307 | touchMoveX = (int) (event.getRawX() - firstTouchX); 308 | if (mForgroundLayout.getX() >= 0) { 309 | mForgroundLayout.setX((int) (layoutPrevX + touchMoveX)); 310 | mBackgroundLockImageView.setX((int) (layoutInPrevX + (touchMoveX / 1.8))); 311 | mLastLayoutX = lastLayoutX; 312 | mMainHandler.sendEmptyMessage(0); 313 | if (mForgroundLayout.getX() < 0) { 314 | mForgroundLayout.setX(0); 315 | } 316 | lastLayoutX = mForgroundLayout.getX(); 317 | } 318 | } else { 319 | return false; 320 | } 321 | } 322 | break; 323 | case MotionEvent.ACTION_UP: { // 1 324 | if (isLockOpen) { 325 | mForgroundLayout.setX(lastLayoutX); 326 | mForgroundLayout.setY(0); 327 | optimizeForground(lastLayoutX); 328 | } 329 | isLockOpen = false; 330 | firstTouchX = 0; 331 | layoutPrevX = 0; 332 | layoutInPrevX = 0; 333 | touchMoveX = 0; 334 | lastLayoutX = 0; 335 | } 336 | break; 337 | default: 338 | break; 339 | } 340 | 341 | return true; 342 | } 343 | }; 344 | 345 | private void optimizeForground(float forgroundX) { 346 | // final int devideDeviceWidth = (mDeviceWidth / 2); 347 | if (forgroundX < mDevideDeviceWidth) { 348 | int startPostion = 0; 349 | for (startPostion = mDevideDeviceWidth; startPostion >= 0; startPostion--) { 350 | mForgroundLayout.setX(startPostion); 351 | } 352 | } else { 353 | TranslateAnimation animation = new TranslateAnimation(0, mDevideDeviceWidth, 0, 0); 354 | animation.setDuration(300); 355 | animation.setAnimationListener(new Animation.AnimationListener() { 356 | @Override 357 | public void onAnimationStart(Animation animation) { 358 | } 359 | 360 | @Override 361 | public void onAnimationEnd(Animation animation) { 362 | mForgroundLayout.setX(mDevideDeviceWidth); 363 | mForgroundLayout.setY(0); 364 | dettachLockScreenView(); 365 | } 366 | 367 | @Override 368 | public void onAnimationRepeat(Animation animation) { 369 | } 370 | }); 371 | 372 | mForgroundLayout.startAnimation(animation); 373 | } 374 | } 375 | } 376 | -------------------------------------------------------------------------------- /lockscreenusingservice/src/main/res/drawable/images.jpeg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hmm-umm/Android-LockScreenSample-DisableHomeButtonKey/0453ae5bbee10099e88a24f1c13f475790d4cb2a/lockscreenusingservice/src/main/res/drawable/images.jpeg -------------------------------------------------------------------------------- /lockscreenusingservice/src/main/res/drawable/lock.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hmm-umm/Android-LockScreenSample-DisableHomeButtonKey/0453ae5bbee10099e88a24f1c13f475790d4cb2a/lockscreenusingservice/src/main/res/drawable/lock.png -------------------------------------------------------------------------------- /lockscreenusingservice/src/main/res/drawable/unlock.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hmm-umm/Android-LockScreenSample-DisableHomeButtonKey/0453ae5bbee10099e88a24f1c13f475790d4cb2a/lockscreenusingservice/src/main/res/drawable/unlock.png -------------------------------------------------------------------------------- /lockscreenusingservice/src/main/res/layout/activity_lockscreen.xml: -------------------------------------------------------------------------------- 1 | 2 | 7 | 8 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /lockscreenusingservice/src/main/res/layout/view_locokscreen.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | 11 | 12 | 13 | 19 | 20 | 26 | 27 | 33 | 34 | 35 | 36 | 37 | 38 | 42 | 43 | 49 | 50 | 55 | 56 | 65 | 66 | 67 | 68 | 69 | 70 | -------------------------------------------------------------------------------- /lockscreenusingservice/src/main/res/menu/menu_main.xml: -------------------------------------------------------------------------------- 1 | 4 | 6 | 7 | -------------------------------------------------------------------------------- /lockscreenusingservice/src/main/res/values-w820dp/color.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | #222222 4 | 5 | -------------------------------------------------------------------------------- /lockscreenusingservice/src/main/res/values-w820dp/dimens.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 64dp 6 | 7 | -------------------------------------------------------------------------------- /lockscreenusingservice/src/main/res/values/color.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | #222222 4 | 5 | -------------------------------------------------------------------------------- /lockscreenusingservice/src/main/res/values/dimens.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 16dp 4 | 16dp 5 | 6 | -------------------------------------------------------------------------------- /lockscreenusingservice/src/main/res/values/strings.xml: -------------------------------------------------------------------------------- 1 | 2 | LockScreenUsingService 3 | 4 | Hello world! 5 | Settings 6 | 7 | -------------------------------------------------------------------------------- /rawimg/softkey_lock_lg.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hmm-umm/Android-LockScreenSample-DisableHomeButtonKey/0453ae5bbee10099e88a24f1c13f475790d4cb2a/rawimg/softkey_lock_lg.gif -------------------------------------------------------------------------------- /rawimg/softkey_unlock_lg.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hmm-umm/Android-LockScreenSample-DisableHomeButtonKey/0453ae5bbee10099e88a24f1c13f475790d4cb2a/rawimg/softkey_unlock_lg.gif -------------------------------------------------------------------------------- /rawimg/softkey_unlock_nexus5.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hmm-umm/Android-LockScreenSample-DisableHomeButtonKey/0453ae5bbee10099e88a24f1c13f475790d4cb2a/rawimg/softkey_unlock_nexus5.gif -------------------------------------------------------------------------------- /rawimg/unsoftkey_lock_samsung.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hmm-umm/Android-LockScreenSample-DisableHomeButtonKey/0453ae5bbee10099e88a24f1c13f475790d4cb2a/rawimg/unsoftkey_lock_samsung.gif -------------------------------------------------------------------------------- /rawimg/unsoftkey_unlock_samsung.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hmm-umm/Android-LockScreenSample-DisableHomeButtonKey/0453ae5bbee10099e88a24f1c13f475790d4cb2a/rawimg/unsoftkey_unlock_samsung.gif -------------------------------------------------------------------------------- /settings.gradle: -------------------------------------------------------------------------------- 1 | include ':app', ':lockscreenusingservice' 2 | --------------------------------------------------------------------------------