Search in sources :

Example 6 with MaterialAboutList

use of com.danielstone.materialaboutlibrary.model.MaterialAboutList in project Giua-App by Giua-app.

the class AboutActivity method getMaterialAboutList.

@NonNull
@Override
protected MaterialAboutList getMaterialAboutList(@NonNull Context context) {
    loggerManager = new LoggerManager("AboutActivity", this);
    loggerManager.d("getMaterialAboutList chiamato");
    loggerManager.d("costruisco pagina about...");
    importantInteger += 160 + 120 + 20 - 1;
    MaterialAboutCard.Builder appCardBuilder = new MaterialAboutCard.Builder();
    // Add items to card
    appCardBuilder.addItem(new MaterialAboutTitleItem.Builder().text("Giua App").desc("L'app non ufficiale per registri giua@school").icon(R.mipmap.ic_launcher).build());
    appCardBuilder.addItem(ConvenienceBuilder.createVersionActionItem(this, new IconicsDrawable(this).icon(CommunityMaterial.Icon2.cmd_information_outline).sizeDp(18), "Versione", false).setOnClickAction(this::justANormalJavaFunction));
    appCardBuilder.addItem(new MaterialAboutActionItem.Builder().text("Changelog").icon(new IconicsDrawable(this).icon(CommunityMaterial.Icon2.cmd_history).sizeDp(18)).setOnClickAction(() -> {
        loggerManager.d("Mostro dialogo changelog");
        new Thread(() -> {
            String body = AppUpdateManager.buildChangelogForHTML(new AppUpdateManager(this).getReleasesJson());
            final SpannableString txt = new SpannableString(Html.fromHtml(body, 0));
            Linkify.addLinks(txt, Linkify.ALL);
            runOnUiThread(() -> {
                final AlertDialog d = new AlertDialog.Builder(this).setTitle("Changelog").setMessage(txt).setPositiveButton("Chiudi", (dialog, id) -> dialog.dismiss()).setCancelable(true).create();
                d.show();
                ((TextView) d.findViewById(android.R.id.message)).setMovementMethod(LinkMovementMethod.getInstance());
            });
        }).start();
    }).build());
    appCardBuilder.addItem(new MaterialAboutActionItem.Builder().text("Privacy Policy").icon(new IconicsDrawable(this).icon(CommunityMaterial.Icon2.cmd_lock).sizeDp(18)).setOnClickAction(() -> {
        loggerManager.d("Mostro dialogo privacy");
        String body = getString(R.string.privacy);
        final SpannableString txt = new SpannableString(Html.fromHtml(body, 0));
        Linkify.addLinks(txt, Linkify.ALL);
        final AlertDialog d = new AlertDialog.Builder(this).setTitle("Privacy Policy").setMessage(txt).setPositiveButton("Chiudi", (dialog, id) -> dialog.dismiss()).setCancelable(true).create();
        d.show();
        ((TextView) d.findViewById(android.R.id.message)).setMovementMethod(LinkMovementMethod.getInstance());
    }).build());
    appCardBuilder.addItem(new MaterialAboutActionItem.Builder().text("Licenze").icon(new IconicsDrawable(this).icon(CommunityMaterial.Icon.cmd_book).sizeDp(18)).setOnClickAction(() -> {
        Intent intent = new Intent(getBaseContext(), AboutLicenseActivity.class);
        intent.putExtra("", getIntent().getIntExtra("", 0));
        context.startActivity(intent);
    }).build());
    MaterialAboutCard.Builder authorCardBuilder = new MaterialAboutCard.Builder();
    authorCardBuilder.title("Sviluppatori");
    // authorCardBuilder.titleColor(ContextCompat.getColor(c, R.color.colorAccent));
    authorCardBuilder.addItem(new MaterialAboutActionItem.Builder().text("Hiem").icon(new IconicsDrawable(this).icon(CommunityMaterial.Icon.cmd_account).sizeDp(18)).build());
    authorCardBuilder.addItem(new MaterialAboutActionItem.Builder().text("Franck1421").icon(new IconicsDrawable(this).icon(CommunityMaterial.Icon.cmd_account).sizeDp(18)).build());
    authorCardBuilder.addItem(new MaterialAboutActionItem.Builder().text("Krek3r").icon(new IconicsDrawable(this).icon(CommunityMaterial.Icon.cmd_account).sizeDp(18)).build());
    authorCardBuilder.addItem(new MaterialAboutActionItem.Builder().text("Source code su GitHub").icon(new IconicsDrawable(this).icon(CommunityMaterial.Icon.cmd_github_circle).sizeDp(18)).setOnClickAction(ConvenienceBuilder.createWebViewDialogOnClickAction(this, "", "Chiudi", "https://github.com/Giua-app/Giua-App", true, false)).build());
    authorCardBuilder.addItem(new MaterialAboutActionItem.Builder().text("Sito web ufficiale").icon(new IconicsDrawable(this).icon(CommunityMaterial.Icon2.cmd_web).sizeDp(18)).setOnClickAction(ConvenienceBuilder.createWebsiteOnClickAction(this, Uri.parse("https://giua-app.github.io"))).build());
    MaterialAboutCard.Builder otherCardBuilder = new MaterialAboutCard.Builder();
    otherCardBuilder.title("Altro");
    otherCardBuilder.addItem(new MaterialAboutActionItem.Builder().text("Guarda gli analytics pubblici").icon(new IconicsDrawable(this).icon(CommunityMaterial.Icon.cmd_google_analytics).sizeDp(18)).setOnClickAction(ConvenienceBuilder.createWebsiteOnClickAction(this, Uri.parse("https://app.posthog.com/shared_dashboard/m3EBhJ_T3dsd4rl3HV399mwKj8szDg"))).build());
    loggerManager.d("Creazione pagina about completata");
    return new MaterialAboutList(appCardBuilder.build(), authorCardBuilder.build(), otherCardBuilder.build());
}
Also used : AlertDialog(androidx.appcompat.app.AlertDialog) MaterialAboutCard(com.danielstone.materialaboutlibrary.model.MaterialAboutCard) Context(android.content.Context) AlertDialog(androidx.appcompat.app.AlertDialog) NonNull(androidx.annotation.NonNull) Uri(android.net.Uri) OpenSourceLicense(com.danielstone.materialaboutlibrary.util.OpenSourceLicense) MaterialAboutList(com.danielstone.materialaboutlibrary.model.MaterialAboutList) Intent(android.content.Intent) IconicsDrawable(com.mikepenz.iconics.IconicsDrawable) LinkMovementMethod(android.text.method.LinkMovementMethod) Linkify(android.text.util.Linkify) R(com.giua.app.R) ConvenienceBuilder(com.danielstone.materialaboutlibrary.ConvenienceBuilder) Analytics(com.giua.app.Analytics) CommunityMaterial(com.mikepenz.community_material_typeface_library.CommunityMaterial) AppUpdateManager(com.giua.app.AppUpdateManager) SpannableString(android.text.SpannableString) MaterialAboutActivity(com.danielstone.materialaboutlibrary.MaterialAboutActivity) TextView(android.widget.TextView) Nullable(androidx.annotation.Nullable) MaterialAboutTitleItem(com.danielstone.materialaboutlibrary.items.MaterialAboutTitleItem) Html(android.text.Html) Snackbar(com.google.android.material.snackbar.Snackbar) MaterialAboutActionItem(com.danielstone.materialaboutlibrary.items.MaterialAboutActionItem) LoggerManager(com.giua.app.LoggerManager) MaterialAboutTitleItem(com.danielstone.materialaboutlibrary.items.MaterialAboutTitleItem) MaterialAboutCard(com.danielstone.materialaboutlibrary.model.MaterialAboutCard) ConvenienceBuilder(com.danielstone.materialaboutlibrary.ConvenienceBuilder) MaterialAboutActionItem(com.danielstone.materialaboutlibrary.items.MaterialAboutActionItem) Intent(android.content.Intent) SpannableString(android.text.SpannableString) AppUpdateManager(com.giua.app.AppUpdateManager) SpannableString(android.text.SpannableString) MaterialAboutList(com.danielstone.materialaboutlibrary.model.MaterialAboutList) LoggerManager(com.giua.app.LoggerManager) TextView(android.widget.TextView) IconicsDrawable(com.mikepenz.iconics.IconicsDrawable) NonNull(androidx.annotation.NonNull)

Example 7 with MaterialAboutList

use of com.danielstone.materialaboutlibrary.model.MaterialAboutList 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

MaterialAboutList (com.danielstone.materialaboutlibrary.model.MaterialAboutList)7 MaterialAboutCard (com.danielstone.materialaboutlibrary.model.MaterialAboutCard)6 IconicsDrawable (com.mikepenz.iconics.IconicsDrawable)6 MaterialAboutActionItem (com.danielstone.materialaboutlibrary.items.MaterialAboutActionItem)4 Intent (android.content.Intent)3 ConvenienceBuilder (com.danielstone.materialaboutlibrary.ConvenienceBuilder)3 MaterialAboutItemOnClickAction (com.danielstone.materialaboutlibrary.items.MaterialAboutItemOnClickAction)2 MaterialAboutTitleItem (com.danielstone.materialaboutlibrary.items.MaterialAboutTitleItem)2 Context (android.content.Context)1 Uri (android.net.Uri)1 Html (android.text.Html)1 SpannableString (android.text.SpannableString)1 LinkMovementMethod (android.text.method.LinkMovementMethod)1 Linkify (android.text.util.Linkify)1 TextView (android.widget.TextView)1 NonNull (androidx.annotation.NonNull)1 Nullable (androidx.annotation.Nullable)1 AlertDialog (androidx.appcompat.app.AlertDialog)1 MaterialAboutActivity (com.danielstone.materialaboutlibrary.MaterialAboutActivity)1 OpenSourceLicense (com.danielstone.materialaboutlibrary.util.OpenSourceLicense)1