use of android.view.KeyEvent in project Android-Terminal-Emulator by jackpal.
the class FSNavigator method fileView.
////////////////////////////////////////////////////////////
private LinearLayout fileView(boolean entryWindow) {
LinearLayout ll = new LinearLayout(context);
ll.setLayoutParams(new LinearLayout.LayoutParams(LinearLayout.LayoutParams.FILL_PARENT, LinearLayout.LayoutParams.WRAP_CONTENT, 1));
ll.setOrientation(LinearLayout.HORIZONTAL);
ll.setGravity(android.view.Gravity.FILL);
final TextView tv;
if (entryWindow) {
tv = new EditText(context);
tv.setHint(getString(R.string.fsnavigator_optional_enter_path));
tv.setLayoutParams(new LinearLayout.LayoutParams(LinearLayout.LayoutParams.FILL_PARENT, LinearLayout.LayoutParams.FILL_PARENT, 2));
tv.setOnKeyListener(new EditText.OnKeyListener() {
public boolean onKey(View v, int keyCode, KeyEvent event) {
if (keyCode == KeyEvent.KEYCODE_ENTER) {
String path = tv.getText().toString();
File file = new File(getCanonicalPath(path));
chdir(file.getParentFile() == null ? file : file.getParentFile());
if (file.isFile()) {
setResult(RESULT_OK, getIntent().setData(Uri.fromFile(file)));
finish();
} else {
chdir(file);
makeView();
}
return (true);
}
return (false);
}
});
ll.addView(tv);
} else {
tv = new TextView(context);
tv.setClickable(true);
tv.setLongClickable(true);
tv.setOnClickListener(fileListener);
tv.setLayoutParams(new LinearLayout.LayoutParams(LinearLayout.LayoutParams.FILL_PARENT, LinearLayout.LayoutParams.FILL_PARENT, 1));
HorizontalScrollView hv = new HorizontalScrollView(context);
hv.setFillViewport(true);
hv.setLayoutParams(new LinearLayout.LayoutParams(LinearLayout.LayoutParams.FILL_PARENT, BUTTON_SIZE, 7));
hv.addView(tv);
ll.addView(hv);
}
tv.setFocusable(true);
tv.setSingleLine();
tv.setTextSize(textLg);
tv.setTypeface(Typeface.SERIF, Typeface.BOLD);
tv.setGravity(Gravity.CENTER_VERTICAL | Gravity.LEFT);
tv.setPadding(10, 5, 10, 5);
//1);
tv.setId(R.id.textview);
return (ll);
}
use of android.view.KeyEvent in project Android-Terminal-Emulator by jackpal.
the class TermKeyListenerTest method keyHelperToggle.
private void keyHelperToggle(int keycode, int metastate, byte[] expectedOutPut, boolean toggle) throws UnsupportedEncodingException, IOException {
KeyEvent event = new KeyEvent(1, 2, KeyEvent.ACTION_DOWN, keycode, 0, metastate);
tkl_AltNotEsc.keyDown(event.getKeyCode(), event, true, toggle);
byte[] res = mckTermSessionB.getCharSequence();
assertNotNull(res);
assertTrue(expectedOutPut.length <= res.length);
for (int i = 0; i < expectedOutPut.length; i++) {
assertEquals(expectedOutPut[i], res[i]);
}
}
use of android.view.KeyEvent in project MaterialSearchView by MiguelCatalan.
the class MaterialSearchView method initSearchView.
private void initSearchView() {
mSearchSrcTextView.setOnEditorActionListener(new TextView.OnEditorActionListener() {
@Override
public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {
onSubmitQuery();
return true;
}
});
mSearchSrcTextView.addTextChangedListener(new TextWatcher() {
@Override
public void beforeTextChanged(CharSequence s, int start, int count, int after) {
}
@Override
public void onTextChanged(CharSequence s, int start, int before, int count) {
mUserQuery = s;
startFilter(s);
MaterialSearchView.this.onTextChanged(s);
}
@Override
public void afterTextChanged(Editable s) {
}
});
mSearchSrcTextView.setOnFocusChangeListener(new OnFocusChangeListener() {
@Override
public void onFocusChange(View v, boolean hasFocus) {
if (hasFocus) {
showKeyboard(mSearchSrcTextView);
showSuggestions();
}
}
});
}
use of android.view.KeyEvent in project android-test-demo by abdyer.
the class LoginActivity method onCreate.
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_login);
DemoApplication.getInstance().getGraph().inject(this);
// Set up the login form.
mEmailView = (AutoCompleteTextView) findViewById(R.id.email);
populateAutoComplete();
mPasswordView = (EditText) findViewById(R.id.password);
mPasswordView.setOnEditorActionListener(new TextView.OnEditorActionListener() {
@Override
public boolean onEditorAction(TextView textView, int id, KeyEvent keyEvent) {
if (id == R.id.login || id == EditorInfo.IME_NULL) {
attemptLogin();
return true;
}
return false;
}
});
Button mEmailSignInButton = (Button) findViewById(R.id.email_sign_in_button);
mEmailSignInButton.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View view) {
attemptLogin();
}
});
mLoginFormView = findViewById(R.id.login_form);
mProgressView = findViewById(R.id.login_progress);
}
use of android.view.KeyEvent in project actor-platform by actorapp.
the class SignInFragment method initView.
private void initView(View v) {
ActorStyle style = ActorSDK.sharedActor().style;
TextView hint = (TextView) v.findViewById(R.id.sign_in_login_hint);
hint.setTextColor(style.getTextSecondaryColor());
signIdEditText = (EditText) v.findViewById(R.id.tv_sign_in);
signIdEditText.setTextColor(style.getTextPrimaryColor());
signIdEditText.setHighlightColor(style.getMainColor());
signIdEditText.setOnEditorActionListener(new TextView.OnEditorActionListener() {
@Override
public boolean onEditorAction(TextView textView, int id, KeyEvent keyEvent) {
if (id == EditorInfo.IME_ACTION_GO) {
requestCode();
return true;
}
return false;
}
});
int availableAuthType = ActorSDK.sharedActor().getAuthType();
String savedAuthId = messenger().getPreferences().getString("sign_in_auth_id");
signIdEditText.setText(savedAuthId);
boolean needSuggested = savedAuthId == null || savedAuthId.isEmpty();
if (((availableAuthType & AuthActivity.AUTH_TYPE_PHONE) == AuthActivity.AUTH_TYPE_PHONE) && ((availableAuthType & AuthActivity.AUTH_TYPE_EMAIL) == AuthActivity.AUTH_TYPE_EMAIL)) {
//both hints set phone + email by default
if (needSuggested) {
setSuggestedEmail(signIdEditText);
}
} else if ((availableAuthType & AuthActivity.AUTH_TYPE_PHONE) == AuthActivity.AUTH_TYPE_PHONE) {
hint.setText(getString(R.string.sign_in_hint_phone_only));
signIdEditText.setHint(getString(R.string.sign_in_edit_text_hint_phone_only));
signIdEditText.setInputType(EditorInfo.TYPE_CLASS_PHONE);
} else if ((availableAuthType & AuthActivity.AUTH_TYPE_EMAIL) == AuthActivity.AUTH_TYPE_EMAIL) {
hint.setText(getString(R.string.sign_in_hint_email_only));
signIdEditText.setHint(getString(R.string.sign_in_edit_text_hint_email_only));
if (needSuggested) {
setSuggestedEmail(signIdEditText);
}
}
Button singUp = (Button) v.findViewById(R.id.button_sign_up);
singUp.setTextColor(style.getTextSecondaryColor());
onClick(singUp, new View.OnClickListener() {
@Override
public void onClick(View v) {
startSignUp();
}
});
onClick(v, R.id.button_continue, new View.OnClickListener() {
@Override
public void onClick(View view) {
requestCode();
}
});
}
Aggregations