use of android.widget.TextView.OnEditorActionListener in project glitch-hq-android by tinyspeck.
the class ActivityDetailFragment method replyNotes.
private void replyNotes(EditText editor) {
editor.setImeActionLabel("Done", EditorInfo.IME_ACTION_DONE);
editor.setImeOptions(EditorInfo.IME_ACTION_DONE);
editor.setOnEditorActionListener(new OnEditorActionListener() {
public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {
if (actionId == EditorInfo.IME_NULL || actionId == EditorInfo.IME_ACTION_DONE) {
setStatusReply(m_currentActivity.playerID, m_currentActivity.id, v.getText().toString());
v.setText("");
InputMethodManager mgr = (InputMethodManager) getActivity().getSystemService(Context.INPUT_METHOD_SERVICE);
mgr.hideSoftInputFromWindow(v.getWindowToken(), 0);
return true;
}
return false;
}
});
}
use of android.widget.TextView.OnEditorActionListener in project glitch-hq-android by tinyspeck.
the class SnapDetailFragment method setSnapDetailView.
protected void setSnapDetailView(View root) {
OnClickListener lsn = new OnClickListener() {
public void onClick(View v) {
String playerId = (String) v.getTag();
ProfileFragment f = new ProfileFragment(m_this, playerId, true);
((HomeScreen) getActivity()).setCurrentFragment(f, true);
}
};
TextView ownerName = (TextView) root.findViewById(R.id.snap_owner_name);
ownerName.setTypeface(m_application.m_vagFont);
ownerName.setText(m_currentSnap.who);
ownerName.setTag(m_currentSnap.playerID);
ownerName.setOnClickListener(lsn);
ImageView goArrow = (ImageView) root.findViewById(R.id.snap_go_arrow);
goArrow.setTag(m_currentSnap.playerID);
goArrow.setOnClickListener(lsn);
ImageView snapPhoto = (ImageView) root.findViewById(R.id.snap_detail_photo);
m_application.Download(m_currentSnap.image, snapPhoto, MyApplication.DOWNLOAD_TYPE_NORMAL);
snapPhoto.setOnClickListener(new OnClickListener() {
public void onClick(View v) {
WebViewFragment f = new WebViewFragment(m_currentSnap.image_orig, "Snap", true);
((HomeScreen) getActivity()).setCurrentFragment(f, true);
}
});
TextView snapDetail = (TextView) root.findViewById(R.id.snap_detail_text);
snapDetail.setText(Html.fromHtml(m_currentSnap.what));
snapDetail.setVisibility((m_currentSnap.what != null && m_currentSnap.what.length() > 0) ? View.VISIBLE : View.GONE);
TextView snapTime = (TextView) root.findViewById(R.id.snap_detail_time);
snapTime.setTypeface(m_application.m_vagLightFont);
snapTime.setText(m_currentSnap.when);
if (!m_currentSnap.when.equalsIgnoreCase("just now"))
snapTime.setText(m_currentSnap.when + " ago");
else
snapTime.setText(m_currentSnap.when);
TextView snapViews = (TextView) root.findViewById(R.id.snap_detail_views);
snapViews.setTypeface(m_application.m_vagLightFont);
if (m_currentSnap.views == 1)
snapViews.setText(String.valueOf(m_currentSnap.views) + " view");
else
snapViews.setText(String.valueOf(m_currentSnap.views) + " views");
EditText snapCommentEditor = (EditText) root.findViewById(R.id.snap_comment_editor);
snapCommentEditor.setHint("Comment on " + m_currentSnap.who + "'s snap...");
snapCommentEditor.setImeActionLabel("Done", EditorInfo.IME_ACTION_DONE);
snapCommentEditor.setImeOptions(EditorInfo.IME_ACTION_DONE);
snapCommentEditor.setOnEditorActionListener(new OnEditorActionListener() {
public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {
if (actionId == EditorInfo.IME_NULL || actionId == EditorInfo.IME_ACTION_DONE) {
postSnapComment(v.getText().toString());
v.setText("");
InputMethodManager mgr = (InputMethodManager) getActivity().getSystemService(Context.INPUT_METHOD_SERVICE);
mgr.hideSoftInputFromWindow(v.getWindowToken(), 0);
}
return false;
}
});
LinearLayout snapCommentsView = (LinearLayout) root.findViewById(R.id.snap_comments_view);
if (m_currentSnap.comments != null && m_currentSnap.comments.size() > 0)
snapCommentsView.setVisibility(View.VISIBLE);
else
snapCommentsView.setVisibility(View.GONE);
}
use of android.widget.TextView.OnEditorActionListener in project android_frameworks_base by AOSPA.
the class CreateDirectoryFragment method onCreateDialog.
@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
final Context context = getActivity();
final ContentResolver resolver = context.getContentResolver();
final AlertDialog.Builder builder = new AlertDialog.Builder(context);
final LayoutInflater dialogInflater = LayoutInflater.from(builder.getContext());
final View view = dialogInflater.inflate(R.layout.dialog_file_name, null, false);
final EditText editText = (EditText) view.findViewById(android.R.id.text1);
builder.setTitle(R.string.menu_create_dir);
builder.setView(view);
builder.setPositiveButton(android.R.string.ok, new OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
createDirectory(editText.getText().toString());
}
});
builder.setNegativeButton(android.R.string.cancel, null);
final AlertDialog dialog = builder.create();
// Workaround for the problem - virtual keyboard doesn't show on the phone.
Shared.ensureKeyboardPresent(context, dialog);
editText.setOnEditorActionListener(new OnEditorActionListener() {
@Override
public boolean onEditorAction(TextView view, int actionId, @Nullable KeyEvent event) {
if ((actionId == EditorInfo.IME_ACTION_DONE) || (event != null && event.getKeyCode() == KeyEvent.KEYCODE_ENTER && event.hasNoModifiers())) {
createDirectory(editText.getText().toString());
dialog.dismiss();
return true;
}
return false;
}
});
return dialog;
}
use of android.widget.TextView.OnEditorActionListener in project KISS by Neamar.
the class MainActivity method onCreate.
/**
* Called when the activity is first created.
*/
@Override
public void onCreate(Bundle savedInstanceState) {
// Initialize UI
prefs = PreferenceManager.getDefaultSharedPreferences(this);
String theme = prefs.getString("theme", "light");
switch(theme) {
case "dark":
setTheme(R.style.AppThemeDark);
break;
case "transparent":
setTheme(R.style.AppThemeTransparent);
break;
case "semi-transparent":
setTheme(R.style.AppThemeSemiTransparent);
break;
case "semi-transparent-dark":
setTheme(R.style.AppThemeSemiTransparentDark);
break;
case "transparent-dark":
setTheme(R.style.AppThemeTransparentDark);
break;
}
super.onCreate(savedInstanceState);
IntentFilter intentFilter = new IntentFilter(START_LOAD);
IntentFilter intentFilterBis = new IntentFilter(LOAD_OVER);
IntentFilter intentFilterTer = new IntentFilter(FULL_LOAD_OVER);
mReceiver = new BroadcastReceiver() {
@Override
public void onReceive(Context context, Intent intent) {
if (intent.getAction().equalsIgnoreCase(LOAD_OVER)) {
updateRecords(searchEditText.getText().toString());
} else if (intent.getAction().equalsIgnoreCase(FULL_LOAD_OVER)) {
// Run GC once to free all the garbage accumulated during provider initialization
System.gc();
displayQuickFavoritesBar(true, false);
displayLoader(false);
} else if (intent.getAction().equalsIgnoreCase(START_LOAD)) {
displayLoader(true);
}
}
};
this.registerReceiver(mReceiver, intentFilter);
this.registerReceiver(mReceiver, intentFilterBis);
this.registerReceiver(mReceiver, intentFilterTer);
KissApplication.initDataHandler(this);
// Initialize preferences
PreferenceManager.setDefaultValues(this, R.xml.preferences, false);
prefs = PreferenceManager.getDefaultSharedPreferences(this);
// Do it here (before initializing the view) to make the transition as smooth as possible
if (prefs.getBoolean("force-portrait", true)) {
if (android.os.Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR2) {
setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_USER_PORTRAIT);
} else {
setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
}
} else {
setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_USER);
}
setContentView(R.layout.main);
this.list = (ListView) this.findViewById(android.R.id.list);
this.listContainer = (View) this.list.getParent();
this.listEmpty = this.findViewById(android.R.id.empty);
// Create adapter for records
this.adapter = new RecordAdapter(this, this, R.layout.item_app, new ArrayList<Result>());
this.list.setAdapter(this.adapter);
this.list.setOnItemClickListener(new AdapterView.OnItemClickListener() {
public void onItemClick(AdapterView<?> parent, View v, int position, long id) {
adapter.onClick(position, v);
}
});
this.adapter.registerDataSetObserver(new DataSetObserver() {
@Override
public void onChanged() {
super.onChanged();
if (adapter.isEmpty()) {
listContainer.setVisibility(View.GONE);
listEmpty.setVisibility(View.VISIBLE);
} else {
listContainer.setVisibility(View.VISIBLE);
listEmpty.setVisibility(View.GONE);
}
}
});
registerLongClickOnFavorites();
searchEditText = (EditText) findViewById(R.id.searchEditText);
// Listen to changes
searchEditText.addTextChangedListener(new TextWatcher() {
public void afterTextChanged(Editable s) {
// Auto left-trim text.
if (s.length() > 0 && s.charAt(0) == ' ')
s.delete(0, 1);
}
public void beforeTextChanged(CharSequence s, int start, int count, int after) {
}
public void onTextChanged(CharSequence s, int start, int before, int count) {
String text = s.toString();
adjustInputType(text);
updateRecords(text);
displayClearOnInput();
}
});
// On validate, launch first record
searchEditText.setOnEditorActionListener(new OnEditorActionListener() {
@Override
public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {
RecordAdapter adapter = ((RecordAdapter) list.getAdapter());
adapter.onClick(adapter.getCount() - 1, v);
return true;
}
});
kissBar = findViewById(R.id.main_kissbar);
favoritesKissBar = findViewById(R.id.favoritesKissBar);
menuButton = findViewById(R.id.menuButton);
registerForContextMenu(menuButton);
this.list.setLongClickable(true);
this.list.setOnItemLongClickListener(new AdapterView.OnItemLongClickListener() {
@Override
public boolean onItemLongClick(AdapterView<?> parent, View v, int pos, long id) {
((RecordAdapter) parent.getAdapter()).onLongClick(pos, v);
return true;
}
});
this.hider = new KeyboardScrollHider(this, (BlockableListView) this.list, (BottomPullEffectView) this.findViewById(R.id.listEdgeEffect));
this.hider.start();
// Check whether user enabled spell check and adjust input type accordingly
searchEditTextWorkaround = prefs.getBoolean("enable-keyboard-workaround", false);
adjustInputType(null);
//enable/disable phone/sms broadcast receiver
PackageManagerUtils.enableComponent(this, IncomingSmsHandler.class, prefs.getBoolean("enable-sms-history", false));
PackageManagerUtils.enableComponent(this, IncomingCallHandler.class, prefs.getBoolean("enable-phone-history", false));
// Hide the "X" after the text field, instead displaying the menu button
displayClearOnInput();
UiTweaks.updateThemePrimaryColor(this);
UiTweaks.tintResources(this);
}
use of android.widget.TextView.OnEditorActionListener in project android-bootstrap by AndroidBootstrap.
the class BootstrapAuthenticatorActivity method onCreate.
@Override
public void onCreate(Bundle bundle) {
super.onCreate(bundle);
BootstrapApplication.component().inject(this);
accountManager = AccountManager.get(this);
final Intent intent = getIntent();
email = intent.getStringExtra(PARAM_USERNAME);
authTokenType = intent.getStringExtra(PARAM_AUTHTOKEN_TYPE);
confirmCredentials = intent.getBooleanExtra(PARAM_CONFIRM_CREDENTIALS, false);
requestNewAccount = email == null;
setContentView(layout.login_activity);
ButterKnife.bind(this);
emailText.setAdapter(new ArrayAdapter<String>(this, simple_dropdown_item_1line, userEmailAccounts()));
passwordText.setOnKeyListener(new OnKeyListener() {
public boolean onKey(final View v, final int keyCode, final KeyEvent event) {
if (event != null && ACTION_DOWN == event.getAction() && keyCode == KEYCODE_ENTER && signInButton.isEnabled()) {
handleLogin(signInButton);
return true;
}
return false;
}
});
passwordText.setOnEditorActionListener(new OnEditorActionListener() {
public boolean onEditorAction(final TextView v, final int actionId, final KeyEvent event) {
if (actionId == IME_ACTION_DONE && signInButton.isEnabled()) {
handleLogin(signInButton);
return true;
}
return false;
}
});
emailText.addTextChangedListener(watcher);
passwordText.addTextChangedListener(watcher);
final TextView signUpText = (TextView) findViewById(id.tv_signup);
signUpText.setMovementMethod(LinkMovementMethod.getInstance());
signUpText.setText(Html.fromHtml(getString(string.signup_link)));
}
Aggregations