Bug 859212 - Part 1: Move AwesomeBar's Swype logic to InputMethods. r=jchen

This commit is contained in:
Chris Peterson 2013-04-04 23:05:48 -07:00
Родитель 3f4d6127cb
Коммит 69a9fc167c
2 изменённых файлов: 13 добавлений и 16 удалений

Просмотреть файл

@ -45,17 +45,10 @@ import android.widget.TabWidget;
import android.widget.Toast;
import java.net.URLEncoder;
import java.util.Arrays;
import java.util.Collection;
public class AwesomeBar extends GeckoActivity {
private static final String LOGTAG = "GeckoAwesomeBar";
private static final Collection<String> sSwypeInputMethods = Arrays.asList(new String[] {
InputMethods.METHOD_SWYPE,
InputMethods.METHOD_SWYPE_BETA,
});
public static final String URL_KEY = "url";
public static final String CURRENT_URL_KEY = "currenturl";
public static final String TARGET_KEY = "target";
@ -70,7 +63,7 @@ public class AwesomeBar extends GeckoActivity {
private CustomEditText mText;
private ImageButton mGoButton;
private ContextMenuSubject mContextMenuSubject;
private boolean mIsUsingSwype;
private boolean mIsUsingGestureKeyboard;
private boolean mDelayRestartInput;
@Override
@ -297,17 +290,15 @@ public class AwesomeBar extends GeckoActivity {
if (!hasFocus)
return;
boolean wasUsingSwype = mIsUsingSwype;
mIsUsingSwype = sSwypeInputMethods.contains(InputMethods.getCurrentInputMethod(this));
if (mIsUsingSwype == wasUsingSwype)
boolean wasUsingGestureKeyboard = mIsUsingGestureKeyboard;
mIsUsingGestureKeyboard = InputMethods.isGestureKeyboard(this);
if (mIsUsingGestureKeyboard == wasUsingGestureKeyboard)
return;
int currentInputType = mText.getInputType();
int newInputType = mIsUsingSwype
? (currentInputType & ~InputType.TYPE_TEXT_VARIATION_URI) // URL=OFF
: (currentInputType | InputType.TYPE_TEXT_VARIATION_URI); // URL=ON
int newInputType = mIsUsingGestureKeyboard
? (currentInputType & ~InputType.TYPE_TEXT_VARIATION_URI) // Text mode
: (currentInputType | InputType.TYPE_TEXT_VARIATION_URI); // URL mode
mText.setRawInputType(newInputType);
}

Просмотреть файл

@ -99,4 +99,10 @@ final class InputMethods {
return METHOD_SAMSUNG.equals(inputMethod) ||
METHOD_SWIFTKEY.equals(inputMethod);
}
public static boolean isGestureKeyboard(Context context) {
String inputMethod = getCurrentInputMethod(context);
return METHOD_SWYPE.equals(inputMethod) ||
METHOD_SWYPE_BETA.equals(inputMethod);
}
}