Selaa lähdekoodia

v1.0.1开发:hybrid页面非自己域名的url增加关闭按钮

#Suyghur 3 vuotta sitten
vanhempi
commit
042a4454ae

+ 1 - 1
config.gradle

@@ -3,7 +3,7 @@ ext {
     module = [
             remoteLib    : false,
             minifyEnabled: true,
-            publish      : false,
+            publish      : true,
             language: 2
     ]
 

+ 0 - 1
demo/build.gradle

@@ -13,7 +13,6 @@ android {
 
     defaultConfig {
         applicationId 'com.shzd.eyuangame'
-//        applicationId 'com.ftsx.eyuangame'
         minSdkVersion rootProject.ext.android.minSdkVersion
         targetSdkVersion rootProject.ext.android.targetSdkVersion
         versionCode 1

+ 0 - 3
demo/src/main/java/com/eyuangame/demo/CacheRoleInfo.kt

@@ -11,14 +11,11 @@ import org.json.JSONObject
  */
 class CacheRoleInfo {
 
-
     data class RoleInfo(
         var roleId: String = "", var roleName: String = "", var roleLevel: String = "",
         var serverCode: String = "", var serverName: String = "", var vipLevel: String = "",
         var balance: String = "", var totalPurchase: Int = 0, var roleCTime: Long = 0
     ) {
-
-
         fun toJsonString(): String {
             try {
                 val jsonObject = JSONObject()

+ 0 - 1
library_base/build.gradle

@@ -61,7 +61,6 @@ dependencies {
     api files('../libs/yyxx_support_1.0.1.jar')
     implementation 'androidx.core:core-ktx:1.7.0'
     implementation 'io.github.suyghur.dolin:zap:1.0.0'
-//    implementation 'androidx.appcompat:appcompat:1.4.0'
 }
 
 apply from: 'buildJar.gradle'

+ 1 - 1
library_base/buildJar.gradle

@@ -1,5 +1,5 @@
 def SDK_BASENAME = "eyuangamesdk_base"
-def SDK_VERSION = "1.0.0"
+def SDK_VERSION = "1.0.1"
 def SEPARATOR = "_"
 def sdkDestinationPath = "build/jar/"
 def zipFile = file('build/intermediates/aar_main_jar/release/classes.jar')

+ 2 - 2
library_base/src/main/java/cn/yyxx/eyuangame/Version.kt

@@ -5,7 +5,7 @@ package cn.yyxx.eyuangame
  * Created on 2021/06/09
  */
 object Version {
-    const val VERSION_NAME = "1.0.0"
-    const val VERSION_CODE = 100
+    const val VERSION_NAME = "1.0.1"
+    const val VERSION_CODE = 101
     const val SERVER_VERSION = "1.0.0"
 }

+ 1 - 1
library_core/build.gradle

@@ -100,7 +100,7 @@ dependencies {
     implementation 'com.adjust.sdk:adjust-android:4.28.2'
 
     if (rootProject.ext.module.publish) {
-        api files('../libs/eyuangamesdk_base_1.0.0.jar')
+        api files('../libs/eyuangamesdk_base_1.0.1.jar')
     } else {
         api project(':library_base')
     }

+ 1 - 1
library_core/publish.gradle

@@ -4,7 +4,7 @@ apply plugin: 'signing'
 ext {
     PUBLISH_GROUP_ID = 'io.github.yyxxgame.sdk'
     PUBLISH_ARTIFACT_ID = 'eyuangame-sdk-ktx'
-    PUBLISH_VERSION = '1.0.0'
+    PUBLISH_VERSION = '1.0.1-rc1'
 }
 
 Properties properties = new Properties()

+ 20 - 12
library_core/src/main/java/cn/yyxx/eyuangame/core/impl/center/HybridActivity.kt

@@ -11,6 +11,7 @@ import android.view.View
 import android.view.WindowManager
 import android.webkit.*
 import android.widget.FrameLayout
+import android.widget.ImageView
 import cn.yyxx.eyuangame.base.utils.Logger
 import cn.yyxx.eyuangame.core.entity.ClickType
 import cn.yyxx.eyuangame.core.entity.SdkBackLoginInfo
@@ -20,6 +21,7 @@ import cn.yyxx.eyuangame.core.impl.SdkJsImpl
 import cn.yyxx.eyuangame.core.impl.share.ShareImpl
 import cn.yyxx.eyuangame.core.internal.IImplCallback
 import cn.yyxx.eyuangame.core.internal.IJsCallback
+import cn.yyxx.eyuangame.core.network.Host
 import cn.yyxx.eyuangame.core.ui.dialog.ScaleLoadingDialog
 import cn.yyxx.support.AndroidBug5497Workaround
 import cn.yyxx.support.JsonUtils
@@ -34,8 +36,9 @@ import org.json.JSONObject
 class HybridActivity : Activity(), View.OnClickListener {
 
     private var uploadMessageForAndroid5: ValueCallback<Array<Uri>>? = null
-    private var mFileChooseParams: WebChromeClient.FileChooserParams? = null
+    private lateinit var container: FrameLayout
     private lateinit var webView: WebView
+    private lateinit var ivClose: ImageView
     private var loadingDialog: ScaleLoadingDialog? = null
 
 
@@ -44,6 +47,7 @@ class HybridActivity : Activity(), View.OnClickListener {
         override fun onCallback(method: String, data: String): String {
             when (method) {
                 "getCommon" -> return SdkDrive.instance.getComm(this@HybridActivity)
+                "getToken" -> return SdkBackLoginInfo.instance.token
                 "close" -> {
                     runOnUiThread {
                         this@HybridActivity.finish()
@@ -132,14 +136,19 @@ class HybridActivity : Activity(), View.OnClickListener {
 
 
     private fun initWebView() {
-        webView = WebView(this)
+        container = findViewById(ResUtils.getResId(this, "yyxx_webview_container", "id"))
+
+        webView = findViewById(ResUtils.getResId(this, "yyxx_webview", "id"))
         webView.isVerticalScrollBarEnabled = true
         webView.scrollBarStyle = View.SCROLLBARS_INSIDE_OVERLAY
         webView.addJavascriptInterface(SdkJsImpl(callback), "eyuangame")
         webView.setBackgroundColor(Color.TRANSPARENT)
-//        webView.alpha = 0F
-        val container = findViewById<FrameLayout>(ResUtils.getResId(this, "yyxx_webview_container", "id"))
-        container.addView(webView)
+
+        ivClose = findViewById(ResUtils.getResId(this, "yyxx_iv_close", "id"))
+        ivClose.visibility = View.GONE
+        ivClose.setOnClickListener {
+            this.finish()
+        }
 
 //        webView.viewTreeObserver.addOnGlobalLayoutListener {
 //            if (isSoftShowing()) {
@@ -167,6 +176,7 @@ class HybridActivity : Activity(), View.OnClickListener {
         webSetting.databasePath = getDir("databases", 0).path
         webSetting.setGeolocationDatabasePath(getDir("geolocation", 0).path)
         webSetting.pluginState = WebSettings.PluginState.ON_DEMAND
+        webSetting.cacheMode = WebSettings.LOAD_NO_CACHE
         CookieSyncManager.createInstance(this)
         CookieSyncManager.getInstance().sync()
 
@@ -190,14 +200,12 @@ class HybridActivity : Activity(), View.OnClickListener {
 
             override fun shouldOverrideUrlLoading(view: WebView, url: String): Boolean {
                 val hitTestResult = view.hitTestResult
-                // 处理paypal
-                if (url.startsWith("https://www.sandbox.paypal.com")
-                    || url.startsWith("https://www.paypal.com")
-                    || url.startsWith("intent://")
-                ) {
-                    container.setBackgroundColor(Color.parseColor("#FFFFFF"))
-                } else {
+                if (Host.originHost(url)) {
                     container.setBackgroundColor(Color.parseColor("#00FFFFFF"))
+                    ivClose.visibility = View.GONE
+                } else {
+                    container.setBackgroundColor(Color.parseColor("#FFFFFF"))
+                    ivClose.visibility = View.VISIBLE
                 }
 
                 if (url.startsWith("http:") || url.startsWith("https:")) {

+ 8 - 0
library_core/src/main/java/cn/yyxx/eyuangame/core/network/Host.kt

@@ -52,6 +52,14 @@ object Host {
         setDefaultHost()
     }
 
+    fun originHost(url: String): Boolean {
+        return (url.startsWith(DEFAULT_ONLINE_HOST_HK)
+                || url.startsWith(DEFAULT_TEST_HOST_HK)
+                || url.startsWith(DEFAULT_ONLINE_HOST_VN)
+                || url.startsWith(DEFAULT_TEST_HOST_VN))
+
+    }
+
     private fun setDefaultHost() {
         DEFAULT_ONLINE_HOST = when (ENV) {
             Env.HK -> DEFAULT_ONLINE_HOST_HK

+ 1 - 0
library_core/src/main/java/cn/yyxx/eyuangame/core/ui/dialog/AgreementDialog.kt

@@ -75,6 +75,7 @@ class AgreementDialog constructor(context: Context, url: String, private val isL
         webSetting.databasePath = context.getDir("databases", 0).path
         webSetting.setGeolocationDatabasePath(context.getDir("geolocation", 0).path)
         webSetting.pluginState = WebSettings.PluginState.ON_DEMAND
+        webSetting.cacheMode = WebSettings.LOAD_NO_CACHE
         CookieSyncManager.createInstance(context)
         CookieSyncManager.getInstance().sync()
 

BIN
library_core/src/main/res/drawable-xhdpi/yyxx_close_img.png


+ 18 - 8
library_core/src/main/res/layout-land/yyxx_hybrid.xml

@@ -1,6 +1,5 @@
 <?xml version="1.0" encoding="utf-8"?>
-<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
-    xmlns:app="http://schemas.android.com/apk/res-auto"
+<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
     android:layout_width="match_parent"
     android:layout_height="wrap_content"
     android:layout_gravity="center"
@@ -11,10 +10,21 @@
         android:layout_width="match_parent"
         android:layout_height="300dp"
         android:layout_margin="50dp"
-        android:background="@color/yyxx_transparent"
-        app:layout_constraintBottom_toBottomOf="parent"
-        app:layout_constraintEnd_toEndOf="parent"
-        app:layout_constraintStart_toStartOf="parent"
-        app:layout_constraintTop_toTopOf="parent" />
+        android:background="@color/yyxx_transparent">
 
-</androidx.constraintlayout.widget.ConstraintLayout>
+        <WebView
+            android:id="@+id/yyxx_webview"
+            android:layout_width="match_parent"
+            android:layout_height="match_parent" />
+
+        <ImageView
+            android:id="@+id/yyxx_iv_close"
+            android:layout_width="15dp"
+            android:layout_height="15dp"
+            android:layout_gravity="top|right"
+            android:layout_marginTop="10dp"
+            android:layout_marginRight="10dp"
+            android:src="@drawable/yyxx_close_img" />
+    </FrameLayout>
+
+</FrameLayout>

+ 18 - 8
library_core/src/main/res/layout/yyxx_hybrid.xml

@@ -1,6 +1,5 @@
 <?xml version="1.0" encoding="utf-8"?>
-<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
-    xmlns:app="http://schemas.android.com/apk/res-auto"
+<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
     android:layout_width="match_parent"
     android:layout_height="wrap_content"
     android:layout_gravity="center"
@@ -11,10 +10,21 @@
         android:layout_width="match_parent"
         android:layout_height="320dp"
         android:layout_margin="20dp"
-        android:background="@color/yyxx_transparent"
-        app:layout_constraintBottom_toBottomOf="parent"
-        app:layout_constraintEnd_toEndOf="parent"
-        app:layout_constraintStart_toStartOf="parent"
-        app:layout_constraintTop_toTopOf="parent" />
+        android:background="@color/yyxx_transparent">
 
-</androidx.constraintlayout.widget.ConstraintLayout>
+        <WebView
+            android:id="@+id/yyxx_webview"
+            android:layout_width="match_parent"
+            android:layout_height="match_parent" />
+
+        <ImageView
+            android:id="@+id/yyxx_iv_close"
+            android:layout_width="15dp"
+            android:layout_height="15dp"
+            android:layout_gravity="top|right"
+            android:layout_marginTop="10dp"
+            android:layout_marginRight="10dp"
+            android:src="@drawable/yyxx_close_img" />
+    </FrameLayout>
+
+</FrameLayout>

+ 2 - 0
library_hk_language/build.gradle

@@ -60,3 +60,5 @@ android {
 dependencies {
 
 }
+
+apply from: 'publish.gradle'

+ 110 - 0
library_hk_language/publish.gradle

@@ -0,0 +1,110 @@
+apply plugin: 'maven-publish'
+apply plugin: 'signing'
+
+ext {
+    PUBLISH_GROUP_ID = 'io.github.yyxxgame.sdk'
+    PUBLISH_ARTIFACT_ID = 'eyuangame-component-lang-hk'
+    PUBLISH_VERSION = '1.0.1-rc1'
+}
+
+Properties properties = new Properties()
+properties.load(project.rootProject.file('local.properties').newDataInputStream())
+
+def ossrhUsername = properties.getProperty("SonaType.user")
+def ossrhPassword = properties.getProperty("SonaType.pwd")
+
+task androidSourcesJar(type: Jar) {
+    archiveClassifier.set('source')
+    if (project.plugins.findPlugin('com.android.library')) {
+        from android.sourceSets.main.java.srcDirs
+    } else {
+        form sourceSets.main.java.srcDirs
+    }
+    exclude "**/R.class"
+    exclude "**/BuildConfig.class"
+}
+
+publishing {
+    publications {
+        release(MavenPublication) {
+            // The coordinates of the library, being set from variables that
+            // we'll set up in a moment
+            groupId PUBLISH_GROUP_ID
+            artifactId PUBLISH_ARTIFACT_ID
+            version PUBLISH_VERSION
+
+            // Two artifacts, the `aar` and the sources
+            artifact("$buildDir/outputs/aar/${project.getName()}-release.aar")
+            artifact androidSourcesJar
+
+            // Self-explanatory metadata for the most part
+            pom {
+                name = "${PUBLISH_GROUP_ID}:${PUBLISH_ARTIFACT_ID}"
+                description = 'game sdk of eyuan'
+                // If your project has a dedicated site, use its URL here
+                url = 'https://github.com/yyxxgame'
+                licenses {
+                    license {
+                        //协议类型,一般默认Apache License2.0的话不用改:
+                        name = 'The Apache License, Version 2.0'
+                        url = 'http://www.apache.org/licenses/LICENSE-2.0.txt'
+                    }
+                }
+                developers {
+                    developer {
+                        id = 'yyxxgame'
+                        name = 'yyxxgame'
+                        email = 'developcentre@yyxxgame.com'
+                    }
+                }
+                // Version control info, if you're using GitHub, follow the format as seen here
+                scm {
+                    //修改成你的Git地址:
+                    connection = 'scm:git:gogs.yyxxgame.com:3000/Client/EYuanGameSdk-KTX.git'
+                    developerConnection = 'scm:git:ssh://gogs.yyxxgame.com:3000/Client/EYuanGameSdk-KTX.git'
+                    //分支地址:
+                    url = 'http://gogs.yyxxgame.com/Client/EYuanGameSdk-KTX'
+                }
+                // A slightly hacky fix so that your POM will include any transitive dependencies
+                // that your library builds upon
+                withXml {
+                    def dependenciesNode = asNode().appendNode('dependencies')
+                    for (def node : project.configurations.implementation.allDependencies) {
+                        if (node.group == "null" || node.name == "unspecified" || node.version == "null") {
+                            break
+                        }
+                        def dependencyNode = dependenciesNode.appendNode('dependency')
+                        dependencyNode.appendNode('groupId', node.group)
+                        dependencyNode.appendNode('artifactId', node.name)
+                        dependencyNode.appendNode('version', node.version)
+                    }
+                }
+            }
+        }
+    }
+    repositories {
+        // The repository to publish to, Sonatype/MavenCentral
+        maven {
+            // This is an arbitrary name, you may also use "mavencentral" or
+            // any other name that's descriptive for you
+            name = "mavencentral"
+
+            def releasesRepoUrl = "https://s01.oss.sonatype.org/service/local/staging/deploy/maven2/"
+            def snapshotsRepoUrl = "https://s01.oss.sonatype.org/content/repositories/snapshots/"
+            // You only need this if you want to publish snapshots, otherwise just set the URL
+            // to the release repo directly
+            url = version.endsWith('SNAPSHOT') ? snapshotsRepoUrl : releasesRepoUrl
+
+            // The username and password we've fetched earlier
+            credentials {
+                username ossrhUsername
+                password ossrhPassword
+            }
+        }
+    }
+}
+signing {
+    sign publishing.publications
+}
+
+publishReleasePublicationToMavencentralRepository.dependsOn(assemble)

+ 2 - 0
library_vn_language/build.gradle

@@ -60,3 +60,5 @@ android {
 dependencies {
 
 }
+
+apply from: 'publish.gradle'

+ 110 - 0
library_vn_language/publish.gradle

@@ -0,0 +1,110 @@
+apply plugin: 'maven-publish'
+apply plugin: 'signing'
+
+ext {
+    PUBLISH_GROUP_ID = 'io.github.yyxxgame.sdk'
+    PUBLISH_ARTIFACT_ID = 'eyuangame-component-lang-vn'
+    PUBLISH_VERSION = '1.0.1-rc1'
+}
+
+Properties properties = new Properties()
+properties.load(project.rootProject.file('local.properties').newDataInputStream())
+
+def ossrhUsername = properties.getProperty("SonaType.user")
+def ossrhPassword = properties.getProperty("SonaType.pwd")
+
+task androidSourcesJar(type: Jar) {
+    archiveClassifier.set('source')
+    if (project.plugins.findPlugin('com.android.library')) {
+        from android.sourceSets.main.java.srcDirs
+    } else {
+        form sourceSets.main.java.srcDirs
+    }
+    exclude "**/R.class"
+    exclude "**/BuildConfig.class"
+}
+
+publishing {
+    publications {
+        release(MavenPublication) {
+            // The coordinates of the library, being set from variables that
+            // we'll set up in a moment
+            groupId PUBLISH_GROUP_ID
+            artifactId PUBLISH_ARTIFACT_ID
+            version PUBLISH_VERSION
+
+            // Two artifacts, the `aar` and the sources
+            artifact("$buildDir/outputs/aar/${project.getName()}-release.aar")
+            artifact androidSourcesJar
+
+            // Self-explanatory metadata for the most part
+            pom {
+                name = "${PUBLISH_GROUP_ID}:${PUBLISH_ARTIFACT_ID}"
+                description = 'game sdk of eyuan'
+                // If your project has a dedicated site, use its URL here
+                url = 'https://github.com/yyxxgame'
+                licenses {
+                    license {
+                        //协议类型,一般默认Apache License2.0的话不用改:
+                        name = 'The Apache License, Version 2.0'
+                        url = 'http://www.apache.org/licenses/LICENSE-2.0.txt'
+                    }
+                }
+                developers {
+                    developer {
+                        id = 'yyxxgame'
+                        name = 'yyxxgame'
+                        email = 'developcentre@yyxxgame.com'
+                    }
+                }
+                // Version control info, if you're using GitHub, follow the format as seen here
+                scm {
+                    //修改成你的Git地址:
+                    connection = 'scm:git:gogs.yyxxgame.com:3000/Client/EYuanGameSdk-KTX.git'
+                    developerConnection = 'scm:git:ssh://gogs.yyxxgame.com:3000/Client/EYuanGameSdk-KTX.git'
+                    //分支地址:
+                    url = 'http://gogs.yyxxgame.com/Client/EYuanGameSdk-KTX'
+                }
+                // A slightly hacky fix so that your POM will include any transitive dependencies
+                // that your library builds upon
+                withXml {
+                    def dependenciesNode = asNode().appendNode('dependencies')
+                    for (def node : project.configurations.implementation.allDependencies) {
+                        if (node.group == "null" || node.name == "unspecified" || node.version == "null") {
+                            break
+                        }
+                        def dependencyNode = dependenciesNode.appendNode('dependency')
+                        dependencyNode.appendNode('groupId', node.group)
+                        dependencyNode.appendNode('artifactId', node.name)
+                        dependencyNode.appendNode('version', node.version)
+                    }
+                }
+            }
+        }
+    }
+    repositories {
+        // The repository to publish to, Sonatype/MavenCentral
+        maven {
+            // This is an arbitrary name, you may also use "mavencentral" or
+            // any other name that's descriptive for you
+            name = "mavencentral"
+
+            def releasesRepoUrl = "https://s01.oss.sonatype.org/service/local/staging/deploy/maven2/"
+            def snapshotsRepoUrl = "https://s01.oss.sonatype.org/content/repositories/snapshots/"
+            // You only need this if you want to publish snapshots, otherwise just set the URL
+            // to the release repo directly
+            url = version.endsWith('SNAPSHOT') ? snapshotsRepoUrl : releasesRepoUrl
+
+            // The username and password we've fetched earlier
+            credentials {
+                username ossrhUsername
+                password ossrhPassword
+            }
+        }
+    }
+}
+signing {
+    sign publishing.publications
+}
+
+publishReleasePublicationToMavencentralRepository.dependsOn(assemble)

BIN
libs/eyuangamesdk_base_1.0.0.jar


BIN
libs/eyuangamesdk_base_1.0.1.jar


BIN
zkeystore/ftsx_yyxx.keystore