Skip to content

Commit

Permalink
Removed Extra Code
Browse files Browse the repository at this point in the history
  • Loading branch information
NidhiDixit09 committed Dec 18, 2023
1 parent ac18daf commit 6926a35
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 41 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -15,29 +15,5 @@ class SharingBroadcastReceiver: BroadcastReceiver() {

BranchLogger.v("Intent: $intent")
BranchLogger.v("Clicked component: $clickedComponent")

val sharedIntent : Intent? = SharingUtil.chooserIntent?.getParcelableExtra(Intent.EXTRA_INTENT);
val shareIntentdExtraText = sharedIntent?.getStringExtra(Intent.EXTRA_TEXT)

BranchLogger.v("Intent Shared: $sharedIntent");
BranchLogger.v("Intent Shared Text: $shareIntentdExtraText");

sharedIntent?.putExtra(Intent.EXTRA_TEXT, "test Nidhi")

SharingUtil.chooserIntent?.putExtra(Intent.EXTRA_INTENT,sharedIntent)

val sharedIntent2 : Intent? = SharingUtil.chooserIntent?.getParcelableExtra(Intent.EXTRA_INTENT);
val shareIntentdExtraText2 = sharedIntent2?.getStringExtra(Intent.EXTRA_TEXT)

BranchLogger.v("Intent Shared Updated: $sharedIntent2");
BranchLogger.v("Intent Shared Text Updated: $shareIntentdExtraText2");

// TODO : Get Pointer to BranchLinkShareListener and call function onChannelSelected

// val shareIntent3 = Intent.createChooser(shareIntent, null)
// context.startActivity(shareIntent3)



}
}
1 change: 0 additions & 1 deletion Branch-SDK/src/main/java/io/branch/referral/Branch.java
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,6 @@ public class Branch {

/**
* Hard-coded {@link String} that denotes a {@link BranchLinkData#tags}; applies to links that
* Hard-coded {@link String} that denotes a {@link BranchLinkData}; applies to links that
* are shared with others directly as a user action, via social media for instance.
*/
public static final String FEATURE_TAG_SHARE = "share";
Expand Down
25 changes: 9 additions & 16 deletions Branch-SDK/src/main/java/io/branch/referral/util/SharingUtil.kt
Original file line number Diff line number Diff line change
Expand Up @@ -8,40 +8,33 @@ import androidx.annotation.RequiresApi
import io.branch.receivers.SharingBroadcastReceiver

object SharingUtil {

val shareIntent = Intent().apply {
action = Intent.ACTION_SEND
type = "text/plain"
putExtra(Intent.EXTRA_TEXT, "test1234")
putExtra(Intent.EXTRA_SUBJECT, "")
}
var chooserIntent: Intent? = null

@JvmStatic @RequiresApi(Build.VERSION_CODES.LOLLIPOP_MR1)
@RequiresApi(Build.VERSION_CODES.LOLLIPOP_MR1)
fun share(text: String, subject: String?, activity: Activity) {

val immutabilityIntentFlags: Int =
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
PendingIntent.FLAG_MUTABLE
} else {
0
}


chooserIntent =
val shareIntent = Intent().apply {
action = Intent.ACTION_SEND
type = "text/plain"
putExtra(Intent.EXTRA_TEXT, text)
putExtra(Intent.EXTRA_SUBJECT, subject)
}
val chooserIntent =
Intent.createChooser(
shareIntent,
null, // dialog title optional
PendingIntent.getBroadcast(
activity.applicationContext,
0,
Intent(activity.applicationContext, SharingBroadcastReceiver::class.java),
PendingIntent.FLAG_UPDATE_CURRENT
PendingIntent.FLAG_UPDATE_CURRENT or immutabilityIntentFlags
).intentSender
)

activity.startActivityForResult(chooserIntent, 1002)

// TODO: Call onLinkShareResponse function once activity finishes.
}
}

0 comments on commit 6926a35

Please sign in to comment.