Search in sources :

Example 1 with MaterialAboutItemOnClickAction

use of com.danielstone.materialaboutlibrary.items.MaterialAboutItemOnClickAction in project material-about-library by daniel-stoneuk.

the class ConvenienceBuilder method createRateOnClickAction.

/**
 * Creates a MaterialAboutItemOnClickAction that will open
 * the Google Play store listing for the app.
 *
 * @param c context
 * @return onClickAction
 */
public static MaterialAboutItemOnClickAction createRateOnClickAction(final Context c) {
    Uri uri = Uri.parse("market://details?id=" + c.getPackageName());
    final Intent goToMarket = new Intent(Intent.ACTION_VIEW, uri);
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
        goToMarket.addFlags(Intent.FLAG_ACTIVITY_NO_HISTORY | Intent.FLAG_ACTIVITY_NEW_DOCUMENT | Intent.FLAG_ACTIVITY_MULTIPLE_TASK);
    } else {
        goToMarket.addFlags(Intent.FLAG_ACTIVITY_NO_HISTORY | Intent.FLAG_ACTIVITY_MULTIPLE_TASK);
    }
    return new MaterialAboutItemOnClickAction() {

        @Override
        public void onClick() {
            try {
                c.startActivity(goToMarket);
            } catch (ActivityNotFoundException e) {
                c.startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse("http://play.google.com/store/apps/details?id=" + c.getPackageName())));
            }
        }
    };
}
Also used : MaterialAboutItemOnClickAction(com.danielstone.materialaboutlibrary.items.MaterialAboutItemOnClickAction) ActivityNotFoundException(android.content.ActivityNotFoundException) Intent(android.content.Intent) Uri(android.net.Uri)

Example 2 with MaterialAboutItemOnClickAction

use of com.danielstone.materialaboutlibrary.items.MaterialAboutItemOnClickAction in project material-about-library by daniel-stoneuk.

the class ConvenienceBuilder method createWebViewDialogOnClickAction.

public static MaterialAboutItemOnClickAction createWebViewDialogOnClickAction(final Context c, final CharSequence dialogTitle, final CharSequence dialogNegativeButton, final String htmlString, final boolean isStringUrl, final boolean supportZoom) {
    return new MaterialAboutItemOnClickAction() {

        @Override
        public void onClick() {
            AlertDialog.Builder alertBuilder = new AlertDialog.Builder(c);
            alertBuilder.setTitle(dialogTitle);
            final WebView wv = new WebView(c);
            wv.getSettings().setSupportZoom(supportZoom);
            if (!supportZoom) {
                wv.getSettings().setLoadWithOverviewMode(true);
                wv.getSettings().setUseWideViewPort(true);
            }
            if (isStringUrl) {
                wv.loadUrl(htmlString);
            } else {
                wv.loadData(htmlString, "text/html; charset=utf-8", "UTF-8");
            }
            alertBuilder.setView(wv);
            alertBuilder.setNegativeButton(dialogNegativeButton, new DialogInterface.OnClickListener() {

                @Override
                public void onClick(DialogInterface dialog, int id) {
                    wv.destroy();
                    dialog.dismiss();
                }
            });
            final AlertDialog dialog = alertBuilder.create();
            dialog.show();
        }
    };
}
Also used : AlertDialog(androidx.appcompat.app.AlertDialog) MaterialAboutItemOnClickAction(com.danielstone.materialaboutlibrary.items.MaterialAboutItemOnClickAction) DialogInterface(android.content.DialogInterface) WebView(android.webkit.WebView)

Example 3 with MaterialAboutItemOnClickAction

use of com.danielstone.materialaboutlibrary.items.MaterialAboutItemOnClickAction in project material-about-library by daniel-stoneuk.

the class ExampleMaterialAboutActivity method createDynamicItem.

private MaterialAboutActionItem createDynamicItem(String subText, final Context c) {
    final MaterialAboutActionItem item = new MaterialAboutActionItem.Builder().text("Dynamic UI").subText(subText).icon(new IconicsDrawable(c).icon(CommunityMaterial.Icon.cmd_refresh).sizeDp(18)).build();
    item.setOnClickAction(new MaterialAboutItemOnClickAction() {

        @Override
        public void onClick() {
            getList().getCards().get(4).getItems().remove(getList().getCards().get(4).getItems().indexOf(item));
            int newIndex = ((int) (Math.random() * 5));
            getList().getCards().get(4).getItems().add(newIndex, item);
            item.setSubText("Random number: " + ((int) (Math.random() * 10)));
            setMaterialAboutList(getList());
        }
    });
    return item;
}
Also used : MaterialAboutItemOnClickAction(com.danielstone.materialaboutlibrary.items.MaterialAboutItemOnClickAction) MaterialAboutActionItem(com.danielstone.materialaboutlibrary.items.MaterialAboutActionItem) ConvenienceBuilder(com.danielstone.materialaboutlibrary.ConvenienceBuilder) IconicsDrawable(com.mikepenz.iconics.IconicsDrawable)

Example 4 with MaterialAboutItemOnClickAction

use of com.danielstone.materialaboutlibrary.items.MaterialAboutItemOnClickAction in project TeamCityApp by vase4kin.

the class AboutFragment method getMaterialAboutList.

@Override
protected MaterialAboutList getMaterialAboutList(final Context context) {
    MaterialAboutCard.Builder appCardBuilder = new MaterialAboutCard.Builder();
    appCardBuilder.addItem(new MaterialAboutActionItem.Builder().text(getString(R.string.version)).icon(new IconDrawable(context, MaterialIcons.md_info_outline).colorRes(R.color.sub_text_color).sizeDp(24)).subText(BuildConfig.VERSION_NAME).build()).addItem(ConvenienceBuilder.createRateActionItem(context, new IconDrawable(context, MaterialIcons.md_star_border).colorRes(R.color.sub_text_color).sizeDp(24), getString(R.string.about_app_text_rate_app), null)).addItem(new MaterialAboutActionItem.Builder().text(R.string.about_app_text_found_issue).subText(R.string.about_app_subtext_found_issue).icon(new IconDrawable(context, MaterialIcons.md_question_answer).colorRes(R.color.sub_text_color).sizeDp(24)).setOnClickAction(new MaterialAboutItemOnClickAction() {

        @Override
        public void onClick() {
            Intent intent = new Intent(Intent.ACTION_VIEW);
            intent.setData(Uri.parse(getString(R.string.about_app_url_found_issue)));
            getActivity().startActivity(intent);
        }
    }).build());
    MaterialAboutCard.Builder miscCardBuilder = new MaterialAboutCard.Builder();
    miscCardBuilder.addItem(new MaterialAboutActionItem.Builder().text(R.string.about_app_text_source_code).icon(new IconDrawable(context, MaterialCommunityIcons.mdi_github_circle).colorRes(R.color.sub_text_color).sizeDp(24)).setOnClickAction(new MaterialAboutItemOnClickAction() {

        @Override
        public void onClick() {
            Intent intent = new Intent(Intent.ACTION_VIEW);
            intent.setData(Uri.parse(getString(R.string.about_app_url_source_code)));
            getActivity().startActivity(intent);
        }
    }).build()).addItem(new MaterialAboutActionItem.Builder().text(R.string.about_app_text_libraries).icon(new IconDrawable(context, MaterialCommunityIcons.mdi_github_circle).colorRes(R.color.sub_text_color).sizeDp(24)).setOnClickAction(new MaterialAboutItemOnClickAction() {

        @Override
        public void onClick() {
            AboutLibrariesActivity.start(getActivity());
        }
    }).build());
    MaterialAboutCard.Builder authorCardBuilder = new MaterialAboutCard.Builder();
    authorCardBuilder.title(R.string.about_app_text_contacts);
    authorCardBuilder.addItem(new MaterialAboutActionItem.Builder().text(R.string.about_app_text_github).icon(new IconDrawable(context, MaterialCommunityIcons.mdi_github_circle).colorRes(R.color.sub_text_color).sizeDp(24)).setOnClickAction(new MaterialAboutItemOnClickAction() {

        @Override
        public void onClick() {
            Intent intent = new Intent(Intent.ACTION_VIEW);
            intent.setData(Uri.parse(getString(R.string.about_app_url_github)));
            getActivity().startActivity(intent);
        }
    }).build()).addItem(new MaterialAboutActionItem.Builder().text(R.string.about_app_text_telegram).icon(new IconDrawable(context, MaterialCommunityIcons.mdi_telegram).colorRes(R.color.sub_text_color).sizeDp(24)).setOnClickAction(new MaterialAboutItemOnClickAction() {

        @Override
        public void onClick() {
            Intent intent = new Intent(Intent.ACTION_VIEW);
            intent.setData(Uri.parse(getString(R.string.about_app_url_telegram)));
            getActivity().startActivity(intent);
        }
    }).build()).addItem(ConvenienceBuilder.createEmailItem(context, new IconDrawable(context, MaterialIcons.md_email).colorRes(R.color.sub_text_color).sizeDp(24), getText(R.string.about_app_text_email), true, getString(R.string.about_app_email), getString(R.string.about_app_email_title)));
    return new MaterialAboutList(appCardBuilder.build(), miscCardBuilder.build(), authorCardBuilder.build());
}
Also used : MaterialAboutList(com.danielstone.materialaboutlibrary.model.MaterialAboutList) MaterialAboutItemOnClickAction(com.danielstone.materialaboutlibrary.items.MaterialAboutItemOnClickAction) MaterialAboutCard(com.danielstone.materialaboutlibrary.model.MaterialAboutCard) ConvenienceBuilder(com.danielstone.materialaboutlibrary.ConvenienceBuilder) MaterialAboutActionItem(com.danielstone.materialaboutlibrary.items.MaterialAboutActionItem) IconDrawable(com.joanzapata.iconify.IconDrawable) Intent(android.content.Intent)

Example 5 with MaterialAboutItemOnClickAction

use of com.danielstone.materialaboutlibrary.items.MaterialAboutItemOnClickAction in project material-about-library by daniel-stoneuk.

the class Demo method createMaterialAboutList.

public static MaterialAboutList createMaterialAboutList(final Context c, final int theme) {
    MaterialAboutCard.Builder appCardBuilder = new MaterialAboutCard.Builder();
    // Add items to card
    appCardBuilder.addItem(new MaterialAboutTitleItem.Builder().text("Material About Library").desc("© 2020 Daniel Stone").icon(R.mipmap.ic_launcher).build());
    appCardBuilder.addItem(ConvenienceBuilder.createVersionActionItem(c, new IconicsDrawable(c).icon(CommunityMaterial.Icon.cmd_information_outline).sizeDp(18), "Version", false));
    appCardBuilder.addItem(new MaterialAboutActionItem.Builder().text("Changelog").icon(new IconicsDrawable(c).icon(CommunityMaterial.Icon.cmd_history).sizeDp(18)).setOnClickAction(ConvenienceBuilder.createWebViewDialogOnClickAction(c, "Releases", "https://github.com/daniel-stoneuk/material-about-library/releases", true, false)).build());
    appCardBuilder.addItem(new MaterialAboutActionItem.Builder().text("Licenses").icon(new IconicsDrawable(c).icon(CommunityMaterial.Icon.cmd_book).sizeDp(18)).setOnClickAction(new MaterialAboutItemOnClickAction() {

        @Override
        public void onClick() {
            Intent intent = new Intent(c, ExampleMaterialAboutLicenseActivity.class);
            intent.putExtra(ExampleMaterialAboutActivity.THEME_EXTRA, theme);
            c.startActivity(intent);
        }
    }).build());
    MaterialAboutCard.Builder authorCardBuilder = new MaterialAboutCard.Builder();
    authorCardBuilder.title("Author");
    // authorCardBuilder.titleColor(ContextCompat.getColor(c, R.color.colorAccent));
    authorCardBuilder.addItem(new MaterialAboutActionItem.Builder().text("Daniel Stone").subText("United Kingdom").icon(new IconicsDrawable(c).icon(CommunityMaterial.Icon.cmd_account).sizeDp(18)).build());
    authorCardBuilder.addItem(new MaterialAboutActionItem.Builder().text("Fork on GitHub").icon(new IconicsDrawable(c).icon(CommunityMaterial.Icon.cmd_github_circle).sizeDp(18)).setOnClickAction(ConvenienceBuilder.createWebsiteOnClickAction(c, Uri.parse("https://github.com/daniel-stoneuk"))).build());
    MaterialAboutCard.Builder convenienceCardBuilder = new MaterialAboutCard.Builder();
    convenienceCardBuilder.title("Convenience Builder");
    convenienceCardBuilder.addItem(ConvenienceBuilder.createVersionActionItem(c, new IconicsDrawable(c).icon(CommunityMaterial.Icon.cmd_information_outline).sizeDp(18), "Version", false));
    convenienceCardBuilder.addItem(ConvenienceBuilder.createWebsiteActionItem(c, new IconicsDrawable(c).icon(CommunityMaterial.Icon.cmd_earth).sizeDp(18), "Visit Website", true, Uri.parse("http://danstone.uk")));
    convenienceCardBuilder.addItem(ConvenienceBuilder.createRateActionItem(c, new IconicsDrawable(c).icon(CommunityMaterial.Icon.cmd_star).sizeDp(18), "Rate this app", null));
    convenienceCardBuilder.addItem(ConvenienceBuilder.createEmailItem(c, new IconicsDrawable(c).icon(CommunityMaterial.Icon.cmd_email).sizeDp(18), "Send an email", true, "apps@danstone.uk", "Question concerning MaterialAboutLibrary"));
    convenienceCardBuilder.addItem(ConvenienceBuilder.createPhoneItem(c, new IconicsDrawable(c).icon(CommunityMaterial.Icon.cmd_phone).sizeDp(18), "Call me", true, "+44 12 3456 7890"));
    convenienceCardBuilder.addItem(ConvenienceBuilder.createMapItem(c, new IconicsDrawable(c).icon(CommunityMaterial.Icon.cmd_map).sizeDp(18), "Visit London", null, "London Eye"));
    MaterialAboutCard.Builder otherCardBuilder = new MaterialAboutCard.Builder();
    otherCardBuilder.title("Other");
    otherCardBuilder.outline(false);
    otherCardBuilder.cardColor(Color.parseColor("#c0cfff"));
    otherCardBuilder.addItem(new MaterialAboutActionItem.Builder().icon(new IconicsDrawable(c).icon(CommunityMaterial.Icon.cmd_language_html5).sizeDp(18)).text("HTML Formatted Sub Text").subTextHtml("This is <b>HTML</b> formatted <i>text</i> <br /> This is very cool because it allows lines to get very long which can lead to all kinds of possibilities. <br /> And line breaks. <br /> Oh and by the way, this card has a custom defined background.").setIconGravity(MaterialAboutActionItem.GRAVITY_TOP).build());
    return new MaterialAboutList(appCardBuilder.build(), authorCardBuilder.build(), convenienceCardBuilder.build(), otherCardBuilder.build());
}
Also used : MaterialAboutTitleItem(com.danielstone.materialaboutlibrary.items.MaterialAboutTitleItem) MaterialAboutItemOnClickAction(com.danielstone.materialaboutlibrary.items.MaterialAboutItemOnClickAction) MaterialAboutCard(com.danielstone.materialaboutlibrary.model.MaterialAboutCard) ConvenienceBuilder(com.danielstone.materialaboutlibrary.ConvenienceBuilder) MaterialAboutActionItem(com.danielstone.materialaboutlibrary.items.MaterialAboutActionItem) Intent(android.content.Intent) MaterialAboutList(com.danielstone.materialaboutlibrary.model.MaterialAboutList) IconicsDrawable(com.mikepenz.iconics.IconicsDrawable)

Aggregations

MaterialAboutItemOnClickAction (com.danielstone.materialaboutlibrary.items.MaterialAboutItemOnClickAction)11 Intent (android.content.Intent)7 ActivityNotFoundException (android.content.ActivityNotFoundException)5 MaterialAboutActionItem (com.danielstone.materialaboutlibrary.items.MaterialAboutActionItem)5 ConvenienceBuilder (com.danielstone.materialaboutlibrary.ConvenienceBuilder)4 IconicsDrawable (com.mikepenz.iconics.IconicsDrawable)4 MaterialAboutCard (com.danielstone.materialaboutlibrary.model.MaterialAboutCard)3 MaterialAboutTitleItem (com.danielstone.materialaboutlibrary.items.MaterialAboutTitleItem)2 MaterialAboutList (com.danielstone.materialaboutlibrary.model.MaterialAboutList)2 DialogInterface (android.content.DialogInterface)1 Uri (android.net.Uri)1 WebView (android.webkit.WebView)1 NonNull (androidx.annotation.NonNull)1 AlertDialog (androidx.appcompat.app.AlertDialog)1 IconDrawable (com.joanzapata.iconify.IconDrawable)1 ArrayList (java.util.ArrayList)1 Library (net.yslibrary.licenseadapter.Library)1 LicenseAdapter (net.yslibrary.licenseadapter.LicenseAdapter)1