Example usage for android.text InputType TYPE_TEXT_FLAG_CAP_WORDS

List of usage examples for android.text InputType TYPE_TEXT_FLAG_CAP_WORDS

Introduction

In this page you can find the example usage for android.text InputType TYPE_TEXT_FLAG_CAP_WORDS.

Prototype

int TYPE_TEXT_FLAG_CAP_WORDS

To view the source code for android.text InputType TYPE_TEXT_FLAG_CAP_WORDS.

Click Source Link

Document

Flag for #TYPE_CLASS_TEXT : capitalize the first character of every word.

Usage

From source file:gov.in.bloomington.georeporter.fragments.PersonalInfoFragment.java

@Override
public void onListItemClick(ListView l, View v, int position, long id) {
    super.onListItemClick(l, v, position, id);

    final String fieldname = PersonalInfoAdapter.FIELDS[position];
    final TextView label = (TextView) v.findViewById(android.R.id.text1);
    final TextView input = (TextView) v.findViewById(android.R.id.text2);

    final EditText newValue = new EditText(getActivity());
    newValue.setText(input.getText());/*from  w w  w .  j  a  v a 2s . co  m*/

    int type = InputType.TYPE_TEXT_FLAG_CAP_WORDS;
    if (fieldname == "email") {
        type = InputType.TYPE_TEXT_VARIATION_EMAIL_ADDRESS;
    }
    if (fieldname == "phone") {
        type = InputType.TYPE_CLASS_PHONE;
    }
    newValue.setInputType(type);

    new AlertDialog.Builder(getActivity()).setTitle(label.getText()).setView(newValue)
            .setPositiveButton("Ok", new DialogInterface.OnClickListener() {
                @Override
                public void onClick(DialogInterface dialog, int which) {
                    try {
                        mPersonalInfo.put(fieldname, newValue.getText());
                    } catch (JSONException e) {
                        // Just ignore any errors
                    }
                }
            }).setNegativeButton("Cancel", new DialogInterface.OnClickListener() {
                @Override
                public void onClick(DialogInterface dialog, int which) {
                    // Do Nothing
                }
            }).show();
}

From source file:com.cyanogenmod.eleven.menu.BasePlaylistDialog.java

/**
 * {@inheritDoc}// ww w.  j  a v  a  2s.  com
 */
@Override
public Dialog onCreateDialog(final Bundle savedInstanceState) {
    // Initialize the alert dialog
    mPlaylistDialog = new AlertDialog.Builder(getActivity()).create();
    // Initialize the edit text
    mPlaylist = new EditText(getActivity());
    // To show the "done" button on the soft keyboard
    mPlaylist.setSingleLine(true);
    // All caps
    mPlaylist.setInputType(mPlaylist.getInputType() | InputType.TYPE_TEXT_FLAG_NO_SUGGESTIONS
            | InputType.TYPE_TEXT_FLAG_CAP_WORDS);
    // Set the save button action
    mPlaylistDialog.setButton(Dialog.BUTTON_POSITIVE, getString(R.string.save), new OnClickListener() {

        @Override
        public void onClick(final DialogInterface dialog, final int which) {
            onSaveClick();
            MusicUtils.refresh();
            dialog.dismiss();
        }
    });
    // Set the cancel button action
    mPlaylistDialog.setButton(Dialog.BUTTON_NEGATIVE, getString(R.string.cancel), new OnClickListener() {

        @Override
        public void onClick(final DialogInterface dialog, final int which) {
            MusicUtils.refresh();
            dialog.dismiss();
        }
    });

    mPlaylist.post(new Runnable() {

        @Override
        public void run() {
            // Request focus to the edit text
            mPlaylist.requestFocus();
            // Select the playlist name
            mPlaylist.selectAll();
        };
    });

    initObjects(savedInstanceState);
    mPlaylistDialog.setTitle(mPrompt);
    mPlaylistDialog.setView(mPlaylist);
    mPlaylist.setText(mDefaultname);
    mPlaylist.setSelection(mDefaultname.length());
    mPlaylist.addTextChangedListener(mTextWatcher);
    mPlaylistDialog.getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_VISIBLE);
    mPlaylistDialog.show();
    return mPlaylistDialog;
}

From source file:com.boko.vimusic.menu.BasePlaylistDialog.java

/**
 * {@inheritDoc}//from   w w w .ja va  2 s .  c o m
 */
@Override
public Dialog onCreateDialog(final Bundle savedInstanceState) {
    // Initialize the alert dialog
    mPlaylistDialog = new AlertDialog.Builder(getActivity()).create();
    // Initialize the edit text
    mPlaylist = new EditText(getActivity());
    // To show the "done" button on the soft keyboard
    mPlaylist.setSingleLine(true);
    // All caps
    mPlaylist.setInputType(mPlaylist.getInputType() | InputType.TYPE_TEXT_FLAG_NO_SUGGESTIONS
            | InputType.TYPE_TEXT_FLAG_CAP_WORDS);
    // Set the save button action
    mPlaylistDialog.setButton(Dialog.BUTTON_POSITIVE, getString(R.string.save), new OnClickListener() {

        @Override
        public void onClick(final DialogInterface dialog, final int which) {
            onSaveClick();
            MusicUtils.refresh(getActivity());
            dialog.dismiss();
        }
    });
    // Set the cancel button action
    mPlaylistDialog.setButton(Dialog.BUTTON_NEGATIVE, getString(R.string.cancel), new OnClickListener() {

        @Override
        public void onClick(final DialogInterface dialog, final int which) {
            closeKeyboard();
            MusicUtils.refresh(getActivity());
            dialog.dismiss();
        }
    });

    mPlaylist.post(new Runnable() {

        @Override
        public void run() {
            // Open up the soft keyboard
            openKeyboard();
            // Request focus to the edit text
            mPlaylist.requestFocus();
            // Select the playlist name
            mPlaylist.selectAll();
        };
    });

    initObjects(savedInstanceState);
    mPlaylistDialog.setTitle(mPrompt);
    mPlaylistDialog.setView(mPlaylist);
    mPlaylist.setText(mDefaultname);
    mPlaylist.setSelection(mDefaultname.length());
    mPlaylist.addTextChangedListener(mTextWatcher);
    mPlaylistDialog.show();
    return mPlaylistDialog;
}

From source file:com.andrew.apollo.menu.BasePlaylistDialog.java

/**
 * {@inheritDoc}/*from w  w w.  j  a  v a 2s.c o m*/
 */
@Override
public Dialog onCreateDialog(final Bundle savedInstanceState) {
    // Initialize the alert dialog
    mPlaylistDialog = new AlertDialog.Builder(getActivity()).create();
    // Initialize the edit text
    mPlaylist = new EditText(getActivity());
    // To show the "done" button on the soft keyboard
    mPlaylist.setSingleLine(true);
    // All caps
    mPlaylist.setInputType(mPlaylist.getInputType() | InputType.TYPE_TEXT_FLAG_NO_SUGGESTIONS
            | InputType.TYPE_TEXT_FLAG_CAP_WORDS);
    // Set the save button action
    mPlaylistDialog.setButton(Dialog.BUTTON_POSITIVE, getString(R.string.save), new OnClickListener() {

        @Override
        public void onClick(final DialogInterface dialog, final int which) {
            onSaveClick();
            MusicUtils.refresh();
            dialog.dismiss();
        }
    });
    // Set the cancel button action
    mPlaylistDialog.setButton(Dialog.BUTTON_NEGATIVE, getString(R.string.cancel), new OnClickListener() {

        @Override
        public void onClick(final DialogInterface dialog, final int which) {
            closeKeyboard();
            MusicUtils.refresh();
            dialog.dismiss();
        }
    });

    mPlaylist.post(new Runnable() {

        @Override
        public void run() {
            // Open up the soft keyboard
            openKeyboard();
            // Request focus to the edit text
            mPlaylist.requestFocus();
            // Select the playlist name
            mPlaylist.selectAll();
        };
    });

    initObjects(savedInstanceState);
    mPlaylistDialog.setTitle(mPrompt);
    mPlaylistDialog.setView(mPlaylist);
    mPlaylist.setText(mDefaultname);
    mPlaylist.setSelection(mDefaultname.length());
    mPlaylist.addTextChangedListener(mTextWatcher);
    mPlaylistDialog.show();
    return mPlaylistDialog;
}

From source file:edu.rosehulman.grocerydroid.ItemDialogFragment.java

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    final View view = inflater.inflate(R.layout.fragment_dialog_item, container, false);

    // EditText nameBox = (EditText) view.findViewById(R.id.item_name_box);
    AutoCompleteTextView nameBox = (AutoCompleteTextView) view.findViewById(R.id.item_name_box);

    nameBox.setInputType(InputType.TYPE_TEXT_FLAG_CAP_WORDS);

    //      String[] names = new String[] { "Bob", "Joe", "Caleb", "Jonathan",
    //            "Elise" };

    String[] foodNames = getResources().getStringArray(R.array.food_names);

    //      ArrayAdapter<String> autoAdapter = new ArrayAdapter<String>(
    //            getActivity(), android.R.layout.simple_list_item_1, names);
    ArrayAdapter<String> autoAdapter = new ArrayAdapter<String>(getActivity(), R.layout.dropdown_item,
            foodNames);/* w w w  . j  a  v a  2  s  .c  o  m*/

    // android.R.layout.sherlock.* both white/invisible
    // android.R.layout.
    // simple_spinner_item too thin
    // simple list item 2: crash
    // activity_list_item crash
    //simple_spinner_dropdown_item

    nameBox.setAdapter(autoAdapter);

    // mEditIcon.setOnKeyListener(new OnKeyListener() {
    // @Override
    // public boolean onKey(View v, int keyCode, KeyEvent event) {
    // // If the event is a key-down event on the "enter" button
    // if ((event.getAction() == KeyEvent.ACTION_DOWN)
    // && (keyCode == KeyEvent.KEYCODE_ENTER)) {
    // Toast.makeText(StockActivity.this, tv.getText(),
    // Toast.LENGTH_SHORT).show();
    // return true;
    // }
    // return false;
    // }
    // });

    EditText priceBox = (EditText) view.findViewById(R.id.item_price_box);
    priceBox.setInputType(InputType.TYPE_CLASS_PHONE);
    // priceBox.setInputType(InputType.TYPE_CLASS_NUMBER|InputType.TYPE_NUMBER_FLAG_DECIMAL);

    // first true : is signed, second one : is decimal
    priceBox.setKeyListener(new DigitsKeyListener(false, true));

    EditText sizeBox = (EditText) view.findViewById(R.id.item_unit_size_box);
    sizeBox.setText("" + mItem.getUnitSize());

    Spinner unitSpinner = (Spinner) view.findViewById(R.id.item_unit_label_spinner);
    ArrayAdapter<Item.UnitLabel> adapter;
    adapter = new ArrayAdapter<Item.UnitLabel>(this.getActivity(), android.R.layout.simple_spinner_item,
            Item.UnitLabel.values());
    adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
    unitSpinner.setAdapter(adapter);

    EditText numStockBox = (EditText) view.findViewById(R.id.item_num_stock);
    numStockBox.setText("" + mItem.getNStock());

    // If this activity was started with the purpose of editing an existing
    // item, then we use the item passed in the intent to populate the
    // spinners and edit text boxes.
    if (!mItem.getName().equals("")) {
        // TODO Make non-focusable, non-touchable so it doesn't kick off the drop down.
        // But it doesn't work!
        nameBox.setFocusable(false);
        nameBox.setFocusableInTouchMode(false);
        nameBox.setText(mItem.getName());
        // Reset the focus & touch
        nameBox.setFocusable(true);
        nameBox.setFocusableInTouchMode(true);

        priceBox.setText(Float.toString(mItem.getPrice()));

        unitSpinner.setSelection(mItem.getUnitLabel().ordinal());
    }

    Button incrementNumStockButton = (Button) view.findViewById(R.id.item_increment_num_stock);
    incrementNumStockButton.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            EditText et = (EditText) view.findViewById(R.id.item_num_stock);
            int numStock = getIntegerFromEditText(et);
            numStock++;
            et.setText(numStock + "");
        }
    });

    Button decrementNumStockButton = (Button) view.findViewById(R.id.item_decrement_num_stock);
    decrementNumStockButton.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            EditText et = (EditText) view.findViewById(R.id.item_num_stock);
            int numStock = getIntegerFromEditText(et);
            numStock--;
            et.setText(numStock + "");
        }
    });

    Button saveButton = (Button) view.findViewById(R.id.item_save_button);
    saveButton.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            EditText et = (EditText) view.findViewById(R.id.item_name_box);
            String name = et.getText().toString();

            et = (EditText) view.findViewById(R.id.item_price_box);
            float price = getFloatFromEditText(et);

            et = (EditText) view.findViewById(R.id.item_unit_size_box);
            float size = getFloatFromEditText(et);

            Spinner spinner = (Spinner) view.findViewById(R.id.item_unit_label_spinner);
            int unitIndex = spinner.getSelectedItemPosition();

            et = (EditText) view.findViewById(R.id.item_num_stock);
            int numStock = getIntegerFromEditText(et);

            mItem = new Item(mItem.getId(), mItem.getListId(), name, numStock, mItem.getNBuy(), price, size,
                    Item.UnitLabel.values()[unitIndex], mItem.isBought(), mItem.getStockIdx(),
                    mItem.getShopIdx());
            if (mMode == Mode.ADD) {
                ((ShoppingListActivity) getActivity()).addItem(mItem);
            } else if (mMode == Mode.EDIT) {
                ((ShoppingListActivity) getActivity()).updateItem(mItem);
            } else {
                // shouldn't get here.
            }
            dismiss();
        }
    });

    Button cancelButton = (Button) view.findViewById(R.id.item_cancel_button);
    cancelButton.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            dismiss();
        }
    });

    Button deleteButton = (Button) view.findViewById(R.id.item_delete_button);
    deleteButton.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            if (mMode == Mode.EDIT) {
                ConfirmDeleteItemDialogFragment df = new ConfirmDeleteItemDialogFragment();
                df.setItem(mItem);
                df.show(getActivity().getSupportFragmentManager(), "confirm");
            }
            // Otherwise, we are adding this item, so we don't need to
            // delete it.
            // TODO: Remove modes altogether once autocomplete works, since
            // every item here will exist and be beging added.
            // CONSIDER: at that point, I will need to make sure that items
            // that have a name only (from autocomplete) have been saved in
            // the DB
            // and have a unique ID so they can be deleted.
            dismiss();
        }
    });

    return view;
}

From source file:ca.rmen.android.scrumchatter.dialog.InputDialogFragment.java

@Override
@NonNull//from  www .j a  v  a2 s.c  o  m
public Dialog onCreateDialog(Bundle savedInstanceState) {
    Log.v(TAG, "onCreateDialog: savedInstanceState = " + savedInstanceState);
    if (savedInstanceState != null)
        mEnteredText = savedInstanceState.getString(DialogFragmentFactory.EXTRA_ENTERED_TEXT);
    Bundle arguments = getArguments();
    final int actionId = arguments.getInt(DialogFragmentFactory.EXTRA_ACTION_ID);

    final InputDialogEditTextBinding binding = DataBindingUtil.inflate(LayoutInflater.from(getActivity()),
            R.layout.input_dialog_edit_text, null, false);

    final Bundle extras = arguments.getBundle(DialogFragmentFactory.EXTRA_EXTRAS);
    final Class<?> inputValidatorClass = (Class<?>) arguments
            .getSerializable(DialogFragmentFactory.EXTRA_INPUT_VALIDATOR_CLASS);
    final String prefilledText = arguments.getString(DialogFragmentFactory.EXTRA_ENTERED_TEXT);
    AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());

    builder.setTitle(arguments.getString(DialogFragmentFactory.EXTRA_TITLE));
    builder.setView(binding.getRoot());
    binding.edit.setInputType(InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_FLAG_CAP_WORDS);
    binding.edit.setHint(arguments.getString(DialogFragmentFactory.EXTRA_INPUT_HINT));
    binding.edit.setText(prefilledText);
    if (!TextUtils.isEmpty(mEnteredText))
        binding.edit.setText(mEnteredText);

    // Notify the activity of the click on the OK button.
    OnClickListener listener = null;
    if ((getActivity() instanceof DialogInputListener)) {
        listener = (dialog, which) -> {
            FragmentActivity activity = getActivity();
            if (activity == null)
                Log.w(TAG, "User clicked on dialog after it was detached from activity. Monkey?");
            else
                ((DialogInputListener) activity).onInputEntered(actionId, binding.edit.getText().toString(),
                        extras);
        };
    }
    builder.setNegativeButton(android.R.string.cancel, null);
    builder.setPositiveButton(android.R.string.ok, listener);

    final AlertDialog dialog = builder.create();
    // Show the keyboard when the EditText gains focus.
    binding.edit.setOnFocusChangeListener((v, hasFocus) -> {
        if (hasFocus) {
            Window window = dialog.getWindow();
            if (window != null) {
                window.setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_VISIBLE);
            }
        }
    });

    final Context context = getActivity();
    try {
        final InputValidator validator = inputValidatorClass == null ? null
                : (InputValidator) inputValidatorClass.newInstance();
        Log.v(TAG, "input validator = " + validator);
        // Validate the text as the user types.
        binding.edit.addTextChangedListener(new TextWatcher() {

            @Override
            public void afterTextChanged(Editable s) {
            }

            @Override
            public void beforeTextChanged(CharSequence s, int start, int count, int after) {
            }

            @Override
            public void onTextChanged(CharSequence s, int start, int before, int count) {
                mEnteredText = binding.edit.getText().toString();
                if (validator != null)
                    validateText(context, dialog, binding.edit, validator, actionId, extras);
            }
        });
        dialog.setOnShowListener(dialogInterface -> {
            Log.v(TAG, "onShow");
            validateText(context, dialog, binding.edit, validator, actionId, extras);
        });
    } catch (Exception e) {
        Log.e(TAG, "Could not instantiate validator " + inputValidatorClass + ": " + e.getMessage(), e);
    }

    return dialog;
}

From source file:com.scigames.slidegame.Registration1UserNameActivity.java

/** Called with the activity is first created. */
@Override/*from  ww  w . j av  a 2s. co m*/
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    Log.d(TAG, "super.OnCreate");

    requestWindowFeature(Window.FEATURE_INDETERMINATE_PROGRESS);
    getWindow().getDecorView().setSystemUiVisibility(View.SYSTEM_UI_FLAG_LOW_PROFILE);
    Intent i = getIntent();
    Log.d(TAG, "...getIntent");
    //       firstNameIn = i.getStringExtra("fName");
    //       lastNameIn = i.getStringExtra("lName");
    //       studentIdIn = i.getStringExtra("studentId");
    //       visitIdIn = i.getStringExtra("visitId");
    Log.d(TAG, "...getStringExtra");
    // Inflate our UI from its XML layout description.
    setContentView(R.layout.registration1_username);
    Log.d(TAG, "...setContentView");
    // Find the text editor view inside the layout, because we
    // want to do various programmatic things with it.
    firstName = (EditText) findViewById(R.id.first_name);
    /* to hide the keyboard on launch, then open when tap in firstname field */
    firstName.setInputType(InputType.TYPE_NULL);
    firstName.setOnTouchListener(new View.OnTouchListener() {
        //@Override
        public boolean onTouch(View v, MotionEvent event) {
            firstName.setInputType(InputType.TYPE_TEXT_VARIATION_PERSON_NAME);
            firstName
                    .setInputType(InputType.TYPE_TEXT_FLAG_CAP_WORDS | InputType.TYPE_TEXT_FLAG_NO_SUGGESTIONS);
            firstName.onTouchEvent(event); // call native handler
            return true; // consume touch even
        }
    });
    lastName = (EditText) findViewById(R.id.last_name);
    password = (EditText) findViewById(R.id.password);
    Log.d(TAG, "...instantiateEditTexts");

    // Hook up button presses to the appropriate event handler.
    ((Button) findViewById(R.id.back)).setOnClickListener(mBackListener);
    //((Button) findViewById(R.id.clear)).setOnClickListener(mClearListener);
    ((Button) findViewById(R.id.continue_button)).setOnClickListener(mContinueButtonListener);
    Log.d(TAG, "...instantiateButtons");

    //set info to what we know already
    //firstName.setText(firstNameIn);
    //lastName.setText(lastNameIn);
    //password.setText(passwordIn);
    //Log.d(TAG,"...setTexts with incoming name/pw");

    //set listener
    task.setOnResultsListener(this);

    alertDialog = new AlertDialog.Builder(Registration1UserNameActivity.this).create();
    // Setting Dialog Title
    alertDialog.setTitle("Login Failed");
    // Setting Dialog Message
    alertDialog.setMessage("Welcome to AndroidHive.info");
    // Setting Icon to Dialog
    //alertDialog.setIcon(R.drawable.tick);

    alertDialog.setButton("OK", new DialogInterface.OnClickListener() {
        public void onClick(DialogInterface dialog, int which) {
            // Write your code here to execute after dialog closed
            Toast.makeText(getApplicationContext(), "You clicked on OK", Toast.LENGTH_SHORT).show();
        }
    });
}

From source file:com.scigames.registration.Registration1UserNameActivity.java

/** Called with the activity is first created. */
@Override// ww w .j a va  2s. c om
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    Log.d(TAG, "super.OnCreate");

    requestWindowFeature(Window.FEATURE_INDETERMINATE_PROGRESS);
    getWindow().getDecorView().setSystemUiVisibility(View.SYSTEM_UI_FLAG_LOW_PROFILE);
    Intent i = getIntent();
    Log.d(TAG, "...getIntent");
    firstNameIn = i.getStringExtra("fName");
    lastNameIn = i.getStringExtra("lName");
    passwordIn = i.getStringExtra("pword");

    Log.d(TAG, "...getStringExtra");
    // Inflate our UI from its XML layout description.
    setContentView(R.layout.registration1_username);
    Log.d(TAG, "...setContentView");

    lastName = (EditText) findViewById(R.id.last_name);
    password = (EditText) findViewById(R.id.password);
    password_confirm = (EditText) findViewById(R.id.confirm_password);
    firstName = (EditText) findViewById(R.id.first_name);
    /* to hide the keyboard on launch, then open when tap in firstname field */
    firstName.setCursorVisible(false);
    firstName.setInputType(InputType.TYPE_NULL);
    firstName.setOnTouchListener(new View.OnTouchListener() {
        //@Override
        public boolean onTouch(View v, MotionEvent event) {
            firstName.setInputType(InputType.TYPE_TEXT_VARIATION_PERSON_NAME);
            firstName
                    .setInputType(InputType.TYPE_TEXT_FLAG_CAP_WORDS | InputType.TYPE_TEXT_FLAG_NO_SUGGESTIONS);
            firstName.setCursorVisible(true);
            firstName.onTouchEvent(event); // call native handler
            return true; // consume touch even
        }
    });

    Log.d(TAG, "...instantiateEditTexts");

    // Hook up button presses to the appropriate event handler.
    ((Button) findViewById(R.id.continue_button)).setOnClickListener(mContinueButtonListener);
    Log.d(TAG, "...instantiateButtons");

    Typeface ExistenceLightOtf = Typeface.createFromAsset(getAssets(), "fonts/Existence-Light.ttf");
    Typeface Museo300Regular = Typeface.createFromAsset(getAssets(), "fonts/Museo300-Regular.otf");
    Typeface Museo500Regular = Typeface.createFromAsset(getAssets(), "fonts/Museo500-Regular.otf");
    Typeface Museo700Regular = Typeface.createFromAsset(getAssets(), "fonts/Museo700-Regular.otf");

    setEditTextFont(Museo500Regular, firstName, lastName, password, password_confirm);

    //set info to what we know already
    firstName.setText(firstNameIn);
    lastName.setText(lastNameIn);
    //password.setText(passwordIn);
    Log.d(TAG, "...setTexts with incoming name/pw");

    //set listener
    task.setOnResultsListener(this);

    alertDialog = new AlertDialog.Builder(Registration1UserNameActivity.this).create();
    // Setting Dialog Title
    alertDialog.setTitle("Login Failed");
    // Setting Dialog Message
    alertDialog.setMessage("Welcome to AndroidHive.info");
    // Setting Icon to Dialog
    //alertDialog.setIcon(R.drawable.tick);

    alertDialog.setButton(RESULT_OK, "OK", new DialogInterface.OnClickListener() {
        public void onClick(DialogInterface dialog, int which) {
            // Write your code here to execute after dialog closed
            Toast.makeText(getApplicationContext(), "", Toast.LENGTH_SHORT).show();
        }
    });
}

From source file:nu.yona.app.ui.profile.EditDetailsProfileFragment.java

@Nullable
@Override/*from ww  w. j av a  2 s. c o  m*/
public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container,
        @Nullable Bundle savedInstanceState) {
    View view = inflater.inflate(R.layout.edit_profile_detail_fragment, null);
    final View activityRootView = view.findViewById(R.id.main_content);

    activityRootView.getViewTreeObserver()
            .addOnGlobalLayoutListener(new ViewTreeObserver.OnGlobalLayoutListener() {
                @Override
                public void onGlobalLayout() {
                    if (isAdded()) {
                        if (AppUtils.checkKeyboardOpen(activityRootView)) {
                            ((YonaActivity) getActivity()).changeBottomTabVisibility(false);
                        } else {
                            ((YonaActivity) getActivity()).changeBottomTabVisibility(true);
                        }
                    }
                }
            });

    setupToolbar(view);

    changeProfileImageClickListener = new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            YonaActivity.getActivity().chooseImage();
        }
    };
    textWatcher = 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) {
            isAdding = count == 1;
            hideErrorMessages();
        }

        @Override
        public void afterTextChanged(Editable s) {
            if (s != null && s.length() > 0 && (s.length() == 1 || s.charAt(s.length() - 1) == ' ')
                    && isAdding) {
                firstName.setInputType(InputType.TYPE_TEXT_FLAG_CAP_WORDS);
                lastName.setInputType(InputType.TYPE_TEXT_FLAG_CAP_WORDS);
                nickName.setInputType(InputType.TYPE_TEXT_FLAG_CAP_WORDS);
            }
        }
    };

    onFocusChangeListener = new View.OnFocusChangeListener() {
        @Override
        public void onFocusChange(View view, boolean b) {
            if (b) {
                ((EditText) view).setSelection(((EditText) view).getText().length());
            }
        }
    };
    inflateView(view);

    setHook(new YonaAnalytics.BackHook(AnalyticsConstant.BACK_FROM_EDIT_PROFILE));

    YonaApplication.getEventChangeManager().registerListener(this);
    return view;
}

From source file:com.scigames.registration.LoginActivity.java

/** Called with the activity is first created. */
@Override/* w  w w.j a v a  2 s  . com*/
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    requestWindowFeature(Window.FEATURE_INDETERMINATE_PROGRESS);
    getWindow().getDecorView().setSystemUiVisibility(View.SYSTEM_UI_FLAG_LOW_PROFILE);
    //getWindow().getDecorView().setSystemUiVisibility(View.SYSTEM_UI_FLAG_HIDE_NAVIGATION );
    // View v = findViewById(R.layout.login_page);
    // v.setSystemUiVisibility(View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN); 
    //Window w = this.getWindow(); // in Activity's onCreate() for instance
    //w.setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
    //        WindowManager.LayoutParams.FLAG_FULLSCREEN);
    setContentView(R.layout.login_page);
    Log.d(TAG, "super.OnCreate");
    // Inflate our UI from its XML layout description.       
    //        Intent i = getIntent();
    //        if (i.hasExtra("token")){
    //           setContentView(R.layout.login_page);
    //        } else {
    //           setContentView(R.layout.no_device);
    //        }
    lastName = (EditText) findViewById(R.id.last_name);
    password = (EditText) findViewById(R.id.password);
    classId = (EditText) findViewById(R.id.class_id);
    firstName = (EditText) findViewById(R.id.first_name);
    /* to hide the keyboard on launch, then open when tap in firstname field */
    //firstName.setActivated(false);
    //firstName.setSelected(false);
    firstName.setCursorVisible(false);
    firstName.setInputType(InputType.TYPE_NULL);
    firstName.setOnTouchListener(new View.OnTouchListener() {
        //@Override
        public boolean onTouch(View v, MotionEvent event) {
            firstName.setInputType(InputType.TYPE_TEXT_VARIATION_PERSON_NAME);
            firstName
                    .setInputType(InputType.TYPE_TEXT_FLAG_CAP_WORDS | InputType.TYPE_TEXT_FLAG_NO_SUGGESTIONS);
            firstName.setCursorVisible(true);
            firstName.onTouchEvent(event); // call native handler
            return true; // consume touch even
        }
    });

    //for faster testing:
    //        firstName.setText("joseph7");
    //        lastName.setText("christopher");
    //        password.setText("qweasd");
    //        classId.setText("66");
    //        
    // Hook up button presses to the appropriate event handler.
    ((Button) findViewById(R.id.login_button)).setOnClickListener(mLogInListener);
    ((Button) findViewById(R.id.register)).setOnClickListener(mRegisterListener);

    //set listener
    task.setOnResultsListener(this);

    alertDialog = new AlertDialog.Builder(LoginActivity.this).create();
    // Setting Dialog Title
    alertDialog.setTitle("Login Failed");
    // Setting Dialog Message
    alertDialog.setMessage("Welcome to AndroidHive.info");
    // Setting Icon to Dialog
    //alertDialog.setIcon(R.drawable.tick);

    alertDialog.setButton(RESULT_OK, "OK", new DialogInterface.OnClickListener() {
        public void onClick(DialogInterface dialog, int which) {
            // Write your code here to execute after dialog closed
            Toast.makeText(getApplicationContext(), "Check your login info!", Toast.LENGTH_SHORT).show();
        }
    });

    Typeface ExistenceLightOtf = Typeface.createFromAsset(getAssets(), "fonts/Existence-Light.ttf");
    Typeface Museo300Regular = Typeface.createFromAsset(getAssets(), "fonts/Museo300-Regular.otf");
    Typeface Museo500Regular = Typeface.createFromAsset(getAssets(), "fonts/Museo500-Regular.otf");
    Typeface Museo700Regular = Typeface.createFromAsset(getAssets(), "fonts/Museo700-Regular.otf");

    //       TextView welcome = (TextView)findViewById(R.id.welcome);
    TextView notascigamersentence = (TextView) findViewById(R.id.notascigamersentence);
    //       setTextViewFont(ExistenceLightOtf, welcome);
    setTextViewFont(Museo500Regular, notascigamersentence);
    setEditTextFont(Museo500Regular, firstName, lastName, password, classId);

    login = (Button) findViewById(R.id.login_button);
    register = (Button) findViewById(R.id.register); /* out for now */
    setButtonFont(ExistenceLightOtf, login, register);
    setButtonFont(Museo500Regular, register);

    //        if (getIntent().getBooleanExtra("EXIT", false)) {
    //            finish();
    //        }

}