Search in sources :

Example 66 with AlertDialog

use of android.app.AlertDialog in project collect by opendatakit.

the class GeoPointOsmMapActivity method showGPSDisabledAlertToUser.

private void showGPSDisabledAlertToUser() {
    AlertDialog.Builder alertDialogBuilder = new AlertDialog.Builder(this);
    alertDialogBuilder.setMessage(getString(R.string.gps_enable_message)).setCancelable(false).setPositiveButton(getString(R.string.enable_gps), new DialogInterface.OnClickListener() {

        public void onClick(DialogInterface dialog, int id) {
            startActivityForResult(new Intent(Settings.ACTION_LOCATION_SOURCE_SETTINGS), 0);
        }
    });
    alertDialogBuilder.setNegativeButton(getString(R.string.cancel), new DialogInterface.OnClickListener() {

        public void onClick(DialogInterface dialog, int id) {
            dialog.cancel();
        }
    });
    AlertDialog alert = alertDialogBuilder.create();
    alert.show();
}
Also used : AlertDialog(android.app.AlertDialog) DialogInterface(android.content.DialogInterface) Intent(android.content.Intent) GeoPoint(org.osmdroid.util.GeoPoint)

Example 67 with AlertDialog

use of android.app.AlertDialog in project collect by opendatakit.

the class GeoShapeOsmMapActivity method showGPSDisabledAlertToUser.

private void showGPSDisabledAlertToUser() {
    AlertDialog.Builder alertDialogBuilder = new AlertDialog.Builder(this);
    alertDialogBuilder.setMessage(getString(R.string.gps_enable_message)).setCancelable(false).setPositiveButton(getString(R.string.enable_gps), new DialogInterface.OnClickListener() {

        public void onClick(DialogInterface dialog, int id) {
            startActivityForResult(new Intent(Settings.ACTION_LOCATION_SOURCE_SETTINGS), 0);
        }
    });
    alertDialogBuilder.setNegativeButton(getString(R.string.cancel), new DialogInterface.OnClickListener() {

        public void onClick(DialogInterface dialog, int id) {
            dialog.cancel();
        }
    });
    AlertDialog alert = alertDialogBuilder.create();
    alert.show();
}
Also used : AlertDialog(android.app.AlertDialog) DialogInterface(android.content.DialogInterface) Intent(android.content.Intent) GeoPoint(org.osmdroid.util.GeoPoint) Paint(android.graphics.Paint)

Example 68 with AlertDialog

use of android.app.AlertDialog in project collect by opendatakit.

the class InstanceUploaderList method showSentAndUnsentChoices.

private boolean showSentAndUnsentChoices() {
    /**
     * Create a dialog with options to save and exit, save, or quit without
     * saving
     */
    String[] items = { getString(R.string.show_unsent_forms), getString(R.string.show_sent_and_unsent_forms) };
    logger.logAction(this, "changeView", "show");
    AlertDialog alertDialog = new AlertDialog.Builder(this).setIcon(android.R.drawable.ic_dialog_info).setTitle(getString(R.string.change_view)).setNeutralButton(getString(R.string.cancel), new DialogInterface.OnClickListener() {

        @Override
        public void onClick(DialogInterface dialog, int id) {
            logger.logAction(this, "changeView", "cancel");
            dialog.cancel();
        }
    }).setItems(items, new DialogInterface.OnClickListener() {

        @Override
        public void onClick(DialogInterface dialog, int which) {
            switch(which) {
                case // show unsent
                0:
                    logger.logAction(this, "changeView", "showUnsent");
                    InstanceUploaderList.this.showUnsent();
                    break;
                case // show all
                1:
                    logger.logAction(this, "changeView", "showAll");
                    InstanceUploaderList.this.showAll();
                    break;
                case // do nothing
                2:
                    break;
            }
        }
    }).create();
    alertDialog.show();
    return true;
}
Also used : AlertDialog(android.app.AlertDialog) DialogInterface(android.content.DialogInterface) OnClickListener(android.view.View.OnClickListener)

Example 69 with AlertDialog

use of android.app.AlertDialog in project orgzly-android by orgzly.

the class MainActivity method onBookRenameRequest.

@Override
public void onBookRenameRequest(final long bookId) {
    final Book book = BooksClient.get(this, bookId);
    if (book == null) {
        return;
    }
    final View dialogView = View.inflate(this, R.layout.dialog_book_rename, null);
    final TextInputLayout nameInputLayout = dialogView.findViewById(R.id.name_input_layout);
    final EditText name = dialogView.findViewById(R.id.name);
    DialogInterface.OnClickListener dialogClickListener = (dialog, which) -> {
        switch(which) {
            case DialogInterface.BUTTON_POSITIVE:
                doRenameBook(book, name.getText().toString(), nameInputLayout);
                break;
            case DialogInterface.BUTTON_NEGATIVE:
                break;
        }
    };
    AlertDialog.Builder builder = new AlertDialog.Builder(this).setTitle(getString(R.string.rename_book, MiscUtils.quotedString(book.getName()))).setPositiveButton(R.string.rename, dialogClickListener).setNegativeButton(R.string.cancel, dialogClickListener).setView(dialogView);
    name.setText(book.getName());
    final AlertDialog dialog = builder.create();
    /* Finish on keyboard action press. */
    name.setOnEditorActionListener((v, actionId, event) -> {
        dialog.getButton(DialogInterface.BUTTON_POSITIVE).performClick();
        return true;
    });
    final Activity activity = this;
    dialog.setOnShowListener(d -> ActivityUtils.INSTANCE.openSoftKeyboard(activity, name));
    dialog.setOnDismissListener(d -> ActivityUtils.INSTANCE.closeSoftKeyboard(activity));
    name.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 str) {
            /* Disable the button is nothing is entered. */
            dialog.getButton(AlertDialog.BUTTON_POSITIVE).setEnabled(!TextUtils.isEmpty(str));
        }
    });
    dialog.show();
}
Also used : EditText(android.widget.EditText) NavigationView(android.support.design.widget.NavigationView) Shelf(com.orgzly.android.Shelf) Bundle(android.os.Bundle) Notifications(com.orgzly.android.Notifications) FilterFragment(com.orgzly.android.ui.fragments.FilterFragment) SearchView(android.support.v7.widget.SearchView) Uri(android.net.Uri) LocalBroadcastManager(android.support.v4.content.LocalBroadcastManager) Note(com.orgzly.android.Note) TextInputLayout(android.support.design.widget.TextInputLayout) BooksClient(com.orgzly.android.provider.clients.BooksClient) ActivityUtils(com.orgzly.android.ui.util.ActivityUtils) CheckBox(android.widget.CheckBox) Query(com.orgzly.android.query.Query) BookPrefaceFragment(com.orgzly.android.ui.fragments.BookPrefaceFragment) Handler(android.os.Handler) Map(java.util.Map) View(android.view.View) DrawerNavigationView(com.orgzly.android.ui.drawer.DrawerNavigationView) Repo(com.orgzly.android.repos.Repo) ActionMode(android.support.v7.view.ActionMode) IntentFilter(android.content.IntentFilter) Fragment(android.support.v4.app.Fragment) NotesBatch(com.orgzly.android.NotesBatch) Set(java.util.Set) BroadcastReceiver(android.content.BroadcastReceiver) ViewGroup(android.view.ViewGroup) AlertDialog(android.app.AlertDialog) TextView(android.widget.TextView) BookFragment(com.orgzly.android.ui.fragments.BookFragment) SyncFragment(com.orgzly.android.ui.fragments.SyncFragment) Book(com.orgzly.android.Book) BuildConfig(com.orgzly.BuildConfig) SimpleOneLinerDialog(com.orgzly.android.ui.dialogs.SimpleOneLinerDialog) NoteListFragment(com.orgzly.android.ui.fragments.NoteListFragment) BooksFragment(com.orgzly.android.ui.fragments.BooksFragment) Snackbar(android.support.design.widget.Snackbar) OrgDateTime(com.orgzly.org.datetime.OrgDateTime) TextWatcher(android.text.TextWatcher) DottedQueryBuilder(com.orgzly.android.query.user.DottedQueryBuilder) MiscUtils(com.orgzly.android.util.MiscUtils) Context(android.content.Context) Intent(android.content.Intent) StringRes(android.support.annotation.StringRes) NonNull(android.support.annotation.NonNull) Editable(android.text.Editable) AppPermissions(com.orgzly.android.util.AppPermissions) TypedArray(android.content.res.TypedArray) MenuItem(android.view.MenuItem) SettingsActivity(com.orgzly.android.ui.settings.SettingsActivity) ArrayList(java.util.ArrayList) GravityCompat(android.support.v4.view.GravityCompat) LinkedHashMap(java.util.LinkedHashMap) AppPreferences(com.orgzly.android.prefs.AppPreferences) NoteFragment(com.orgzly.android.ui.fragments.NoteFragment) R(com.orgzly.R) Menu(android.view.Menu) AppIntent(com.orgzly.android.AppIntent) DrawerLayout(android.support.v4.widget.DrawerLayout) FiltersFragment(com.orgzly.android.ui.fragments.FiltersFragment) DialogInterface(android.content.DialogInterface) CompoundButton(android.widget.CompoundButton) TextUtils(android.text.TextUtils) IOException(java.io.IOException) File(java.io.File) Spinner(android.widget.Spinner) Filter(com.orgzly.android.filter.Filter) ArrayAdapter(android.widget.ArrayAdapter) ReposClient(com.orgzly.android.provider.clients.ReposClient) Toolbar(android.support.v7.widget.Toolbar) Configuration(android.content.res.Configuration) Condition(com.orgzly.android.query.Condition) ActionService(com.orgzly.android.ActionService) BookName(com.orgzly.android.BookName) Activity(android.app.Activity) ActionBarDrawerToggle(android.support.v7.app.ActionBarDrawerToggle) EditText(android.widget.EditText) LogUtils(com.orgzly.android.util.LogUtils) AlertDialog(android.app.AlertDialog) DialogInterface(android.content.DialogInterface) DottedQueryBuilder(com.orgzly.android.query.user.DottedQueryBuilder) SettingsActivity(com.orgzly.android.ui.settings.SettingsActivity) Activity(android.app.Activity) NavigationView(android.support.design.widget.NavigationView) SearchView(android.support.v7.widget.SearchView) View(android.view.View) DrawerNavigationView(com.orgzly.android.ui.drawer.DrawerNavigationView) TextView(android.widget.TextView) Book(com.orgzly.android.Book) TextWatcher(android.text.TextWatcher) Editable(android.text.Editable) TextInputLayout(android.support.design.widget.TextInputLayout)

Example 70 with AlertDialog

use of android.app.AlertDialog in project pictureapp by EyeSeeTea.

the class Dialog method onCreate.

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    Intent intent = getIntent();
    String message = intent.getStringExtra("message");
    String title = intent.getStringExtra("title");
    alertDialog = new AlertDialog.Builder(this);
    alertDialog.setTitle("");
    alertDialog.setMessage(message);
    alertDialog.setCancelable(false);
    alertDialog.setTitle(title);
    alertDialog.setPositiveButton(R.string.accept, new DialogInterface.OnClickListener() {

        public void onClick(DialogInterface dialog, int id) {
            goBack();
        }
    });
    alertDialog.show();
}
Also used : AlertDialog(android.app.AlertDialog) DialogInterface(android.content.DialogInterface) Intent(android.content.Intent)

Aggregations

AlertDialog (android.app.AlertDialog)1029 DialogInterface (android.content.DialogInterface)573 View (android.view.View)278 TextView (android.widget.TextView)213 Intent (android.content.Intent)172 EditText (android.widget.EditText)160 Test (org.junit.Test)148 ShadowAlertDialog (org.robolectric.shadows.ShadowAlertDialog)111 Context (android.content.Context)96 ListView (android.widget.ListView)87 ImageView (android.widget.ImageView)86 LayoutInflater (android.view.LayoutInflater)80 Button (android.widget.Button)78 AdapterView (android.widget.AdapterView)72 Activity (android.app.Activity)66 SuppressLint (android.annotation.SuppressLint)61 Bundle (android.os.Bundle)56 OnClickListener (android.content.DialogInterface.OnClickListener)54 ArrayList (java.util.ArrayList)50 Dialog (android.app.Dialog)46