Skip to content

Commit 13d3ba4

Browse files
committed
fixed gradle conflict
1 parent 4a6acd5 commit 13d3ba4

File tree

10 files changed

+130
-61
lines changed

10 files changed

+130
-61
lines changed

build.gradle

Lines changed: 4 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,14 @@
1-
// Top-level build file where you can add configuration options common to all sub-projects/modules.
2-
buildscript {
3-
ext.kotlin_version = '1.7.10'
4-
repositories {
5-
google()
6-
mavenCentral()
7-
}
8-
dependencies {
9-
classpath "com.android.tools.build:gradle:7.3.1"
10-
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:1.7.10"
11-
// NOTE: Do not place your application dependencies here; they belong
12-
// in the individual module build.gradle files
13-
}
14-
}
151

162
plugins{
3+
id 'com.android.application' version '7.4.0' apply false
4+
id 'com.android.library' version '7.4.0' apply false
5+
id 'org.jetbrains.kotlin.android' version '1.8.0' apply false
176
id 'io.github.gradle-nexus.publish-plugin' version '1.1.0'
18-
id 'org.jetbrains.kotlin.android' version '1.7.10' apply false
197
}
208

21-
task clean(type: Delete) {
22-
delete rootProject.buildDir
23-
}
249

2510
ext {
11+
kotlin_version = '1.7.21'
2612

2713
//ktlint
2814
ktlintVersion = '0.46.1'

demo-app/build.gradle

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,19 +2,17 @@ plugins {
22
id 'com.android.application'
33
id 'kotlin-android'
44
id 'kotlin-kapt'
5-
id 'org.jetbrains.kotlin.android'
6-
75
}
86

97

108
android {
11-
compileSdk 33
9+
compileSdkVersion 33
1210

1311

1412
defaultConfig {
1513
applicationId "co.thepeer"
16-
minSdk 21
17-
targetSdk 33
14+
minSdkVersion 21
15+
targetSdkVersion 33
1816
versionCode 1
1917
versionName "1.0"
2018

@@ -43,12 +41,11 @@ android {
4341
dependencies {
4442

4543
implementation project(":thepeer-android")
46-
implementation 'androidx.core:core-ktx:1.9.0'
44+
implementation 'androidx.core:core-ktx:1.7.0'
4745
implementation 'androidx.appcompat:appcompat:1.4.1'
4846
implementation 'com.google.android.material:material:1.5.0'
4947
implementation 'androidx.constraintlayout:constraintlayout:2.1.3'
5048
implementation 'androidx.core:core-ktx:+'
51-
implementation 'androidx.core:core-ktx:+'
5249
testImplementation 'junit:junit:4.+'
5350
androidTestImplementation 'androidx.test.ext:junit:1.1.3'
5451
androidTestImplementation 'androidx.test.espresso:espresso-core:3.4.0'

demo-app/src/main/java/co/thepeer/MainActivity.kt

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -59,14 +59,4 @@ class MainActivity : AppCompatActivity() {
5959

6060
}
6161

62-
63-
override fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent?) {
64-
super.onActivityResult(requestCode, resultCode, data)
65-
66-
if (requestCode == INITIATE_PAYMENT_REQUEST_CODE && resultCode == RESULT_OK) {
67-
Log.v("Demo", data?.getStringExtra(KEY_RESULT) ?: "")
68-
69-
}
70-
71-
}
7262
}

gradle.properties

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,4 +18,5 @@ android.useAndroidX=true
1818
# Automatically convert third-party libraries to use AndroidX
1919
android.enableJetifier=true
2020
# Kotlin code style for this project: "official" or "obsolete":
21-
kotlin.code.style=official
21+
kotlin.code.style=official
22+
android.disableAutomaticComponentCreation=true
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
#Wed Feb 09 22:24:53 WAT 2022
1+
#Sun Jan 29 21:57:51 WAT 2023
22
distributionBase=GRADLE_USER_HOME
3-
distributionUrl=https\://services.gradle.org/distributions/gradle-7.4-bin.zip
3+
distributionUrl=https\://services.gradle.org/distributions/gradle-7.5-bin.zip
44
distributionPath=wrapper/dists
55
zipStorePath=wrapper/dists
66
zipStoreBase=GRADLE_USER_HOME

java-demo/build.gradle

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,14 @@
11
plugins {
22
id 'com.android.application'
3-
id 'org.jetbrains.kotlin.android'
43
}
54

65
android {
7-
compileSdk 31
6+
compileSdkVersion 33
87

98
defaultConfig {
109
applicationId "com.example.java_demo"
11-
minSdk 21
12-
targetSdk 31
10+
minSdkVersion 21
11+
targetSdkVersion 33
1312
versionCode 1
1413
versionName "1.0"
1514

@@ -29,7 +28,7 @@ android {
2928
}
3029

3130
dependencies {
32-
implementation 'co.thepeer:thepeer-android:1.0.0-alpha05'
31+
implementation project(":thepeer-android")
3332
implementation 'androidx.appcompat:appcompat:1.4.1'
3433
implementation 'com.google.android.material:material:1.5.0'
3534
implementation 'androidx.constraintlayout:constraintlayout:2.1.3'

settings.gradle

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,17 @@
11
import org.gradle.api.initialization.resolve.RepositoriesMode
22

3+
pluginManagement {
4+
repositories {
5+
google()
6+
mavenCentral()
7+
gradlePluginPortal()
8+
}
9+
}
310
dependencyResolutionManagement {
411
repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
512
repositories {
613
google()
714
mavenCentral()
8-
915
}
1016
}
1117
rootProject.name = "thepeer-android"

thepeer-android/build.gradle

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4,18 +4,17 @@ plugins {
44
id 'kotlin-parcelize'
55
id 'kotlin-kapt'
66
id 'maven-publish'
7-
id 'org.jetbrains.kotlin.android'
87
}
98

109

1110
version = "1.0.0"
1211

1312
android {
14-
compileSdk 33
13+
compileSdkVersion 33
1514

1615
defaultConfig {
17-
minSdk 21
18-
targetSdk 33
16+
minSdkVersion 21
17+
targetSdkVersion 33
1918
versionCode 1
2019
versionName "1.0"
2120

@@ -47,17 +46,14 @@ android {
4746

4847
dependencies {
4948

50-
implementation 'androidx.core:core-ktx:1.9.0'
49+
implementation 'androidx.core:core-ktx:1.7.0'
5150
implementation 'androidx.appcompat:appcompat:1.4.2'
5251
implementation 'com.google.android.material:material:1.6.1'
5352
implementation 'androidx.constraintlayout:constraintlayout:2.1.4'
5453

5554
// Kotlin
56-
implementation "org.jetbrains.kotlinx:kotlinx-coroutines-android:$coroutineVersion"
5755
implementation "org.jetbrains.kotlin:kotlin-reflect:$kotlin_version"
5856
implementation 'androidx.webkit:webkit:1.4.0'
59-
implementation 'androidx.core:core-ktx:+'
60-
implementation 'androidx.core:core-ktx:+'
6157

6258
// MockK kotlin mocking framework
6359
testImplementation "io.mockk:mockk:$mockkVersion"
Lines changed: 75 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,22 @@
11
package co.thepeer.sdk.ui.activity
22

3+
import android.annotation.SuppressLint
4+
import android.content.Intent
5+
import android.os.Build
36
import android.os.Bundle
7+
import android.webkit.WebView
8+
import android.webkit.WebViewClient
9+
import androidx.activity.OnBackPressedCallback
410
import androidx.appcompat.app.AppCompatActivity
11+
import androidx.core.view.isVisible
512
import co.thepeer.sdk.databinding.SdkActivityBinding
613
import co.thepeer.sdk.model.ThepeerParam
14+
import co.thepeer.sdk.model.ThepeerResult
715
import co.thepeer.sdk.ui.fragments.ThepeerFragment
16+
import co.thepeer.sdk.utils.Logger
817
import co.thepeer.sdk.utils.ThepeerConstants
18+
import co.thepeer.sdk.utils.Urls
19+
import co.thepeer.sdk.utils.WebInterface
920

1021
class ThepeerSDKActivity : AppCompatActivity() {
1122
private var params: ThepeerParam? = null
@@ -14,21 +25,79 @@ class ThepeerSDKActivity : AppCompatActivity() {
1425
super.onCreate(savedInstanceState)
1526
binding = SdkActivityBinding.inflate(layoutInflater)
1627
setContentView(binding.root)
17-
params = intent.getParcelableExtra<ThepeerParam>(ThepeerConstants.THE_PEER_PARAMS)!!
28+
onBackPressedDispatcher.addCallback(this, onBackPressedCallback)
29+
30+
params = if (Build.VERSION.SDK_INT >= 33) {
31+
intent.getParcelableExtra(
32+
ThepeerConstants.THE_PEER_PARAMS,
33+
ThepeerParam::class.java
34+
)
35+
} else {
36+
intent.getParcelableExtra<ThepeerParam>(ThepeerConstants.THE_PEER_PARAMS)
37+
}
38+
39+
40+
if (params == null) {
41+
throw IllegalStateException("Params should not be null. Initialize thePeer using this function Thepeer.Builder(...)")
42+
}
1843

1944
params?.let {
20-
supportFragmentManager.beginTransaction()
21-
.replace(binding.fragmentContainer.id, ThepeerFragment(it))
22-
.commit()
45+
val url = Urls.createTransactionUrl(it)
46+
setupWebView(url)
47+
Logger.log(this, url)
2348
}
49+
50+
51+
2452
}
2553

26-
override fun onBackPressed() {
27-
finish()
54+
@SuppressLint("SetJavaScriptEnabled")
55+
private fun setupWebView(transactionUrl: String) {
56+
binding.webViewPeer.apply {
57+
settings.apply {
58+
javaScriptEnabled = true
59+
javaScriptCanOpenWindowsAutomatically = true
60+
domStorageEnabled = true
61+
}
62+
}
63+
binding.webViewPeer.webViewClient = object : WebViewClient() {
64+
override fun onPageFinished(view: WebView, url: String) {
65+
super.onPageFinished(view, url)
66+
binding.webViewPeer.isVisible = true
67+
}
68+
}
69+
70+
71+
binding.webViewPeer.addJavascriptInterface(
72+
WebInterface { results ->
73+
redirectWithResult(results)
74+
},
75+
"Android"
76+
)
77+
78+
binding.webViewPeer.loadUrl(transactionUrl)
2879
}
2980

3081
override fun onDestroy() {
3182
super.onDestroy()
3283
params = null
84+
binding.webViewPeer.loadUrl("about:blank")
85+
binding.webViewPeer.clearHistory()
86+
redirectWithResult(ThepeerResult.Cancelled)
87+
}
88+
89+
private fun redirectWithResult(result: ThepeerResult) {
90+
val resultData = Intent()
91+
resultData.putExtra(ThepeerConstants.TRANSACTION_RESULT, result)
92+
setResult(AppCompatActivity.RESULT_OK, resultData)
93+
finish()
3394
}
95+
96+
private val onBackPressedCallback: OnBackPressedCallback =
97+
object : OnBackPressedCallback(true) {
98+
override fun handleOnBackPressed() {
99+
params = null
100+
}
101+
}
102+
34103
}

thepeer-android/src/main/res/layout/sdk_activity.xml

Lines changed: 28 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,34 @@
66
android:layout_height="match_parent">
77

88

9-
<FrameLayout
10-
android:id="@+id/fragment_container"
9+
<androidx.constraintlayout.widget.ConstraintLayout
10+
android:id="@+id/design_bottom_sheet"
1111
android:layout_width="match_parent"
1212
android:layout_height="match_parent"
13-
/>
13+
android:background="@drawable/dialog_background">
14+
15+
<ProgressBar
16+
android:id="@+id/loading"
17+
android:layout_width="24dp"
18+
android:layout_height="24dp"
19+
android:background="@null"
20+
app:layout_constraintTop_toTopOf="parent"
21+
app:layout_constraintBottom_toBottomOf="parent"
22+
app:layout_constraintStart_toStartOf="parent"
23+
app:layout_constraintEnd_toEndOf="parent" />
24+
25+
<WebView
26+
android:id="@+id/webViewPeer"
27+
android:layout_width="0dp"
28+
android:layout_height="0dp"
29+
android:layout_marginTop="10dp"
30+
android:layout_marginBottom="10dp"
31+
app:layout_constraintTop_toTopOf="parent"
32+
app:layout_constraintBottom_toBottomOf="parent"
33+
app:layout_constraintStart_toStartOf="parent"
34+
app:layout_constraintHorizontal_bias="0.5"
35+
app:layout_constraintEnd_toEndOf="parent"
36+
android:visibility="gone" />
37+
38+
</androidx.constraintlayout.widget.ConstraintLayout>
1439
</androidx.coordinatorlayout.widget.CoordinatorLayout>

0 commit comments

Comments
 (0)