Skip to content

Commit b440131

Browse files
author
sds100
committed
Merge branch 'develop' into release/1.1.2
# Conflicts: # app/build.gradle
2 parents 3df6e50 + b07b2ac commit b440131

File tree

10 files changed

+67
-16
lines changed

10 files changed

+67
-16
lines changed

app/proguard-rules.pro

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,3 +19,4 @@
1919
# If you keep the line number information, uncomment this to
2020
# hide the original source file name.
2121
#-renamesourcefileattribute SourceFile
22+
-keepclassmembers enum * { *; }

app/src/ci/res/values/strings.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
<?xml version="1.0" encoding="utf-8"?>
22
<resources>
33
<string name="app_name">Key Mapper CI</string>
4+
<string name="ime_service_label" translatable="false">Key Mapper CI Keyboard</string>
45
</resources>
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
<?xml version="1.0" encoding="utf-8"?>
22
<resources>
33
<string name="app_name">Key Mapper Debug</string>
4+
<string name="ime_service_label" translatable="false">Key Mapper Debug Keyboard</string>
45
</resources>

app/src/main/java/io/github/sds100/keymapper/KeyMap.kt

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -63,8 +63,6 @@ class KeyMap(
6363
}
6464

6565
fun containsTrigger(keyCodes: List<Int>): Boolean {
66-
return triggerList.any { trigger ->
67-
trigger.keys.toTypedArray().contentEquals(keyCodes.toTypedArray())
68-
}
66+
return triggerList.any { trigger -> keyCodes.containsAll(trigger.keys) }
6967
}
7068
}

app/src/main/java/io/github/sds100/keymapper/activity/IntroActivity.kt

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,13 @@
11
package io.github.sds100.keymapper.activity
22

3+
import android.Manifest
34
import android.content.Context
45
import android.content.Intent
56
import android.os.Build
67
import android.os.Bundle
78
import android.os.PowerManager
89
import android.provider.Settings
10+
import androidx.annotation.RequiresApi
911
import androidx.core.content.edit
1012
import com.heinrichreimersoftware.materialintro.app.IntroActivity
1113
import com.heinrichreimersoftware.materialintro.slide.SimpleSlide
@@ -14,13 +16,16 @@ import io.github.sds100.keymapper.Constants
1416
import io.github.sds100.keymapper.R
1517
import io.github.sds100.keymapper.util.DexUtils.isDexSupported
1618
import io.github.sds100.keymapper.util.FirebaseUtils
19+
import io.github.sds100.keymapper.util.PermissionUtils
20+
import io.github.sds100.keymapper.util.isPermissionGranted
1721
import io.github.sds100.keymapper.util.str
1822
import org.jetbrains.anko.defaultSharedPreferences
1923

2024
/**
2125
* Created by sds100 on 07/07/2019.
2226
*/
2327

28+
@RequiresApi(Build.VERSION_CODES.M)
2429
class IntroActivity : IntroActivity() {
2530

2631
companion object {
@@ -93,6 +98,23 @@ class IntroActivity : IntroActivity() {
9398
}.build()
9499
}
95100

101+
private val mDndAccessSlide: Slide by lazy {
102+
SimpleSlide.Builder().apply {
103+
title(R.string.showcase_dnd_access_title)
104+
description(R.string.showcase_dnd_access_description)
105+
background(R.color.red)
106+
backgroundDark(R.color.redDark)
107+
image(R.drawable.ic_do_not_disturb_white_64dp)
108+
canGoBackward(true)
109+
scrollable(true)
110+
111+
buttonCtaLabel(R.string.pos_grant)
112+
buttonCtaClickListener {
113+
PermissionUtils.requestPermission(this@IntroActivity, Manifest.permission.ACCESS_NOTIFICATION_POLICY)
114+
}
115+
}.build()
116+
}
117+
96118
private val currentSlide: Slide
97119
get() = getSlide(currentSlidePosition)
98120

@@ -115,6 +137,10 @@ class IntroActivity : IntroActivity() {
115137
}
116138

117139
addSlide(mDataCollectionSlide)
140+
141+
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
142+
addSlide(mDndAccessSlide)
143+
}
118144
}
119145

120146
override fun onResume() {
@@ -130,5 +156,10 @@ class IntroActivity : IntroActivity() {
130156
nextSlide()
131157
removeSlide(mBatteryOptimisationSlide)
132158
}
159+
160+
if (isPermissionGranted(Manifest.permission.ACCESS_NOTIFICATION_POLICY) && currentSlide == mDndAccessSlide) {
161+
nextSlide()
162+
removeSlide(mDndAccessSlide)
163+
}
133164
}
134165
}

app/src/main/java/io/github/sds100/keymapper/service/MyIMEService.kt

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,8 @@ import android.view.inputmethod.InputConnection
1212
import android.view.inputmethod.InputMethodManager
1313
import io.github.sds100.keymapper.Constants.PACKAGE_NAME
1414
import io.github.sds100.keymapper.Result
15-
import io.github.sds100.keymapper.R
1615
import io.github.sds100.keymapper.handle
1716
import io.github.sds100.keymapper.result
18-
import org.jetbrains.anko.toast
1917

2018
/**
2119
* Created by sds100 on 28/09/2018.
@@ -60,7 +58,8 @@ class MyIMEService : InputMethodService() {
6058
Settings.Secure.DEFAULT_INPUT_METHOD
6159
)
6260

63-
return chosenImeId.contains(PACKAGE_NAME)
61+
val imeManager = ctx.getSystemService(Context.INPUT_METHOD_SERVICE) as InputMethodManager
62+
return imeManager.inputMethodList.find { it.id == chosenImeId }?.packageName == PACKAGE_NAME
6463
}
6564
}
6665

app/src/main/java/io/github/sds100/keymapper/util/ErrorCodeUtils.kt

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -47,13 +47,13 @@ object ErrorCodeUtils {
4747
const val ERROR_CODE_SDK_VERSION_TOO_HIGH = 15
4848

4949
private val FIXABLE_ERRORS = arrayOf(
50-
ERROR_CODE_APP_DISABLED,
51-
ERROR_CODE_APP_UNINSTALLED,
52-
ERROR_CODE_PERMISSION_DENIED,
53-
ERROR_CODE_SHORTCUT_NOT_FOUND,
54-
ERROR_CODE_IME_SERVICE_NOT_CHOSEN,
55-
ERROR_CODE_IME_SERVICE_DISABLED,
56-
ERROR_CODE_GOOGLE_APP_NOT_INSTALLED
50+
ERROR_CODE_APP_DISABLED,
51+
ERROR_CODE_APP_UNINSTALLED,
52+
ERROR_CODE_PERMISSION_DENIED,
53+
ERROR_CODE_SHORTCUT_NOT_FOUND,
54+
ERROR_CODE_IME_SERVICE_NOT_CHOSEN,
55+
ERROR_CODE_IME_SERVICE_DISABLED,
56+
ERROR_CODE_GOOGLE_APP_NOT_INSTALLED
5757
)
5858

5959
/**
@@ -75,7 +75,13 @@ object ErrorCodeUtils {
7575

7676
ERROR_CODE_SHORTCUT_NOT_FOUND -> PackageUtils.viewAppOnline(ctx, errorResult.data!!)
7777

78-
ERROR_CODE_IME_SERVICE_NOT_CHOSEN -> KeyboardUtils.switchToKeyMapperIme(ctx)
78+
ERROR_CODE_IME_SERVICE_NOT_CHOSEN -> {
79+
if (ctx.haveWriteSecureSettingsPermission) {
80+
KeyboardUtils.switchToKeyMapperIme(ctx)
81+
} else {
82+
KeyboardUtils.showInputMethodPicker(ctx)
83+
}
84+
}
7985

8086
ERROR_CODE_IME_SERVICE_DISABLED -> KeyboardUtils.openImeSettings(ctx)
8187

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
<vector xmlns:android="http://schemas.android.com/apk/res/android"
2+
android:width="64dp"
3+
android:height="64dp"
4+
android:viewportWidth="24.0"
5+
android:viewportHeight="24.0">
6+
<path
7+
android:fillColor="#ffffff"
8+
android:pathData="M12,2C6.48,2 2,6.48 2,12s4.48,10 10,10 10,-4.48 10,-10S17.52,2 12,2zM17,13L7,13v-2h10v2z" />
9+
</vector>

app/src/main/res/values/strings.xml

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -132,6 +132,7 @@
132132
<string name="pos_opt_in">Opt in</string>
133133
<string name="pos_help_page">Help page</string>
134134
<string name="pos_enable_root_features">Enable root features</string>
135+
<string name="pos_grant">Grant</string>
135136

136137
<string name="neg_stay_out">Stay out</string>
137138
<string name="neg_no">No</string>
@@ -157,7 +158,7 @@
157158

158159
<string name="notification_action_open_app">Open App</string>
159160
<string name="notification_action_stop_acc_service">Stop Accessibility Service</string>
160-
161+
161162
<string name="notification_keyboard_hidden_title">Keyboard is hidden!</string>
162163
<string name="notification_keyboard_hidden_text">Tap to start showing the keyboard again.</string>
163164
<!-- Notification strings -->
@@ -265,6 +266,9 @@
265266

266267
<string name="showcase_data_collection_title">Anonymous analytics</string>
267268
<string name="showcase_data_collection_message">Do you want to allow Key Mapper to anonymously collect data about how it is used (e.g crash reports)? You have to opt in and the data is collected by Google Firebase. The privacy policy is located in the About activity. Click "opt in" to opt in. If you don\'t then you remain opted out.</string>
269+
270+
<string name="showcase_dnd_access_title">Do Not Disturb Access</string>
271+
<string name="showcase_dnd_access_description">The app needs Do Not Disturb access if you want actions which change the volume and remapped volume buttons to work while in Do Not Disturb mode.</string>
268272
<!-- Showcase -->
269273

270274
<!-- system action options -->

gradle.properties

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,4 +12,5 @@ org.gradle.jvmargs=-Xmx1536m
1212
# http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects
1313
# org.gradle.parallel=true
1414
android.useAndroidX=true
15-
android.enableJetifier=true
15+
android.enableJetifier=true
16+
android.enableR8=true

0 commit comments

Comments
 (0)