public void updateType(Amenity amenity) { poiTypeEditText.setText(amenity.getSubType()); poiTypeTextInputLayout.setHint(amenity.getType().getTranslation()); setAdapterForPoiTypeEditText(); poiTypeEditText.setOnTouchListener( new View.OnTouchListener() { @Override public boolean onTouch(final View v, MotionEvent event) { final EditText editText = (EditText) v; final int DRAWABLE_RIGHT = 2; if (event.getAction() == MotionEvent.ACTION_UP) { if (event.getX() >= (editText.getRight() - editText.getCompoundDrawables()[DRAWABLE_RIGHT].getBounds().width() - editText.getPaddingRight())) { if (editPoiData.amenity.getType() != null) { DialogFragment dialogFragment = PoiSubTypeDialogFragment.createInstance(editPoiData.amenity); dialogFragment.show(getChildFragmentManager(), "PoiSubTypeDialogFragment"); } return true; } } return false; } }); }
/** This initialise the email autocomplete with all emails accounts in the devise. */ private void emailInitialisation() { final Set<String> emails = new HashSet<>(); Account[] accounts = AccountManager.get(this).getAccounts(); for (Account account : accounts) { if (Patterns.EMAIL_ADDRESS.matcher(account.name).matches()) { emails.add(account.name); } } // Create the adapter and set it to the loginEmail ArrayAdapter<String> adapter = new ArrayAdapter<>(this, android.R.layout.simple_list_item_1, new ArrayList<>(emails)); emailLogin.setAdapter(adapter); final String selectedEmail = ActivityManager.getSharedStringValue(this, SELECTED_EMAIL, null); if (null != selectedEmail) { emailLogin.setText(selectedEmail); } else if (!emails.isEmpty()) { emailLogin.setText(emails.iterator().next()); } emailLogin.setOnTouchListener( new View.OnTouchListener() { @Override public boolean onTouch(View v, MotionEvent event) { if (event.getAction() == MotionEvent.ACTION_DOWN) { if (event.getRawX() >= (emailLogin.getRight() - emailLogin.getCompoundDrawables()[2].getBounds().width())) { emailLogin.setText(null); return true; } } emailLogin.getBackground().clearColorFilter(); emailLoginError.setVisibility(View.GONE); return false; } }); }
@Nullable @Override public View onCreateView( LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { rootview = inflater.inflate(R.layout.offre_layout, container, false); Typeface font = Typeface.createFromAsset( getActivity().getAssets(), "font-awesome-4.3.0/fonts/fontawesome-webfont.ttf"); autoCompViewFrom = (AutoCompleteTextView) rootview.findViewById(R.id.etStarting); autoCompViewFrom.setTypeface(font); autoCompViewFrom.setAdapter( new PlacesAutoCompleteAdapter(getActivity(), R.layout.list_autocomplete)); autoCompViewTo = (AutoCompleteTextView) rootview.findViewById(R.id.etDestination); autoCompViewTo.setTypeface(font); autoCompViewTo.setAdapter( new PlacesAutoCompleteAdapter(getActivity(), R.layout.list_autocomplete)); // NumericPicker nbre de places etNbreProp = (AutoCompleteTextView) rootview.findViewById(R.id.etNbreProposition); // DatePicker date de depart /** ** Gestion de la date de dpart */ etDate_ = (AutoCompleteTextView) rootview.findViewById(R.id.etDate); // Get current date by calender c_date = Calendar.getInstance(); year_depart = c_date.get(Calendar.YEAR); month_depart = c_date.get(Calendar.MONTH); day_depart = c_date.get(Calendar.DAY_OF_MONTH); etDate_.setText( new StringBuilder() .append(month_depart + 1) .append("-") .append(day_depart) .append("-") .append(year_depart) .append(" ")); mDatePicker = new DatePickerDialog( getActivity(), new DatePickerDialog.OnDateSetListener() { public void onDateSet( DatePicker datepicker, int selectedyear, int selectedmonth, int selectedday) { c_date.set(selectedyear, selectedmonth, selectedday); // si ca se trouve ca sert a rien mais je le fais qd meme year_depart = selectedyear; month_depart = selectedmonth; day_depart = selectedday; etDate_.setText( new StringBuilder() .append(selectedmonth + 1) .append("-") .append(selectedday) .append("-") .append(selectedyear) .append(" ")); } }, year_depart, month_depart, day_depart); etDate_.setOnTouchListener( new View.OnTouchListener() { @Override public boolean onTouch(View v, MotionEvent event) { mDatePicker.setTitle("Date de départ"); mDatePicker.show(); Log.d("log", "dans le logId"); Log.d("anee", "anne " + year_depart); Log.d("mois", "anne " + month_depart); Log.d("jour", "anne " + day_depart); etDate_.requestFocus(); return false; } }); /** Gestion du temps de depart */ // Get current date by calender c_time_entre = Calendar.getInstance(); hour_entre = c_time_entre.get(Calendar.HOUR_OF_DAY); minute_entre = c_time_entre.get(Calendar.MINUTE); ac_etBetweenStart = (AutoCompleteTextView) rootview.findViewById(R.id.etBetweenStart); ac_etBetweenStart.setText( new StringBuilder() .append(padding_str(hour_entre)) .append(":") .append(padding_str(minute_entre))); timePickerListenerEntre = new TimePickerDialog.OnTimeSetListener() { public void onTimeSet(TimePicker view, int selectedHour, int selectedMinute) { hour_entre = selectedHour; minute_entre = selectedMinute; // set current time into textview ac_etBetweenStart.setText( new StringBuilder() .append(padding_str(hour_entre)) .append(":") .append(padding_str(minute_entre))); } }; timePickeraDialog_entre = new TimePickerDialog( getActivity(), timePickerListenerEntre, hour_entre, minute_entre, false); ac_etBetweenStart.setOnTouchListener( new View.OnTouchListener() { @Override public boolean onTouch(View v, MotionEvent event) { timePickeraDialog_entre.show(); Log.d("log", "dans le logId"); Log.d("heure depart", "heure " + hour_entre); Log.d("minute depart", "minute " + minute_entre); ac_etBetweenStart.requestFocus(); return false; } }); /** * Gestion du temps d'arrivee */ // TimePicker et ac_etBetweenEnd = (AutoCompleteTextView) rootview.findViewById(R.id.etBetweenEnd); c_time_et = Calendar.getInstance(); hour_et = c_time_et.get(Calendar.HOUR_OF_DAY); minute_et = c_time_et.get(Calendar.MINUTE); ac_etBetweenEnd.setText( new StringBuilder() .append(padding_str(hour_et)) .append(":") .append(padding_str(minute_et))); timePickerListenerEt = new TimePickerDialog.OnTimeSetListener() { public void onTimeSet(TimePicker view, int selectedHour, int selectedMinute) { hour_et = selectedHour; minute_et = selectedMinute; // set current time into textview ac_etBetweenEnd.setText( new StringBuilder() .append(padding_str(hour_et)) .append(":") .append(padding_str(minute_et))); } }; timePickerDialog_et = new TimePickerDialog(getActivity(), timePickerListenerEt, hour_et, minute_et, false); ac_etBetweenEnd.setOnTouchListener( new View.OnTouchListener() { @Override public boolean onTouch(View v, MotionEvent event) { timePickerDialog_et.show(); Log.d("log", "dans le logId"); Log.d("heure arrivee", "heure " + hour_et); Log.d("minute arrivee", "minute " + minute_et); ac_etBetweenEnd.requestFocus(); return true; } }); Button submitOffer = (Button) (rootview.findViewById(R.id.btnSubmitOffer)); font = Typeface.createFromAsset( getActivity().getAssets(), "font-awesome-4.3.0/fonts/fontawesome-webfont.ttf"); submitOffer.append(" Ajouter Offre"); submitOffer.setTypeface(font); submitOffer.setOnClickListener( new View.OnClickListener() { @Override public void onClick(View v) { // on verifie que l'utilisateur est connecte avant de rajouter une offre ParseUser current = ParseUser.getCurrentUser(); List<String> address = new ArrayList<>(); String eStarting = autoCompViewFrom.getText().toString(); String eDestination = autoCompViewTo.getText().toString(); String nbProp = etNbreProp.getText().toString(); if (eStarting.length() > 0 && eDestination.length() > 0 && nbProp.length() > 0) { address.add(eStarting); address.add(eDestination); if (current != null) { GeocodingLocation locationAddress = new GeocodingLocation(); locationAddress.getAddressFromLocation( address, getActivity().getApplicationContext(), new GeocoderHandler()); } else { Bundle bundle = new Bundle(); bundle.putString("textContent", getString(R.string.content_dialog_offer)); WarningConnectionFragment wcf = new WarningConnectionFragment(); wcf.setArguments(bundle); wcf.show(getActivity().getSupportFragmentManager(), "Alerte Connexion"); } } else { if (eStarting.length() == 0) { autoCompViewTo.setError("champ obligatoire"); autoCompViewTo.requestFocus(); } else { autoCompViewTo.setError(null); } if (eDestination.length() == 0) { autoCompViewFrom.setError("Champ obligatoire"); autoCompViewFrom.requestFocus(); } else { autoCompViewFrom.setError(null); } if (nbProp.length() == 0) { etNbreProp.setError("Champ obligatoire"); etNbreProp.requestFocus(); } else { etNbreProp.setError(null); } } } }); return rootview; }
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); final AutoCompleteTextView emailText = (AutoCompleteTextView) findViewById(R.id.email); final EditText messageText = (EditText) findViewById(R.id.message); final ApptentiveDialogButton declineButton = (ApptentiveDialogButton) findViewById(R.id.decline); final ApptentiveDialogButton submitButton = (ApptentiveDialogButton) findViewById(R.id.submit); // Pre-populate a list of possible emails based on those pulled from the phone. ArrayAdapter<String> emailAdapter = new ArrayAdapter<String>( getContext(), android.R.layout.simple_dropdown_item_1line, Util.getAllUserAccountEmailAddresses(getContext())); emailText.setAdapter(emailAdapter); emailText.setOnTouchListener( new View.OnTouchListener() { @Override public boolean onTouch(View v, MotionEvent event) { emailText.showDropDown(); return false; } }); emailText.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) { email = charSequence; validateForm(submitButton); } @Override public void afterTextChanged(Editable editable) {} }); messageText.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) { message = charSequence; validateForm(submitButton); } @Override public void afterTextChanged(Editable editable) {} }); declineButton.setEnabled(true); declineButton.setOnClickListener( new View.OnClickListener() { @Override public void onClick(View view) { cancel(); } }); submitButton.setEnabled(false); submitButton.setOnClickListener( new View.OnClickListener() { @Override public void onClick(View view) { if (email != null && email.length() != 0 && !Util.isEmailValid(email.toString())) { EmailValidationFailedDialog dialog = new EmailValidationFailedDialog(getContext()); dialog.show(); return; } if (MessageCenterIntroDialog.this.onSendListener != null) { onSendListener.onSend( emailText.getText().toString(), messageText.getText().toString()); } } }); validateForm(submitButton); }
@Override public void show(final Activity activity) { super.show(activity); activity.setContentView(R.layout.apptentive_feedback_dialog_interaction); // Legacy support: We can remove this when we switch over to 100% interaction based Message // Center. SharedPreferences prefs = activity.getSharedPreferences(Constants.PREF_NAME, Context.MODE_PRIVATE); prefs .edit() .putBoolean(Constants.PREF_KEY_MESSAGE_CENTER_SHOULD_SHOW_INTRO_DIALOG, false) .commit(); if (!thankYouDialogVisible) { if (!feedbackDialogVisible) { EngagementModule.engageInternal(activity, interaction.getType().name(), CODE_POINT_LAUNCH); } String title = interaction.getTitle(); final AutoCompleteTextView emailView = (AutoCompleteTextView) activity.findViewById(R.id.email); EditText messageView = (EditText) activity.findViewById(R.id.message); Button noButton = (Button) activity.findViewById(R.id.decline); final Button sendButton = (Button) activity.findViewById(R.id.submit); // Title if (title != null) { TextView titleView = (TextView) activity.findViewById(R.id.title); titleView.setText(title); } // Body String body = interaction.getBody(activity); TextView bodyView = (TextView) activity.findViewById(R.id.body); bodyView.setText(body); // Email String personEnteredEmail = PersonManager.loadPersonEmail(activity); if (!interaction.isAskForEmail()) { emailView.setVisibility(View.GONE); } else if (!Util.isEmpty(personEnteredEmail)) { emailView.setVisibility(View.GONE); email = personEnteredEmail; } else { String personInitialEmail = PersonManager.loadInitialPersonEmail(activity); if (!Util.isEmpty(personInitialEmail)) { emailView.setText(personInitialEmail); email = personInitialEmail; } String emailHintText = interaction.getEmailHintText(); if (emailHintText != null) { emailView.setHint(emailHintText); } else if (interaction.isEmailRequired()) { emailView.setHint(R.string.apptentive_edittext_hint_email_required); } // Pre-populate a list of possible emails based on those pulled from the phone. ArrayAdapter<String> emailAdapter = new ArrayAdapter<String>( activity, android.R.layout.simple_dropdown_item_1line, Util.getAllUserAccountEmailAddresses(activity)); emailView.setAdapter(emailAdapter); emailView.setOnTouchListener( new View.OnTouchListener() { @Override public boolean onTouch(View v, MotionEvent event) { emailView.showDropDown(); return false; } }); emailView.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) { email = charSequence; validateForm(sendButton); } @Override public void afterTextChanged(Editable editable) {} }); } // Message String messageHintText = interaction.getMessageHintText(); if (messageHintText != null) { messageView.setHint(messageHintText); } messageView.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) { message = charSequence; validateForm(sendButton); } @Override public void afterTextChanged(Editable editable) {} }); // No String no = interaction.getDeclineText(); if (no != null) { noButton.setText(no); } noButton.setOnClickListener( new View.OnClickListener() { @Override public void onClick(View view) { cleanup(); EngagementModule.engageInternal( activity, interaction.getType().name(), CODE_POINT_DECLINE); activity.finish(); } }); // Send String send = interaction.getSubmitText(); if (send != null) { sendButton.setText(send); } sendButton.setOnClickListener( new View.OnClickListener() { @Override public void onClick(View view) { if (email != null && email.length() != 0 && !Util.isEmailValid(email.toString())) { EmailValidationFailedDialog dialog = new EmailValidationFailedDialog(activity); dialog.show(); return; } // Before we send this message, send an auto message. createMessageCenterAutoMessage(activity); sendMessage(activity); EngagementModule.engageInternal( activity, interaction.getType().name(), CODE_POINT_SUBMIT); thankYouDialogVisible = true; feedbackDialogVisible = false; activity.findViewById(R.id.feedback_dialog).setVisibility(View.GONE); activity.findViewById(R.id.thank_you_dialog).setVisibility(View.VISIBLE); } }); } else { activity.findViewById(R.id.feedback_dialog).setVisibility(View.GONE); activity.findViewById(R.id.thank_you_dialog).setVisibility(View.VISIBLE); } // Thank You Title TextView thankYouTitleView = (TextView) activity.findViewById(R.id.thank_you_title); String thankYouTitle = interaction.getThankYouTitle(); if (thankYouTitle != null) { thankYouTitleView.setText(thankYouTitle); } // Thank You Body TextView thankYouBodyView = (TextView) activity.findViewById(R.id.thank_you_body); String thankYouBody = interaction.getThankYouBody(); if (thankYouBody != null) { thankYouBodyView.setText(thankYouBody); } // Thank You Close Button Button thankYouCloseButton = (Button) activity.findViewById(R.id.thank_you_close); String thankYouCloseText = interaction.getThankYouCloseText(); if (thankYouCloseText != null) { thankYouCloseButton.setText(thankYouCloseText); } thankYouCloseButton.setOnClickListener( new View.OnClickListener() { @Override public void onClick(View view) { cleanup(); EngagementModule.engageInternal( activity, interaction.getType().name(), CODE_POINT_SKIP_VIEW_MESSAGES); activity.finish(); } }); // Thank You View Messages Button Button thankYouViewMessagesButton = (Button) activity.findViewById(R.id.thank_you_view_messages); String thankYouViewMessages = interaction.getThankYouViewMessagesText(); if (thankYouViewMessages != null) { thankYouViewMessagesButton.setText(thankYouViewMessages); } thankYouViewMessagesButton.setOnClickListener( new View.OnClickListener() { @Override public void onClick(View view) { cleanup(); EngagementModule.engageInternal( activity, interaction.getType().name(), CODE_POINT_VIEW_MESSAGES); activity.finish(); } }); feedbackDialogVisible = true; }