Search in sources :

Example 76 with Builder

use of android.support.v7.app.AlertDialog.Builder in project android by owncloud.

the class CredentialsDialogFragment method onCreateDialog.

@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
    // Create field for username
    mUsernameET = new EditText(getActivity());
    mUsernameET.setHint(getActivity().getText(R.string.auth_username));
    // Create field for password
    mPasswordET = new EditText(getActivity());
    mPasswordET.setHint(getActivity().getText(R.string.auth_password));
    mPasswordET.setInputType(InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_VARIATION_PASSWORD);
    // Prepare LinearLayout for dialog
    LinearLayout ll = new LinearLayout(getActivity());
    ll.setOrientation(LinearLayout.VERTICAL);
    ll.addView(mUsernameET);
    ll.addView(mPasswordET);
    ll.requestFocus();
    setRetainInstance(true);
    Builder authDialog = new AlertDialog.Builder(getActivity()).setTitle(getActivity().getText(R.string.saml_authentication_required_text)).setView(ll).setCancelable(false).setPositiveButton(R.string.common_ok, this).setNegativeButton(R.string.common_cancel, this);
    Dialog d = authDialog.create();
    d.getWindow().setSoftInputMode(LayoutParams.SOFT_INPUT_STATE_VISIBLE);
    return d;
}
Also used : EditText(android.widget.EditText) AlertDialog(android.support.v7.app.AlertDialog) Dialog(android.app.Dialog) AlertDialog(android.support.v7.app.AlertDialog) Builder(android.support.v7.app.AlertDialog.Builder) Builder(android.support.v7.app.AlertDialog.Builder) LinearLayout(android.widget.LinearLayout)

Example 77 with Builder

use of android.support.v7.app.AlertDialog.Builder in project android by owncloud.

the class SharePasswordDialogFragment method onCreateDialog.

@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
    mFile = getArguments().getParcelable(ARG_FILE);
    mCreateShare = getArguments().getBoolean(ARG_CREATE_SHARE, false);
    // Inflate the layout for the dialog
    LayoutInflater inflater = getActivity().getLayoutInflater();
    View v = inflater.inflate(R.layout.password_dialog, null);
    // Setup layout
    EditText inputText = ((EditText) v.findViewById(R.id.share_password));
    inputText.setText("");
    inputText.requestFocus();
    // Build the dialog
    AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());
    builder.setView(v).setPositiveButton(R.string.common_ok, this).setNegativeButton(R.string.common_cancel, this).setTitle(R.string.share_link_password_title);
    Dialog d = builder.create();
    d.getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_VISIBLE);
    return d;
}
Also used : EditText(android.widget.EditText) AlertDialog(android.support.v7.app.AlertDialog) Dialog(android.app.Dialog) AlertDialog(android.support.v7.app.AlertDialog) LayoutInflater(android.view.LayoutInflater) TextView(android.widget.TextView) View(android.view.View)

Example 78 with Builder

use of android.support.v7.app.AlertDialog.Builder in project android by owncloud.

the class UploadSourceDialogFragment method onCreateDialog.

@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
    String[] allTheItems = { getString(R.string.actionbar_upload_files), getString(R.string.actionbar_upload_from_apps) };
    AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());
    builder.setTitle(R.string.actionbar_upload);
    builder.setItems(allTheItems, new DialogInterface.OnClickListener() {

        public void onClick(DialogInterface dialog, int item) {
            if (item == 0) {
                Intent action = new Intent(getActivity(), UploadFilesActivity.class);
                action.putExtra(UploadFilesActivity.EXTRA_ACCOUNT, ((FileActivity) getActivity()).getAccount());
                //startActivityForResult(action, REQUEST_CODE__SELECT_FILES_FROM_FILE_SYSTEM);
                // this flow seems broken;
                // Actionbarsherlock, maybe?
                getActivity().startActivityForResult(action, FileDisplayActivity.REQUEST_CODE__SELECT_FILES_FROM_FILE_SYSTEM);
            } else if (item == 1) {
                Intent action = new Intent(Intent.ACTION_GET_CONTENT);
                action = action.setType("*/*").addCategory(Intent.CATEGORY_OPENABLE);
                //Intent.EXTRA_ALLOW_MULTIPLE is only supported on api level 18+, Jelly Bean
                if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR2) {
                    action.putExtra(Intent.EXTRA_ALLOW_MULTIPLE, true);
                }
                getActivity().startActivityForResult(Intent.createChooser(action, getString(R.string.upload_chooser_title)), FileDisplayActivity.REQUEST_CODE__SELECT_CONTENT_FROM_APPS);
            }
        }
    });
    return builder.create();
}
Also used : AlertDialog(android.support.v7.app.AlertDialog) DialogInterface(android.content.DialogInterface) FileActivity(com.owncloud.android.ui.activity.FileActivity) Intent(android.content.Intent) UploadFilesActivity(com.owncloud.android.ui.activity.UploadFilesActivity)

Example 79 with Builder

use of android.support.v7.app.AlertDialog.Builder in project platform_frameworks_base by android.

the class DialogListActivity method onCreate.

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    ListView listView = new ListView(this);
    listView.setAdapter(new ArrayAdapter<>(this, android.R.layout.simple_list_item_1, TextUtils.buildSimpleStringList()));
    AlertDialog.Builder builder = new AlertDialog.Builder(this);
    builder.setTitle("Dialog");
    builder.setView(listView);
    builder.create().show();
}
Also used : AlertDialog(android.support.v7.app.AlertDialog) ListView(android.widget.ListView)

Example 80 with Builder

use of android.support.v7.app.AlertDialog.Builder in project SharedPreferenceInspector by PrashamTrivedi.

the class SharedPreferencesItem method onItemClick.

/**
	 * Callback method to be invoked when an item in this AdapterView has been clicked.
	 * <p/>
	 * Implementers can call getItemAtPosition(position) if they need to access the data associated with the selected item.
	 *
	 * @param parent
	 * 		The AdapterView where the click happened.
	 * @param view
	 * 		The view within the AdapterView that was clicked (this will be a view provided by the adapter)
	 * @param position
	 * 		The position of the view in the adapter.
	 * @param id
	 * 		The row id of the item that was clicked.
	 */
@Override
public void onItemClick(final AdapterView<?> parent, final View view, final int position, final long id) {
    String cancel = "Cancel";
    /**
		 * Checks if entered in test mode. If not, clicking on preferences will prompt user to enter test mode first. If already entered in
		 * test mode,
		 * it will present the UI to change the value. Once it's changed, it will store original value
		 */
    if (preferenceUtils.getBoolean(testModeOpened, false)) {
        final Pair<String, Object> keyValue = (Pair<String, Object>) parent.getItemAtPosition(position);
        Object second = keyValue.second;
        final String valueType = second.getClass().getSimpleName();
        AlertDialog.Builder builder = new Builder(getActivity());
        View editView = LayoutInflater.from(getActivity()).inflate(R.layout.edit_mode, null);
        final EditText et_value = (EditText) editView.findViewById(R.id.value);
        final SwitchCompat booleanSwitch = (SwitchCompat) editView.findViewById(R.id.switchBoolean);
        Spinner type = (Spinner) editView.findViewById(R.id.type);
        final String value = second.toString();
        et_value.setText(value);
        OnItemSelectedListener listener = new OnItemSelectedListener() {

            @Override
            public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {
                if (typePosition != position) {
                    et_value.setText("");
                    typePosition = position;
                }
                booleanSwitch.setVisibility(View.GONE);
                et_value.setVisibility(View.VISIBLE);
                if (typePosition == SharedPreferenceUtils.SPINNER_STRING) {
                    et_value.setInputType(InputType.TYPE_CLASS_TEXT);
                } else if (typePosition == SharedPreferenceUtils.SPINNER_INT || typePosition == SharedPreferenceUtils.SPINNER_LONG) {
                    et_value.setInputType(InputType.TYPE_CLASS_NUMBER);
                } else if (typePosition == SharedPreferenceUtils.SPINNER_FLOAT) {
                    et_value.setInputType(InputType.TYPE_NUMBER_FLAG_DECIMAL);
                } else if (typePosition == SharedPreferenceUtils.SPINNER_BOOLEAN) {
                    et_value.setVisibility(View.GONE);
                    booleanSwitch.setVisibility(View.VISIBLE);
                    boolean isPreferenceTrue = !ConstantMethods.isEmptyString(value) && value.equalsIgnoreCase("true");
                    booleanSwitch.setText(isPreferenceTrue ? "true" : "false");
                    booleanSwitch.setChecked(isPreferenceTrue);
                    booleanSwitch.setOnCheckedChangeListener(new OnCheckedChangeListener() {

                        @Override
                        public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
                            buttonView.setText(isChecked ? "true" : "false");
                        }
                    });
                }
            }

            @Override
            public void onNothingSelected(AdapterView<?> parent) {
                typePosition = 0;
            }
        };
        type.setOnItemSelectedListener(listener);
        OnClickListener listener2 = new OnClickListener() {

            @Override
            public void onClick(DialogInterface dialog, int which) {
            //TODO: Hell nothing right now.
            }
        };
        OnClickListener clearListener = new OnClickListener() {

            @Override
            public void onClick(DialogInterface dialog, int which) {
                storeOriginal(keyValue);
                preferenceUtils.clear(keyValue.first);
                refreshKeyValues();
            }
        };
        if (valueType.equalsIgnoreCase(SharedPreferenceUtils.INT)) {
            typePosition = SharedPreferenceUtils.SPINNER_INT;
            type.setSelection(SharedPreferenceUtils.SPINNER_INT);
        } else if (valueType.equalsIgnoreCase(SharedPreferenceUtils.LONG)) {
            typePosition = SharedPreferenceUtils.SPINNER_LONG;
            type.setSelection(SharedPreferenceUtils.SPINNER_LONG);
        } else if (valueType.equalsIgnoreCase(SharedPreferenceUtils.FLOAT)) {
            typePosition = SharedPreferenceUtils.SPINNER_FLOAT;
            type.setSelection(SharedPreferenceUtils.SPINNER_FLOAT);
        } else if (valueType.equalsIgnoreCase(SharedPreferenceUtils.BOOLEAN)) {
            typePosition = SharedPreferenceUtils.SPINNER_BOOLEAN;
            type.setSelection(SharedPreferenceUtils.SPINNER_BOOLEAN);
        } else if (valueType.equalsIgnoreCase(SharedPreferenceUtils.STRING)) {
            typePosition = SharedPreferenceUtils.SPINNER_STRING;
            type.setSelection(SharedPreferenceUtils.SPINNER_STRING);
        }
        final AlertDialog dialog = builder.setTitle("Change Value").setView(editView).setPositiveButton("Set", null).setNegativeButton(cancel, listener2).setNeutralButton("Clear", clearListener).create();
        dialog.setOnShowListener(new DialogInterface.OnShowListener() {

            @Override
            public void onShow(DialogInterface dialog1) {
                Button b = dialog.getButton(AlertDialog.BUTTON_POSITIVE);
                b.setOnClickListener(new View.OnClickListener() {

                    @Override
                    public void onClick(View view) {
                        storeOriginal(keyValue);
                        Editable text = et_value.getText();
                        switch(typePosition) {
                            case SharedPreferenceUtils.SPINNER_STRING:
                                preferenceUtils.putString(keyValue.first, String.valueOf(text));
                                dialog.dismiss();
                                break;
                            case SharedPreferenceUtils.SPINNER_INT:
                                int number = SharedPreferenceUtils.getNumber(text);
                                preferenceUtils.putInt(keyValue.first, number);
                                dialog.dismiss();
                                break;
                            case SharedPreferenceUtils.SPINNER_LONG:
                                long numberLong = SharedPreferenceUtils.getNumberLong(text);
                                preferenceUtils.putLong(keyValue.first, numberLong);
                                dialog.dismiss();
                                break;
                            case SharedPreferenceUtils.SPINNER_BOOLEAN:
                                boolean value = booleanSwitch.isChecked();
                                preferenceUtils.putBoolean(keyValue.first, value);
                                dialog.dismiss();
                                break;
                            case SharedPreferenceUtils.SPINNER_FLOAT:
                                float numberFloat = SharedPreferenceUtils.getNumberFloat(text);
                                preferenceUtils.putFloat(keyValue.first, numberFloat);
                                dialog.dismiss();
                                break;
                        }
                        refreshKeyValues();
                    }
                });
            }
        });
        dialog.show();
    } else {
        AlertDialog.Builder builder = new Builder(getActivity());
        builder.setTitle("Test mode not enabled").setMessage("If you want to edit value for testing, testing mode should be enabled. It's available in options menu").setPositiveButton("Enable test mode", new OnClickListener() {

            @Override
            public void onClick(DialogInterface dialog, int which) {
                getActivity().supportInvalidateOptionsMenu();
                changeTestMode();
                onItemClick(parent, view, position, id);
            }
        }).setNegativeButton(cancel, new OnClickListener() {

            @Override
            public void onClick(DialogInterface dialog, int which) {
                dialog.dismiss();
                dialog.cancel();
            }
        }).show();
    }
}
Also used : AlertDialog(android.support.v7.app.AlertDialog) DialogInterface(android.content.DialogInterface) Spinner(android.widget.Spinner) Builder(android.support.v7.app.AlertDialog.Builder) Builder(android.support.v7.app.AlertDialog.Builder) Button(android.widget.Button) CompoundButton(android.widget.CompoundButton) Editable(android.text.Editable) Pair(android.support.v4.util.Pair) EditText(android.widget.EditText) OnCheckedChangeListener(android.widget.CompoundButton.OnCheckedChangeListener) SearchView(android.support.v7.widget.SearchView) View(android.view.View) AdapterView(android.widget.AdapterView) ListView(android.widget.ListView) OnItemSelectedListener(android.widget.AdapterView.OnItemSelectedListener) OnClickListener(android.content.DialogInterface.OnClickListener) AdapterView(android.widget.AdapterView) CompoundButton(android.widget.CompoundButton) SwitchCompat(android.support.v7.widget.SwitchCompat)

Aggregations

AlertDialog (android.support.v7.app.AlertDialog)114 DialogInterface (android.content.DialogInterface)76 View (android.view.View)67 TextView (android.widget.TextView)48 Intent (android.content.Intent)36 RecyclerView (android.support.v7.widget.RecyclerView)27 ListView (android.widget.ListView)23 Dialog (android.app.Dialog)22 LayoutInflater (android.view.LayoutInflater)20 ImageView (android.widget.ImageView)20 EditText (android.widget.EditText)18 SuppressLint (android.annotation.SuppressLint)17 Context (android.content.Context)17 Bundle (android.os.Bundle)15 NonNull (android.support.annotation.NonNull)14 Button (android.widget.Button)13 ArrayList (java.util.ArrayList)12 BrowserDialog (acr.browser.lightning.dialog.BrowserDialog)10 OnClickListener (android.content.DialogInterface.OnClickListener)10 ScrollView (android.widget.ScrollView)10