use of android.widget.TextView.OnEditorActionListener in project androidannotations by androidannotations.
the class EditorActionsActivityTest method testActionHandled.
@Test
public void testActionHandled() {
assertThat(activity.actionHandled).isFalse();
EditText editText = (EditText) activity.findViewById(R.id.editText1);
OnEditorActionListener listener = getOnEditorActionListener(editText);
listener.onEditorAction(editText, 0, null);
assertThat(activity.actionHandled).isTrue();
}
use of android.widget.TextView.OnEditorActionListener in project androidannotations by androidannotations.
the class EditorActionsActivityTest method testEditTextPassed.
@Test
public void testEditTextPassed() {
assertThat(activity.passedEditText).isNull();
EditText editText = (EditText) activity.findViewById(R.id.editText4);
OnEditorActionListener listener = getOnEditorActionListener(editText);
listener.onEditorAction(editText, 0, null);
assertThat(activity.passedEditText).isSameAs(editText);
}
use of android.widget.TextView.OnEditorActionListener in project androidannotations by androidannotations.
the class EditorActionsActivityTest method testActionIdPassed.
@Test
public void testActionIdPassed() {
assertThat(activity.actionId).isZero();
EditText editText = (EditText) activity.findViewById(R.id.editText2);
OnEditorActionListener listener = getOnEditorActionListener(editText);
int actionId = 2;
listener.onEditorAction(editText, actionId, null);
assertThat(activity.actionId).isEqualTo(actionId);
}
use of android.widget.TextView.OnEditorActionListener in project storymaker by StoryMaker.
the class CacheWordActivity method requestPassphrase.
private void requestPassphrase() {
mViewCreatePin.setVisibility(View.GONE);
mViewEnterPin.setVisibility(View.VISIBLE);
mButton = (Button) findViewById(R.id.btnOpen);
mButton.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
if (mTextEnterPin.getText().toString().length() == 0)
return;
// Check passphrase
try {
if (mNotif == null) {
Timber.d("no handler notification");
// only display notification if the user has set a pin
SharedPreferences sp = getSharedPreferences("appPrefs", MODE_PRIVATE);
String cachewordStatus = sp.getString("cacheword_status", "default");
if (cachewordStatus.equals(BaseActivity.CACHEWORD_SET)) {
Timber.d("pin set, so display notification (cacheword)");
mNotif = buildNotification(CacheWordActivity.this);
mCacheWordHandler.setNotification(mNotif);
} else {
Timber.d("no pin set, so no notification (cacheword)");
}
Timber.d("set handler notification?");
} else {
Timber.d("handler has a notification");
}
mCacheWordHandler.setPassphrase(mTextEnterPin.getText().toString().toCharArray());
Timber.d("verified pin (request)");
} catch (GeneralSecurityException gse) {
mTextEnterPin.setText("");
Log.e("CacheWordActivity", "failed to verify pin (request): " + gse.getMessage());
return;
}
}
});
mTextEnterPin.setOnEditorActionListener(new OnEditorActionListener() {
@Override
public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {
if (actionId == EditorInfo.IME_NULL || actionId == EditorInfo.IME_ACTION_GO) {
InputMethodManager imm = (InputMethodManager) getSystemService(INPUT_METHOD_SERVICE);
Handler threadHandler = new Handler();
imm.hideSoftInputFromWindow(v.getWindowToken(), 0, new ResultReceiver(threadHandler) {
@Override
protected void onReceiveResult(int resultCode, Bundle resultData) {
super.onReceiveResult(resultCode, resultData);
mButton.performClick();
}
});
return true;
}
return false;
}
});
}
use of android.widget.TextView.OnEditorActionListener in project storymaker by StoryMaker.
the class CacheWordActivity method createPassphrase.
private void createPassphrase() {
mViewCreatePin.setVisibility(View.VISIBLE);
mViewEnterPin.setVisibility(View.GONE);
mTextCreatePin.setOnEditorActionListener(new OnEditorActionListener() {
@Override
public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {
if (actionId == EditorInfo.IME_NULL || actionId == EditorInfo.IME_ACTION_DONE) {
if (!isPasswordValid())
showValidationError();
else
mSlider.showConfirmationField();
}
return false;
}
});
mTextConfirmPin.setOnEditorActionListener(new OnEditorActionListener() {
@Override
public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {
if (actionId == EditorInfo.IME_NULL || actionId == EditorInfo.IME_ACTION_DONE) {
if (!newEqualsConfirmation()) {
showInequalityError();
mSlider.showNewPasswordField();
}
}
return false;
}
});
Button btnCreate = (Button) findViewById(R.id.btnCreate);
btnCreate.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
// validate pin
if (!isPasswordValid()) {
showValidationError();
mSlider.showNewPasswordField();
} else if (isConfirmationFieldEmpty()) {
mSlider.showConfirmationField();
} else if (!newEqualsConfirmation()) {
showInequalityError();
mSlider.showNewPasswordField();
} else {
try {
CharSequence defaultPinSequence = getText(R.string.cacheword_default_pin);
char[] defaultPin = defaultPinSequence.toString().toCharArray();
PassphraseSecrets secrets = PassphraseSecrets.fetchSecrets(CacheWordActivity.this, defaultPin);
mCacheWordHandler.changePassphrase(secrets, mTextCreatePin.getText().toString().toCharArray());
Timber.d("replaced default pin");
// moving this code here to prevent accidental locks
// set status to prevent use of default pin
SharedPreferences sp = getSharedPreferences("appPrefs", Context.MODE_PRIVATE);
SharedPreferences.Editor e = sp.edit();
e.putString("cacheword_status", BaseActivity.CACHEWORD_SET);
e.commit();
// changePassphrase does not seem to trigger this so it is called manually
onCacheWordOpened();
} catch (GeneralSecurityException gse1) {
Log.e("CacheWordActivity", "failed to replace default pin: " + gse1.getMessage());
try {
mCacheWordHandler.setPassphrase(mTextCreatePin.getText().toString().toCharArray());
Timber.d("created new pin (create)");
} catch (GeneralSecurityException gse2) {
Log.e("CacheWordActivity", "failed to create new pin (create): " + gse2.getMessage());
}
} catch (IOException ioe) {
Log.e("CacheWordActivity", "unexpected exception: " + ioe.getMessage());
}
}
}
});
}
Aggregations