-
Notifications
You must be signed in to change notification settings - Fork 357
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 #62 from wilburt/dev
Changes for v1.0.4
- Loading branch information
Showing
31 changed files
with
285 additions
and
315 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
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 |
---|---|---|
@@ -1,9 +1,9 @@ | ||
<manifest xmlns:android="http://schemas.android.com/apk/res/android" | ||
package="co.paystack.flutterpaystack"> | ||
package="co.paystack.flutterpaystack"> | ||
|
||
<application> | ||
<activity | ||
android:name=".AuthActivity" | ||
android:theme="@style/Paystack.Dialog"/> | ||
android:theme="@style/Paystack.Dialog" /> | ||
</application> | ||
</manifest> |
92 changes: 45 additions & 47 deletions
92
android/src/main/kotlin/co/paystack/flutterpaystack/FlutterPaystackPlugin.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 |
---|---|---|
@@ -1,54 +1,52 @@ | ||
package co.paystack.flutterpaystack | ||
|
||
import android.annotation.SuppressLint | ||
import android.content.Context | ||
import android.os.Build | ||
import android.provider.Settings | ||
import io.flutter.plugin.common.MethodCall | ||
import io.flutter.plugin.common.MethodChannel | ||
import io.flutter.plugin.common.MethodChannel.MethodCallHandler | ||
import io.flutter.plugin.common.MethodChannel.Result | ||
import io.flutter.plugin.common.PluginRegistry.Registrar | ||
|
||
class FlutterPaystackPlugin(val appContext: Context, val authDelegate: AuthDelegate) : MethodCallHandler { | ||
companion object { | ||
@JvmStatic | ||
fun registerWith(registrar: Registrar) { | ||
val activity = registrar.activity() ?: return | ||
val channel = MethodChannel(registrar.messenger(), "flutter_paystack") | ||
val authDelegate = AuthDelegate(activity = activity) | ||
val plugin = FlutterPaystackPlugin(appContext = registrar.context(), authDelegate = authDelegate) | ||
channel.setMethodCallHandler(plugin) | ||
import android.app.Activity | ||
import io.flutter.embedding.engine.plugins.FlutterPlugin | ||
import io.flutter.embedding.engine.plugins.activity.ActivityAware | ||
import io.flutter.embedding.engine.plugins.activity.ActivityPluginBinding | ||
import io.flutter.plugin.common.BinaryMessenger | ||
import io.flutter.plugin.common.PluginRegistry | ||
|
||
|
||
class FlutterPaystackPlugin : FlutterPlugin, ActivityAware { | ||
|
||
private var pluginBinding: FlutterPlugin.FlutterPluginBinding? = null | ||
private var methodCallHandler: MethodCallHandlerImpl? = null | ||
|
||
override fun onAttachedToEngine(binding: FlutterPlugin.FlutterPluginBinding) { | ||
pluginBinding = binding | ||
} | ||
} | ||
|
||
@SuppressLint("HardwareIds") | ||
override fun onMethodCall(call: MethodCall, result: Result) { | ||
|
||
when (call.method) { | ||
"getDeviceId" -> { | ||
result.success("androidsdk_" + Settings.Secure.getString(appContext.contentResolver, | ||
Settings.Secure.ANDROID_ID)) | ||
} | ||
"getUserAgent" -> { | ||
result.success("Android_" + Build.VERSION.SDK_INT + "_Paystack_" + BuildConfig.VERSION_NAME) | ||
} | ||
|
||
"getVersionCode" -> { | ||
result.success(BuildConfig.VERSION_CODE.toString()) | ||
} | ||
|
||
"getAuthorization" -> { | ||
authDelegate.handleAuthorization(result, call) | ||
} | ||
"getEncryptedData" -> { | ||
val encryptedData = Crypto.encrypt(call.argument<String>("stringData").toString()) | ||
result.success(encryptedData) | ||
} | ||
|
||
else -> result.notImplemented() | ||
|
||
override fun onDetachedFromEngine(binding: FlutterPlugin.FlutterPluginBinding) { | ||
pluginBinding = null | ||
} | ||
|
||
} | ||
private fun setupMethodHandler(messenger: BinaryMessenger?, activity: Activity) { | ||
methodCallHandler = MethodCallHandlerImpl(messenger, activity) | ||
} | ||
|
||
|
||
override fun onDetachedFromActivity() { | ||
methodCallHandler?.disposeHandler() | ||
methodCallHandler = null | ||
} | ||
|
||
|
||
override fun onAttachedToActivity(binding: ActivityPluginBinding) { | ||
setupMethodHandler(pluginBinding?.binaryMessenger, binding.activity) | ||
} | ||
|
||
override fun onDetachedFromActivityForConfigChanges() = onDetachedFromActivity() | ||
|
||
override fun onReattachedToActivityForConfigChanges(binding: ActivityPluginBinding) = onAttachedToActivity(binding) | ||
|
||
companion object { | ||
|
||
@JvmStatic | ||
fun registerWith(registrar: PluginRegistry.Registrar) { | ||
val plugin = FlutterPaystackPlugin() | ||
plugin.setupMethodHandler(registrar.messenger(), registrar.activity()) | ||
} | ||
} | ||
|
||
} |
57 changes: 57 additions & 0 deletions
57
android/src/main/kotlin/co/paystack/flutterpaystack/MethodCallHandlerImpl.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,57 @@ | ||
package co.paystack.flutterpaystack | ||
|
||
import android.annotation.SuppressLint | ||
import android.app.Activity | ||
import android.os.Build | ||
import android.provider.Settings | ||
import io.flutter.plugin.common.BinaryMessenger | ||
import io.flutter.plugin.common.MethodCall | ||
import io.flutter.plugin.common.MethodChannel | ||
import io.flutter.plugin.common.MethodChannel.MethodCallHandler | ||
|
||
class MethodCallHandlerImpl(messenger: BinaryMessenger?, private val activity: Activity?) : MethodCallHandler { | ||
private var channel: MethodChannel? = null | ||
private var authDelegate: AuthDelegate? = null | ||
|
||
init { | ||
activity!!.let { | ||
authDelegate = AuthDelegate(it) | ||
channel = MethodChannel(messenger, channelName) | ||
channel?.setMethodCallHandler(this) | ||
} | ||
} | ||
|
||
@SuppressLint("HardwareIds") | ||
override fun onMethodCall(call: MethodCall, result: MethodChannel.Result) { | ||
when (call.method) { | ||
"getDeviceId" -> { | ||
val deviceId = Settings.Secure.getString(activity?.contentResolver, Settings.Secure.ANDROID_ID) | ||
result.success("androidsdk_$deviceId") | ||
} | ||
"getUserAgent" -> { | ||
result.success("Android_" + Build.VERSION.SDK_INT + "_Paystack_" + BuildConfig.VERSION_NAME) | ||
} | ||
|
||
"getVersionCode" -> { | ||
result.success(BuildConfig.VERSION_CODE.toString()) | ||
} | ||
|
||
"getAuthorization" -> { | ||
authDelegate?.handleAuthorization(result, call) | ||
} | ||
"getEncryptedData" -> { | ||
val encryptedData = Crypto.encrypt(call.argument<String>("stringData").toString()) | ||
result.success(encryptedData) | ||
} | ||
|
||
else -> result.notImplemented() | ||
} | ||
} | ||
|
||
fun disposeHandler() { | ||
channel?.setMethodCallHandler(null) | ||
channel = null | ||
} | ||
} | ||
|
||
private const val channelName = "plugins.wilburt/flutter_paystack" |
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
11 changes: 2 additions & 9 deletions
11
example/android/app/src/main/kotlin/co/paystack/flutterpaystackexample/MainActivity.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 |
---|---|---|
@@ -1,13 +1,6 @@ | ||
package co.paystack.flutterpaystackexample | ||
|
||
import android.os.Bundle | ||
import io.flutter.embedding.android.FlutterActivity | ||
|
||
import io.flutter.app.FlutterActivity | ||
import io.flutter.plugins.GeneratedPluginRegistrant | ||
|
||
class MainActivity(): FlutterActivity() { | ||
override fun onCreate(savedInstanceState: Bundle?) { | ||
super.onCreate(savedInstanceState) | ||
GeneratedPluginRegistrant.registerWith(this) | ||
} | ||
} | ||
class MainActivity: FlutterActivity() |
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 |
---|---|---|
@@ -1,6 +1,6 @@ | ||
#Thu Oct 25 11:04:03 WAT 2018 | ||
#Fri Aug 21 21:56:56 WAT 2020 | ||
distributionBase=GRADLE_USER_HOME | ||
distributionPath=wrapper/dists | ||
zipStoreBase=GRADLE_USER_HOME | ||
zipStorePath=wrapper/dists | ||
distributionUrl=https\://services.gradle.org/distributions/gradle-5.4.1-all.zip | ||
distributionUrl=https\://services.gradle.org/distributions/gradle-6.1.1-all.zip |
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 @@ | ||
85f89a72efc4102d6ce4c0a159895eef |
Oops, something went wrong.