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:net.henryco.opalette.application.MainActivity.java
@Override public void setResultBitmap(Bitmap bitmap) { SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(this); ImageView imageView = new ImageView(this); imageView.setImageBitmap(bitmap);//from w w w . j a va2 s . co m String name = GodConfig.genDefaultImgFileName(); new OPallAlertDialog().title("").content(imageView) .positive(getResources().getString(R.string.save), () -> { View v = new LinearLayout(this); OPallViewInjector.inject(this, new OPallViewInjector<AppMainProto>(v, R.layout.textline) { @Override protected void onInject(AppMainProto context, View view) { TextView imageNameLine = (TextView) view.findViewById(R.id.lineText); imageNameLine.setInputType(InputType.TYPE_CLASS_TEXT); imageNameLine.setText(name); new OPallAlertDialog().title(getResources().getString(R.string.save_as)).content(v) .positive(getResources().getString(R.string.save), () -> { Utils.saveBitmapAction(bitmap, imageNameLine.getText().toString(), context.getActivityContext()); createSaveSuccessNotification(context.getActivityContext(), name); }).negative(getResources().getString(R.string.cancel)) .show(getSupportFragmentManager(), "Bitmap save"); } }); }) .negative(getResources().getString(R.string.share), () -> Utils.shareBitmapAction(bitmap, name, this, preferences.getBoolean(GodConfig.PREF_KEY_SAVE_AFTER, false), () -> createSaveSuccessNotification(this, name))) .neutral(getResources().getString(R.string.cancel)) .show(getSupportFragmentManager(), "Bitmap preview"); }
From source file:it.mb.whatshare.Dialogs.java
/** * Shows a prompt to the user to rename the argument <tt>device</tt>. * /*from w w w . jav a 2 s .c o m*/ * @param device * the device to be renamed * @param activity * the parent activity */ public static void promptForNewDeviceName(final PairedDevice device, final MainActivity activity) { Handler handler = new Handler(Looper.getMainLooper()); handler.post(new Runnable() { @Override public void run() { DialogFragment prompt = new PatchedDialogFragment() { public Dialog onCreateDialog(Bundle savedInstanceState) { AlertDialog.Builder builder = getBuilder(activity); final EditText input = new EditText(getContext()); input.setInputType(InputType.TYPE_CLASS_TEXT); input.setText(device.name); input.setSelection(device.name.length()); // @formatter:off builder.setTitle(R.string.device_name_chooser_title).setView(input) .setPositiveButton(android.R.string.ok, null); // @formatter:on final AlertDialog alertDialog = builder.create(); alertDialog.setOnShowListener( new DeviceNameChooserPrompt(alertDialog, input, activity, new Callback<String>() { @Override public void run() { // @formatter:off device.rename(getParam()); activity.onSelectedDeviceRenamed(); ((InputMethodManager) activity .getSystemService(Context.INPUT_METHOD_SERVICE)) .hideSoftInputFromWindow(input.getWindowToken(), 0); // @formatter:on } })); return alertDialog; } }; prompt.show(activity.getSupportFragmentManager(), "chooseName"); } }); }
From source file:com.hughes.android.dictionary.DictionaryManagerActivity.java
private void onCreateSetupActionBar() { ActionBar actionBar = getSupportActionBar(); actionBar.setDisplayShowTitleEnabled(false); actionBar.setDisplayShowHomeEnabled(false); actionBar.setDisplayHomeAsUpEnabled(false); filterSearchView = new SearchView(getSupportActionBar().getThemedContext()); filterSearchView.setIconifiedByDefault(false); // filterSearchView.setIconified(false); // puts the magnifying glass in // the/* w ww. ja v a 2s .com*/ // wrong place. filterSearchView.setQueryHint(getString(R.string.searchText)); filterSearchView.setSubmitButtonEnabled(false); FrameLayout.LayoutParams lp = new FrameLayout.LayoutParams(FrameLayout.LayoutParams.WRAP_CONTENT, FrameLayout.LayoutParams.WRAP_CONTENT); filterSearchView.setLayoutParams(lp); filterSearchView.setInputType(InputType.TYPE_CLASS_TEXT); filterSearchView.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); filterSearchView.setOnQueryTextListener(new OnQueryTextListener() { @Override public boolean onQueryTextSubmit(String query) { filterSearchView.clearFocus(); return false; } @Override public boolean onQueryTextChange(String filterText) { setMyListAdapater(); return true; } }); filterSearchView.setFocusable(true); actionBar.setCustomView(filterSearchView); actionBar.setDisplayShowCustomEnabled(true); // Avoid wasting space on large left inset Toolbar tb = (Toolbar) filterSearchView.getParent(); tb.setContentInsetsRelative(0, 0); }
From source file:org.eatabrick.vecna.Vecna.java
private void getPassphrase() { final EditText pass = new EditText(this); pass.setInputType(InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_VARIATION_PASSWORD); AlertDialog.Builder builder = new AlertDialog.Builder(this); builder.setMessage(getString(R.string.prompt)); builder.setView(pass);/*from www .jav a2s .co m*/ builder.setPositiveButton(android.R.string.ok, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int which) { passphrase = pass.getText().toString(); if (passphrase.length() != 0) new ReadEntriesTask().execute(passphrase); } }); builder.show(); }
From source file:com.mobicage.rogerthat.SendMessageButtonActivity.java
private void addButton() { final View dialog = getLayoutInflater().inflate(R.layout.new_button_dialog, null); final TextInputLayout captionViewLayout = (TextInputLayout) dialog.findViewById(R.id.button_caption); mCaptionView = captionViewLayout.getEditText(); mActionView = (EditText) dialog.findViewById(R.id.button_action); final ImageButton actionHelpButton = (ImageButton) dialog.findViewById(R.id.action_help_button); final RadioButton noneRadio = (RadioButton) dialog.findViewById(R.id.action_none); final RadioButton telRadio = (RadioButton) dialog.findViewById(R.id.action_tel); final RadioButton geoRadio = (RadioButton) dialog.findViewById(R.id.action_geo); final RadioButton wwwRadio = (RadioButton) dialog.findViewById(R.id.action_www); final int iconColor = LookAndFeelConstants.getPrimaryIconColor(SendMessageButtonActivity.this); noneRadio.setChecked(true);//w w w .j a va2s. c om mActionView.setVisibility(View.GONE); actionHelpButton.setVisibility(View.GONE); noneRadio.setOnClickListener(new SafeViewOnClickListener() { @Override public void safeOnClick(View v) { mActionView.setVisibility(View.GONE); actionHelpButton.setVisibility(View.GONE); } }); telRadio.setOnClickListener(new SafeViewOnClickListener() { @Override public void safeOnClick(View v) { mActionView.setText(""); mActionView.setVisibility(View.VISIBLE); mActionView.setInputType(InputType.TYPE_CLASS_PHONE); actionHelpButton.setVisibility(View.VISIBLE); actionHelpButton.setImageDrawable(new IconicsDrawable(mService, FontAwesome.Icon.faw_address_book_o) .color(iconColor).sizeDp(24)); } }); geoRadio.setOnClickListener(new SafeViewOnClickListener() { @Override public void safeOnClick(View v) { mActionView.setText(""); mActionView.setVisibility(View.VISIBLE); mActionView.setInputType(InputType.TYPE_CLASS_TEXT); actionHelpButton.setVisibility(View.VISIBLE); actionHelpButton.setImageDrawable( new IconicsDrawable(mService, FontAwesome.Icon.faw_map_marker).color(iconColor).sizeDp(24)); } }); wwwRadio.setOnClickListener(new SafeViewOnClickListener() { @Override public void safeOnClick(View v) { mActionView.setText("http://"); mActionView.setVisibility(View.VISIBLE); mActionView.setInputType(InputType.TYPE_CLASS_TEXT); actionHelpButton.setVisibility(View.GONE); } }); actionHelpButton.setOnClickListener(new SafeViewOnClickListener() { @Override public void safeOnClick(View v) { if (telRadio.isChecked()) { Intent intent = new Intent(Intent.ACTION_PICK, ContactsContract.CommonDataKinds.Phone.CONTENT_URI); startActivityForResult(intent, PICK_CONTACT); } else if (geoRadio.isChecked()) { Intent intent = new Intent(SendMessageButtonActivity.this, GetLocationActivity.class); startActivityForResult(intent, GET_LOCATION); } } }); String message = getString(R.string.create_button_title); String positiveCaption = getString(R.string.ok); String negativeCaption = getString(R.string.cancel); SafeDialogClick positiveClick = new SafeDialogClick() { @Override public void safeOnClick(DialogInterface di, int id) { String caption = mCaptionView.getText().toString(); if ("".equals(caption.trim())) { UIUtils.showLongToast(SendMessageButtonActivity.this, getString(R.string.caption_required)); return; } CannedButton cannedButton; if (!noneRadio.isChecked()) { String actionText = mActionView.getText().toString(); if ("".equals(caption.trim())) { UIUtils.showLongToast(SendMessageButtonActivity.this, getString(R.string.action_not_valid)); return; } if (telRadio.isChecked()) { actionText = "tel://" + actionText; } else if (geoRadio.isChecked()) { actionText = "geo://" + actionText; } Matcher action = actionPattern.matcher(actionText); if (!action.matches()) { UIUtils.showLongToast(SendMessageButtonActivity.this, getString(R.string.action_not_valid)); return; } cannedButton = new CannedButton(caption, "".equals(action.group(2)) ? null : action.group()); } else { cannedButton = new CannedButton(caption, null); } mCannedButtons.add(cannedButton); cannedButton.setSelected(true); mCannedButtonAdapter.notifyDataSetChanged(); mButtons.add(cannedButton.getId()); di.dismiss(); } }; AlertDialog alertDialog = UIUtils.showDialog(SendMessageButtonActivity.this, null, message, positiveCaption, positiveClick, negativeCaption, null, dialog); alertDialog.setCanceledOnTouchOutside(true); }
From source file:com.grarak.kerneladiutor.fragments.other.SettingsFragment.java
private void editPasswordDialog(final String oldPass) { mOldPassword = oldPass;/* ww w . j a v a 2 s .com*/ LinearLayout linearLayout = new LinearLayout(getActivity()); linearLayout.setOrientation(LinearLayout.VERTICAL); linearLayout.setGravity(Gravity.CENTER); int padding = Math.round(getResources().getDimension(R.dimen.dialog_padding)); linearLayout.setPadding(padding, padding, padding, padding); final AppCompatEditText oldPassword = new AppCompatEditText(getActivity()); if (!oldPass.isEmpty()) { oldPassword.setInputType(InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_VARIATION_PASSWORD); oldPassword.setHint(getString(R.string.old_password)); linearLayout.addView(oldPassword); } final AppCompatEditText newPassword = new AppCompatEditText(getActivity()); newPassword.setInputType(InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_VARIATION_PASSWORD); newPassword.setHint(getString(R.string.new_password)); linearLayout.addView(newPassword); final AppCompatEditText confirmNewPassword = new AppCompatEditText(getActivity()); confirmNewPassword.setInputType(InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_VARIATION_PASSWORD); confirmNewPassword.setHint(getString(R.string.confirm_new_password)); linearLayout.addView(confirmNewPassword); new Dialog(getActivity()).setView(linearLayout) .setNegativeButton(getString(R.string.cancel), new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialogInterface, int i) { } }).setPositiveButton(getString(R.string.ok), new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialogInterface, int i) { if (!oldPass.isEmpty() && !oldPassword.getText().toString().equals(Utils.decodeString(oldPass))) { Utils.toast(getString(R.string.old_password_wrong), getActivity()); return; } if (newPassword.getText().toString().isEmpty()) { Utils.toast(getString(R.string.password_empty), getActivity()); return; } if (!newPassword.getText().toString().equals(confirmNewPassword.getText().toString())) { Utils.toast(getString(R.string.password_not_match), getActivity()); return; } if (newPassword.getText().toString().length() > 32) { Utils.toast(getString(R.string.password_too_long), getActivity()); return; } Prefs.saveString("password", Utils.encodeString(newPassword.getText().toString()), getActivity()); if (mFingerprint != null) { mFingerprint.setEnabled(true); } } }).setOnDismissListener(new DialogInterface.OnDismissListener() { @Override public void onDismiss(DialogInterface dialogInterface) { mOldPassword = null; } }).show(); }
From source file:com.rsltc.profiledata.main.MainActivity.java
private void showSaveDialog(final List<JSONObject> jsonObjectList) { AlertDialog.Builder builder = new AlertDialog.Builder(thisActivity); builder.setTitle("Dataset title"); final EditText input = new EditText(thisActivity); input.setInputType(InputType.TYPE_CLASS_TEXT); builder.setView(input);//from www. j ava 2 s .c o m builder.setPositiveButton("OK", new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { final String m_Text = input.getText().toString(); Runnable r = new Runnable() { @Override public void run() { exportFile(jsonObjectList, m_Text); } }; Thread t = new Thread(r); t.start(); } }); builder.setNegativeButton("Cancel", new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { dialog.cancel(); } }); builder.show(); }
From source file:com.leavjenn.smoothdaterangepicker.date.SmoothDateRangePickerFragment.java
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { // Log.d(TAG, "onCreateView: "); getDialog().getWindow().requestFeature(Window.FEATURE_NO_TITLE); View view = inflater.inflate(R.layout.sdrp_dialog, container); mDayOfWeekView = (TextView) view.findViewById(R.id.date_picker_header); mDayOfWeekViewEnd = (TextView) view.findViewById(R.id.date_picker_header_end); mMonthAndDayView = (LinearLayout) view.findViewById(R.id.date_picker_month_and_day); mMonthAndDayViewEnd = (LinearLayout) view.findViewById(R.id.date_picker_month_and_day_end); mMonthAndDayView.setOnClickListener(this); mMonthAndDayViewEnd.setOnClickListener(this); mSelectedMonthTextView = (TextView) view.findViewById(R.id.date_picker_month); mSelectedMonthTextViewEnd = (TextView) view.findViewById(R.id.date_picker_month_end); mSelectedDayTextView = (TextView) view.findViewById(R.id.date_picker_day); mSelectedDayTextViewEnd = (TextView) view.findViewById(R.id.date_picker_day_end); mYearView = (TextView) view.findViewById(R.id.date_picker_year); mYearViewEnd = (TextView) view.findViewById(R.id.date_picker_year_end); mYearView.setOnClickListener(this); mYearViewEnd.setOnClickListener(this); mDurationView = (LinearLayout) view.findViewById(R.id.date_picker_duration_layout); mDurationView.setOnClickListener(this); mDurationTextView = (TextView) view.findViewById(R.id.date_picker_duration_days); mDurationEditText = (EditText) view.findViewById(R.id.date_picker_duration_days_et); // disable soft keyboard popup when edittext is selected mDurationEditText.setRawInputType(InputType.TYPE_CLASS_TEXT); mDurationEditText.setTextIsSelectable(true); mDurationDayTextView = (TextView) view.findViewById(R.id.tv_duration_day); mDurationArrow = (TextView) view.findViewById(R.id.arrow_start); mDurationArrow.setOnClickListener(this); mDurationArrowEnd = (TextView) view.findViewById(R.id.arrow_end); mDurationArrowEnd.setOnClickListener(this); viewList = new ArrayList<>(); viewList.add(MONTH_AND_DAY_VIEW, mMonthAndDayView); viewList.add(YEAR_VIEW, mYearView);/* w ww. ja v a 2s . c o m*/ viewList.add(MONTH_AND_DAY_VIEW_END, mMonthAndDayViewEnd); viewList.add(YEAR_VIEW_END, mYearViewEnd); viewList.add(DURATION_VIEW, mDurationView); int listPosition = -1; int listPositionOffset = 0; int listPositionEnd = -1; int listPositionOffsetEnd = 0; int currentView = MONTH_AND_DAY_VIEW; if (savedInstanceState != null) { mWeekStart = savedInstanceState.getInt(KEY_WEEK_START); mMinYear = savedInstanceState.getInt(KEY_YEAR_START); mMaxYear = savedInstanceState.getInt(KEY_YEAR_END); currentView = savedInstanceState.getInt(KEY_CURRENT_VIEW); listPosition = savedInstanceState.getInt(KEY_LIST_POSITION); listPositionOffset = savedInstanceState.getInt(KEY_LIST_POSITION_OFFSET); listPositionEnd = savedInstanceState.getInt(KEY_LIST_POSITION_END); listPositionOffsetEnd = savedInstanceState.getInt(KEY_LIST_POSITION_OFFSET_END); mMinDate = (Calendar) savedInstanceState.getSerializable(KEY_MIN_DATE); mMaxDate = (Calendar) savedInstanceState.getSerializable(KEY_MAX_DATE); mMinSelectableDate = (Calendar) savedInstanceState.getSerializable(KEY_MIN_DATE_SELECTABLE); highlightedDays = (Calendar[]) savedInstanceState.getSerializable(KEY_HIGHLIGHTED_DAYS); selectableDays = (Calendar[]) savedInstanceState.getSerializable(KEY_SELECTABLE_DAYS); mThemeDark = savedInstanceState.getBoolean(KEY_THEME_DARK); mAccentColor = savedInstanceState.getInt(KEY_ACCENT); mVibrate = savedInstanceState.getBoolean(KEY_VIBRATE); mDismissOnPause = savedInstanceState.getBoolean(KEY_DISMISS); } final Activity activity = getActivity(); mDayPickerView = new SimpleDayPickerView(activity, this); mYearPickerView = new YearPickerView(activity, this); mDayPickerViewEnd = new SimpleDayPickerView(activity, this); mYearPickerViewEnd = new YearPickerView(activity, this); mNumberPadView = new NumberPadView(activity, this); Resources res = getResources(); mDayPickerDescription = res.getString(R.string.mdtp_day_picker_description); mSelectDay = res.getString(R.string.mdtp_select_day); mYearPickerDescription = res.getString(R.string.mdtp_year_picker_description); mSelectYear = res.getString(R.string.mdtp_select_year); int bgColorResource = mThemeDark ? R.color.mdtp_date_picker_view_animator_dark_theme : R.color.mdtp_date_picker_view_animator; view.setBackgroundColor(activity.getResources().getColor(bgColorResource)); if (mThemeDark) { view.findViewById(R.id.hyphen).setBackgroundColor( activity.getResources().getColor(R.color.date_picker_selector_unselected_dark_theme)); Utils.setMultiTextColorList(activity.getResources().getColorStateList(R.color.sdrp_selector_dark), mDayOfWeekView, mDayOfWeekViewEnd, mSelectedMonthTextView, mSelectedMonthTextViewEnd, mSelectedDayTextView, mSelectedDayTextViewEnd, mYearView, mYearViewEnd, mDurationTextView, mDurationDayTextView, mDurationArrow, mDurationArrowEnd, mDurationEditText, (TextView) view.findViewById(R.id.tv_duration)); } mAnimator = (AccessibleDateAnimator) view.findViewById(R.id.animator); mAnimator.addView(mDayPickerView); mAnimator.addView(mYearPickerView); mAnimator.addView(mDayPickerViewEnd); mAnimator.addView(mYearPickerViewEnd); mAnimator.addView(mNumberPadView); mAnimator.setDateMillis(mCalendar.getTimeInMillis()); Animation animation = new AlphaAnimation(0.0f, 1.0f); animation.setDuration(ANIMATION_DURATION); mAnimator.setInAnimation(animation); Animation animation2 = new AlphaAnimation(1.0f, 0.0f); animation2.setDuration(ANIMATION_DURATION); mAnimator.setOutAnimation(animation2); Button okButton = (Button) view.findViewById(R.id.ok); okButton.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { tryVibrate(); if (mCallBack != null) { mCallBack.onDateRangeSet(SmoothDateRangePickerFragment.this, mCalendar.get(Calendar.YEAR), mCalendar.get(Calendar.MONTH), mCalendar.get(Calendar.DAY_OF_MONTH), mCalendarEnd.get(Calendar.YEAR), mCalendarEnd.get(Calendar.MONTH), mCalendarEnd.get(Calendar.DAY_OF_MONTH)); } dismiss(); } }); okButton.setTypeface(TypefaceHelper.get(activity, "Roboto-Medium")); Button cancelButton = (Button) view.findViewById(R.id.cancel); cancelButton.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { tryVibrate(); if (getDialog() != null) getDialog().cancel(); } }); cancelButton.setTypeface(TypefaceHelper.get(activity, "Roboto-Medium")); cancelButton.setVisibility(isCancelable() ? View.VISIBLE : View.GONE); //If an accent color has not been set manually, try and get it from the context if (mAccentColor == -1) { int accentColor = Utils.getAccentColorFromThemeIfAvailable(getActivity()); if (accentColor != -1) { mAccentColor = accentColor; } } if (mAccentColor != -1) { if (mDayOfWeekView != null) mDayOfWeekView.setBackgroundColor(mAccentColor); if (mDayOfWeekViewEnd != null) mDayOfWeekViewEnd.setBackgroundColor(mAccentColor); view.findViewById(R.id.layout_container).setBackgroundColor(mAccentColor); view.findViewById(R.id.day_picker_selected_date_layout).setBackgroundColor(mAccentColor); view.findViewById(R.id.day_picker_selected_date_layout_end).setBackgroundColor(mAccentColor); mDurationView.setBackgroundColor(mAccentColor); mDurationEditText.setHighlightColor(Utils.darkenColor(mAccentColor)); mDurationEditText.getBackground().setColorFilter(Utils.darkenColor(mAccentColor), PorterDuff.Mode.SRC_ATOP); okButton.setTextColor(mAccentColor); cancelButton.setTextColor(mAccentColor); mYearPickerView.setAccentColor(mAccentColor); mDayPickerView.setAccentColor(mAccentColor); mYearPickerViewEnd.setAccentColor(mAccentColor); mDayPickerViewEnd.setAccentColor(mAccentColor); } updateDisplay(false); setCurrentView(currentView); if (listPosition != -1) { if (currentView == MONTH_AND_DAY_VIEW) { mDayPickerView.postSetSelection(listPosition); } else if (currentView == YEAR_VIEW) { mYearPickerView.postSetSelectionFromTop(listPosition, listPositionOffset); } } if (listPositionEnd != -1) { if (currentView == MONTH_AND_DAY_VIEW_END) { mDayPickerViewEnd.postSetSelection(listPositionEnd); } else if (currentView == YEAR_VIEW_END) { mYearPickerViewEnd.postSetSelectionFromTop(listPositionEnd, listPositionOffsetEnd); } } mHapticFeedbackController = new HapticFeedbackController(activity); return view; }
From source file:com.example.carsharing.LongWayActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { photouri = Uri//w w w.j a v a2 s .c o m .fromFile(new File(this.getExternalFilesDir(Environment.DIRECTORY_PICTURES), IMAGE_FILE_NAME2)); System.out.println("abc"); super.onCreate(savedInstanceState); setContentView(R.layout.activity_long_way); activity_drawer = new Drawer(this, R.id.long_way_layout); mDrawerToggle = activity_drawer.newdrawer(); mDrawerLayout = activity_drawer.setDrawerLayout(); // standard_date = new SimpleDateFormat("yyyy-MM-dd", Locale.SIMPLIFIED_CHINESE); primary_date = new SimpleDateFormat("yyyyMMdd", Locale.SIMPLIFIED_CHINESE); queue = Volley.newRequestQueue(this); exchange = (ImageView) findViewById(R.id.longway_exchange); exchange.setOnClickListener(new OnClickListener() { @Override public void onClick(View arg0) { // TODO Auto-generated method stub String temp = startplace.getText().toString(); startplace.setText(endplace.getText().toString()); endplace.setText(temp); } }); bdriver = true; datebutton = (Button) findViewById(R.id.longway_dates); increase = (Button) findViewById(R.id.longway_increase); decrease = (Button) findViewById(R.id.longway_decrease); s1 = (TextView) findViewById(R.id.longway_count); sure = (Button) findViewById(R.id.longway_sure); sure.setEnabled(false); startplace = (EditText) findViewById(R.id.longway_start_place); endplace = (EditText) findViewById(R.id.longway_end_place); noteinfo = (EditText) findViewById(R.id.longway_remarkText); commute = findViewById(R.id.drawer_commute); shortway = findViewById(R.id.drawer_shortway); longway = findViewById(R.id.drawer_longway); 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.longway_CarBrand); model = (EditText) findViewById(R.id.longway_CarModel); color = (EditText) findViewById(R.id.longway_color); setting = findViewById(R.id.drawer_setting); licensenum = (EditText) findViewById(R.id.longway_Num); licensenum.addTextChangedListener(numTextWatcher); carbrand.addTextChangedListener(detTextWatcher); color.addTextChangedListener(coTextWatcher); model.addTextChangedListener(moTextWatcher); startplace.addTextChangedListener(spTextWatcher); endplace.addTextChangedListener(epTextWatcher); final TextView content = (TextView) findViewById(R.id.longway_content); longway_group = (RadioGroup) findViewById(R.id.longway_radiobutton); passangerRadioButton = (RadioButton) findViewById(R.id.longway_radioButton02); driverRadioButton = (RadioButton) findViewById(R.id.longway_radioButton01); personalcenter = findViewById(R.id.drawer_personalcenter); taxi = findViewById(R.id.drawer_taxi); // 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("stpmapname")); bstart = true; endplace.setText(bundle.getString("epmapname")); bend = true; datebutton.setText(bundle.getString("re_longway_startdate")); bdate = true; } // judge the value of "pre_page" // SharedPreferences sharedPref = this.getSharedPreferences(getString(R.string.PreferenceDefaultName), Context.MODE_PRIVATE); UserPhoneNumber = sharedPref.getString(getString(R.string.PreferenceUserPhoneNumber), "0"); // database db = new DatabaseHelper(getApplicationContext(), UserPhoneNumber, null, 1); db1 = db.getWritableDatabase(); about = findViewById(R.id.drawer_respond); 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(LongWayActivity.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(LongWayActivity.this, SettingActivity.class); startActivity(setting); } }); // database end 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(LongWayActivity.this, PersonalCenterActivity.class); personalcenter.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP); startActivity(personalcenter); } }); // RadioGroup longway_group.setOnCheckedChangeListener(new OnCheckedChangeListener() { @Override public void onCheckedChanged(RadioGroup arg0, int checkedId) { // TODO Auto-generated method stub18 // ID // """"textView if (checkedId == passangerRadioButton.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(); } private void selectcarinfo(final String phonenum) { // TODO Auto-generated method stub String carinfo_selectrequest_baseurl = getString(R.string.uri_base) + getString(R.string.uri_CarInfo) + getString(R.string.uri_selectcarinfo_action); Log.d("carinfo_selectrequest_baseurl", carinfo_selectrequest_baseurl); StringRequest stringRequest = new StringRequest(Request.Method.POST, carinfo_selectrequest_baseurl, new Response.Listener<String>() { @Override public void onResponse(String response) { // TODO Auto-generated method stub Log.d("carinfo_select", response); String jas_id = null; JSONObject json1 = null; try { json1 = new JSONObject(response); JSONObject json = json1.getJSONObject("result"); jas_id = json.getString("id"); if (jas_id.compareTo("") != 0) { // carinfochoosing_type = 2; carbrand.setText(json.getString("carBrand")); model.setText(json.getString("carModel")); licensenum.setText(json.getString("carNum")); color.setText(json.getString("carColor")); } { carinfochoosing_type = 1; } } catch (JSONException e) { // TODO Auto-generated catch block e.printStackTrace(); } } }, new Response.ErrorListener() { @Override public void onErrorResponse(VolleyError error) { // TODO Auto-generated method stub Log.e("carinfo_selectresult_result", error.getMessage(), error); } }) { protected Map<String, String> getParams() { Map<String, String> params = new HashMap<String, String>(); params.put("phonenum", phonenum); return params; } }; queue.add(stringRequest); } }); sure.setOnClickListener(new OnClickListener() { @Override public void onClick(View arg0) { // TODO Auto-generated method stub if (longway_group.getCheckedRadioButtonId() == passangerRadioButton.getId()) userrole = "p"; else userrole = "d"; // start! Context phonenumber = LongWayActivity.this; SharedPreferences filename = phonenumber .getSharedPreferences(getString(R.string.PreferenceDefaultName), Context.MODE_PRIVATE); username = filename.getString("refreshfilename", "0"); longway_request(username, userrole, datebutton.getText().toString(), startplace.getText().toString(), endplace.getText().toString(), noteinfo.getText().toString()); // end! } private void longway_request(final String longway_phonenum, final String longway_userrole, final String longway_startdate, final String longway_startplace, final String longway_destination, final String longway_noteinfo) { // TODO Auto-generated method stub String longway_addrequest_baseurl = getString(R.string.uri_base) + getString(R.string.uri_LongwayPublish) + getString(R.string.uri_addpublish_action); // + "phonenum=" + longway_phonenum // + "&userrole=" + longway_userrole // + "&startdate=" + standard_longway_startdate // + "&startplace=" + longway_startplace // + "&destination=" + longway_destination // + "¬einfo=" + longway_noteinfo; // Log.d("longway_baseurl",longway_addrequest_baseurl); StringRequest stringRequest = new StringRequest(Request.Method.POST, longway_addrequest_baseurl, new Response.Listener<String>() { @Override public void onResponse(String response) { Log.d("longway_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(longway_phonenum, licensenum.getText().toString(), carbrand.getText().toString(), model.getText().toString(), color.getText().toString(), String.valueOf(sum), 1); // end! } else { // update // start! carinfo(longway_phonenum, licensenum.getText().toString(), carbrand.getText().toString(), model.getText().toString(), color.getText().toString(), String.valueOf(sum), 2); // end! } Intent sure = new Intent(LongWayActivity.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(LongWayActivity.this, OrderResponseActivity.class); sure.putExtra(getString(R.string.request_response), "false"); sure.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP); startActivity(sure); } } }, new Response.ErrorListener() { @Override public void onErrorResponse(VolleyError error) { Log.e("longway_result", error.getMessage(), error); // Toast errorinfo = Toast.makeText(null, // "", Toast.LENGTH_LONG); // errorinfo.show(); Intent sure = new Intent(LongWayActivity.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(longway_startdate); standard_longway_startdate = standard_date.format(test_date); } catch (ParseException e) { // TODO Auto-generated catch block e.printStackTrace(); } // end! Map<String, String> params = new HashMap<String, String>(); params.put(getString(R.string.uri_phonenum), longway_phonenum); params.put(getString(R.string.uri_userrole), longway_userrole); params.put(getString(R.string.uri_startplace), longway_startplace); params.put(getString(R.string.uri_destination), longway_destination); params.put(getString(R.string.uri_startdate), standard_longway_startdate); params.put(getString(R.string.uri_noteinfo), longway_noteinfo); return params; } }; queue.add(stringRequest); } }); // start! shortway.setOnClickListener(new OnClickListener() { @Override public void onClick(View arg0) { // TODO Auto-generated method stub mDrawerLayout.closeDrawer(findViewById(R.id.left_drawer)); Intent shortway = new Intent(LongWayActivity.this, ShortWayActivity.class); startActivity(shortway); } }); longway.setOnClickListener(new OnClickListener() { @Override public void onClick(View arg0) { // TODO Auto-generated method stub mDrawerLayout.closeDrawer(findViewById(R.id.left_drawer)); } }); 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(LongWayActivity.this, CommuteActivity.class); startActivity(commute); } }); // end! increase.setOnClickListener(new OnClickListener() { @Override public void onClick(View arg0) { // TODO Auto-generated method stub sum++; s1.setText("" + sum); confirm(); } }); decrease.setOnClickListener(new OnClickListener() { @Override public void onClick(View arg0) { // TODO Auto-generated method stub sum--; if (sum < 0) { sum = 0; } s1.setText("" + sum); confirm(); } }); datebutton.setOnClickListener(new OnClickListener() { @Override public void onClick(View arg0) { // TODO Auto-generated method stub showDialog(DATE_DIALOG); } }); }
From source file:com.geecko.QuickLyric.fragment.LyricsViewFragment.java
private void startEditTagsMode() { ImageButton editButton = (ImageButton) getActivity().findViewById(R.id.edit_tags_btn); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { editButton.setImageResource(R.drawable.ic_edit_anim); ((Animatable) editButton.getDrawable()).start(); } else// ww w .j a va2 s. c o m editButton.setImageResource(R.drawable.ic_done); ((DrawerLayout) ((MainActivity) getActivity()).drawer) .setDrawerLockMode(DrawerLayout.LOCK_MODE_LOCKED_CLOSED); mRefreshLayout.setEnabled(false); getActivity().findViewById(R.id.refresh_fab).setEnabled(false); ((RefreshIcon) getActivity().findViewById(R.id.refresh_fab)).hide(); ((Toolbar) getActivity().findViewById(R.id.toolbar)).getMenu().clear(); TextSwitcher textSwitcher = ((TextSwitcher) getActivity().findViewById(R.id.switcher)); EditText songTV = (EditText) getActivity().findViewById(R.id.song); TextView artistTV = ((TextView) getActivity().findViewById(R.id.artist)); EditText newLyrics = (EditText) getActivity().findViewById(R.id.edit_lyrics); newLyrics.setTypeface(LyricsTextFactory.FontCache.get("light", getActivity())); newLyrics.setText(((TextView) textSwitcher.getCurrentView()).getText(), TextView.BufferType.EDITABLE); textSwitcher.setVisibility(View.GONE); newLyrics.setVisibility(View.VISIBLE); songTV.setInputType(InputType.TYPE_CLASS_TEXT); artistTV.setInputType(InputType.TYPE_CLASS_TEXT); songTV.setBackgroundResource(R.drawable.abc_textfield_search_material); artistTV.setBackgroundResource(R.drawable.abc_textfield_search_material); if (songTV.requestFocus()) { InputMethodManager imm = (InputMethodManager) getActivity().getApplicationContext() .getSystemService(Context.INPUT_METHOD_SERVICE); imm.toggleSoftInput(InputMethodManager.SHOW_FORCED, InputMethodManager.SHOW_IMPLICIT); } }