Search in sources :

Example 41 with CardView

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

the class AlertDialogsHelper method getDetailsDialog.

public static AlertDialog getDetailsDialog(final ThemedActivity activity, AlertDialog.Builder detailsDialogBuilder, final Media f) {
    MediaDetailsMap<String, String> mainDetails = f.getMainDetails(activity.getApplicationContext());
    final View dialogLayout = activity.getLayoutInflater().inflate(org.horaapps.leafpic.R.layout.dialog_media_detail, null);
    ImageView imgMap = (ImageView) dialogLayout.findViewById(org.horaapps.leafpic.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) {
        PreferenceUtil SP = PreferenceUtil.getInstance(activity.getApplicationContext());
        StaticMapProvider staticMapProvider = StaticMapProvider.fromValue(SP.getInt(activity.getString(R.string.preference_map_provider), StaticMapProvider.GOOGLE_MAPS.getValue()));
        Glide.with(activity.getApplicationContext()).load(staticMapProvider.getUrl(location)).asBitmap().centerCrop().animate(org.horaapps.leafpic.R.anim.fade_in).into(imgMap);
        imgMap.setOnClickListener(new View.OnClickListener() {

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

        @Override
        public void onClick(View view) {
            showMoreDetails(dialogLayout, activity, f);
            showMoreText.setVisibility(View.INVISIBLE);
        }
    });
    detailsDialogBuilder.setView(dialogLayout);
    loadDetails(dialogLayout, activity, mainDetails);
    return detailsDialogBuilder.create();
}
Also used : CardView(android.support.v7.widget.CardView) Intent(android.content.Intent) TextView(android.widget.TextView) ImageView(android.widget.ImageView) GeoLocation(com.drew.lang.GeoLocation) ImageView(android.widget.ImageView) View(android.view.View) CardView(android.support.v7.widget.CardView) TextView(android.widget.TextView)

Example 42 with CardView

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

the class SecurityHelper method getInsertPasswordDialog.

public EditText getInsertPasswordDialog(final ThemedActivity activity, AlertDialog.Builder passwordDialog) {
    final View PasswordDialogLayout = activity.getLayoutInflater().inflate(org.horaapps.leafpic.R.layout.dialog_password, null);
    final TextView passwordDialogTitle = (TextView) PasswordDialogLayout.findViewById(org.horaapps.leafpic.R.id.password_dialog_title);
    final CardView passwordDialogCard = (CardView) PasswordDialogLayout.findViewById(org.horaapps.leafpic.R.id.password_dialog_card);
    final EditText editxtPassword = (EditText) PasswordDialogLayout.findViewById(org.horaapps.leafpic.R.id.password_edittxt);
    passwordDialogTitle.setBackgroundColor(activity.getPrimaryColor());
    passwordDialogCard.setBackgroundColor(activity.getCardBackgroundColor());
    ThemeHelper.setCursorDrawableColor(editxtPassword, activity.getTextColor());
    editxtPassword.getBackground().mutate().setColorFilter(activity.getTextColor(), PorterDuff.Mode.SRC_ATOP);
    editxtPassword.setTextColor(activity.getTextColor());
    passwordDialog.setView(PasswordDialogLayout);
    return editxtPassword;
}
Also used : EditText(android.widget.EditText) CardView(android.support.v7.widget.CardView) TextView(android.widget.TextView) TextView(android.widget.TextView) CardView(android.support.v7.widget.CardView) View(android.view.View)

Example 43 with CardView

use of android.support.v7.widget.CardView in project Rashr by DsLNeXuS.

the class FlashFragment method FlashSupportedKernel.

/**
     * Flash Kernels provided by Rashr like stock kernels for Nexus Devices
     *
     * @param card CardView that contains the Kernel type should be flashed for example: stock,
     *             bricked...
     */
public void FlashSupportedKernel(Card card) {
    final File path;
    final ArrayList<String> Versions;
    ArrayAdapter<String> VersionsAdapter = new ArrayAdapter<>(mContext, R.layout.custom_list_item);
    /**
         * If there files be needed to flash download it and listing device specified recovery
         * file for example stock-boot-grouper-4.4.img (read out from kernel_sums)
         */
    String SYSTEM = card.getData().toString();
    if (SYSTEM.equals(Device.KER_SYS_STOCK)) {
        Versions = RashrApp.DEVICE.getStockKernelVersions();
        path = Const.PathToStockKernel;
        for (String i : Versions) {
            try {
                String version = i.split("-")[3].replace(RashrApp.DEVICE.getRecoveryExt(), "");
                String deviceName = i.split("-")[2];
                /** Readable name for user */
                VersionsAdapter.add("Stock Kernel " + version + " (" + deviceName + ")");
            } catch (ArrayIndexOutOfBoundsException e) {
                /** Add the normal filename if something went wrong */
                VersionsAdapter.add(i);
            }
        }
    } else {
        /** Only stock kernel is supported at the moment, why are you here?
             * Something went wrong better return :)
             */
        return;
    }
    final AlertDialog.Builder KernelDialog = new AlertDialog.Builder(mContext);
    KernelDialog.setTitle(SYSTEM);
    KernelDialog.setAdapter(VersionsAdapter, new DialogInterface.OnClickListener() {

        @Override
        public void onClick(DialogInterface dialog, int which) {
            final File kernel = new File(path, Versions.get(which));
            if (!kernel.exists()) {
                try {
                    URL url = new URL(Const.KERNEL_URL + "/" + kernel.getName());
                    Downloader downloader = new Downloader(url, kernel);
                    final DownloadDialog KernelDownloader = new DownloadDialog(mContext, downloader);
                    KernelDownloader.setOnDownloadListener(new DownloadDialog.OnDownloadListener() {

                        @Override
                        public void onSuccess(File file) {
                            flashKernel(file);
                        }

                        @Override
                        public void onFail(Exception e) {
                            KernelDownloader.retry();
                        }
                    });
                    KernelDownloader.setAskBeforeDownload(true);
                    downloader.setChecksumFile(Const.KernelCollectionFile);
                    KernelDownloader.ask();
                } catch (MalformedURLException ignored) {
                }
            } else {
                flashKernel(kernel);
            }
        }
    });
    KernelDialog.show();
//}
}
Also used : AlertDialog(android.support.v7.app.AlertDialog) MalformedURLException(java.net.MalformedURLException) DialogInterface(android.content.DialogInterface) Downloader(de.mkrtchyan.utils.Downloader) DownloadDialog(de.mkrtchyan.utils.DownloadDialog) SuppressLint(android.annotation.SuppressLint) URL(java.net.URL) MalformedURLException(java.net.MalformedURLException) IOException(java.io.IOException) File(java.io.File) ArrayAdapter(android.widget.ArrayAdapter)

Example 44 with CardView

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

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 45 with CardView

use of android.support.v7.widget.CardView in project LeMondeRssReader by MBach.

the class ArticleActivity method extractParagraphs.

@NonNull
private List<Model> extractParagraphs(@NonNull Element article) {
    List<Model> p = new ArrayList<>();
    Elements articleBody = article.select("[itemprop='articleBody']");
    if (articleBody.isEmpty()) {
        return p;
    }
    Element body = articleBody.first();
    Elements elements = body.children();
    for (int i = 0; i < elements.size(); i++) {
        Element element = elements.get(i);
        // Ignore "À lire" ("Read also") parts which don't add much information on mobile phones
        if (element.hasClass("lire")) {
            continue;
        }
        Elements figures = element.getElementsByTag("figure");
        // Text or figure ?
        if (figures.isEmpty()) {
            // Cleanup hyperlink and keep only the value
            element.select("a[href]").unwrap();
            if (element.is("div.snippet.multimedia-embed")) {
                boolean hasGraph = !element.select("div.graphe").isEmpty();
                boolean hasScript = !element.select("script").isEmpty();
                if (hasGraph && hasScript) {
                    GraphExtractor graphExtractor = new GraphExtractor(getBaseContext(), element.select("script").first());
                    p.add(new Model(Model.GRAPH_TYPE, graphExtractor.generate()));
                    continue;
                }
            }
            if (element.is("blockquote.twitter-tweet")) {
                SharedPreferences sharedPreferences = PreferenceManager.getDefaultSharedPreferences(getBaseContext());
                boolean displayTweets = sharedPreferences.getBoolean("displayTweets", false);
                element.remove();
                if (displayTweets) {
                    TextView t = new TextView(getBaseContext());
                    t.setText(Html.fromHtml(element.html(), Html.FROM_HTML_MODE_COMPACT));
                    t.setTextColor(Color.WHITE);
                    CardView cardView = new CardView(getBaseContext());
                    cardView.addView(t);
                    p.add(new Model(Model.TWEET_TYPE, cardView));
                }
                continue;
            }
            // Cleanup style markup and script which should be placed on top
            if (element.is("style")) {
                element.remove();
                continue;
            }
            if (element.is("script")) {
                element.remove();
                continue;
            }
            TextView t = new TextView(getBaseContext());
            t.setText(Html.fromHtml(element.html(), Html.FROM_HTML_MODE_COMPACT));
            t.setTextColor(Color.WHITE);
            boolean hasIntertitre = element.is("h2.intertitre");
            if (!hasIntertitre) {
                hasIntertitre = !element.select("h2.intertitre").isEmpty();
            }
            if (hasIntertitre) {
                t.setTypeface(Typeface.SERIF);
                t.setPadding(0, Constants.PADDING_TOP_SUBTITLE, 0, Constants.PADDING_BOTTOM_SUBTITLE);
                t.setTextSize(TypedValue.COMPLEX_UNIT_SP, getResources().getDimension(R.dimen.article_description));
            } else {
                t.setPadding(0, 0, 0, Constants.PADDING_BOTTOM);
                t.setTextSize(TypedValue.COMPLEX_UNIT_SP, getResources().getDimension(R.dimen.article_body));
            }
            if (element.is("p.question")) {
                t.setTypeface(null, Typeface.BOLD);
            }
            if (element.is("h2.tag") && element.children().size() > 0) {
                String cssClass = element.child(0).attr("class");
                Log.d(TAG, cssClass);
                t.setAllCaps(true);
                t.setPadding(Constants.PADDING_LEFT_RIGHT_TAG, Constants.PADDING_BOTTOM, Constants.PADDING_LEFT_RIGHT_TAG, Constants.PADDING_BOTTOM);
                switch(cssClass) {
                    case "faux":
                        t.setBackgroundColor(getResources().getColor(R.color.tag_red, null));
                        break;
                    case "vrai":
                        t.setBackgroundColor(getResources().getColor(R.color.tag_green, null));
                        break;
                    case "plutot_vrai":
                        t.setBackgroundColor(getResources().getColor(R.color.tag_yellow, null));
                        break;
                    case "oubli":
                        t.setBackgroundColor(getResources().getColor(R.color.tag_grey, null));
                        break;
                    default:
                        break;
                }
            }
            p.add(new Model(t));
        } else {
            // If image is on first position in the DOM, it's useless to display once more: it's already displayed in the toolbar
            if (i > 0) {
                Element figure = figures.first();
                Elements images = figure.getElementsByTag("img");
                if (!images.isEmpty()) {
                    p.add(new Model(Model.IMAGE_TYPE, images.first().attr("src")));
                }
            }
        }
    }
    return p;
}
Also used : SharedPreferences(android.content.SharedPreferences) Element(org.jsoup.nodes.Element) ArrayList(java.util.ArrayList) CardView(android.support.v7.widget.CardView) TextView(android.widget.TextView) Elements(org.jsoup.select.Elements) NonNull(android.support.annotation.NonNull)

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