Example usage for android.text InputType TYPE_TEXT_FLAG_CAP_SENTENCES

List of usage examples for android.text InputType TYPE_TEXT_FLAG_CAP_SENTENCES

Introduction

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

Prototype

int TYPE_TEXT_FLAG_CAP_SENTENCES

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

Click Source Link

Document

Flag for #TYPE_CLASS_TEXT : capitalize the first character of each sentence.

Usage

From source file:de.nico.ha_manager.activities.Preferences.java

@SuppressWarnings("deprecation")
private void checkPreferences() {
    Preference language = findPreference("pref_app_language");
    language.setOnPreferenceClickListener(new OnPreferenceClickListener() {
        @Override//  w w  w.  ja  v a 2s .  co  m
        public boolean onPreferenceClick(Preference preference) {
            Utils.langSpinner(c);
            return true;
        }
    });

    Preference subjects_add = findPreference("subjects_add");
    subjects_add.setOnPreferenceClickListener(new OnPreferenceClickListener() {
        @Override
        public boolean onPreferenceClick(Preference preference) {
            final EditText input = new EditText(c);
            input.setInputType(InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_FLAG_CAP_SENTENCES);
            AlertDialog.Builder alertDialog = new AlertDialog.Builder(c);
            alertDialog.setTitle(getString(R.string.dialog_addSubject))
                    .setMessage(getString(R.string.dialog_addSubject_message)).setView(input)
                    .setPositiveButton(getString(android.R.string.ok), new DialogInterface.OnClickListener() {
                        @Override
                        public void onClick(DialogInterface d, int i) {
                            Subject.add(c, input.getText().toString());
                        }
                    }).setNegativeButton((getString(android.R.string.no)), null).show();
            return true;
        }
    });

    Preference subjects_reset = findPreference("subjects_reset");
    subjects_reset.setOnPreferenceClickListener(new OnPreferenceClickListener() {
        @Override
        public boolean onPreferenceClick(Preference preference) {
            AlertDialog.Builder alertDialog = new AlertDialog.Builder(c);
            alertDialog.setTitle(getString(R.string.dialog_delete))
                    .setMessage(getString(R.string.dialog_really_delete_subs))
                    .setPositiveButton((getString(android.R.string.yes)),
                            new DialogInterface.OnClickListener() {

                                @Override
                                public void onClick(DialogInterface d, int i) {
                                    Subject.setDefault(c);
                                }

                            })
                    .setNegativeButton((getString(android.R.string.no)), null).show();
            return true;
        }
    });

    Preference feedback_share = findPreference("feedback_share");
    feedback_share.setOnPreferenceClickListener(new OnPreferenceClickListener() {
        @Override
        public boolean onPreferenceClick(Preference preference) {
            return Utils.shareApp(c);
        }
    });

    Preference importexport_export = findPreference("pref_importexport_export");
    importexport_export.setOnPreferenceClickListener(new OnPreferenceClickListener() {
        @Override
        public boolean onPreferenceClick(Preference preference) {
            AlertDialog.Builder alertDialog = new AlertDialog.Builder(c);
            alertDialog.setTitle(getString(R.string.pref_homework_export))
                    .setMessage(getString(R.string.dialog_export_message))
                    .setPositiveButton((getString(android.R.string.yes)),
                            new DialogInterface.OnClickListener() {

                                @Override
                                public void onClick(DialogInterface d, int i) {
                                    Homework.exportIt(c);
                                }

                            })
                    .setNegativeButton((getString(android.R.string.no)), null).show();
            return true;

        }

    });

    Preference importexport_import = findPreference("pref_importexport_import");
    importexport_import.setOnPreferenceClickListener(new OnPreferenceClickListener() {
        @Override
        public boolean onPreferenceClick(Preference preference) {
            AlertDialog.Builder alertDialog = new AlertDialog.Builder(c);
            alertDialog.setTitle(getString(R.string.pref_homework_import))
                    .setMessage(getString(R.string.dialog_import_message))
                    .setPositiveButton((getString(android.R.string.yes)),
                            new DialogInterface.OnClickListener() {

                                @Override
                                public void onClick(DialogInterface d, int i) {
                                    Homework.importIt(c);
                                }

                            })
                    .setNegativeButton((getString(android.R.string.no)), null).show();
            return true;

        }

    });
}

From source file:ru.orangesoftware.financisto.activity.AccountActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.account);//from w  w  w .  j av  a 2s. c  o m

    accountTitle = new EditText(this);
    accountTitle.setInputType(InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_FLAG_CAP_SENTENCES);
    accountTitle.setSingleLine();

    issuerName = new EditText(this);
    issuerName.setSingleLine();

    numberText = new EditText(this);
    numberText.setHint(R.string.card_number_hint);
    numberText.setSingleLine();

    sortOrderText = new EditText(this);
    sortOrderText.setInputType(InputType.TYPE_CLASS_NUMBER);
    sortOrderText.setFilters(new InputFilter[] { new InputFilter.LengthFilter(3) });
    sortOrderText.setSingleLine();

    closingDayText = new EditText(this);
    closingDayText.setInputType(InputType.TYPE_CLASS_NUMBER);
    closingDayText.setHint(R.string.closing_day_hint);
    closingDayText.setSingleLine();

    paymentDayText = new EditText(this);
    paymentDayText.setInputType(InputType.TYPE_CLASS_NUMBER);
    paymentDayText.setHint(R.string.payment_day_hint);
    paymentDayText.setSingleLine();

    amountInput = AmountInput_.build(this);
    amountInput.setOwner(this);

    limitInput = AmountInput_.build(this);
    limitInput.setOwner(this);

    LinearLayout layout = findViewById(R.id.layout);

    accountTypeAdapter = new EntityEnumAdapter<>(this, AccountType.values(), false);
    accountTypeNode = x.addListNodeIcon(layout, R.id.account_type, R.string.account_type,
            R.string.account_type);
    ImageView icon = accountTypeNode.findViewById(R.id.icon);
    icon.setColorFilter(ContextCompat.getColor(this, R.color.holo_gray_light));

    cardIssuerAdapter = new EntityEnumAdapter<>(this, CardIssuer.values(), false);
    cardIssuerNode = x.addListNodeIcon(layout, R.id.card_issuer, R.string.card_issuer, R.string.card_issuer);
    setVisibility(cardIssuerNode, View.GONE);

    electronicPaymentAdapter = new EntityEnumAdapter<>(this, ElectronicPaymentType.values(), false);
    electronicPaymentNode = x.addListNodeIcon(layout, R.id.electronic_payment_type,
            R.string.electronic_payment_type, R.string.card_issuer);
    setVisibility(electronicPaymentNode, View.GONE);

    issuerNode = x.addEditNode(layout, R.string.issuer, issuerName);
    setVisibility(issuerNode, View.GONE);

    numberNode = x.addEditNode(layout, R.string.card_number, numberText);
    setVisibility(numberNode, View.GONE);

    closingDayNode = x.addEditNode(layout, R.string.closing_day, closingDayText);
    setVisibility(closingDayNode, View.GONE);

    paymentDayNode = x.addEditNode(layout, R.string.payment_day, paymentDayText);
    setVisibility(paymentDayNode, View.GONE);

    currencyCursor = db.getAllCurrencies("name");
    startManagingCursor(currencyCursor);
    currencyAdapter = TransactionUtils.createCurrencyAdapter(this, currencyCursor);

    x.addEditNode(layout, R.string.title, accountTitle);
    currencyText = x.addListNodePlus(layout, R.id.currency, R.id.currency_add, R.string.currency,
            R.string.select_currency);

    limitInput.setExpense();
    limitInput.disableIncomeExpenseButton();
    limitAmountView = x.addEditNode(layout, R.string.limit_amount, limitInput);
    setVisibility(limitAmountView, View.GONE);

    Intent intent = getIntent();
    if (intent != null) {
        long accountId = intent.getLongExtra(ACCOUNT_ID_EXTRA, -1);
        if (accountId != -1) {
            this.account = db.getAccount(accountId);
            if (this.account == null) {
                this.account = new Account();
            }
        } else {
            selectAccountType(AccountType.valueOf(account.type));
        }
    }

    if (account.id == -1) {
        x.addEditNode(layout, R.string.opening_amount, amountInput);
        amountInput.setIncome();
    }

    noteText = new EditText(this);
    noteText.setInputType(InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_FLAG_CAP_SENTENCES);
    noteText.setLines(2);
    x.addEditNode(layout, R.string.note, noteText);

    x.addEditNode(layout, R.string.sort_order, sortOrderText);
    isIncludedIntoTotals = x.addCheckboxNode(layout, R.id.is_included_into_totals,
            R.string.is_included_into_totals, R.string.is_included_into_totals_summary, true);

    if (account.id > 0) {
        editAccount();
    }

    Button bOK = findViewById(R.id.bOK);
    bOK.setOnClickListener(arg0 -> {
        if (account.currency == null) {
            Toast.makeText(AccountActivity.this, R.string.select_currency, Toast.LENGTH_SHORT).show();
            return;
        }
        if (Utils.isEmpty(accountTitle)) {
            accountTitle.setError(getString(R.string.title));
            return;
        }
        AccountType type = AccountType.valueOf(account.type);
        if (type.hasIssuer) {
            account.issuer = Utils.text(issuerName);
        }
        if (type.hasNumber) {
            account.number = Utils.text(numberText);
        }

        /********** validate closing and payment days **********/
        if (type.isCreditCard) {
            String closingDay = Utils.text(closingDayText);
            account.closingDay = closingDay == null ? 0 : Integer.parseInt(closingDay);
            if (account.closingDay != 0) {
                if (account.closingDay > 31) {
                    Toast.makeText(AccountActivity.this, R.string.closing_day_error, Toast.LENGTH_SHORT).show();
                    return;
                }
            }

            String paymentDay = Utils.text(paymentDayText);
            account.paymentDay = paymentDay == null ? 0 : Integer.parseInt(paymentDay);
            if (account.paymentDay != 0) {
                if (account.paymentDay > 31) {
                    Toast.makeText(AccountActivity.this, R.string.payment_day_error, Toast.LENGTH_SHORT).show();
                    return;
                }
            }
        }

        account.title = text(accountTitle);
        account.creationDate = System.currentTimeMillis();
        String sortOrder = text(sortOrderText);
        account.sortOrder = sortOrder == null ? 0 : Integer.parseInt(sortOrder);
        account.isIncludeIntoTotals = isIncludedIntoTotals.isChecked();
        account.limitAmount = -Math.abs(limitInput.getAmount());
        account.note = text(noteText);

        long accountId = db.saveAccount(account);
        long amount = amountInput.getAmount();
        if (amount != 0) {
            Transaction t = new Transaction();
            t.fromAccountId = accountId;
            t.categoryId = 0;
            t.note = getResources().getText(R.string.opening_amount) + " (" + account.title + ")";
            t.fromAmount = amount;
            db.insertOrUpdate(t, null);
        }
        AccountWidget.updateWidgets(this);
        Intent intent1 = new Intent();
        intent1.putExtra(ACCOUNT_ID_EXTRA, accountId);
        setResult(RESULT_OK, intent1);
        finish();
    });

    Button bCancel = findViewById(R.id.bCancel);
    bCancel.setOnClickListener(arg0 -> {
        setResult(RESULT_CANCELED);
        finish();
    });

}

From source file:org.telegram.ui.ChangeChatNameActivity.java

@Override
public View createView(Context context) {
    actionBar.setBackButtonImage(R.drawable.ic_ab_back);
    actionBar.setAllowOverlayTitle(true);
    actionBar.setTitle(LocaleController.getString("EditName", R.string.EditName));
    actionBar.setActionBarMenuOnItemClick(new ActionBar.ActionBarMenuOnItemClick() {
        @Override/*w ww  .ja va  2s .  co  m*/
        public void onItemClick(int id) {
            if (id == -1) {
                finishFragment();
            } else if (id == done_button) {
                if (firstNameField.getText().length() != 0) {
                    saveName();
                    finishFragment();
                }
            }
        }
    });

    ActionBarMenu menu = actionBar.createMenu();
    doneButton = menu.addItemWithWidth(done_button, R.drawable.ic_done, AndroidUtilities.dp(56));

    TLRPC.Chat currentChat = MessagesController.getInstance().getChat(chat_id);

    LinearLayout linearLayout = new LinearLayout(context);
    fragmentView = linearLayout;
    fragmentView.setLayoutParams(new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT,
            ViewGroup.LayoutParams.MATCH_PARENT));
    ((LinearLayout) fragmentView).setOrientation(LinearLayout.VERTICAL);
    fragmentView.setOnTouchListener(new View.OnTouchListener() {
        @Override
        public boolean onTouch(View v, MotionEvent event) {
            return true;
        }
    });

    firstNameField = new EditText(context);
    firstNameField.setText(currentChat.title);
    firstNameField.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 18);
    //firstNameField.setHintTextColor(0xff979797);
    firstNameField.setTextColor(ContextCompat.getColor(context, R.color.primary_text));
    firstNameField.setMaxLines(3);
    firstNameField.setPadding(0, 0, 0, 0);
    firstNameField.setGravity(LocaleController.isRTL ? Gravity.RIGHT : Gravity.LEFT);
    firstNameField.setInputType(InputType.TYPE_TEXT_FLAG_CAP_SENTENCES | InputType.TYPE_TEXT_FLAG_MULTI_LINE
            | InputType.TYPE_TEXT_FLAG_AUTO_CORRECT);
    firstNameField.setImeOptions(EditorInfo.IME_ACTION_DONE);
    firstNameField.setGravity(LocaleController.isRTL ? Gravity.RIGHT : Gravity.LEFT);
    AndroidUtilities.clearCursorDrawable(firstNameField);
    firstNameField.setOnEditorActionListener(new TextView.OnEditorActionListener() {
        @Override
        public boolean onEditorAction(TextView textView, int i, KeyEvent keyEvent) {
            if (i == EditorInfo.IME_ACTION_DONE && doneButton != null) {
                doneButton.performClick();
                return true;
            }
            return false;
        }
    });

    linearLayout.addView(firstNameField,
            LayoutHelper.createLinear(LayoutHelper.MATCH_PARENT, 36, 24, 24, 24, 0));

    if (chat_id > 0) {
        firstNameField.setHint(LocaleController.getString("GroupName", R.string.GroupName));
    } else {
        firstNameField.setHint(LocaleController.getString("EnterListName", R.string.EnterListName));
    }
    firstNameField.setSelection(firstNameField.length());

    return fragmentView;
}

From source file:org.telegram.ui.ChangeNameActivity.java

@Override
public View createView(Context context) {
    actionBar.setBackButtonImage(R.drawable.ic_ab_back);
    actionBar.setAllowOverlayTitle(true);
    actionBar.setTitle(LocaleController.getString("EditName", R.string.EditName));
    actionBar.setActionBarMenuOnItemClick(new ActionBar.ActionBarMenuOnItemClick() {
        @Override/*w  w w  .ja v a 2  s  .  c om*/
        public void onItemClick(int id) {
            if (id == -1) {
                finishFragment();
            } else if (id == done_button) {
                if (firstNameField.getText().length() != 0) {
                    saveName();
                    finishFragment();
                }
            }
        }
    });

    ActionBarMenu menu = actionBar.createMenu();
    doneButton = menu.addItemWithWidth(done_button, R.drawable.ic_done, AndroidUtilities.dp(56));

    TLRPC.User user = MessagesController.getInstance().getUser(UserConfig.getClientUserId());
    if (user == null) {
        user = UserConfig.getCurrentUser();
    }

    LinearLayout linearLayout = new LinearLayout(context);
    fragmentView = linearLayout;
    fragmentView.setLayoutParams(new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT,
            ViewGroup.LayoutParams.MATCH_PARENT));
    ((LinearLayout) fragmentView).setOrientation(LinearLayout.VERTICAL);
    fragmentView.setOnTouchListener(new View.OnTouchListener() {
        @Override
        public boolean onTouch(View v, MotionEvent event) {
            return true;
        }
    });

    firstNameField = new EditText(context);
    firstNameField.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 18);
    //firstNameField.setHintTextColor(0xff979797);
    firstNameField.setTextColor(ContextCompat.getColor(context, R.color.primary_text));
    firstNameField.setMaxLines(1);
    firstNameField.setLines(1);
    firstNameField.setSingleLine(true);
    firstNameField.setGravity(LocaleController.isRTL ? Gravity.RIGHT : Gravity.LEFT);
    firstNameField.setInputType(InputType.TYPE_TEXT_FLAG_CAP_SENTENCES | InputType.TYPE_TEXT_FLAG_AUTO_CORRECT);
    firstNameField.setImeOptions(EditorInfo.IME_ACTION_NEXT);
    firstNameField.setHint(LocaleController.getString("FirstName", R.string.FirstName));
    AndroidUtilities.clearCursorDrawable(firstNameField);
    linearLayout.addView(firstNameField,
            LayoutHelper.createLinear(LayoutHelper.MATCH_PARENT, 36, 24, 24, 24, 0));
    firstNameField.setOnEditorActionListener(new TextView.OnEditorActionListener() {
        @Override
        public boolean onEditorAction(TextView textView, int i, KeyEvent keyEvent) {
            if (i == EditorInfo.IME_ACTION_NEXT) {
                lastNameField.requestFocus();
                lastNameField.setSelection(lastNameField.length());
                return true;
            }
            return false;
        }
    });

    lastNameField = new EditText(context);
    lastNameField.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 18);
    //lastNameField.setHintTextColor(0xff979797);
    lastNameField.setTextColor(ContextCompat.getColor(context, R.color.primary_text));
    lastNameField.setMaxLines(1);
    lastNameField.setLines(1);
    lastNameField.setSingleLine(true);
    lastNameField.setGravity(LocaleController.isRTL ? Gravity.RIGHT : Gravity.LEFT);
    lastNameField.setInputType(InputType.TYPE_TEXT_FLAG_CAP_SENTENCES | InputType.TYPE_TEXT_FLAG_AUTO_CORRECT);
    lastNameField.setImeOptions(EditorInfo.IME_ACTION_DONE);
    lastNameField.setHint(LocaleController.getString("LastName", R.string.LastName));
    AndroidUtilities.clearCursorDrawable(lastNameField);
    linearLayout.addView(lastNameField,
            LayoutHelper.createLinear(LayoutHelper.MATCH_PARENT, 36, 24, 16, 24, 0));
    lastNameField.setOnEditorActionListener(new TextView.OnEditorActionListener() {
        @Override
        public boolean onEditorAction(TextView textView, int i, KeyEvent keyEvent) {
            if (i == EditorInfo.IME_ACTION_DONE) {
                doneButton.performClick();
                return true;
            }
            return false;
        }
    });

    if (user != null) {
        firstNameField.setText(user.first_name);
        firstNameField.setSelection(firstNameField.length());
        lastNameField.setText(user.last_name);
    }

    return fragmentView;
}

From source file:com.anton.gavel.GavelMain.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    setContentView(R.layout.activity_gavel_main);

    // set up edit text input style for complaints (multiline, capitalize sentences)
    EditText edit = (EditText) findViewById(R.id.complaint_body);
    edit.setInputType(InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_FLAG_CAP_SENTENCES
            | InputType.TYPE_TEXT_FLAG_MULTI_LINE);
    // set up cities spinner
    Spinner citiesSpinner = (Spinner) findViewById(R.id.cities_spinner);
    ArrayAdapter<CharSequence> citiesAdapter = ArrayAdapter.createFromResource(this, R.array.cities,
            android.R.layout.simple_spinner_item);
    citiesAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
    citiesSpinner.setAdapter(citiesAdapter);

    // set up complaints map
    List<String> standardComplaints = this.getStandardComplaints();
    List<String> complaintSubmitValues = this.getComplaintSubmitValues();

    Iterator<String> standard = standardComplaints.iterator();
    Iterator<String> submit = complaintSubmitValues.iterator();
    complaintsMap = new HashMap<String, String>();
    //standard.next(); submit.next(); //skip the first item 'select a complaint'
    while (standard.hasNext() && submit.hasNext())
        complaintsMap.put(standard.next().toString(), submit.next().toString());

    // set up complaint spinner
    List<String> complaints_list = this.getStandardComplaints();
    complaintSpinner = (Spinner) findViewById(R.id.complaint_spinner);
    complaintsAdapter = new ArrayAdapter<String>(this, android.R.layout.simple_spinner_dropdown_item,
            complaints_list);// w w w. ja v  a2  s.  c  o m
    complaintsAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
    complaintSpinner.setAdapter(complaintsAdapter);
    complaintSpinner.setOnItemSelectedListener(this);
    complaintSpinner.setOnItemLongClickListener(this);// this doesn't actually work yet bc not supported by API - events don't get fired

    //attach location listener to button
    findViewById(R.id.location_button).setOnClickListener(this);

    // make link in disclaimer clickable
    TextView disclaimer = (TextView) findViewById(R.id.disclaimer_textview);
    disclaimer.setMovementMethod(LinkMovementMethod.getInstance());

    // check &or load shared preferences to populate saved personal information
    mPersonalInfo = new PersonalInfo();
    SharedPreferences preferences = getPreferences(MODE_PRIVATE);
    mPersonalInfo.loadFromPreferences(preferences);

    // suppress keyboard
    this.getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_HIDDEN);

    // set complaint location to multiline for large layouts
    if (findViewById(R.id.layout_large_land) != null || findViewById(R.id.layout_large) != null) {
        ((EditText) findViewById(R.id.complaint_address)).setInputType(InputType.TYPE_CLASS_TEXT
                | InputType.TYPE_TEXT_FLAG_MULTI_LINE | InputType.TYPE_TEXT_FLAG_CAP_WORDS);
    }

}

From source file:org.telegram.ui.ChangeUsernameActivity.java

@Override
public View createView(Context context) {
    actionBar.setBackButtonImage(R.drawable.ic_ab_back);
    actionBar.setAllowOverlayTitle(true);
    actionBar.setTitle(LocaleController.getString("Username", R.string.Username));
    actionBar.setActionBarMenuOnItemClick(new ActionBar.ActionBarMenuOnItemClick() {
        @Override//from w  w w  . j av  a 2  s  .  c o  m
        public void onItemClick(int id) {
            if (id == -1) {
                finishFragment();
            } else if (id == done_button) {
                saveName();
            }
        }
    });

    ActionBarMenu menu = actionBar.createMenu();
    doneButton = menu.addItemWithWidth(done_button, R.drawable.ic_done, AndroidUtilities.dp(56));

    TLRPC.User user = MessagesController.getInstance().getUser(UserConfig.getClientUserId());
    if (user == null) {
        user = UserConfig.getCurrentUser();
    }

    fragmentView = new LinearLayout(context);
    ((LinearLayout) fragmentView).setOrientation(LinearLayout.VERTICAL);
    fragmentView.setOnTouchListener(new View.OnTouchListener() {
        @Override
        public boolean onTouch(View v, MotionEvent event) {
            return true;
        }
    });

    firstNameField = new EditText(context);
    firstNameField.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 18);
    //firstNameField.setHintTextColor(0xff979797);
    //firstNameField.setTextColor(0xff212121);
    firstNameField.setMaxLines(1);
    firstNameField.setLines(1);
    firstNameField.setPadding(0, 0, 0, 0);
    firstNameField.setSingleLine(true);
    firstNameField.setGravity(LocaleController.isRTL ? Gravity.RIGHT : Gravity.LEFT);
    firstNameField.setInputType(InputType.TYPE_TEXT_FLAG_CAP_SENTENCES | InputType.TYPE_TEXT_FLAG_MULTI_LINE
            | InputType.TYPE_TEXT_FLAG_AUTO_CORRECT);
    firstNameField.setImeOptions(EditorInfo.IME_ACTION_DONE);
    firstNameField.setHint(LocaleController.getString("UsernamePlaceholder", R.string.UsernamePlaceholder));
    AndroidUtilities.clearCursorDrawable(firstNameField);
    firstNameField.setOnEditorActionListener(new TextView.OnEditorActionListener() {
        @Override
        public boolean onEditorAction(TextView textView, int i, KeyEvent keyEvent) {
            if (i == EditorInfo.IME_ACTION_DONE && doneButton != null) {
                doneButton.performClick();
                return true;
            }
            return false;
        }
    });

    ((LinearLayout) fragmentView).addView(firstNameField,
            LayoutHelper.createLinear(LayoutHelper.MATCH_PARENT, 36, 24, 24, 24, 0));

    if (user != null && user.username != null && user.username.length() > 0) {
        firstNameField.setText(user.username);
        firstNameField.setSelection(firstNameField.length());
    }

    checkTextView = new TextView(context);
    checkTextView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 15);
    checkTextView.setGravity(LocaleController.isRTL ? Gravity.RIGHT : Gravity.LEFT);
    ((LinearLayout) fragmentView).addView(checkTextView, LayoutHelper.createLinear(LayoutHelper.WRAP_CONTENT,
            LayoutHelper.WRAP_CONTENT, LocaleController.isRTL ? Gravity.RIGHT : Gravity.LEFT, 24, 12, 24, 0));

    TextView helpTextView = new TextView(context);
    helpTextView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 15);
    helpTextView.setTextColor(0xff6d6d72);
    helpTextView.setGravity(LocaleController.isRTL ? Gravity.RIGHT : Gravity.LEFT);
    helpTextView.setText(
            AndroidUtilities.replaceTags(LocaleController.getString("UsernameHelp", R.string.UsernameHelp)));
    ((LinearLayout) fragmentView).addView(helpTextView, LayoutHelper.createLinear(LayoutHelper.WRAP_CONTENT,
            LayoutHelper.WRAP_CONTENT, LocaleController.isRTL ? Gravity.RIGHT : Gravity.LEFT, 24, 10, 24, 0));

    firstNameField.addTextChangedListener(new TextWatcher() {
        @Override
        public void beforeTextChanged(CharSequence charSequence, int i, int i2, int i3) {

        }

        @Override
        public void onTextChanged(CharSequence charSequence, int i, int i2, int i3) {
            checkUserName(firstNameField.getText().toString(), false);
        }

        @Override
        public void afterTextChanged(Editable editable) {

        }
    });

    checkTextView.setVisibility(View.GONE);

    return fragmentView;
}

From source file:cz.maresmar.sfm.app.SfmApp.java

/**
 * Opens email app with log file/*from   w w w. j ava  2 s  . co  m*/
 */
public void sendFeedback(Context context) {
    // Shows subjects dialog
    AlertDialog.Builder builder = new AlertDialog.Builder(context);
    builder.setTitle(R.string.feedback_subject_title);
    builder.setMessage(R.string.feedback_subject_msg);

    // Set up the input
    final EditText input = new EditText(context);
    // Specify the type of input expected; this, for example, sets the input as a password, and will mask the text
    input.setInputType(InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_VARIATION_SHORT_MESSAGE
            | InputType.TYPE_TEXT_FLAG_CAP_SENTENCES);
    builder.setView(input);

    // Set up the buttons
    builder.setPositiveButton(android.R.string.ok,
            (dialog, which) -> sendFeedback(context, input.getText().toString()));
    builder.setNegativeButton(android.R.string.cancel, (dialog, which) -> dialog.cancel());

    builder.show();
}

From source file:com.activiti.android.ui.fragments.form.EditTextDialogFragment.java

@Override
public void onStart() {
    String value = null;//w  w  w  .  j  ava  2  s .  c  om
    if (getArguments() != null) {
        value = getArguments().getString(ARGUMENT_VALUE);
        hintId = getArguments().getInt(ARGUMENT_HINT_ID);
        notNull = getArguments().getBoolean(ARGUMENT_EMPTY);
        singleLine = getArguments().getBoolean(ARGUMENT_SINGLE_LINE);
    }
    super.onStart();
    if (getDialog() != null) {
        et = ((EditText) getDialog().getWindow().findViewById(R.id.text_value));
        if (singleLine) {
            et.setInputType(InputType.TYPE_TEXT_FLAG_CAP_SENTENCES | InputType.TYPE_CLASS_TEXT);
            et.setSingleLine(true);
            et.setMinLines(1);
            et.setMaxLines(1);
            et.setLines(1);
        }
        et.setText(value);
        if (hintId != 0) {
            et.setHint(hintId);
        }
        et.setSelection(et.getText().length());
        if (notNull) {
            et.addTextChangedListener(new TextWatcher() {
                @Override
                public void onTextChanged(CharSequence s, int start, int before, int count) {
                }

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

                @Override
                public void afterTextChanged(Editable s) {
                    if (s.length() == 0) {
                        ((MaterialDialog) getDialog()).getActionButton(DialogAction.POSITIVE).setEnabled(false);
                        // ((MaterialDialog)getDialog()).getActionButton(DialogAction.POSITIVE).setBackgroundColor(getResources().getColor(R.color.primary_background));
                    } else {
                        ((MaterialDialog) getDialog()).getActionButton(DialogAction.POSITIVE).setEnabled(true);
                        // ((MaterialDialog)getDialog()).getActionButton(DialogAction.POSITIVE).setBackgroundColor(getResources().getColor(R.color.primary));
                        // backField.setBackgroundColor(getResources().getColor(R.color.primary));
                    }
                }
            });
        }
        UIUtils.showKeyboard(getActivity(), et);
    }
}

From source file:support.plus.reportit.rv.AllReportsRV.java

public void add_items_setup() {
    com.github.clans.fab.FloatingActionButton fbAddReport = (com.github.clans.fab.FloatingActionButton) findViewById(
            R.id.fbAddReport);//  ww  w.j  av a 2s  . co m

    fbAddReport.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            new MaterialDialog.Builder(AllReportsRV.this).title(R.string.add_report)
                    .content(R.string.add_reportdesc)
                    .inputType(InputType.TYPE_TEXT_FLAG_AUTO_CORRECT | InputType.TYPE_CLASS_TEXT
                            | InputType.TYPE_TEXT_FLAG_CAP_SENTENCES)
                    .inputRange(1, 15).backgroundColor(getResources().getColor(R.color.cardColor))
                    .input(getString(R.string.example_work), "", new MaterialDialog.InputCallback() {
                        @Override
                        public void onInput(MaterialDialog dialog, CharSequence input) {
                            String name = String.valueOf(input);
                            File myFile2 = new File(Environment.getExternalStorageDirectory() + File.separator
                                    + "/ReportIt/Reports/" + name);
                            if (myFile2.exists()) {
                                Toast toast = Toast.makeText(AllReportsRV.this, R.string.error_file_exists,
                                        Toast.LENGTH_SHORT);
                                toast.show();
                                return;
                            } else {
                                Calendar c = Calendar.getInstance();
                                int weekNo = c.get(Calendar.WEEK_OF_YEAR);
                                itemTexte.add(name);
                                rvadapter1.notifyDataSetChanged();
                                recyclerView1.smoothScrollToPosition(itemTexte.size());
                                try {
                                    File mydirectory = new File(Environment.getExternalStorageDirectory()
                                            + File.separator + "ReportIt");
                                    boolean success = true;
                                    if (!mydirectory.exists()) {
                                        success = mydirectory.mkdir();
                                    }
                                    if (success) {
                                        File reportsdirectory = new File(
                                                Environment.getExternalStorageDirectory() + File.separator
                                                        + "/ReportIt/Reports");
                                        boolean success2 = true;
                                        if (!reportsdirectory.exists()) {
                                            success2 = reportsdirectory.mkdir();
                                        }
                                        if (success2) {
                                            File myFile = new File(Environment.getExternalStorageDirectory()
                                                    + File.separator + "/ReportIt/Reports/" + name);
                                            if (!myFile.exists()) {
                                                myFile.createNewFile();
                                            }

                                        }

                                    } else {

                                    }

                                } catch (Exception e) {
                                }
                            }
                            return;
                        }
                    }).cancelable(false).positiveText(R.string.add).negativeText(R.string.cancel).show();
        }
    });

}

From source file:org.site_monitor.activity.SiteSettingsActivity.java

@Override
public boolean onOptionsItemSelected(MenuItem item) {
    int id = item.getItemId();
    if (id == R.id.action_refresh) {
        if (siteSettings.isChecking()) {
            return true;
        }/* www . j a v a2 s . c  o m*/
        syncMenuItem.setEnabled(false);
        new CallSiteTask(this, siteSettingsFragment).execute(siteSettings.getSiteSettings());
        return true;
    }
    if (id == R.id.action_rename) {
        AlertDialog.Builder builder = new AlertDialog.Builder(context);
        builder.setTitle(R.string.action_rename);
        final EditText input = new EditText(context);
        input.setHint(R.string.hint_rename_site);
        input.setText(siteSettings.getName());
        input.setInputType(InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_FLAG_NO_SUGGESTIONS
                | InputType.TYPE_TEXT_FLAG_CAP_SENTENCES);
        builder.setView(input);
        builder.setPositiveButton(R.string.action_rename, new DialogInterface.OnClickListener() {
            @Override
            public void onClick(DialogInterface dialog, int which) {
                String name = input.getText().toString().trim();
                if (name.isEmpty()) {
                    name = getString(R.string.no_name);
                }
                siteSettings.getSiteSettings().setName(name);
                setTitle(siteSettings.getName());
                try {
                    DBSiteSettings dbSiteSettings = dbHelper.getDBSiteSettings();
                    dbSiteSettings.update(siteSettings.getSiteSettings());
                    WidgetManager.refresh(context);
                } catch (SQLException e) {
                    Log.e(TAG, "rename", e);
                }

            }
        });
        builder.setNegativeButton(R.string.action_cancel, new DialogInterface.OnClickListener() {
            @Override
            public void onClick(DialogInterface dialog, int which) {
            }
        });
        builder.show();
        return true;
    }
    if (id == R.id.action_delete) {
        AlertDialog.Builder builder = new AlertDialog.Builder(this);
        builder.setMessage(R.string.remove_current_monitor);
        builder.setPositiveButton(R.string.action_delete, new DialogInterface.OnClickListener() {
            @Override
            public void onClick(DialogInterface dialog, int which) {
                try {
                    DBSiteSettings dbSiteSettings = dbHelper.getDBSiteSettings();
                    dbSiteSettings.delete(siteSettings.getSiteSettings());
                    AlarmUtil.instance().stopAlarmIfNeeded(context);
                } catch (SQLException e) {
                    Log.e(TAG, "remove", e);
                }
                WidgetManager.refresh(context);
                finish();
            }
        });

        builder.setNegativeButton(R.string.action_cancel, new DialogInterface.OnClickListener() {
            @Override
            public void onClick(DialogInterface dialog, int which) {
            }
        });
        builder.show();
        return true;
    }
    if (id == R.id.action_add_internal_ip) {
        if (addInternalIpMenuItem.isChecked()) {
            try {
                siteSettings.getSiteSettings().setInternalUrl(null);
                DBSiteSettings dbSiteSettings = dbHelper.getDBSiteSettings();
                dbSiteSettings.update(siteSettings.getSiteSettings());
                addInternalIpMenuItem.setChecked(!addInternalIpMenuItem.isChecked());
                Snackbar.make(this.getCurrentFocus(), R.string.internal_url_removed, Snackbar.LENGTH_SHORT)
                        .show();
                siteSettingsFragment.setSiteSettings(siteSettings);
            } catch (SQLException e) {
                Log.e(TAG, "update", e);
            }
        } else {
            AlertDialog.Builder builder = new AlertDialog.Builder(context);
            builder.setTitle(R.string.add_internal_url);
            final EditText input = new EditText(context);
            input.setHint(R.string.hint_interval_site_url);
            input.setInputType(InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_FLAG_NO_SUGGESTIONS
                    | InputType.TYPE_TEXT_VARIATION_URI);
            builder.setView(input);
            builder.setPositiveButton(R.string.action_add, new DialogInterface.OnClickListener() {
                @Override
                public void onClick(DialogInterface dialog, int which) {
                    String internalIp = input.getText().toString().trim();
                    if (internalIp.isEmpty()) {
                        return;
                    }
                    try {
                        siteSettings.getSiteSettings().setInternalUrl(internalIp);
                        DBSiteSettings dbSiteSettings = dbHelper.getDBSiteSettings();
                        dbSiteSettings.update(siteSettings.getSiteSettings());
                        addInternalIpMenuItem.setChecked(!addInternalIpMenuItem.isChecked());
                        Snackbar.make(context.getCurrentFocus(), R.string.internal_url_added,
                                Snackbar.LENGTH_SHORT).show();
                        siteSettingsFragment.setSiteSettings(siteSettings);
                    } catch (SQLException e) {
                        Log.e(TAG, "update", e);
                    }
                }
            });
            builder.setNegativeButton(R.string.action_cancel, new DialogInterface.OnClickListener() {
                @Override
                public void onClick(DialogInterface dialog, int which) {
                }
            });
            builder.show();
        }
        return true;
    }
    return false;
}