mirror of
https://github.com/ethauvin/android-about-box.git
synced 2025-04-25 02:37:11 -07:00
Merge pull request #26 from eggheadgames/feature/remove_branch_io
Remove dependancy on Branch.io
This commit is contained in:
commit
4e3900f40c
5 changed files with 23 additions and 57 deletions
|
@ -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'
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -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);
|
||||||
|
}
|
|
@ -105,11 +105,14 @@ public class AboutActivity extends MaterialAboutActivity {
|
||||||
new MaterialAboutItemOnClickListener() {
|
new MaterialAboutItemOnClickListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onClick(boolean b) {
|
public void onClick(boolean b) {
|
||||||
ShareUtil.share(AboutActivity.this);
|
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));
|
logUIEventName(config.analytics, config.logUiEventName, getString(R.string.egab_share_log_event));
|
||||||
}
|
}
|
||||||
}));
|
}));
|
||||||
|
|
||||||
return card.build();
|
return card.build();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -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