Skip to content

Commit

Permalink
Long press of enter key launches emoji keyboard
Browse files Browse the repository at this point in the history
  • Loading branch information
Danation committed Feb 16, 2014
1 parent eeca612 commit d8a7ce9
Show file tree
Hide file tree
Showing 3 changed files with 64 additions and 3 deletions.
Binary file added ReleaseAPK/SwypeTweaks_1_0_3(beta).apk
Binary file not shown.
4 changes: 2 additions & 2 deletions Source/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.danation.xposed.swypetweaks"
android:versionCode="3"
android:versionName="1.02" >
android:versionCode="4"
android:versionName="1.03" >

<uses-sdk
android:minSdkVersion="15"
Expand Down
63 changes: 62 additions & 1 deletion Source/src/com/danation/xposed/swypetweaks/SwypeTweaks.java
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ public class SwypeTweaks implements IXposedHookLoadPackage
@Override
public void handleLoadPackage(LoadPackageParam lpparam) throws Throwable
{
final ClassLoader loader = lpparam.classLoader;
if (lpparam.packageName.contains("com.nuance.swype"))
{
log("Found Swype package: " + lpparam.packageName);
Expand Down Expand Up @@ -47,7 +48,7 @@ protected Object replaceHookedMethod(MethodHookParam param) throws Throwable
//Search list for the voice keyboard
for (InputMethodInfo info : inputMethodInfo)
{
// if (info.getId().contains("iwnnime"))
//"iwnnime" is emoji, for future use
if (info.getId().contains("googlequicksearchbox"))
{
inputId = info.getId();
Expand All @@ -74,6 +75,66 @@ protected Object replaceHookedMethod(MethodHookParam param) throws Throwable
return null;
}
});

Class<?> KeyClass = XposedHelpers.findClass("com.nuance.swype.input.KeyboardEx.Key", loader);
final int ENTER_CODE = 10;
XposedHelpers.findAndHookMethod("com.nuance.swype.input.KeyboardViewEx", lpparam.classLoader, "handleLongPress", KeyClass, new XC_MethodHook()
{
@Override
protected void beforeHookedMethod(MethodHookParam param) throws Throwable
{
log("before handleLongPress()");

int code = ((int[])XposedHelpers.getObjectField(param.args[0], "codes"))[0];

if (code != ENTER_CODE)
{
return;
}

//Get instance of com.nuance.swype.input.IME
Object mIme = XposedHelpers.getObjectField(param.thisObject, "mIme");
//Get mIme.myInputMethodImpl
Object mIme_myInputMethodImpl = XposedHelpers.getObjectField(mIme, "myInputMethodImpl");
//Get mIme.myInputMethodImpl.myToken (needed for switching input method)
IBinder mIme_myInputMethodImpl_myToken = (IBinder)XposedHelpers.getObjectField(mIme_myInputMethodImpl, "myToken");

InputMethodManager imm = (InputMethodManager)XposedHelpers.callMethod(mIme, "getSystemService", "input_method");

try
{
//Get list of all input methods
List<InputMethodInfo> inputMethodInfo = imm.getInputMethodList();
String inputId = null;

//Search list for the voice keyboard
for (InputMethodInfo info : inputMethodInfo)
{
if (info.getId().contains("iwnnime"))
{
inputId = info.getId();
break;
}
}

//If its found, launch it. Otherwise, show error message
if (inputId != null)
{
imm.setInputMethod(mIme_myInputMethodImpl_myToken, inputId);
}
else
{
log("Emoji input not found");
//showMessage("The Google Voice Recognition keyboard was not found", TODO context?);
}
}
catch (IllegalArgumentException ex)
{
//showMessage("An unexpected error occurred and was logged.", TODO context?);
log(ex);
}
}
});
}
catch (Exception ex)
{
Expand Down

0 comments on commit d8a7ce9

Please sign in to comment.