use of android.widget.AutoCompleteTextView in project kijenzi-mobile by kijenzi.
the class LoginActivity method onCreate.
@Override
protected void onCreate(Bundle savedInstanceState) {
this.requestWindowFeature(Window.FEATURE_NO_TITLE);
FirebaseDB firebasedb = new FirebaseDB();
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_login);
submitButton = (Button) findViewById(R.id.email_sign_in_button);
submitButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
submit();
}
});
TextView link = (TextView) findViewById(R.id.facebook_link);
link.setMovementMethod(LinkMovementMethod.getInstance());
// // Set up the login form.
// mEmailView = (AutoCompleteTextView) findViewById(R.id.email);
//
// mPasswordView = (EditText) findViewById(R.id.password);
// mPasswordView.setOnEditorActionListener(new TextView.OnEditorActionListener() {
// @Override
// public boolean onEditorAction(TextView textView, int id, KeyEvent keyEvent) {
// if (id == EditorInfo.IME_ACTION_DONE || id == EditorInfo.IME_NULL) {
// attemptLogin();
// return true;
// }
// return false;
// }
// });
//
// Button mEmailSignInButton = (Button) findViewById(R.id.email_sign_in_button);
// mEmailSignInButton.setOnClickListener(new OnClickListener() {
// @Override
// public void onClick(View view) {
// attemptLogin();
// }
// });
//
// mLoginFormView = findViewById(R.id.login_form);
// mProgressView = findViewById(R.id.login_progress);
}
use of android.widget.AutoCompleteTextView in project Osmand by osmandapp.
the class EditPoiDialogFragment method onCreateView.
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
view = inflater.inflate(R.layout.fragment_edit_poi, container, false);
boolean isLightTheme = getSettings().OSMAND_THEME.get() == OsmandSettings.OSMAND_LIGHT_THEME;
if (savedInstanceState != null) {
@SuppressWarnings("unchecked") Map<String, String> mp = (Map<String, String>) savedInstanceState.getSerializable(TAGS_LIST);
editPoiData.updateTags(mp);
}
boolean isAddingPoi = getArguments().getBoolean(IS_ADDING_POI);
Toolbar toolbar = (Toolbar) view.findViewById(R.id.toolbar);
toolbar.setTitle(isAddingPoi ? R.string.poi_create_title : R.string.poi_edit_title);
toolbar.setNavigationIcon(R.drawable.ic_arrow_back);
toolbar.setNavigationContentDescription(R.string.access_shared_string_navigate_up);
toolbar.setNavigationOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
dismissCheckForChanges();
}
});
viewPager = (ViewPager) view.findViewById(R.id.viewpager);
String basicTitle = getResources().getString(R.string.tab_title_basic);
String extendedTitle = getResources().getString(R.string.tab_title_advanced);
final MyAdapter pagerAdapter = new MyAdapter(getChildFragmentManager(), basicTitle, extendedTitle);
viewPager.setAdapter(pagerAdapter);
viewPager.addOnPageChangeListener(new ViewPager.OnPageChangeListener() {
@Override
public void onPageScrolled(int i, float v, int i1) {
}
@Override
public void onPageSelected(int i) {
((OnFragmentActivatedListener) pagerAdapter.getItem(i)).onFragmentActivated();
}
@Override
public void onPageScrollStateChanged(int i) {
}
});
final TabLayout tabLayout = (TabLayout) view.findViewById(R.id.tab_layout);
tabLayout.setTabMode(TabLayout.MODE_SCROLLABLE);
// TODO remove in new version
if (Build.VERSION.SDK_INT >= 11) {
if (ViewCompat.isLaidOut(tabLayout)) {
tabLayout.setupWithViewPager(viewPager);
} else {
tabLayout.addOnLayoutChangeListener(new View.OnLayoutChangeListener() {
@Override
public void onLayoutChange(View v, int left, int top, int right, int bottom, int oldLeft, int oldTop, int oldRight, int oldBottom) {
tabLayout.setupWithViewPager(viewPager);
tabLayout.removeOnLayoutChangeListener(this);
}
});
}
} else {
ViewTreeObserver vto = view.getViewTreeObserver();
vto.addOnGlobalLayoutListener(new ViewTreeObserver.OnGlobalLayoutListener() {
@Override
public void onGlobalLayout() {
ViewTreeObserver obs = view.getViewTreeObserver();
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) {
obs.removeGlobalOnLayoutListener(this);
}
if (getActivity() != null) {
tabLayout.setupWithViewPager(viewPager);
}
}
});
}
ImageButton onlineDocumentationButton = (ImageButton) view.findViewById(R.id.onlineDocumentationButton);
onlineDocumentationButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
getActivity().startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse("https://wiki.openstreetmap.org/wiki/Map_Features")));
}
});
final int colorId = isLightTheme ? R.color.inactive_item_orange : R.color.dash_search_icon_dark;
final int color = getResources().getColor(colorId);
onlineDocumentationButton.setImageDrawable(getPaintedContentIcon(R.drawable.ic_action_help, color));
final ImageButton poiTypeButton = (ImageButton) view.findViewById(R.id.poiTypeButton);
poiTypeButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
PoiTypeDialogFragment fragment = PoiTypeDialogFragment.createInstance();
fragment.setOnItemSelectListener(new PoiTypeDialogFragment.OnItemSelectListener() {
@Override
public void select(PoiCategory poiCategory) {
setPoiCategory(poiCategory);
}
});
fragment.show(getChildFragmentManager(), "PoiTypeDialogFragment");
}
});
EditText poiNameEditText = (EditText) view.findViewById(R.id.poiNameEditText);
poiNameEditText.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) {
if (!getEditPoiData().isInEdit()) {
if (!TextUtils.isEmpty(s)) {
getEditPoiData().putTag(OSMSettings.OSMTagKey.NAME.getValue(), s.toString());
} else {
getEditPoiData().removeTag(OSMSettings.OSMTagKey.NAME.getValue());
}
}
}
});
poiNameEditText.setText(editPoiData.getTag(OSMSettings.OSMTagKey.NAME.getValue()));
poiTypeTextInputLayout = (TextInputLayout) view.findViewById(R.id.poiTypeTextInputLayout);
poiTypeEditText = (AutoCompleteTextView) view.findViewById(R.id.poiTypeEditText);
poiTypeEditText.setText(editPoiData.getPoiTypeString());
poiTypeEditText.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) {
if (!getEditPoiData().isInEdit()) {
getEditPoiData().updateTypeTag(s.toString(), true);
if (!getMyApplication().isApplicationInitializing()) {
poiTypeTextInputLayout.setHint(editPoiData.getPoiCategory().getTranslation());
}
}
}
});
poiNameEditText.setOnEditorActionListener(mOnEditorActionListener);
poiTypeEditText.setOnEditorActionListener(mOnEditorActionListener);
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.getPoiCategory() != null) {
PoiSubTypeDialogFragment dialogFragment = PoiSubTypeDialogFragment.createInstance(editPoiData.getPoiCategory());
dialogFragment.setOnItemSelectListener(new PoiSubTypeDialogFragment.OnItemSelectListener() {
@Override
public void select(String category) {
setSubCategory(category);
}
});
dialogFragment.show(getChildFragmentManager(), "PoiSubTypeDialogFragment");
}
return true;
}
}
return false;
}
});
if (!isAddingPoi) {
Button deleteButton = (Button) view.findViewById(R.id.deleteButton);
deleteButton.setVisibility(View.VISIBLE);
deleteButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
DeletePoiHelper deletePoiHelper = new DeletePoiHelper(getMyActivity());
deletePoiHelper.setCallback(new DeletePoiHelper.DeletePoiCallback() {
@Override
public void poiDeleted() {
dismiss();
}
});
deletePoiHelper.deletePoiWithDialog(getEditPoiData().getEntity());
}
});
}
Button saveButton = (Button) view.findViewById(R.id.saveButton);
saveButton.setText(mOpenstreetmapUtil instanceof OpenstreetmapRemoteUtil ? R.string.shared_string_upload : R.string.shared_string_save);
saveButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
trySave();
}
});
Button cancelButton = (Button) view.findViewById(R.id.cancelButton);
cancelButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
dismissCheckForChanges();
}
});
setAdapterForPoiTypeEditText();
setCancelable(false);
return view;
}
use of android.widget.AutoCompleteTextView in project Zom-Android by zom.
the class AccountViewFragment method onCreateView.
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
// Inflate the layout for this fragment
View view = inflater.inflate(R.layout.account_activity, container, false);
mIsNewAccount = getIntent().getBooleanExtra("register", false);
mEditUserAccount = (EditText) view.findViewById(R.id.edtName);
mEditUserAccount.setOnFocusChangeListener(new View.OnFocusChangeListener() {
@Override
public void onFocusChange(View v, boolean hasFocus) {
checkUserChanged();
}
});
mEditPass = (EditText) view.findViewById(R.id.edtPass);
mEditPassConfirm = (EditText) view.findViewById(R.id.edtPassConfirm);
mSpinnerDomains = (AutoCompleteTextView) view.findViewById(R.id.spinnerDomains);
if (mIsNewAccount) {
mEditPassConfirm.setVisibility(View.VISIBLE);
mSpinnerDomains.setVisibility(View.VISIBLE);
mEditUserAccount.setHint(R.string.account_setup_new_username);
ArrayAdapter<String> adapter = new ArrayAdapter<String>(getActivity(), android.R.layout.simple_dropdown_item_1line, OnboardingManager.getServers(getActivity()));
mSpinnerDomains.setAdapter(adapter);
}
// mRememberPass = (CheckBox) findViewById(R.id.rememberPassword);
// mUseTor = (CheckBox) findViewById(R.id.useTor);
mBtnSignIn = (Button) view.findViewById(R.id.btnSignIn);
if (mIsNewAccount)
mBtnSignIn.setText(R.string.btn_create_new_account);
return view;
}
use of android.widget.AutoCompleteTextView in project Osmand by osmandapp.
the class FavoriteDialogs method createAddFavouriteDialog.
public static Dialog createAddFavouriteDialog(final Activity activity, final Bundle args) {
AlertDialog.Builder builder = new AlertDialog.Builder(activity);
builder.setTitle(R.string.favourites_context_menu_edit);
final View v = activity.getLayoutInflater().inflate(R.layout.favorite_edit_dialog, null, false);
final FavouritesDbHelper helper = ((OsmandApplication) activity.getApplication()).getFavorites();
builder.setView(v);
final EditText editText = (EditText) v.findViewById(R.id.Name);
final EditText description = (EditText) v.findViewById(R.id.description);
final AutoCompleteTextView cat = (AutoCompleteTextView) v.findViewById(R.id.Category);
List<FavoriteGroup> gs = helper.getFavoriteGroups();
final String[] list = new String[gs.size()];
for (int i = 0; i < list.length; i++) {
list[i] = gs.get(i).name;
}
cat.setAdapter(new ArrayAdapter<String>(activity, R.layout.list_textview, list));
if (((OsmandApplication) activity.getApplication()).accessibilityEnabled()) {
final TextView textButton = (TextView) v.findViewById(R.id.TextButton);
textButton.setClickable(true);
textButton.setFocusable(true);
textButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
AlertDialog.Builder b = new AlertDialog.Builder(activity);
b.setTitle(R.string.access_category_choice);
b.setItems(list, new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
cat.setText(list[which]);
}
});
b.setNegativeButton(R.string.shared_string_cancel, null);
b.show();
}
});
}
builder.setNegativeButton(R.string.shared_string_cancel, null);
builder.setNeutralButton(R.string.update_existing, new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
// Don't use showDialog because it is impossible to refresh favorite items list
Dialog dlg = createReplaceFavouriteDialog(activity, args);
if (dlg != null) {
dlg.show();
}
// mapActivity.showDialog(DIALOG_REPLACE_FAVORITE);
}
});
builder.setPositiveButton(R.string.shared_string_add, new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
final FavouritePoint point = (FavouritePoint) args.getSerializable(KEY_FAVORITE);
OsmandApplication app = (OsmandApplication) activity.getApplication();
String categoryStr = cat.getText().toString().trim();
final FavouritesDbHelper helper = app.getFavorites();
app.getSettings().LAST_FAV_CATEGORY_ENTERED.set(categoryStr);
point.setName(editText.getText().toString().trim());
point.setDescription(description.getText().toString().trim());
point.setCategory(categoryStr);
AlertDialog.Builder bld = FavouritesDbHelper.checkDuplicates(point, helper, activity);
if (bld != null) {
bld.setPositiveButton(R.string.shared_string_ok, new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
addFavorite(activity, point, helper);
}
});
bld.show();
} else {
addFavorite(activity, point, helper);
}
}
protected void addFavorite(final Activity activity, FavouritePoint point, final FavouritesDbHelper helper) {
boolean added = helper.addFavourite(point);
if (added) {
Toast.makeText(activity, MessageFormat.format(activity.getString(R.string.add_favorite_dialog_favourite_added_template), point.getName()), Toast.LENGTH_SHORT).show();
}
if (activity instanceof MapActivity) {
((MapActivity) activity).getMapView().refreshMap(true);
}
}
});
return builder.create();
}
use of android.widget.AutoCompleteTextView in project BloodHub by kazijehangir.
the class AddDonorActivity method onCreate.
@Override
protected void onCreate(Bundle savedInstanceState) {
mAuth = FirebaseAuth.getInstance();
user = mAuth.getCurrentUser();
mEmail = user.getEmail();
// INITIALIZE FIREBASE DB
db = FirebaseDatabase.getInstance().getReference().child("donors");
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_add_donor);
setTitle("Add Donor");
name = (AutoCompleteTextView) findViewById(R.id.name);
bloodgroup = (Spinner) findViewById(R.id.spin);
age = (EditText) findViewById(R.id.age);
number = (EditText) findViewById(R.id.editText2);
address = (EditText) findViewById(R.id.editText3);
donorOrigin = (EditText) findViewById(R.id.editText4);
lastDonated = (EditText) findViewById(R.id.editText);
final EditText set = (EditText) findViewById(R.id.editText);
set.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
AlertDialog.Builder builder = new AlertDialog.Builder(AddDonorActivity.this);
builder.setTitle("Last donated");
builder.setItems(options, new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
if (options[which] == "Set date") {
final Dialog dialog1;
dialog1 = new Dialog(AddDonorActivity.this);
dialog1.setTitle("Set Date and Time");
dialog1.setContentView(R.layout.set_date);
dialog1.show();
final Button setDate = (Button) dialog1.findViewById(R.id.set_date);
final DatePicker datePicker = (DatePicker) dialog1.findViewById(R.id.datePicker);
setDate.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
date = datePicker.getDayOfMonth();
month = datePicker.getMonth();
year = datePicker.getYear();
Calendar calendar = Calendar.getInstance();
calendar.set(year, month, date);
pdate = calendar.getTime();
String date = DateFormat.getDateInstance().format(pdate);
set.setText(date);
dialog1.cancel();
}
});
} else {
set.setText("Never");
}
}
});
builder.show();
}
});
Button addDonor = (Button) findViewById(R.id.add_donor);
addDonor.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
final Context context = getApplicationContext();
dName = name.getText().toString();
dBloodgroup = bloodgroup.getSelectedItem().toString();
dAge = age.getText().toString();
dNumber = number.getText().toString();
dAddress = address.getText().toString();
ddonorOrigin = donorOrigin.getText().toString();
dLastDonated = lastDonated.getText().toString();
View focusView = null;
if (TextUtils.isEmpty(dName)) {
name.setError("Name cannot be empty");
focusView = name;
} else if (TextUtils.isEmpty(dNumber)) {
number.setError("Number cannot be empty");
} else {
Donor donor = new Donor(user.getUid(), dName, dBloodgroup, dNumber, dAddress, dLastDonated, ddonorOrigin, dAge);
try {
db.push().setValue(donor);
dialog = new Dialog(AddDonorActivity.this);
dialog.setTitle("Add Donor");
dialog.setContentView(R.layout.popup_donor);
dialog.show();
dialog.getWindow().setBackgroundDrawable(new ColorDrawable(Color.TRANSPARENT));
final Button submit = (Button) dialog.findViewById(R.id.button_ok);
submit.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
Intent intent = new Intent(AddDonorActivity.this, MainActivityOrg.class);
startActivity(intent);
}
});
} catch (DatabaseException e) {
Toast.makeText(context, "Error occurred", Toast.LENGTH_SHORT).show();
}
}
// else if(dBloodgroup) {
// bloodgroup.setError("Blood group can not be empty");
// }
}
});
}
Aggregations