Search in sources :

Example 41 with AlertDialog

use of android.support.v7.app.AlertDialog in project instructure-android by instructure.

the class CalendarChooserDialogStyled method onCreateDialog.

@NonNull
@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
    final FragmentActivity activity = getActivity();
    final CalendarChooserAdapter listAdapter = new CalendarChooserAdapter(activity, android.R.layout.select_dialog_multichoice);
    final ListView listView = new ListView(activity);
    listView.setAdapter(listAdapter);
    // Override onItemCLick to implement "checking" behavior and handle contextsForReturn
    listView.setOnItemClickListener(new AdapterView.OnItemClickListener() {

        @Override
        public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
            CheckBox checkBox = view.findViewById(R.id.checkBox);
            String contextId = "";
            if (view.getTag() instanceof ViewHolder) {
                contextId = ((ViewHolder) view.getTag()).contextId;
            }
            if (checkBox.isChecked()) {
                checkBox.setChecked(false);
                removeSelection(position, contextId);
            } else {
                if (mSelectedIds.size() >= 10) {
                    Toast.makeText(activity, getResources().getString(R.string.calendarDialog10Warning), Toast.LENGTH_SHORT).show();
                } else {
                    checkBox.setChecked(true);
                    addSelection(position, contextId);
                }
            }
        }
    });
    final AlertDialog dialog = new AlertDialog.Builder(activity).setTitle(R.string.selectCanvasCalendars).setView(listView).setPositiveButton(R.string.done, new DialogInterface.OnClickListener() {

        @Override
        public void onClick(DialogInterface dialog, int which) {
            if (mSelectedIds.size() > 0) {
                if (mCallback != null) {
                    if (selectionChanged()) {
                        // We only want to refresh if a change was made
                        mCallback.onCalendarsSelected(getSelectedContexts());
                    }
                } else {
                    Toast.makeText(activity, R.string.errorOccurred, Toast.LENGTH_SHORT).show();
                }
                dialog.dismiss();
            } else {
                Toast.makeText(activity, getResources().getString(R.string.calendarDialogNoneWarning), Toast.LENGTH_SHORT).show();
            }
        }
    }).setNegativeButton(R.string.cancel, new DialogInterface.OnClickListener() {

        @Override
        public void onClick(DialogInterface dialog, int which) {
            if (mSelectedIds.size() < 1) {
                Toast.makeText(activity, getResources().getString(R.string.calendarDialogNoneWarning), Toast.LENGTH_SHORT).show();
            } else {
                if (mCallback != null) {
                    if (mIsFirstShow) {
                        // We only want to make a call here if it's their first time (on negative)
                        mCallback.onCalendarsSelected(getSelectedContexts());
                    }
                }
                dialog.dismiss();
            }
        }
    }).setCancelable(false).setOnDismissListener(new DialogInterface.OnDismissListener() {

        @Override
        public void onDismiss(DialogInterface dialog) {
            if (mSelectedIds.size() > 0) {
                if (mCallback != null) {
                    if (mIsFirstShow) {
                        // We only want to make a call here if it's their first time (on negative)
                        mCallback.onCalendarsSelected(getSelectedContexts());
                    }
                }
            }
            dialog.dismiss();
        }
    }).setOnKeyListener(new DialogInterface.OnKeyListener() {

        @Override
        public boolean onKey(DialogInterface dialog, int keyCode, KeyEvent event) {
            if (keyCode == KeyEvent.KEYCODE_BACK && event.getRepeatCount() == 0) {
                if (mSelectedIds.size() > 0) {
                    if (mCallback != null) {
                        if (mIsFirstShow) {
                            // We only want to make a call here if it's their first time (on negative)
                            mCallback.onCalendarsSelected(getSelectedContexts());
                        }
                    }
                }
                dialog.dismiss();
                return true;
            }
            return false;
        }
    }).create();
    dialog.setOnShowListener(new DialogInterface.OnShowListener() {

        @Override
        public void onShow(DialogInterface useless) {
            dialog.getButton(AlertDialog.BUTTON_POSITIVE).setTextColor(ThemePrefs.getBrandColor());
            dialog.getButton(AlertDialog.BUTTON_NEGATIVE).setTextColor(ThemePrefs.getBrandColor());
        }
    });
    return dialog;
}
Also used : AlertDialog(android.support.v7.app.AlertDialog) DialogInterface(android.content.DialogInterface) ImageView(android.widget.ImageView) View(android.view.View) AdapterView(android.widget.AdapterView) TextView(android.widget.TextView) ListView(android.widget.ListView) KeyEvent(android.view.KeyEvent) FragmentActivity(android.support.v4.app.FragmentActivity) ListView(android.widget.ListView) CheckBox(android.widget.CheckBox) AppCompatCheckBox(android.support.v7.widget.AppCompatCheckBox) AdapterView(android.widget.AdapterView) NonNull(android.support.annotation.NonNull)

Example 42 with AlertDialog

use of android.support.v7.app.AlertDialog in project instructure-android by instructure.

the class QuizQuestionDialog method onCreateDialog.

@NonNull
@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
    final FragmentActivity activity = getActivity();
    AlertDialog.Builder builder = new AlertDialog.Builder(activity).setTitle(activity.getString(R.string.viewQuestions)).setPositiveButton(activity.getString(R.string.okay), null);
    // Suppress lint warning about null parent when inflating layout
    @SuppressLint("InflateParams") View view = LayoutInflater.from(getActivity()).inflate(R.layout.quiz_question_dialog, null);
    listView = view.findViewById(R.id.listview);
    builder.setView(view);
    final AlertDialog dialog = builder.create();
    dialog.setCancelable(true);
    dialog.setCanceledOnTouchOutside(true);
    dialog.setOnShowListener(new DialogInterface.OnShowListener() {

        @Override
        public void onShow(DialogInterface useless) {
            CanvasContext course = getArguments().getParcelable(Const.COURSE);
            if (course != null) {
                int courseColor = ColorKeeper.getOrGenerateColor(course);
                dialog.getButton(AlertDialog.BUTTON_POSITIVE).setTextColor(courseColor);
            }
        }
    });
    return dialog;
}
Also used : AlertDialog(android.support.v7.app.AlertDialog) FragmentActivity(android.support.v4.app.FragmentActivity) DialogInterface(android.content.DialogInterface) SuppressLint(android.annotation.SuppressLint) CanvasContext(com.instructure.canvasapi2.models.CanvasContext) ImageView(android.widget.ImageView) View(android.view.View) RecyclerView(android.support.v7.widget.RecyclerView) TextView(android.widget.TextView) ExpandableListView(android.widget.ExpandableListView) NonNull(android.support.annotation.NonNull)

Example 43 with AlertDialog

use of android.support.v7.app.AlertDialog in project instructure-android by instructure.

the class ShareFileDestinationDialog method onCreateDialog.

@NonNull
@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
    loadBundleData();
    final AlertDialog alertDialog = new AlertDialog.Builder(getActivity()).setView(initViews()).setPositiveButton(R.string.next, new DialogInterface.OnClickListener() {

        @Override
        public void onClick(DialogInterface dialog, int which) {
            validateAndShowNext();
        }
    }).setNegativeButton(R.string.cancel, new DialogInterface.OnClickListener() {

        @Override
        public void onClick(DialogInterface dialog, int which) {
            dismissAllowingStateLoss();
        }
    }).setCancelable(true).create();
    alertDialog.setOnShowListener(new DialogInterface.OnShowListener() {

        @Override
        public void onShow(DialogInterface dialog) {
            if (alertDialog != null) {
                alertDialog.getButton(AlertDialog.BUTTON_POSITIVE).setTextColor(ThemePrefs.getButtonColor());
                alertDialog.getButton(AlertDialog.BUTTON_NEGATIVE).setTextColor(ThemePrefs.getButtonColor());
            }
        }
    });
    return alertDialog;
}
Also used : AlertDialog(android.support.v7.app.AlertDialog) DialogInterface(android.content.DialogInterface) NonNull(android.support.annotation.NonNull)

Example 44 with AlertDialog

use of android.support.v7.app.AlertDialog in project instructure-android by instructure.

the class WhatIfDialogStyled method onCreateDialog.

@NonNull
@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
    final FragmentActivity activity = getActivity();
    AlertDialog.Builder builder = new AlertDialog.Builder(activity).setTitle(activity.getString(R.string.whatIfDialogText)).setPositiveButton(R.string.done, new DialogInterface.OnClickListener() {

        @Override
        public void onClick(DialogInterface dialog, int which) {
            if (callback != null) {
                final String whatIf = whatIfScore.getText().toString();
                callback.onOkayClick(whatIf, Double.parseDouble(totalScore), assignment, position);
            }
            dismissAllowingStateLoss();
        }
    }).setNegativeButton(R.string.cancel, new DialogInterface.OnClickListener() {

        @Override
        public void onClick(DialogInterface dialog, int which) {
            dismissAllowingStateLoss();
        }
    });
    @SuppressLint("InflateParams") View view = LayoutInflater.from(activity).inflate(R.layout.what_if_dialog, null);
    EditText totalScoreEdit = view.findViewById(R.id.totalScore);
    totalScoreEdit.setText(totalScore);
    whatIfScore = view.findViewById(R.id.currentScore);
    builder.setView(view);
    final AlertDialog dialog = builder.create();
    dialog.setOnShowListener(new DialogInterface.OnShowListener() {

        @Override
        public void onShow(DialogInterface worthless) {
            if (courseColor != 0) {
                dialog.getButton(AlertDialog.BUTTON_POSITIVE).setTextColor(courseColor);
                dialog.getButton(AlertDialog.BUTTON_NEGATIVE).setTextColor(courseColor);
            }
        }
    });
    dialog.setCanceledOnTouchOutside(true);
    return dialog;
}
Also used : AlertDialog(android.support.v7.app.AlertDialog) EditText(android.widget.EditText) DialogInterface(android.content.DialogInterface) View(android.view.View) SuppressLint(android.annotation.SuppressLint) FragmentActivity(android.support.v4.app.FragmentActivity) SuppressLint(android.annotation.SuppressLint) NonNull(android.support.annotation.NonNull)

Example 45 with AlertDialog

use of android.support.v7.app.AlertDialog in project instructure-android by instructure.

the class RCEInsertDialog method onCreateDialog.

@NonNull
@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
    View root = LayoutInflater.from(getContext()).inflate(R.layout.rce_dialog_insert, null);
    AlertDialog.Builder builder = new AlertDialog.Builder(getContext());
    builder.setView(root);
    builder.setTitle(getArguments().getString(TITLE));
    builder.setPositiveButton(R.string.rce_dialogDone, new DialogInterface.OnClickListener() {

        @Override
        public void onClick(DialogInterface dialog, int which) {
            if (mCallback != null) {
                mCallback.onResults(mUrlEditText.getText().toString(), mAltEditText.getText().toString());
            }
            dismiss();
        }
    });
    builder.setNegativeButton(R.string.rce_dialogCancel, new DialogInterface.OnClickListener() {

        @Override
        public void onClick(DialogInterface dialog, int which) {
            dismiss();
        }
    });
    final int themeColor = getArguments().getInt(THEME_COLOR, Color.BLACK);
    final int highlightColor = RCEUtils.increaseAlpha(themeColor);
    final ColorStateList colorStateList = RCEUtils.makeEditTextColorStateList(Color.BLACK, themeColor);
    mAltEditText = (AppCompatEditText) root.findViewById(R.id.altEditText);
    mUrlEditText = (AppCompatEditText) root.findViewById(R.id.urlEditText);
    mAltEditText.setHighlightColor(highlightColor);
    mUrlEditText.setHighlightColor(highlightColor);
    mAltEditText.setSupportBackgroundTintList(colorStateList);
    mUrlEditText.setSupportBackgroundTintList(colorStateList);
    final AlertDialog dialog = builder.create();
    dialog.setOnShowListener(new DialogInterface.OnShowListener() {

        @Override
        public void onShow(DialogInterface dialogInterface) {
            final int buttonColor = getArguments().getInt(BUTTON_COLOR, Color.BLACK);
            dialog.getButton(DialogInterface.BUTTON_POSITIVE).setTextColor(buttonColor);
            dialog.getButton(DialogInterface.BUTTON_NEGATIVE).setTextColor(buttonColor);
        }
    });
    return dialog;
}
Also used : AlertDialog(android.support.v7.app.AlertDialog) DialogInterface(android.content.DialogInterface) ColorStateList(android.content.res.ColorStateList) View(android.view.View) NonNull(android.support.annotation.NonNull)

Aggregations

AlertDialog (android.support.v7.app.AlertDialog)413 DialogInterface (android.content.DialogInterface)275 View (android.view.View)219 TextView (android.widget.TextView)165 Intent (android.content.Intent)117 EditText (android.widget.EditText)87 ImageView (android.widget.ImageView)68 Button (android.widget.Button)67 LayoutInflater (android.view.LayoutInflater)59 RecyclerView (android.support.v7.widget.RecyclerView)54 NonNull (android.support.annotation.NonNull)53 AdapterView (android.widget.AdapterView)51 SuppressLint (android.annotation.SuppressLint)50 ArrayList (java.util.ArrayList)48 Bundle (android.os.Bundle)46 ListView (android.widget.ListView)42 Context (android.content.Context)35 SharedPreferences (android.content.SharedPreferences)35 Uri (android.net.Uri)32 LinearLayout (android.widget.LinearLayout)29