Search in sources :

Example 36 with AlertDialog

use of android.support.v7.app.AlertDialog in project LeafPic by HoraApps.

the class AlertDialogsHelper method showChangelogDialog.

public static AlertDialog showChangelogDialog(final ThemedActivity activity) {
    final AlertDialog.Builder changelogDialogBuilder = new AlertDialog.Builder(activity, activity.getDialogStyle());
    View dialogLayout = activity.getLayoutInflater().inflate(R.layout.dialog_changelog, null);
    TextView dialogTitle = dialogLayout.findViewById(R.id.dialog_changelog_title);
    TextView dialogMessage = dialogLayout.findViewById(R.id.dialog_changelog_text);
    CardView cvBackground = dialogLayout.findViewById(R.id.dialog_changelog_card);
    ScrollView scrChangelog = dialogLayout.findViewById(R.id.changelog_scrollview);
    cvBackground.setCardBackgroundColor(activity.getCardBackgroundColor());
    dialogTitle.setBackgroundColor(activity.getPrimaryColor());
    activity.getThemeHelper().setScrollViewColor(scrChangelog);
    dialogTitle.setText(activity.getString(R.string.changelog));
    Bypass bypass = new Bypass(activity);
    String markdownString;
    try {
        markdownString = getChangeLogFromAssets(activity);
    } catch (IOException e) {
        ChromeCustomTabs.launchUrl(activity, LEAFPIC_CHANGELOG);
        return null;
    }
    CharSequence string = bypass.markdownToSpannable(markdownString);
    dialogMessage.setText(string);
    dialogMessage.setMovementMethod(LinkMovementMethod.getInstance());
    dialogMessage.setTextColor(activity.getTextColor());
    changelogDialogBuilder.setView(dialogLayout);
    changelogDialogBuilder.setPositiveButton(activity.getString(R.string.ok_action).toUpperCase(), null);
    changelogDialogBuilder.setNeutralButton(activity.getString(R.string.show_full).toUpperCase(), new DialogInterface.OnClickListener() {

        @Override
        public void onClick(DialogInterface dialog, int which) {
            ChromeCustomTabs.launchUrl(activity, LEAFPIC_CHANGELOG);
        }
    });
    return changelogDialogBuilder.show();
}
Also used : AlertDialog(android.support.v7.app.AlertDialog) DialogInterface(android.content.DialogInterface) CardView(android.support.v7.widget.CardView) IOException(java.io.IOException) ImageView(android.widget.ImageView) View(android.view.View) CardView(android.support.v7.widget.CardView) RecyclerView(android.support.v7.widget.RecyclerView) TextView(android.widget.TextView) ScrollView(android.widget.ScrollView) ScrollView(android.widget.ScrollView) Bypass(in.uncod.android.bypass.Bypass) TextView(android.widget.TextView)

Example 37 with AlertDialog

use of android.support.v7.app.AlertDialog in project LeafPic by HoraApps.

the class SelectAlbumBuilder method setupDialog.

@Override
public void setupDialog(Dialog dialog, int style) {
    super.setupDialog(dialog, style);
    View contentView = View.inflate(getContext(), R.layout.select_folder_bottom_sheet, null);
    final RecyclerView mRecyclerView = contentView.findViewById(R.id.folders);
    final Spinner spinner = contentView.findViewById(R.id.storage_spinner);
    currentFolderPath = contentView.findViewById(R.id.bottom_sheet_sub_title);
    exploreModePanel = contentView.findViewById(R.id.ll_explore_mode_panel);
    imgExploreMode = contentView.findViewById(R.id.toggle_hidden_icon);
    theme = ThemeHelper.getInstanceLoaded(getContext());
    sdCardPath = StorageHelper.getSdcardPath(getContext());
    mRecyclerView.setLayoutManager(new GridLayoutManager(getContext(), 2));
    mRecyclerView.addItemDecoration(new GridSpacingItemDecoration(2, Measure.pxToDp(3, getContext()), true));
    adapter = new BottomSheetAlbumsAdapter();
    mRecyclerView.setAdapter(adapter);
    spinner.setAdapter(new VolumeSpinnerAdapter(contentView.getContext()));
    spinner.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {

        @Override
        public void onItemSelected(AdapterView<?> adapterView, View view, int pos, long l) {
            switch(pos) {
                case INTERNAL_STORAGE:
                    displayContentFolder(Environment.getExternalStorageDirectory());
                    break;
                default:
                    // }
                    break;
            }
        }

        @Override
        public void onNothingSelected(AdapterView<?> adapterView) {
        }
    });
    /**
     *SET UP THEME*
     */
    contentView.findViewById(R.id.rl_bottom_sheet_title).setBackgroundColor(theme.getPrimaryColor());
    exploreModePanel.setBackgroundColor(theme.getPrimaryColor());
    contentView.findViewById(R.id.ll_select_folder).setBackgroundColor(theme.getCardBackgroundColor());
    theme.setColorScrollBarDrawable(ContextCompat.getDrawable(dialog.getContext(), R.drawable.ic_scrollbar));
    mRecyclerView.setBackgroundColor(theme.getBackgroundColor());
    fabDone = contentView.findViewById(R.id.fab_bottomsheet_done);
    fabDone.setBackgroundTintList(ColorStateList.valueOf(theme.getAccentColor()));
    fabDone.setImageDrawable(new IconicsDrawable(getContext()).icon(GoogleMaterial.Icon.gmd_done).color(Color.WHITE));
    fabDone.setVisibility(exploreMode ? View.VISIBLE : View.GONE);
    fabDone.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            dismiss();
            onFolderSelected.folderSelected(currentFolderPath.getText().toString());
        }
    });
    ((TextView) contentView.findViewById(R.id.bottom_sheet_title)).setText(title);
    ((ThemedIcon) contentView.findViewById(R.id.create_new_folder_icon)).setColor(theme.getIconColor());
    contentView.findViewById(R.id.rl_create_new_folder).setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View view) {
            final EditText editText = new EditText(getContext());
            AlertDialog insertTextDialog = AlertDialogsHelper.getInsertTextDialog(((ThemedActivity) getActivity()), editText, R.string.new_folder);
            insertTextDialog.setButton(DialogInterface.BUTTON_POSITIVE, getString(R.string.ok_action).toUpperCase(), new DialogInterface.OnClickListener() {

                @Override
                public void onClick(DialogInterface dialogInterface, int i) {
                    File folderPath = new File(currentFolderPath.getText().toString() + File.separator + editText.getText().toString());
                    if (folderPath.mkdir())
                        displayContentFolder(folderPath);
                }
            });
            insertTextDialog.setButton(DialogInterface.BUTTON_NEGATIVE, getString(R.string.cancel).toUpperCase(), new DialogInterface.OnClickListener() {

                @Override
                public void onClick(DialogInterface dialogInterface, int i) {
                }
            });
            insertTextDialog.show();
        }
    });
    contentView.findViewById(R.id.rl_bottom_sheet_title).setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            if (!forzed) {
                toggleExplorerMode(!exploreMode);
                fabDone.setVisibility(exploreMode ? View.VISIBLE : View.GONE);
            }
        }
    });
    dialog.setContentView(contentView);
    CoordinatorLayout.LayoutParams layoutParams = (CoordinatorLayout.LayoutParams) ((View) contentView.getParent()).getLayoutParams();
    CoordinatorLayout.Behavior behavior = layoutParams.getBehavior();
    if (behavior != null && behavior instanceof BottomSheetBehavior) {
        ((BottomSheetBehavior) behavior).setBottomSheetCallback(mBottomSheetBehaviorCallback);
    }
    adapter.notifyDataSetChanged();
    toggleExplorerMode(exploreMode);
}
Also used : AlertDialog(android.support.v7.app.AlertDialog) DialogInterface(android.content.DialogInterface) Spinner(android.widget.Spinner) BottomSheetBehavior(android.support.design.widget.BottomSheetBehavior) TextView(android.widget.TextView) IconicsDrawable(com.mikepenz.iconics.IconicsDrawable) EditText(android.widget.EditText) ImageView(android.widget.ImageView) View(android.view.View) AdapterView(android.widget.AdapterView) RecyclerView(android.support.v7.widget.RecyclerView) TextView(android.widget.TextView) CoordinatorLayout(android.support.design.widget.CoordinatorLayout) GridLayoutManager(android.support.v7.widget.GridLayoutManager) ThemedIcon(org.horaapps.liz.ui.ThemedIcon) RecyclerView(android.support.v7.widget.RecyclerView) AdapterView(android.widget.AdapterView) File(java.io.File) GridSpacingItemDecoration(org.horaapps.leafpic.views.GridSpacingItemDecoration)

Example 38 with AlertDialog

use of android.support.v7.app.AlertDialog in project LeafPic by HoraApps.

the class SharedMediaActivity method requestSdCardPermissions.

public void requestSdCardPermissions() {
    AlertDialog textDialog = AlertDialogsHelper.getTextDialog(this, R.string.sd_card_write_permission_title, R.string.sd_card_permissions_message);
    textDialog.setButton(DialogInterface.BUTTON_POSITIVE, getString(R.string.ok_action).toUpperCase(), new DialogInterface.OnClickListener() {

        @Override
        public void onClick(DialogInterface dialogInterface, int i) {
            if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.LOLLIPOP)
                startActivityForResult(new Intent(Intent.ACTION_OPEN_DOCUMENT_TREE), REQUEST_CODE_SD_CARD_PERMISSIONS);
        }
    });
    textDialog.show();
}
Also used : AlertDialog(android.support.v7.app.AlertDialog) DialogInterface(android.content.DialogInterface) Intent(android.content.Intent)

Example 39 with AlertDialog

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

the class AuthenticationDialog method onCreateDialog.

@NonNull
@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
    AlertDialog.Builder builder = new AlertDialog.Builder(getContext());
    builder.setTitle(R.string.authenticationRequired);
    View root = LayoutInflater.from(getContext()).inflate(R.layout.dialog_auth, null);
    mUsername = (EditText) root.findViewById(R.id.username);
    mPassword = (EditText) root.findViewById(R.id.password);
    builder.setView(root);
    builder.setPositiveButton(R.string.done, new DialogInterface.OnClickListener() {

        @Override
        public void onClick(DialogInterface dialog, int which) {
            if (mCallback != null) {
                mCallback.onRetrieveCredentials(mUsername.getText().toString(), mPassword.getText().toString());
            }
            dialog.dismiss();
        }
    });
    builder.setNegativeButton(R.string.cancel, new DialogInterface.OnClickListener() {

        @Override
        public void onClick(DialogInterface dialog, int which) {
            dialog.dismiss();
        }
    });
    AlertDialog dialog = builder.create();
    dialog.setCancelable(false);
    dialog.setCanceledOnTouchOutside(false);
    return dialog;
}
Also used : AlertDialog(android.support.v7.app.AlertDialog) DialogInterface(android.content.DialogInterface) View(android.view.View) NonNull(android.support.annotation.NonNull)

Example 40 with AlertDialog

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

the class AskInstructorDialogStyled method onCreateDialog.

@NonNull
@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
    AlertDialog.Builder builder = new AlertDialog.Builder(getActivity()).setTitle(getActivity().getString(R.string.instructor_question)).setPositiveButton(getActivity().getString(R.string.send), new DialogInterface.OnClickListener() {

        @Override
        public void onClick(DialogInterface dialog, int which) {
            if (canClickSend) {
                if (message == null || message.getText().toString().trim().equals("")) {
                    Toast.makeText(getActivity(), getString(R.string.emptyMessage), Toast.LENGTH_SHORT).show();
                } else {
                    progressDialog = ProgressDialog.show(getActivity(), "", getActivity().getString(R.string.sending));
                    loadTeacherData();
                }
            }
        }
    });
    // Suppress lint warning about null parent when inflating layout
    @SuppressLint("InflateParams") final View view = LayoutInflater.from(getActivity()).inflate(R.layout.ask_instructor, null);
    courseSpinner = view.findViewById(R.id.courseSpinner);
    ArrayList<Course> loadingIndicator = new ArrayList<Course>();
    Course loading = new Course();
    loading.setName(getActivity().getString(R.string.loading));
    loadingIndicator.add(loading);
    courseAdapter = new CourseSpinnerAdapter(getActivity(), android.R.layout.simple_spinner_dropdown_item, loadingIndicator);
    // we haven't set an onItemSelectedListener, so selecting the item shouldn't do anything
    courseSpinner.setAdapter(courseAdapter);
    message = view.findViewById(R.id.message);
    builder.setView(view);
    final AlertDialog dialog = builder.create();
    dialog.setOnShowListener(new DialogInterface.OnShowListener() {

        @Override
        public void onShow(DialogInterface worthless) {
            dialog.getButton(AlertDialog.BUTTON_POSITIVE).setTextColor(ThemePrefs.getBrandColor());
            ViewStyler.themeEditText(getContext(), (AppCompatEditText) message, ThemePrefs.getBrandColor());
        }
    });
    dialog.setCanceledOnTouchOutside(true);
    return dialog;
}
Also used : AlertDialog(android.support.v7.app.AlertDialog) DialogInterface(android.content.DialogInterface) ArrayList(java.util.ArrayList) View(android.view.View) AdapterView(android.widget.AdapterView) TextView(android.widget.TextView) SuppressLint(android.annotation.SuppressLint) AppCompatEditText(android.support.v7.widget.AppCompatEditText) SuppressLint(android.annotation.SuppressLint) Course(com.instructure.canvasapi2.models.Course) 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