├── .gitignore
├── CHANGELOG.md
├── LICENSE
├── README.md
├── app
├── .gitignore
├── build.gradle.kts
├── proguard-rules.pro
└── src
│ └── main
│ ├── AndroidManifest.xml
│ ├── ic_launcher-playstore.png
│ ├── kotlin
│ └── de
│ │ └── bigboot
│ │ └── watch4payswitch
│ │ ├── AccessibilityService.kt
│ │ ├── ActivityRuleFragment.kt
│ │ ├── AppPreferences.kt
│ │ ├── MainActivity.kt
│ │ ├── SelectPredefinedActivity.kt
│ │ └── SelectPredefinedAdapter.kt
│ └── res
│ ├── drawable
│ ├── activity_select_predefined_item_background.xml
│ ├── ic_launcher_background.xml
│ ├── ic_launcher_foreground.xml
│ ├── ic_predefined.xml
│ └── ic_rule_add.xml
│ ├── layout
│ ├── activity_main.xml
│ ├── activity_select_predefined.xml
│ ├── activity_select_predefined_item.xml
│ └── fragment_activity_rule.xml
│ ├── mipmap-anydpi-v26
│ ├── ic_launcher.xml
│ └── ic_launcher_round.xml
│ ├── mipmap-hdpi
│ ├── ic_launcher.png
│ ├── ic_launcher_adaptive_back.png
│ └── ic_launcher_adaptive_fore.png
│ ├── mipmap-mdpi
│ ├── ic_launcher.png
│ ├── ic_launcher_adaptive_back.png
│ └── ic_launcher_adaptive_fore.png
│ ├── mipmap-xhdpi
│ ├── ic_launcher.png
│ ├── ic_launcher_adaptive_back.png
│ └── ic_launcher_adaptive_fore.png
│ ├── mipmap-xxhdpi
│ ├── ic_launcher.png
│ ├── ic_launcher_adaptive_back.png
│ └── ic_launcher_adaptive_fore.png
│ ├── mipmap-xxxhdpi
│ ├── ic_launcher.png
│ ├── ic_launcher_adaptive_back.png
│ └── ic_launcher_adaptive_fore.png
│ ├── values
│ ├── dimens.xml
│ └── strings.xml
│ └── xml
│ └── accessibility_service_config.xml
├── build.gradle.kts
├── gradle.properties
├── gradle
└── wrapper
│ ├── gradle-wrapper.jar
│ └── gradle-wrapper.properties
├── gradlew
├── gradlew.bat
├── img
├── 1.png
├── 10.png
├── 2.png
├── 3.png
├── 4.png
├── 5.png
├── 6.png
├── 7.png
├── 8.png
└── 9.png
└── settings.gradle.kts
/.gitignore:
--------------------------------------------------------------------------------
1 | # Created by https://www.toptal.com/developers/gitignore/api/android,androidstudio
2 | # Edit at https://www.toptal.com/developers/gitignore?templates=android,androidstudio
3 |
4 | ### Android ###
5 | # Gradle files
6 | .gradle/
7 | build/
8 |
9 | # Local configuration file (sdk path, etc)
10 | local.properties
11 |
12 | # Log/OS Files
13 | *.log
14 |
15 | # Android Studio generated files and folders
16 | captures/
17 | .externalNativeBuild/
18 | .cxx/
19 | *.apk
20 | output.json
21 |
22 | # IntelliJ
23 | *.iml
24 | .idea/
25 |
26 | # Keystore files
27 | *.jks
28 | *.keystore
29 | *.p12
30 | *.pfx
31 |
32 | # Google Services (e.g. APIs or Firebase)
33 | google-services.json
34 |
35 | # Android Profiling
36 | *.hprof
37 |
38 | ### Android Patch ###
39 | gen-external-apklibs
40 |
41 | # Replacement of .externalNativeBuild directories introduced
42 | # with Android Studio 3.5.
43 |
44 | ### AndroidStudio ###
45 | # Covers files to be ignored for android development using Android Studio.
46 |
47 | # Built application files
48 | *.ap_
49 | *.aab
50 |
51 | # Files for the ART/Dalvik VM
52 | *.dex
53 |
54 | # Java class files
55 | *.class
56 |
57 | # Generated files
58 | bin/
59 | gen/
60 | out/
61 |
62 | # Gradle files
63 | .gradle
64 |
65 | # Signing files
66 | .signing/
67 |
68 | # Local configuration file (sdk path, etc)
69 |
70 | # Proguard folder generated by Eclipse
71 | proguard/
72 |
73 | # Log Files
74 |
75 | # Android Studio
76 | /*/build/
77 | /*/local.properties
78 | /*/out
79 | /*/*/build
80 | /*/*/production
81 | .navigation/
82 | *.ipr
83 | *~
84 | *.swp
85 |
86 | # Keystore files
87 |
88 | # Google Services (e.g. APIs or Firebase)
89 | # google-services.json
90 |
91 | # Android Patch
92 |
93 | # External native build folder generated in Android Studio 2.2 and later
94 | .externalNativeBuild
95 |
96 | # NDK
97 | obj/
98 |
99 | # IntelliJ IDEA
100 | *.iws
101 | /out/
102 |
103 | # User-specific configurations
104 | .idea/caches/
105 | .idea/libraries/
106 | .idea/shelf/
107 | .idea/workspace.xml
108 | .idea/tasks.xml
109 | .idea/.name
110 | .idea/compiler.xml
111 | .idea/copyright/profiles_settings.xml
112 | .idea/encodings.xml
113 | .idea/misc.xml
114 | .idea/modules.xml
115 | .idea/scopes/scope_settings.xml
116 | .idea/dictionaries
117 | .idea/vcs.xml
118 | .idea/jsLibraryMappings.xml
119 | .idea/datasources.xml
120 | .idea/dataSources.ids
121 | .idea/sqlDataSources.xml
122 | .idea/dynamic.xml
123 | .idea/uiDesigner.xml
124 | .idea/assetWizardSettings.xml
125 | .idea/gradle.xml
126 | .idea/jarRepositories.xml
127 | .idea/navEditor.xml
128 |
129 | # OS-specific files
130 | .DS_Store
131 | .DS_Store?
132 | ._*
133 | .Spotlight-V100
134 | .Trashes
135 | ehthumbs.db
136 | Thumbs.db
137 |
138 | # Legacy Eclipse project files
139 | .classpath
140 | .project
141 | .cproject
142 | .settings/
143 |
144 | # Mobile Tools for Java (J2ME)
145 | .mtj.tmp/
146 |
147 | # Package Files #
148 | *.war
149 | *.ear
150 |
151 | # virtual machine crash logs (Reference: http://www.java.com/en/download/help/error_hotspot.xml)
152 | hs_err_pid*
153 |
154 | ## Plugin-specific files:
155 |
156 | # mpeltonen/sbt-idea plugin
157 | .idea_modules/
158 |
159 | # JIRA plugin
160 | atlassian-ide-plugin.xml
161 |
162 | # Mongo Explorer plugin
163 | .idea/mongoSettings.xml
164 |
165 | # Crashlytics plugin (for Android Studio and IntelliJ)
166 | com_crashlytics_export_strings.xml
167 | crashlytics.properties
168 | crashlytics-build.properties
169 | fabric.properties
170 |
171 | ### AndroidStudio Patch ###
172 |
173 | !/gradle/wrapper/gradle-wrapper.jar
174 |
175 | # End of https://www.toptal.com/developers/gitignore/api/android,androidstudio
--------------------------------------------------------------------------------
/CHANGELOG.md:
--------------------------------------------------------------------------------
1 | # Changelog
2 | All notable changes to this project will be documented in this file.
3 |
4 | The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
5 | and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
6 |
7 | ## [Unreleased]
8 |
9 | ## 2.0.0-alpha1
10 | ### Changed
11 | - Implement new detection method for button presses
12 |
13 | ## 1.0.1
14 | ### Changed
15 | - Replace Google Pay with Google Wallet
16 |
17 |
18 | ## 1.0.0
19 | ### Changed
20 | - App name and package changed **(please uninstall the old version manually)**
21 | - New icon
22 |
23 | ### Added
24 | - Predefined target: Ultimate Alexa
25 |
26 | ## 1.0.0-alpha2
27 | ### Added
28 | - Ability to define custom rules
29 | - Predefined sources: Samsung Pay, Bixby, Power Menu
30 | - Predefined targets: Google Pay, Google Assistant Go
31 |
32 | ## 1.0.0-alpha1
33 | ### Added
34 | - Initial release of Watch 4 PaySwitch
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | Apache License
2 | Version 2.0, January 2004
3 | http://www.apache.org/licenses/
4 |
5 | TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6 |
7 | 1. Definitions.
8 |
9 | "License" shall mean the terms and conditions for use, reproduction,
10 | and distribution as defined by Sections 1 through 9 of this document.
11 |
12 | "Licensor" shall mean the copyright owner or entity authorized by
13 | the copyright owner that is granting the License.
14 |
15 | "Legal Entity" shall mean the union of the acting entity and all
16 | other entities that control, are controlled by, or are under common
17 | control with that entity. For the purposes of this definition,
18 | "control" means (i) the power, direct or indirect, to cause the
19 | direction or management of such entity, whether by contract or
20 | otherwise, or (ii) ownership of fifty percent (50%) or more of the
21 | outstanding shares, or (iii) beneficial ownership of such entity.
22 |
23 | "You" (or "Your") shall mean an individual or Legal Entity
24 | exercising permissions granted by this License.
25 |
26 | "Source" form shall mean the preferred form for making modifications,
27 | including but not limited to software source code, documentation
28 | source, and configuration files.
29 |
30 | "Object" form shall mean any form resulting from mechanical
31 | transformation or translation of a Source form, including but
32 | not limited to compiled object code, generated documentation,
33 | and conversions to other media types.
34 |
35 | "Work" shall mean the work of authorship, whether in Source or
36 | Object form, made available under the License, as indicated by a
37 | copyright notice that is included in or attached to the work
38 | (an example is provided in the Appendix below).
39 |
40 | "Derivative Works" shall mean any work, whether in Source or Object
41 | form, that is based on (or derived from) the Work and for which the
42 | editorial revisions, annotations, elaborations, or other modifications
43 | represent, as a whole, an original work of authorship. For the purposes
44 | of this License, Derivative Works shall not include works that remain
45 | separable from, or merely link (or bind by name) to the interfaces of,
46 | the Work and Derivative Works thereof.
47 |
48 | "Contribution" shall mean any work of authorship, including
49 | the original version of the Work and any modifications or additions
50 | to that Work or Derivative Works thereof, that is intentionally
51 | submitted to Licensor for inclusion in the Work by the copyright owner
52 | or by an individual or Legal Entity authorized to submit on behalf of
53 | the copyright owner. For the purposes of this definition, "submitted"
54 | means any form of electronic, verbal, or written communication sent
55 | to the Licensor or its representatives, including but not limited to
56 | communication on electronic mailing lists, source code control systems,
57 | and issue tracking systems that are managed by, or on behalf of, the
58 | Licensor for the purpose of discussing and improving the Work, but
59 | excluding communication that is conspicuously marked or otherwise
60 | designated in writing by the copyright owner as "Not a Contribution."
61 |
62 | "Contributor" shall mean Licensor and any individual or Legal Entity
63 | on behalf of whom a Contribution has been received by Licensor and
64 | subsequently incorporated within the Work.
65 |
66 | 2. Grant of Copyright License. Subject to the terms and conditions of
67 | this License, each Contributor hereby grants to You a perpetual,
68 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable
69 | copyright license to reproduce, prepare Derivative Works of,
70 | publicly display, publicly perform, sublicense, and distribute the
71 | Work and such Derivative Works in Source or Object form.
72 |
73 | 3. Grant of Patent License. Subject to the terms and conditions of
74 | this License, each Contributor hereby grants to You a perpetual,
75 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable
76 | (except as stated in this section) patent license to make, have made,
77 | use, offer to sell, sell, import, and otherwise transfer the Work,
78 | where such license applies only to those patent claims licensable
79 | by such Contributor that are necessarily infringed by their
80 | Contribution(s) alone or by combination of their Contribution(s)
81 | with the Work to which such Contribution(s) was submitted. If You
82 | institute patent litigation against any entity (including a
83 | cross-claim or counterclaim in a lawsuit) alleging that the Work
84 | or a Contribution incorporated within the Work constitutes direct
85 | or contributory patent infringement, then any patent licenses
86 | granted to You under this License for that Work shall terminate
87 | as of the date such litigation is filed.
88 |
89 | 4. Redistribution. You may reproduce and distribute copies of the
90 | Work or Derivative Works thereof in any medium, with or without
91 | modifications, and in Source or Object form, provided that You
92 | meet the following conditions:
93 |
94 | (a) You must give any other recipients of the Work or
95 | Derivative Works a copy of this License; and
96 |
97 | (b) You must cause any modified files to carry prominent notices
98 | stating that You changed the files; and
99 |
100 | (c) You must retain, in the Source form of any Derivative Works
101 | that You distribute, all copyright, patent, trademark, and
102 | attribution notices from the Source form of the Work,
103 | excluding those notices that do not pertain to any part of
104 | the Derivative Works; and
105 |
106 | (d) If the Work includes a "NOTICE" text file as part of its
107 | distribution, then any Derivative Works that You distribute must
108 | include a readable copy of the attribution notices contained
109 | within such NOTICE file, excluding those notices that do not
110 | pertain to any part of the Derivative Works, in at least one
111 | of the following places: within a NOTICE text file distributed
112 | as part of the Derivative Works; within the Source form or
113 | documentation, if provided along with the Derivative Works; or,
114 | within a display generated by the Derivative Works, if and
115 | wherever such third-party notices normally appear. The contents
116 | of the NOTICE file are for informational purposes only and
117 | do not modify the License. You may add Your own attribution
118 | notices within Derivative Works that You distribute, alongside
119 | or as an addendum to the NOTICE text from the Work, provided
120 | that such additional attribution notices cannot be construed
121 | as modifying the License.
122 |
123 | You may add Your own copyright statement to Your modifications and
124 | may provide additional or different license terms and conditions
125 | for use, reproduction, or distribution of Your modifications, or
126 | for any such Derivative Works as a whole, provided Your use,
127 | reproduction, and distribution of the Work otherwise complies with
128 | the conditions stated in this License.
129 |
130 | 5. Submission of Contributions. Unless You explicitly state otherwise,
131 | any Contribution intentionally submitted for inclusion in the Work
132 | by You to the Licensor shall be under the terms and conditions of
133 | this License, without any additional terms or conditions.
134 | Notwithstanding the above, nothing herein shall supersede or modify
135 | the terms of any separate license agreement you may have executed
136 | with Licensor regarding such Contributions.
137 |
138 | 6. Trademarks. This License does not grant permission to use the trade
139 | names, trademarks, service marks, or product names of the Licensor,
140 | except as required for reasonable and customary use in describing the
141 | origin of the Work and reproducing the content of the NOTICE file.
142 |
143 | 7. Disclaimer of Warranty. Unless required by applicable law or
144 | agreed to in writing, Licensor provides the Work (and each
145 | Contributor provides its Contributions) on an "AS IS" BASIS,
146 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
147 | implied, including, without limitation, any warranties or conditions
148 | of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
149 | PARTICULAR PURPOSE. You are solely responsible for determining the
150 | appropriateness of using or redistributing the Work and assume any
151 | risks associated with Your exercise of permissions under this License.
152 |
153 | 8. Limitation of Liability. In no event and under no legal theory,
154 | whether in tort (including negligence), contract, or otherwise,
155 | unless required by applicable law (such as deliberate and grossly
156 | negligent acts) or agreed to in writing, shall any Contributor be
157 | liable to You for damages, including any direct, indirect, special,
158 | incidental, or consequential damages of any character arising as a
159 | result of this License or out of the use or inability to use the
160 | Work (including but not limited to damages for loss of goodwill,
161 | work stoppage, computer failure or malfunction, or any and all
162 | other commercial damages or losses), even if such Contributor
163 | has been advised of the possibility of such damages.
164 |
165 | 9. Accepting Warranty or Additional Liability. While redistributing
166 | the Work or Derivative Works thereof, You may choose to offer,
167 | and charge a fee for, acceptance of support, warranty, indemnity,
168 | or other liability obligations and/or rights consistent with this
169 | License. However, in accepting such obligations, You may act only
170 | on Your own behalf and on Your sole responsibility, not on behalf
171 | of any other Contributor, and only if You agree to indemnify,
172 | defend, and hold each Contributor harmless for any liability
173 | incurred by, or claims asserted against, such Contributor by reason
174 | of your accepting any such warranty or additional liability.
175 |
176 | END OF TERMS AND CONDITIONS
177 |
178 | APPENDIX: How to apply the Apache License to your work.
179 |
180 | To apply the Apache License to your work, attach the following
181 | boilerplate notice, with the fields enclosed by brackets "[]"
182 | replaced with your own identifying information. (Don't include
183 | the brackets!) The text should be enclosed in the appropriate
184 | comment syntax for the file format. We also recommend that a
185 | file or class name and description of purpose be included on the
186 | same "printed page" as the copyright notice for easier
187 | identification within third-party archives.
188 |
189 | Copyright [yyyy] [name of copyright owner]
190 |
191 | Licensed under the Apache License, Version 2.0 (the "License");
192 | you may not use this file except in compliance with the License.
193 | You may obtain a copy of the License at
194 |
195 | http://www.apache.org/licenses/LICENSE-2.0
196 |
197 | Unless required by applicable law or agreed to in writing, software
198 | distributed under the License is distributed on an "AS IS" BASIS,
199 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
200 | See the License for the specific language governing permissions and
201 | limitations under the License.
202 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # ⚠️ Notice: GW4Remap Project Status -> See https://github.com/BigBoot/GW4Remap/issues/24 ⚠️
2 |
3 | # GW4 Remap
4 |
5 | GW4 Remap allows you remap the hardware buttons on the Galaxy Watch 4.
6 |
7 | ## Installation
8 |
9 | TBD
10 |
11 |
12 | ## Usage
13 |
14 | | First launch setup | |
15 | | -------------------- | ----------------------------------------------------------- |
16 | |  | Press the switch to start the setup |
17 | |  | Select `Installed services` |
18 | |  | Select `GW4 Remap` |
19 | |  | Enable the Service |
20 | |  | Confirm |
21 | |  | Go back to the app and your should see the rules screen |
22 |
23 |
24 | | Creating rules | |
25 | | --------------------- | ------------------------------------------------------------------- |
26 | |  | Press the `+` button to create a new rule |
27 | |  | Press the bookmark icon next to the source input to select a source |
28 | |  | Select the source |
29 | |  | Do the same for the target |
30 |
31 |
32 | That's it. Your buttons should now be remapped.
33 |
34 |
35 | ## License
36 | [Apache License 2.0](https://choosealicense.com/licenses/apache-2.0/)
37 |
--------------------------------------------------------------------------------
/app/.gitignore:
--------------------------------------------------------------------------------
1 | /build
--------------------------------------------------------------------------------
/app/build.gradle.kts:
--------------------------------------------------------------------------------
1 | import com.android.build.gradle.internal.cxx.configure.gradleLocalProperties
2 |
3 | plugins {
4 | id("com.android.application")
5 | id("kotlin-android")
6 | id("com.google.devtools.ksp").version("1.6.10-1.0.2")
7 | }
8 |
9 | val properties = gradleLocalProperties(rootDir)
10 |
11 | android {
12 | compileSdk = 31
13 |
14 | defaultConfig {
15 | applicationId = "de.bigboot.gw4remap"
16 | minSdk = 30
17 | targetSdk = 31
18 | versionCode = 2001
19 | versionName = "2.0.0-alpha1"
20 |
21 | }
22 |
23 | signingConfigs {
24 | create("release") {
25 | storeType = properties.getProperty("signing.release.storeType", "PKCS12")
26 | storeFile = rootDir.resolve(properties.getProperty("signing.release.storeFile", "keystore.p12"))
27 | storePassword = properties.getProperty("signing.release.storePassword", "")
28 | keyAlias = properties.getProperty("signing.release.keyAlias", "")
29 | keyPassword = properties.getProperty("signing.release.keyPassword", "")
30 | }
31 | }
32 |
33 | buildTypes {
34 | release {
35 | isMinifyEnabled = true
36 | proguardFiles(getDefaultProguardFile("proguard-android-optimize.txt"), "proguard-rules.pro")
37 | signingConfig = signingConfigs["release"]
38 | }
39 | }
40 |
41 | buildFeatures {
42 | viewBinding = true
43 | }
44 | }
45 |
46 | dependencies {
47 | implementation("com.google.android.gms:play-services-wearable:17.1.0")
48 | implementation("androidx.core:core-ktx:1.8.0")
49 | implementation("androidx.wear:wear:1.2.0")
50 | implementation("androidx.percentlayout:percentlayout:1.0.0")
51 | implementation("androidx.legacy:legacy-support-v4:1.0.0")
52 | implementation("androidx.recyclerview:recyclerview:1.2.1")
53 | implementation("androidx.activity:activity-ktx:1.4.0")
54 | implementation("androidx.fragment:fragment-ktx:1.4.1")
55 | implementation("androidx.appcompat:appcompat:1.4.2")
56 | implementation("com.google.android.material:material:1.6.1")
57 | implementation("androidx.constraintlayout:constraintlayout:2.1.4")
58 | implementation("com.squareup.moshi:moshi-kotlin:1.13.0") {
59 | exclude("org.jetbrains.kotlin", "kotlin-reflect ")
60 | }
61 | ksp("com.squareup.moshi:moshi-kotlin-codegen:1.13.0")
62 | }
--------------------------------------------------------------------------------
/app/proguard-rules.pro:
--------------------------------------------------------------------------------
1 | # Add project specific ProGuard rules here.
2 | # You can control the set of applied configuration files using the
3 | # proguardFiles setting in build.gradle.kts.
4 | #
5 | # For more details, see
6 | # http://developer.android.com/guide/developing/tools/proguard.html
7 |
8 | # If your project uses WebView with JS, uncomment the following
9 | # and specify the fully qualified class name to the JavaScript interface
10 | # class:
11 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview {
12 | # public *;
13 | #}
14 |
15 | # Uncomment this to preserve the line number information for
16 | # debugging stack traces.
17 | #-keepattributes SourceFile,LineNumberTable
18 |
19 | # If you keep the line number information, uncomment this to
20 | # hide the original source file name.
21 | #-renamesourcefileattribute SourceFile
--------------------------------------------------------------------------------
/app/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
2 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
26 |
27 |
30 |
31 |
34 |
35 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
49 |
50 |
55 |
56 |
57 |
58 |
59 |
62 |
63 |
64 |
65 |
66 |
--------------------------------------------------------------------------------
/app/src/main/ic_launcher-playstore.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/BigBoot/GW4Remap/1aeb56267fbe4219b8c4296b7712a414737884f6/app/src/main/ic_launcher-playstore.png
--------------------------------------------------------------------------------
/app/src/main/kotlin/de/bigboot/watch4payswitch/AccessibilityService.kt:
--------------------------------------------------------------------------------
1 | package de.bigboot.gw4remap
2 |
3 | import android.accessibilityservice.AccessibilityService
4 | import android.content.Intent
5 | import android.os.VibrationEffect
6 | import android.os.Vibrator
7 | import android.util.Log
8 | import android.view.accessibility.AccessibilityEvent
9 | import androidx.core.content.getSystemService
10 | import kotlinx.coroutines.*
11 | import java.util.*
12 | import java.util.regex.Pattern
13 |
14 |
15 | class AccessibilityService : AccessibilityService() {
16 | private var rules: List = emptyList()
17 | private var rulesRevision: UUID = UUID.randomUUID()
18 |
19 | private var logcatWatcher: Job? = null
20 |
21 | override fun onServiceConnected() {
22 | super.onServiceConnected()
23 | Log.v(this::class.simpleName, "AccessibilityService connected")
24 |
25 | logcatWatcher = GlobalScope.launch(Dispatchers.IO) {
26 | Runtime.getRuntime()
27 | .exec(arrayOf("logcat", "-T", "1", "-b", "system", "-e", "stemPrimaryLongPress|powerLongPress"))
28 | .inputStream
29 | .use { reader ->
30 | Log.d(AccessibilityService::class.simpleName, "watching logcat started...")
31 | val buffer = ByteArray(1024 * 10) { 0 }
32 | while (true) {
33 | val read = reader.read(buffer, 0, buffer.size)
34 | if(read <= 0) break
35 |
36 | val line = String(buffer, 0, read)
37 | Log.d(AccessibilityService::class.simpleName, String(buffer, 0, read))
38 | when {
39 | line.contains("stemPrimaryLongPress") -> onActivitySource(ActivitySource.BUTTON_BACK_LONGPRESS)
40 | line.contains("powerLongPress") ->onActivitySource(ActivitySource.BUTTON_POWER_LONGPRESS)
41 | else -> {}
42 | }
43 | }
44 | Log.d(AccessibilityService::class.simpleName, "watching logcat exited...")
45 | }
46 | }
47 | }
48 |
49 | override fun onUnbind(intent: Intent?): Boolean {
50 | runBlocking { logcatWatcher?.cancelAndJoin() }
51 | Log.v(this::class.simpleName, "AccessibilityService disconnected")
52 | return super.onUnbind(intent)
53 | }
54 |
55 | override fun onInterrupt() {}
56 |
57 | override fun onAccessibilityEvent(event: AccessibilityEvent) {}
58 |
59 | private fun onActivitySource(source: ActivitySource) {
60 | getAppPreferences().let { prefs ->
61 | if(prefs.revision() != rulesRevision) {
62 | rulesRevision = prefs.revision()
63 | rules = prefs.getRules()
64 | }
65 | }
66 |
67 | val rule = rules.firstOrNull { it.enabled && it.source == source }
68 |
69 | if(rule != null)
70 | {
71 | getSystemService()?.vibrate(
72 | VibrationEffect.createPredefined(VibrationEffect.EFFECT_CLICK)
73 | )
74 | try {
75 | startActivity(Intent().apply {
76 | setClassName(rule.target.packageName, rule.target.activityName)
77 | action = rule.target.action
78 | flags = Intent.FLAG_ACTIVITY_NEW_TASK
79 | })
80 | } catch (ex: Throwable) {
81 | Log.w(AccessibilityService::class.simpleName, "Unable to start activity", ex)
82 | }
83 | }
84 | }
85 | }
86 |
--------------------------------------------------------------------------------
/app/src/main/kotlin/de/bigboot/watch4payswitch/ActivityRuleFragment.kt:
--------------------------------------------------------------------------------
1 | package de.bigboot.gw4remap
2 |
3 | import android.annotation.SuppressLint
4 | import android.app.Activity
5 | import android.content.Context
6 | import android.content.Intent
7 | import android.os.Bundle
8 | import androidx.fragment.app.Fragment
9 | import android.view.LayoutInflater
10 | import android.view.View
11 | import android.view.ViewGroup
12 | import androidx.activity.result.contract.ActivityResultContract
13 | import androidx.core.widget.doOnTextChanged
14 | import de.bigboot.gw4remap.databinding.FragmentActivityRuleBinding
15 | import java.lang.IndexOutOfBoundsException
16 | import java.util.*
17 |
18 | private const val ARG_RULE_ID = "RULE_ID"
19 |
20 | private abstract class SelectPredefined : ActivityResultContract() {
21 | override fun parseResult(resultCode: Int, intent: Intent?) : String? {
22 | if (resultCode != Activity.RESULT_OK) {
23 | return null
24 | }
25 | return intent?.getStringExtra(SelectPredefinedActivity.EXTRA_SELECTED_ACTIVITY) ?: ""
26 | }
27 | }
28 |
29 | private class SelectPredefinedTarget : SelectPredefined() {
30 | override fun createIntent(context: Context, input: Unit?) =
31 | Intent(context, SelectPredefinedActivity::class.java).apply {
32 | putExtra(SelectPredefinedActivity.EXTRA_ACTIVITY_TYPE, SelectPredefinedActivity.ActivityType.Target.name)
33 | }
34 | }
35 |
36 |
37 | class ActivityRuleFragment : Fragment() {
38 | var onDelete: (()->Unit)? = null
39 |
40 | private lateinit var ruleId: UUID
41 | private lateinit var binding: FragmentActivityRuleBinding
42 |
43 | private val selectPredefinedTarget = registerForActivityResult(SelectPredefinedTarget()) {
44 | it?.let {
45 | binding.texteditRuleTarget.setText(it)
46 | }
47 | }
48 |
49 | override fun onCreate(savedInstanceState: Bundle?) {
50 | super.onCreate(savedInstanceState)
51 | arguments?.let {
52 | ruleId = UUID.fromString(it.getString(ARG_RULE_ID))
53 | }
54 | }
55 |
56 | @SuppressLint("SetTextI18n")
57 | override fun onCreateView(
58 | inflater: LayoutInflater, container: ViewGroup?,
59 | savedInstanceState: Bundle?
60 | ): View {
61 | binding = FragmentActivityRuleBinding.inflate(inflater, container, false)
62 |
63 | val rule = context?.getAppPreferences()?.getRule(ruleId)
64 |
65 | if(rule != null)
66 | {
67 | binding.labelRuleSource.setText(rule.source.text)
68 | binding.texteditRuleTarget.setText("${rule.target.packageName}/${rule.target.activityName}/${rule.target.action}")
69 | binding.checkRuleEnabled.isChecked = rule.enabled
70 |
71 | binding.checkRuleEnabled.setOnCheckedChangeListener { _, _ -> saveRule() }
72 | binding.texteditRuleTarget.doOnTextChanged { _, _, _, _ -> saveRule() }
73 |
74 | binding.fabPredefinedTarget.setOnClickListener { selectPredefinedTarget.launch(null) }
75 | }
76 |
77 | return binding.root
78 | }
79 |
80 | private fun saveRule() {
81 |
82 | try {
83 | val rule = context?.getAppPreferences()?.getRule(ruleId)!!
84 | val (targetPackageName, targetActivityName, targetAction) = binding.texteditRuleTarget.text.toString()
85 | .split('/')
86 | .plus(arrayOf("",""))
87 | .take(3)
88 |
89 | context?.getAppPreferences()?.saveRule(rule.copy(
90 | source = rule.source,
91 | target = rule.target.copy(
92 | packageName = targetPackageName,
93 | activityName = targetActivityName,
94 | action = targetAction,
95 | ),
96 | enabled = binding.checkRuleEnabled.isChecked
97 | ))
98 | } catch (_: IndexOutOfBoundsException) {}
99 | }
100 |
101 | companion object {
102 | @JvmStatic
103 | fun newInstance(ruleId: UUID = UUID.randomUUID()) =
104 | ActivityRuleFragment().apply {
105 | arguments = Bundle().apply {
106 | putString(ARG_RULE_ID, ruleId.toString())
107 | }
108 | }
109 | }
110 | }
--------------------------------------------------------------------------------
/app/src/main/kotlin/de/bigboot/watch4payswitch/AppPreferences.kt:
--------------------------------------------------------------------------------
1 | package de.bigboot.gw4remap
2 |
3 | import android.content.Context
4 | import androidx.core.content.edit
5 | import com.squareup.moshi.*
6 | import com.squareup.moshi.kotlin.reflect.KotlinJsonAdapterFactory
7 | import java.lang.Exception
8 | import java.util.*
9 |
10 | @JsonClass(generateAdapter = true)
11 | data class ActivityTarget(val packageName: String, val activityName: String, val action: String? = null, val name: Int? = null)
12 |
13 | @JsonClass(generateAdapter = false)
14 | enum class ActivitySource(val text: Int)
15 | {
16 | BUTTON_POWER_LONGPRESS(R.string.source_power_longpress),
17 | BUTTON_BACK_LONGPRESS(R.string.source_back_longpress),
18 | }
19 |
20 | @JsonClass(generateAdapter = true)
21 | data class ActivityRule(val source: ActivitySource, val target: ActivityTarget, val id: UUID = UUID.randomUUID(), val enabled: Boolean = false)
22 |
23 | private val KEY_FILE = "settings"
24 | private val KEY_RULES = "rules"
25 | private val KEY_REVISION = "revision"
26 |
27 | class UuidJsonAdapter {
28 | @ToJson
29 | fun toJson(value: UUID?) = value?.toString()
30 |
31 | @FromJson
32 | fun fromJson(input: String): UUID = UUID.fromString(input)
33 | }
34 |
35 | class AppPreferences(context: Context) {
36 | private val sharedPrefs = context.getSharedPreferences(KEY_FILE, Context.MODE_PRIVATE)
37 | private val moshi = Moshi.Builder()
38 | .add(UuidJsonAdapter())
39 | .addLast(KotlinJsonAdapterFactory())
40 | .build()
41 |
42 | fun getRules(): List {
43 | return moshi
44 | .adapter>(
45 | Types.newParameterizedType(
46 | List::class.java,
47 | ActivityRule::class.java
48 | )
49 | )
50 | .lenient()
51 | .let {
52 | try {
53 | it.fromJson(sharedPrefs.getString(KEY_RULES, "[]") ?: "") ?: emptyList()
54 | } catch (ex: Exception) {
55 | emptyList()
56 | }
57 | }
58 | .toMutableList()
59 | .apply {
60 | if(size != 2 || none { it.source == ActivitySource.BUTTON_POWER_LONGPRESS } || none { it.source == ActivitySource.BUTTON_BACK_LONGPRESS }) {
61 | clear()
62 | add(ActivityRule(ActivitySource.BUTTON_POWER_LONGPRESS, PredefinedTargets.GOOGLE_ASSISTANT, enabled = true ))
63 | add(ActivityRule(ActivitySource.BUTTON_BACK_LONGPRESS, PredefinedTargets.GOOGLE_WALLET, enabled = true ))
64 | saveRules(this)
65 | }
66 | }
67 | }
68 |
69 | private fun saveRules(rules: List) {
70 | sharedPrefs.edit {
71 | putString(
72 | KEY_RULES, moshi
73 | .adapter>(
74 | Types.newParameterizedType(
75 | List::class.java,
76 | ActivityRule::class.java
77 | )
78 | )
79 | .toJson(rules)
80 | )
81 |
82 | putString(KEY_REVISION, moshi.adapter(UUID::class.java).toJson(UUID.randomUUID()))
83 | }
84 | }
85 |
86 | fun getRule(id: UUID): ActivityRule = getRules().find { it.id == id }
87 | ?: ActivityRule(ActivitySource.BUTTON_POWER_LONGPRESS, ActivityTarget("", ""), id)
88 |
89 | fun saveRule(rule: ActivityRule) {
90 | saveRules(getRules().filter { it.id != rule.id } + rule)
91 | }
92 |
93 | fun deleteRule(id: UUID) {
94 | saveRules(getRules().filter { it.id != id })
95 | }
96 |
97 | fun revision(): UUID = moshi.adapter(UUID::class.java)
98 | .lenient()
99 | .fromJson(sharedPrefs.getString(KEY_REVISION, UUID.randomUUID().toString()) ?: "{}")
100 | ?: UUID.randomUUID()
101 | }
102 |
103 | object PredefinedTargets {
104 | val GOOGLE_WALLET = ActivityTarget(
105 | "com.google.android.apps.walletnfcrel",
106 | "com.google.commerce.tapandpay.wear.cardlist.WalletThemedWearCardListActivity",
107 | name = R.string.target_google_wallet
108 | )
109 |
110 | val GOOGLE_ASSISTANT = ActivityTarget(
111 | "com.google.android.wearable.assistant",
112 | "com.google.android.wearable.assistant.MainActivity",
113 | action = "android.intent.action.ASSIST",
114 | name = R.string.target_google_assistant
115 | )
116 |
117 | val GOOGLE_ASSISTANT_GO = ActivityTarget(
118 | "com.google.android.apps.assistant",
119 | "com.google.android.apps.assistant.go.MainActivity",
120 | name = R.string.target_google_assistant_go
121 | )
122 |
123 | val ULTIMATE_ALEXA = ActivityTarget(
124 | "com.com.customsolutions.android.alexa",
125 | "com.customsolutions.android.alexa.MainActivity",
126 | name = R.string.target_ultimate_alexa
127 | )
128 |
129 | val ALL = listOf(GOOGLE_WALLET, GOOGLE_ASSISTANT, GOOGLE_ASSISTANT_GO, ULTIMATE_ALEXA)
130 | }
131 |
132 | fun Context.getAppPreferences() = AppPreferences(this)
--------------------------------------------------------------------------------
/app/src/main/kotlin/de/bigboot/watch4payswitch/MainActivity.kt:
--------------------------------------------------------------------------------
1 | package de.bigboot.gw4remap
2 |
3 | import android.content.Intent
4 | import android.os.Bundle
5 | import android.provider.Settings
6 | import android.view.View
7 | import androidx.fragment.app.FragmentActivity
8 | import de.bigboot.gw4remap.databinding.ActivityMainBinding
9 | import java.util.*
10 |
11 |
12 | class MainActivity : FragmentActivity() {
13 |
14 | private lateinit var binding: ActivityMainBinding
15 |
16 | override fun onCreate(savedInstanceState: Bundle?) {
17 | super.onCreate(savedInstanceState)
18 |
19 | binding = ActivityMainBinding.inflate(layoutInflater)
20 | setContentView(binding.root)
21 |
22 | binding.switchEnabled.setOnClickListener {
23 | openAccessibilitySettings()
24 | }
25 |
26 | for (rule in getAppPreferences().getRules()) {
27 | addRule(rule.id)
28 | }
29 | }
30 |
31 | override fun onResume() {
32 | super.onResume()
33 | updateServiceState()
34 | }
35 |
36 | private fun addRule(ruleID: UUID = UUID.randomUUID()) {
37 | supportFragmentManager.beginTransaction().apply {
38 | add(R.id.layout_rules, ActivityRuleFragment.newInstance(ruleID).also { fragment ->
39 | fragment.onDelete = {
40 | getAppPreferences().deleteRule(ruleID)
41 | supportFragmentManager.beginTransaction().apply {
42 | remove(fragment)
43 | }.commitNow()
44 | }
45 | })
46 | }.commitNow()
47 | }
48 |
49 |
50 | private fun updateServiceState() {
51 | val serviceEnabled = checkAccesibilityServiceEnabled()
52 |
53 | binding.switchEnabled.visibility = when {
54 | serviceEnabled -> View.GONE
55 | else -> View.VISIBLE
56 | }
57 |
58 | binding.scrollviewRules.visibility = when {
59 | serviceEnabled -> View.VISIBLE
60 | else -> View.GONE
61 | }
62 | }
63 |
64 | private fun checkAccesibilityServiceEnabled(): Boolean {
65 | return Settings.Secure
66 | .getString(this.contentResolver, Settings.Secure.ENABLED_ACCESSIBILITY_SERVICES)
67 | ?.contains("${packageName}/${AccessibilityService::class.qualifiedName}")
68 | ?: false
69 |
70 | }
71 |
72 | private fun openAccessibilitySettings() {
73 | startActivity(Intent(Settings.ACTION_ACCESSIBILITY_SETTINGS).apply {
74 | flags = Intent.FLAG_ACTIVITY_NEW_TASK
75 | })
76 | }
77 | }
--------------------------------------------------------------------------------
/app/src/main/kotlin/de/bigboot/watch4payswitch/SelectPredefinedActivity.kt:
--------------------------------------------------------------------------------
1 | package de.bigboot.gw4remap
2 |
3 | import android.app.Activity
4 | import android.content.Intent
5 | import android.graphics.Rect
6 | import androidx.appcompat.app.AppCompatActivity
7 | import android.os.Bundle
8 | import android.util.TypedValue
9 | import android.view.View
10 | import androidx.lifecycle.lifecycleScope
11 | import androidx.recyclerview.widget.RecyclerView
12 | import androidx.wear.widget.WearableLinearLayoutManager
13 | import de.bigboot.gw4remap.databinding.ActivitySelectPredefinedBinding
14 | import kotlinx.coroutines.Dispatchers
15 | import kotlinx.coroutines.launch
16 | import kotlinx.coroutines.withContext
17 |
18 | class SelectPredefinedActivity : AppCompatActivity() {
19 | enum class ActivityType { Source, Target }
20 |
21 | private lateinit var binding: ActivitySelectPredefinedBinding
22 | private lateinit var activityType: ActivityType
23 |
24 | override fun onCreate(savedInstanceState: Bundle?) {
25 | super.onCreate(savedInstanceState)
26 |
27 | activityType = ActivityType.valueOf(
28 | intent.getStringExtra(EXTRA_ACTIVITY_TYPE) ?: ActivityType.Source.name
29 | )
30 |
31 | binding = ActivitySelectPredefinedBinding.inflate(layoutInflater)
32 |
33 | binding.recyclerView.layoutManager = WearableLinearLayoutManager(this)
34 | binding.recyclerView.addItemDecoration(object : RecyclerView.ItemDecoration() {
35 | override fun getItemOffsets(
36 | outRect: Rect,
37 | view: View,
38 | parent: RecyclerView,
39 | state: RecyclerView.State
40 | ) {
41 | super.getItemOffsets(outRect, view, parent, state)
42 |
43 | val index = parent.getChildAdapterPosition(view)
44 | val count = parent.adapter?.itemCount?.minus(1) ?: 0
45 |
46 | if (index == 0) {
47 | outRect.top =
48 | TypedValue.applyDimension(
49 | TypedValue.COMPLEX_UNIT_DIP,
50 | 50.0f,
51 | resources.displayMetrics
52 | )
53 | .toInt()
54 | }
55 |
56 | if (index == count) {
57 | outRect.bottom =
58 | TypedValue.applyDimension(
59 | TypedValue.COMPLEX_UNIT_DIP,
60 | 50.0f,
61 | resources.displayMetrics
62 | )
63 | .toInt()
64 | }
65 | }
66 | })
67 | binding.recyclerView.adapter = SelectPredefinedAdapter(predefinedTargetItems()).apply {
68 | onItemSelected = {
69 | setResult(Activity.RESULT_OK, Intent().apply {
70 | putExtra(EXTRA_SELECTED_ACTIVITY, it.value)
71 | })
72 | finish()
73 | }
74 |
75 | if (activityType == ActivityType.Target) {
76 | loadAllApps(this)
77 | }
78 | }
79 |
80 |
81 | setContentView(binding.root)
82 | }
83 |
84 |
85 | private fun loadAllApps(targetAdapter: SelectPredefinedAdapter) {
86 | lifecycleScope.launch(Dispatchers.Default) {
87 | val targetIntent = Intent(Intent.ACTION_MAIN)
88 | .also { it.addCategory(Intent.CATEGORY_LAUNCHER) }
89 |
90 | val apps = packageManager.queryIntentActivities(targetIntent, 0)
91 | .map { resolveInfo ->
92 | val label = resolveInfo.loadLabel(packageManager)
93 |
94 | SelectPredefinedAdapter.Item(
95 | label.toString(),
96 | "${resolveInfo.activityInfo.packageName}/${resolveInfo.activityInfo.name}"
97 | )
98 | }
99 | .sortedBy { it.name }
100 |
101 | val predefinedAndApps = predefinedTargetItems() + apps
102 |
103 | withContext(Dispatchers.Main) {
104 | targetAdapter.items = predefinedAndApps
105 | }
106 | }
107 | }
108 |
109 | private fun predefinedTargetItems() = PredefinedTargets.ALL.map { target ->
110 | SelectPredefinedAdapter.Item(
111 | target.name?.let { getText(it).toString() } ?: "",
112 | "${target.packageName}/${target.activityName}/${target.action}")
113 | }
114 |
115 |
116 | companion object {
117 | val EXTRA_ACTIVITY_TYPE = "EXTRA_ACTIVITY_TYPE"
118 | val EXTRA_SELECTED_ACTIVITY = "EXTRA_SELECTED_ACTIVITY"
119 | }
120 | }
121 |
--------------------------------------------------------------------------------
/app/src/main/kotlin/de/bigboot/watch4payswitch/SelectPredefinedAdapter.kt:
--------------------------------------------------------------------------------
1 | package de.bigboot.gw4remap
2 |
3 | import android.annotation.SuppressLint
4 | import android.view.LayoutInflater
5 | import android.view.ViewGroup
6 | import androidx.recyclerview.widget.RecyclerView
7 | import de.bigboot.gw4remap.databinding.ActivitySelectPredefinedItemBinding
8 |
9 | class SelectPredefinedAdapter(items: List- ): RecyclerView.Adapter() {
10 | var items: List
- = items
11 | @SuppressLint("NotifyDataSetChanged")
12 | set(value) {
13 | field = value
14 | notifyDataSetChanged()
15 | }
16 |
17 | data class Item(val name: String, val value: String)
18 |
19 | var onItemSelected: ((item: Item)->Unit)? = null
20 |
21 | override fun onCreateViewHolder(
22 | parent: ViewGroup,
23 | viewType: Int
24 | ): ViewHolder {
25 | return ViewHolder(ActivitySelectPredefinedItemBinding.inflate(
26 | LayoutInflater.from(parent.context),
27 | parent,
28 | false
29 | ))
30 | }
31 |
32 | override fun onBindViewHolder(holder: ViewHolder, position: Int) {
33 | val item = items[position]
34 | val binding = holder.binding
35 |
36 | binding.text.text = item.name
37 | binding.root.setOnClickListener { onItemSelected?.invoke(item) }
38 | }
39 |
40 | override fun getItemCount(): Int = items.size
41 |
42 | class ViewHolder(val binding: ActivitySelectPredefinedItemBinding): RecyclerView.ViewHolder(binding.root)
43 | }
44 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/activity_select_predefined_item_background.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
-
4 |
5 |
6 |
7 |
8 |
9 |
10 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/ic_launcher_background.xml:
--------------------------------------------------------------------------------
1 |
2 |
8 |
10 |
11 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/ic_launcher_foreground.xml:
--------------------------------------------------------------------------------
1 |
6 |
12 |
18 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/ic_predefined.xml:
--------------------------------------------------------------------------------
1 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/ic_rule_add.xml:
--------------------------------------------------------------------------------
1 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/activity_main.xml:
--------------------------------------------------------------------------------
1 |
2 |
10 |
11 |
16 |
17 |
29 |
30 |
41 |
42 |
46 |
47 |
52 |
53 |
57 |
58 |
59 |
60 |
61 |
62 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/activity_select_predefined.xml:
--------------------------------------------------------------------------------
1 |
2 |
10 |
11 |
16 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/activity_select_predefined_item.xml:
--------------------------------------------------------------------------------
1 |
2 |
10 |
11 |
18 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/fragment_activity_rule.xml:
--------------------------------------------------------------------------------
1 |
2 |
12 |
13 |
27 |
28 |
38 |
39 |
50 |
51 |
67 |
68 |
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-anydpi-v26/ic_launcher.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-hdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/BigBoot/GW4Remap/1aeb56267fbe4219b8c4296b7712a414737884f6/app/src/main/res/mipmap-hdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-hdpi/ic_launcher_adaptive_back.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/BigBoot/GW4Remap/1aeb56267fbe4219b8c4296b7712a414737884f6/app/src/main/res/mipmap-hdpi/ic_launcher_adaptive_back.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-hdpi/ic_launcher_adaptive_fore.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/BigBoot/GW4Remap/1aeb56267fbe4219b8c4296b7712a414737884f6/app/src/main/res/mipmap-hdpi/ic_launcher_adaptive_fore.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-mdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/BigBoot/GW4Remap/1aeb56267fbe4219b8c4296b7712a414737884f6/app/src/main/res/mipmap-mdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-mdpi/ic_launcher_adaptive_back.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/BigBoot/GW4Remap/1aeb56267fbe4219b8c4296b7712a414737884f6/app/src/main/res/mipmap-mdpi/ic_launcher_adaptive_back.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-mdpi/ic_launcher_adaptive_fore.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/BigBoot/GW4Remap/1aeb56267fbe4219b8c4296b7712a414737884f6/app/src/main/res/mipmap-mdpi/ic_launcher_adaptive_fore.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/BigBoot/GW4Remap/1aeb56267fbe4219b8c4296b7712a414737884f6/app/src/main/res/mipmap-xhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xhdpi/ic_launcher_adaptive_back.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/BigBoot/GW4Remap/1aeb56267fbe4219b8c4296b7712a414737884f6/app/src/main/res/mipmap-xhdpi/ic_launcher_adaptive_back.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xhdpi/ic_launcher_adaptive_fore.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/BigBoot/GW4Remap/1aeb56267fbe4219b8c4296b7712a414737884f6/app/src/main/res/mipmap-xhdpi/ic_launcher_adaptive_fore.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/BigBoot/GW4Remap/1aeb56267fbe4219b8c4296b7712a414737884f6/app/src/main/res/mipmap-xxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxhdpi/ic_launcher_adaptive_back.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/BigBoot/GW4Remap/1aeb56267fbe4219b8c4296b7712a414737884f6/app/src/main/res/mipmap-xxhdpi/ic_launcher_adaptive_back.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxhdpi/ic_launcher_adaptive_fore.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/BigBoot/GW4Remap/1aeb56267fbe4219b8c4296b7712a414737884f6/app/src/main/res/mipmap-xxhdpi/ic_launcher_adaptive_fore.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/BigBoot/GW4Remap/1aeb56267fbe4219b8c4296b7712a414737884f6/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxxhdpi/ic_launcher_adaptive_back.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/BigBoot/GW4Remap/1aeb56267fbe4219b8c4296b7712a414737884f6/app/src/main/res/mipmap-xxxhdpi/ic_launcher_adaptive_back.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxxhdpi/ic_launcher_adaptive_fore.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/BigBoot/GW4Remap/1aeb56267fbe4219b8c4296b7712a414737884f6/app/src/main/res/mipmap-xxxhdpi/ic_launcher_adaptive_fore.png
--------------------------------------------------------------------------------
/app/src/main/res/values/dimens.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
7 | 0dp
8 |
9 |
14 | 5dp
15 |
--------------------------------------------------------------------------------
/app/src/main/res/values/strings.xml:
--------------------------------------------------------------------------------
1 |
2 | GW4 Remap
3 |
4 | GW4 Remap
5 | GW4 Remap Service
6 | GW4 Remap enabled
7 |
8 | Predefined targets
9 |
10 | Google Wallet
11 | Google Assistant
12 | Google Assistant Go
13 | Ultimate Alexa
14 |
15 | Power Button Long-Press
16 | Back Button Long-Press
17 |
18 | Source
19 | Target
20 |
--------------------------------------------------------------------------------
/app/src/main/res/xml/accessibility_service_config.xml:
--------------------------------------------------------------------------------
1 |
10 |
--------------------------------------------------------------------------------
/build.gradle.kts:
--------------------------------------------------------------------------------
1 | // Top-level build file where you can add configuration options common to all sub-projects/modules.
2 | buildscript {
3 | repositories {
4 | google()
5 | mavenCentral()
6 | }
7 | dependencies {
8 | classpath ("com.android.tools.build:gradle:7.2.1")
9 | classpath ("org.jetbrains.kotlin:kotlin-gradle-plugin:1.6.10")
10 |
11 | // NOTE: Do not place your application dependencies here; they belong
12 | // in the individual module build.gradle files
13 | }
14 | }
15 |
16 | task("clean") {
17 | delete(rootProject.buildDir)
18 | }
--------------------------------------------------------------------------------
/gradle.properties:
--------------------------------------------------------------------------------
1 | # Project-wide Gradle settings.
2 | # IDE (e.g. Android Studio) users:
3 | # Gradle settings configured through the IDE *will override*
4 | # any settings specified in this file.
5 | # For more details on how to configure your build environment visit
6 | # http://www.gradle.org/docs/current/userguide/build_environment.html
7 | # Specifies the JVM arguments used for the daemon process.
8 | # The setting is particularly useful for tweaking memory settings.
9 | org.gradle.jvmargs=-Xmx2048m -Dfile.encoding=UTF-8
10 | # When configured, Gradle will run in incubating parallel mode.
11 | # This option should only be used with decoupled projects. More details, visit
12 | # http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects
13 | # org.gradle.parallel=true
14 | # AndroidX package structure to make it clearer which packages are bundled with the
15 | # Android operating system, and which are packaged with your app"s APK
16 | # https://developer.android.com/topic/libraries/support-library/androidx-rn
17 | android.useAndroidX=true
18 | # Automatically convert third-party libraries to use AndroidX
19 | android.enableJetifier=true
20 | # Kotlin code style for this project: "official" or "obsolete":
21 | kotlin.code.style=official
--------------------------------------------------------------------------------
/gradle/wrapper/gradle-wrapper.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/BigBoot/GW4Remap/1aeb56267fbe4219b8c4296b7712a414737884f6/gradle/wrapper/gradle-wrapper.jar
--------------------------------------------------------------------------------
/gradle/wrapper/gradle-wrapper.properties:
--------------------------------------------------------------------------------
1 | #Thu Jun 16 19:36:23 CEST 2022
2 | distributionBase=GRADLE_USER_HOME
3 | distributionUrl=https\://services.gradle.org/distributions/gradle-7.4.2-bin.zip
4 | distributionPath=wrapper/dists
5 | zipStorePath=wrapper/dists
6 | zipStoreBase=GRADLE_USER_HOME
7 |
--------------------------------------------------------------------------------
/gradlew:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env sh
2 |
3 | #
4 | # Copyright 2015 the original author or authors.
5 | #
6 | # Licensed under the Apache License, Version 2.0 (the "License");
7 | # you may not use this file except in compliance with the License.
8 | # You may obtain a copy of the License at
9 | #
10 | # https://www.apache.org/licenses/LICENSE-2.0
11 | #
12 | # Unless required by applicable law or agreed to in writing, software
13 | # distributed under the License is distributed on an "AS IS" BASIS,
14 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 | # See the License for the specific language governing permissions and
16 | # limitations under the License.
17 | #
18 |
19 | ##############################################################################
20 | ##
21 | ## Gradle start up script for UN*X
22 | ##
23 | ##############################################################################
24 |
25 | # Attempt to set APP_HOME
26 | # Resolve links: $0 may be a link
27 | PRG="$0"
28 | # Need this for relative symlinks.
29 | while [ -h "$PRG" ] ; do
30 | ls=`ls -ld "$PRG"`
31 | link=`expr "$ls" : '.*-> \(.*\)$'`
32 | if expr "$link" : '/.*' > /dev/null; then
33 | PRG="$link"
34 | else
35 | PRG=`dirname "$PRG"`"/$link"
36 | fi
37 | done
38 | SAVED="`pwd`"
39 | cd "`dirname \"$PRG\"`/" >/dev/null
40 | APP_HOME="`pwd -P`"
41 | cd "$SAVED" >/dev/null
42 |
43 | APP_NAME="Gradle"
44 | APP_BASE_NAME=`basename "$0"`
45 |
46 | # Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
47 | DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'
48 |
49 | # Use the maximum available, or set MAX_FD != -1 to use that value.
50 | MAX_FD="maximum"
51 |
52 | warn () {
53 | echo "$*"
54 | }
55 |
56 | die () {
57 | echo
58 | echo "$*"
59 | echo
60 | exit 1
61 | }
62 |
63 | # OS specific support (must be 'true' or 'false').
64 | cygwin=false
65 | msys=false
66 | darwin=false
67 | nonstop=false
68 | case "`uname`" in
69 | CYGWIN* )
70 | cygwin=true
71 | ;;
72 | Darwin* )
73 | darwin=true
74 | ;;
75 | MINGW* )
76 | msys=true
77 | ;;
78 | NONSTOP* )
79 | nonstop=true
80 | ;;
81 | esac
82 |
83 | CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
84 |
85 |
86 | # Determine the Java command to use to start the JVM.
87 | if [ -n "$JAVA_HOME" ] ; then
88 | if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
89 | # IBM's JDK on AIX uses strange locations for the executables
90 | JAVACMD="$JAVA_HOME/jre/sh/java"
91 | else
92 | JAVACMD="$JAVA_HOME/bin/java"
93 | fi
94 | if [ ! -x "$JAVACMD" ] ; then
95 | die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
96 |
97 | Please set the JAVA_HOME variable in your environment to match the
98 | location of your Java installation."
99 | fi
100 | else
101 | JAVACMD="java"
102 | which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
103 |
104 | Please set the JAVA_HOME variable in your environment to match the
105 | location of your Java installation."
106 | fi
107 |
108 | # Increase the maximum file descriptors if we can.
109 | if [ "$cygwin" = "false" -a "$darwin" = "false" -a "$nonstop" = "false" ] ; then
110 | MAX_FD_LIMIT=`ulimit -H -n`
111 | if [ $? -eq 0 ] ; then
112 | if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then
113 | MAX_FD="$MAX_FD_LIMIT"
114 | fi
115 | ulimit -n $MAX_FD
116 | if [ $? -ne 0 ] ; then
117 | warn "Could not set maximum file descriptor limit: $MAX_FD"
118 | fi
119 | else
120 | warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT"
121 | fi
122 | fi
123 |
124 | # For Darwin, add options to specify how the application appears in the dock
125 | if $darwin; then
126 | GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\""
127 | fi
128 |
129 | # For Cygwin or MSYS, switch paths to Windows format before running java
130 | if [ "$cygwin" = "true" -o "$msys" = "true" ] ; then
131 | APP_HOME=`cygpath --path --mixed "$APP_HOME"`
132 | CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
133 |
134 | JAVACMD=`cygpath --unix "$JAVACMD"`
135 |
136 | # We build the pattern for arguments to be converted via cygpath
137 | ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null`
138 | SEP=""
139 | for dir in $ROOTDIRSRAW ; do
140 | ROOTDIRS="$ROOTDIRS$SEP$dir"
141 | SEP="|"
142 | done
143 | OURCYGPATTERN="(^($ROOTDIRS))"
144 | # Add a user-defined pattern to the cygpath arguments
145 | if [ "$GRADLE_CYGPATTERN" != "" ] ; then
146 | OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)"
147 | fi
148 | # Now convert the arguments - kludge to limit ourselves to /bin/sh
149 | i=0
150 | for arg in "$@" ; do
151 | CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -`
152 | CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option
153 |
154 | if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition
155 | eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"`
156 | else
157 | eval `echo args$i`="\"$arg\""
158 | fi
159 | i=`expr $i + 1`
160 | done
161 | case $i in
162 | 0) set -- ;;
163 | 1) set -- "$args0" ;;
164 | 2) set -- "$args0" "$args1" ;;
165 | 3) set -- "$args0" "$args1" "$args2" ;;
166 | 4) set -- "$args0" "$args1" "$args2" "$args3" ;;
167 | 5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;;
168 | 6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;;
169 | 7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;;
170 | 8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;;
171 | 9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;;
172 | esac
173 | fi
174 |
175 | # Escape application args
176 | save () {
177 | for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done
178 | echo " "
179 | }
180 | APP_ARGS=`save "$@"`
181 |
182 | # Collect all arguments for the java command, following the shell quoting and substitution rules
183 | eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS"
184 |
185 | exec "$JAVACMD" "$@"
186 |
--------------------------------------------------------------------------------
/gradlew.bat:
--------------------------------------------------------------------------------
1 | @rem
2 | @rem Copyright 2015 the original author or authors.
3 | @rem
4 | @rem Licensed under the Apache License, Version 2.0 (the "License");
5 | @rem you may not use this file except in compliance with the License.
6 | @rem You may obtain a copy of the License at
7 | @rem
8 | @rem https://www.apache.org/licenses/LICENSE-2.0
9 | @rem
10 | @rem Unless required by applicable law or agreed to in writing, software
11 | @rem distributed under the License is distributed on an "AS IS" BASIS,
12 | @rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | @rem See the License for the specific language governing permissions and
14 | @rem limitations under the License.
15 | @rem
16 |
17 | @if "%DEBUG%" == "" @echo off
18 | @rem ##########################################################################
19 | @rem
20 | @rem Gradle startup script for Windows
21 | @rem
22 | @rem ##########################################################################
23 |
24 | @rem Set local scope for the variables with windows NT shell
25 | if "%OS%"=="Windows_NT" setlocal
26 |
27 | set DIRNAME=%~dp0
28 | if "%DIRNAME%" == "" set DIRNAME=.
29 | set APP_BASE_NAME=%~n0
30 | set APP_HOME=%DIRNAME%
31 |
32 | @rem Resolve any "." and ".." in APP_HOME to make it shorter.
33 | for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi
34 |
35 | @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
36 | set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m"
37 |
38 | @rem Find java.exe
39 | if defined JAVA_HOME goto findJavaFromJavaHome
40 |
41 | set JAVA_EXE=java.exe
42 | %JAVA_EXE% -version >NUL 2>&1
43 | if "%ERRORLEVEL%" == "0" goto execute
44 |
45 | echo.
46 | echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
47 | echo.
48 | echo Please set the JAVA_HOME variable in your environment to match the
49 | echo location of your Java installation.
50 |
51 | goto fail
52 |
53 | :findJavaFromJavaHome
54 | set JAVA_HOME=%JAVA_HOME:"=%
55 | set JAVA_EXE=%JAVA_HOME%/bin/java.exe
56 |
57 | if exist "%JAVA_EXE%" goto execute
58 |
59 | echo.
60 | echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
61 | echo.
62 | echo Please set the JAVA_HOME variable in your environment to match the
63 | echo location of your Java installation.
64 |
65 | goto fail
66 |
67 | :execute
68 | @rem Setup the command line
69 |
70 | set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
71 |
72 |
73 | @rem Execute Gradle
74 | "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %*
75 |
76 | :end
77 | @rem End local scope for the variables with windows NT shell
78 | if "%ERRORLEVEL%"=="0" goto mainEnd
79 |
80 | :fail
81 | rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
82 | rem the _cmd.exe /c_ return code!
83 | if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
84 | exit /b 1
85 |
86 | :mainEnd
87 | if "%OS%"=="Windows_NT" endlocal
88 |
89 | :omega
90 |
--------------------------------------------------------------------------------
/img/1.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/BigBoot/GW4Remap/1aeb56267fbe4219b8c4296b7712a414737884f6/img/1.png
--------------------------------------------------------------------------------
/img/10.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/BigBoot/GW4Remap/1aeb56267fbe4219b8c4296b7712a414737884f6/img/10.png
--------------------------------------------------------------------------------
/img/2.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/BigBoot/GW4Remap/1aeb56267fbe4219b8c4296b7712a414737884f6/img/2.png
--------------------------------------------------------------------------------
/img/3.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/BigBoot/GW4Remap/1aeb56267fbe4219b8c4296b7712a414737884f6/img/3.png
--------------------------------------------------------------------------------
/img/4.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/BigBoot/GW4Remap/1aeb56267fbe4219b8c4296b7712a414737884f6/img/4.png
--------------------------------------------------------------------------------
/img/5.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/BigBoot/GW4Remap/1aeb56267fbe4219b8c4296b7712a414737884f6/img/5.png
--------------------------------------------------------------------------------
/img/6.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/BigBoot/GW4Remap/1aeb56267fbe4219b8c4296b7712a414737884f6/img/6.png
--------------------------------------------------------------------------------
/img/7.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/BigBoot/GW4Remap/1aeb56267fbe4219b8c4296b7712a414737884f6/img/7.png
--------------------------------------------------------------------------------
/img/8.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/BigBoot/GW4Remap/1aeb56267fbe4219b8c4296b7712a414737884f6/img/8.png
--------------------------------------------------------------------------------
/img/9.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/BigBoot/GW4Remap/1aeb56267fbe4219b8c4296b7712a414737884f6/img/9.png
--------------------------------------------------------------------------------
/settings.gradle.kts:
--------------------------------------------------------------------------------
1 | dependencyResolutionManagement {
2 | repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
3 | repositories {
4 | google()
5 | mavenCentral()
6 | }
7 | }
8 | rootProject.name = "GW4 Remap"
9 | include(":app")
10 |
--------------------------------------------------------------------------------