Skip to content

Commit

Permalink
Added support for trial version of Swype. Added better logging and ex…
Browse files Browse the repository at this point in the history
…ception handling. Added APK archive
  • Loading branch information
Danation committed Feb 15, 2014
1 parent b790cb4 commit f544dd1
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 18 deletions.
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="1"
android:versionName="1.0" >
android:versionCode="2"
android:versionName="1.1" >

<uses-sdk
android:minSdkVersion="15"
Expand Down
46 changes: 30 additions & 16 deletions Source/src/com/danation/xposed/swypetweaks/SwypeTweaks.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,27 +5,41 @@
import de.robv.android.xposed.*;
import de.robv.android.xposed.callbacks.XC_LoadPackage.LoadPackageParam;

public class SwypeTweaks implements IXposedHookLoadPackage {
public class SwypeTweaks implements IXposedHookLoadPackage
{
@Override
public void handleLoadPackage(LoadPackageParam lpparam) throws Throwable {

public void handleLoadPackage(LoadPackageParam lpparam) throws Throwable
{
final ClassLoader loader = lpparam.classLoader;
final String logPrefix = "SwypeTweaks: ";

if (lpparam.packageName.equals("com.nuance.swype.dtc")) {
if (lpparam.packageName.equals("com.nuance.swype.dtc") ||
lpparam.packageName.equals("com.nuance.swype.trial"))
{
XposedBridge.log(logPrefix + "Found Swype package");

XposedHelpers.findAndHookMethod("com.nuance.swype.input.InputView", lpparam.classLoader,
"startSpeech", new XC_MethodReplacement() {
@Override
protected Object replaceHookedMethod(MethodHookParam param) throws Throwable
try
{
XposedHelpers.findAndHookMethod("com.nuance.swype.input.InputView", lpparam.classLoader, "startSpeech", new XC_MethodReplacement()
{
Object mIme = XposedHelpers.getObjectField(param.thisObject, "mIme");
Method mImeStartVoiceRecognition = XposedHelpers.findMethodExact("com.nuance.swype.input.IME", loader, "startVoiceRecognition", String.class);

mImeStartVoiceRecognition.invoke(mIme, "");

return null;
}
});
@Override
protected Object replaceHookedMethod(MethodHookParam param) throws Throwable
{
XposedBridge.log(logPrefix + "Replacing startSpeech() and calling startVoiceRecognition()");
Object mIme = XposedHelpers.getObjectField(param.thisObject, "mIme");
Method mImeStartVoiceRecognition = XposedHelpers.findMethodExact("com.nuance.swype.input.IME", loader, "startVoiceRecognition", String.class);

mImeStartVoiceRecognition.invoke(mIme, "");

return null;
}
});
}
catch (Exception ex)
{
XposedBridge.log(logPrefix + "SwypeTweaks: Caught Exception");
XposedBridge.log(ex);
}
}
}
}

0 comments on commit f544dd1

Please sign in to comment.