List of usage examples for android.text InputType TYPE_CLASS_TEXT
int TYPE_CLASS_TEXT
To view the source code for android.text InputType TYPE_CLASS_TEXT.
Click Source Link
From source file:com.velli.passwordmanager.FragmentPasswordDetails.java
@Override public boolean onOptionsItemSelected(MenuItem item) { switch (item.getItemId()) { case R.id.menu_starred: mEntry.setStarred(!mEntry.isStarred()); PasswordDatabaseHandler.getInstance().updatePassword(mEntry); getActivity().invalidateOptionsMenu(); return true; case R.id.menu_edit: edit();// w w w. j av a 2 s . com return true; case android.R.id.home: getActivity().getSupportFragmentManager().popBackStack(); return true; case R.id.menu_delete: new MaterialDialog.Builder(getActivity()).title(R.string.title_delete_password) .content(R.string.dialog_message_delete_password).positiveText(R.string.action_ok) .negativeText(R.string.action_cancel).onPositive(new MaterialDialog.SingleButtonCallback() { @Override public void onClick(@NonNull MaterialDialog materialDialog, @NonNull DialogAction dialogAction) { PasswordDatabaseHandler.getInstance().deletePassword(mEntryId); getActivity().getSupportFragmentManager().popBackStack(); } }).show(); return true; case R.id.menu_show_as_toolbar: showFloatingCard(); return true; case R.id.menu_open_web_page: showFloatingCard(); if (mEntry.getLoginIcon() == NavigationDrawerConstants.LABEL_APP) { openApp(getActivity(), mEntry.getAppPackageName()); } else { openWebPage(getActivity(), mEntry.getUrl()); } return true; case R.id.menu_share_email: sharePasswordEmail(); return true; case R.id.menu_view_hide_password: if (mPassword != null) { mPassword.setInputType(mShowingPassword ? InputType.TYPE_TEXT_VARIATION_PASSWORD : InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_VARIATION_PASSWORD); } else if (mCardCSV != null) { mCardCSV.setInputType(mShowingPassword ? InputType.TYPE_TEXT_VARIATION_PASSWORD : InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_VARIATION_PASSWORD); } mShowingPassword = !mShowingPassword; updateToolbarItems(); return true; case R.id.menu_share_screenshot: createScreenshot(); return true; } return super.onOptionsItemSelected(item); }
From source file:onion.chat.MainActivity.java
void changeContactName(final String address, final String name) { final FrameLayout view = new FrameLayout(this); final EditText editText = new EditText(this); editText.setImeOptions(EditorInfo.IME_FLAG_NO_EXTRACT_UI); editText.setSingleLine();/*from w ww.j ava2 s . com*/ editText.setInputType(InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_VARIATION_PERSON_NAME | InputType.TYPE_TEXT_FLAG_CAP_SENTENCES | InputType.TYPE_TEXT_FLAG_CAP_WORDS); view.addView(editText); int padding = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 8, getResources().getDisplayMetrics()); ; view.setPadding(padding, padding, padding, padding); editText.setText(name); new AlertDialog.Builder(this).setTitle(R.string.title_change_alias).setView(view) .setPositiveButton(R.string.apply, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { db.setContactName(address, editText.getText().toString()); update(); snack(getString(R.string.snack_alias_changed)); } }).setNegativeButton(R.string.cancel, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { } }).show(); }
From source file:paulscode.android.mupen64plusae.jni.CoreInterface.java
public static void saveFileFromPrompt() { CharSequence title = sActivity.getText(R.string.menuItem_fileSave); CharSequence hint = sActivity.getText(R.string.hintFileSave); int inputType = InputType.TYPE_CLASS_TEXT; Prompt.promptText(sActivity, title, null, null, hint, inputType, new PromptTextListener() { @Override//from www . ja va 2 s.co m public void onDialogClosed(CharSequence text, int which) { if (which == DialogInterface.BUTTON_POSITIVE) { saveState(text.toString()); } } }); }
From source file:org.telegram.ui.ChannelCreateActivity.java
@Override public View createView(Context context) { searching = false;/*from w ww . j a v a2 s . c om*/ searchWas = false; actionBar.setBackButtonImage(R.drawable.ic_ab_back); actionBar.setAllowOverlayTitle(true); actionBar.setActionBarMenuOnItemClick(new ActionBar.ActionBarMenuOnItemClick() { @Override public void onItemClick(int id) { if (id == -1) { finishFragment(); } else if (id == done_button) { if (currentStep == 0) { if (donePressed) { return; } if (nameTextView.length() == 0) { Vibrator v = (Vibrator) getParentActivity().getSystemService(Context.VIBRATOR_SERVICE); if (v != null) { v.vibrate(200); } AndroidUtilities.shakeView(nameTextView, 2, 0); return; } donePressed = true; if (avatarUpdater.uploadingAvatar != null) { createAfterUpload = true; progressDialog = new ProgressDialog(getParentActivity()); progressDialog.setMessage(LocaleController.getString("Loading", R.string.Loading)); progressDialog.setCanceledOnTouchOutside(false); progressDialog.setCancelable(false); progressDialog.setButton(DialogInterface.BUTTON_NEGATIVE, LocaleController.getString("Cancel", R.string.Cancel), new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { createAfterUpload = false; progressDialog = null; donePressed = false; try { dialog.dismiss(); } catch (Exception e) { FileLog.e("tmessages", e); } } }); progressDialog.show(); return; } final int reqId = MessagesController.getInstance().createChat( nameTextView.getText().toString(), new ArrayList<Integer>(), descriptionTextView.getText().toString(), ChatObject.CHAT_TYPE_CHANNEL, ChannelCreateActivity.this); progressDialog = new ProgressDialog(getParentActivity()); progressDialog.setMessage(LocaleController.getString("Loading", R.string.Loading)); progressDialog.setCanceledOnTouchOutside(false); progressDialog.setCancelable(false); progressDialog.setButton(DialogInterface.BUTTON_NEGATIVE, LocaleController.getString("Cancel", R.string.Cancel), new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { ConnectionsManager.getInstance().cancelRequest(reqId, true); donePressed = false; try { dialog.dismiss(); } catch (Exception e) { FileLog.e("tmessages", e); } } }); progressDialog.show(); } else if (currentStep == 1) { if (!isPrivate) { if (nameTextView.length() == 0) { AlertDialog.Builder builder = new AlertDialog.Builder(getParentActivity()); builder.setTitle(LocaleController.getString("AppName", R.string.AppName)); builder.setMessage(LocaleController.getString("ChannelPublicEmptyUsername", R.string.ChannelPublicEmptyUsername)); builder.setPositiveButton(LocaleController.getString("Close", R.string.Close), null); showDialog(builder.create()); return; } else { if (!lastNameAvailable) { Vibrator v = (Vibrator) getParentActivity() .getSystemService(Context.VIBRATOR_SERVICE); if (v != null) { v.vibrate(200); } AndroidUtilities.shakeView(checkTextView, 2, 0); return; } else { MessagesController.getInstance().updateChannelUserName(chatId, lastCheckName); } } } Bundle args = new Bundle(); args.putInt("step", 2); args.putInt("chat_id", chatId); presentFragment(new ChannelCreateActivity(args), true); } else { ArrayList<TLRPC.InputUser> result = new ArrayList<>(); for (Integer uid : selectedContacts.keySet()) { TLRPC.InputUser user = MessagesController .getInputUser(MessagesController.getInstance().getUser(uid)); if (user != null) { result.add(user); } } MessagesController.getInstance().addUsersToChannel(chatId, result, null); NotificationCenter.getInstance().postNotificationName(NotificationCenter.closeChats); Bundle args2 = new Bundle(); args2.putInt("chat_id", chatId); presentFragment(new ChatActivity(args2), true); } } } }); ActionBarMenu menu = actionBar.createMenu(); doneButton = menu.addItemWithWidth(done_button, R.drawable.ic_done, AndroidUtilities.dp(56)); if (currentStep != 2) { fragmentView = new ScrollView(context); ScrollView scrollView = (ScrollView) fragmentView; scrollView.setFillViewport(true); linearLayout = new LinearLayout(context); scrollView.addView(linearLayout, new ScrollView.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT)); } else { fragmentView = new LinearLayout(context); fragmentView.setOnTouchListener(new View.OnTouchListener() { @Override public boolean onTouch(View v, MotionEvent event) { return true; } }); linearLayout = (LinearLayout) fragmentView; } linearLayout.setOrientation(LinearLayout.VERTICAL); if (currentStep == 0) { actionBar.setTitle(LocaleController.getString("NewChannel", R.string.NewChannel)); fragmentView.setBackgroundColor(ContextCompat.getColor(context, R.color.card_background)); FrameLayout frameLayout = new FrameLayout(context); linearLayout.addView(frameLayout, LayoutHelper.createLinear(LayoutHelper.MATCH_PARENT, LayoutHelper.WRAP_CONTENT)); avatarImage = new BackupImageView(context); avatarImage.setRoundRadius(AndroidUtilities.dp(32)); avatarDrawable.setInfo(5, null, null, false); avatarDrawable.setDrawPhoto(true); avatarImage.setImageDrawable(avatarDrawable); frameLayout.addView(avatarImage, LayoutHelper.createFrame(64, 64, Gravity.TOP | (LocaleController.isRTL ? Gravity.RIGHT : Gravity.LEFT), LocaleController.isRTL ? 0 : 16, 12, LocaleController.isRTL ? 16 : 0, 12)); avatarImage.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { if (getParentActivity() == null) { return; } AlertDialog.Builder builder = new AlertDialog.Builder(getParentActivity()); CharSequence[] items; if (avatar != null) { items = new CharSequence[] { LocaleController.getString("FromCamera", R.string.FromCamera), LocaleController.getString("FromGalley", R.string.FromGalley), LocaleController.getString("DeletePhoto", R.string.DeletePhoto) }; } else { items = new CharSequence[] { LocaleController.getString("FromCamera", R.string.FromCamera), LocaleController.getString("FromGalley", R.string.FromGalley) }; } builder.setItems(items, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialogInterface, int i) { if (i == 0) { avatarUpdater.openCamera(); } else if (i == 1) { avatarUpdater.openGallery(); } else if (i == 2) { avatar = null; uploadedAvatar = null; avatarImage.setImage(avatar, "50_50", avatarDrawable); } } }); showDialog(builder.create()); } }); nameTextView = new EditText(context); nameTextView.setHint(LocaleController.getString("EnterChannelName", R.string.EnterChannelName)); if (nameToSet != null) { nameTextView.setText(nameToSet); nameToSet = null; } nameTextView.setMaxLines(4); nameTextView .setGravity(Gravity.CENTER_VERTICAL | (LocaleController.isRTL ? Gravity.RIGHT : Gravity.LEFT)); nameTextView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 16); //nameTextView.setHintTextColor(0xff979797); nameTextView.setImeOptions(EditorInfo.IME_FLAG_NO_EXTRACT_UI); nameTextView.setInputType(InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_FLAG_CAP_SENTENCES); InputFilter[] inputFilters = new InputFilter[1]; inputFilters[0] = new InputFilter.LengthFilter(100); nameTextView.setFilters(inputFilters); nameTextView.setPadding(0, 0, 0, AndroidUtilities.dp(8)); AndroidUtilities.clearCursorDrawable(nameTextView); nameTextView.setTextColor(ContextCompat.getColor(context, R.color.primary_text)); frameLayout.addView(nameTextView, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, LayoutHelper.WRAP_CONTENT, Gravity.CENTER_VERTICAL, LocaleController.isRTL ? 16 : 96, 0, LocaleController.isRTL ? 96 : 16, 0)); nameTextView.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) { } @Override public void afterTextChanged(Editable s) { avatarDrawable.setInfo(5, nameTextView.length() > 0 ? nameTextView.getText().toString() : null, null, false); avatarImage.invalidate(); } }); descriptionTextView = new EditText(context); descriptionTextView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 18); //descriptionTextView.setHintTextColor(0xff979797); descriptionTextView.setTextColor(ContextCompat.getColor(context, R.color.primary_text)); descriptionTextView.setPadding(0, 0, 0, AndroidUtilities.dp(6)); descriptionTextView.setGravity(LocaleController.isRTL ? Gravity.RIGHT : Gravity.LEFT); descriptionTextView.setInputType(InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_FLAG_CAP_SENTENCES | InputType.TYPE_TEXT_FLAG_MULTI_LINE | InputType.TYPE_TEXT_FLAG_AUTO_CORRECT); descriptionTextView.setImeOptions(EditorInfo.IME_ACTION_DONE); inputFilters = new InputFilter[1]; inputFilters[0] = new InputFilter.LengthFilter(120); descriptionTextView.setFilters(inputFilters); descriptionTextView .setHint(LocaleController.getString("DescriptionPlaceholder", R.string.DescriptionPlaceholder)); AndroidUtilities.clearCursorDrawable(descriptionTextView); linearLayout.addView(descriptionTextView, LayoutHelper.createLinear(LayoutHelper.MATCH_PARENT, LayoutHelper.WRAP_CONTENT, 24, 18, 24, 0)); descriptionTextView.setOnEditorActionListener(new TextView.OnEditorActionListener() { @Override public boolean onEditorAction(TextView textView, int i, KeyEvent keyEvent) { if (i == EditorInfo.IME_ACTION_DONE && doneButton != null) { doneButton.performClick(); return true; } return false; } }); descriptionTextView.addTextChangedListener(new TextWatcher() { @Override public void beforeTextChanged(CharSequence charSequence, int i, int i2, int i3) { } @Override public void onTextChanged(CharSequence charSequence, int i, int i2, int i3) { } @Override public void afterTextChanged(Editable editable) { } }); TextView helpTextView = new TextView(context); helpTextView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 15); //helpTextView.setTextColor(0xff6d6d72); helpTextView.setGravity(LocaleController.isRTL ? Gravity.RIGHT : Gravity.LEFT); helpTextView.setText(LocaleController.getString("DescriptionInfo", R.string.DescriptionInfo)); linearLayout.addView(helpTextView, LayoutHelper.createLinear(LayoutHelper.WRAP_CONTENT, LayoutHelper.WRAP_CONTENT, LocaleController.isRTL ? Gravity.RIGHT : Gravity.LEFT, 24, 10, 24, 20)); } else if (currentStep == 1) { actionBar.setTitle(LocaleController.getString("ChannelSettings", R.string.ChannelSettings)); fragmentView.setBackgroundColor(ContextCompat.getColor(context, R.color.settings_background)); LinearLayout linearLayout2 = new LinearLayout(context); linearLayout2.setOrientation(LinearLayout.VERTICAL); linearLayout2.setBackgroundColor(ContextCompat.getColor(context, R.color.card_background)); linearLayout2.setElevation(AndroidUtilities.dp(2)); linearLayout.addView(linearLayout2, LayoutHelper.createLinear(LayoutHelper.MATCH_PARENT, LayoutHelper.WRAP_CONTENT)); radioButtonCell1 = new RadioButtonCell(context); radioButtonCell1.setElevation(0); radioButtonCell1.setForeground(R.drawable.list_selector); radioButtonCell1.setTextAndValue(LocaleController.getString("ChannelPublic", R.string.ChannelPublic), LocaleController.getString("ChannelPublicInfo", R.string.ChannelPublicInfo), !isPrivate, false); linearLayout2.addView(radioButtonCell1, LayoutHelper.createLinear(LayoutHelper.MATCH_PARENT, LayoutHelper.WRAP_CONTENT)); radioButtonCell1.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { if (!isPrivate) { return; } isPrivate = false; updatePrivatePublic(); } }); radioButtonCell2 = new RadioButtonCell(context); radioButtonCell2.setElevation(0); radioButtonCell2.setForeground(R.drawable.list_selector); radioButtonCell2.setTextAndValue(LocaleController.getString("ChannelPrivate", R.string.ChannelPrivate), LocaleController.getString("ChannelPrivateInfo", R.string.ChannelPrivateInfo), isPrivate, false); linearLayout2.addView(radioButtonCell2, LayoutHelper.createLinear(LayoutHelper.MATCH_PARENT, LayoutHelper.WRAP_CONTENT)); radioButtonCell2.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { if (isPrivate) { return; } isPrivate = true; updatePrivatePublic(); } }); sectionCell = new ShadowSectionCell(context); linearLayout.addView(sectionCell, LayoutHelper.createLinear(LayoutHelper.MATCH_PARENT, LayoutHelper.WRAP_CONTENT)); linkContainer = new LinearLayout(context); linkContainer.setOrientation(LinearLayout.VERTICAL); linkContainer.setBackgroundColor(ContextCompat.getColor(context, R.color.card_background)); linkContainer.setElevation(AndroidUtilities.dp(2)); linearLayout.addView(linkContainer, LayoutHelper.createLinear(LayoutHelper.MATCH_PARENT, LayoutHelper.WRAP_CONTENT)); headerCell = new HeaderCell(context); linkContainer.addView(headerCell); publicContainer = new LinearLayout(context); publicContainer.setOrientation(LinearLayout.HORIZONTAL); linkContainer.addView(publicContainer, LayoutHelper.createLinear(LayoutHelper.MATCH_PARENT, 36, 17, 7, 17, 0)); EditText editText = new EditText(context); editText.setText("telegram.me/"); editText.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 18); //editText.setHintTextColor(0xff979797); editText.setTextColor(ContextCompat.getColor(context, R.color.primary_text)); editText.setMaxLines(1); editText.setLines(1); editText.setEnabled(false); editText.setBackgroundDrawable(null); editText.setPadding(0, 0, 0, 0); editText.setSingleLine(true); editText.setInputType(InputType.TYPE_TEXT_FLAG_MULTI_LINE | InputType.TYPE_TEXT_FLAG_AUTO_CORRECT); editText.setImeOptions(EditorInfo.IME_ACTION_DONE); publicContainer.addView(editText, LayoutHelper.createLinear(LayoutHelper.WRAP_CONTENT, 36)); nameTextView = new EditText(context); nameTextView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 18); //nameTextView.setHintTextColor(0xff979797); nameTextView.setTextColor(ContextCompat.getColor(context, R.color.primary_text)); nameTextView.setMaxLines(1); nameTextView.setLines(1); nameTextView.setBackgroundDrawable(null); nameTextView.setPadding(0, 0, 0, 0); nameTextView.setSingleLine(true); nameTextView.setInputType(InputType.TYPE_TEXT_VARIATION_EMAIL_ADDRESS | InputType.TYPE_TEXT_FLAG_MULTI_LINE | InputType.TYPE_TEXT_FLAG_AUTO_CORRECT); nameTextView.setImeOptions(EditorInfo.IME_ACTION_DONE); nameTextView.setHint( LocaleController.getString("ChannelUsernamePlaceholder", R.string.ChannelUsernamePlaceholder)); AndroidUtilities.clearCursorDrawable(nameTextView); publicContainer.addView(nameTextView, LayoutHelper.createLinear(LayoutHelper.MATCH_PARENT, 36)); nameTextView.addTextChangedListener(new TextWatcher() { @Override public void beforeTextChanged(CharSequence charSequence, int i, int i2, int i3) { } @Override public void onTextChanged(CharSequence charSequence, int i, int i2, int i3) { checkUserName(nameTextView.getText().toString()); } @Override public void afterTextChanged(Editable editable) { } }); privateContainer = new TextBlockCell(context); privateContainer.setForeground(R.drawable.list_selector); privateContainer.setElevation(0); linkContainer.addView(privateContainer); privateContainer.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { if (invite == null) { return; } try { android.content.ClipboardManager clipboard = (android.content.ClipboardManager) ApplicationLoader.applicationContext .getSystemService(Context.CLIPBOARD_SERVICE); android.content.ClipData clip = android.content.ClipData.newPlainText("label", invite.link); clipboard.setPrimaryClip(clip); Toast.makeText(getParentActivity(), LocaleController.getString("LinkCopied", R.string.LinkCopied), Toast.LENGTH_SHORT) .show(); } catch (Exception e) { FileLog.e("tmessages", e); } } }); checkTextView = new TextView(context); checkTextView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 15); checkTextView.setGravity(LocaleController.isRTL ? Gravity.RIGHT : Gravity.LEFT); checkTextView.setVisibility(View.GONE); linkContainer.addView(checkTextView, LayoutHelper.createLinear(LayoutHelper.WRAP_CONTENT, LayoutHelper.WRAP_CONTENT, LocaleController.isRTL ? Gravity.RIGHT : Gravity.LEFT, 17, 3, 17, 7)); typeInfoCell = new TextInfoPrivacyCell(context); //typeInfoCell.setBackgroundResource(R.drawable.greydivider_bottom); linearLayout.addView(typeInfoCell, LayoutHelper.createLinear(LayoutHelper.MATCH_PARENT, LayoutHelper.WRAP_CONTENT)); loadingAdminedCell = new LoadingCell(context); linearLayout.addView(loadingAdminedCell, LayoutHelper.createLinear(LayoutHelper.MATCH_PARENT, LayoutHelper.WRAP_CONTENT)); adminedInfoCell = new TextInfoPrivacyCell(context); //adminedInfoCell.setBackgroundResource(R.drawable.greydivider_bottom); linearLayout.addView(adminedInfoCell, LayoutHelper.createLinear(LayoutHelper.MATCH_PARENT, LayoutHelper.WRAP_CONTENT)); updatePrivatePublic(); } else if (currentStep == 2) { actionBar.setTitle(LocaleController.getString("ChannelAddMembers", R.string.ChannelAddMembers)); actionBar.setSubtitle(LocaleController.formatPluralString("Members", selectedContacts.size())); searchListViewAdapter = new SearchAdapter(context, null, false, false, false, false); searchListViewAdapter.setCheckedMap(selectedContacts); searchListViewAdapter.setUseUserCell(true); listViewAdapter = new ContactsAdapter(context, 1, false, null, false); listViewAdapter.setCheckedMap(selectedContacts); FrameLayout frameLayout = new FrameLayout(context); frameLayout.setBackgroundColor(ContextCompat.getColor(context, R.color.chat_list_background)); linearLayout.addView(frameLayout, LayoutHelper.createLinear(LayoutHelper.MATCH_PARENT, LayoutHelper.WRAP_CONTENT)); nameTextView = new EditText(context); nameTextView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 16); //nameTextView.setHintTextColor(0xff979797); nameTextView.setTextColor(ContextCompat.getColor(context, R.color.primary_text)); nameTextView.setInputType(InputType.TYPE_TEXT_VARIATION_FILTER | InputType.TYPE_TEXT_FLAG_NO_SUGGESTIONS | InputType.TYPE_TEXT_FLAG_MULTI_LINE); nameTextView.setMinimumHeight(AndroidUtilities.dp(54)); nameTextView.setSingleLine(false); nameTextView.setLines(2); nameTextView.setMaxLines(2); nameTextView.setVerticalScrollBarEnabled(true); nameTextView.setHorizontalScrollBarEnabled(false); nameTextView.setPadding(0, 0, 0, 0); nameTextView.setHint(LocaleController.getString("AddMutual", R.string.AddMutual)); nameTextView.setTextIsSelectable(false); nameTextView.setImeOptions(EditorInfo.IME_ACTION_DONE | EditorInfo.IME_FLAG_NO_EXTRACT_UI); nameTextView .setGravity((LocaleController.isRTL ? Gravity.RIGHT : Gravity.LEFT) | Gravity.CENTER_VERTICAL); AndroidUtilities.clearCursorDrawable(nameTextView); frameLayout.addView(nameTextView, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, LayoutHelper.WRAP_CONTENT, Gravity.LEFT | Gravity.TOP, 10, 0, 10, 0)); nameTextView.addTextChangedListener(new TextWatcher() { @Override public void beforeTextChanged(CharSequence charSequence, int start, int count, int after) { if (!ignoreChange) { beforeChangeIndex = nameTextView.getSelectionStart(); changeString = new SpannableString(charSequence); } } @Override public void onTextChanged(CharSequence charSequence, int i, int i2, int i3) { } @Override public void afterTextChanged(Editable editable) { if (!ignoreChange) { boolean search = false; int afterChangeIndex = nameTextView.getSelectionEnd(); if (editable.toString().length() < changeString.toString().length()) { String deletedString = ""; try { deletedString = changeString.toString().substring(afterChangeIndex, beforeChangeIndex); } catch (Exception e) { FileLog.e("tmessages", e); } if (deletedString.length() > 0) { if (searching && searchWas) { search = true; } Spannable span = nameTextView.getText(); for (int a = 0; a < allSpans.size(); a++) { ChipSpan sp = allSpans.get(a); if (span.getSpanStart(sp) == -1) { allSpans.remove(sp); selectedContacts.remove(sp.uid); } } actionBar.setSubtitle( LocaleController.formatPluralString("Members", selectedContacts.size())); listView.invalidateViews(); } else { search = true; } } else { search = true; } if (search) { String text = nameTextView.getText().toString().replace("<", ""); if (text.length() != 0) { searching = true; searchWas = true; if (listView != null) { listView.setAdapter(searchListViewAdapter); searchListViewAdapter.notifyDataSetChanged(); listView.setFastScrollAlwaysVisible(false); listView.setFastScrollEnabled(false); listView.setVerticalScrollBarEnabled(true); } if (emptyTextView != null) { emptyTextView .setText(LocaleController.getString("NoResult", R.string.NoResult)); } searchListViewAdapter.searchDialogs(text); } else { searchListViewAdapter.searchDialogs(null); searching = false; searchWas = false; listView.setAdapter(listViewAdapter); listViewAdapter.notifyDataSetChanged(); listView.setFastScrollAlwaysVisible(true); listView.setFastScrollEnabled(true); listView.setVerticalScrollBarEnabled(false); emptyTextView .setText(LocaleController.getString("NoContacts", R.string.NoContacts)); } } } } }); LinearLayout emptyTextLayout = new LinearLayout(context); emptyTextLayout.setVisibility(View.INVISIBLE); emptyTextLayout.setOrientation(LinearLayout.VERTICAL); linearLayout.addView(emptyTextLayout, LayoutHelper.createLinear(LayoutHelper.MATCH_PARENT, LayoutHelper.MATCH_PARENT)); emptyTextLayout.setOnTouchListener(new View.OnTouchListener() { @Override public boolean onTouch(View v, MotionEvent event) { return true; } }); emptyTextView = new TextView(context); emptyTextView.setTextColor(0xff808080); emptyTextView.setTextSize(20); emptyTextView.setGravity(Gravity.CENTER); emptyTextView.setText(LocaleController.getString("NoContacts", R.string.NoContacts)); emptyTextLayout.addView(emptyTextView, LayoutHelper.createLinear(LayoutHelper.MATCH_PARENT, LayoutHelper.MATCH_PARENT, 0.5f)); FrameLayout frameLayout2 = new FrameLayout(context); emptyTextLayout.addView(frameLayout2, LayoutHelper.createLinear(LayoutHelper.MATCH_PARENT, LayoutHelper.MATCH_PARENT, 0.5f)); listView = new LetterSectionsListView(context); listView.setEmptyView(emptyTextLayout); listView.setVerticalScrollBarEnabled(false); listView.setDivider(null); listView.setDividerHeight(0); listView.setFastScrollEnabled(true); listView.setScrollBarStyle(View.SCROLLBARS_OUTSIDE_OVERLAY); listView.setAdapter(listViewAdapter); listView.setFastScrollAlwaysVisible(true); listView.setVerticalScrollbarPosition( LocaleController.isRTL ? ListView.SCROLLBAR_POSITION_LEFT : ListView.SCROLLBAR_POSITION_RIGHT); linearLayout.addView(listView, LayoutHelper.createLinear(LayoutHelper.MATCH_PARENT, LayoutHelper.MATCH_PARENT)); listView.setOnItemClickListener(new AdapterView.OnItemClickListener() { @Override public void onItemClick(AdapterView<?> adapterView, View view, int i, long l) { TLRPC.User user; if (searching && searchWas) { user = (TLRPC.User) searchListViewAdapter.getItem(i); } else { int section = listViewAdapter.getSectionForPosition(i); int row = listViewAdapter.getPositionInSectionForPosition(i); if (row < 0 || section < 0) { return; } user = (TLRPC.User) listViewAdapter.getItem(section, row); } if (user == null) { return; } boolean check = true; if (selectedContacts.containsKey(user.id)) { check = false; try { ChipSpan span = selectedContacts.get(user.id); selectedContacts.remove(user.id); SpannableStringBuilder text = new SpannableStringBuilder(nameTextView.getText()); text.delete(text.getSpanStart(span), text.getSpanEnd(span)); allSpans.remove(span); ignoreChange = true; nameTextView.setText(text); nameTextView.setSelection(text.length()); ignoreChange = false; } catch (Exception e) { FileLog.e("tmessages", e); } } else { ignoreChange = true; ChipSpan span = createAndPutChipForUser(user); if (span != null) { span.uid = user.id; } ignoreChange = false; if (span == null) { return; } } actionBar.setSubtitle(LocaleController.formatPluralString("Members", selectedContacts.size())); if (searching || searchWas) { ignoreChange = true; SpannableStringBuilder ssb = new SpannableStringBuilder(""); for (ImageSpan sp : allSpans) { ssb.append("<<"); ssb.setSpan(sp, ssb.length() - 2, ssb.length(), SpannableStringBuilder.SPAN_EXCLUSIVE_EXCLUSIVE); } nameTextView.setText(ssb); nameTextView.setSelection(ssb.length()); ignoreChange = false; searchListViewAdapter.searchDialogs(null); searching = false; searchWas = false; listView.setAdapter(listViewAdapter); listViewAdapter.notifyDataSetChanged(); listView.setFastScrollAlwaysVisible(true); listView.setFastScrollEnabled(true); listView.setVerticalScrollBarEnabled(false); emptyTextView.setText(LocaleController.getString("NoContacts", R.string.NoContacts)); } else { if (view instanceof UserCell) { ((UserCell) view).setChecked(check, true); } } } }); listView.setOnScrollListener(new AbsListView.OnScrollListener() { @Override public void onScrollStateChanged(AbsListView absListView, int i) { if (i == SCROLL_STATE_TOUCH_SCROLL) { AndroidUtilities.hideKeyboard(nameTextView); } if (listViewAdapter != null) { listViewAdapter.setIsScrolling(i != SCROLL_STATE_IDLE); } } @Override public void onScroll(AbsListView absListView, int firstVisibleItem, int visibleItemCount, int totalItemCount) { if (absListView.isFastScrollEnabled()) { AndroidUtilities.clearDrawableAnimation(absListView); } } }); } return fragmentView; }
From source file:com.doplgangr.secrecy.views.FilesListFragment.java
void deleteVault() { final EditText passwordView = new EditText(context); passwordView.setInputType(InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_VARIATION_PASSWORD); passwordView.setHint(R.string.Vault__confirm_password_hint); new AlertDialog.Builder(context).setTitle(getString(R.string.Vault__confirm_delete)).setView(passwordView) .setPositiveButton(R.string.OK, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int whichButton) { String input = passwordView.getText().toString(); if (password.equals(input)) { secret.delete(); context.finish(); } else { Util.alert(context, CustomApp.context.getString(R.string.Error__delete_password_incorrect), CustomApp.context.getString(R.string.Error__delete_password_incorrect_message), Util.emptyClickListener, null); }// w w w .j a va 2 s .c o m } }).setNegativeButton(R.string.CANCEL, Util.emptyClickListener).show(); }
From source file:com.hughes.android.dictionary.DictionaryActivity.java
private void onCreateSetupActionBarAndSearchView() { ActionBar actionBar = getSupportActionBar(); actionBar.setDisplayShowTitleEnabled(false); actionBar.setDisplayShowHomeEnabled(false); actionBar.setDisplayHomeAsUpEnabled(false); final LinearLayout customSearchView = new LinearLayout(getSupportActionBar().getThemedContext()); final LinearLayout.LayoutParams layoutParams = new LinearLayout.LayoutParams( ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT); customSearchView.setLayoutParams(layoutParams); listView.setOnItemClickListener(new OnItemClickListener() { @Override//w w w . ja v a 2 s.c o m public void onItemClick(AdapterView<?> parent, View view, int row, long id) { onListItemClick(getListView(), view, row, id); } }); languageButton = new ImageButton(customSearchView.getContext()); languageButton.setScaleType(ScaleType.FIT_CENTER); languageButton.setOnClickListener(new OnClickListener() { @Override public void onClick(View arg0) { onLanguageButtonClick(); } }); languageButton.setOnLongClickListener(new OnLongClickListener() { @Override public boolean onLongClick(View v) { onLanguageButtonLongClick(v.getContext()); return true; } }); languageButton.setAdjustViewBounds(true); LinearLayout.LayoutParams lpb = new LinearLayout.LayoutParams(application.languageButtonPixels, LinearLayout.LayoutParams.MATCH_PARENT); customSearchView.addView(languageButton, lpb); searchView = new SearchView(getSupportActionBar().getThemedContext()); // Get rid of search icon, it takes up too much space. // There is still text saying "search" in the search field. searchView.setIconifiedByDefault(true); searchView.setIconified(false); searchView.setQueryHint(getString(R.string.searchText)); searchView.setSubmitButtonEnabled(false); searchView.setInputType(InputType.TYPE_CLASS_TEXT); searchView.setImeOptions(EditorInfo.IME_ACTION_DONE | EditorInfo.IME_FLAG_NO_EXTRACT_UI | // EditorInfo.IME_FLAG_NO_FULLSCREEN | // Requires API // 11 EditorInfo.TYPE_TEXT_FLAG_NO_SUGGESTIONS); onQueryTextListener = new OnQueryTextListener() { @Override public boolean onQueryTextSubmit(String query) { Log.d(LOG, "OnQueryTextListener: onQueryTextSubmit: " + searchView.getQuery()); hideKeyboard(); return true; } @Override public boolean onQueryTextChange(String newText) { Log.d(LOG, "OnQueryTextListener: onQueryTextChange: " + searchView.getQuery()); onSearchTextChange(searchView.getQuery().toString()); return true; } }; searchView.setOnQueryTextListener(onQueryTextListener); searchView.setFocusable(true); LinearLayout.LayoutParams lp = new LinearLayout.LayoutParams(0, FrameLayout.LayoutParams.WRAP_CONTENT, 1); customSearchView.addView(searchView, lp); actionBar.setCustomView(customSearchView); actionBar.setDisplayShowCustomEnabled(true); // Avoid wasting space on large left inset Toolbar tb = (Toolbar) customSearchView.getParent(); tb.setContentInsetsRelative(0, 0); }
From source file:hu.fnf.devel.atlas.Atlas.java
private void setViewCategoryProperties(int page) { /*//from w w w .j a v a 2s .c o m * List LABEL */ TextView header = (TextView) findViewById(R.id.header_text_view); TextView newe = (TextView) findViewById(R.id.new_etwas_text); EditText newc = (EditText) findViewById(R.id.new_etwas); ContentResolver cr = getContentResolver(); Uri.Builder builder = new Builder(); builder.scheme("content"); builder.authority(AtlasData.DB_AUTHORITY); Cursor list = null; String[] projection = null; switch (page) { case AtlasData.PINCOME: newe.setText(getResources().getString(R.string.category) + ":"); newc.setInputType(InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_FLAG_CAP_WORDS); builder.appendPath(AtlasData.TABLE_DATA); builder.appendPath("guess"); list = cr.query(builder.build(), AtlasData.DATA_COLUMNS, null, null, null); header.setText(getResources().getString(R.string.guess) + "(" + String.valueOf(list.getCount()) + ")"); list.close(); builder = new Builder(); builder.scheme("content"); builder.authority(AtlasData.DB_AUTHORITY); builder.appendPath(AtlasData.TABLE_DATA); projection = AtlasData.DATA_COLUMNS; if (getResources().getConfiguration().orientation == Configuration.ORIENTATION_PORTRAIT) { Log.d("onCreate", "only toptask"); builder.appendPath("topguess"); } else { Log.d("onCreate", "all tasks"); builder.appendPath("guess"); } break; case AtlasData.PSUMMARY: newe.setText(getResources().getString(R.string.amount) + ":"); newc.setInputType(InputType.TYPE_CLASS_NUMBER | InputType.TYPE_NUMBER_FLAG_DECIMAL | InputType.TYPE_NUMBER_FLAG_SIGNED); builder.appendPath(AtlasData.TABLE_TRANSACTIONS); builder.appendPath("tasks"); list = cr.query(builder.build(), AtlasData.TRANSACTIONS_COLUMNS, null, null, null); header.setText(getResources().getString(R.string.tasks) + "(" + String.valueOf(list.getCount()) + ")"); list.close(); builder = new Builder(); builder.scheme("content"); builder.authority(AtlasData.DB_AUTHORITY); builder.appendPath(AtlasData.TABLE_TRANSACTIONS); projection = AtlasData.TRANSACTIONS_COLUMNS; if (getResources().getConfiguration().orientation == Configuration.ORIENTATION_PORTRAIT) { Log.d("onCreate", "only toptask"); builder.appendPath("toptask"); } else { Log.d("onCreate", "all tasks"); builder.appendPath("tasks"); } break; case AtlasData.POUTCOME: newe.setText(getResources().getString(R.string.category) + ":"); newc.setInputType(InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_FLAG_CAP_WORDS); builder.appendPath(AtlasData.TABLE_DATA); builder.appendPath("data"); list = cr.query(builder.build(), AtlasData.DATA_COLUMNS, null, null, null); header.setText(getResources().getString(R.string.data) + "(" + String.valueOf(list.getCount()) + ")"); list.close(); builder = new Builder(); builder.scheme("content"); builder.authority(AtlasData.DB_AUTHORITY); builder.appendPath(AtlasData.TABLE_DATA); projection = AtlasData.DATA_COLUMNS; if (getResources().getConfiguration().orientation == Configuration.ORIENTATION_PORTRAIT) { Log.d("onCreate", "only toptask"); builder.appendPath("topdata"); } else { Log.d("onCreate", "all tasks"); builder.appendPath("data"); } break; default: Log.e("onPageSelected", "page?!: " + page); break; } header.setOnClickListener(onHeaderClickListener); Cursor tasks_result = cr.query(builder.build(), projection, null, null, null); DatabaseQueryAdapter ta = new DatabaseQueryAdapter(this, tasks_result, 0, builder.build().getPathSegments().get(0)); Log.d("onCreate", "result count: " + tasks_result.getColumnCount()); ListView lv = (ListView) findViewById(R.id.tasklist); lv.setAdapter(ta); }
From source file:com.example.carsharing.ShortWayActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { photouri = Uri/*w w w . j a va2s . c o m*/ .fromFile(new File(this.getExternalFilesDir(Environment.DIRECTORY_PICTURES), IMAGE_FILE_NAME2)); super.onCreate(savedInstanceState); setContentView(R.layout.activity_short_way); activity_drawer = new Drawer(this, R.id.short_way_layout); mDrawerToggle = activity_drawer.newdrawer(); mDrawerLayout = activity_drawer.setDrawerLayout(); bdriver = true; // SharedPreferences sharedPref = this.getSharedPreferences(getString(R.string.PreferenceDefaultName), Context.MODE_PRIVATE); UserPhoneNumber = sharedPref.getString(getString(R.string.PreferenceUserPhoneNumber), "0"); // standard_date = new SimpleDateFormat("yyyy-MM-dd", Locale.SIMPLIFIED_CHINESE); primary_date = new SimpleDateFormat("yyyyMMdd", Locale.SIMPLIFIED_CHINESE); standard_time = new SimpleDateFormat("HH:mm:ss", Locale.SIMPLIFIED_CHINESE); primary_time = new SimpleDateFormat("HHmmss", Locale.SIMPLIFIED_CHINESE); queue = Volley.newRequestQueue(this); exchange = (ImageView) findViewById(R.id.shortway_exchange); exchange.setOnClickListener(new OnClickListener() { @Override public void onClick(View arg0) { // TODO Auto-generated method stub String temp = startplace.getText().toString(); if (!temp.equals("") && !endplace.getText().toString().equals("")) { startplace.setText(endplace.getText().toString()); endplace.setText(temp); float a, b; a = startplace_longitude; b = startplace_latitude; startplace_longitude = destination_longitude; startplace_latitude = destination_latitude; destination_longitude = a; destination_latitude = b; } } }); datebutton = (Button) findViewById(R.id.shortway_dates); earlystarttime = (Button) findViewById(R.id.shortway_earliest_start_time); latestarttime = (Button) findViewById(R.id.shortway_latest_start_time); increase = (Button) findViewById(R.id.shortway_increase); decrease = (Button) findViewById(R.id.shortway_decrease); s2 = (TextView) findViewById(R.id.shortway_count); startplace = (Button) findViewById(R.id.shortway_startplace); endplace = (Button) findViewById(R.id.shortway_endplace); sure = (Button) findViewById(R.id.shortway_sure); commute = findViewById(R.id.drawer_commute); shortway = findViewById(R.id.drawer_shortway); longway = findViewById(R.id.drawer_longway); setting = findViewById(R.id.drawer_setting); personalcenter = findViewById(R.id.drawer_personalcenter); about = findViewById(R.id.drawer_respond); taxi = findViewById(R.id.drawer_taxi); drawericon = (ImageView) findViewById(R.id.drawer_icon); drawername = (TextView) findViewById(R.id.drawer_name); drawernum = (TextView) findViewById(R.id.drawer_phone); carbrand = (EditText) findViewById(R.id.shortway_CarBrand); model = (EditText) findViewById(R.id.shortway_CarModel); color = (EditText) findViewById(R.id.shortway_color); licensenum = (EditText) findViewById(R.id.shortway_Num); licensenum.addTextChangedListener(numTextWatcher); carbrand.addTextChangedListener(detTextWatcher); color.addTextChangedListener(coTextWatcher); model.addTextChangedListener(moTextWatcher); next = (Button) findViewById(R.id.shortway_sure); next.setEnabled(false); db = new DatabaseHelper(ShortWayActivity.this, "test", null, 1); db1 = db.getWritableDatabase(); final TextView content = (TextView) findViewById(R.id.shortway_content); mRadio1 = (RadioButton) findViewById(R.id.shortway_radioButton1); mRadio2 = (RadioButton) findViewById(R.id.shortway_radioButton2); shortway_group = (RadioGroup) findViewById(R.id.shortway_radiobutton01); star1 = (ImageView) findViewById(R.id.shortway_star); star2 = (ImageView) findViewById(R.id.shortway_star01); // judge the value of "pre_page" Bundle bundle = this.getIntent().getExtras(); String PRE_PAGE = bundle.getString("pre_page"); if (PRE_PAGE.compareTo("ReOrder") == 0) { // startplace.setText(bundle.getString("stpusername") + "," + bundle.getString("stpmapname")); bstart = true; endplace.setText(bundle.getString("epusername") + "," + bundle.getString("epmapname")); bend = true; startplace_longitude = bundle.getFloat("stpx"); Log.e("startplace_longitude", String.valueOf(startplace_longitude)); startplace_latitude = bundle.getFloat("stpy"); Log.e("startplace_latitude", String.valueOf(startplace_latitude)); destination_longitude = bundle.getFloat("epx"); Log.e("destination_longitude", String.valueOf(destination_longitude)); destination_latitude = bundle.getFloat("epy"); Log.e("destination_latitude", String.valueOf(destination_latitude)); datebutton.setText(bundle.getString("re_short_startdate")); bdate = true; earlystarttime.setText(bundle.getString("re_short_starttime")); best = true; latestarttime.setText(bundle.getString("re_short_endtime")); blst = true; } // judge the value of "pre_page" about.setOnClickListener(new OnClickListener() { @Override public void onClick(View arg0) { // TODO Auto-generated method stub mDrawerLayout.closeDrawer(findViewById(R.id.left_drawer)); Intent about = new Intent(ShortWayActivity.this, AboutActivity.class); startActivity(about); } }); setting.setOnClickListener(new OnClickListener() { @Override public void onClick(View arg0) { // TODO Auto-generated method stub mDrawerLayout.closeDrawer(findViewById(R.id.left_drawer)); Intent setting = new Intent(ShortWayActivity.this, SettingActivity.class); startActivity(setting); } }); // database db = new DatabaseHelper(getApplicationContext(), UserPhoneNumber, null, 1); db1 = db.getWritableDatabase(); // database end star1.setOnClickListener(new OnClickListener() { @Override public void onClick(View arg0) { if (bstart) { if (Pointisliked(StartPointMapName)) { // Define 'where' part of query. String selection = getString(R.string.dbstring_PlaceMapName) + " LIKE ?"; // Specify arguments in placeholder order. String[] selelectionArgs = { StartPointMapName }; // Issue SQL statement. db1.delete(getString(R.string.dbtable_placeliked), selection, selelectionArgs); star1.setImageResource(R.drawable.ic_action_not_important); } else { ContentValues content = new ContentValues(); content.put(getString(R.string.dbstring_PlaceUserName), StartPointUserName); content.put(getString(R.string.dbstring_PlaceMapName), StartPointMapName); content.put(getString(R.string.dbstring_longitude), startplace_longitude); content.put(getString(R.string.dbstring_latitude), startplace_latitude); db1.insert(getString(R.string.dbtable_placeliked), null, content); // Define 'where' part of query. String selection = getString(R.string.dbstring_PlaceMapName) + " LIKE ?"; // Specify arguments in placeholder order. String[] selelectionArgs = { StartPointMapName }; // Issue SQL statement. db1.delete(getString(R.string.dbtable_placehistory), selection, selelectionArgs); star1.setImageResource(R.drawable.ic_action_important); } } } }); star2.setOnClickListener(new OnClickListener() { @Override public void onClick(View arg0) { if (bend) { if (Pointisliked(EndPointMapName)) { // Define 'where' part of query. String selection = getString(R.string.dbstring_PlaceMapName) + " LIKE ?"; // Specify arguments in placeholder order. String[] selelectionArgs = { EndPointMapName }; // Issue SQL statement. db1.delete(getString(R.string.dbtable_placeliked), selection, selelectionArgs); star2.setImageResource(R.drawable.ic_action_not_important); } else { ContentValues content = new ContentValues(); content.put(getString(R.string.dbstring_PlaceUserName), EndPointUserName); content.put(getString(R.string.dbstring_PlaceMapName), EndPointMapName); content.put(getString(R.string.dbstring_longitude), destination_longitude); content.put(getString(R.string.dbstring_latitude), destination_latitude); db1.insert(getString(R.string.dbtable_placeliked), null, content); // Define 'where' part of query. String selection = getString(R.string.dbstring_PlaceMapName) + " LIKE ?"; // Specify arguments in placeholder order. String[] selelectionArgs = { EndPointMapName }; // Issue SQL statement. db1.delete(getString(R.string.dbtable_placehistory), selection, selelectionArgs); star2.setImageResource(R.drawable.ic_action_important); } } } }); taxi.setOnClickListener(new OnClickListener() { @Override public void onClick(View arg0) { // TODO Auto-generated method stub mDrawerLayout.closeDrawer(findViewById(R.id.left_drawer)); } }); personalcenter.setOnClickListener(new OnClickListener() { @Override public void onClick(View arg0) { // TODO Auto-generated method stub mDrawerLayout.closeDrawer(findViewById(R.id.left_drawer)); Intent personalcenter = new Intent(ShortWayActivity.this, PersonalCenterActivity.class); startActivity(personalcenter); } }); shortway.setOnClickListener(new OnClickListener() { @Override public void onClick(View arg0) { // TODO Auto-generated method stub mDrawerLayout.closeDrawer(findViewById(R.id.left_drawer)); } }); longway.setOnClickListener(new OnClickListener() { @Override public void onClick(View arg0) { // TODO Auto-generated method stub mDrawerLayout.closeDrawer(findViewById(R.id.left_drawer)); Intent longway = new Intent(ShortWayActivity.this, MainActivity.class); startActivity(longway); } }); commute.setOnClickListener(new OnClickListener() { @Override public void onClick(View arg0) { // TODO Auto-generated method stub mDrawerLayout.closeDrawer(findViewById(R.id.left_drawer)); Intent commute = new Intent(ShortWayActivity.this, CommuteActivity.class); commute.putExtra("pre_page", "Drawer"); startActivity(commute); } }); // RadioGroup shortway_group.setOnCheckedChangeListener(new OnCheckedChangeListener() { @Override public void onCheckedChanged(RadioGroup arg0, int checkedId) { // TODO Auto-generated method stub18 // ID // """"textView if (checkedId == mRadio2.getId()) { bpassenager = true; bdriver = false; licensenum.setEnabled(false); carbrand.setEnabled(false); color.setEnabled(false); model.setEnabled(false); licensenum.setFilters(new InputFilter[] { new InputFilter() { @Override public CharSequence filter(CharSequence source, int start, int end, Spanned dest, int dstart, int dend) { return source.length() < 1 ? dest.subSequence(dstart, dend) : ""; } } }); carbrand.setFilters(new InputFilter[] { new InputFilter() { @Override public CharSequence filter(CharSequence source, int start, int end, Spanned dest, int dstart, int dend) { return source.length() < 1 ? dest.subSequence(dstart, dend) : ""; } } }); color.setFilters(new InputFilter[] { new InputFilter() { @Override public CharSequence filter(CharSequence source, int start, int end, Spanned dest, int dstart, int dend) { return source.length() < 1 ? dest.subSequence(dstart, dend) : ""; } } }); model.setFilters(new InputFilter[] { new InputFilter() { @Override public CharSequence filter(CharSequence source, int start, int end, Spanned dest, int dstart, int dend) { return source.length() < 1 ? dest.subSequence(dstart, dend) : ""; } } }); content.setText(getString(R.string.warningInfo_seatNeed)); licensenum.setHintTextColor(Color.parseColor("#cccccc")); carbrand.setHintTextColor(Color.parseColor("#cccccc")); color.setHintTextColor(Color.parseColor("#cccccc")); model.setHintTextColor(Color.parseColor("#cccccc")); licensenum.setInputType(InputType.TYPE_NULL); carbrand.setInputType(InputType.TYPE_NULL); color.setInputType(InputType.TYPE_NULL); model.setInputType(InputType.TYPE_NULL); } else { bpassenager = false; bdriver = true; licensenum.setEnabled(true); carbrand.setEnabled(true); color.setEnabled(true); model.setEnabled(true); licensenum.setFilters(new InputFilter[] { new InputFilter() { @Override public CharSequence filter(CharSequence source, int start, int end, Spanned dest, int dstart, int dend) { return null; } } }); carbrand.setFilters(new InputFilter[] { new InputFilter() { @Override public CharSequence filter(CharSequence source, int start, int end, Spanned dest, int dstart, int dend) { return null; } } }); color.setFilters(new InputFilter[] { new InputFilter() { @Override public CharSequence filter(CharSequence source, int start, int end, Spanned dest, int dstart, int dend) { return null; } } }); model.setFilters(new InputFilter[] { new InputFilter() { @Override public CharSequence filter(CharSequence source, int start, int end, Spanned dest, int dstart, int dend) { return null; } } }); content.setText(getString(R.string.warningInfo_seatOffer)); licensenum.setHintTextColor(Color.parseColor("#9F35FF")); carbrand.setHintTextColor(Color.parseColor("#9F35FF")); color.setHintTextColor(Color.parseColor("#9F35FF")); model.setHintTextColor(Color.parseColor("#9F35FF")); // licensenum.setText(""); // carbrand.setText(""); // color.setText(""); // model.setText(""); licensenum.setInputType(InputType.TYPE_CLASS_TEXT); carbrand.setInputType(InputType.TYPE_CLASS_TEXT); color.setInputType(InputType.TYPE_CLASS_TEXT); model.setInputType(InputType.TYPE_CLASS_TEXT); // start! selectcarinfo(UserPhoneNumber); // end! } confirm(); } }); sure.setOnClickListener(new OnClickListener() { @Override public void onClick(View arg0) { // TODO Auto-generated method stub if (shortway_group.getCheckedRadioButtonId() == mRadio1.getId()) userrole = "d"; else userrole = "p"; // start! shortway_request(UserPhoneNumber, datebutton.getText().toString(), earlystarttime.getText().toString(), latestarttime.getText().toString()); // end! } private void shortway_request(final String shortway_phonenum, final String shortway_date, final String shortway_starttime, final String shortway_endtime) { // TODO Auto-generated method stub // start try { test_date = primary_date.parse(shortway_date); standard_shortway_startdate = standard_date.format(test_date); } catch (ParseException e) { // TODO Auto-generated catch block e.printStackTrace(); } try { test_date = primary_time.parse(shortway_starttime); standard_shortway_starttime = standard_time.format(test_date); } catch (ParseException e) { // TODO Auto-generated catch block e.printStackTrace(); } try { test_date = primary_time.parse(shortway_endtime); standard_shortway_endtime = standard_time.format(test_date); } catch (ParseException e) { // TODO Auto-generated catch block e.printStackTrace(); } // end! String shortway_baseurl = getString(R.string.uri_base) + getString(R.string.uri_ShortwayRequest) + getString(R.string.uri_addrequest_action); // "http://192.168.1.111:8080/CarsharingServer/ShortwayRequest!addrequest.action?"; Log.w("URL", shortway_baseurl); StringRequest stringRequest = new StringRequest(Request.Method.POST, shortway_baseurl, new Response.Listener<String>() { @Override public void onResponse(String response) { Log.d("shortway_result", response); JSONObject json1 = null; try { json1 = new JSONObject(response); requestok = json1.getBoolean("result"); } catch (JSONException e) { // TODO Auto-generated catch block e.printStackTrace(); } if (requestok == true) { if (carinfochoosing_type == 1) { // add // start! carinfo(shortway_phonenum, licensenum.getText().toString(), carbrand.getText().toString(), model.getText().toString(), color.getText().toString(), String.valueOf(sum), 1); // end! } else { // update // start! carinfo(shortway_phonenum, licensenum.getText().toString(), carbrand.getText().toString(), model.getText().toString(), color.getText().toString(), String.valueOf(sum), 2); // end! } Intent sure = new Intent(ShortWayActivity.this, OrderResponseActivity.class); sure.putExtra(getString(R.string.request_response), "true"); sure.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP); startActivity(sure); } else { // Toast errorinfo = // Toast.makeText(getApplicationContext(), // "", Toast.LENGTH_LONG); // errorinfo.show(); Intent sure = new Intent(ShortWayActivity.this, OrderResponseActivity.class); sure.putExtra(getString(R.string.request_response), "false"); } } }, new Response.ErrorListener() { @Override public void onErrorResponse(VolleyError error) { Log.e("shortway_result", error.getMessage(), error); // Toast errorinfo = Toast.makeText(null, // "", Toast.LENGTH_LONG); // errorinfo.show(); Intent sure = new Intent(ShortWayActivity.this, OrderResponseActivity.class); sure.putExtra(getString(R.string.request_response), "false"); sure.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP); startActivity(sure); } }) { protected Map<String, String> getParams() { // POSTgetParams // start try { test_date = primary_date.parse(shortway_date); standard_shortway_startdate = standard_date.format(test_date); } catch (ParseException e) { // TODO Auto-generated catch block e.printStackTrace(); } try { test_date = primary_time.parse(shortway_starttime); standard_shortway_starttime = standard_time.format(test_date); } catch (ParseException e) { // TODO Auto-generated catch block e.printStackTrace(); } try { test_date = primary_time.parse(shortway_endtime); standard_shortway_endtime = standard_time.format(test_date); } catch (ParseException e) { // TODO Auto-generated catch block e.printStackTrace(); } // end! Map<String, String> params = new HashMap<String, String>(); params.put("phonenum", shortway_phonenum); params.put("userrole", userrole); params.put("startplacex", String.valueOf(startplace_longitude)); params.put("startplacey", String.valueOf(startplace_latitude)); params.put(getString(R.string.uri_startplace), startplace.getText().toString()); params.put("destinationx", String.valueOf(destination_longitude)); params.put("destinationy", String.valueOf(destination_latitude)); params.put(getString(R.string.uri_destination), endplace.getText().toString()); params.put("startdate", standard_shortway_startdate); params.put("starttime", standard_shortway_starttime); params.put("endtime", standard_shortway_endtime); return params; } }; queue.add(stringRequest); } }); startplace.setOnClickListener(new OnClickListener() { @Override public void onClick(View arg0) { // TODO Auto-generated method stub startActivityForResult(new Intent(ShortWayActivity.this, ChooseAddressActivity.class), 1); } }); endplace.setOnClickListener(new OnClickListener() { @Override public void onClick(View arg0) { // TODO Auto-generated method stub startActivityForResult(new Intent(ShortWayActivity.this, ChooseArrivalActivity.class), 2); } }); increase.setOnClickListener(new OnClickListener() { @Override public void onClick(View arg0) { // TODO Auto-generated method stub sum++; s2.setText("" + sum); confirm(); } }); decrease.setOnClickListener(new OnClickListener() { @Override public void onClick(View arg0) { // TODO Auto-generated method stub sum--; if (sum < 0) { sum = 0; } s2.setText("" + sum); confirm(); } }); datebutton.setOnClickListener(new OnClickListener() { @Override public void onClick(View arg0) { // TODO Auto-generated method stub showDialog(DATE_DIALOG); } }); earlystarttime.setOnClickListener(new OnClickListener() { @Override public void onClick(View arg0) { // TODO Auto-generated method stub showDialog(TIME_DIALOG); } }); latestarttime.setOnClickListener(new OnClickListener() { @Override public void onClick(View arg0) { // TODO Auto-generated method stub showDialog(TIME_DIALOG1); } }); }
From source file:com.dwdesign.tweetings.activity.ComposeActivity.java
@Override public void onCreate(final Bundle savedInstanceState) { mLocationManager = (LocationManager) getSystemService(Context.LOCATION_SERVICE); mPreferences = getSharedPreferences(SHARED_PREFERENCES_NAME, Context.MODE_PRIVATE); mService = getTweetingsApplication().getServiceInterface(); mResolver = getContentResolver();//from w ww .j av a 2s. c om super.onCreate(savedInstanceState); setContentView(R.layout.compose); mActionBar = getSupportActionBar(); mActionBar.setDisplayHomeAsUpEnabled(true); mUploadProvider = mPreferences.getString(PREFERENCE_KEY_IMAGE_UPLOADER, null); final Bundle bundle = savedInstanceState != null ? savedInstanceState : getIntent().getExtras(); final long account_id = bundle != null ? bundle.getLong(INTENT_KEY_ACCOUNT_ID) : -1; mAccountIds = bundle != null ? bundle.getLongArray(INTENT_KEY_IDS) : null; mInReplyToStatusId = bundle != null ? bundle.getLong(INTENT_KEY_IN_REPLY_TO_ID) : -1; mInReplyToScreenName = bundle != null ? bundle.getString(INTENT_KEY_IN_REPLY_TO_SCREEN_NAME) : null; mInReplyToName = bundle != null ? bundle.getString(INTENT_KEY_IN_REPLY_TO_NAME) : null; mInReplyToText = bundle != null ? bundle.getString(INTENT_KEY_IN_REPLY_TO_TWEET) : null; mIsImageAttached = bundle != null ? bundle.getBoolean(INTENT_KEY_IS_IMAGE_ATTACHED) : false; mIsPhotoAttached = bundle != null ? bundle.getBoolean(INTENT_KEY_IS_PHOTO_ATTACHED) : false; mImageUri = bundle != null ? (Uri) bundle.getParcelable(INTENT_KEY_IMAGE_URI) : null; final String[] mentions = bundle != null ? bundle.getStringArray(INTENT_KEY_MENTIONS) : null; final String account_username = getAccountUsername(this, account_id); int text_selection_start = -1; mIsBuffer = bundle != null ? bundle.getBoolean(INTENT_KEY_IS_BUFFER, false) : false; if (mInReplyToStatusId > 0) { if (bundle != null && bundle.getString(INTENT_KEY_TEXT) != null && (mentions == null || mentions.length < 1)) { mText = bundle.getString(INTENT_KEY_TEXT); } else if (mentions != null) { final StringBuilder builder = new StringBuilder(); for (final String mention : mentions) { if (mentions.length == 1 && mentions[0].equalsIgnoreCase(account_username)) { builder.append('@' + account_username + ' '); } else if (!mention.equalsIgnoreCase(account_username)) { builder.append('@' + mention + ' '); } } mText = builder.toString(); text_selection_start = mText.indexOf(' ') + 1; } mIsQuote = bundle != null ? bundle.getBoolean(INTENT_KEY_IS_QUOTE, false) : false; final boolean display_name = mPreferences.getBoolean(PREFERENCE_KEY_DISPLAY_NAME, false); final String name = display_name ? mInReplyToName : mInReplyToScreenName; if (name != null) { setTitle(getString(mIsQuote ? R.string.quote_user : R.string.reply_to, name)); } if (mAccountIds == null || mAccountIds.length == 0) { mAccountIds = new long[] { account_id }; } TextView replyText = (TextView) findViewById(R.id.reply_text); if (!isNullOrEmpty(mInReplyToText)) { replyText.setVisibility(View.VISIBLE); replyText.setText(mInReplyToText); } else { replyText.setVisibility(View.GONE); } } else { if (mentions != null) { final StringBuilder builder = new StringBuilder(); for (final String mention : mentions) { if (mentions.length == 1 && mentions[0].equalsIgnoreCase(account_username)) { builder.append('@' + account_username + ' '); } else if (!mention.equalsIgnoreCase(account_username)) { builder.append('@' + mention + ' '); } } mText = builder.toString(); } if (mAccountIds == null || mAccountIds.length == 0) { final long[] ids_in_prefs = ArrayUtils .fromString(mPreferences.getString(PREFERENCE_KEY_COMPOSE_ACCOUNTS, null), ','); final long[] activated_ids = getActivatedAccountIds(this); final long[] intersection = ArrayUtils.intersection(ids_in_prefs, activated_ids); mAccountIds = intersection.length > 0 ? intersection : activated_ids; } final String action = getIntent().getAction(); if (Intent.ACTION_SEND.equals(action) || Intent.ACTION_SEND_MULTIPLE.equals(action)) { setTitle(R.string.share); final Bundle extras = getIntent().getExtras(); if (extras != null) { if (mText == null) { final CharSequence extra_subject = extras.getCharSequence(Intent.EXTRA_SUBJECT); final CharSequence extra_text = extras.getCharSequence(Intent.EXTRA_TEXT); mText = getShareStatus(this, parseString(extra_subject), parseString(extra_text)); } else { mText = bundle.getString(INTENT_KEY_TEXT); } if (mImageUri == null) { final Uri extra_stream = extras.getParcelable(Intent.EXTRA_STREAM); final String content_type = getIntent().getType(); if (extra_stream != null && content_type != null && content_type.startsWith("image/")) { final String real_path = getImagePathFromUri(this, extra_stream); final File file = real_path != null ? new File(real_path) : null; if (file != null && file.exists()) { mImageUri = Uri.fromFile(file); mIsImageAttached = true; mIsPhotoAttached = false; } else { mImageUri = null; mIsImageAttached = false; } } } } } else if (bundle != null) { if (bundle.getString(INTENT_KEY_TEXT) != null) { mText = bundle.getString(INTENT_KEY_TEXT); } } } final File image_file = mImageUri != null && "file".equals(mImageUri.getScheme()) ? new File(mImageUri.getPath()) : null; final boolean image_file_valid = image_file != null && image_file.exists(); mImageThumbnailPreview.setVisibility(image_file_valid ? View.VISIBLE : View.GONE); if (image_file_valid) { reloadAttachedImageThumbnail(image_file); } mImageThumbnailPreview.setOnClickListener(this); mImageThumbnailPreview.setOnLongClickListener(this); mMenuBar.setOnMenuItemClickListener(this); mMenuBar.inflate(R.menu.menu_compose); mMenuBar.show(); if (mPreferences.getBoolean(PREFERENCE_KEY_QUICK_SEND, false)) { mEditText.setRawInputType(InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_FLAG_CAP_SENTENCES | InputType.TYPE_TEXT_FLAG_MULTI_LINE | InputType.TYPE_TEXT_FLAG_AUTO_CORRECT); mEditText.setMovementMethod(ArrowKeyMovementMethod.getInstance()); mEditText.setImeOptions(EditorInfo.IME_ACTION_GO); mEditText.setOnEditorActionListener(this); } mEditText.addTextChangedListener(this); if (mText != null) { mEditText.setText(mText); if (mIsQuote) { mEditText.setSelection(0); } else if (text_selection_start != -1 && text_selection_start < mEditText.length() && mEditText.length() > 0) { mEditText.setSelection(text_selection_start, mEditText.length() - 1); } else if (mEditText.length() > 0) { mEditText.setSelection(mEditText.length()); } } invalidateSupportOptionsMenu(); setMenu(); if (mColorIndicator != null) { mColorIndicator.setOrientation(ColorView.VERTICAL); mColorIndicator.setColor(getAccountColors(this, mAccountIds)); } mContentModified = savedInstanceState != null ? savedInstanceState.getBoolean(INTENT_KEY_CONTENT_MODIFIED) : false; mIsPossiblySensitive = savedInstanceState != null ? savedInstanceState.getBoolean(INTENT_KEY_IS_POSSIBLY_SENSITIVE) : false; }
From source file:com.microsoft.onedrive.apiexplorer.ItemFragment.java
/** * Renames a sourceItem/*from w w w . j a v a 2s.c o m*/ * @param sourceItem The sourceItem to rename */ private void renameItem(final Item sourceItem) { final Activity activity = getActivity(); final EditText newName = new EditText(activity); newName.setInputType(InputType.TYPE_CLASS_TEXT); newName.setHint(sourceItem.name); final AlertDialog alertDialog = new AlertDialog.Builder(activity).setTitle(R.string.rename) .setIcon(android.R.drawable.ic_menu_edit).setView(newName) .setPositiveButton(R.string.rename, new DialogInterface.OnClickListener() { @Override public void onClick(final DialogInterface dialog, final int which) { final ICallback<Item> callback = new DefaultCallback<Item>(getActivity()) { @Override public void success(final Item item) { Toast.makeText(activity, activity.getString(R.string.renamed_item, sourceItem.name, item.name), Toast.LENGTH_LONG).show(); refresh(); dialog.dismiss(); } @Override public void failure(final ClientException error) { Toast.makeText(activity, activity.getString(R.string.rename_error, sourceItem.name), Toast.LENGTH_LONG).show(); dialog.dismiss(); } }; Item updatedItem = new Item(); updatedItem.id = sourceItem.id; updatedItem.name = newName.getText().toString(); ((BaseApplication) activity.getApplication()).getOneDriveClient().getDrive() .getItems(updatedItem.id).buildRequest().update(updatedItem, callback); } }).setNegativeButton("Cancel", new DialogInterface.OnClickListener() { @Override public void onClick(final DialogInterface dialog, final int which) { dialog.cancel(); } }).create(); alertDialog.show(); }