Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 0 additions & 9 deletions android/.gitignore

This file was deleted.

9 changes: 5 additions & 4 deletions android/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ group 'tap.company.tap_google_pay_kit_flutter'
version '1.0'

buildscript {
ext.kotlin_version = '2.1.0'
repositories {
google()
mavenCentral()
Expand All @@ -23,8 +24,8 @@ rootProject.allprojects {
apply plugin: 'com.android.library'

android {
compileSdkVersion 34
namespace 'tap.company.tap_google_pay_kit_flutter'
namespace "company.tap.google.pay.kit.flutter"
compileSdkVersion 31

compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
Expand All @@ -37,6 +38,6 @@ android {
}

dependencies {
implementation 'com.github.Tap-Payments:TapGooglePayKit:1.0.2'
implementation "com.google.android.gms:play-services-wallet:19.4.0"
implementation 'com.github.Tap-Payments:TapGooglePayKit:1.0.0'
implementation "com.google.android.gms:play-services-wallet:18.1.3"
}
3 changes: 1 addition & 2 deletions android/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="tap.company.tap_google_pay_kit_flutter">
<manifest xmlns:android="http://schemas.android.com/apk/res/android">

<application>
<meta-data
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
package tap.company.tap_google_pay_kit_flutter;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.FrameLayout;

import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
Expand All @@ -15,16 +15,30 @@

public class GooglePayButtonViewManager implements PlatformView {

private GooglePayButton googlePayButton;
private View view;
private GooglePayButton googlePayButton;
private FrameLayout containerView;

GooglePayButtonViewManager(@NonNull Context context, int id, @Nullable Map<String, Object> creationParams) {
view = LayoutInflater.from(context).inflate(R.layout.google_pay_button_layout,null);
googlePayButton = view.findViewById(R.id.googlePayView);
googlePayButton.setGooglePayButtonType(getGooglePayType(creationParams.get("type").toString()));
System.out.println("Google Pay Button View Manager >>>>>>>>>>>>>>");
}
// Create views programmatically instead of using XML inflation
containerView = new FrameLayout(context);
googlePayButton = new GooglePayButton(context);

// Add GooglePayButton to the container
FrameLayout.LayoutParams params = new FrameLayout.LayoutParams(
FrameLayout.LayoutParams.MATCH_PARENT,
FrameLayout.LayoutParams.WRAP_CONTENT);
containerView.addView(googlePayButton, params);

// Set button type if provided in creation params
if (creationParams != null && creationParams.containsKey("type")) {
googlePayButton.setGooglePayButtonType(getGooglePayType(creationParams.get("type").toString()));
} else {
// Default type
googlePayButton.setGooglePayButtonType(GooglePayButtonType.NORMAL_GOOGLE_PAY);
}

System.out.println("Google Pay Button View Manager programmatically created >>>>>>>>>>>>>>");
}

@NonNull
private GooglePayButtonType getGooglePayType(String typeValue) {
Expand Down Expand Up @@ -56,21 +70,14 @@ private GooglePayButtonType getGooglePayType(String typeValue) {
return type;
}


// public void setType(@NonNull View view, String type) {
// googlePayButton = view.findViewById(R.id.googlePayView);
// googlePayButton.setGooglePayButtonType(getGooglePayType("BUY_WITH_GOOGLE_PAY"));
// }

@Nullable
@Override
public View getView() {
return view;
return containerView;
}


@Override
public void dispose() {

// Clean up any resources
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,6 @@
*/
public class TapGooglePayKitFlutterPlugin implements MethodChannel.MethodCallHandler, FlutterPlugin, ActivityAware {



/**
* LifeCycleObserver
*/
Expand Down Expand Up @@ -116,7 +114,16 @@ public void onActivityStopped(Activity activity) {
private LifeCycleObserver observer;
private static final String CHANNEL = "tap_google_pay_kit_flutter";

/**
* Register with
*
* @param registrar
*/

public static void registerWith(Object registrar) {
// This method is kept for compatibility with older Flutter versions
// but is no longer used with the v2 embedding API
}

/**
* Default constructor for the plugin.
Expand All @@ -126,7 +133,6 @@ public void onActivityStopped(Activity activity) {
public TapGooglePayKitFlutterPlugin() {
}


/**
* @param binding
*/
Expand All @@ -150,6 +156,7 @@ public void onAttachedToActivity(ActivityPluginBinding binding) {
pluginBinding.getBinaryMessenger(),
(Application) pluginBinding.getApplicationContext(),
activityBinding.getActivity(),
null,
activityBinding);
}

Expand All @@ -163,7 +170,6 @@ public void onDetachedFromActivityForConfigChanges() {
onDetachedFromActivity();
}


@Override
public void onReattachedToActivityForConfigChanges(ActivityPluginBinding binding) {
onAttachedToActivity(binding);
Expand All @@ -177,14 +183,18 @@ private void setup(
final BinaryMessenger messenger,
final Application application,
final Activity activity,
final Object registrar, // Changed from PluginRegistry.Registrar
final ActivityPluginBinding activityBinding) {
this.activity = activity;
this.application = application;
this.delegate = constructDelegate(activity);
channel = new MethodChannel(messenger, "tap_google_pay_kit_flutter");
channel.setMethodCallHandler(this);
observer = new LifeCycleObserver(activity);
if (activityBinding != null) {
if (registrar != null) {
// V1 embedding setup for activity listeners is no longer supported
application.registerActivityLifecycleCallbacks(observer);
} else {
// V2 embedding setup for activity listeners.
activityBinding.addActivityResultListener(delegate);
activityBinding.addRequestPermissionsResultListener(delegate);
Expand All @@ -193,7 +203,6 @@ private void setup(
}
}


/**
* tearDown()
*/
Expand All @@ -211,7 +220,6 @@ private void tearDown() {
application = null;
}


/**
* construct delegate
*/
Expand Down Expand Up @@ -275,11 +283,11 @@ public void onMethodCall(MethodCall call, MethodChannel.Result rawResult) {

if (call.method.equals("terminate_session")) {
System.out.println("terminate session!");
// delegate.terminateSDKSession();
// delegate.terminateSDKSession();
return;
}
MethodChannel.Result result = new MethodResultWrapper(rawResult);
delegate.start(activity, result, args);

}
}
}
18 changes: 5 additions & 13 deletions android/src/main/res/layout/google_pay_button_layout.xml
Original file line number Diff line number Diff line change
@@ -1,19 +1,11 @@
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:clickable="true"
android:focusable="true"
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="50sp"
android:padding="8sp"
>

android:layout_height="wrap_content">

<company.tap.google.pay.open.GooglePayButton
android:id="@+id/googlePayView"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:enabled="true"
android:focusable="true"
/>
</RelativeLayout>
android:layout_height="wrap_content" />

</FrameLayout>
4 changes: 4 additions & 0 deletions android/src/main/res/values/ids.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<item name="googlePayView" type="id" />
</resources>