Search in sources :

Example 46 with CardView

use of android.support.v7.widget.CardView in project android_frameworks_base by DirtyUnicorns.

the class RecentsTvView method launchTaskFomRecents.

/**
     * Launch the given task from recents with animation. If the task is not focused, this will
     * attempt to scroll to focus the task before launching.
     * @param task
     */
private void launchTaskFomRecents(final Task task, boolean animate) {
    if (!animate) {
        SystemServicesProxy ssp = Recents.getSystemServices();
        ssp.startActivityFromRecents(getContext(), task.key, task.title, null);
        return;
    }
    mTaskStackHorizontalView.requestFocus();
    Task focusedTask = mTaskStackHorizontalView.getFocusedTask();
    if (focusedTask != null && task != focusedTask) {
        if (mScrollListener != null) {
            mTaskStackHorizontalView.removeOnScrollListener(mScrollListener);
        }
        mScrollListener = new OnScrollListener() {

            @Override
            public void onScrollStateChanged(RecyclerView recyclerView, int newState) {
                super.onScrollStateChanged(recyclerView, newState);
                if (newState == RecyclerView.SCROLL_STATE_IDLE) {
                    TaskCardView cardView = mTaskStackHorizontalView.getChildViewForTask(task);
                    if (cardView != null) {
                        mTransitionHelper.launchTaskFromRecents(mStack, task, mTaskStackHorizontalView, cardView, null, INVALID_STACK_ID);
                    } else {
                        // This should not happen normally. If this happens then the data in
                        // the grid view was altered during the scroll. Log error and launch
                        // task with no animation.
                        Log.e(TAG, "Card view for task : " + task + ", returned null.");
                        SystemServicesProxy ssp = Recents.getSystemServices();
                        ssp.startActivityFromRecents(getContext(), task.key, task.title, null);
                    }
                    mTaskStackHorizontalView.removeOnScrollListener(mScrollListener);
                }
            }
        };
        mTaskStackHorizontalView.addOnScrollListener(mScrollListener);
        mTaskStackHorizontalView.setSelectedPositionSmooth(((TaskStackHorizontalViewAdapter) mTaskStackHorizontalView.getAdapter()).getPositionOfTask(task));
    } else {
        mTransitionHelper.launchTaskFromRecents(mStack, task, mTaskStackHorizontalView, mTaskStackHorizontalView.getChildViewForTask(task), null, INVALID_STACK_ID);
    }
}
Also used : SystemServicesProxy(com.android.systemui.recents.misc.SystemServicesProxy) Task(com.android.systemui.recents.model.Task) OnScrollListener(android.support.v7.widget.RecyclerView.OnScrollListener) RecyclerView(android.support.v7.widget.RecyclerView)

Example 47 with CardView

use of android.support.v7.widget.CardView in project dobby-android by InceptAi.

the class WifiDocMainFragment method fetchViewInstances.

private void fetchViewInstances(View rootView) {
    mainFab = (FloatingActionButton) rootView.findViewById(R.id.main_fab_button);
    mainFab.setOnClickListener(this);
    yourNetworkCv = (CardView) rootView.findViewById(R.id.net_cardview);
    pingCv = (CardView) rootView.findViewById(R.id.ping_cardview);
    statusCv = (CardView) rootView.findViewById(R.id.status_cardview);
    View downloadView = rootView.findViewById(R.id.cg_download);
    downloadCircularGauge = (CircularGauge) downloadView.findViewById(R.id.bw_gauge);
    downloadGaugeTv = (TextView) downloadView.findViewById(R.id.gauge_tv);
    downloadGaugeTitleTv = (TextView) downloadView.findViewById(R.id.title_tv);
    downloadGaugeTitleTv.setText(R.string.download_bw);
    View uploadView = rootView.findViewById(R.id.cg_upload);
    uploadCircularGauge = (CircularGauge) uploadView.findViewById(R.id.bw_gauge);
    uploadGaugeTv = (TextView) uploadView.findViewById(R.id.gauge_tv);
    uploadGaugeTitleTv = (TextView) uploadView.findViewById(R.id.title_tv);
    uploadGaugeTitleTv.setText(R.string.upload_bw);
    View row1View = rootView.findViewById(R.id.ping_latency_row_inc1);
    pingRouterTitleTv = (TextView) row1View.findViewById(R.id.left_title_tv);
    pingRouterValueTv = (TextView) row1View.findViewById(R.id.left_value_tv);
    pingRouterGradeIv = (ImageView) row1View.findViewById(R.id.left_grade_iv);
    pingWebTitleTv = (TextView) row1View.findViewById(R.id.right_title_tv);
    pingWebValueTv = (TextView) row1View.findViewById(R.id.right_value_tv);
    pingWebGradeIv = (ImageView) row1View.findViewById(R.id.right_grade_iv);
    View row2View = rootView.findViewById(R.id.ping_latency_row_inc2);
    pingDnsPrimaryTitleTv = (TextView) row2View.findViewById(R.id.left_title_tv);
    pingDnsPrimaryValueTv = (TextView) row2View.findViewById(R.id.left_value_tv);
    pingDnsPrimaryGradeIv = (ImageView) row2View.findViewById(R.id.left_grade_iv);
    pingDnsSecondTitleTv = (TextView) row2View.findViewById(R.id.right_title_tv);
    pingDnsSecondValueTv = (TextView) row2View.findViewById(R.id.right_value_tv);
    pingDnsSecondGradeIv = (ImageView) row2View.findViewById(R.id.right_grade_iv);
    pingRouterTitleTv.setText(R.string.router_ping);
    pingDnsPrimaryTitleTv.setText(R.string.dns_primary_ping);
    pingDnsSecondTitleTv.setText(R.string.dns_second_ping);
    pingWebTitleTv.setText(R.string.web_ping);
    // Populate wifi card views
    wifiSsidTv = (TextView) rootView.findViewById(R.id.wifi_ssid_tv);
    wifiSignalValueTv = (TextView) rootView.findViewById(R.id.value_tv);
    wifiSignalIconIv = (ImageView) rootView.findViewById(R.id.icon_iv);
    ispNameTv = (TextView) rootView.findViewById(R.id.isp_name_tv);
    routerIpTv = (TextView) rootView.findViewById(R.id.router_ip_tv);
    statusTv = (TextView) rootView.findViewById(R.id.status_tv);
    aboutLayout = (LinearLayout) rootView.findViewById(R.id.about_ll);
    feedbackLayout = (LinearLayout) rootView.findViewById(R.id.feedback_ll);
    aboutLayout.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            showAboutAndPrivacyPolicy();
        }
    });
    feedbackLayout.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            showFeedbackForm();
        }
    });
// suggestionsValueTv = (TextView)rootView.findViewById(R.id.suggestion_value_tv);
}
Also used : ImageView(android.widget.ImageView) View(android.view.View) CardView(android.support.v7.widget.CardView) TextView(android.widget.TextView)

Example 48 with CardView

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

the class DeleteAlbumsDialog method onCreateDialog.

@NonNull
@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
    ThemedAlertDialogBuilder builder = new ThemedAlertDialogBuilder(getActivity(), ThemeHelper.getInstanceLoaded(getContext()));
    View view = LayoutInflater.from(getContext()).inflate(R.layout.dialog_delete_album_progress, null, false);
    RecyclerView rv = view.findViewById(R.id.rv_folders);
    adapter = new FolderAdapter(getContext(), albums);
    rv.setLayoutManager(new LinearLayoutManager(getContext()));
    rv.setAdapter(adapter);
    dialogTitle = view.findViewById(R.id.text_dialog_title);
    fileName = view.findViewById(R.id.file_name);
    progress = view.findViewById(R.id.progress_bar);
    ((CardView) view.findViewById(R.id.message_card)).setCardBackgroundColor(t.getCardBackgroundColor());
    dialogTitle.setBackgroundColor(t.getPrimaryColor());
    progress.setMax(80);
    progress.setProgress(50);
    builder.setView(view);
    builder.setNegativeButton(getString(R.string.cancel).toUpperCase(), (dialogInterface, i) -> {
        Toast.makeText(getContext(), "No Way", Toast.LENGTH_SHORT).show();
        dialogInterface.dismiss();
    });
    return builder.create();
}
Also used : CardView(android.support.v7.widget.CardView) RecyclerView(android.support.v7.widget.RecyclerView) ThemedAlertDialogBuilder(org.horaapps.liz.ThemedAlertDialogBuilder) LinearLayoutManager(android.support.v7.widget.LinearLayoutManager) CardView(android.support.v7.widget.CardView) RecyclerView(android.support.v7.widget.RecyclerView) TextView(android.widget.TextView) View(android.view.View) NonNull(android.support.annotation.NonNull)

Example 49 with CardView

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

the class RvMediaFragment method onOptionsItemSelected.

@Override
public boolean onOptionsItemSelected(MenuItem item) {
    switch(item.getItemId()) {
        case R.id.all_media_filter:
            album.setFilterMode(FilterMode.ALL);
            item.setChecked(true);
            reload();
            return true;
        case R.id.video_media_filter:
            album.setFilterMode(FilterMode.VIDEO);
            item.setChecked(true);
            reload();
            return true;
        case R.id.image_media_filter:
            album.setFilterMode(FilterMode.IMAGES);
            item.setChecked(true);
            reload();
            return true;
        case R.id.gifs_media_filter:
            album.setFilterMode(FilterMode.GIF);
            item.setChecked(true);
            reload();
            return true;
        case R.id.sharePhotos:
            Intent intent = new Intent(Intent.ACTION_SEND_MULTIPLE);
            HashMap<String, Integer> types = new HashMap<>();
            ArrayList<Uri> files = new ArrayList<>();
            for (Media f : adapter.getSelected()) {
                String mimeType = MimeTypeUtils.getTypeMime(f.getMimeType());
                int count = 0;
                if (types.containsKey(mimeType)) {
                    count = types.get(mimeType);
                }
                types.put(mimeType, count);
                files.add(LegacyCompatFileProvider.getUri(getContext(), f.getFile()));
            }
            Set<String> fileTypes = types.keySet();
            if (fileTypes.size() > 1) {
                Toast.makeText(getContext(), R.string.waring_share_multiple_file_types, Toast.LENGTH_SHORT).show();
            }
            int max = -1;
            String type = null;
            for (String fileType : fileTypes) {
                Integer count = types.get(fileType);
                if (count > max) {
                    type = fileType;
                }
            }
            intent.setType(type + "/*");
            intent.putParcelableArrayListExtra(Intent.EXTRA_STREAM, files);
            intent.setFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION);
            startActivity(Intent.createChooser(intent, getResources().getText(R.string.send_to)));
            return true;
        case R.id.set_as_cover:
            String path = adapter.getFirstSelected().getPath();
            album.setCover(path);
            db().setCover(album.getPath(), path);
            adapter.clearSelected();
            return true;
        case R.id.action_palette:
            Intent paletteIntent = new Intent(getActivity(), PaletteActivity.class);
            paletteIntent.setData(adapter.getFirstSelected().getUri());
            startActivity(paletteIntent);
            return true;
        case R.id.rename:
            final EditText editTextNewName = new EditText(getActivity());
            editTextNewName.setText(StringUtils.getPhotoNameByPath(adapter.getFirstSelected().getPath()));
            AlertDialog renameDialog = AlertDialogsHelper.getInsertTextDialog(((ThemedActivity) getActivity()), editTextNewName, R.string.rename_photo_action);
            renameDialog.setButton(DialogInterface.BUTTON_POSITIVE, getString(R.string.ok_action).toUpperCase(), (dialog, which) -> {
                if (editTextNewName.length() != 0) {
                    boolean b = MediaHelper.renameMedia(getActivity(), adapter.getFirstSelected(), editTextNewName.getText().toString());
                    if (!b) {
                        StringUtils.showToast(getActivity(), getString(R.string.rename_error));
                    // adapter.notifyDataSetChanged();
                    } else
                        // Deselect media if rename successful
                        adapter.clearSelected();
                } else
                    StringUtils.showToast(getActivity(), getString(R.string.nothing_changed));
            });
            renameDialog.setButton(DialogInterface.BUTTON_NEGATIVE, getString(R.string.cancel).toUpperCase(), (dialog, which) -> dialog.dismiss());
            renameDialog.show();
            return true;
        case R.id.select_all:
            if (adapter.getSelectedCount() == adapter.getItemCount())
                adapter.clearSelected();
            else
                adapter.selectAll();
            return true;
        case R.id.name_sort_mode:
            adapter.changeSortingMode(SortingMode.NAME);
            HandlingAlbums.getInstance(getContext()).setSortingMode(album.getPath(), SortingMode.NAME.getValue());
            album.setSortingMode(SortingMode.NAME);
            item.setChecked(true);
            return true;
        case R.id.date_taken_sort_mode:
            adapter.changeSortingMode(SortingMode.DATE);
            HandlingAlbums.getInstance(getContext()).setSortingMode(album.getPath(), SortingMode.DATE.getValue());
            album.setSortingMode(SortingMode.DATE);
            item.setChecked(true);
            return true;
        case R.id.size_sort_mode:
            adapter.changeSortingMode(SortingMode.SIZE);
            HandlingAlbums.getInstance(getContext()).setSortingMode(album.getPath(), SortingMode.SIZE.getValue());
            album.setSortingMode(SortingMode.SIZE);
            item.setChecked(true);
            return true;
        case R.id.numeric_sort_mode:
            adapter.changeSortingMode(SortingMode.NUMERIC);
            HandlingAlbums.getInstance(getContext()).setSortingMode(album.getPath(), SortingMode.NUMERIC.getValue());
            album.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);
            HandlingAlbums.getInstance(getContext()).setSortingOrder(album.getPath(), sortingOrder.getValue());
            album.setSortingOrder(sortingOrder);
            return true;
        case R.id.delete:
            ProgressAdapter errorsAdapter = new ProgressAdapter(getContext());
            ArrayList<Media> selected = adapter.getSelected();
            AlertDialog alertDialog = AlertDialogsHelper.getProgressDialogWithErrors(((ThemedActivity) getActivity()), R.string.deleting_images, errorsAdapter, selected.size());
            alertDialog.setButton(DialogInterface.BUTTON_POSITIVE, this.getString(R.string.cancel).toUpperCase(), (dialog, id) -> {
                alertDialog.dismiss();
            });
            alertDialog.show();
            MediaHelper.deleteMedia(getContext(), selected).subscribeOn(Schedulers.io()).observeOn(AndroidSchedulers.mainThread()).subscribe(m -> {
                adapter.remove(m);
                errorsAdapter.add(new ProgressAdapter.ListItem(m.getName()), false);
            }, throwable -> {
                if (throwable instanceof DeleteException)
                    errorsAdapter.add(new ProgressAdapter.ListItem((DeleteException) throwable), true);
            }, () -> {
                if (errorsAdapter.getItemCount() == 0)
                    alertDialog.dismiss();
                adapter.clearSelected();
            });
            return true;
        // TODO: 11/21/16 move away from here
        case R.id.affix:
            // region Async MediaAffix
            class affixMedia extends AsyncTask<Affix.Options, Integer, Void> {

                private AlertDialog dialog;

                @Override
                protected void onPreExecute() {
                    super.onPreExecute();
                    dialog = AlertDialogsHelper.getProgressDialog((ThemedActivity) getActivity(), getString(R.string.affix), getString(R.string.affix_text));
                    dialog.show();
                }

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

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

                @Override
                protected void onPostExecute(Void result) {
                    adapter.clearSelected();
                    dialog.dismiss();
                }
            }
            // endregion
            final AlertDialog.Builder builder = new AlertDialog.Builder(getActivity(), 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 = dialogLayout.findViewById(R.id.affix_vertical_switch);
            final SwitchCompat swSaveHere = dialogLayout.findViewById(R.id.save_here_switch);
            final LinearLayout llSwVertical = dialogLayout.findViewById(R.id.ll_affix_vertical);
            final LinearLayout llSwSaveHere = dialogLayout.findViewById(R.id.ll_affix_save_here);
            final RadioGroup radioFormatGroup = dialogLayout.findViewById(R.id.radio_format);
            final TextView txtQuality = dialogLayout.findViewById(R.id.affix_quality_title);
            final SeekBar seekQuality = dialogLayout.findViewById(R.id.seek_bar_quality);
            // region Example
            final LinearLayout llExample = dialogLayout.findViewById(R.id.affix_example);
            llExample.setBackgroundColor(getBackgroundColor());
            llExample.setVisibility(Hawk.get("show_tips", true) ? View.VISIBLE : View.GONE);
            final LinearLayout llExampleH = dialogLayout.findViewById(R.id.affix_example_horizontal);
            // llExampleH.setBackgroundColor(getCardBackgroundColor());
            final LinearLayout llExampleV = dialogLayout.findViewById(R.id.affix_example_vertical);
            // llExampleV.setBackgroundColor(getCardBackgroundColor());
            // endregion
            // region THEME STUFF
            getThemeHelper().setScrollViewColor(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);
            // Example Stuff
            ((TextView) dialogLayout.findViewById(R.id.affix_example_horizontal_txt1)).setTextColor(color);
            ((TextView) dialogLayout.findViewById(R.id.affix_example_horizontal_txt2)).setTextColor(color);
            ((TextView) dialogLayout.findViewById(R.id.affix_example_vertical_txt1)).setTextColor(color);
            ((TextView) dialogLayout.findViewById(R.id.affix_example_vertical_txt2)).setTextColor(color);
            /**
             * Sub TextViews *
             */
            color = getThemeHelper().getSubTextColor();
            ((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();
            ((ThemedIcon) dialogLayout.findViewById(R.id.affix_quality_icon)).setColor(color);
            ((ThemedIcon) dialogLayout.findViewById(R.id.affix_format_icon)).setColor(color);
            ((ThemedIcon) dialogLayout.findViewById(R.id.affix_vertical_icon)).setColor(color);
            ((ThemedIcon) dialogLayout.findViewById(R.id.save_here_icon)).setColor(color);
            // Example bg
            color = getCardBackgroundColor();
            dialogLayout.findViewById(R.id.affix_example_horizontal_txt1).setBackgroundColor(color);
            dialogLayout.findViewById(R.id.affix_example_horizontal_txt2).setBackgroundColor(color);
            dialogLayout.findViewById(R.id.affix_example_vertical_txt1).setBackgroundColor(color);
            dialogLayout.findViewById(R.id.affix_example_vertical_txt2).setBackgroundColor(color);
            seekQuality.getProgressDrawable().setColorFilter(new PorterDuffColorFilter(getAccentColor(), PorterDuff.Mode.SRC_IN));
            seekQuality.getThumb().setColorFilter(new PorterDuffColorFilter(getAccentColor(), PorterDuff.Mode.SRC_IN));
            getThemeHelper().themeRadioButton(dialogLayout.findViewById(R.id.radio_jpeg));
            getThemeHelper().themeRadioButton(dialogLayout.findViewById(R.id.radio_png));
            getThemeHelper().themeRadioButton(dialogLayout.findViewById(R.id.radio_webp));
            getThemeHelper().setSwitchCompactColor(swSaveHere, getAccentColor());
            getThemeHelper().setSwitchCompactColor(swVertical, getAccentColor());
            // #endregion
            seekQuality.setOnSeekBarChangeListener(new SeekBar.OnSeekBarChangeListener() {

                @Override
                public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) {
                    txtQuality.setText(StringUtils.html(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) {
                }
            });
            seekQuality.setProgress(50);
            swVertical.setClickable(false);
            llSwVertical.setOnClickListener(new View.OnClickListener() {

                @Override
                public void onClick(View v) {
                    swVertical.setChecked(!swVertical.isChecked());
                    getThemeHelper().setSwitchCompactColor(swVertical, getAccentColor());
                    llExampleH.setVisibility(swVertical.isChecked() ? View.GONE : View.VISIBLE);
                    llExampleV.setVisibility(swVertical.isChecked() ? View.VISIBLE : View.GONE);
                }
            });
            swSaveHere.setClickable(false);
            llSwSaveHere.setOnClickListener(new View.OnClickListener() {

                @Override
                public void onClick(View v) {
                    swSaveHere.setChecked(!swSaveHere.isChecked());
                    getThemeHelper().setSwitchCompactColor(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() ? adapter.getFirstSelected().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;
    }
    return super.onOptionsItemSelected(item);
}
Also used : AlertDialog(android.support.v7.app.AlertDialog) RadioGroup(android.widget.RadioGroup) HashMap(java.util.HashMap) DialogInterface(android.content.DialogInterface) DeleteException(org.horaapps.leafpic.util.file.DeleteException) ArrayList(java.util.ArrayList) PorterDuffColorFilter(android.graphics.PorterDuffColorFilter) Uri(android.net.Uri) Bitmap(android.graphics.Bitmap) ThemedActivity(org.horaapps.liz.ThemedActivity) SortingOrder(org.horaapps.leafpic.data.sort.SortingOrder) TextView(android.widget.TextView) EditText(android.widget.EditText) SeekBar(android.widget.SeekBar) Media(org.horaapps.leafpic.data.Media) AsyncTask(android.os.AsyncTask) CardView(android.support.v7.widget.CardView) Intent(android.content.Intent) BindView(butterknife.BindView) View(android.view.View) CardView(android.support.v7.widget.CardView) TextView(android.widget.TextView) RecyclerView(android.support.v7.widget.RecyclerView) Affix(org.horaapps.leafpic.util.Affix) ThemedIcon(org.horaapps.liz.ui.ThemedIcon) ProgressAdapter(org.horaapps.leafpic.adapters.ProgressAdapter) LinearLayout(android.widget.LinearLayout) SwitchCompat(android.support.v7.widget.SwitchCompat)

Example 50 with CardView

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

the class GeneralSetting method editNumberOfColumns.

public void editNumberOfColumns() {
    AlertDialog.Builder multiColumnDialogBuilder = new AlertDialog.Builder(getActivity(), getActivity().getDialogStyle());
    View dialogLayout = LayoutInflater.from(getActivity()).inflate(R.layout.dialog_multi_column, null);
    ((TextView) dialogLayout.findViewById(R.id.folders_title)).setTextColor(getActivity().getTextColor());
    ((TextView) dialogLayout.findViewById(R.id.media_title)).setTextColor(getActivity().getTextColor());
    ((TextView) dialogLayout.findViewById(R.id.folders_title_landscape)).setTextColor(getActivity().getTextColor());
    ((TextView) dialogLayout.findViewById(R.id.media_title_landscape)).setTextColor(getActivity().getTextColor());
    ((CardView) dialogLayout.findViewById(R.id.multi_column_card)).setCardBackgroundColor(getActivity().getCardBackgroundColor());
    dialogLayout.findViewById(R.id.multi_column_title).setBackgroundColor(getActivity().getPrimaryColor());
    final TextView nColFolders = (TextView) dialogLayout.findViewById(R.id.n_columns_folders);
    final TextView nColMedia = (TextView) dialogLayout.findViewById(R.id.n_columns_media);
    final TextView nColFoldersL = (TextView) dialogLayout.findViewById(R.id.n_columns_folders_landscape);
    final TextView nColMediaL = (TextView) dialogLayout.findViewById(R.id.n_columns_media_landscape);
    nColFolders.setTextColor(getActivity().getSubTextColor());
    nColMedia.setTextColor(getActivity().getSubTextColor());
    nColFoldersL.setTextColor(getActivity().getSubTextColor());
    nColMediaL.setTextColor(getActivity().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);
    SeekBar barFoldersL = (SeekBar) dialogLayout.findViewById(R.id.seek_bar_n_columns_folders_landscape);
    SeekBar barMediaL = (SeekBar) dialogLayout.findViewById(R.id.seek_bar_n_columns_media_landscape);
    getActivity().themeSeekBar(barFolders);
    getActivity().themeSeekBar(barMedia);
    getActivity().themeSeekBar(barFoldersL);
    getActivity().themeSeekBar(barMediaL);
    // Portrait Orientation
    int folderColumnsPortrait = Prefs.getFolderColumnsPortrait();
    int mediaColumnsPortrait = Prefs.getMediaColumnsPortrait();
    nColFolders.setText(String.valueOf(folderColumnsPortrait));
    nColMedia.setText(String.valueOf(mediaColumnsPortrait));
    barFolders.setProgress(folderColumnsPortrait - 1);
    barMedia.setProgress(mediaColumnsPortrait - 2);
    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 + 2));
        }

        @Override
        public void onStartTrackingTouch(SeekBar seekBar) {
        }

        @Override
        public void onStopTrackingTouch(SeekBar seekBar) {
        }
    });
    // Landscape Orientation
    int folderColumnsLandscape = Prefs.getFolderColumnsLandscape();
    int mediaColumnsLandscape = Prefs.getMediaColumnsLandscape();
    nColFoldersL.setText(String.valueOf(folderColumnsLandscape));
    nColMediaL.setText(String.valueOf(mediaColumnsLandscape));
    barFoldersL.setProgress(folderColumnsLandscape - 2);
    barMediaL.setProgress(mediaColumnsLandscape - 3);
    barFoldersL.setOnSeekBarChangeListener(new SeekBar.OnSeekBarChangeListener() {

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

        @Override
        public void onStartTrackingTouch(SeekBar seekBar) {
        }

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

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

        @Override
        public void onStartTrackingTouch(SeekBar seekBar) {
        }

        @Override
        public void onStopTrackingTouch(SeekBar seekBar) {
        }
    });
    multiColumnDialogBuilder.setPositiveButton(getActivity().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());
            int nFoldersL = Integer.parseInt(nColFoldersL.getText().toString());
            int nMediaL = Integer.parseInt(nColMediaL.getText().toString());
            Prefs.setFolderColumnsPortrait(nFolders);
            Prefs.setMediaColumnsPortrait(nMedia);
            Prefs.setFolderColumnsLandscape(nFoldersL);
            Prefs.setMediaColumnsLandscape(nMediaL);
        }
    });
    multiColumnDialogBuilder.setNegativeButton(getActivity().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) TextView(android.widget.TextView) CardView(android.support.v7.widget.CardView) View(android.view.View) 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