1
0
Fork 0
mirror of https://github.com/ethauvin/android-about-box.git synced 2025-04-25 02:37:11 -07:00

Compare commits

...

44 commits

Author SHA1 Message Date
mikemee
097f246870 Merge pull request #39 from eggheadgames/improve-share-message
Improve share message
2017-10-08 12:04:26 -07:00
Michael Mee
c3e6dca4c8 Increment build tools to the latest 25.x point release 2017-10-08 11:59:15 -07:00
Michael Mee
da75a1835c Bump version for immediate release 2017-10-08 11:52:21 -07:00
Michael Mee
b577541efa Prepend sharing message to the URL 2017-10-08 11:52:04 -07:00
mikemee
51d0b9fcbb Merge pull request #38 from eggheadgames/release-1-3-0
Release 1.3.0 with latest Material About Box
2017-10-08 11:08:02 -07:00
mikemee
5b6719dd13 Release 1.3.0 with latest Material About Box 2017-10-08 11:02:19 -07:00
mikemee
210c48d2ed Merge pull request #37 from ethauvin/develop
Move to Material About Library 2.2.1
2017-10-08 10:59:16 -07:00
fac8415ad9 Moved to version 2.2.1 of the material-about-library. 2017-09-01 23:28:00 -07:00
5df77387e6 Changed publisher URLs to https.
Workaround for invalid developer URL.
2017-09-01 23:25:03 -07:00
mikemee
5cf889dd42 Merge pull request #36 from eggheadgames/release-1.2.2
Release 1.2.2 with fix from #35
2017-09-01 11:07:44 -07:00
Michael Mee
77e3a67097 Release 1.2.2 with fix from #35 2017-09-01 11:02:35 -07:00
mikemee
4fe12914a9 Merge pull request #35 from ethauvin/develop
Handle both publisher or developer page.
2017-09-01 11:00:45 -07:00
Michael Mee
b5729bcfdf Merge branch 'develop'
* develop:
2017-09-01 10:52:33 -07:00
6fbb16f264 Handle both publisher or developer page. 2017-08-31 09:12:11 -07:00
mikemee
696fea95ee Merge pull request #32 from eggheadgames/release/1.2.1
Release 1.2.1
2017-08-30 16:06:35 -07:00
mikemee
c6fae1ad37 Merge pull request #33 from eggheadgames/release/1.2.1
Release/1.2.1 to master
2017-08-30 16:05:39 -07:00
Michael Mee
0fb1c6fb8d Correct downloads URL 2017-08-30 16:00:52 -07:00
Michael Mee
d6fe7c6975 Fix bracket imbalance for License badge 2017-08-30 15:59:26 -07:00
Michael Mee
e957ef5b56 Release 1.2.1 2017-08-30 15:57:45 -07:00
mikemee
0d52e41e48 Merge pull request #31 from ethauvin/develop
Author & Extra & About Company.
2017-08-30 15:36:35 -07:00
71c6c60762 Bring intent to font, to treat the activity as a single instance on background/resume. 2017-08-25 08:58:18 -07:00
546a95373a Added support for HTML in config.extra. 2017-08-22 11:13:23 -07:00
666ae83137 Added config.author, config.extra and config.extraTitle to general info card. 2017-08-22 10:56:18 -07:00
5f556fe8ce Do not display config.aboutLabelTitle if empty. 2017-08-22 10:55:31 -07:00
mikemee
85132d5e50 Merge pull request #29 from ethauvin/develop
Various Minor Fixes
2017-08-22 06:34:57 -07:00
337b7dafb3 Added default case to switch per PMD report. 2017-08-22 00:23:15 -07:00
3ae1c381d1 Made constants final per FindBugs report. 2017-08-22 00:09:03 -07:00
134ebebb61 Force CircleCI trigger. 2017-08-21 23:56:46 -07:00
0ebb478771 Added default shareMessage if not set. 2017-08-21 15:22:16 -07:00
852005c24e Fixed home page URL cleaning for display. 2017-08-21 14:52:44 -07:00
9d708b650f Switched to proper link to Publisher, per official documentation. 2017-08-21 14:22:22 -07:00
AlexDibrivnyy
83c54ea02f Merge pull request #28 from eggheadgames/release_1.2.0
Release 1.2.0 to master
2017-05-16 22:41:06 +03:00
AlexDibrivnyy
e8e817ed30 Merge pull request #27 from eggheadgames/release_1.2.0
Update Readme file
2017-05-16 22:35:01 +03:00
mikemee
1a79efd84a Edit sharing information, adjust styling 2017-05-16 12:25:38 -07:00
Alex Dibrivnyi
139cd11741 Updated Readme file. Incremented version number 2017-05-16 22:13:11 +03:00
AlexDibrivnyy
4e3900f40c Merge pull request #26 from eggheadgames/feature/remove_branch_io
Remove dependancy on Branch.io
2017-05-16 20:47:45 +03:00
Alex Dibrivnyi
3cf3fc8f47 merged 2017-05-16 20:09:11 +03:00
mikemee
ddca85d1b3 Merge pull request #25 from eggheadgames/feature/null_check_to_protect_from_crash
Fix "Force close on launching AboutActivity"
2017-05-16 07:06:15 -07:00
Alexandr Dibrivnyi
1ad0a69002 Added activity context 2017-05-16 12:50:32 +03:00
Alex Dibrivnyi
fc4c2ee3ab Fixed pmd 2017-05-16 00:01:42 +03:00
Alex Dibrivnyi
170c879b10 Removed branch io. We need to try to integrate this version to real app and test (CLose #24) 2017-05-15 23:55:50 +03:00
Alex Dibrivnyi
a3ea5e4d90 Tried to fix GOD class pmd fail 2017-05-15 23:40:57 +03:00
Alex Dibrivnyi
11f7abc55f added null checks to protect lib from crashes 2017-05-15 23:13:25 +03:00
mikemee
93ae9c499e Merge pull request #21 from eggheadgames/release/1.1.0
Release 1.1.0
2017-04-14 10:19:08 -07:00
11 changed files with 352 additions and 297 deletions

View file

@ -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.1.0, you can also optionally provide a help file with the `aboutConfig.guideHtmlPath` setting. Leave it unset (null or empty string) and the behaviour is compatible with version 1.0.x.
You can omit most features if they don't apply (e.g. like website), by not setting the values.
## Installation Instructions
@ -34,12 +36,7 @@ dependencies {
}
```
## Example
### Setup Branch.io
Branch.io integration can be found [here](https://github.com/BranchMetrics/android-branch-deep-linking)
### Setup AboutBox
## Setup AboutBox
Add AboutBox configuration to your Application class
@ -48,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;
@ -90,23 +88,41 @@ Add AboutBox configuration to your Application class
aboutConfig.emailSubject = EMAIL_SUBJECT;
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 AboutBox screen
## Open the About Box from your app
```java
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
Add to your AndroidManifest.xml file
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"/>
@ -120,7 +136,7 @@ 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>

View file

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

View file

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

View file

@ -0,0 +1,109 @@
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,6 +8,9 @@ public class AboutConfig {
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;
@ -21,9 +24,10 @@ public class AboutConfig {
public BuildType buildType;
public String packageName;
// custom analytics and dialog
// custom analytics, dialog and share
public IAnalytic analytics;
public IDialog dialog;
public IShare share;
// email
public String emailAddress;
@ -31,7 +35,6 @@ public class AboutConfig {
public String emailBody;
// share
public String shareMessageTitle;
public String shareMessage;
public String sharingTitle;

View file

@ -0,0 +1,9 @@
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;
import android.app.Activity;
import android.content.ActivityNotFoundException;
import android.content.Context;
import android.content.Intent;
import android.net.Uri;
import android.support.annotation.NonNull;
import android.text.TextUtils;
import android.widget.Toast;
import com.danielstone.materialaboutlibrary.MaterialAboutActivity;
import com.danielstone.materialaboutlibrary.items.MaterialAboutActionItem;
import com.danielstone.materialaboutlibrary.items.MaterialAboutItemOnClickListener;
import com.danielstone.materialaboutlibrary.items.MaterialAboutItemOnClickAction;
import com.danielstone.materialaboutlibrary.items.MaterialAboutTitleItem;
import com.danielstone.materialaboutlibrary.model.MaterialAboutCard;
import com.danielstone.materialaboutlibrary.model.MaterialAboutList;
import com.eggheadgames.aboutbox.AboutBoxUtils;
import com.eggheadgames.aboutbox.AboutConfig;
import com.eggheadgames.aboutbox.IAnalytic;
import com.eggheadgames.aboutbox.R;
@ -25,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);
}
@ -34,13 +33,13 @@ public class AboutActivity extends MaterialAboutActivity {
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();
.addCard(buildGeneralInfoCard(config))
.addCard(buildSupportCard(config))
.addCard(buildShareCard(config))
.addCard(buildAboutCard(config))
.addCard(buildSocialNetworksCard(config))
.addCard(buildPrivacyCard(config))
.build();
}
@NonNull
@ -56,6 +55,21 @@ public class AboutActivity extends MaterialAboutActivity {
.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();
}
@ -65,27 +79,27 @@ public class AboutActivity extends MaterialAboutActivity {
if (!TextUtils.isEmpty(config.guideHtmlPath)) {
card.addItem(itemHelper(R.string.egab_guide, R.drawable.ic_help_green,
new MaterialAboutItemOnClickListener() {
@Override
public void onClick(boolean b) {
if (config.dialog == null) {
openHTMLPage(config.guideHtmlPath);
} else {
config.dialog.open(AboutActivity.this, config.guideHtmlPath, getString(R.string.egab_guide));
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));
}
logUIEventName(config.analytics, config.logUiEventName, getString(R.string.egab_guide));
}
})
})
);
}
card.addItem(itemHelper(R.string.egab_contact_support, R.drawable.ic_email_black,
new MaterialAboutItemOnClickListener() {
@Override
public void onClick(boolean b) {
EmailUtil.contactUs(AboutActivity.this);
logUIEventName(config.analytics, config.logUiEventName, getString(R.string.egab_contact_log_event));
}
}));
new MaterialAboutItemOnClickAction() {
@Override
public void onClick() {
EmailUtil.contactUs(AboutActivity.this);
logUIEventName(config.analytics, config.logUiEventName, getString(R.string.egab_contact_log_event));
}
}));
return card.build();
}
@ -93,144 +107,156 @@ public class AboutActivity extends MaterialAboutActivity {
@NonNull
private MaterialAboutCard buildShareCard(final AboutConfig config) {
MaterialAboutCard.Builder card = new MaterialAboutCard.Builder();
card.addItem(itemHelper(R.string.egab_leave_review, R.drawable.ic_review,
new MaterialAboutItemOnClickListener() {
@Override
public void onClick(boolean b) {
openApp(config.buildType, config.packageName);
logUIEventName(config.analytics, config.logUiEventName, getString(R.string.egab_review_log_event));
}
}));
if (config.buildType != null && !TextUtils.isEmpty(config.packageName)) {
card.addItem(itemHelper(R.string.egab_leave_review, R.drawable.ic_review,
new MaterialAboutItemOnClickAction() {
@Override
public void onClick() {
AboutBoxUtils.openApp(AboutActivity.this, config.buildType, config.packageName);
logUIEventName(config.analytics, config.logUiEventName, getString(R.string.egab_review_log_event));
}
}));
}
card.addItem(itemHelper(R.string.egab_share, R.drawable.ic_share_black,
new MaterialAboutItemOnClickListener() {
@Override
public void onClick(boolean b) {
ShareUtil.share(AboutActivity.this);
logUIEventName(config.analytics, config.logUiEventName, getString(R.string.egab_share_log_event));
}
}));
new MaterialAboutItemOnClickAction() {
@Override
public void onClick() {
if (config.share == null) {
ShareUtil.share(AboutActivity.this);
} else {
config.share.share(AboutActivity.this);
}
logUIEventName(config.analytics, config.logUiEventName, getString(R.string.egab_share_log_event));
}
}));
return card.build();
}
@NonNull
private MaterialAboutCard buildAboutCard(final AboutConfig config) {
MaterialAboutCard.Builder card = new MaterialAboutCard.Builder();
card.addItem(itemHelper(R.string.egab_try_other_apps, R.drawable.ic_try_other_apps,
new MaterialAboutItemOnClickListener() {
@Override
public void onClick(boolean b) {
openPublisher(config.buildType, config.appPublisher, config.packageName);
logUIEventName(config.analytics, config.logUiEventName, getString(R.string.egab_try_other_app_log_event));
}
}));
card.addItem(new MaterialAboutActionItem.Builder()
.text(config.aboutLabelTitle)
.icon(R.drawable.ic_about_black)
.setOnClickListener(new MaterialAboutItemOnClickListener() {
@Override
public void onClick(boolean b) {
if (config.dialog == null) {
openHTMLPage(config.companyHtmlPath);
} else {
config.dialog.open(AboutActivity.this, config.companyHtmlPath, config.aboutLabelTitle);
}
logUIEventName(config.analytics, config.logUiEventName, config.aboutLabelTitle);
}
})
.build());
if (config.buildType != null && !TextUtils.isEmpty(config.appPublisher) && !TextUtils.isEmpty(config.packageName)) {
card.addItem(itemHelper(R.string.egab_try_other_apps, R.drawable.ic_try_other_apps,
new MaterialAboutItemOnClickAction() {
@Override
public void onClick() {
AboutBoxUtils.openPublisher(AboutActivity.this, config.buildType,
config.appPublisher, config.packageName);
logUIEventName(config.analytics, 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()
.text(config.aboutLabelTitle)
.icon(R.drawable.ic_about_black)
.setOnClickAction(new MaterialAboutItemOnClickAction() {
@Override
public void onClick() {
if (config.dialog == null) {
AboutBoxUtils.openHTMLPage(AboutActivity.this, config.companyHtmlPath);
} else {
config.dialog.open(AboutActivity.this, config.companyHtmlPath, config.aboutLabelTitle);
}
logUIEventName(config.analytics, config.logUiEventName, config.aboutLabelTitle);
}
})
.build());
}
return card.build();
}
@NonNull
private MaterialAboutCard buildSocialNetworksCard(final AboutConfig config) {
MaterialAboutCard.Builder card = new MaterialAboutCard.Builder();
card.addItem(new MaterialAboutActionItem.Builder()
.text(R.string.egab_facebook_label)
.subText(config.facebookUserName)
.icon(R.drawable.ic_facebook_24)
.setOnClickListener(new MaterialAboutItemOnClickListener() {
@Override
public void onClick(boolean b) {
getOpenFacebookIntent(AboutActivity.this, config.facebookUserName);
logUIEventName(config.analytics, config.logUiEventName, getString(R.string.egab_facebook_log_event));
}
})
.build());
card.addItem(new MaterialAboutActionItem.Builder()
.text(R.string.egab_twitter_label)
.subText(config.twitterUserName)
.icon(R.drawable.ic_twitter_24dp)
.setOnClickListener(new MaterialAboutItemOnClickListener() {
@Override
public void onClick(boolean b) {
startTwitter(AboutActivity.this, config.twitterUserName);
logUIEventName(config.analytics, config.logUiEventName, getString(R.string.egab_twitter_log_event));
}
})
.build());
card.addItem(new MaterialAboutActionItem.Builder()
.text(R.string.egab_web_label)
.subText(config.webHomePage.replace("https://", "").replace("http://", "").replace("/", ""))
.icon(R.drawable.ic_web_black_24dp)
.setOnClickListener(new MaterialAboutItemOnClickListener() {
@Override
public void onClick(boolean b) {
openHTMLPage(config.webHomePage);
logUIEventName(config.analytics, config.logUiEventName, getString(R.string.egab_website_log_event));
}
})
.build());
if (!TextUtils.isEmpty(config.facebookUserName)) {
card.addItem(new MaterialAboutActionItem.Builder()
.text(R.string.egab_facebook_label)
.subText(config.facebookUserName)
.icon(R.drawable.ic_facebook_24)
.setOnClickAction(new MaterialAboutItemOnClickAction() {
@Override
public void onClick() {
AboutBoxUtils.getOpenFacebookIntent(AboutActivity.this, config.facebookUserName);
logUIEventName(config.analytics, config.logUiEventName, getString(R.string.egab_facebook_log_event));
}
})
.build());
}
if (!TextUtils.isEmpty(config.twitterUserName)) {
card.addItem(new MaterialAboutActionItem.Builder()
.text(R.string.egab_twitter_label)
.subText(config.twitterUserName)
.icon(R.drawable.ic_twitter_24dp)
.setOnClickAction(new MaterialAboutItemOnClickAction() {
@Override
public void onClick() {
AboutBoxUtils.startTwitter(AboutActivity.this, config.twitterUserName);
logUIEventName(config.analytics, config.logUiEventName, getString(R.string.egab_twitter_log_event));
}
})
.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
private MaterialAboutCard buildPrivacyCard(final AboutConfig config) {
MaterialAboutCard.Builder card = new MaterialAboutCard.Builder();
if (!TextUtils.isEmpty(config.privacyHtmlPath)) {
card.addItem(itemHelper(R.string.egab_privacy_policy, R.drawable.ic_privacy,
new MaterialAboutItemOnClickAction() {
@Override
public void onClick() {
if (config.dialog == null) {
AboutBoxUtils.openHTMLPage(AboutActivity.this, config.privacyHtmlPath);
} else {
config.dialog.open(AboutActivity.this, config.privacyHtmlPath, getString(R.string.egab_privacy_policy));
}
card.addItem(itemHelper(R.string.egab_privacy_policy, R.drawable.ic_privacy,
new MaterialAboutItemOnClickListener() {
@Override
public void onClick(boolean b) {
if (config.dialog == null) {
openHTMLPage(config.privacyHtmlPath);
} else {
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));
}
})
);
card.addItem(itemHelper(R.string.egab_acknowledgements, R.drawable.ic_acknowledgements,
new MaterialAboutItemOnClickListener() {
@Override
public void onClick(boolean b) {
if (config.dialog == null) {
openHTMLPage(config.acknowledgmentHtmlPath);
} else {
config.dialog.open(AboutActivity.this, config.acknowledgmentHtmlPath, getString(R.string.egab_acknowledgements));
}
logUIEventName(config.analytics, config.logUiEventName, getString(R.string.egab_acknowledgements_log_event));
}
})
);
logUIEventName(config.analytics, config.logUiEventName, getString(R.string.egab_privacy_log_event));
}
})
);
}
if (!TextUtils.isEmpty(config.acknowledgmentHtmlPath)) {
card.addItem(itemHelper(R.string.egab_acknowledgements, R.drawable.ic_acknowledgements,
new MaterialAboutItemOnClickAction() {
@Override
public void onClick() {
if (config.dialog == null) {
AboutBoxUtils.openHTMLPage(AboutActivity.this, config.acknowledgmentHtmlPath);
} else {
config.dialog.open(AboutActivity.this, config.acknowledgmentHtmlPath, getString(R.string.egab_acknowledgements));
}
logUIEventName(config.analytics, config.logUiEventName, getString(R.string.egab_acknowledgements_log_event));
}
})
);
}
return card.build();
}
private MaterialAboutActionItem itemHelper(int name, int icon, MaterialAboutItemOnClickListener listener) {
private MaterialAboutActionItem itemHelper(int name, int icon, MaterialAboutItemOnClickAction clickAction) {
return new MaterialAboutActionItem.Builder()
.text(name)
.icon(icon)
.setOnClickListener(listener)
.build();
.text(name)
.icon(icon)
.setOnClickAction(clickAction)
.build();
}
@ -239,89 +265,6 @@ public class AboutActivity extends MaterialAboutActivity {
return getString(R.string.egab_about_screen_title);
}
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 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
}
openApplication(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
}
openApplication(appURI, webURI);
}
private void openApplication(String appURI, String webURI) {
try {
startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse(appURI)));
} catch (ActivityNotFoundException e1) {
try {
openHTMLPage(webURI);
} catch (ActivityNotFoundException e2) {
Toast.makeText(this, R.string.egab_can_not_open, Toast.LENGTH_SHORT).show();
}
}
}
private void openHTMLPage(String htmlPath) {
startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse(htmlPath)));
}
private void logUIEventName(IAnalytic analytics, String eventType, String eventValue) {
if (analytics != null) {
analytics.logUiEvent(eventType, eventValue);

View file

@ -1,17 +1,12 @@
package com.eggheadgames.aboutbox.share;
import android.app.Activity;
import android.content.Intent;
import android.text.TextUtils;
import com.eggheadgames.aboutbox.AboutBoxUtils;
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 {
private ShareUtil() {
@ -19,48 +14,29 @@ public final class ShareUtil {
}
public static void share(Activity activity) {
BranchUniversalObject branchUniversalObject = new BranchUniversalObject();
final AboutConfig config = AboutConfig.getInstance();
AboutConfig config = AboutConfig.getInstance();
ShareSheetStyle shareSheetStyle = new ShareSheetStyle(activity, config.shareMessageTitle,
config.shareMessage)
.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);
Intent intent2 = new Intent();
intent2.setAction(Intent.ACTION_SEND);
intent2.setType("text/plain");
branchUniversalObject.showShareSheet(activity,
new LinkProperties(), shareSheetStyle, new Branch.BranchLinkShareListener() {
@Override
public void onShareLinkDialogLaunched() {
//nothing
}
String shareMessage = config.shareMessage;
@Override
public void onShareLinkDialogDismissed() {
if (config.analytics != null) {
config.analytics.logUiEvent("Share", "Dismissed");
}
}
if (!TextUtils.isEmpty(config.packageName) && !TextUtils.isEmpty(shareMessage) && config.buildType != null) {
switch (config.buildType) {
case GOOGLE:
shareMessage = shareMessage + AboutBoxUtils.playStoreAppURI + config.packageName;
break;
case AMAZON:
shareMessage = shareMessage + AboutBoxUtils.amznStoreAppURI + config.packageName;
break;
default:
break;
}
}
@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
}
});
intent2.putExtra(Intent.EXTRA_TEXT, shareMessage);
activity.startActivity(Intent.createChooser(intent2, config.sharingTitle));
}
}

View file

@ -3,6 +3,7 @@
<string name="egab_contact_support">Contactar o Suporte</string>
<string name="egab_try_other_apps">Experimentar outras aplicações</string>
<string name="egab_version">Versão</string>
<string name="egab_author">Autor</string>
<string name="egab_facebook_label">Facebook</string>
<string name="egab_twitter_label">Twitter</string>
<string name="egab_web_label">Web</string>

View file

@ -3,6 +3,7 @@
<string name="egab_contact_support">Contact Support</string>
<string name="egab_try_other_apps">Try Other Apps</string>
<string name="egab_version">Version</string>
<string name="egab_author">Author</string>
<string name="egab_facebook_label">Facebook</string>
<string name="egab_twitter_label">Twitter</string>
<string name="egab_web_label">Web</string>

View file

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