Search in sources :

Example 31 with AlertDialog

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

the class AlbumsFragment method onOptionsItemSelected.

@Override
public boolean onOptionsItemSelected(MenuItem item) {
    Album selectedAlbum = adapter.getFirstSelectedAlbum();
    switch(item.getItemId()) {
        case R.id.select_all:
            if (adapter.getSelectedCount() == adapter.getItemCount())
                adapter.clearSelected();
            else
                adapter.selectAll();
            return true;
        case R.id.pin_album:
            if (selectedAlbum != null) {
                boolean b = selectedAlbum.togglePinAlbum();
                db().setPined(selectedAlbum.getPath(), b);
                adapter.clearSelected();
                adapter.sort();
            }
            return true;
        case R.id.clear_album_cover:
            if (selectedAlbum != null) {
                selectedAlbum.removeCoverAlbum();
                db().setCover(selectedAlbum.getPath(), null);
                adapter.clearSelected();
                adapter.notifyItemChanaged(selectedAlbum);
                // TODO: 4/5/17 updateui
                return true;
            }
            return false;
        case R.id.hide:
            final AlertDialog hideDialog = AlertDialogsHelper.getTextDialog(((ThemedActivity) getActivity()), hidden ? R.string.unhide : R.string.hide, hidden ? R.string.unhide_album_message : R.string.hide_album_message);
            hideDialog.setButton(AlertDialog.BUTTON_POSITIVE, getString(hidden ? R.string.unhide : R.string.hide).toUpperCase(), (dialog, id) -> {
                ArrayList<String> hiddenPaths = AlbumsHelper.getLastHiddenPaths();
                for (Album album : adapter.getSelectedAlbums()) {
                    if (hidden) {
                        // unhide
                        AlbumsHelper.unHideAlbum(album.getPath(), getContext());
                        hiddenPaths.remove(album.getPath());
                    } else {
                        // hide
                        AlbumsHelper.hideAlbum(album.getPath(), getContext());
                        hiddenPaths.add(album.getPath());
                    }
                }
                AlbumsHelper.saveLastHiddenPaths(hiddenPaths);
                adapter.removeSelectedAlbums();
                updateToolbar();
            });
            if (!hidden) {
                hideDialog.setButton(AlertDialog.BUTTON_NEUTRAL, getString(R.string.exclude).toUpperCase(), (dialog, which) -> {
                    for (Album album : adapter.getSelectedAlbums()) {
                        db().excludeAlbum(album.getPath());
                        excuded.add(album.getPath());
                    }
                    adapter.removeSelectedAlbums();
                });
            }
            hideDialog.setButton(DialogInterface.BUTTON_NEGATIVE, this.getString(R.string.cancel).toUpperCase(), (dialogInterface, i) -> hideDialog.dismiss());
            hideDialog.show();
            return true;
        case R.id.shortcut:
            AlbumsHelper.createShortcuts(getContext(), adapter.getSelectedAlbums());
            adapter.clearSelected();
            return true;
        case R.id.name_sort_mode:
            adapter.changeSortingMode(SortingMode.NAME);
            AlbumsHelper.setSortingMode(SortingMode.NAME);
            item.setChecked(true);
            return true;
        case R.id.date_taken_sort_mode:
            adapter.changeSortingMode(SortingMode.DATE);
            AlbumsHelper.setSortingMode(SortingMode.DATE);
            item.setChecked(true);
            return true;
        case R.id.size_sort_mode:
            adapter.changeSortingMode(SortingMode.SIZE);
            AlbumsHelper.setSortingMode(SortingMode.SIZE);
            item.setChecked(true);
            return true;
        case R.id.numeric_sort_mode:
            adapter.changeSortingMode(SortingMode.NUMERIC);
            AlbumsHelper.setSortingMode(SortingMode.NUMERIC);
            item.setChecked(true);
            return true;
        case R.id.ascending_sort_order:
            item.setChecked(!item.isChecked());
            SortingOrder sortingOrder = SortingOrder.fromValue(item.isChecked());
            adapter.changeSortingOrder(sortingOrder);
            AlbumsHelper.setSortingOrder(sortingOrder);
            return true;
        case R.id.exclude:
            final AlertDialog.Builder excludeDialogBuilder = new AlertDialog.Builder(getActivity(), getDialogStyle());
            final View excludeDialogLayout = LayoutInflater.from(getContext()).inflate(R.layout.dialog_exclude, null);
            TextView textViewExcludeTitle = excludeDialogLayout.findViewById(R.id.text_dialog_title);
            TextView textViewExcludeMessage = excludeDialogLayout.findViewById(R.id.text_dialog_message);
            final Spinner spinnerParents = excludeDialogLayout.findViewById(R.id.parents_folder);
            spinnerParents.getBackground().setColorFilter(getIconColor(), PorterDuff.Mode.SRC_ATOP);
            ((CardView) excludeDialogLayout.findViewById(R.id.message_card)).setCardBackgroundColor(getCardBackgroundColor());
            textViewExcludeTitle.setBackgroundColor(getPrimaryColor());
            textViewExcludeTitle.setText(getString(R.string.exclude));
            if (adapter.getSelectedCount() > 1) {
                textViewExcludeMessage.setText(R.string.exclude_albums_message);
                spinnerParents.setVisibility(View.GONE);
            } else {
                textViewExcludeMessage.setText(R.string.exclude_album_message);
                spinnerParents.setAdapter(getThemeHelper().getSpinnerAdapter(adapter.getFirstSelectedAlbum().getParentsFolders()));
            }
            textViewExcludeMessage.setTextColor(getTextColor());
            excludeDialogBuilder.setView(excludeDialogLayout);
            excludeDialogBuilder.setPositiveButton(this.getString(R.string.exclude).toUpperCase(), (dialog, id) -> {
                if (adapter.getSelectedCount() > 1) {
                    for (Album album : adapter.getSelectedAlbums()) {
                        db().excludeAlbum(album.getPath());
                        excuded.add(album.getPath());
                    }
                    adapter.removeSelectedAlbums();
                } else {
                    String path = spinnerParents.getSelectedItem().toString();
                    db().excludeAlbum(path);
                    excuded.add(path);
                    adapter.removeAlbumsThatStartsWith(path);
                    adapter.forceSelectedCount(0);
                }
                updateToolbar();
            });
            excludeDialogBuilder.setNegativeButton(this.getString(R.string.cancel).toUpperCase(), null);
            excludeDialogBuilder.show();
            return true;
        case R.id.delete:
            /* class DeleteAlbums extends AsyncTask<String, Integer, Boolean> {

                    //private AlertDialog dialog;
                    List<Album> selectedAlbums;
                    DeleteAlbumsDialog newFragment;


                    @Override
                    protected void onPreExecute() {
                        super.onPreExecute();
                        newFragment = new DeleteAlbumsDialog();
                        Bundle b = new Bundle();
                        b.putParcelableArrayList("albums", ((ArrayList<Album>) adapter.getSelectedAlbums()));

                        newFragment.setArguments(b);
                        newFragment.show(getFragmentManager(), "dialog");
                        //newFragment.setTitle("asd");

                        //dialog = AlertDialogsHelper.getProgressDialog(((ThemedActivity) getActivity()), getString(R.string.delete), getString(R.string.deleting_images));
                        //dialog.show();


                    }

                    @Override
                    protected Boolean doInBackground(String... arg0) {

                        return true;
                    }

                    @Override
                    protected void onPostExecute(Boolean result) {
                        */
            /*if (result) {
                            if (albumsMode) {
                                albumsAdapter.clearSelected();
                                //albumsAdapter.notifyDataSetChanged();
                            } else {
                                if (getAlbum().getMedia().size() == 0) {
                                    getAlbums().removeCurrentAlbum();
                                    albumsAdapter.notifyDataSetChanged();
                                    displayAlbums();
                                } else
                                    oldMediaAdapter.swapDataSet(getAlbum().getMedia());
                            }
                        } else requestSdCardPermissions();

                        supportInvalidateOptionsMenu();
                        checkNothing();
                        dialog.dismiss();*/
            /*
                    }
                }*/
            final AlertDialog alertDialog = AlertDialogsHelper.getTextDialog(((ThemedActivity) getActivity()), R.string.delete, R.string.delete_album_message);
            alertDialog.setButton(DialogInterface.BUTTON_NEGATIVE, this.getString(R.string.cancel).toUpperCase(), (dialogInterface, i) -> alertDialog.dismiss());
            alertDialog.setButton(DialogInterface.BUTTON_POSITIVE, this.getString(R.string.delete).toUpperCase(), (dialog1, id) -> {
                if (Security.isPasswordOnDelete()) {
                    Security.authenticateUser(((ThemedActivity) getActivity()), new Security.AuthCallBack() {

                        @Override
                        public void onAuthenticated() {
                        /*new DeleteAlbums().execute();*/
                        }

                        @Override
                        public void onError() {
                            Toast.makeText(getContext(), R.string.wrong_password, Toast.LENGTH_SHORT).show();
                        }
                    });
                }
            /* else new DeleteAlbums().execute();*/
            });
            alertDialog.show();
            return true;
    }
    return super.onOptionsItemSelected(item);
}
Also used : AlertDialog(android.support.v7.app.AlertDialog) Spinner(android.widget.Spinner) CardView(android.support.v7.widget.CardView) Album(org.horaapps.leafpic.data.Album) Security(org.horaapps.leafpic.util.Security) BindView(butterknife.BindView) View(android.view.View) CardView(android.support.v7.widget.CardView) RecyclerView(android.support.v7.widget.RecyclerView) TextView(android.widget.TextView) ThemedActivity(org.horaapps.liz.ThemedActivity) SortingOrder(org.horaapps.leafpic.data.sort.SortingOrder) TextView(android.widget.TextView)

Example 32 with AlertDialog

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

the class ColorsSetting method chooseBaseTheme.

public void chooseBaseTheme() {
    final AlertDialog.Builder dialogBuilder = new AlertDialog.Builder(getActivity(), getActivity().getDialogStyle());
    final View dialogLayout = LayoutInflater.from(getActivity()).inflate(R.layout.dialog_base_theme, null);
    final TextView dialogTitle = (TextView) dialogLayout.findViewById(R.id.basic_theme_title);
    final CardView dialogCardView = (CardView) dialogLayout.findViewById(R.id.basic_theme_card);
    /**
     * SET OBJ THEME *
     */
    dialogTitle.setBackgroundColor(getActivity().getPrimaryColor());
    dialogCardView.setCardBackgroundColor(getActivity().getCardBackgroundColor());
    dialogBuilder.setView(dialogLayout);
    dialogBuilder.setView(dialogLayout);
    final AlertDialog dialog = dialogBuilder.show();
    View.OnClickListener listener = new View.OnClickListener() {

        @Override
        public void onClick(View view) {
            switch(view.getId()) {
                case R.id.ll_white_basic_theme:
                    getActivity().setBaseTheme(LIGHT);
                    break;
                case R.id.ll_dark_basic_theme:
                    getActivity().setBaseTheme(DARK);
                    break;
                case R.id.ll_dark_amoled_basic_theme:
                    getActivity().setBaseTheme(AMOLED);
                    break;
            }
            getActivity().updateUiElements();
            dialog.dismiss();
        }
    };
    ((ThemedIcon) dialogLayout.findViewById(R.id.white_basic_theme_icon)).setColor(getActivity().getIconColor());
    ((ThemedIcon) dialogLayout.findViewById(R.id.dark_basic_theme_icon)).setColor(getActivity().getIconColor());
    ((ThemedIcon) dialogLayout.findViewById(R.id.dark_amoled_basic_theme_icon)).setColor(getActivity().getIconColor());
    dialogLayout.findViewById(R.id.ll_white_basic_theme).setOnClickListener(listener);
    dialogLayout.findViewById(R.id.ll_dark_basic_theme).setOnClickListener(listener);
    dialogLayout.findViewById(R.id.ll_dark_amoled_basic_theme).setOnClickListener(listener);
}
Also used : AlertDialog(android.support.v7.app.AlertDialog) ThemedIcon(org.horaapps.liz.ui.ThemedIcon) CardView(android.support.v7.widget.CardView) TextView(android.widget.TextView) CardView(android.support.v7.widget.CardView) TextView(android.widget.TextView) View(android.view.View)

Example 33 with AlertDialog

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

the class ColorsSetting method chooseColor.

public void chooseColor(@StringRes int title, final ColorChooser chooser, int defaultColor) {
    final AlertDialog.Builder dialogBuilder = new AlertDialog.Builder(getActivity(), getActivity().getDialogStyle());
    View dialogLayout = LayoutInflater.from(getActivity()).inflate(R.layout.dialog_color_picker, null);
    final LineColorPicker colorPicker = (LineColorPicker) dialogLayout.findViewById(R.id.color_picker_primary);
    final LineColorPicker colorPicker2 = (LineColorPicker) dialogLayout.findViewById(R.id.color_picker_primary_2);
    final TextView dialogTitle = (TextView) dialogLayout.findViewById(R.id.dialog_title);
    dialogTitle.setText(title);
    ((CardView) dialogLayout.findViewById(R.id.dialog_card)).setCardBackgroundColor(getActivity().getCardBackgroundColor());
    colorPicker2.setOnColorChangedListener(new OnColorChangedListener() {

        @Override
        public void onColorChanged(int c) {
            dialogTitle.setBackgroundColor(c);
            chooser.onColorChanged(c);
        }
    });
    colorPicker.setOnColorChangedListener(new OnColorChangedListener() {

        @Override
        public void onColorChanged(int c) {
            colorPicker2.setColors(ColorPalette.getColors(getActivity(), colorPicker.getColor()));
            colorPicker2.setSelectedColor(colorPicker.getColor());
        }
    });
    int[] baseColors = ColorPalette.getBaseColors(getActivity());
    colorPicker.setColors(baseColors);
    for (int i : baseColors) {
        for (int i2 : ColorPalette.getColors(getActivity(), i)) if (i2 == defaultColor) {
            colorPicker.setSelectedColor(i);
            colorPicker2.setColors(ColorPalette.getColors(getActivity(), i));
            colorPicker2.setSelectedColor(i2);
            break;
        }
    }
    dialogBuilder.setView(dialogLayout);
    dialogBuilder.setNegativeButton(getActivity().getString(R.string.cancel).toUpperCase(), new DialogInterface.OnClickListener() {

        @Override
        public void onClick(DialogInterface dialog, int which) {
            dialog.cancel();
            chooser.onDialogDismiss();
        }
    });
    dialogBuilder.setPositiveButton(getActivity().getString(R.string.ok_action).toUpperCase(), new DialogInterface.OnClickListener() {

        public void onClick(DialogInterface dialog, int which) {
            AlertDialog alertDialog = (AlertDialog) dialog;
            alertDialog.setOnDismissListener(null);
            chooser.onColorSelected(colorPicker2.getColor());
        }
    });
    dialogBuilder.setOnDismissListener(new DialogInterface.OnDismissListener() {

        @Override
        public void onDismiss(DialogInterface dialog) {
            chooser.onDialogDismiss();
        }
    });
    dialogBuilder.show();
}
Also used : AlertDialog(android.support.v7.app.AlertDialog) DialogInterface(android.content.DialogInterface) CardView(android.support.v7.widget.CardView) CardView(android.support.v7.widget.CardView) TextView(android.widget.TextView) View(android.view.View) LineColorPicker(uz.shift.colorpicker.LineColorPicker) OnColorChangedListener(uz.shift.colorpicker.OnColorChangedListener) TextView(android.widget.TextView)

Example 34 with AlertDialog

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

the class AlertDialogsHelper method getProgressDialog.

public static AlertDialog getProgressDialog(final ThemedActivity activity, String title, String message) {
    AlertDialog.Builder progressDialog = new AlertDialog.Builder(activity, activity.getDialogStyle());
    View dialogLayout = activity.getLayoutInflater().inflate(org.horaapps.leafpic.R.layout.dialog_progress, null);
    TextView dialogTitle = dialogLayout.findViewById(R.id.progress_dialog_title);
    TextView dialogMessage = dialogLayout.findViewById(R.id.progress_dialog_text);
    dialogTitle.setBackgroundColor(activity.getPrimaryColor());
    ((CardView) dialogLayout.findViewById(org.horaapps.leafpic.R.id.progress_dialog_card)).setCardBackgroundColor(activity.getCardBackgroundColor());
    ((ProgressBar) dialogLayout.findViewById(org.horaapps.leafpic.R.id.progress_dialog_loading)).getIndeterminateDrawable().setColorFilter(activity.getPrimaryColor(), android.graphics.PorterDuff.Mode.SRC_ATOP);
    dialogTitle.setText(title);
    dialogMessage.setText(message);
    dialogMessage.setTextColor(activity.getTextColor());
    progressDialog.setCancelable(false);
    progressDialog.setView(dialogLayout);
    return progressDialog.create();
}
Also used : AlertDialog(android.support.v7.app.AlertDialog) CardView(android.support.v7.widget.CardView) TextView(android.widget.TextView) 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)

Example 35 with AlertDialog

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

the class AlertDialogsHelper method getDetailsDialog.

public static AlertDialog getDetailsDialog(final ThemedActivity activity, final Media f) {
    AlertDialog.Builder detailsDialogBuilder = new AlertDialog.Builder(activity, activity.getDialogStyle());
    MetadataHelper mdhelper = new MetadataHelper();
    MediaDetailsMap<String, String> mainDetails = mdhelper.getMainDetails(activity, f);
    final View dialogLayout = activity.getLayoutInflater().inflate(org.horaapps.leafpic.R.layout.dialog_media_detail, null);
    ImageView imgMap = dialogLayout.findViewById(R.id.photo_map);
    dialogLayout.findViewById(org.horaapps.leafpic.R.id.details_title).setBackgroundColor(activity.getPrimaryColor());
    ((CardView) dialogLayout.findViewById(org.horaapps.leafpic.R.id.photo_details_card)).setCardBackgroundColor(activity.getCardBackgroundColor());
    final GeoLocation location;
    if ((location = f.getGeoLocation()) != null) {
        StaticMapProvider staticMapProvider = StaticMapProvider.fromValue(Hawk.get(activity.getString(R.string.preference_map_provider), StaticMapProvider.GOOGLE_MAPS.getValue()));
        Glide.with(activity.getApplicationContext()).load(staticMapProvider.getUrl(location)).into(imgMap);
        imgMap.setOnClickListener(new View.OnClickListener() {

            public void onClick(View v) {
                try {
                    activity.startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse(String.format(Locale.ENGLISH, "geo:%f,%f?z=%d", location.getLatitude(), location.getLongitude(), 17))));
                } catch (ActivityNotFoundException e) {
                    Toast.makeText(activity, R.string.no_app_to_perform, Toast.LENGTH_SHORT).show();
                }
            }
        });
        imgMap.setVisibility(View.VISIBLE);
        dialogLayout.findViewById(org.horaapps.leafpic.R.id.details_title).setVisibility(View.GONE);
    } else
        imgMap.setVisibility(View.GONE);
    final TextView showMoreText = dialogLayout.findViewById(R.id.details_showmore);
    showMoreText.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View view) {
            showMoreDetails(dialogLayout, activity, f);
            showMoreText.setVisibility(View.GONE);
        }
    });
    detailsDialogBuilder.setView(dialogLayout);
    loadDetails(dialogLayout, activity, mainDetails);
    return detailsDialogBuilder.create();
}
Also used : AlertDialog(android.support.v7.app.AlertDialog) CardView(android.support.v7.widget.CardView) Intent(android.content.Intent) 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) MetadataHelper(org.horaapps.leafpic.data.metadata.MetadataHelper) ActivityNotFoundException(android.content.ActivityNotFoundException) TextView(android.widget.TextView) ImageView(android.widget.ImageView) GeoLocation(com.drew.lang.GeoLocation)

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