Skip to content
This repository was archived by the owner on Feb 1, 2020. It is now read-only.

Commit bc73168

Browse files
committed
Adding forward-delete
Also, bumping lots of stuff, and adding basic unit-tests Change-Id: Ica429030c1804f2ad40fb84e1215ae08a4fa80e1
1 parent 4f584fa commit bc73168

10 files changed

Lines changed: 102 additions & 9 deletions

File tree

api/build.gradle

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,17 +2,24 @@ apply plugin: 'com.android.library'
22

33
android {
44
compileSdkVersion 27
5-
buildToolsVersion '27.0.2'
5+
buildToolsVersion '27.0.3'
66

77
defaultConfig {
8-
minSdkVersion 7
8+
minSdkVersion 9
99
targetSdkVersion 27
10-
versionCode 8
11-
versionName "1.10.0"
10+
versionCode 9
11+
versionName "1.11.0"
1212
}
1313
buildTypes {
1414
release {
1515
minifyEnabled false
1616
}
1717
}
18+
19+
testOptions.unitTests.includeAndroidResources true
20+
}
21+
22+
dependencies {
23+
testImplementation 'org.robolectric:robolectric:3.8'
24+
testImplementation 'junit:junit:4.12'
1825
}

api/src/main/java/com/anysoftkeyboard/api/KeyCodes.java

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ public class KeyCodes {
99

1010
public static final int DELETE = -5;
1111
public static final int DELETE_WORD = -7;
12+
public static final int FORWARD_DELETE = -8;
1213

1314
public static final int QUICK_TEXT = -10;
1415
public static final int QUICK_TEXT_POPUP = -102;
@@ -59,4 +60,14 @@ public class KeyCodes {
5960

6061
public static final int UNDO = -136;
6162
public static final int REDO = -137;
63+
64+
public static final int IMAGE_MEDIA_POPUP = -140;
65+
66+
public static final int PRE_PREPARED_ABBREVIATIONS_POPUP = -150;
67+
public static final int PRE_PREPARED_TEXT_POPUP = -151;
68+
public static final int PRE_PREPARED_EMAILS_POPUP = -152;
69+
70+
public static final int EXTERNAL_INTEGRATION = -200;
71+
72+
6273
}

api/src/main/res/values/functional_key_codes.xml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
<?xml version="1.0" encoding="utf-8"?>
22
<resources xmlns:tools="http://schemas.android.com/tools" tools:ignore="UnusedResources">
3+
<integer name="key_code_disabled">0</integer>
4+
35
<integer name="key_code_esc">27</integer>
46
<integer name="key_code_tab">9</integer>
57

@@ -59,4 +61,5 @@
5961
<integer name="key_code_redo">-137</integer>
6062

6163
<integer name="key_code_delete_word">-7</integer>
64+
<integer name="key_code_forward_delete">-8</integer>
6265
</resources>

api/src/main/res/values/keyboard_theme_api.xml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -260,6 +260,8 @@
260260
<attr name="iconKeyUndo" format="reference"/>
261261
<!-- should support normal, key_type_feedback -->
262262
<attr name="iconKeyRedo" format="reference"/>
263+
<!-- should support normal, key_type_feedback -->
264+
<attr name="iconKeyForwardDelete" format="reference"/>
263265
</declare-styleable>
264266

265267
</resources>
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
<?xml version="1.0" encoding="utf-8"?>
22
<resources>
3-
<integer name="anysoftkeyboard_api_version_code">8</integer>
3+
<integer name="anysoftkeyboard_api_version_code">9</integer>
44
</resources>
Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
package com.anysoftkeyboard.api;
2+
3+
import android.content.res.Resources;
4+
5+
import org.junit.Assert;
6+
import org.junit.Test;
7+
import org.junit.runner.RunWith;
8+
import org.robolectric.RobolectricTestRunner;
9+
import org.robolectric.RuntimeEnvironment;
10+
11+
import java.lang.reflect.Field;
12+
import java.lang.reflect.Modifier;
13+
import java.util.HashSet;
14+
import java.util.function.BinaryOperator;
15+
import java.util.function.Function;
16+
17+
@RunWith(RobolectricTestRunner.class)
18+
public class KeyCodesTest {
19+
20+
@Test
21+
public void testVerifyKeyCodesHasUniques() throws Exception {
22+
HashSet<Integer> seenValues = new HashSet<>();
23+
24+
for (Field field : KeyCodes.class.getFields()) {
25+
final int intValue = (int) field.get(null/*This is a static field*/);
26+
Assert.assertTrue("Field " + field, seenValues.add(intValue));
27+
}
28+
29+
//verifying that the R integers match
30+
testVerifyKeyCodesResourcesHasUniques(seenValues);
31+
}
32+
33+
private void testVerifyKeyCodesResourcesHasUniques(HashSet<Integer> seenValues) throws Exception {
34+
Resources resources = RuntimeEnvironment.application.getResources();
35+
for (Field field : R.integer.class.getFields()) {
36+
if (field.getName().startsWith("key_code_")) {
37+
final int idValue = (int) field.get(null/*This is a static field*/);
38+
final int intValue = resources.getInteger(idValue);
39+
40+
Assert.assertTrue("Field " + field, seenValues.remove(intValue));
41+
}
42+
}
43+
44+
45+
Assert.assertEquals(
46+
seenValues.stream().map(new Function<Integer, String>() {
47+
@Override
48+
public String apply(Integer integer) {
49+
return integer.toString();
50+
}
51+
}).reduce(new BinaryOperator<String>() {
52+
@Override
53+
public String apply(String s, String s2) {
54+
return s + ", " + s2;
55+
}
56+
}).orElse("EMPTY"),
57+
0, seenValues.size());
58+
}
59+
60+
@Test
61+
public void testAllFieldsArePublicStaticFinalInt() {
62+
for (Field field : KeyCodes.class.getFields()) {
63+
Assert.assertEquals("Field " + field, Modifier.PUBLIC, field.getModifiers() & Modifier.PUBLIC);
64+
Assert.assertEquals("Field " + field, Modifier.STATIC, field.getModifiers() & Modifier.STATIC);
65+
Assert.assertEquals("Field " + field, Modifier.FINAL, field.getModifiers() & Modifier.FINAL);
66+
Assert.assertEquals("Field " + field, int.class, field.getType());
67+
}
68+
}
69+
}

build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ buildscript {
77
mavenCentral()
88
}
99
dependencies {
10-
classpath 'com.android.tools.build:gradle:3.1.0-alpha06'
10+
classpath 'com.android.tools.build:gradle:3.1.2'
1111
}
1212
}
1313

gradle.properties

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,4 +15,6 @@
1515
# When configured, Gradle will run in incubating parallel mode.
1616
# This option should only be used with decoupled projects. More details, visit
1717
# http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects
18-
# org.gradle.parallel=true
18+
# org.gradle.parallel=true
19+
org.gradle.configureondemand=false
20+
android.enableAapt2=false

gradle/wrapper/gradle-wrapper.jar

5 Bytes
Binary file not shown.
Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
1-
#Fri Dec 29 08:58:00 EST 2017
21
distributionBase=GRADLE_USER_HOME
32
distributionPath=wrapper/dists
43
zipStoreBase=GRADLE_USER_HOME
54
zipStorePath=wrapper/dists
6-
distributionUrl=https\://services.gradle.org/distributions/gradle-4.4-rc-3-all.zip
5+
distributionUrl=https\://services.gradle.org/distributions/gradle-4.7-bin.zip

0 commit comments

Comments
 (0)