зеркало из https://github.com/mozilla/gecko-dev.git
Bug 859212 - Part 1: Move AwesomeBar's Swype logic to InputMethods. r=jchen
This commit is contained in:
Родитель
3f4d6127cb
Коммит
69a9fc167c
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
|
Загрузка…
Ссылка в новой задаче