Search in sources :

Example 31 with CardView

use of android.support.v7.widget.CardView in project ViewPagerCards by rubensousa.

the class CardFragment method onCreateView.

@Nullable
@Override
public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
    View view = inflater.inflate(R.layout.fragment_adapter, container, false);
    mCardView = (CardView) view.findViewById(R.id.cardView);
    mCardView.setMaxCardElevation(mCardView.getCardElevation() * CardAdapter.MAX_ELEVATION_FACTOR);
    return view;
}
Also used : CardView(android.support.v7.widget.CardView) View(android.view.View) Nullable(android.support.annotation.Nullable)

Example 32 with CardView

use of android.support.v7.widget.CardView in project ViewPagerCards by rubensousa.

the class CardPagerAdapter method instantiateItem.

@Override
public Object instantiateItem(ViewGroup container, int position) {
    View view = LayoutInflater.from(container.getContext()).inflate(R.layout.adapter, container, false);
    container.addView(view);
    bind(mData.get(position), view);
    CardView cardView = (CardView) view.findViewById(R.id.cardView);
    if (mBaseElevation == 0) {
        mBaseElevation = cardView.getCardElevation();
    }
    cardView.setMaxCardElevation(mBaseElevation * MAX_ELEVATION_FACTOR);
    mViews.set(position, cardView);
    return view;
}
Also used : CardView(android.support.v7.widget.CardView) TextView(android.widget.TextView) CardView(android.support.v7.widget.CardView) View(android.view.View)

Example 33 with CardView

use of android.support.v7.widget.CardView in project LeafPic by HoraApps.

the class MainActivity method onOptionsItemSelected.

//endregion
@Override
public boolean onOptionsItemSelected(MenuItem item) {
    switch(item.getItemId()) {
        case R.id.select_all:
            if (albumsMode) {
                if (getAlbums().getSelectedCount() == albumsAdapter.getItemCount()) {
                    editMode = false;
                    getAlbums().clearSelectedAlbums();
                } else
                    getAlbums().selectAllAlbums();
                albumsAdapter.notifyDataSetChanged();
            } else {
                if (getAlbum().getSelectedCount() == mediaAdapter.getItemCount()) {
                    editMode = false;
                    getAlbum().clearSelectedPhotos();
                } else
                    getAlbum().selectAllPhotos();
                mediaAdapter.notifyDataSetChanged();
            }
            invalidateOptionsMenu();
            return true;
        case R.id.set_pin_album:
            getAlbums().getSelectedAlbum(0).settings.togglePin(getApplicationContext());
            getAlbums().sortAlbums(getApplicationContext());
            getAlbums().clearSelectedAlbums();
            albumsAdapter.swapDataSet(getAlbums().dispAlbums);
            invalidateOptionsMenu();
            return true;
        case R.id.settings:
            startActivity(new Intent(MainActivity.this, SettingsActivity.class));
            return true;
        case R.id.installShortcut:
            getAlbums().installShortcutForSelectedAlbums(this.getApplicationContext());
            finishEditMode();
            return true;
        case R.id.hideAlbumButton:
            final AlertDialog.Builder hideDialogBuilder = new AlertDialog.Builder(MainActivity.this, getDialogStyle());
            AlertDialogsHelper.getTextDialog(MainActivity.this, hideDialogBuilder, hidden ? R.string.unhide : R.string.hide, hidden ? R.string.unhide_album_message : R.string.hide_album_message);
            hideDialogBuilder.setPositiveButton(getString(hidden ? R.string.unhide : R.string.hide).toUpperCase(), new DialogInterface.OnClickListener() {

                public void onClick(DialogInterface dialog, int id) {
                    if (albumsMode) {
                        if (hidden)
                            getAlbums().unHideSelectedAlbums(getApplicationContext());
                        else
                            getAlbums().hideSelectedAlbums(getApplicationContext());
                        albumsAdapter.notifyDataSetChanged();
                        invalidateOptionsMenu();
                    } else {
                        if (hidden)
                            getAlbums().unHideAlbum(getAlbum().getPath(), getApplicationContext());
                        else
                            getAlbums().hideAlbum(getAlbum().getPath(), getApplicationContext());
                        displayAlbums(true);
                    }
                }
            });
            if (!hidden) {
                hideDialogBuilder.setNeutralButton(this.getString(R.string.exclude).toUpperCase(), new DialogInterface.OnClickListener() {

                    @Override
                    public void onClick(DialogInterface dialog, int which) {
                        if (albumsMode) {
                            getAlbums().excludeSelectedAlbums(getApplicationContext());
                            albumsAdapter.notifyDataSetChanged();
                            invalidateOptionsMenu();
                        } else {
                            customAlbumsHelper.excludeAlbum(getAlbum().getPath());
                            displayAlbums(true);
                        }
                    }
                });
            }
            hideDialogBuilder.setNegativeButton(this.getString(R.string.cancel).toUpperCase(), null);
            hideDialogBuilder.show();
            return true;
        case R.id.delete_action:
            class DeletePhotos extends AsyncTask<String, Integer, Boolean> {

                @Override
                protected void onPreExecute() {
                    swipeRefreshLayout.setRefreshing(true);
                    super.onPreExecute();
                }

                @Override
                protected Boolean doInBackground(String... arg0) {
                    if (albumsMode)
                        return getAlbums().deleteSelectedAlbums(MainActivity.this);
                    else {
                        if (editMode)
                            return getAlbum().deleteSelectedMedia(getApplicationContext());
                        else {
                            boolean succ = getAlbums().deleteAlbum(getAlbum(), getApplicationContext());
                            getAlbum().getMedia().clear();
                            return succ;
                        }
                    }
                }

                @Override
                protected void onPostExecute(Boolean result) {
                    if (result) {
                        if (albumsMode) {
                            getAlbums().clearSelectedAlbums();
                            albumsAdapter.notifyDataSetChanged();
                        } else {
                            if (getAlbum().getMedia().size() == 0) {
                                getAlbums().removeCurrentAlbum();
                                albumsAdapter.notifyDataSetChanged();
                                displayAlbums();
                            } else
                                mediaAdapter.swapDataSet(getAlbum().getMedia());
                        }
                    } else
                        requestSdCardPermissions();
                    invalidateOptionsMenu();
                    checkNothing();
                    swipeRefreshLayout.setRefreshing(false);
                }
            }
            AlertDialog.Builder deleteDialog = new AlertDialog.Builder(MainActivity.this, getDialogStyle());
            AlertDialogsHelper.getTextDialog(this, deleteDialog, R.string.delete, albumsMode || !editMode ? R.string.delete_album_message : R.string.delete_photos_message);
            deleteDialog.setNegativeButton(this.getString(R.string.cancel).toUpperCase(), null);
            deleteDialog.setPositiveButton(this.getString(R.string.delete).toUpperCase(), new DialogInterface.OnClickListener() {

                public void onClick(DialogInterface dialog, int id) {
                    if (securityObj.isActiveSecurity() && securityObj.isPasswordOnDelete()) {
                        AlertDialog.Builder passwordDialogBuilder = new AlertDialog.Builder(MainActivity.this, getDialogStyle());
                        final EditText editTextPassword = securityObj.getInsertPasswordDialog(MainActivity.this, passwordDialogBuilder);
                        passwordDialogBuilder.setNegativeButton(getString(R.string.cancel).toUpperCase(), null);
                        passwordDialogBuilder.setPositiveButton(getString(R.string.ok_action).toUpperCase(), new DialogInterface.OnClickListener() {

                            @Override
                            public void onClick(DialogInterface dialog, int which) {
                            //This should br empty it will be overwrite later
                            //to avoid dismiss of the dialog on wrong password
                            }
                        });
                        final AlertDialog passwordDialog = passwordDialogBuilder.create();
                        passwordDialog.show();
                        passwordDialog.getButton(AlertDialog.BUTTON_POSITIVE).setOnClickListener(new View.OnClickListener() {

                            @Override
                            public void onClick(View v) {
                                if (securityObj.checkPassword(editTextPassword.getText().toString())) {
                                    passwordDialog.dismiss();
                                    new DeletePhotos().execute();
                                } else {
                                    Toast.makeText(getApplicationContext(), R.string.wrong_password, Toast.LENGTH_SHORT).show();
                                    editTextPassword.getText().clear();
                                    editTextPassword.requestFocus();
                                }
                            }
                        });
                    } else
                        new DeletePhotos().execute();
                }
            });
            deleteDialog.show();
            return true;
        case R.id.excludeAlbumButton:
            final AlertDialog.Builder excludeDialogBuilder = new AlertDialog.Builder(MainActivity.this, getDialogStyle());
            final View excludeDialogLayout = getLayoutInflater().inflate(R.layout.dialog_exclude, null);
            TextView textViewExcludeTitle = (TextView) excludeDialogLayout.findViewById(R.id.text_dialog_title);
            TextView textViewExcludeMessage = (TextView) excludeDialogLayout.findViewById(R.id.text_dialog_message);
            final Spinner spinnerParents = (Spinner) 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 ((albumsMode && getAlbums().getSelectedCount() > 1)) {
                textViewExcludeMessage.setText(R.string.exclude_albums_message);
                spinnerParents.setVisibility(View.GONE);
            } else {
                textViewExcludeMessage.setText(R.string.exclude_album_message);
                spinnerParents.setAdapter(getSpinnerAdapter(albumsMode ? getAlbums().getSelectedAlbum(0).getParentsFolders() : getAlbum().getParentsFolders()));
            }
            textViewExcludeMessage.setTextColor(getTextColor());
            excludeDialogBuilder.setView(excludeDialogLayout);
            excludeDialogBuilder.setPositiveButton(this.getString(R.string.exclude).toUpperCase(), new DialogInterface.OnClickListener() {

                public void onClick(DialogInterface dialog, int id) {
                    if ((albumsMode && getAlbums().getSelectedCount() > 1)) {
                        getAlbums().excludeSelectedAlbums(getApplicationContext());
                        albumsAdapter.notifyDataSetChanged();
                        invalidateOptionsMenu();
                    } else {
                        customAlbumsHelper.excludeAlbum(spinnerParents.getSelectedItem().toString());
                        finishEditMode();
                        displayAlbums(true);
                    }
                }
            });
            excludeDialogBuilder.setNegativeButton(this.getString(R.string.cancel).toUpperCase(), null);
            excludeDialogBuilder.show();
            return true;
        case R.id.sharePhotos:
            Intent intent = new Intent();
            intent.setAction(Intent.ACTION_SEND_MULTIPLE);
            intent.putExtra(Intent.EXTRA_SUBJECT, getString(R.string.sent_to_action));
            ArrayList<Uri> files = new ArrayList<Uri>();
            for (Media f : getAlbum().getSelectedMedia()) files.add(f.getUri());
            intent.putParcelableArrayListExtra(Intent.EXTRA_STREAM, files);
            intent.setType(StringUtils.getGenericMIME(getAlbum().getSelectedMedia(0).getMimeType()));
            finishEditMode();
            startActivity(Intent.createChooser(intent, getResources().getText(R.string.send_to)));
            return true;
        case R.id.all_media_filter:
            if (!albumsMode) {
                getAlbum().filterMedias(getApplicationContext(), FilterMode.ALL);
                mediaAdapter.swapDataSet(getAlbum().getMedia());
                item.setChecked(true);
                checkNothing();
            }
            return true;
        case R.id.video_media_filter:
            if (!albumsMode) {
                getAlbum().filterMedias(getApplicationContext(), FilterMode.VIDEO);
                mediaAdapter.swapDataSet(getAlbum().getMedia());
                item.setChecked(true);
                checkNothing();
            }
            return true;
        case R.id.image_media_filter:
            if (!albumsMode) {
                getAlbum().filterMedias(getApplicationContext(), FilterMode.IMAGES);
                mediaAdapter.swapDataSet(getAlbum().getMedia());
                item.setChecked(true);
                checkNothing();
            }
            return true;
        case R.id.gifs_media_filter:
            if (!albumsMode) {
                getAlbum().filterMedias(getApplicationContext(), FilterMode.GIF);
                mediaAdapter.swapDataSet(getAlbum().getMedia());
                item.setChecked(true);
                checkNothing();
            }
            return true;
        case R.id.name_sort_action:
            if (albumsMode) {
                getAlbums().setDefaultSortingMode(SortingMode.NAME);
                getAlbums().sortAlbums(getApplicationContext());
                albumsAdapter.swapDataSet(getAlbums().dispAlbums);
            } else {
                getAlbum().setDefaultSortingMode(getApplicationContext(), SortingMode.NAME);
                getAlbum().sortPhotos();
                mediaAdapter.swapDataSet(getAlbum().getMedia());
            }
            item.setChecked(true);
            return true;
        case R.id.date_taken_sort_action:
            if (albumsMode) {
                getAlbums().setDefaultSortingMode(SortingMode.DATE);
                getAlbums().sortAlbums(getApplicationContext());
                albumsAdapter.swapDataSet(getAlbums().dispAlbums);
            } else {
                getAlbum().setDefaultSortingMode(getApplicationContext(), SortingMode.DATE);
                getAlbum().sortPhotos();
                mediaAdapter.swapDataSet(getAlbum().getMedia());
            }
            item.setChecked(true);
            return true;
        case R.id.size_sort_action:
            if (albumsMode) {
                getAlbums().setDefaultSortingMode(SortingMode.SIZE);
                getAlbums().sortAlbums(getApplicationContext());
                albumsAdapter.swapDataSet(getAlbums().dispAlbums);
            } else {
                getAlbum().setDefaultSortingMode(getApplicationContext(), SortingMode.SIZE);
                getAlbum().sortPhotos();
                mediaAdapter.swapDataSet(getAlbum().getMedia());
            }
            item.setChecked(true);
            return true;
        case R.id.type_sort_action:
            if (!albumsMode) {
                getAlbum().setDefaultSortingMode(getApplicationContext(), SortingMode.TYPE);
                getAlbum().sortPhotos();
                mediaAdapter.swapDataSet(getAlbum().getMedia());
                item.setChecked(true);
            }
            return true;
        case R.id.numeric_sort_action:
            if (albumsMode) {
                getAlbums().setDefaultSortingMode(SortingMode.NUMERIC);
                getAlbums().sortAlbums(getApplicationContext());
                albumsAdapter.swapDataSet(getAlbums().dispAlbums);
            } else {
                getAlbum().setDefaultSortingMode(getApplicationContext(), SortingMode.NUMERIC);
                getAlbum().sortPhotos();
                mediaAdapter.swapDataSet(getAlbum().getMedia());
            }
            item.setChecked(true);
            return true;
        case R.id.ascending_sort_action:
            if (albumsMode) {
                getAlbums().setDefaultSortingAscending(item.isChecked() ? SortingOrder.DESCENDING : SortingOrder.ASCENDING);
                getAlbums().sortAlbums(getApplicationContext());
                albumsAdapter.swapDataSet(getAlbums().dispAlbums);
            } else {
                getAlbum().setDefaultSortingAscending(getApplicationContext(), item.isChecked() ? SortingOrder.DESCENDING : SortingOrder.ASCENDING);
                getAlbum().sortPhotos();
                mediaAdapter.swapDataSet(getAlbum().getMedia());
            }
            item.setChecked(!item.isChecked());
            return true;
        //region Affix
        case R.id.affixPhoto:
            //region Async MediaAffix
            class affixMedia extends AsyncTask<Affix.Options, Integer, Void> {

                private AlertDialog dialog;

                @Override
                protected void onPreExecute() {
                    AlertDialog.Builder progressDialog = new AlertDialog.Builder(MainActivity.this, getDialogStyle());
                    dialog = AlertDialogsHelper.getProgressDialog(MainActivity.this, progressDialog, getString(R.string.affix), getString(R.string.affix_text));
                    dialog.show();
                    super.onPreExecute();
                }

                @Override
                protected Void doInBackground(Affix.Options... arg0) {
                    ArrayList<Bitmap> bitmapArray = new ArrayList<Bitmap>();
                    for (int i = 0; i < getAlbum().getSelectedCount(); i++) {
                        if (!getAlbum().getSelectedMedia(i).isVideo())
                            bitmapArray.add(getAlbum().getSelectedMedia(i).getBitmap());
                    }
                    if (bitmapArray.size() > 1)
                        Affix.AffixBitmapList(getApplicationContext(), bitmapArray, arg0[0]);
                    else
                        runOnUiThread(new Runnable() {

                            @Override
                            public void run() {
                                Toast.makeText(getApplicationContext(), R.string.affix_error, Toast.LENGTH_SHORT).show();
                            }
                        });
                    return null;
                }

                @Override
                protected void onPostExecute(Void result) {
                    editMode = false;
                    getAlbum().clearSelectedPhotos();
                    dialog.dismiss();
                    invalidateOptionsMenu();
                    mediaAdapter.notifyDataSetChanged();
                    new PreparePhotosTask().execute();
                }
            }
            //endregion
            final AlertDialog.Builder builder = new AlertDialog.Builder(MainActivity.this, getDialogStyle());
            final View dialogLayout = getLayoutInflater().inflate(R.layout.dialog_affix, null);
            dialogLayout.findViewById(R.id.affix_title).setBackgroundColor(getPrimaryColor());
            ((CardView) dialogLayout.findViewById(R.id.affix_card)).setCardBackgroundColor(getCardBackgroundColor());
            //ITEMS
            final SwitchCompat swVertical = (SwitchCompat) dialogLayout.findViewById(R.id.affix_vertical_switch);
            final SwitchCompat swSaveHere = (SwitchCompat) dialogLayout.findViewById(R.id.save_here_switch);
            final RadioGroup radioFormatGroup = (RadioGroup) dialogLayout.findViewById(R.id.radio_format);
            final TextView txtQuality = (TextView) dialogLayout.findViewById(R.id.affix_quality_title);
            final SeekBar seekQuality = (SeekBar) dialogLayout.findViewById(R.id.seek_bar_quality);
            //region THEME STUFF
            setScrollViewColor((ScrollView) dialogLayout.findViewById(R.id.affix_scrollView));
            /** TextViews **/
            int color = getTextColor();
            ((TextView) dialogLayout.findViewById(R.id.affix_vertical_title)).setTextColor(color);
            ((TextView) dialogLayout.findViewById(R.id.compression_settings_title)).setTextColor(color);
            ((TextView) dialogLayout.findViewById(R.id.save_here_title)).setTextColor(color);
            /** Sub TextViews **/
            color = getTextColor();
            ((TextView) dialogLayout.findViewById(R.id.save_here_sub)).setTextColor(color);
            ((TextView) dialogLayout.findViewById(R.id.affix_vertical_sub)).setTextColor(color);
            ((TextView) dialogLayout.findViewById(R.id.affix_format_sub)).setTextColor(color);
            txtQuality.setTextColor(color);
            /** Icons **/
            color = getIconColor();
            ((IconicsImageView) dialogLayout.findViewById(R.id.affix_quality_icon)).setColor(color);
            ((IconicsImageView) dialogLayout.findViewById(R.id.affix_format_icon)).setColor(color);
            ((IconicsImageView) dialogLayout.findViewById(R.id.affix_vertical_icon)).setColor(color);
            ((IconicsImageView) dialogLayout.findViewById(R.id.save_here_icon)).setColor(color);
            seekQuality.getProgressDrawable().setColorFilter(new PorterDuffColorFilter(getAccentColor(), PorterDuff.Mode.SRC_IN));
            seekQuality.getThumb().setColorFilter(new PorterDuffColorFilter(getAccentColor(), PorterDuff.Mode.SRC_IN));
            updateRadioButtonColor((RadioButton) dialogLayout.findViewById(R.id.radio_jpeg));
            updateRadioButtonColor((RadioButton) dialogLayout.findViewById(R.id.radio_png));
            updateRadioButtonColor((RadioButton) dialogLayout.findViewById(R.id.radio_webp));
            updateSwitchColor(swVertical, getAccentColor());
            updateSwitchColor(swSaveHere, getAccentColor());
            //endregion
            seekQuality.setOnSeekBarChangeListener(new SeekBar.OnSeekBarChangeListener() {

                @Override
                public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) {
                    txtQuality.setText(Html.fromHtml(String.format(Locale.getDefault(), "%s <b>%d</b>", getString(R.string.quality), progress)));
                }

                @Override
                public void onStartTrackingTouch(SeekBar seekBar) {
                }

                @Override
                public void onStopTrackingTouch(SeekBar seekBar) {
                }
            });
            //DEFAULT
            seekQuality.setProgress(90);
            swVertical.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {

                @Override
                public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
                    updateSwitchColor(swVertical, getAccentColor());
                }
            });
            swSaveHere.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {

                @Override
                public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
                    updateSwitchColor(swSaveHere, getAccentColor());
                }
            });
            builder.setView(dialogLayout);
            builder.setPositiveButton(this.getString(R.string.ok_action).toUpperCase(), new DialogInterface.OnClickListener() {

                public void onClick(DialogInterface dialog, int id) {
                    Bitmap.CompressFormat compressFormat;
                    switch(radioFormatGroup.getCheckedRadioButtonId()) {
                        case R.id.radio_jpeg:
                        default:
                            compressFormat = Bitmap.CompressFormat.JPEG;
                            break;
                        case R.id.radio_png:
                            compressFormat = Bitmap.CompressFormat.PNG;
                            break;
                        case R.id.radio_webp:
                            compressFormat = Bitmap.CompressFormat.WEBP;
                            break;
                    }
                    Affix.Options options = new Affix.Options(swSaveHere.isChecked() ? getAlbum().getPath() : Affix.getDefaultDirectoryPath(), compressFormat, seekQuality.getProgress(), swVertical.isChecked());
                    new affixMedia().execute(options);
                }
            });
            builder.setNegativeButton(this.getString(R.string.cancel).toUpperCase(), null);
            builder.show();
            return true;
        case R.id.action_move:
            bottomSheetDialogFragment = new SelectAlbumBottomSheet();
            bottomSheetDialogFragment.setTitle(getString(R.string.move_to));
            bottomSheetDialogFragment.setSelectAlbumInterface(new SelectAlbumBottomSheet.SelectAlbumInterface() {

                @Override
                public void folderSelected(String path) {
                    swipeRefreshLayout.setRefreshing(true);
                    if (getAlbum().moveSelectedMedia(getApplicationContext(), path) > 0) {
                        if (getAlbum().getMedia().size() == 0) {
                            getAlbums().removeCurrentAlbum();
                            albumsAdapter.notifyDataSetChanged();
                            displayAlbums();
                        }
                        mediaAdapter.swapDataSet(getAlbum().getMedia());
                        finishEditMode();
                        invalidateOptionsMenu();
                    } else
                        requestSdCardPermissions();
                    swipeRefreshLayout.setRefreshing(false);
                    bottomSheetDialogFragment.dismiss();
                }
            });
            bottomSheetDialogFragment.show(getSupportFragmentManager(), bottomSheetDialogFragment.getTag());
            return true;
        case R.id.action_copy:
            bottomSheetDialogFragment = new SelectAlbumBottomSheet();
            bottomSheetDialogFragment.setTitle(getString(R.string.copy_to));
            bottomSheetDialogFragment.setSelectAlbumInterface(new SelectAlbumBottomSheet.SelectAlbumInterface() {

                @Override
                public void folderSelected(String path) {
                    boolean success = getAlbum().copySelectedPhotos(getApplicationContext(), path);
                    finishEditMode();
                    bottomSheetDialogFragment.dismiss();
                    if (!success)
                        requestSdCardPermissions();
                }
            });
            bottomSheetDialogFragment.show(getSupportFragmentManager(), bottomSheetDialogFragment.getTag());
            return true;
        case R.id.renameAlbum:
            AlertDialog.Builder renameDialogBuilder = new AlertDialog.Builder(MainActivity.this, getDialogStyle());
            final EditText editTextNewName = new EditText(getApplicationContext());
            editTextNewName.setText(albumsMode ? getAlbums().getSelectedAlbum(0).getName() : getAlbum().getName());
            AlertDialogsHelper.getInsertTextDialog(MainActivity.this, renameDialogBuilder, editTextNewName, R.string.rename_album);
            renameDialogBuilder.setNegativeButton(getString(R.string.cancel).toUpperCase(), null);
            renameDialogBuilder.setPositiveButton(getString(R.string.ok_action).toUpperCase(), new DialogInterface.OnClickListener() {

                @Override
                public void onClick(DialogInterface dialog, int which) {
                //This should br empty it will be overwrite later
                //to avoid dismiss of the dialog
                }
            });
            final AlertDialog renameDialog = renameDialogBuilder.create();
            renameDialog.show();
            renameDialog.getButton(DialogInterface.BUTTON_POSITIVE).setOnClickListener(new View.OnClickListener() {

                @Override
                public void onClick(View dialog) {
                    if (editTextNewName.length() != 0) {
                        swipeRefreshLayout.setRefreshing(true);
                        boolean success;
                        if (albumsMode) {
                            int index = getAlbums().dispAlbums.indexOf(getAlbums().getSelectedAlbum(0));
                            getAlbums().getAlbum(index).updatePhotos(getApplicationContext());
                            success = getAlbums().getAlbum(index).renameAlbum(getApplicationContext(), editTextNewName.getText().toString());
                            albumsAdapter.notifyItemChanged(index);
                        } else {
                            success = getAlbum().renameAlbum(getApplicationContext(), editTextNewName.getText().toString());
                            toolbar.setTitle(getAlbum().getName());
                            mediaAdapter.notifyDataSetChanged();
                        }
                        renameDialog.dismiss();
                        if (!success)
                            requestSdCardPermissions();
                        swipeRefreshLayout.setRefreshing(false);
                    } else {
                        StringUtils.showToast(getApplicationContext(), getString(R.string.insert_something));
                        editTextNewName.requestFocus();
                    }
                }
            });
            return true;
        case R.id.clear_album_preview:
            if (!albumsMode) {
                getAlbum().removeCoverAlbum(getApplicationContext());
            }
            return true;
        case R.id.setAsAlbumPreview:
            if (!albumsMode) {
                getAlbum().setSelectedPhotoAsPreview(getApplicationContext());
                finishEditMode();
            }
            return true;
        default:
            // Invoke the superclass to handle it.
            return super.onOptionsItemSelected(item);
    }
}
Also used : AlertDialog(android.support.v7.app.AlertDialog) RadioGroup(android.widget.RadioGroup) DialogInterface(android.content.DialogInterface) Spinner(android.widget.Spinner) ArrayList(java.util.ArrayList) PorterDuffColorFilter(android.graphics.PorterDuffColorFilter) Uri(android.net.Uri) SelectAlbumBottomSheet(org.horaapps.leafpic.SelectAlbumBottomSheet) Bitmap(android.graphics.Bitmap) TextView(android.widget.TextView) EditText(android.widget.EditText) SeekBar(android.widget.SeekBar) AsyncTask(android.os.AsyncTask) CardView(android.support.v7.widget.CardView) Media(org.horaapps.leafpic.data.Media) Intent(android.content.Intent) SearchView(android.support.v7.widget.SearchView) View(android.view.View) CardView(android.support.v7.widget.CardView) TextView(android.widget.TextView) RecyclerView(android.support.v7.widget.RecyclerView) ScrollView(android.widget.ScrollView) IconicsImageView(com.mikepenz.iconics.view.IconicsImageView) IconicsImageView(com.mikepenz.iconics.view.IconicsImageView) Affix(org.horaapps.leafpic.util.Affix) CompoundButton(android.widget.CompoundButton) SwitchCompat(android.support.v7.widget.SwitchCompat)

Example 34 with CardView

use of android.support.v7.widget.CardView in project LeafPic by HoraApps.

the class SecurityActivity method setupUI.

private void setupUI() {
    setStatusBarColor();
    setNavBarColor();
    toolbar.setBackgroundColor(getPrimaryColor());
    setSupportActionBar(toolbar);
    toolbar.setNavigationIcon(new IconicsDrawable(this).icon(GoogleMaterial.Icon.gmd_arrow_back).color(Color.WHITE).sizeDp(19));
    toolbar.setNavigationOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            onBackPressed();
        }
    });
    toolbar.setTitle(getString(org.horaapps.leafpic.R.string.about));
    IconicsImageView imgActiveSecurity = (IconicsImageView) findViewById(org.horaapps.leafpic.R.id.active_security_icon);
    TextView txtActiveSecurity = (TextView) findViewById(org.horaapps.leafpic.R.id.active_security_item_title);
    TextView txtApplySecurity = (TextView) findViewById(org.horaapps.leafpic.R.id.security_body_apply_on);
    IconicsImageView imgApplySecurityHidden = (IconicsImageView) findViewById(org.horaapps.leafpic.R.id.security_body_apply_hidden_icon);
    TextView txtApplySecurityHidden = (TextView) findViewById(org.horaapps.leafpic.R.id.security_body_apply_hidden_title);
    IconicsImageView imgApplySecurityDelete = (IconicsImageView) findViewById(org.horaapps.leafpic.R.id.security_body_apply_delete_icon);
    TextView txtApplySecurityDelete = (TextView) findViewById(org.horaapps.leafpic.R.id.security_body_apply_delete_title);
    CardView securityDialogCard = (CardView) findViewById(org.horaapps.leafpic.R.id.security_dialog_card);
    llroot.setBackgroundColor(getBackgroundColor());
    securityDialogCard.setCardBackgroundColor(getCardBackgroundColor());
    /*ICONS*/
    int color = getIconColor();
    imgActiveSecurity.setColor(color);
    imgApplySecurityHidden.setColor(color);
    imgApplySecurityDelete.setColor(color);
    /*TEXTVIEWS*/
    color = getTextColor();
    txtActiveSecurity.setTextColor(color);
    txtApplySecurity.setTextColor(color);
    txtApplySecurityHidden.setTextColor(color);
    txtApplySecurityDelete.setTextColor(color);
}
Also used : IconicsImageView(com.mikepenz.iconics.view.IconicsImageView) CardView(android.support.v7.widget.CardView) TextView(android.widget.TextView) IconicsDrawable(com.mikepenz.iconics.IconicsDrawable) CardView(android.support.v7.widget.CardView) TextView(android.widget.TextView) IconicsImageView(com.mikepenz.iconics.view.IconicsImageView) View(android.view.View)

Example 35 with CardView

use of android.support.v7.widget.CardView in project LeafPic by HoraApps.

the class SettingsActivity method multiColumnsDialog.

private void multiColumnsDialog() {
    AlertDialog.Builder multiColumnDialogBuilder = new AlertDialog.Builder(SettingsActivity.this, getDialogStyle());
    View dialogLayout = getLayoutInflater().inflate(R.layout.dialog_multi_column, null);
    ((TextView) dialogLayout.findViewById(R.id.folders_title)).setTextColor(getTextColor());
    ((TextView) dialogLayout.findViewById(R.id.media_title)).setTextColor(getTextColor());
    ((CardView) dialogLayout.findViewById(R.id.multi_column_card)).setCardBackgroundColor(getCardBackgroundColor());
    dialogLayout.findViewById(R.id.multi_column_title).setBackgroundColor(getPrimaryColor());
    final TextView nColFolders = (TextView) dialogLayout.findViewById(R.id.n_columns_folders);
    final TextView nColMedia = (TextView) dialogLayout.findViewById(R.id.n_columns_media);
    nColFolders.setTextColor(getSubTextColor());
    nColMedia.setTextColor(getSubTextColor());
    SeekBar barFolders = (SeekBar) dialogLayout.findViewById(R.id.seek_bar_n_columns_folders);
    SeekBar barMedia = (SeekBar) dialogLayout.findViewById(R.id.seek_bar_n_columns_media);
    themeSeekBar(barFolders);
    themeSeekBar(barMedia);
    nColFolders.setText(String.valueOf(SP.getInt("n_columns_folders", 2)));
    nColMedia.setText(String.valueOf(SP.getInt("n_columns_media", 3)));
    barFolders.setProgress(SP.getInt("n_columns_folders", 2) - 1);
    barMedia.setProgress(SP.getInt("n_columns_media", 3) - 1);
    barFolders.setOnSeekBarChangeListener(new SeekBar.OnSeekBarChangeListener() {

        @Override
        public void onProgressChanged(SeekBar seekBar, int i, boolean b) {
            nColFolders.setText(String.valueOf(i + 1));
        }

        @Override
        public void onStartTrackingTouch(SeekBar seekBar) {
        }

        @Override
        public void onStopTrackingTouch(SeekBar seekBar) {
        }
    });
    barMedia.setOnSeekBarChangeListener(new SeekBar.OnSeekBarChangeListener() {

        @Override
        public void onProgressChanged(SeekBar seekBar, int i, boolean b) {
            nColMedia.setText(String.valueOf(i + 1));
        }

        @Override
        public void onStartTrackingTouch(SeekBar seekBar) {
        }

        @Override
        public void onStopTrackingTouch(SeekBar seekBar) {
        }
    });
    multiColumnDialogBuilder.setPositiveButton(getString(R.string.ok_action).toUpperCase(), new DialogInterface.OnClickListener() {

        @Override
        public void onClick(DialogInterface dialogInterface, int i) {
            int nFolders = Integer.parseInt(nColFolders.getText().toString());
            int nMedia = Integer.parseInt(nColMedia.getText().toString());
            SP.putInt("n_columns_folders", nFolders);
            SP.putInt("n_columns_media", nMedia);
        }
    });
    multiColumnDialogBuilder.setNegativeButton(getString(R.string.cancel).toUpperCase(), null);
    multiColumnDialogBuilder.setView(dialogLayout);
    multiColumnDialogBuilder.show();
}
Also used : AlertDialog(android.support.v7.app.AlertDialog) SeekBar(android.widget.SeekBar) DialogInterface(android.content.DialogInterface) CardView(android.support.v7.widget.CardView) View(android.view.View) CardView(android.support.v7.widget.CardView) TextView(android.widget.TextView) ScrollView(android.widget.ScrollView) IconicsImageView(com.mikepenz.iconics.view.IconicsImageView) TextView(android.widget.TextView)

Aggregations

CardView (android.support.v7.widget.CardView)49 View (android.view.View)44 TextView (android.widget.TextView)41 AlertDialog (android.support.v7.app.AlertDialog)24 ImageView (android.widget.ImageView)19 RecyclerView (android.support.v7.widget.RecyclerView)18 DialogInterface (android.content.DialogInterface)16 ScrollView (android.widget.ScrollView)14 IconicsImageView (com.mikepenz.iconics.view.IconicsImageView)8 Intent (android.content.Intent)6 LinearLayoutManager (android.support.v7.widget.LinearLayoutManager)5 OnScrollListener (android.support.v7.widget.RecyclerView.OnScrollListener)5 EditText (android.widget.EditText)5 RadioGroup (android.widget.RadioGroup)5 SeekBar (android.widget.SeekBar)5 SystemServicesProxy (com.android.systemui.recents.misc.SystemServicesProxy)5 Task (com.android.systemui.recents.model.Task)5 LineColorPicker (uz.shift.colorpicker.LineColorPicker)5 SwitchCompat (android.support.v7.widget.SwitchCompat)4 CompoundButton (android.widget.CompoundButton)4