Example usage for android.text InputType TYPE_CLASS_TEXT

List of usage examples for android.text InputType TYPE_CLASS_TEXT

Introduction

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

Prototype

int TYPE_CLASS_TEXT

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

Click Source Link

Document

Class for normal text.

Usage

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

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.account);//from ww w  .  j a  va 2 s  .com

    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.odk.collect.android.preferences.AdminPreferencesFragment.java

@Override
public boolean onPreferenceClick(Preference preference) {

    switch (preference.getKey()) {

    case KEY_CHANGE_ADMIN_PASSWORD:
        AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());

        LayoutInflater factory = LayoutInflater.from(getActivity());
        final View dialogView = factory.inflate(R.layout.password_dialog_layout, null);
        final EditText passwordEditText = (EditText) dialogView.findViewById(R.id.pwd_field);
        final CheckBox passwordCheckBox = (CheckBox) dialogView.findViewById(R.id.checkBox2);
        passwordCheckBox.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
            @Override/* w  ww  . ja  v  a  2  s  . com*/
            public void onCheckedChanged(CompoundButton compoundButton, boolean b) {
                if (!passwordCheckBox.isChecked()) {
                    passwordEditText
                            .setInputType(InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_VARIATION_PASSWORD);
                } else {
                    passwordEditText.setInputType(InputType.TYPE_TEXT_VARIATION_PASSWORD);
                }
            }
        });
        builder.setTitle(R.string.change_admin_password);
        builder.setView(dialogView);
        builder.setPositiveButton(getString(R.string.ok), new DialogInterface.OnClickListener() {
            @Override
            public void onClick(DialogInterface dialog, int which) {
                String pw = passwordEditText.getText().toString();
                if (!pw.equals("")) {
                    SharedPreferences.Editor editor = getActivity()
                            .getSharedPreferences(ADMIN_PREFERENCES, MODE_PRIVATE).edit();
                    editor.putString(KEY_ADMIN_PW, pw);
                    ToastUtils.showShortToast(R.string.admin_password_changed);
                    editor.apply();
                    dialog.dismiss();
                    Collect.getInstance().getActivityLogger().logAction(this, "AdminPasswordDialog", "CHANGED");
                } else {
                    SharedPreferences.Editor editor = getActivity()
                            .getSharedPreferences(ADMIN_PREFERENCES, MODE_PRIVATE).edit();
                    editor.putString(KEY_ADMIN_PW, "");
                    editor.apply();
                    ToastUtils.showShortToast(R.string.admin_password_disabled);
                    dialog.dismiss();
                    Collect.getInstance().getActivityLogger().logAction(this, "AdminPasswordDialog",
                            "DISABLED");
                }
            }
        });
        builder.setNegativeButton(getString(R.string.cancel), new DialogInterface.OnClickListener() {
            @Override
            public void onClick(DialogInterface dialog, int which) {
                dialog.dismiss();
                Collect.getInstance().getActivityLogger().logAction(this, "AdminPasswordDialog", "CANCELLED");
            }
        });

        builder.setCancelable(false);
        AlertDialog dialog = builder.create();
        dialog.getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_VISIBLE);
        dialog.show();

        break;

    case KEY_IMPORT_SETTINGS:
        getActivity().getFragmentManager().beginTransaction()
                .replace(android.R.id.content, new ShowQRCodeFragment()).addToBackStack(null).commit();
        break;
    }
    return true;
}

From source file:ca.uqac.florentinth.speakerauthentication.MainActivity.java

private void initGUI() {
    view = findViewById(R.id.main_layout);
    usernameInput = (EditText) findViewById(R.id.username_input);
    passwordInput = (EditText) findViewById(R.id.password_input);
    visibiltyImage = (ImageView) findViewById(R.id.visibility);
    loginBtn = (Button) findViewById(R.id.btn_login);
    newAccountBtn = (Button) findViewById(R.id.btn_new_account);

    visibiltyImage.setOnTouchListener(new View.OnTouchListener() {
        @Override//  w  w  w  .  j a  va 2  s . com
        public boolean onTouch(View v, MotionEvent event) {
            if (event.getAction() == MotionEvent.ACTION_DOWN) {
                passwordInput.setInputType(InputType.TYPE_TEXT_VARIATION_VISIBLE_PASSWORD);
            } else {
                if (event.getAction() == MotionEvent.ACTION_UP) {
                    passwordInput
                            .setInputType(InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_VARIATION_PASSWORD);
                }
            }
            return true;
        }
    });

    loginBtn.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            checkExternalStoragePermissions();
        }
    });

    newAccountBtn.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            startActivity(new Intent(getApplicationContext(), CreateActivity.class));
        }
    });
}

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

@Override
@NonNull//w  ww . j  ava  2  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.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  ww . j  av  a 2s .  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:de.mrapp.android.validation.PasswordEditText.java

/**
 * Initializes the view./*from  w ww.ja va  2 s. c om*/
 *
 * @param attributeSet
 *         The attribute set, the attributes should be obtained from, as an instance of the type
 *         {@link AttributeSet} or null, if no attributes should be obtained
 */
private void initialize(@Nullable final AttributeSet attributeSet) {
    constraints = new ArrayList<>();
    helperTexts = new ArrayList<>();
    helperTextColors = new ArrayList<>();
    regularHelperText = getHelperText();
    regularHelperTextColor = getHelperTextColor();
    obtainStyledAttributes(attributeSet);
    setInputType(InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_VARIATION_PASSWORD);
    getView().addTextChangedListener(createTextChangeListener());
}

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

/** Called with the activity is first created. */
@Override/*from  w w  w. ja  va 2  s . 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");
    studentIdIn = i.getStringExtra("studentId");
    visitIdIn = i.getStringExtra("visitId");
    Log.d(TAG, "...getStringExtra");

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

    // Find the text editor view inside the layout, because we
    // want to do various programmatic things with it.
    thisMass = (EditText) findViewById(R.id.mass);
    /* to hide the keyboard on launch, then open when tap in firstname field */
    thisMass.setInputType(InputType.TYPE_NULL);
    thisMass.setOnTouchListener(new View.OnTouchListener() {
        //@Override
        public boolean onTouch(View v, MotionEvent event) {
            thisMass.setInputType(InputType.TYPE_CLASS_TEXT);
            thisMass.onTouchEvent(event); // call native handler
            return true; // consume touch even
        }
    });
    Log.d(TAG, "...instantiateEditTexts");

    //display name in greeting sentence
    Resources res = getResources();
    TextView greets = (TextView) findViewById(R.id.greeting);
    greets.setText(String.format(res.getString(R.string.greeting), firstNameIn, lastNameIn));
    Log.d(TAG, greets.toString());
    Log.d(TAG, "...Greetings");

    //set info to what we know already
    //firstName.setText(firstNameIn);
    //lastName.setText(lastNameIn);

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

    //set listener
    task.setOnResultsListener(this);
}

From source file:org.hansel.myAlert.AlarmFragment.java

@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
    getActivity().getWindow().addFlags(LayoutParams.FLAG_TURN_SCREEN_ON | LayoutParams.FLAG_DISMISS_KEYGUARD);
    mVibrator = (Vibrator) getActivity().getSystemService(Context.VIBRATOR_SERVICE);
    alarmManager = (AlarmManager) getActivity().getSystemService(Activity.ALARM_SERVICE);
    usuarioDao = new UsuarioDAO(getActivity().getApplicationContext());
    usuarioDao.open();/*from   w w  w. ja  va2  s .co m*/
    setAlarm();
    Vibra();
    // tocamos la alarma:
    String _uri = Util.getRingtone(getActivity().getApplicationContext());
    if (_uri != null && _uri.length() > 0) {

        //handler.post(vibrate);
        playSound(getActivity().getApplicationContext(), Uri.parse(_uri));
    }
    //preparamos handler para terminar alarma;
    handler.postDelayed(stop, 1000 * 60 * 2);
    AlertDialog.Builder alert = new AlertDialog.Builder(getActivity());
    alert.setTitle("Contrasea para cancelar...");
    alert.setMessage("Contrasea:");

    // Set an EditText view to get user input   
    final EditText input = new EditText(getActivity());
    input.setInputType(InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_VARIATION_PASSWORD);
    alert.setView(input);

    alert.setPositiveButton("Ok", new DialogInterface.OnClickListener() {
        public void onClick(DialogInterface dialog, int whichButton) {
            String value = input.getText().toString();
            //encriptamos el password y lo comparamos con el guardado
            /*  String hash = SimpleCrypto.md5(SimpleCrypto.MD5_KEY);
            if(hash.length()>0)
            {
             String encrypted= SimpleCrypto.encrypt(value, hash);
             if(encrypted.length()>0)
             {
                value = encrypted;
             }
            }*/
            if (usuarioDao.getPassword(value.trim())) //buscar en la BD la contrasea
            {
                Log.v("Detener Rastreo");
                getActivity().stopService(
                        new Intent(getActivity().getApplicationContext(), LocationManagement.class));

                alarmManager.cancel(Util.getPendingAlarmPanicButton(getActivity().getApplicationContext()));

                Toast.makeText(getActivity(), "Rastreo Detenido", Toast.LENGTH_SHORT).show();
                getActivity().finish();
                return;
            } else {
                Toast.makeText(getActivity(), "Contrasea Incorrecta", Toast.LENGTH_SHORT).show();
                return;
            }
        }
    });

    alert.setNegativeButton("Cancelar", new DialogInterface.OnClickListener() {

        public void onClick(DialogInterface dialog, int which) {

            getActivity().finish();
            return;
        }
    });

    return alert.create();

}

From source file:org.rssin.android.NavigationDrawerManageFeedsFragment.java

/**
 * Open dialog to add new feed//from w w  w  . j  a  v  a2  s  .  c o  m
 * For the moment, we temporarily disable rotating because we can't get it working otherwise.
 * Possible feature: make rotating possible
 */
public void openAddDialog() {
    //setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_NOSENSOR);
    final Context context = rootView.getContext();

    AlertDialog.Builder alert = new AlertDialog.Builder(context);

    alert.setTitle(getString(R.string.feeds_activity_add_feed));
    alert.setMessage(getString(R.string.feeds_activity_url));

    final EditText input = new EditText(context);
    input.setFocusable(true);
    input.setInputType(InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_VARIATION_URI);
    input.setMaxLines(1);
    input.requestFocus();

    AlertDialog dialog = alert.setView(input).setPositiveButton(getResources().getString(R.string.button_apply),
            new DialogInterface.OnClickListener() {
                public void onClick(DialogInterface dialog, int whichButton) {
                    String value = input.getText().toString();
                    try {
                        Feed f = new Feed(value, DefaultStorageProvider.getInstance(context),
                                VolleyFetcher.getInstance(context), new FallibleListener<String, Object>() {
                                    @Override
                                    public void onError(Object error) {

                                    }

                                    @Override
                                    public void onReceive(String data) {
                                        feedAdapter.notifyDataSetChanged();
                                    }
                                });

                        f.store(DefaultStorageProvider.getInstance(context));
                        feedsList.getFeeds().add(f);
                        feedAdapter.notifyDataSetChanged();
                    } catch (Exception e) {
                        Frontend.error(context, R.string.error_save_feeds, e);
                    }
                    input.setText("");
                    //setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_SENSOR);
                }
            }).setNegativeButton(getResources().getString(R.string.button_cancel),
                    new DialogInterface.OnClickListener() {
                        @Override
                        public void onClick(DialogInterface dialog, int which) {
                            input.setText("");
                            //setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_SENSOR);
                        }
                    })
            .setOnCancelListener(new DialogInterface.OnCancelListener() {
                @Override
                public void onCancel(DialogInterface dialog) {
                    input.setText("");
                    //setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_SENSOR);
                }
            }).create();

    dialog.getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_VISIBLE);
    dialog.show();
}

From source file:com.launcher.silverfish.launcher.appdrawer.TabbedAppDrawerFragment.java

private void promptNewTab() {
    AlertDialog.Builder builder = new AlertDialog.Builder(getContext());

    // Set up the dialog
    builder.setTitle(getString(R.string.text_new_tab_name));

    // Set up the input
    final EditText input = new EditText(getContext());
    // Specify the type of input expected
    input.setInputType(InputType.TYPE_CLASS_TEXT);
    builder.setView(input);// w  ww.  j a  v a  2  s.co  m

    // setup the buttons
    builder.setPositiveButton(getString(R.string.text_add_tab), new DialogInterface.OnClickListener() {
        @Override
        public void onClick(DialogInterface dialogInterface, int i) {
            try {
                tabHandler.addTab(input.getText().toString());
            } catch (IllegalArgumentException e) {
                // This means that the tab name was empty.
                showToast(R.string.text_cannot_name_empty);
            }
        }
    });
    builder.setNegativeButton(getString(R.string.text_cancel), new DialogInterface.OnClickListener() {
        @Override
        public void onClick(DialogInterface dialogInterface, int i) {
            dialogInterface.cancel();
        }
    });
    builder.show();
}