1
0
Fork 0
mirror of https://github.com/ethauvin/android-about-box.git synced 2025-04-27 03:18:13 -07:00

Compare commits

..

No commits in common. "master" and "1.0.1" have entirely different histories.

13 changed files with 312 additions and 435 deletions

View file

@ -1,7 +1,5 @@
[![Circle CI](https://circleci.com/gh/eggheadgames/android-about-box.svg?style=svg)](https://circleci.com/gh/eggheadgames/android-about-box) [![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) [![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 # 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). A modern About Box for an Android App built on the [daniel-stoneuk/material-about-library](https://github.com/daniel-stoneuk/material-about-library).
@ -14,8 +12,6 @@ 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. 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.
You can omit most features if they don't apply (e.g. like website), by not setting the values.
## Installation Instructions ## Installation Instructions
Add the JitPack.io repository to your root `build.gradle`: Add the JitPack.io repository to your root `build.gradle`:
@ -36,7 +32,12 @@ dependencies {
} }
``` ```
## Setup AboutBox ## Example
### Setup Branch.io
Branch.io integration can be found [here](https://github.com/BranchMetrics/android-branch-deep-linking)
### Setup AboutBox
Add AboutBox configuration to your Application class Add AboutBox configuration to your Application class
@ -45,7 +46,6 @@ Add AboutBox configuration to your Application class
aboutConfig.appName = getString(R.string.app_name); aboutConfig.appName = getString(R.string.app_name);
aboutConfig.appIcon = R.mipmap.ic_launcher; aboutConfig.appIcon = R.mipmap.ic_launcher;
aboutConfig.version = "1.0.0"; aboutConfig.version = "1.0.0";
aboutConfig.author = "Tolstoy";
aboutConfig.aboutLabelTitle = "About App"; aboutConfig.aboutLabelTitle = "About App";
aboutConfig.packageName = getApplicationContext().getPackageName(); aboutConfig.packageName = getApplicationContext().getPackageName();
aboutConfig.buildType = google ? AboutConfig.BuildType.GOOGLE : AboutConfig.BuildType.AMAZON; aboutConfig.buildType = google ? AboutConfig.BuildType.GOOGLE : AboutConfig.BuildType.AMAZON;
@ -88,62 +88,18 @@ Add AboutBox configuration to your Application class
aboutConfig.emailSubject = EMAIL_SUBJECT; aboutConfig.emailSubject = EMAIL_SUBJECT;
aboutConfig.emailBody = EMAIL_BODY; aboutConfig.emailBody = EMAIL_BODY;
// Branch.io labels.
aboutConfig.shareMessageTitle = getString(R.string.share_message_title);
aboutConfig.shareMessage = getString(R.string.share_message);
aboutConfig.sharingTitle = getString(R.string.sharing_title);
``` ```
## Open the About Box from your app Open AboutBox screen
```java ```java
AboutActivity.launch(activity); AboutActivity.launch(activity);
``` ```
## Sharing
By default, the default Android share intent will be called with the values specified in `shareMessage` and `sharingTitle`. For example:
```java
aboutConfig.shareMessage = getString(R.string.share_message);
aboutConfig.sharingTitle = getString(R.string.sharing_title);
```
The `share_message` string will have an app store URL appended to it (appropriately constructed for Google Play or Amazon).
Alternatively, you can provide a custom sharing function (and omit `shareMessage` and `sharingTitle`):
```java
aboutConfig.share = new IShare() {
@Override
public void share(Activity activity) {
// do custom sharing
}
};
```
## Theme
If you add the following to your AndroidManifest.xml file, the About Box will use these colours. This allows you to match your app colours:
```xml
<activity
android:name="com.eggheadgames.aboutbox.activity.AboutActivity"
android:theme="@style/AppTheme.MaterialAboutActivity"/>
```
Ensure that `AppTheme.MaterialAboutActivity` theme extends either of these themes, and apply primary & accent colours:
```
Theme.Mal.Light.DarkActionBar
Theme.Mal.Light.LightActionBar
Theme.Mal.Dark.LightActionBar
Theme.Mal.Dark.DarkActionBar
```
```xml
<style name="AppTheme.MaterialAboutActivity" parent="Theme.Mal.Light.DarkActionBar" >
<!-- Customize your theme here. -->
<item name="colorPrimary">@color/colorPrimary</item>
<item name="colorPrimaryDark">@color/colorPrimaryDark</item>
<item name="colorAccent">@color/colorAccent</item>
</style>
```
## Screenshot ## Screenshot
<img src="extras/example.png?raw=true"> <img src="extras/example.png?raw=true">

View file

@ -1,7 +1,7 @@
dependencies: dependencies:
pre: pre:
- echo y | android update sdk --no-ui --all --filter tools,platform-tools,android-25 - echo y | android update sdk --no-ui --all --filter tools,platform-tools,android-24
- echo y | android update sdk --no-ui --all --filter build-tools-25.0.3 - echo y | android update sdk --no-ui --all --filter build-tools-24.0.2
test: test:
override: override:

View file

@ -5,14 +5,14 @@ apply plugin: 'com.github.dcendents.android-maven'
group='com.github.eggheadgames' group='com.github.eggheadgames'
android { android {
compileSdkVersion 25 compileSdkVersion 24
buildToolsVersion "25.0.3" buildToolsVersion "24.0.2"
defaultConfig { defaultConfig {
minSdkVersion 15 minSdkVersion 15
targetSdkVersion 24 targetSdkVersion 24
versionCode 7 versionCode 2
versionName "1.3.1" versionName "1.0.1"
} }
buildTypes { buildTypes {
release { release {
@ -28,5 +28,8 @@ android {
} }
dependencies { dependencies {
compile 'com.github.daniel-stoneuk:material-about-library:2.2.1' compile 'com.github.daniel-stoneuk:material-about-library:1.5.0'
compile('io.branch.sdk.android:library:2.5.7') {
exclude module: 'answers.shim'
}
} }

View file

@ -1,10 +1,10 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android" <manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.eggheadgames.aboutbox"> package="com.eggheadgames.aboutbox">
<application> <application android:label="@string/app_name">
<activity <activity
android:name="com.eggheadgames.aboutbox.activity.AboutActivity" android:name="com.eggheadgames.aboutbox.activity.AboutActivity"
android:theme="@style/AppTheme.MaterialAboutActivity"/> android:theme="@style/AppTheme.MaterialAboutActivity" />
</application> </application>

View file

@ -1,109 +0,0 @@
package com.eggheadgames.aboutbox;
import android.app.Activity;
import android.content.ActivityNotFoundException;
import android.content.Intent;
import android.net.Uri;
import android.widget.Toast;
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
}
public static void getOpenFacebookIntent(Activity context, String name) {
try {
context.getPackageManager().getPackageInfo("com.facebook.katana", 0);
Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse("fb://profile/" + name));
context.startActivity(intent);
} catch (Exception e) {
try {
Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse("https://www.facebook.com/" + name));
context.startActivity(intent);
} catch (Exception e1) {
Toast.makeText(context, R.string.egab_can_not_open, Toast.LENGTH_SHORT).show();
}
}
}
public static void startTwitter(Activity context, String name) {
try {
context.getPackageManager().getPackageInfo("com.twitter.android", 0);
Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse("twitter://user?screen_name=" + name));
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
context.startActivity(intent);
} catch (Exception e) {
try {
Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse("https://twitter.com/" + name));
context.startActivity(intent);
} catch (Exception e1) {
Toast.makeText(context, R.string.egab_can_not_open, Toast.LENGTH_SHORT).show();
}
}
}
public static void openApp(Activity context, AboutConfig.BuildType buildType, String packageName) {
String appURI = null;
String webURI = null;
switch (buildType) {
case GOOGLE:
appURI = "market://details?id=" + packageName;
webURI = playStoreAppURI + packageName;
break;
case AMAZON:
appURI = "amzn://apps/android?p=" + packageName;
webURI = amznStoreAppURI + packageName;
break;
default:
//nothing
}
openApplication(context, appURI, webURI);
}
public static void openPublisher(Activity context, AboutConfig.BuildType buildType, String publisher, String packageName) {
String appURI = null;
String webURI = null;
switch (buildType) {
case GOOGLE:
// see:
// https://developer.android.com/distribute/marketing-tools/linking-to-google-play.html#OpeningPublisher
// https://stackoverflow.com/questions/32029408/how-to-open-developer-page-on-google-play-store-market
// https://issuetracker.google.com/65244694
if (publisher.matches("\\d+")) {
webURI = "https://play.google.com/store/apps/dev?id=" + publisher;
appURI = webURI;
} else {
appURI = "market://search?q=pub:" + publisher;
webURI = "https://play.google.com/store/search?q=pub:" + publisher;
}
break;
case AMAZON:
appURI = "amzn://apps/android?showAll=1&p=" + packageName;
webURI = "http://www.amazon.com/gp/mas/dl/android?showAll=1&p=" + packageName;
break;
default:
//nothing
}
openApplication(context, appURI, webURI);
}
public static void openApplication(Activity context, String appURI, String webURI) {
try {
context.startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse(appURI)));
} catch (ActivityNotFoundException e1) {
try {
openHTMLPage(context, webURI);
} catch (ActivityNotFoundException e2) {
Toast.makeText(context, R.string.egab_can_not_open, Toast.LENGTH_SHORT).show();
}
}
}
public static void openHTMLPage(Activity context, String htmlPath) {
context.startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse(htmlPath)));
}
}

View file

@ -8,15 +8,11 @@ public class AboutConfig {
public String appName; public String appName;
public int appIcon; public int appIcon;
public String version; public String version;
public String author;
public String extra;
public String extraTitle;
public String aboutLabelTitle; public String aboutLabelTitle;
public String logUiEventName; public String logUiEventName;
public String facebookUserName; public String facebookUserName;
public String twitterUserName; public String twitterUserName;
public String webHomePage; public String webHomePage;
public String guideHtmlPath;
public String appPublisher; public String appPublisher;
public String companyHtmlPath; public String companyHtmlPath;
public String privacyHtmlPath; public String privacyHtmlPath;
@ -24,10 +20,9 @@ public class AboutConfig {
public BuildType buildType; public BuildType buildType;
public String packageName; public String packageName;
// custom analytics, dialog and share // custom analytics and dialog
public IAnalytic analytics; public IAnalytic analytics;
public IDialog dialog; public IDialog dialog;
public IShare share;
// email // email
public String emailAddress; public String emailAddress;
@ -35,6 +30,7 @@ public class AboutConfig {
public String emailBody; public String emailBody;
// share // share
public String shareMessageTitle;
public String shareMessage; public String shareMessage;
public String sharingTitle; public String sharingTitle;

View file

@ -1,9 +0,0 @@
package com.eggheadgames.aboutbox;
import android.app.Activity;
public interface IShare {
void share(Activity activity);
}

View file

@ -1,20 +1,18 @@
package com.eggheadgames.aboutbox.activity; package com.eggheadgames.aboutbox.activity;
import android.app.Activity; import android.app.Activity;
import android.content.ActivityNotFoundException;
import android.content.Context; import android.content.Context;
import android.content.Intent; import android.content.Intent;
import android.support.annotation.NonNull; import android.net.Uri;
import android.text.TextUtils; import android.widget.Toast;
import com.danielstone.materialaboutlibrary.MaterialAboutActivity; import com.danielstone.materialaboutlibrary.MaterialAboutActivity;
import com.danielstone.materialaboutlibrary.items.MaterialAboutActionItem; import com.danielstone.materialaboutlibrary.model.MaterialAboutActionItem;
import com.danielstone.materialaboutlibrary.items.MaterialAboutItemOnClickAction;
import com.danielstone.materialaboutlibrary.items.MaterialAboutTitleItem;
import com.danielstone.materialaboutlibrary.model.MaterialAboutCard; import com.danielstone.materialaboutlibrary.model.MaterialAboutCard;
import com.danielstone.materialaboutlibrary.model.MaterialAboutList; import com.danielstone.materialaboutlibrary.model.MaterialAboutList;
import com.eggheadgames.aboutbox.AboutBoxUtils; import com.danielstone.materialaboutlibrary.model.MaterialAboutTitleItem;
import com.eggheadgames.aboutbox.AboutConfig; import com.eggheadgames.aboutbox.AboutConfig;
import com.eggheadgames.aboutbox.IAnalytic;
import com.eggheadgames.aboutbox.R; import com.eggheadgames.aboutbox.R;
import com.eggheadgames.aboutbox.share.EmailUtil; import com.eggheadgames.aboutbox.share.EmailUtil;
import com.eggheadgames.aboutbox.share.ShareUtil; import com.eggheadgames.aboutbox.share.ShareUtil;
@ -23,7 +21,6 @@ public class AboutActivity extends MaterialAboutActivity {
public static void launch(Activity activity) { public static void launch(Activity activity) {
Intent intent = new Intent(activity, AboutActivity.class); Intent intent = new Intent(activity, AboutActivity.class);
intent.setFlags(Intent.FLAG_ACTIVITY_REORDER_TO_FRONT);
activity.startActivity(intent); activity.startActivity(intent);
} }
@ -32,18 +29,6 @@ public class AboutActivity extends MaterialAboutActivity {
final AboutConfig config = AboutConfig.getInstance(); final AboutConfig config = AboutConfig.getInstance();
return new MaterialAboutList.Builder()
.addCard(buildGeneralInfoCard(config))
.addCard(buildSupportCard(config))
.addCard(buildShareCard(config))
.addCard(buildAboutCard(config))
.addCard(buildSocialNetworksCard(config))
.addCard(buildPrivacyCard(config))
.build();
}
@NonNull
private MaterialAboutCard buildGeneralInfoCard(AboutConfig config) {
MaterialAboutCard.Builder generalInfoCardBuilder = new MaterialAboutCard.Builder(); MaterialAboutCard.Builder generalInfoCardBuilder = new MaterialAboutCard.Builder();
generalInfoCardBuilder.addItem(new MaterialAboutTitleItem.Builder() generalInfoCardBuilder.addItem(new MaterialAboutTitleItem.Builder()
@ -56,218 +41,262 @@ public class AboutActivity extends MaterialAboutActivity {
.subText(config.version) .subText(config.version)
.build()); .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)) { MaterialAboutCard.Builder supportCardBuilder = new MaterialAboutCard.Builder();
generalInfoCardBuilder.addItem(new MaterialAboutActionItem.Builder() supportCardBuilder.addItem(new MaterialAboutActionItem.Builder()
.text(config.extraTitle) .text(R.string.egab_contact_support)
.subTextHtml(config.extra) .icon(R.drawable.ic_email_black)
.build()); .setOnClickListener(new MaterialAboutActionItem.OnClickListener() {
}
return generalInfoCardBuilder.build();
}
@NonNull
private MaterialAboutCard buildSupportCard(final AboutConfig config) {
MaterialAboutCard.Builder card = new MaterialAboutCard.Builder();
if (!TextUtils.isEmpty(config.guideHtmlPath)) {
card.addItem(itemHelper(R.string.egab_guide, R.drawable.ic_help_green,
new MaterialAboutItemOnClickAction() {
@Override
public void onClick() {
if (config.dialog == null) {
AboutBoxUtils.openHTMLPage(AboutActivity.this, config.guideHtmlPath);
} else {
config.dialog.open(AboutActivity.this, config.guideHtmlPath, getString(R.string.egab_guide));
}
logUIEventName(config.analytics, config.logUiEventName, getString(R.string.egab_guide));
}
})
);
}
card.addItem(itemHelper(R.string.egab_contact_support, R.drawable.ic_email_black,
new MaterialAboutItemOnClickAction() {
@Override @Override
public void onClick() { public void onClick() {
EmailUtil.contactUs(AboutActivity.this); EmailUtil.contactUs(AboutActivity.this);
logUIEventName(config.analytics, config.logUiEventName, getString(R.string.egab_contact_log_event)); if (config.analytics != null) {
config.analytics.logUiEvent(config.logUiEventName, getString(R.string.egab_contact_log_event));
} }
}));
return card.build();
} }
})
.build());
@NonNull
private MaterialAboutCard buildShareCard(final AboutConfig config) { MaterialAboutCard.Builder shareCardBuilder = new MaterialAboutCard.Builder();
MaterialAboutCard.Builder card = new MaterialAboutCard.Builder(); shareCardBuilder.addItem(new MaterialAboutActionItem.Builder()
if (config.buildType != null && !TextUtils.isEmpty(config.packageName)) { .text(R.string.egab_leave_review)
card.addItem(itemHelper(R.string.egab_leave_review, R.drawable.ic_review, .icon(R.drawable.ic_review)
new MaterialAboutItemOnClickAction() { .setOnClickListener(new MaterialAboutActionItem.OnClickListener() {
@Override @Override
public void onClick() { public void onClick() {
AboutBoxUtils.openApp(AboutActivity.this, config.buildType, config.packageName); openApp(config.buildType, config.packageName);
logUIEventName(config.analytics, config.logUiEventName, getString(R.string.egab_review_log_event)); if (config.analytics != null) {
config.analytics.logUiEvent(config.logUiEventName, getString(R.string.egab_review_log_event));
} }
}));
} }
card.addItem(itemHelper(R.string.egab_share, R.drawable.ic_share_black, })
new MaterialAboutItemOnClickAction() { .build());
shareCardBuilder.addItem(new MaterialAboutActionItem.Builder()
.text(R.string.egab_share)
.icon(R.drawable.ic_share_black)
.setOnClickListener(new MaterialAboutActionItem.OnClickListener() {
@Override @Override
public void onClick() { public void onClick() {
if (config.share == null) {
ShareUtil.share(AboutActivity.this); ShareUtil.share(AboutActivity.this);
} else { if (config.analytics != null) {
config.share.share(AboutActivity.this); config.analytics.logUiEvent(config.logUiEventName, getString(R.string.egab_share_log_event));
} }
logUIEventName(config.analytics, config.logUiEventName, getString(R.string.egab_share_log_event));
}
}));
return card.build();
} }
})
.build());
@NonNull
private MaterialAboutCard buildAboutCard(final AboutConfig config) { MaterialAboutCard.Builder aboutCardBuilder = new MaterialAboutCard.Builder();
MaterialAboutCard.Builder card = new MaterialAboutCard.Builder(); aboutCardBuilder.addItem(new MaterialAboutActionItem.Builder()
if (config.buildType != null && !TextUtils.isEmpty(config.appPublisher) && !TextUtils.isEmpty(config.packageName)) { .text(R.string.egab_try_other_apps)
card.addItem(itemHelper(R.string.egab_try_other_apps, R.drawable.ic_try_other_apps, .icon(R.drawable.ic_try_other_apps)
new MaterialAboutItemOnClickAction() { .setOnClickListener(new MaterialAboutActionItem.OnClickListener() {
@Override @Override
public void onClick() { public void onClick() {
AboutBoxUtils.openPublisher(AboutActivity.this, config.buildType, openPublisher(config.buildType, config.appPublisher, config.packageName);
config.appPublisher, config.packageName); if (config.analytics != null) {
logUIEventName(config.analytics, config.logUiEventName, getString(R.string.egab_try_other_app_log_event)); config.analytics.logUiEvent(config.logUiEventName, getString(R.string.egab_try_other_app_log_event));
} }
}));
} }
if (!TextUtils.isEmpty(config.companyHtmlPath) && !TextUtils.isEmpty(config.aboutLabelTitle)) { })
card.addItem(new MaterialAboutActionItem.Builder() .build());
aboutCardBuilder.addItem(new MaterialAboutActionItem.Builder()
.text(config.aboutLabelTitle) .text(config.aboutLabelTitle)
.icon(R.drawable.ic_about_black) .icon(R.drawable.ic_about_black)
.setOnClickAction(new MaterialAboutItemOnClickAction() { .setOnClickListener(new MaterialAboutActionItem.OnClickListener() {
@Override @Override
public void onClick() { public void onClick() {
if (config.dialog == null) { if (config.dialog == null) {
AboutBoxUtils.openHTMLPage(AboutActivity.this, config.companyHtmlPath); startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse(config.companyHtmlPath)));
} else { } else {
config.dialog.open(AboutActivity.this, config.companyHtmlPath, config.aboutLabelTitle); config.dialog.open(AboutActivity.this, config.companyHtmlPath, config.aboutLabelTitle);
} }
logUIEventName(config.analytics, config.logUiEventName, config.aboutLabelTitle);
if (config.analytics != null) {
config.analytics.logUiEvent(config.logUiEventName, config.aboutLabelTitle);
}
} }
}) })
.build()); .build());
}
return card.build();
}
@NonNull
private MaterialAboutCard buildSocialNetworksCard(final AboutConfig config) { MaterialAboutCard.Builder socialNetworksCardBuilder = new MaterialAboutCard.Builder();
MaterialAboutCard.Builder card = new MaterialAboutCard.Builder(); socialNetworksCardBuilder.addItem(new MaterialAboutActionItem.Builder()
if (!TextUtils.isEmpty(config.facebookUserName)) {
card.addItem(new MaterialAboutActionItem.Builder()
.text(R.string.egab_facebook_label) .text(R.string.egab_facebook_label)
.subText(config.facebookUserName) .subText(config.facebookUserName)
.icon(R.drawable.ic_facebook_24) .icon(R.drawable.ic_facebook_24)
.setOnClickAction(new MaterialAboutItemOnClickAction() { .setOnClickListener(new MaterialAboutActionItem.OnClickListener() {
@Override @Override
public void onClick() { public void onClick() {
AboutBoxUtils.getOpenFacebookIntent(AboutActivity.this, config.facebookUserName); getOpenFacebookIntent(AboutActivity.this, config.facebookUserName);
logUIEventName(config.analytics, config.logUiEventName, getString(R.string.egab_facebook_log_event)); if (config.analytics != null) {
config.analytics.logUiEvent(config.logUiEventName, getString(R.string.egab_facebook_log_event));
}
} }
}) })
.build()); .build());
} socialNetworksCardBuilder.addItem(new MaterialAboutActionItem.Builder()
if (!TextUtils.isEmpty(config.twitterUserName)) {
card.addItem(new MaterialAboutActionItem.Builder()
.text(R.string.egab_twitter_label) .text(R.string.egab_twitter_label)
.subText(config.twitterUserName) .subText(config.twitterUserName)
.icon(R.drawable.ic_twitter_24dp) .icon(R.drawable.ic_twitter_24dp)
.setOnClickAction(new MaterialAboutItemOnClickAction() { .setOnClickListener(new MaterialAboutActionItem.OnClickListener() {
@Override @Override
public void onClick() { public void onClick() {
AboutBoxUtils.startTwitter(AboutActivity.this, config.twitterUserName); startTwitter(AboutActivity.this, config.twitterUserName);
logUIEventName(config.analytics, config.logUiEventName, getString(R.string.egab_twitter_log_event)); if (config.analytics != null) {
config.analytics.logUiEvent(config.logUiEventName, getString(R.string.egab_twitter_log_event));
}
} }
}) })
.build()); .build());
}
if (!TextUtils.isEmpty(config.webHomePage)) {
card.addItem(new MaterialAboutActionItem.Builder()
.text(R.string.egab_web_label)
.subText(config.webHomePage.replaceFirst("^https?://", "").replaceAll("/$", ""))
.icon(R.drawable.ic_web_black_24dp)
.setOnClickAction(new MaterialAboutItemOnClickAction() {
@Override
public void onClick() {
AboutBoxUtils.openHTMLPage(AboutActivity.this, config.webHomePage);
logUIEventName(config.analytics, config.logUiEventName, getString(R.string.egab_website_log_event));
}
})
.build());
}
return card.build();
}
@NonNull socialNetworksCardBuilder.addItem(new MaterialAboutActionItem.Builder()
private MaterialAboutCard buildPrivacyCard(final AboutConfig config) { .text(R.string.egab_web_label)
MaterialAboutCard.Builder card = new MaterialAboutCard.Builder(); .subText(config.webHomePage.replace("https://", "").replace("http://", "").replace("/", ""))
if (!TextUtils.isEmpty(config.privacyHtmlPath)) { .icon(R.drawable.ic_web_black_24dp)
card.addItem(itemHelper(R.string.egab_privacy_policy, R.drawable.ic_privacy, .setOnClickListener(new MaterialAboutActionItem.OnClickListener() {
new MaterialAboutItemOnClickAction() { @Override
public void onClick() {
startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse(config.webHomePage)));
if (config.analytics != null) {
config.analytics.logUiEvent(config.logUiEventName, getString(R.string.egab_website_log_event));
}
}
})
.build());
MaterialAboutCard.Builder privacyCardBuilder = new MaterialAboutCard.Builder();
privacyCardBuilder.addItem(new MaterialAboutActionItem.Builder()
.text(R.string.egab_privacy_policy)
.icon(R.drawable.ic_privacy)
.setOnClickListener(new MaterialAboutActionItem.OnClickListener() {
@Override @Override
public void onClick() { public void onClick() {
if (config.dialog == null) { if (config.dialog == null) {
AboutBoxUtils.openHTMLPage(AboutActivity.this, config.privacyHtmlPath); startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse(config.privacyHtmlPath)));
} else { } else {
config.dialog.open(AboutActivity.this, config.privacyHtmlPath, getString(R.string.egab_privacy_policy)); config.dialog.open(AboutActivity.this, config.privacyHtmlPath, getString(R.string.egab_privacy_policy));
} }
logUIEventName(config.analytics, config.logUiEventName, getString(R.string.egab_privacy_log_event)); if (config.analytics != null) {
config.analytics.logUiEvent(config.logUiEventName, getString(R.string.egab_privacy_log_event));
}
} }
}) })
); .build());
} privacyCardBuilder.addItem(new MaterialAboutActionItem.Builder()
if (!TextUtils.isEmpty(config.acknowledgmentHtmlPath)) { .text(R.string.egab_acknowledgements)
card.addItem(itemHelper(R.string.egab_acknowledgements, R.drawable.ic_acknowledgements, .icon(R.drawable.ic_acknowledgements)
new MaterialAboutItemOnClickAction() { .setOnClickListener(new MaterialAboutActionItem.OnClickListener() {
@Override @Override
public void onClick() { public void onClick() {
if (config.dialog == null) { if (config.dialog == null) {
AboutBoxUtils.openHTMLPage(AboutActivity.this, config.acknowledgmentHtmlPath); startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse(config.acknowledgmentHtmlPath)));
} else { } else {
config.dialog.open(AboutActivity.this, config.acknowledgmentHtmlPath, getString(R.string.egab_acknowledgements)); config.dialog.open(AboutActivity.this, config.acknowledgmentHtmlPath, getString(R.string.egab_acknowledgements));
} }
logUIEventName(config.analytics, config.logUiEventName, getString(R.string.egab_acknowledgements_log_event));
if (config.analytics != null) {
config.analytics.logUiEvent(config.logUiEventName, getString(R.string.egab_acknowledgements_log_event));
}
} }
}) })
); .build());
}
return card.build();
}
private MaterialAboutActionItem itemHelper(int name, int icon, MaterialAboutItemOnClickAction clickAction) {
return new MaterialAboutActionItem.Builder() return new MaterialAboutList.Builder()
.text(name) .addCard(generalInfoCardBuilder.build())
.icon(icon) .addCard(supportCardBuilder.build())
.setOnClickAction(clickAction) .addCard(shareCardBuilder.build())
.addCard(aboutCardBuilder.build())
.addCard(socialNetworksCardBuilder.build())
.addCard(privacyCardBuilder.build())
.build(); .build();
} }
@Override @Override
protected CharSequence getActivityTitle() { protected CharSequence getActivityTitle() {
return getString(R.string.egab_about_screen_title); return getString(R.string.egab_about_screen_title);
} }
private void logUIEventName(IAnalytic analytics, String eventType, String eventValue) { public static void getOpenFacebookIntent(Activity context, String name) {
if (analytics != null) { try {
analytics.logUiEvent(eventType, eventValue); context.getPackageManager().getPackageInfo("com.facebook.katana", 0);
Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse("fb://profile/" + name));
context.startActivity(intent);
} catch (Exception e) {
try {
Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse("https://www.facebook.com/" + name));
context.startActivity(intent);
} catch (Exception e1) {
Toast.makeText(context, R.string.egab_can_not_open, Toast.LENGTH_SHORT).show();
}
}
}
public static void startTwitter(Activity context, String name) {
try {
context.getPackageManager().getPackageInfo("com.twitter.android", 0);
Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse("twitter://user?screen_name=" + name));
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
context.startActivity(intent);
} catch (Exception e) {
try {
Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse("https://twitter.com/" + name));
context.startActivity(intent);
} catch (Exception e1) {
Toast.makeText(context, R.string.egab_can_not_open, Toast.LENGTH_SHORT).show();
}
}
}
public void openApp(AboutConfig.BuildType buildType, String packageName) {
String appURI = null;
String webURI = null;
switch (buildType) {
case GOOGLE:
appURI = "market://details?id=" + packageName;
webURI = "http://play.google.com/store/apps/details?id=" + packageName;
break;
case AMAZON:
appURI = "amzn://apps/android?p=" + packageName;
webURI = "http://www.amazon.com/gp/mas/dl/android?p=" + packageName;
break;
default:
//nothing
}
open(appURI, webURI);
}
public void openPublisher(AboutConfig.BuildType buildType, String publisher, String packageName) {
String appURI = null;
String webURI = null;
switch (buildType) {
case GOOGLE:
appURI = "market://search?q=pub:" + publisher;
webURI = "http://play.google.com/store/search?q=pub:" + publisher;
break;
case AMAZON:
appURI = "amzn://apps/android?showAll=1&p=" + packageName;
webURI = "http://www.amazon.com/gp/mas/dl/android?showAll=1&p=" + packageName;
break;
default:
//nothing
}
open(appURI, webURI);
}
private void open(String appURI, String webURI) {
try {
startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse(appURI)));
} catch (ActivityNotFoundException e1) {
try {
startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse(webURI)));
} catch (ActivityNotFoundException e2) {
Toast.makeText(this, R.string.egab_can_not_open, Toast.LENGTH_SHORT).show();
}
} }
} }
} }

View file

@ -1,12 +1,17 @@
package com.eggheadgames.aboutbox.share; package com.eggheadgames.aboutbox.share;
import android.app.Activity; import android.app.Activity;
import android.content.Intent;
import android.text.TextUtils; import android.text.TextUtils;
import com.eggheadgames.aboutbox.AboutBoxUtils;
import com.eggheadgames.aboutbox.AboutConfig; import com.eggheadgames.aboutbox.AboutConfig;
import io.branch.indexing.BranchUniversalObject;
import io.branch.referral.Branch;
import io.branch.referral.BranchError;
import io.branch.referral.SharingHelper;
import io.branch.referral.util.LinkProperties;
import io.branch.referral.util.ShareSheetStyle;
public final class ShareUtil { public final class ShareUtil {
private ShareUtil() { private ShareUtil() {
@ -14,29 +19,48 @@ public final class ShareUtil {
} }
public static void share(Activity activity) { public static void share(Activity activity) {
AboutConfig config = AboutConfig.getInstance(); BranchUniversalObject branchUniversalObject = new BranchUniversalObject();
final AboutConfig config = AboutConfig.getInstance();
Intent intent2 = new Intent(); ShareSheetStyle shareSheetStyle = new ShareSheetStyle(activity, config.shareMessageTitle,
intent2.setAction(Intent.ACTION_SEND); config.shareMessage)
intent2.setType("text/plain"); .setCopyUrlStyle(activity.getResources().getDrawable(android.R.drawable.ic_menu_send),
"Copy", "Added to clipboard")
.setMoreOptionStyle(activity.getResources().getDrawable(android.R.drawable.ic_menu_search), "Show more")
.addPreferredSharingOption(SharingHelper.SHARE_WITH.FACEBOOK)
.addPreferredSharingOption(SharingHelper.SHARE_WITH.EMAIL)
.setSharingTitle(config.sharingTitle);
String shareMessage = config.shareMessage; branchUniversalObject.showShareSheet(activity,
new LinkProperties(), shareSheetStyle, new Branch.BranchLinkShareListener() {
@Override
public void onShareLinkDialogLaunched() {
//nothing
}
if (!TextUtils.isEmpty(config.packageName) && !TextUtils.isEmpty(shareMessage) && config.buildType != null) { @Override
switch (config.buildType) { public void onShareLinkDialogDismissed() {
case GOOGLE: if (config.analytics != null) {
shareMessage = shareMessage + AboutBoxUtils.playStoreAppURI + config.packageName; config.analytics.logUiEvent("Share", "Dismissed");
break;
case AMAZON:
shareMessage = shareMessage + AboutBoxUtils.amznStoreAppURI + config.packageName;
break;
default:
break;
} }
} }
intent2.putExtra(Intent.EXTRA_TEXT, shareMessage); @Override
public void onLinkShareResponse(String sharedLink, String sharedChannel, BranchError error) {
if (config.analytics != null) {
if (error == null || TextUtils.isEmpty(error.getMessage())) {
config.analytics.logUiEvent("Share", sharedChannel);
} else {
config.analytics.logUiEvent("Share Failure", error.getMessage());
}
}
}
@Override
public void onChannelSelected(String channelName) {
//nothing
}
});
activity.startActivity(Intent.createChooser(intent2, config.sharingTitle));
} }
} }

View file

@ -1,11 +0,0 @@
<?xml version="1.0"?>
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:viewportHeight="24.0"
android:viewportWidth="24.0">
<path
android:fillColor="#00c853"
android:pathData="M12,2C6.48,2 2,6.48 2,12s4.48,10 10,10 10,-4.48 10,-10S17.52,2 12,2zm1,17h-2v-2h2v2zm2.07,-7.75l-0.9,0.92C13.45,12.9 13,13.5 13,15h-2v-0.5c0,-1.1 0.45,-2.1 1.17,-2.83l1.24,-1.26c0.37,-0.36 0.59,-0.86 0.59,-1.41 0,-1.1 -0.9,-2 -2,-2s-2,0.9 -2,2H8c0,-2.21 1.79,-4 4,-4s4,1.79 4,4c0,0.88 -0.36,1.68 -0.93,2.25z"/>
</vector>

View file

@ -1,9 +1,9 @@
<resources> <resources>
<string name="app_name">AboutBox</string>
<string name="egab_leave_review">Avaliar</string> <string name="egab_leave_review">Avaliar</string>
<string name="egab_contact_support">Contactar o Suporte</string> <string name="egab_contact_support">Contactar o Suporte</string>
<string name="egab_try_other_apps">Experimentar outras aplicações</string> <string name="egab_try_other_apps">Experimentar outras aplicações</string>
<string name="egab_version">Versão</string> <string name="egab_version">Versão</string>
<string name="egab_author">Autor</string>
<string name="egab_facebook_label">Facebook</string> <string name="egab_facebook_label">Facebook</string>
<string name="egab_twitter_label">Twitter</string> <string name="egab_twitter_label">Twitter</string>
<string name="egab_web_label">Web</string> <string name="egab_web_label">Web</string>
@ -22,5 +22,4 @@
<string name="egab_acknowledgements_log_event">Acknowledgements</string> <string name="egab_acknowledgements_log_event">Acknowledgements</string>
<string name="egab_can_not_open">Tu não tens nenhuma aplicação que possa abrir esta ligação</string> <string name="egab_can_not_open">Tu não tens nenhuma aplicação que possa abrir esta ligação</string>
<string name="egab_email_body_prompt">Digite sua pergunta aqui: </string> <string name="egab_email_body_prompt">Digite sua pergunta aqui: </string>
<string name="egab_guide">Guia</string>
</resources> </resources>

View file

@ -1,9 +1,9 @@
<resources> <resources>
<string name="app_name">AboutBox</string>
<string name="egab_leave_review">Leave Review</string> <string name="egab_leave_review">Leave Review</string>
<string name="egab_contact_support">Contact Support</string> <string name="egab_contact_support">Contact Support</string>
<string name="egab_try_other_apps">Try Other Apps</string> <string name="egab_try_other_apps">Try Other Apps</string>
<string name="egab_version">Version</string> <string name="egab_version">Version</string>
<string name="egab_author">Author</string>
<string name="egab_facebook_label">Facebook</string> <string name="egab_facebook_label">Facebook</string>
<string name="egab_twitter_label">Twitter</string> <string name="egab_twitter_label">Twitter</string>
<string name="egab_web_label">Web</string> <string name="egab_web_label">Web</string>
@ -22,6 +22,5 @@
<string name="egab_acknowledgements_log_event">Acknowledgements</string> <string name="egab_acknowledgements_log_event">Acknowledgements</string>
<string name="egab_can_not_open">You don\'t have any app that can open this link</string> <string name="egab_can_not_open">You don\'t have any app that can open this link</string>
<string name="egab_email_body_prompt">Please type your question here: </string> <string name="egab_email_body_prompt">Please type your question here: </string>
<string name="egab_guide">Guide</string>
</resources> </resources>

View file

@ -1,7 +1,7 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<resources> <resources>
<style name="AppTheme.MaterialAboutActivity" parent="Theme.Mal.Light.DarkActionBar" > <style name="AppTheme.MaterialAboutActivity" parent="Theme.Mal" >
<item name="colorPrimary">@color/colorPrimary</item> <item name="colorPrimary">@color/colorPrimary</item>
<item name="colorPrimaryDark">@color/colorPrimaryDark</item> <item name="colorPrimaryDark">@color/colorPrimaryDark</item>
<item name="colorAccent">@color/colorAccent</item> <item name="colorAccent">@color/colorAccent</item>