diff --git a/README.md b/README.md index 72a96a6..9598017 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,7 @@ [![Circle CI](https://circleci.com/gh/eggheadgames/android-about-box.svg?style=svg)](https://circleci.com/gh/eggheadgames/android-about-box) [![Release](https://jitpack.io/v/eggheadgames/android-about-box.svg)](https://jitpack.io/#eggheadgames/android-about-box) +![Downloads](https://jitpack.io/v/eggheadgames/android-about-box/month.svg) +[![GitHub license](https://img.shields.io/badge/license-MIT-blue.svg)](https://github.com/eggheadgames/android-about-box/blob/develop/LICENSE) # About Box A modern About Box for an Android App built on the [daniel-stoneuk/material-about-library](https://github.com/daniel-stoneuk/material-about-library). @@ -12,7 +14,7 @@ Android About Box is configured with a set of (mostly) strings for the company n When triggered from a menu item, it will display the app name, icon and version, provide links to contact support, leave a review, share the app, go to other apps by the same company in the app store -- as well as links to Facebook etc. -As of version 1.2.0, you can omit many features that don't apply (e.g. like website), by not setting the values. +You can omit most features if they don't apply (e.g. like website), by not setting the values. ## Installation Instructions @@ -43,6 +45,7 @@ Add AboutBox configuration to your Application class aboutConfig.appName = getString(R.string.app_name); aboutConfig.appIcon = R.mipmap.ic_launcher; aboutConfig.version = "1.0.0"; + aboutConfig.author = "Tolstoy"; aboutConfig.aboutLabelTitle = "About App"; aboutConfig.packageName = getApplicationContext().getPackageName(); aboutConfig.buildType = google ? AboutConfig.BuildType.GOOGLE : AboutConfig.BuildType.AMAZON; diff --git a/library/build.gradle b/library/build.gradle index 33530f1..123c681 100644 --- a/library/build.gradle +++ b/library/build.gradle @@ -12,7 +12,7 @@ android { minSdkVersion 15 targetSdkVersion 24 versionCode 4 - versionName "1.2.0" + versionName "1.2.1" } buildTypes { release { diff --git a/library/src/main/java/com/eggheadgames/aboutbox/AboutBoxUtils.java b/library/src/main/java/com/eggheadgames/aboutbox/AboutBoxUtils.java index 3b5dace..fc3f654 100644 --- a/library/src/main/java/com/eggheadgames/aboutbox/AboutBoxUtils.java +++ b/library/src/main/java/com/eggheadgames/aboutbox/AboutBoxUtils.java @@ -8,6 +8,9 @@ public final class AboutBoxUtils { + public final static String playStoreAppURI = "https://play.google.com/store/apps/details?id="; + public final static String amznStoreAppURI = "https://www.amazon.com/gp/mas/dl/android?p="; + private AboutBoxUtils() { //nothing } @@ -49,11 +52,11 @@ public static void openApp(Activity context, AboutConfig.BuildType buildType, St switch (buildType) { case GOOGLE: appURI = "market://details?id=" + packageName; - webURI = "http://play.google.com/store/apps/details?id=" + packageName; + webURI = playStoreAppURI + packageName; break; case AMAZON: appURI = "amzn://apps/android?p=" + packageName; - webURI = "http://www.amazon.com/gp/mas/dl/android?p=" + packageName; + webURI = amznStoreAppURI + packageName; break; default: //nothing @@ -66,8 +69,9 @@ public static void openPublisher(Activity context, AboutConfig.BuildType buildTy String webURI = null; switch (buildType) { case GOOGLE: - appURI = "market://search?q=pub:" + publisher; - webURI = "http://play.google.com/store/search?q=pub:" + publisher; + // per: https://developer.android.com/distribute/marketing-tools/linking-to-google-play.html#OpeningPublisher + appURI = "market://dev?id=" + publisher; + webURI = "http://play.google.com/store/dev?id=" + publisher; break; case AMAZON: appURI = "amzn://apps/android?showAll=1&p=" + packageName; diff --git a/library/src/main/java/com/eggheadgames/aboutbox/AboutConfig.java b/library/src/main/java/com/eggheadgames/aboutbox/AboutConfig.java index ed456c3..4929ab6 100644 --- a/library/src/main/java/com/eggheadgames/aboutbox/AboutConfig.java +++ b/library/src/main/java/com/eggheadgames/aboutbox/AboutConfig.java @@ -8,6 +8,9 @@ public enum BuildType {AMAZON, GOOGLE} public String appName; public int appIcon; public String version; + public String author; + public String extra; + public String extraTitle; public String aboutLabelTitle; public String logUiEventName; public String facebookUserName; diff --git a/library/src/main/java/com/eggheadgames/aboutbox/activity/AboutActivity.java b/library/src/main/java/com/eggheadgames/aboutbox/activity/AboutActivity.java index 7d292dc..f2073b6 100644 --- a/library/src/main/java/com/eggheadgames/aboutbox/activity/AboutActivity.java +++ b/library/src/main/java/com/eggheadgames/aboutbox/activity/AboutActivity.java @@ -23,6 +23,7 @@ public class AboutActivity extends MaterialAboutActivity { public static void launch(Activity activity) { Intent intent = new Intent(activity, AboutActivity.class); + intent.setFlags(Intent.FLAG_ACTIVITY_REORDER_TO_FRONT); activity.startActivity(intent); } @@ -54,6 +55,21 @@ private MaterialAboutCard buildGeneralInfoCard(AboutConfig config) { .text(R.string.egab_version) .subText(config.version) .build()); + + if (!TextUtils.isEmpty(config.author)) { + generalInfoCardBuilder.addItem(new MaterialAboutActionItem.Builder() + .text(R.string.egab_author) + .subText(config.author) + .build()); + } + + if (!TextUtils.isEmpty(config.extra) && !TextUtils.isEmpty(config.extraTitle)) { + generalInfoCardBuilder.addItem(new MaterialAboutActionItem.Builder() + .text(config.extraTitle) + .subTextHtml(config.extra) + .build()); + } + return generalInfoCardBuilder.build(); } @@ -130,7 +146,7 @@ public void onClick(boolean b) { } })); } - if (!TextUtils.isEmpty(config.companyHtmlPath)) { + if (!TextUtils.isEmpty(config.companyHtmlPath) && !TextUtils.isEmpty(config.aboutLabelTitle)) { card.addItem(new MaterialAboutActionItem.Builder() .text(config.aboutLabelTitle) .icon(R.drawable.ic_about_black) @@ -184,7 +200,7 @@ public void onClick(boolean b) { if (!TextUtils.isEmpty(config.webHomePage)) { card.addItem(new MaterialAboutActionItem.Builder() .text(R.string.egab_web_label) - .subText(config.webHomePage.replace("https://", "").replace("http://", "").replace("/", "")) + .subText(config.webHomePage.replaceFirst("^https?://", "").replaceAll("/$", "")) .icon(R.drawable.ic_web_black_24dp) .setOnClickListener(new MaterialAboutItemOnClickListener() { @Override diff --git a/library/src/main/java/com/eggheadgames/aboutbox/share/ShareUtil.java b/library/src/main/java/com/eggheadgames/aboutbox/share/ShareUtil.java index 61a4511..851ec00 100644 --- a/library/src/main/java/com/eggheadgames/aboutbox/share/ShareUtil.java +++ b/library/src/main/java/com/eggheadgames/aboutbox/share/ShareUtil.java @@ -2,7 +2,9 @@ import android.app.Activity; import android.content.Intent; +import android.text.TextUtils; +import com.eggheadgames.aboutbox.AboutBoxUtils; import com.eggheadgames.aboutbox.AboutConfig; public final class ShareUtil { @@ -17,7 +19,24 @@ public static void share(Activity activity) { Intent intent2 = new Intent(); intent2.setAction(Intent.ACTION_SEND); intent2.setType("text/plain"); - intent2.putExtra(Intent.EXTRA_TEXT, config.shareMessage); + + String shareMessage = config.shareMessage; + + if (!TextUtils.isEmpty(config.packageName) && !TextUtils.isEmpty(shareMessage) && config.buildType != null) { + switch (config.buildType) { + case GOOGLE: + shareMessage = AboutBoxUtils.playStoreAppURI + config.packageName; + break; + case AMAZON: + shareMessage = AboutBoxUtils.amznStoreAppURI + config.packageName; + break; + default: + break; + } + } + + intent2.putExtra(Intent.EXTRA_TEXT, shareMessage); + activity.startActivity(Intent.createChooser(intent2, config.sharingTitle)); } } diff --git a/library/src/main/res/values-pt/strings.xml b/library/src/main/res/values-pt/strings.xml index 0e6a643..18a0b23 100644 --- a/library/src/main/res/values-pt/strings.xml +++ b/library/src/main/res/values-pt/strings.xml @@ -3,6 +3,7 @@ Contactar o Suporte Experimentar outras aplicações Versão + Autor Facebook Twitter Web diff --git a/library/src/main/res/values/strings.xml b/library/src/main/res/values/strings.xml index b979e55..894f9ae 100644 --- a/library/src/main/res/values/strings.xml +++ b/library/src/main/res/values/strings.xml @@ -3,6 +3,7 @@ Contact Support Try Other Apps Version + Author Facebook Twitter Web