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

Merge pull request #10 from eggheadgames/feature/config_fixes

FIxed small errors
This commit is contained in:
mikemee 2017-02-09 16:05:46 -08:00 committed by GitHub
commit ffd2b9c899
5 changed files with 156 additions and 87 deletions

View file

@ -37,21 +37,21 @@ public class AboutActivity extends MaterialAboutActivity {
.build()); .build());
generalInfoCardBuilder.addItem(new MaterialAboutActionItem.Builder() generalInfoCardBuilder.addItem(new MaterialAboutActionItem.Builder()
.text(R.string.version) .text(R.string.egab_version)
.subText(config.version) .subText(config.version)
.build()); .build());
MaterialAboutCard.Builder supportCardBuilder = new MaterialAboutCard.Builder(); MaterialAboutCard.Builder supportCardBuilder = new MaterialAboutCard.Builder();
supportCardBuilder.addItem(new MaterialAboutActionItem.Builder() supportCardBuilder.addItem(new MaterialAboutActionItem.Builder()
.text(R.string.contact_support) .text(R.string.egab_contact_support)
.icon(R.drawable.ic_email_black) .icon(R.drawable.ic_email_black)
.setOnClickListener(new MaterialAboutActionItem.OnClickListener() { .setOnClickListener(new MaterialAboutActionItem.OnClickListener() {
@Override @Override
public void onClick() { public void onClick() {
EmailUtil.contactUs(AboutActivity.this); EmailUtil.contactUs(AboutActivity.this);
if (config.analytics != null) { if (config.analytics != null) {
config.analytics.logUiEvent(config.logUiEventName, getString(R.string.contact_log_event)); config.analytics.logUiEvent(config.logUiEventName, getString(R.string.egab_contact_log_event));
} }
} }
}) })
@ -60,27 +60,27 @@ public class AboutActivity extends MaterialAboutActivity {
MaterialAboutCard.Builder shareCardBuilder = new MaterialAboutCard.Builder(); MaterialAboutCard.Builder shareCardBuilder = new MaterialAboutCard.Builder();
shareCardBuilder.addItem(new MaterialAboutActionItem.Builder() shareCardBuilder.addItem(new MaterialAboutActionItem.Builder()
.text(R.string.leave_review) .text(R.string.egab_leave_review)
.icon(R.drawable.ic_review) .icon(R.drawable.ic_review)
.setOnClickListener(new MaterialAboutActionItem.OnClickListener() { .setOnClickListener(new MaterialAboutActionItem.OnClickListener() {
@Override @Override
public void onClick() { public void onClick() {
openApp(config.packageName, config.buildType == AboutConfig.BuildType.GOOGLE); openApp(config.buildType, config.packageName);
if (config.analytics != null) { if (config.analytics != null) {
config.analytics.logUiEvent(config.logUiEventName, getString(R.string.review_log_event)); config.analytics.logUiEvent(config.logUiEventName, getString(R.string.egab_review_log_event));
} }
} }
}) })
.build()); .build());
shareCardBuilder.addItem(new MaterialAboutActionItem.Builder() shareCardBuilder.addItem(new MaterialAboutActionItem.Builder()
.text(R.string.share) .text(R.string.egab_share)
.icon(R.drawable.ic_share_black) .icon(R.drawable.ic_share_black)
.setOnClickListener(new MaterialAboutActionItem.OnClickListener() { .setOnClickListener(new MaterialAboutActionItem.OnClickListener() {
@Override @Override
public void onClick() { public void onClick() {
ShareUtil.share(AboutActivity.this); ShareUtil.share(AboutActivity.this);
if (config.analytics != null) { if (config.analytics != null) {
config.analytics.logUiEvent(config.logUiEventName, getString(R.string.share_log_event)); config.analytics.logUiEvent(config.logUiEventName, getString(R.string.egab_share_log_event));
} }
} }
}) })
@ -89,14 +89,14 @@ public class AboutActivity extends MaterialAboutActivity {
MaterialAboutCard.Builder aboutCardBuilder = new MaterialAboutCard.Builder(); MaterialAboutCard.Builder aboutCardBuilder = new MaterialAboutCard.Builder();
aboutCardBuilder.addItem(new MaterialAboutActionItem.Builder() aboutCardBuilder.addItem(new MaterialAboutActionItem.Builder()
.text(R.string.try_other_apps) .text(R.string.egab_try_other_apps)
.icon(R.drawable.ic_try_other_apps) .icon(R.drawable.ic_try_other_apps)
.setOnClickListener(new MaterialAboutActionItem.OnClickListener() { .setOnClickListener(new MaterialAboutActionItem.OnClickListener() {
@Override @Override
public void onClick() { public void onClick() {
openPublisher(config.buildType == AboutConfig.BuildType.GOOGLE, config.appPublisher); openPublisher(config.buildType, config.appPublisher, config.packageName);
if (config.analytics != null) { if (config.analytics != null) {
config.analytics.logUiEvent(config.logUiEventName, getString(R.string.try_other_app_log_event)); config.analytics.logUiEvent(config.logUiEventName, getString(R.string.egab_try_other_app_log_event));
} }
} }
}) })
@ -123,7 +123,7 @@ public class AboutActivity extends MaterialAboutActivity {
MaterialAboutCard.Builder socialNetworksCardBuilder = new MaterialAboutCard.Builder(); MaterialAboutCard.Builder socialNetworksCardBuilder = new MaterialAboutCard.Builder();
socialNetworksCardBuilder.addItem(new MaterialAboutActionItem.Builder() socialNetworksCardBuilder.addItem(new MaterialAboutActionItem.Builder()
.text(R.string.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 MaterialAboutActionItem.OnClickListener() { .setOnClickListener(new MaterialAboutActionItem.OnClickListener() {
@ -131,13 +131,13 @@ public class AboutActivity extends MaterialAboutActivity {
public void onClick() { public void onClick() {
getOpenFacebookIntent(AboutActivity.this, config.facebookUserName); getOpenFacebookIntent(AboutActivity.this, config.facebookUserName);
if (config.analytics != null) { if (config.analytics != null) {
config.analytics.logUiEvent(config.logUiEventName, getString(R.string.facebook_log_event)); config.analytics.logUiEvent(config.logUiEventName, getString(R.string.egab_facebook_log_event));
} }
} }
}) })
.build()); .build());
socialNetworksCardBuilder.addItem(new MaterialAboutActionItem.Builder() socialNetworksCardBuilder.addItem(new MaterialAboutActionItem.Builder()
.text(R.string.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)
.setOnClickListener(new MaterialAboutActionItem.OnClickListener() { .setOnClickListener(new MaterialAboutActionItem.OnClickListener() {
@ -145,14 +145,14 @@ public class AboutActivity extends MaterialAboutActivity {
public void onClick() { public void onClick() {
startTwitter(AboutActivity.this, config.twitterUserName); startTwitter(AboutActivity.this, config.twitterUserName);
if (config.analytics != null) { if (config.analytics != null) {
config.analytics.logUiEvent(config.logUiEventName, getString(R.string.twitter_log_event)); config.analytics.logUiEvent(config.logUiEventName, getString(R.string.egab_twitter_log_event));
} }
} }
}) })
.build()); .build());
socialNetworksCardBuilder.addItem(new MaterialAboutActionItem.Builder() socialNetworksCardBuilder.addItem(new MaterialAboutActionItem.Builder()
.text(R.string.web_label) .text(R.string.egab_web_label)
.subText(config.webHomePage.replace("https://", "").replace("http://", "").replace("/", "")) .subText(config.webHomePage.replace("https://", "").replace("http://", "").replace("/", ""))
.icon(R.drawable.ic_web_black_24dp) .icon(R.drawable.ic_web_black_24dp)
.setOnClickListener(new MaterialAboutActionItem.OnClickListener() { .setOnClickListener(new MaterialAboutActionItem.OnClickListener() {
@ -160,7 +160,7 @@ public class AboutActivity extends MaterialAboutActivity {
public void onClick() { public void onClick() {
startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse(config.webHomePage))); startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse(config.webHomePage)));
if (config.analytics != null) { if (config.analytics != null) {
config.analytics.logUiEvent(config.logUiEventName, getString(R.string.website_log_event)); config.analytics.logUiEvent(config.logUiEventName, getString(R.string.egab_website_log_event));
} }
} }
}) })
@ -168,7 +168,7 @@ public class AboutActivity extends MaterialAboutActivity {
MaterialAboutCard.Builder privacyCardBuilder = new MaterialAboutCard.Builder(); MaterialAboutCard.Builder privacyCardBuilder = new MaterialAboutCard.Builder();
privacyCardBuilder.addItem(new MaterialAboutActionItem.Builder() privacyCardBuilder.addItem(new MaterialAboutActionItem.Builder()
.text(R.string.privacy_policy) .text(R.string.egab_privacy_policy)
.icon(R.drawable.ic_privacy) .icon(R.drawable.ic_privacy)
.setOnClickListener(new MaterialAboutActionItem.OnClickListener() { .setOnClickListener(new MaterialAboutActionItem.OnClickListener() {
@Override @Override
@ -176,29 +176,29 @@ public class AboutActivity extends MaterialAboutActivity {
if (config.dialog == null) { if (config.dialog == null) {
startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse(config.privacyHtmlPath))); startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse(config.privacyHtmlPath)));
} else { } else {
config.dialog.open(AboutActivity.this, config.privacyHtmlPath, getString(R.string.privacy_policy)); config.dialog.open(AboutActivity.this, config.privacyHtmlPath, getString(R.string.egab_privacy_policy));
} }
if (config.analytics != null) { if (config.analytics != null) {
config.analytics.logUiEvent(config.logUiEventName, getString(R.string.privacy_log_event)); config.analytics.logUiEvent(config.logUiEventName, getString(R.string.egab_privacy_log_event));
} }
} }
}) })
.build()); .build());
privacyCardBuilder.addItem(new MaterialAboutActionItem.Builder() privacyCardBuilder.addItem(new MaterialAboutActionItem.Builder()
.text(R.string.acknowledgment) .text(R.string.egab_acknowledgements)
.icon(R.drawable.ic_acknowledgment) .icon(R.drawable.ic_acknowledgements)
.setOnClickListener(new MaterialAboutActionItem.OnClickListener() { .setOnClickListener(new MaterialAboutActionItem.OnClickListener() {
@Override @Override
public void onClick() { public void onClick() {
if (config.dialog == null) { if (config.dialog == null) {
startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse(config.acknowledgmentHtmlPath))); startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse(config.acknowledgmentHtmlPath)));
} else { } else {
config.dialog.open(AboutActivity.this, config.acknowledgmentHtmlPath, getString(R.string.acknowledgment)); config.dialog.open(AboutActivity.this, config.acknowledgmentHtmlPath, getString(R.string.egab_acknowledgements));
} }
if (config.analytics != null) { if (config.analytics != null) {
config.analytics.logUiEvent(config.logUiEventName, getString(R.string.asknowledgment_log_event)); config.analytics.logUiEvent(config.logUiEventName, getString(R.string.egab_acknowledgements_log_event));
} }
} }
}) })
@ -217,53 +217,85 @@ public class AboutActivity extends MaterialAboutActivity {
@Override @Override
protected CharSequence getActivityTitle() { protected CharSequence getActivityTitle() {
return getString(R.string.about_screen_title); return getString(R.string.egab_about_screen_title);
} }
public static void getOpenFacebookIntent(Activity context, String name) { public static void getOpenFacebookIntent(Activity context, String name) {
Intent intent;
try { try {
context.getPackageManager().getPackageInfo("com.facebook.katana", 0); context.getPackageManager().getPackageInfo("com.facebook.katana", 0);
intent = new Intent(Intent.ACTION_VIEW, Uri.parse("fb://profile/" + name)); Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse("fb://profile/" + name));
context.startActivity(intent);
} catch (Exception e) { } catch (Exception e) {
intent = new Intent(Intent.ACTION_VIEW, Uri.parse("https://www.facebook.com/" + name));
}
context.startActivity(intent);
}
public static void startTwitter(Activity context, String name) {
Intent intent;
try {
context.getPackageManager().getPackageInfo("com.twitter.android", 0);
intent = new Intent(Intent.ACTION_VIEW, Uri.parse("twitter://user?screen_name=" + name));
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
} catch (Exception e) {
intent = new Intent(Intent.ACTION_VIEW, Uri.parse("https://twitter.com/" + name));
}
context.startActivity(intent);
}
public void openApp(String packageName, boolean googlePlay) {//true if Google Play, false if Amazon Store
try {
startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse((googlePlay ? "market://details?id=" : "amzn://apps/android?p=") + packageName)));
} catch (ActivityNotFoundException e1) {
try { try {
startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse((googlePlay ? "http://play.google.com/store/apps/details?id=" : "http://www.amazon.com/gp/mas/dl/android?p=") + packageName))); Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse("https://www.facebook.com/" + name));
} catch (ActivityNotFoundException e2) { context.startActivity(intent);
Toast.makeText(this, R.string.can_not_open, Toast.LENGTH_SHORT).show(); } catch (Exception e1) {
Toast.makeText(context, R.string.egab_can_not_open, Toast.LENGTH_SHORT).show();
} }
} }
} }
public void openPublisher(boolean googlePlay, String publisher) {//true if Google Play, false if Amazon Store public static void startTwitter(Activity context, String name) {
try { try {
startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse((googlePlay ? "market://search?q=pub:" : "amzn://apps/android?showAll=1&p=") + publisher))); 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) {//true if Google Play, false if Amazon Store
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) {//true if Google Play, false if Amazon Store
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) { } catch (ActivityNotFoundException e1) {
try { try {
startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse((googlePlay ? "http://play.google.com/store/search?q=pub:" : "http://www.amazon.com/gp/mas/dl/android?showAll=1&p=") + publisher))); startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse(webURI)));
} catch (ActivityNotFoundException e2) { } catch (ActivityNotFoundException e2) {
Toast.makeText(this, R.string.can_not_open, Toast.LENGTH_SHORT).show(); Toast.makeText(this, R.string.egab_can_not_open, Toast.LENGTH_SHORT).show();
} }
} }
} }

View file

@ -3,9 +3,11 @@ package com.eggheadgames.aboutbox.share;
import android.app.Activity; import android.app.Activity;
import android.content.Intent; import android.content.Intent;
import android.net.Uri; import android.net.Uri;
import android.os.Build;
import android.text.TextUtils;
import com.eggheadgames.aboutbox.AboutConfig; import com.eggheadgames.aboutbox.AboutConfig;
import com.eggheadgames.aboutbox.BuildConfig; import com.eggheadgames.aboutbox.R;
public final class EmailUtil { public final class EmailUtil {
@ -18,26 +20,35 @@ public final class EmailUtil {
final Uri mailto = Uri.fromParts("mailto", config.emailAddress, null); final Uri mailto = Uri.fromParts("mailto", config.emailAddress, null);
final String emailSubject; String emailBody = config.emailBody;
if (TextUtils.isEmpty(emailBody)) {
String deviceInfo = "";
deviceInfo += "\n App version: " + config.version;
deviceInfo += "\n Android version: " + Build.VERSION.RELEASE + " (" + android.os.Build.VERSION.SDK_INT + ")";
deviceInfo += "\n Device: " + android.os.Build.MODEL + " (" + android.os.Build.PRODUCT + ")";
deviceInfo += "\n Platform: " + platformName(config.buildType);
if ("google".equals(BuildConfig.FLAVOR)) { emailBody = activity.getString(R.string.egab_email_body_prompt) + "\n\n\n\n\n"
emailSubject = config.emailSubject + "G"; + "---------------------------" + deviceInfo;
} else if ("amazon".equals(BuildConfig.FLAVOR)) {
emailSubject = config.emailSubject + "K";
} else {
emailSubject = config.emailSubject;
} }
try { try {
Intent emailIntent = new Intent(Intent.ACTION_SENDTO, mailto); Intent emailIntent = new Intent(Intent.ACTION_SENDTO, mailto);
emailIntent.putExtra(Intent.EXTRA_SUBJECT, emailSubject); emailIntent.putExtra(Intent.EXTRA_SUBJECT, config.emailSubject);
emailIntent.putExtra(Intent.EXTRA_TEXT, config.emailBody); emailIntent.putExtra(Intent.EXTRA_TEXT, emailBody);
activity.startActivity(Intent.createChooser(emailIntent, "Send email...")); activity.startActivity(Intent.createChooser(emailIntent, "Send email..."));
} catch (Exception e) { } catch (Exception e) {
if (config.analytics != null) { if (config.analytics != null) {
config.analytics.logException(e, false); config.analytics.logException(e, false);
} }
} }
}
private static String platformName(AboutConfig.BuildType buildType) {
switch (buildType) {
case GOOGLE: return "Google Play";
case AMAZON: return "Amazon Kindle";
default: return "Unknown";
}
} }
} }

View file

@ -0,0 +1,25 @@
<resources>
<string name="app_name">AboutBox</string>
<string name="egab_leave_review">Avaliar</string>
<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_facebook_label">Facebook</string>
<string name="egab_twitter_label">Twitter</string>
<string name="egab_web_label">Web</string>
<string name="egab_acknowledgements">Acknowledgements</string>
<string name="egab_privacy_policy">Política de Privacidade</string>
<string name="egab_about_screen_title">Sobre</string>
<string name="egab_share">Partilhar</string>
<string name="egab_contact_log_event">Contactos</string>
<string name="egab_review_log_event">Avalie</string>
<string name="egab_share_log_event">Partilhar</string>
<string name="egab_try_other_app_log_event">Experimentar outras aplicações</string>
<string name="egab_facebook_log_event">Facebook</string>
<string name="egab_twitter_log_event">Twitter</string>
<string name="egab_website_log_event">Website</string>
<string name="egab_privacy_log_event">Privacicidade</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_email_body_prompt">Digite sua pergunta aqui: </string>
</resources>

View file

@ -1,25 +1,26 @@
<resources> <resources>
<string name="app_name">AboutBox</string> <string name="app_name">AboutBox</string>
<string name="leave_review">Leave Review</string> <string name="egab_leave_review">Leave Review</string>
<string name="contact_support">Contact Support</string> <string name="egab_contact_support">Contact Support</string>
<string name="try_other_apps">Try Other Apps</string> <string name="egab_try_other_apps">Try Other Apps</string>
<string name="version">Version</string> <string name="egab_version">Version</string>
<string name="facebook_label">Facebook</string> <string name="egab_facebook_label">Facebook</string>
<string name="twitter_label">Twitter</string> <string name="egab_twitter_label">Twitter</string>
<string name="web_label">Web</string> <string name="egab_web_label">Web</string>
<string name="acknowledgment">Acknowledgment</string> <string name="egab_acknowledgements">Acknowledgements</string>
<string name="privacy_policy">Privacy Policy</string> <string name="egab_privacy_policy">Privacy Policy</string>
<string name="about_screen_title">About</string> <string name="egab_about_screen_title">About</string>
<string name="share">Share</string> <string name="egab_share">Share</string>
<string name="contact_log_event">Contact</string> <string name="egab_contact_log_event">Contact</string>
<string name="review_log_event">Review</string> <string name="egab_review_log_event">Review</string>
<string name="share_log_event">Share</string> <string name="egab_share_log_event">Share</string>
<string name="try_other_app_log_event">Try Other Apps</string> <string name="egab_try_other_app_log_event">Try Other Apps</string>
<string name="facebook_log_event">Facebook</string> <string name="egab_facebook_log_event">Facebook</string>
<string name="twitter_log_event">Twitter</string> <string name="egab_twitter_log_event">Twitter</string>
<string name="website_log_event">Website</string> <string name="egab_website_log_event">Website</string>
<string name="privacy_log_event">Privacy</string> <string name="egab_privacy_log_event">Privacy</string>
<string name="asknowledgment_log_event">Acknowledgement</string> <string name="egab_acknowledgements_log_event">Acknowledgements</string>
<string name="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>
</resources> </resources>