Search in sources :

Example 96 with DialogInterface

use of android.content.DialogInterface in project wire-android by wireapp.

the class PickUserFragment method onContactListContactClicked.

@Override
public void onContactListContactClicked(final ContactDetails contactDetails) {
    getStoreFactory().getNetworkStore().doIfHasInternetOrNotifyUser(new DefaultNetworkAction() {

        @Override
        public void execute(NetworkMode networkMode) {
            final int contactMethodsCount = contactDetails.getContactMethods().size();
            final ContactMethod[] contactMethods = contactDetails.getContactMethods().toArray(new ContactMethod[contactMethodsCount]);
            if (contactMethodsCount == 1 && contactMethods[0].getKind() == ContactMethod.Kind.SMS) {
                // Launch SMS app directly if contact only has phone numner
                final String number = contactMethods[0].getStringRepresentation();
                sendSMSInvite(number);
                ((BaseScalaActivity) getActivity()).injectJava(GlobalTrackingController.class).tagEvent(new OpenedGenericInviteMenuEvent(OpenedGenericInviteMenuEvent.EventContext.ADDRESSBOOK));
                return;
            }
            final CharSequence[] itemNames = new CharSequence[contactMethodsCount];
            for (int i = 0; i < contactMethodsCount; i++) {
                ContactMethod contactMethod = contactMethods[i];
                itemNames[i] = contactMethod.getStringRepresentation();
            }
            AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());
            builder.setTitle(getResources().getString(R.string.people_picker__contact_list__invite_dialog__title)).setPositiveButton(getResources().getText(R.string.confirmation_menu__confirm_done), new DialogInterface.OnClickListener() {

                @Override
                public void onClick(DialogInterface dialogInterface, int i) {
                    ListView lv = dialog.getListView();
                    int selected = lv.getCheckedItemPosition();
                    ContactMethod selectedContactMethod = null;
                    if (selected >= 0) {
                        selectedContactMethod = contactMethods[selected];
                    }
                    if (selectedContactMethod == null) {
                        return;
                    }
                    if (selectedContactMethod.getKind() == ContactMethod.Kind.SMS) {
                        final String number = String.valueOf(itemNames[selected]);
                        sendSMSInvite(number);
                        ((BaseScalaActivity) getActivity()).injectJava(GlobalTrackingController.class).tagEvent(new OpenedGenericInviteMenuEvent(OpenedGenericInviteMenuEvent.EventContext.ADDRESSBOOK));
                    } else {
                        selectedContactMethod.invite(" ", null);
                        Toast.makeText(getActivity(), getResources().getString(R.string.people_picker__invite__sent_feedback), Toast.LENGTH_LONG).show();
                        boolean fromSearch = TextUtils.isEmpty(getControllerFactory().getPickUserController().getSearchFilter());
                        TrackingUtils.tagSentInviteToContactEvent(((BaseScalaActivity) getActivity()).injectJava(GlobalTrackingController.class), selectedContactMethod.getKind(), contactDetails.hasBeenInvited(), fromSearch);
                    }
                }
            }).setNegativeButton(getResources().getText(R.string.confirmation_menu__cancel), new DialogInterface.OnClickListener() {

                @Override
                public void onClick(DialogInterface dialogInterface, int i) {
                    dialogInterface.cancel();
                }
            }).setSingleChoiceItems(itemNames, DEFAULT_SELECTED_INVITE_METHOD, null);
            dialog = builder.create();
            dialog.show();
            ((BaseScalaActivity) getActivity()).injectJava(GlobalTrackingController.class).onApplicationScreen(ApplicationScreen.SEND_PERSONAL_INVITE_MENU);
        }
    });
}
Also used : AlertDialog(android.support.v7.app.AlertDialog) BaseScalaActivity(com.waz.zclient.BaseScalaActivity) GlobalTrackingController(com.waz.zclient.tracking.GlobalTrackingController) DialogInterface(android.content.DialogInterface) NetworkMode(com.waz.api.NetworkMode) ListView(android.widget.ListView) OpenedGenericInviteMenuEvent(com.waz.zclient.controllers.tracking.events.connect.OpenedGenericInviteMenuEvent) DefaultNetworkAction(com.waz.zclient.core.stores.network.DefaultNetworkAction) ContactMethod(com.waz.api.ContactMethod)

Example 97 with DialogInterface

use of android.content.DialogInterface in project WordPress-Android by wordpress-mobile.

the class CommentsListFragment method confirmDeleteComments.

private void confirmDeleteComments() {
    if (mCommentStatusFilter == CommentStatusCriteria.TRASH) {
        AlertDialog.Builder dialogBuilder = new AlertDialog.Builder(getActivity());
        dialogBuilder.setTitle(getResources().getText(R.string.delete));
        int resId = getAdapter().getSelectedCommentCount() > 1 ? R.string.dlg_sure_to_delete_comments : R.string.dlg_sure_to_delete_comment;
        dialogBuilder.setMessage(getResources().getText(resId));
        dialogBuilder.setPositiveButton(getResources().getText(R.string.yes), new DialogInterface.OnClickListener() {

            public void onClick(DialogInterface dialog, int whichButton) {
                deleteSelectedComments(true);
            }
        });
        dialogBuilder.setNegativeButton(getResources().getText(R.string.no), null);
        dialogBuilder.setCancelable(true);
        dialogBuilder.create().show();
    } else {
        AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());
        builder.setMessage(R.string.dlg_confirm_trash_comments);
        builder.setTitle(R.string.trash);
        builder.setCancelable(true);
        builder.setPositiveButton(R.string.trash_yes, new DialogInterface.OnClickListener() {

            @Override
            public void onClick(DialogInterface dialog, int id) {
                deleteSelectedComments(false);
            }
        });
        builder.setNegativeButton(R.string.trash_no, new DialogInterface.OnClickListener() {

            @Override
            public void onClick(DialogInterface dialog, int id) {
                dialog.cancel();
            }
        });
        AlertDialog alert = builder.create();
        alert.show();
    }
}
Also used : AlertDialog(android.app.AlertDialog) DialogInterface(android.content.DialogInterface) CommentActionBuilder(org.wordpress.android.fluxc.generated.CommentActionBuilder)

Example 98 with DialogInterface

use of android.content.DialogInterface in project HumaneApp by Ganesh1010.

the class GPSTracker method showSettingsAlert.

/**
	 * Function to show settings alert dialog
	 */
public void showSettingsAlert() {
    AlertDialog.Builder alertDialog = new AlertDialog.Builder(mContext);
    //Setting Dialog Title
    alertDialog.setTitle("GPSAlertDialogTitle");
    //Setting Dialog Message
    alertDialog.setMessage("GPSAlertDialogMessage");
    //On Pressing Setting button
    alertDialog.setPositiveButton(R.string.action_settings, new DialogInterface.OnClickListener() {

        @Override
        public void onClick(DialogInterface dialog, int which) {
            Intent intent = new Intent(Settings.ACTION_LOCATION_SOURCE_SETTINGS);
            mContext.startActivity(intent);
        }
    });
    //On pressing cancel button
    alertDialog.setNegativeButton(R.string.cancel, new DialogInterface.OnClickListener() {

        @Override
        public void onClick(DialogInterface dialog, int which) {
            dialog.cancel();
        }
    });
    alertDialog.show();
}
Also used : AlertDialog(android.app.AlertDialog) DialogInterface(android.content.DialogInterface) Intent(android.content.Intent)

Example 99 with DialogInterface

use of android.content.DialogInterface in project HumaneApp by Ganesh1010.

the class OrganisationRegistrationFragment method onCreateView.

@Nullable
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    Bundle i = getArguments();
    if (i != null) {
        orgDetailsString = i.getString("COORDINATOR");
    }
    if (v == null)
        v = inflater.inflate(R.layout.fragment_organisation_register_page, container, false);
    landingPage = (LandingPage) getActivity();
    orgNoEditText = (EditText) v.findViewById(R.id.org_register_num_editText_org_form);
    orgNameEditText = (EditText) v.findViewById(R.id.org_name_editText_org_form);
    orgaddressEditText = (EditText) v.findViewById(R.id.org_address_editText_org_form);
    orgEmailEditText = (EditText) v.findViewById(R.id.org_email_editText_org_form);
    orgMobNoEditText = (EditText) v.findViewById(R.id.org_phone_editText_org_form);
    orgDescEditText = (EditText) v.findViewById(R.id.org_desc_editText_org_form);
    orgTypeFromSpinner = (Spinner) v.findViewById(R.id.org_type_spinner_org_form);
    orgRegisterButton = (Button) v.findViewById(R.id.submit_button_org_form);
    chooseLocationButton = (Button) v.findViewById(R.id.map);
    //v.getRootView().setBackgroundColor(Color.WHITE);
    orgRegisterButton.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View view) {
            register();
        }
    });
    chooseLocationButton.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View arg0) {
            // create class object
            gps = new GPSTracker(landingPage);
            // check if GPS enabled
            if (gps.getIsGPSTrackingEnabled()) {
                if (isNetworkAvailable()) {
                    Intent intent = new Intent(landingPage, MapActivity.class);
                    startActivityForResult(intent, 2);
                } else {
                    AlertDialog.Builder alertDialog = new AlertDialog.Builder(landingPage);
                    alertDialog.setTitle("Internet settings");
                    alertDialog.setMessage("Mobile data is not enabled. Do you want to go to settings menu?");
                    // On pressing Settings button
                    alertDialog.setPositiveButton("Settings", new DialogInterface.OnClickListener() {

                        public void onClick(DialogInterface dialog, int which) {
                            Intent intent = new Intent(Settings.ACTION_SETTINGS);
                            startActivity(intent);
                        }
                    });
                    alertDialog.setNegativeButton("Cancel", new DialogInterface.OnClickListener() {

                        public void onClick(DialogInterface dialog, int which) {
                            dialog.cancel();
                        }
                    });
                    // Showing Alert Message
                    alertDialog.show();
                }
            } else {
                gps.showSettingsAlert();
            }
        }
    });
    return v;
}
Also used : AlertDialog(android.app.AlertDialog) DialogInterface(android.content.DialogInterface) Bundle(android.os.Bundle) Intent(android.content.Intent) View(android.view.View) Nullable(android.support.annotation.Nullable)

Example 100 with DialogInterface

use of android.content.DialogInterface in project HumaneApp by Ganesh1010.

the class DonationConfirmationActivity method onCreate.

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_donation_confirmation);
    mainItemList = (LinearLayout) findViewById(R.id.mainItemNeedList);
    for (int i = 0; i < 2; i++) {
        ImageView mainItem = new ImageView(getApplicationContext());
        mainItem.setBackgroundResource(R.drawable.ic_cloth_black);
        mainItemList.addView(mainItem);
        LinearLayout.LayoutParams margins = new LinearLayout.LayoutParams(mainItem.getLayoutParams());
        margins.rightMargin = 20;
        margins.leftMargin = 20;
        mainItem.setLayoutParams(margins);
        mainItem.setMinimumHeight(100);
        mainItem.setMaxHeight(200);
        mainItem.setMinimumWidth(100);
        mainItem.setMaxWidth(200);
        mainItem.setOnClickListener(new View.OnClickListener() {

            @Override
            public void onClick(View v) {
                AlertDialog.Builder builder = new AlertDialog.Builder(DonationConfirmationActivity.this);
                builder.setTitle("Item Details");
                LayoutInflater inflater = (LayoutInflater) getApplicationContext().getSystemService(Context.LAYOUT_INFLATER_SERVICE);
                View dialogView = inflater.inflate(R.layout.donation_confirmation_item_display, null);
                RecyclerView itemToDisplay = (RecyclerView) dialogView.findViewById(R.id.itemToDisplay);
                itemToDisplay.setAdapter(new DonationConfirmationItemDisplayAdapter());
                builder.setView(dialogView);
                itemToDisplay.setAdapter(new DonationConfirmationItemDisplayAdapter());
                builder.setPositiveButton("OK", new DialogInterface.OnClickListener() {

                    public void onClick(DialogInterface dialog, int id) {
                        dialog.dismiss();
                    }
                });
                AlertDialog dialog = builder.create();
                dialog.show();
            }
        });
    }
}
Also used : AlertDialog(android.app.AlertDialog) DialogInterface(android.content.DialogInterface) RecyclerView(android.support.v7.widget.RecyclerView) ImageView(android.widget.ImageView) View(android.view.View) LayoutInflater(android.view.LayoutInflater) RecyclerView(android.support.v7.widget.RecyclerView) ImageView(android.widget.ImageView) LinearLayout(android.widget.LinearLayout)

Aggregations

DialogInterface (android.content.DialogInterface)2727 AlertDialog (android.app.AlertDialog)1227 View (android.view.View)877 Intent (android.content.Intent)708 TextView (android.widget.TextView)653 AlertDialog (android.support.v7.app.AlertDialog)644 EditText (android.widget.EditText)426 ImageView (android.widget.ImageView)308 OnClickListener (android.content.DialogInterface.OnClickListener)285 LayoutInflater (android.view.LayoutInflater)242 SuppressLint (android.annotation.SuppressLint)225 AdapterView (android.widget.AdapterView)220 ListView (android.widget.ListView)220 ArrayList (java.util.ArrayList)213 Dialog (android.app.Dialog)179 Context (android.content.Context)179 File (java.io.File)160 OnClickListener (android.view.View.OnClickListener)157 Bundle (android.os.Bundle)146 Activity (android.app.Activity)143