-
Notifications
You must be signed in to change notification settings - Fork 241
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1015 from braintree/paypal-messaging-feature
[DO NOT REVIEW] Merge `paypal-messaing-feature` into `main`
- Loading branch information
Showing
32 changed files
with
974 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
7 changes: 7 additions & 0 deletions
7
BraintreeCore/src/main/java/com/braintreepayments/api/ExperimentalBetaApi.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
package com.braintreepayments.api | ||
|
||
/** | ||
* The annotated method or class is in beta. It's public API may change or be removed in future releases. | ||
*/ | ||
@RequiresOptIn | ||
annotation class ExperimentalBetaApi |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
71 changes: 71 additions & 0 deletions
71
Demo/src/main/java/com/braintreepayments/demo/PayPalMessagingFragment.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
package com.braintreepayments.demo | ||
|
||
import android.os.Bundle | ||
import android.view.LayoutInflater | ||
import android.view.View | ||
import android.view.ViewGroup | ||
import android.widget.LinearLayout | ||
import com.braintreepayments.api.ExperimentalBetaApi | ||
import com.braintreepayments.api.PayPalMessagingColor | ||
import com.braintreepayments.api.PayPalMessagingListener | ||
import com.braintreepayments.api.PayPalMessagingLogoType | ||
import com.braintreepayments.api.PayPalMessagingOfferType | ||
import com.braintreepayments.api.PayPalMessagingRequest | ||
import com.braintreepayments.api.PayPalMessagingTextAlignment | ||
import com.braintreepayments.api.PayPalMessagingView | ||
|
||
@OptIn(ExperimentalBetaApi::class) | ||
class PayPalMessagingFragment : BaseFragment(), PayPalMessagingListener { | ||
override fun onCreateView( | ||
inflater: LayoutInflater, | ||
container: ViewGroup?, | ||
savedInstanceState: Bundle? | ||
): View? { | ||
return inflater.inflate(R.layout.fragment_paypal_messaging, container, false) | ||
} | ||
|
||
override fun onViewCreated(view: View, savedInstanceState: Bundle?) { | ||
super.onViewCreated(view, savedInstanceState) | ||
|
||
val payPalMessagingRequest = PayPalMessagingRequest( | ||
amount = 2.0, | ||
pageType = null, | ||
offerType = PayPalMessagingOfferType.PAY_LATER_LONG_TERM, | ||
buyerCountry = "US", | ||
logoType = PayPalMessagingLogoType.PRIMARY, | ||
textAlignment = PayPalMessagingTextAlignment.CENTER, | ||
color = PayPalMessagingColor.BLACK | ||
) | ||
|
||
val payPalMessagingView = PayPalMessagingView(braintreeClient, requireActivity()) | ||
payPalMessagingView.setListener(this) | ||
payPalMessagingView.start(payPalMessagingRequest) | ||
payPalMessagingView.layoutParams = ViewGroup.LayoutParams( | ||
ViewGroup.LayoutParams.MATCH_PARENT, | ||
ViewGroup.LayoutParams.MATCH_PARENT | ||
) | ||
|
||
val messagingView: LinearLayout = view.findViewById(R.id.content) | ||
messagingView.addView(payPalMessagingView) | ||
} | ||
|
||
override fun onPayPalMessagingClick() { | ||
println("User clicked on the PayPalMessagingView") | ||
} | ||
|
||
override fun onPayPalMessagingApply() { | ||
println("User is attempting to apply for PayPal Credit") | ||
} | ||
|
||
override fun onPayPalMessagingLoading() { | ||
println("Loading PayPalMessagingView") | ||
} | ||
|
||
override fun onPayPalMessagingSuccess() { | ||
println("PayPalMessagingView displayed to user") | ||
} | ||
|
||
override fun onPayPalMessagingFailure(error: Exception) { | ||
println("PayPalMessagingView returned the error:" + error.message) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" | ||
xmlns:tools="http://schemas.android.com/tools" | ||
android:id="@+id/content" | ||
android:layout_width="match_parent" | ||
android:layout_height="80dp" | ||
android:orientation="vertical" | ||
android:layout_gravity="center_vertical" | ||
android:padding="10dp" | ||
tools:context=".PayPalMessagingFragment" /> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
plugins { | ||
id 'com.android.library' | ||
id 'org.jetbrains.kotlin.android' | ||
} | ||
|
||
android { | ||
compileSdkVersion rootProject.compileSdkVersion | ||
|
||
defaultConfig { | ||
// required to be out of sync with other modules due to messaging SDK min version | ||
minSdkVersion rootProject.minSdkVersionPayPalMessaging | ||
targetSdkVersion rootProject.targetSdkVersion | ||
|
||
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" | ||
|
||
buildConfigField "String", "VERSION_NAME", "\"${rootProject.versionName}\"" | ||
} | ||
|
||
testOptions { | ||
unitTests { | ||
includeAndroidResources = true | ||
returnDefaultValues true | ||
all { | ||
jvmArgs '-noverify' | ||
} | ||
} | ||
} | ||
|
||
buildTypes { | ||
release { | ||
minifyEnabled false | ||
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro' | ||
} | ||
} | ||
compileOptions { | ||
sourceCompatibility versions.javaSourceCompatibility | ||
targetCompatibility versions.javaTargetCompatibility | ||
} | ||
} | ||
|
||
dependencies { | ||
api project(':BraintreeCore') | ||
|
||
implementation deps.coreKtx | ||
implementation deps.kotlinStdLib | ||
implementation deps.appCompat | ||
implementation('com.paypal.messages:paypal-messages:1.0.1') | ||
|
||
testImplementation deps.robolectric | ||
testImplementation deps.jsonAssert | ||
testImplementation deps.junitTest | ||
testImplementation deps.mockk | ||
testImplementation deps.mockitoCore | ||
testImplementation project(':TestUtils') | ||
} | ||
|
||
// region signing and publishing | ||
|
||
project.ext.name = "paypal-messaging" | ||
project.ext.pom_name = "paypal-messaging" | ||
project.ext.group_id = "com.braintreepayments.api" | ||
project.ext.version = rootProject.version | ||
project.ext.pom_desc = "PayPal Messaging dependencies for Braintree Android." | ||
|
||
apply from: rootProject.file("gradle/gradle-publish.gradle") | ||
|
||
// endregion |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<manifest xmlns:android="http://schemas.android.com/apk/res/android" | ||
package="com.braintreepayments.api.paypalmessaging"> | ||
</manifest> |
7 changes: 7 additions & 0 deletions
7
PayPalMessaging/src/main/java/com/braintreepayments/api/PayPalMessagingAnalytics.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
package com.braintreepayments.api | ||
|
||
internal object PayPalMessagingAnalytics { | ||
const val STARTED = "paypal-messaging:create-view:started" | ||
const val FAILED = "paypal-messaging:create-view:failed" | ||
const val SUCCEEDED = "paypal-messaging:create-view:succeeded" | ||
} |
38 changes: 38 additions & 0 deletions
38
PayPalMessaging/src/main/java/com/braintreepayments/api/PayPalMessagingColor.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
package com.braintreepayments.api | ||
|
||
import com.paypal.messages.config.message.style.PayPalMessageColor | ||
|
||
/** | ||
* Text and logo color option for a PayPal Message | ||
* Note: **This module is in beta. It's public API may change or be removed in future releases.** | ||
*/ | ||
@ExperimentalBetaApi | ||
enum class PayPalMessagingColor { | ||
/** | ||
* Black text with a color logo | ||
*/ | ||
BLACK, | ||
|
||
/** | ||
* White text with a color logo | ||
*/ | ||
WHITE, | ||
|
||
/** | ||
* Black text with a black logo | ||
*/ | ||
MONOCHROME, | ||
|
||
/** | ||
* Black text with a desaturated logo | ||
*/ | ||
GRAYSCALE; | ||
|
||
internal val internalValue: PayPalMessageColor | ||
get() = when (this) { | ||
BLACK -> PayPalMessageColor.BLACK | ||
WHITE -> PayPalMessageColor.WHITE | ||
MONOCHROME -> PayPalMessageColor.MONOCHROME | ||
GRAYSCALE -> PayPalMessageColor.GRAYSCALE | ||
} | ||
} |
Oops, something went wrong.