mirror of
https://github.com/ethauvin/android-about-box.git
synced 2025-04-25 02:37:11 -07:00
Merge pull request #28 from eggheadgames/release_1.2.0
Release 1.2.0 to master
This commit is contained in:
commit
83c54ea02f
7 changed files with 293 additions and 294 deletions
42
README.md
42
README.md
|
@ -12,7 +12,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.
|
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.
|
As of version 1.2.0, you can omit many features that don't apply (e.g. like website), by not setting the values.
|
||||||
|
|
||||||
## Installation Instructions
|
## Installation Instructions
|
||||||
|
|
||||||
|
@ -34,12 +34,7 @@ dependencies {
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
## Example
|
## Setup AboutBox
|
||||||
### 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
|
||||||
|
|
||||||
|
@ -90,23 +85,40 @@ 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 AboutBox screen
|
## Open the About Box from your app
|
||||||
|
|
||||||
```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);
|
||||||
|
```
|
||||||
|
|
||||||
|
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
|
## 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
|
<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"/>
|
||||||
|
@ -120,7 +132,7 @@ Theme.Mal.Dark.LightActionBar
|
||||||
Theme.Mal.Dark.DarkActionBar
|
Theme.Mal.Dark.DarkActionBar
|
||||||
```
|
```
|
||||||
|
|
||||||
```
|
```xml
|
||||||
<style name="AppTheme.MaterialAboutActivity" parent="Theme.Mal.Light.DarkActionBar" >
|
<style name="AppTheme.MaterialAboutActivity" parent="Theme.Mal.Light.DarkActionBar" >
|
||||||
<!-- Customize your theme here. -->
|
<!-- Customize your theme here. -->
|
||||||
<item name="colorPrimary">@color/colorPrimary</item>
|
<item name="colorPrimary">@color/colorPrimary</item>
|
||||||
|
|
|
@ -12,7 +12,7 @@ android {
|
||||||
minSdkVersion 15
|
minSdkVersion 15
|
||||||
targetSdkVersion 24
|
targetSdkVersion 24
|
||||||
versionCode 4
|
versionCode 4
|
||||||
versionName "1.1.0"
|
versionName "1.2.0"
|
||||||
}
|
}
|
||||||
buildTypes {
|
buildTypes {
|
||||||
release {
|
release {
|
||||||
|
@ -29,7 +29,4 @@ android {
|
||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
compile 'com.github.daniel-stoneuk:material-about-library:1.8.2'
|
compile 'com.github.daniel-stoneuk:material-about-library:1.8.2'
|
||||||
compile('io.branch.sdk.android:library:2.6.1') {
|
|
||||||
exclude module: 'answers.shim'
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,97 @@
|
||||||
|
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 {
|
||||||
|
|
||||||
|
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 = "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(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:
|
||||||
|
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(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)));
|
||||||
|
}
|
||||||
|
}
|
|
@ -21,9 +21,10 @@ public class AboutConfig {
|
||||||
public BuildType buildType;
|
public BuildType buildType;
|
||||||
public String packageName;
|
public String packageName;
|
||||||
|
|
||||||
// custom analytics and dialog
|
// custom analytics, dialog and share
|
||||||
public IAnalytic analytics;
|
public IAnalytic analytics;
|
||||||
public IDialog dialog;
|
public IDialog dialog;
|
||||||
|
public IShare share;
|
||||||
|
|
||||||
// email
|
// email
|
||||||
public String emailAddress;
|
public String emailAddress;
|
||||||
|
@ -31,7 +32,6 @@ 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;
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,9 @@
|
||||||
|
package com.eggheadgames.aboutbox;
|
||||||
|
|
||||||
|
|
||||||
|
import android.app.Activity;
|
||||||
|
|
||||||
|
public interface IShare {
|
||||||
|
|
||||||
|
void share(Activity activity);
|
||||||
|
}
|
|
@ -1,13 +1,10 @@
|
||||||
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.net.Uri;
|
|
||||||
import android.support.annotation.NonNull;
|
import android.support.annotation.NonNull;
|
||||||
import android.text.TextUtils;
|
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.items.MaterialAboutActionItem;
|
||||||
|
@ -15,6 +12,7 @@ import com.danielstone.materialaboutlibrary.items.MaterialAboutItemOnClickListen
|
||||||
import com.danielstone.materialaboutlibrary.items.MaterialAboutTitleItem;
|
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.eggheadgames.aboutbox.AboutConfig;
|
import com.eggheadgames.aboutbox.AboutConfig;
|
||||||
import com.eggheadgames.aboutbox.IAnalytic;
|
import com.eggheadgames.aboutbox.IAnalytic;
|
||||||
import com.eggheadgames.aboutbox.R;
|
import com.eggheadgames.aboutbox.R;
|
||||||
|
@ -34,13 +32,13 @@ public class AboutActivity extends MaterialAboutActivity {
|
||||||
final AboutConfig config = AboutConfig.getInstance();
|
final AboutConfig config = AboutConfig.getInstance();
|
||||||
|
|
||||||
return new MaterialAboutList.Builder()
|
return new MaterialAboutList.Builder()
|
||||||
.addCard(buildGeneralInfoCard(config))
|
.addCard(buildGeneralInfoCard(config))
|
||||||
.addCard(buildSupportCard(config))
|
.addCard(buildSupportCard(config))
|
||||||
.addCard(buildShareCard(config))
|
.addCard(buildShareCard(config))
|
||||||
.addCard(buildAboutCard(config))
|
.addCard(buildAboutCard(config))
|
||||||
.addCard(buildSocialNetworksCard(config))
|
.addCard(buildSocialNetworksCard(config))
|
||||||
.addCard(buildPrivacyCard(config))
|
.addCard(buildPrivacyCard(config))
|
||||||
.build();
|
.build();
|
||||||
}
|
}
|
||||||
|
|
||||||
@NonNull
|
@NonNull
|
||||||
|
@ -65,27 +63,27 @@ public class AboutActivity extends MaterialAboutActivity {
|
||||||
|
|
||||||
if (!TextUtils.isEmpty(config.guideHtmlPath)) {
|
if (!TextUtils.isEmpty(config.guideHtmlPath)) {
|
||||||
card.addItem(itemHelper(R.string.egab_guide, R.drawable.ic_help_green,
|
card.addItem(itemHelper(R.string.egab_guide, R.drawable.ic_help_green,
|
||||||
new MaterialAboutItemOnClickListener() {
|
new MaterialAboutItemOnClickListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onClick(boolean b) {
|
public void onClick(boolean b) {
|
||||||
if (config.dialog == null) {
|
if (config.dialog == null) {
|
||||||
openHTMLPage(config.guideHtmlPath);
|
AboutBoxUtils.openHTMLPage(AboutActivity.this, config.guideHtmlPath);
|
||||||
} else {
|
} else {
|
||||||
config.dialog.open(AboutActivity.this, config.guideHtmlPath, getString(R.string.egab_guide));
|
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,
|
card.addItem(itemHelper(R.string.egab_contact_support, R.drawable.ic_email_black,
|
||||||
new MaterialAboutItemOnClickListener() {
|
new MaterialAboutItemOnClickListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onClick(boolean b) {
|
public void onClick(boolean b) {
|
||||||
EmailUtil.contactUs(AboutActivity.this);
|
EmailUtil.contactUs(AboutActivity.this);
|
||||||
logUIEventName(config.analytics, config.logUiEventName, getString(R.string.egab_contact_log_event));
|
logUIEventName(config.analytics, config.logUiEventName, getString(R.string.egab_contact_log_event));
|
||||||
}
|
}
|
||||||
}));
|
}));
|
||||||
|
|
||||||
return card.build();
|
return card.build();
|
||||||
}
|
}
|
||||||
|
@ -93,144 +91,156 @@ public class AboutActivity extends MaterialAboutActivity {
|
||||||
@NonNull
|
@NonNull
|
||||||
private MaterialAboutCard buildShareCard(final AboutConfig config) {
|
private MaterialAboutCard buildShareCard(final AboutConfig config) {
|
||||||
MaterialAboutCard.Builder card = new MaterialAboutCard.Builder();
|
MaterialAboutCard.Builder card = new MaterialAboutCard.Builder();
|
||||||
|
if (config.buildType != null && !TextUtils.isEmpty(config.packageName)) {
|
||||||
card.addItem(itemHelper(R.string.egab_leave_review, R.drawable.ic_review,
|
card.addItem(itemHelper(R.string.egab_leave_review, R.drawable.ic_review,
|
||||||
new MaterialAboutItemOnClickListener() {
|
new MaterialAboutItemOnClickListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onClick(boolean b) {
|
public void onClick(boolean b) {
|
||||||
openApp(config.buildType, config.packageName);
|
AboutBoxUtils.openApp(AboutActivity.this, config.buildType, config.packageName);
|
||||||
logUIEventName(config.analytics, config.logUiEventName, getString(R.string.egab_review_log_event));
|
logUIEventName(config.analytics, config.logUiEventName, getString(R.string.egab_review_log_event));
|
||||||
}
|
}
|
||||||
}));
|
}));
|
||||||
|
}
|
||||||
card.addItem(itemHelper(R.string.egab_share, R.drawable.ic_share_black,
|
card.addItem(itemHelper(R.string.egab_share, R.drawable.ic_share_black,
|
||||||
new MaterialAboutItemOnClickListener() {
|
new MaterialAboutItemOnClickListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onClick(boolean b) {
|
public void onClick(boolean b) {
|
||||||
ShareUtil.share(AboutActivity.this);
|
if (config.share == null) {
|
||||||
logUIEventName(config.analytics, config.logUiEventName, getString(R.string.egab_share_log_event));
|
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();
|
return card.build();
|
||||||
}
|
}
|
||||||
|
|
||||||
@NonNull
|
@NonNull
|
||||||
private MaterialAboutCard buildAboutCard(final AboutConfig config) {
|
private MaterialAboutCard buildAboutCard(final AboutConfig config) {
|
||||||
MaterialAboutCard.Builder card = new MaterialAboutCard.Builder();
|
MaterialAboutCard.Builder card = new MaterialAboutCard.Builder();
|
||||||
|
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,
|
card.addItem(itemHelper(R.string.egab_try_other_apps, R.drawable.ic_try_other_apps,
|
||||||
new MaterialAboutItemOnClickListener() {
|
new MaterialAboutItemOnClickListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onClick(boolean b) {
|
public void onClick(boolean b) {
|
||||||
openPublisher(config.buildType, config.appPublisher, config.packageName);
|
AboutBoxUtils.openPublisher(AboutActivity.this, config.buildType,
|
||||||
logUIEventName(config.analytics, config.logUiEventName, getString(R.string.egab_try_other_app_log_event));
|
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)
|
if (!TextUtils.isEmpty(config.companyHtmlPath)) {
|
||||||
.setOnClickListener(new MaterialAboutItemOnClickListener() {
|
card.addItem(new MaterialAboutActionItem.Builder()
|
||||||
@Override
|
.text(config.aboutLabelTitle)
|
||||||
public void onClick(boolean b) {
|
.icon(R.drawable.ic_about_black)
|
||||||
if (config.dialog == null) {
|
.setOnClickListener(new MaterialAboutItemOnClickListener() {
|
||||||
openHTMLPage(config.companyHtmlPath);
|
@Override
|
||||||
} else {
|
public void onClick(boolean b) {
|
||||||
config.dialog.open(AboutActivity.this, config.companyHtmlPath, config.aboutLabelTitle);
|
if (config.dialog == null) {
|
||||||
}
|
AboutBoxUtils.openHTMLPage(AboutActivity.this, config.companyHtmlPath);
|
||||||
logUIEventName(config.analytics, config.logUiEventName, config.aboutLabelTitle);
|
} else {
|
||||||
}
|
config.dialog.open(AboutActivity.this, config.companyHtmlPath, config.aboutLabelTitle);
|
||||||
})
|
}
|
||||||
.build());
|
logUIEventName(config.analytics, config.logUiEventName, config.aboutLabelTitle);
|
||||||
|
}
|
||||||
|
})
|
||||||
|
.build());
|
||||||
|
}
|
||||||
return card.build();
|
return card.build();
|
||||||
}
|
}
|
||||||
|
|
||||||
@NonNull
|
@NonNull
|
||||||
private MaterialAboutCard buildSocialNetworksCard(final AboutConfig config) {
|
private MaterialAboutCard buildSocialNetworksCard(final AboutConfig config) {
|
||||||
MaterialAboutCard.Builder card = new MaterialAboutCard.Builder();
|
MaterialAboutCard.Builder card = new MaterialAboutCard.Builder();
|
||||||
|
if (!TextUtils.isEmpty(config.facebookUserName)) {
|
||||||
card.addItem(new MaterialAboutActionItem.Builder()
|
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)
|
||||||
.setOnClickListener(new MaterialAboutItemOnClickListener() {
|
.setOnClickListener(new MaterialAboutItemOnClickListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onClick(boolean b) {
|
public void onClick(boolean b) {
|
||||||
getOpenFacebookIntent(AboutActivity.this, config.facebookUserName);
|
AboutBoxUtils.getOpenFacebookIntent(AboutActivity.this, config.facebookUserName);
|
||||||
logUIEventName(config.analytics, config.logUiEventName, getString(R.string.egab_facebook_log_event));
|
logUIEventName(config.analytics, config.logUiEventName, getString(R.string.egab_facebook_log_event));
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
.build());
|
.build());
|
||||||
card.addItem(new MaterialAboutActionItem.Builder()
|
}
|
||||||
.text(R.string.egab_twitter_label)
|
if (!TextUtils.isEmpty(config.twitterUserName)) {
|
||||||
.subText(config.twitterUserName)
|
card.addItem(new MaterialAboutActionItem.Builder()
|
||||||
.icon(R.drawable.ic_twitter_24dp)
|
.text(R.string.egab_twitter_label)
|
||||||
.setOnClickListener(new MaterialAboutItemOnClickListener() {
|
.subText(config.twitterUserName)
|
||||||
@Override
|
.icon(R.drawable.ic_twitter_24dp)
|
||||||
public void onClick(boolean b) {
|
.setOnClickListener(new MaterialAboutItemOnClickListener() {
|
||||||
startTwitter(AboutActivity.this, config.twitterUserName);
|
@Override
|
||||||
logUIEventName(config.analytics, config.logUiEventName, getString(R.string.egab_twitter_log_event));
|
public void onClick(boolean b) {
|
||||||
}
|
AboutBoxUtils.startTwitter(AboutActivity.this, config.twitterUserName);
|
||||||
})
|
logUIEventName(config.analytics, config.logUiEventName, getString(R.string.egab_twitter_log_event));
|
||||||
.build());
|
}
|
||||||
|
})
|
||||||
card.addItem(new MaterialAboutActionItem.Builder()
|
.build());
|
||||||
.text(R.string.egab_web_label)
|
}
|
||||||
.subText(config.webHomePage.replace("https://", "").replace("http://", "").replace("/", ""))
|
if (!TextUtils.isEmpty(config.webHomePage)) {
|
||||||
.icon(R.drawable.ic_web_black_24dp)
|
card.addItem(new MaterialAboutActionItem.Builder()
|
||||||
.setOnClickListener(new MaterialAboutItemOnClickListener() {
|
.text(R.string.egab_web_label)
|
||||||
@Override
|
.subText(config.webHomePage.replace("https://", "").replace("http://", "").replace("/", ""))
|
||||||
public void onClick(boolean b) {
|
.icon(R.drawable.ic_web_black_24dp)
|
||||||
openHTMLPage(config.webHomePage);
|
.setOnClickListener(new MaterialAboutItemOnClickListener() {
|
||||||
logUIEventName(config.analytics, config.logUiEventName, getString(R.string.egab_website_log_event));
|
@Override
|
||||||
}
|
public void onClick(boolean b) {
|
||||||
})
|
AboutBoxUtils.openHTMLPage(AboutActivity.this, config.webHomePage);
|
||||||
.build());
|
logUIEventName(config.analytics, config.logUiEventName, getString(R.string.egab_website_log_event));
|
||||||
|
}
|
||||||
|
})
|
||||||
|
.build());
|
||||||
|
}
|
||||||
return card.build();
|
return card.build();
|
||||||
}
|
}
|
||||||
|
|
||||||
@NonNull
|
@NonNull
|
||||||
private MaterialAboutCard buildPrivacyCard(final AboutConfig config) {
|
private MaterialAboutCard buildPrivacyCard(final AboutConfig config) {
|
||||||
MaterialAboutCard.Builder card = new MaterialAboutCard.Builder();
|
MaterialAboutCard.Builder card = new MaterialAboutCard.Builder();
|
||||||
|
if (!TextUtils.isEmpty(config.privacyHtmlPath)) {
|
||||||
|
card.addItem(itemHelper(R.string.egab_privacy_policy, R.drawable.ic_privacy,
|
||||||
|
new MaterialAboutItemOnClickListener() {
|
||||||
|
@Override
|
||||||
|
public void onClick(boolean b) {
|
||||||
|
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,
|
logUIEventName(config.analytics, config.logUiEventName, getString(R.string.egab_privacy_log_event));
|
||||||
new MaterialAboutItemOnClickListener() {
|
}
|
||||||
@Override
|
})
|
||||||
public void onClick(boolean b) {
|
);
|
||||||
if (config.dialog == null) {
|
}
|
||||||
openHTMLPage(config.privacyHtmlPath);
|
if (!TextUtils.isEmpty(config.acknowledgmentHtmlPath)) {
|
||||||
} else {
|
card.addItem(itemHelper(R.string.egab_acknowledgements, R.drawable.ic_acknowledgements,
|
||||||
config.dialog.open(AboutActivity.this, config.privacyHtmlPath, getString(R.string.egab_privacy_policy));
|
new MaterialAboutItemOnClickListener() {
|
||||||
}
|
@Override
|
||||||
|
public void onClick(boolean b) {
|
||||||
logUIEventName(config.analytics, config.logUiEventName, getString(R.string.egab_privacy_log_event));
|
if (config.dialog == null) {
|
||||||
}
|
AboutBoxUtils.openHTMLPage(AboutActivity.this, config.acknowledgmentHtmlPath);
|
||||||
})
|
} else {
|
||||||
);
|
config.dialog.open(AboutActivity.this, config.acknowledgmentHtmlPath, getString(R.string.egab_acknowledgements));
|
||||||
card.addItem(itemHelper(R.string.egab_acknowledgements, R.drawable.ic_acknowledgements,
|
}
|
||||||
new MaterialAboutItemOnClickListener() {
|
logUIEventName(config.analytics, config.logUiEventName, getString(R.string.egab_acknowledgements_log_event));
|
||||||
@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));
|
|
||||||
}
|
|
||||||
})
|
|
||||||
);
|
|
||||||
return card.build();
|
return card.build();
|
||||||
}
|
}
|
||||||
|
|
||||||
private MaterialAboutActionItem itemHelper(int name, int icon, MaterialAboutItemOnClickListener listener) {
|
private MaterialAboutActionItem itemHelper(int name, int icon, MaterialAboutItemOnClickListener listener) {
|
||||||
return new MaterialAboutActionItem.Builder()
|
return new MaterialAboutActionItem.Builder()
|
||||||
.text(name)
|
.text(name)
|
||||||
.icon(icon)
|
.icon(icon)
|
||||||
.setOnClickListener(listener)
|
.setOnClickListener(listener)
|
||||||
.build();
|
.build();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -239,89 +249,6 @@ public class AboutActivity extends MaterialAboutActivity {
|
||||||
return getString(R.string.egab_about_screen_title);
|
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) {
|
private void logUIEventName(IAnalytic analytics, String eventType, String eventValue) {
|
||||||
if (analytics != null) {
|
if (analytics != null) {
|
||||||
analytics.logUiEvent(eventType, eventValue);
|
analytics.logUiEvent(eventType, eventValue);
|
||||||
|
|
|
@ -1,17 +1,10 @@
|
||||||
package com.eggheadgames.aboutbox.share;
|
package com.eggheadgames.aboutbox.share;
|
||||||
|
|
||||||
import android.app.Activity;
|
import android.app.Activity;
|
||||||
import android.text.TextUtils;
|
import android.content.Intent;
|
||||||
|
|
||||||
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() {
|
||||||
|
@ -19,48 +12,12 @@ public final class ShareUtil {
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void share(Activity activity) {
|
public static void share(Activity activity) {
|
||||||
BranchUniversalObject branchUniversalObject = new BranchUniversalObject();
|
AboutConfig config = AboutConfig.getInstance();
|
||||||
final 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);
|
|
||||||
|
|
||||||
branchUniversalObject.showShareSheet(activity,
|
|
||||||
new LinkProperties(), shareSheetStyle, new Branch.BranchLinkShareListener() {
|
|
||||||
@Override
|
|
||||||
public void onShareLinkDialogLaunched() {
|
|
||||||
//nothing
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onShareLinkDialogDismissed() {
|
|
||||||
if (config.analytics != null) {
|
|
||||||
config.analytics.logUiEvent("Share", "Dismissed");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@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
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
|
Intent intent2 = new Intent();
|
||||||
|
intent2.setAction(Intent.ACTION_SEND);
|
||||||
|
intent2.setType("text/plain");
|
||||||
|
intent2.putExtra(Intent.EXTRA_TEXT, config.shareMessage);
|
||||||
|
activity.startActivity(Intent.createChooser(intent2, config.sharingTitle));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue