commit 3897ed262ba37b2d0e5b80c76d2ae7189471b23b Author: 18631081161 <2088094923@qq.com> Date: Sat Dec 28 15:57:33 2024 +0800 First push diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..2c15f2d --- /dev/null +++ b/.gitignore @@ -0,0 +1,44 @@ +# Miscellaneous +*.class +*.log +*.pyc +*.swp +.DS_Store +.atom/ +.buildlog/ +.history +.svn/ +migrate_working_dir/ + +# IntelliJ related +*.iml +*.ipr +*.iws +.idea/ + +# The .vscode folder contains launch configuration and tasks you configure in +# VS Code which you may wish to be included in version control, so this line +# is commented out by default. +#.vscode/ + +# Flutter/Dart/Pub related +**/doc/api/ +**/ios/Flutter/.last_build_id +.dart_tool/ +.flutter-plugins +.flutter-plugins-dependencies +.pub-cache/ +.pub/ +/build/ + +# Symbolication related +app.*.symbols + +# Obfuscation related +app.*.map.json + +# Android Studio will place build artifacts here +/android/app/debug +/android/app/profile +/android/app/release +/pubspec.lock diff --git a/.metadata b/.metadata new file mode 100644 index 0000000..ff28e46 --- /dev/null +++ b/.metadata @@ -0,0 +1,33 @@ +# This file tracks properties of this Flutter project. +# Used by Flutter tool to assess capabilities and perform upgrades etc. +# +# This file should be version controlled and should not be manually edited. + +version: + revision: "54e66469a933b60ddf175f858f82eaeb97e48c8d" + channel: "stable" + +project_type: app + +# Tracks metadata for the flutter migrate command +migration: + platforms: + - platform: root + create_revision: 54e66469a933b60ddf175f858f82eaeb97e48c8d + base_revision: 54e66469a933b60ddf175f858f82eaeb97e48c8d + - platform: android + create_revision: 54e66469a933b60ddf175f858f82eaeb97e48c8d + base_revision: 54e66469a933b60ddf175f858f82eaeb97e48c8d + - platform: ios + create_revision: 54e66469a933b60ddf175f858f82eaeb97e48c8d + base_revision: 54e66469a933b60ddf175f858f82eaeb97e48c8d + + # User provided section + + # List of Local paths (relative to this file) that should be + # ignored by the migrate tool. + # + # Files that are not part of the templates will be ignored by default. + unmanaged_files: + - 'lib/main.dart' + - 'ios/Runner.xcodeproj/project.pbxproj' diff --git a/README.md b/README.md new file mode 100644 index 0000000..3d3d4ba --- /dev/null +++ b/README.md @@ -0,0 +1,16 @@ +# cargame + +A new Flutter project. + +## Getting Started + +This project is a starting point for a Flutter application. + +A few resources to get you started if this is your first Flutter project: + +- [Lab: Write your first Flutter app](https://docs.flutter.dev/get-started/codelab) +- [Cookbook: Useful Flutter samples](https://docs.flutter.dev/cookbook) + +For help getting started with Flutter development, view the +[online documentation](https://docs.flutter.dev/), which offers tutorials, +samples, guidance on mobile development, and a full API reference. diff --git a/analysis_options.yaml b/analysis_options.yaml new file mode 100644 index 0000000..0d29021 --- /dev/null +++ b/analysis_options.yaml @@ -0,0 +1,28 @@ +# This file configures the analyzer, which statically analyzes Dart code to +# check for errors, warnings, and lints. +# +# The issues identified by the analyzer are surfaced in the UI of Dart-enabled +# IDEs (https://dart.dev/tools#ides-and-editors). The analyzer can also be +# invoked from the command line by running `flutter analyze`. + +# The following line activates a set of recommended lints for Flutter apps, +# packages, and plugins designed to encourage good coding practices. +include: package:flutter_lints/flutter.yaml + +linter: + # The lint rules applied to this project can be customized in the + # section below to disable rules from the `package:flutter_lints/flutter.yaml` + # included above or to enable additional rules. A list of all available lints + # and their documentation is published at https://dart.dev/lints. + # + # Instead of disabling a lint rule for the entire project in the + # section below, it can also be suppressed for a single line of code + # or a specific dart file by using the `// ignore: name_of_lint` and + # `// ignore_for_file: name_of_lint` syntax on the line or in the file + # producing the lint. + rules: + # avoid_print: false # Uncomment to disable the `avoid_print` rule + # prefer_single_quotes: true # Uncomment to enable the `prefer_single_quotes` rule + +# Additional information about this file can be found at +# https://dart.dev/guides/language/analysis-options diff --git a/android/.gitignore b/android/.gitignore new file mode 100644 index 0000000..6f56801 --- /dev/null +++ b/android/.gitignore @@ -0,0 +1,13 @@ +gradle-wrapper.jar +/.gradle +/captures/ +/gradlew +/gradlew.bat +/local.properties +GeneratedPluginRegistrant.java + +# Remember to never publicly share your keystore. +# See https://flutter.dev/docs/deployment/android#reference-the-keystore-from-the-app +key.properties +**/*.keystore +**/*.jks diff --git a/android/app/build.gradle b/android/app/build.gradle new file mode 100644 index 0000000..193b5fd --- /dev/null +++ b/android/app/build.gradle @@ -0,0 +1,121 @@ +plugins { + id "com.android.application" + id "kotlin-android" + id "dev.flutter.flutter-gradle-plugin" +} + +def localProperties = new Properties() +def localPropertiesFile = rootProject.file('local.properties') +if (localPropertiesFile.exists()) { + localPropertiesFile.withReader('UTF-8') { reader -> + localProperties.load(reader) + } +} + +def flutterVersionCode = localProperties.getProperty('flutter.versionCode') +if (flutterVersionCode == null) { + flutterVersionCode = '1' +} + +def flutterVersionName = localProperties.getProperty('flutter.versionName') +if (flutterVersionName == null) { + flutterVersionName = '1.0' +} + +android { + namespace "co.steamcloud.cargame" + compileSdk flutter.compileSdkVersion + ndkVersion flutter.ndkVersion + + compileOptions { + sourceCompatibility JavaVersion.VERSION_1_8 + targetCompatibility JavaVersion.VERSION_1_8 + } + + signingConfigs { + //签名的配置 + signConfig { + storeFile file("game.jks") + storePassword '123456' + keyAlias 'game' + keyPassword '123456' + } + + debug { + storeFile file("game.jks") + storePassword '123456' + keyAlias 'game' + keyPassword '123456' + } + + } + + defaultConfig { + // TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html). + applicationId "co.steamcloud.cargame" + // You can update the following values to match your application needs. + // For more information, see: https://docs.flutter.dev/deployment/android#reviewing-the-gradle-build-configuration. + minSdkVersion flutter.minSdkVersion + targetSdkVersion flutter.targetSdkVersion + versionCode flutterVersionCode.toInteger() + versionName flutterVersionName + ndk { + abiFilters "armeabi-v7a", "arm64-v8a", "x86" + } + multiDexEnabled true + } + + buildTypes { + release { + // TODO: Add your own signing config for the release build. + // Signing with the debug keys for now, so `flutter run --release` works. + signingConfig signingConfigs.signConfig //打包命令行:gradlew assembleRelease + proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' + + //关闭混淆 + minifyEnabled false //删除无用代码 + shrinkResources false //删除无用资源 + } + } + + dependencies { + implementation fileTree(dir: 'libs', include: ['*.jar', '*.aar']) + implementation 'androidx.appcompat:appcompat:1.2.0' + implementation 'com.google.android.material:material:1.3.0' + implementation 'androidx.constraintlayout:constraintlayout:2.0.4' + + implementation 'com.squareup.okhttp3:okhttp:3.9.0' + implementation 'com.squareup.okhttp3:logging-interceptor:3.9.0' //OKHttp优化策略依赖 + implementation 'com.squareup.okio:okio:1.13.0' + implementation 'org.greenrobot:eventbus:3.1.1' + implementation 'com.google.code.gson:gson:2.10.1' + + //配置glide图片加载框架 + implementation 'com.github.bumptech.glide:glide:3.7.0' + implementation 'com.github.bumptech.glide:okhttp3-integration:1.4.0@aar' + + //lottie动画 + implementation 'com.airbnb.android:lottie:4.2.2' + + // 支付宝 SDK AAR 包所需的配置 + api 'com.alipay.sdk:alipaysdk-android:15.8.17' + api 'com.android.support:support-v4:28.0.0' + api "com.android.support:appcompat-v7:28.0.0" + + //微信 + api 'com.tencent.mm.opensdk:wechat-sdk-android:6.8.30' + + + // api 'org.greenrobot:eventbus:3.3.1' + //配置eventbus + implementation 'org.simple:androideventbus:1.0.5.1' + + //二维码 + implementation 'com.google.zxing:core:3.3.0' + + } +} + +flutter { + source '../..' +} diff --git a/android/app/game.jks b/android/app/game.jks new file mode 100644 index 0000000..0445118 Binary files /dev/null and b/android/app/game.jks differ diff --git a/android/app/libs/cloudgamelibrary-2.4.115.aar b/android/app/libs/cloudgamelibrary-2.4.115.aar new file mode 100644 index 0000000..cc001bc Binary files /dev/null and b/android/app/libs/cloudgamelibrary-2.4.115.aar differ diff --git a/android/app/src/debug/AndroidManifest.xml b/android/app/src/debug/AndroidManifest.xml new file mode 100644 index 0000000..399f698 --- /dev/null +++ b/android/app/src/debug/AndroidManifest.xml @@ -0,0 +1,7 @@ + + + + diff --git a/android/app/src/main/AndroidManifest.xml b/android/app/src/main/AndroidManifest.xml new file mode 100644 index 0000000..6e7076e --- /dev/null +++ b/android/app/src/main/AndroidManifest.xml @@ -0,0 +1,111 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/android/app/src/main/assets/loading.json b/android/app/src/main/assets/loading.json new file mode 100644 index 0000000..c5ca962 --- /dev/null +++ b/android/app/src/main/assets/loading.json @@ -0,0 +1 @@ +{"v":"5.7.1","fr":25,"ip":0,"op":50,"w":512,"h":512,"nm":"logo_2","ddd":0,"assets":[],"layers":[{"ddd":0,"ind":1,"ty":4,"nm":"矩形","sr":1,"ks":{"o":{"a":0,"k":100,"ix":11},"r":{"a":0,"k":0,"ix":10},"p":{"a":1,"k":[{"i":{"x":0.833,"y":0.833},"o":{"x":0.167,"y":0.167},"t":0,"s":[255.943,107.75,0],"to":[0,0,0],"ti":[0,0,0]},{"t":10,"s":[255.943,428.75,0]}],"ix":2},"a":{"a":0,"k":[0,0,0],"ix":1},"s":{"a":1,"k":[{"i":{"x":[0.833,0.833,0.833],"y":[0.833,0.833,0.833]},"o":{"x":[0.167,0.167,0.167],"y":[0.167,0.167,0.167]},"t":0,"s":[100,100,100]},{"i":{"x":[0.833,0.833,0.833],"y":[0.833,0.833,0.833]},"o":{"x":[0.167,0.167,0.167],"y":[0.167,0.167,0.167]},"t":10,"s":[100,26,100]},{"t":11,"s":[100,0,100]}],"ix":6}},"ao":0,"ef":[{"ty":5,"nm":"real glow","np":16,"mn":"ADBE Glo2","ix":1,"en":1,"ef":[{"ty":7,"nm":"发光基于","mn":"ADBE Glo2-0001","ix":1,"v":{"a":0,"k":2,"ix":1}},{"ty":0,"nm":"发光阈值","mn":"ADBE Glo2-0002","ix":2,"v":{"a":0,"k":153,"ix":2}},{"ty":0,"nm":"发光半径","mn":"ADBE Glo2-0003","ix":3,"v":{"a":0,"k":10,"ix":3}},{"ty":0,"nm":"发光强度","mn":"ADBE Glo2-0004","ix":4,"v":{"a":0,"k":1,"ix":4}},{"ty":7,"nm":"合成原始项目","mn":"ADBE Glo2-0005","ix":5,"v":{"a":0,"k":2,"ix":5}},{"ty":7,"nm":"发光操作","mn":"ADBE Glo2-0006","ix":6,"v":{"a":0,"k":3,"ix":6}},{"ty":7,"nm":"发光颜色","mn":"ADBE Glo2-0007","ix":7,"v":{"a":0,"k":2,"ix":7}},{"ty":7,"nm":"颜色循环","mn":"ADBE Glo2-0008","ix":8,"v":{"a":0,"k":3,"ix":8}},{"ty":0,"nm":"颜色循环","mn":"ADBE Glo2-0009","ix":9,"v":{"a":0,"k":1,"ix":9}},{"ty":0,"nm":"色彩相位","mn":"ADBE Glo2-0010","ix":10,"v":{"a":0,"k":0,"ix":10}},{"ty":0,"nm":"A 和 B 中点","mn":"ADBE Glo2-0011","ix":11,"v":{"a":0,"k":0.5,"ix":11}},{"ty":2,"nm":"颜色 A","mn":"ADBE Glo2-0012","ix":12,"v":{"a":0,"k":[0,0.172549024224,1,1],"ix":12}},{"ty":2,"nm":"颜色 B","mn":"ADBE Glo2-0013","ix":13,"v":{"a":0,"k":[0,0.172549024224,1,1],"ix":13}},{"ty":7,"nm":"发光维度","mn":"ADBE Glo2-0014","ix":14,"v":{"a":0,"k":1,"ix":14}}]}],"shapes":[{"ty":"gr","it":[{"ty":"rc","d":1,"s":{"a":0,"k":[19.5,48.5],"ix":2},"p":{"a":0,"k":[0,0],"ix":3},"r":{"a":0,"k":10,"ix":4},"nm":"矩形路径 1","mn":"ADBE Vector Shape - Rect","hd":false},{"ty":"fl","c":{"a":0,"k":[1,1,1,1],"ix":4},"o":{"a":0,"k":100,"ix":5},"r":1,"bm":0,"nm":"填充 1","mn":"ADBE Vector Graphic - Fill","hd":false},{"ty":"tr","p":{"a":0,"k":[0,0],"ix":2},"a":{"a":0,"k":[0,0],"ix":1},"s":{"a":0,"k":[100,100],"ix":3},"r":{"a":0,"k":0,"ix":6},"o":{"a":0,"k":100,"ix":7},"sk":{"a":0,"k":0,"ix":4},"sa":{"a":0,"k":0,"ix":5},"nm":"变换"}],"nm":"矩形","np":2,"cix":2,"bm":0,"ix":1,"mn":"ADBE Vector Group","hd":false}],"ip":0,"op":54,"st":0,"bm":0},{"ddd":0,"ind":2,"ty":4,"nm":"路径 3","sr":1,"ks":{"o":{"a":0,"k":100,"ix":11},"r":{"a":0,"k":0,"ix":10},"p":{"a":0,"k":[255.943,256.25,0],"ix":2},"a":{"a":0,"k":[0,0,0],"ix":1},"s":{"a":0,"k":[100,100,100],"ix":6}},"ao":0,"ef":[{"ty":5,"nm":"real glow","np":16,"mn":"ADBE Glo2","ix":1,"en":1,"ef":[{"ty":7,"nm":"发光基于","mn":"ADBE Glo2-0001","ix":1,"v":{"a":0,"k":2,"ix":1}},{"ty":0,"nm":"发光阈值","mn":"ADBE Glo2-0002","ix":2,"v":{"a":0,"k":153,"ix":2}},{"ty":0,"nm":"发光半径","mn":"ADBE Glo2-0003","ix":3,"v":{"a":0,"k":36,"ix":3}},{"ty":0,"nm":"发光强度","mn":"ADBE Glo2-0004","ix":4,"v":{"a":0,"k":1,"ix":4}},{"ty":7,"nm":"合成原始项目","mn":"ADBE Glo2-0005","ix":5,"v":{"a":0,"k":2,"ix":5}},{"ty":7,"nm":"发光操作","mn":"ADBE Glo2-0006","ix":6,"v":{"a":0,"k":3,"ix":6}},{"ty":7,"nm":"发光颜色","mn":"ADBE Glo2-0007","ix":7,"v":{"a":0,"k":2,"ix":7}},{"ty":7,"nm":"颜色循环","mn":"ADBE Glo2-0008","ix":8,"v":{"a":0,"k":3,"ix":8}},{"ty":0,"nm":"颜色循环","mn":"ADBE Glo2-0009","ix":9,"v":{"a":0,"k":1,"ix":9}},{"ty":0,"nm":"色彩相位","mn":"ADBE Glo2-0010","ix":10,"v":{"a":0,"k":0,"ix":10}},{"ty":0,"nm":"A 和 B 中点","mn":"ADBE Glo2-0011","ix":11,"v":{"a":0,"k":0.5,"ix":11}},{"ty":2,"nm":"颜色 A","mn":"ADBE Glo2-0012","ix":12,"v":{"a":0,"k":[0,0.173070013523,1,1],"ix":12}},{"ty":2,"nm":"颜色 B","mn":"ADBE Glo2-0013","ix":13,"v":{"a":0,"k":[0,0.172549024224,1,1],"ix":13}},{"ty":7,"nm":"发光维度","mn":"ADBE Glo2-0014","ix":14,"v":{"a":0,"k":1,"ix":14}}]}],"shapes":[{"ty":"gr","it":[{"ind":0,"ty":"sh","ix":1,"ks":{"a":0,"k":{"i":[[-46.64,0],[-12.67,-42.54],[0,-46.91],[42.82,-12.49],[46.86,0],[12.5,42.8],[0,46.9],[-42.97,12.4]],"o":[[46.66,0],[42.9,12.44],[0,46.86],[-12.49,42.82],[-46.84,0],[-42.88,-12.45],[0,-46.96],[12.68,-42.52]],"v":[[0.053,-172.75],[98.793,-99.19],[173.053,-0.25],[98.953,98.64],[0.053,172.75],[-98.827,98.68],[-173.057,-0.25],[-98.667,-99.23]],"c":true},"ix":2},"nm":"路径 1","mn":"ADBE Vector Shape - Group","hd":false},{"ty":"st","c":{"a":0,"k":[1,1,1,1],"ix":3},"o":{"a":0,"k":100,"ix":4},"w":{"a":0,"k":16,"ix":5},"lc":2,"lj":1,"ml":4,"bm":0,"nm":"描边 1","mn":"ADBE Vector Graphic - Stroke","hd":false},{"ty":"tr","p":{"a":0,"k":[0,0],"ix":2},"a":{"a":0,"k":[0,0],"ix":1},"s":{"a":0,"k":[100,100],"ix":3},"r":{"a":0,"k":0,"ix":6},"o":{"a":0,"k":100,"ix":7},"sk":{"a":0,"k":0,"ix":4},"sa":{"a":0,"k":0,"ix":5},"nm":"变换"}],"nm":"路径","np":2,"cix":2,"bm":0,"ix":1,"mn":"ADBE Vector Group","hd":false},{"ty":"tm","s":{"a":1,"k":[{"i":{"x":[0.833],"y":[0.833]},"o":{"x":[0.167],"y":[0.167]},"t":10,"s":[50]},{"t":30,"s":[0]}],"ix":1},"e":{"a":1,"k":[{"i":{"x":[0.833],"y":[0.833]},"o":{"x":[0.167],"y":[0.167]},"t":10,"s":[50]},{"t":30,"s":[100]}],"ix":2},"o":{"a":0,"k":0,"ix":3},"m":1,"ix":2,"nm":"修剪路径 1","mn":"ADBE Vector Filter - Trim","hd":false}],"ip":30,"op":35,"st":0,"bm":0},{"ddd":0,"ind":3,"ty":4,"nm":"路径 4","sr":1,"ks":{"o":{"a":0,"k":100,"ix":11},"r":{"a":0,"k":0,"ix":10},"p":{"a":0,"k":[255.943,256.25,0],"ix":2},"a":{"a":0,"k":[0,0,0],"ix":1},"s":{"a":0,"k":[100,100,100],"ix":6}},"ao":0,"ef":[{"ty":5,"nm":"real glow","np":16,"mn":"ADBE Glo2","ix":1,"en":1,"ef":[{"ty":7,"nm":"发光基于","mn":"ADBE Glo2-0001","ix":1,"v":{"a":0,"k":2,"ix":1}},{"ty":0,"nm":"发光阈值","mn":"ADBE Glo2-0002","ix":2,"v":{"a":0,"k":153,"ix":2}},{"ty":0,"nm":"发光半径","mn":"ADBE Glo2-0003","ix":3,"v":{"a":0,"k":36,"ix":3}},{"ty":0,"nm":"发光强度","mn":"ADBE Glo2-0004","ix":4,"v":{"a":0,"k":2,"ix":4}},{"ty":7,"nm":"合成原始项目","mn":"ADBE Glo2-0005","ix":5,"v":{"a":0,"k":2,"ix":5}},{"ty":7,"nm":"发光操作","mn":"ADBE Glo2-0006","ix":6,"v":{"a":0,"k":3,"ix":6}},{"ty":7,"nm":"发光颜色","mn":"ADBE Glo2-0007","ix":7,"v":{"a":0,"k":2,"ix":7}},{"ty":7,"nm":"颜色循环","mn":"ADBE Glo2-0008","ix":8,"v":{"a":0,"k":3,"ix":8}},{"ty":0,"nm":"颜色循环","mn":"ADBE Glo2-0009","ix":9,"v":{"a":0,"k":1,"ix":9}},{"ty":0,"nm":"色彩相位","mn":"ADBE Glo2-0010","ix":10,"v":{"a":0,"k":0,"ix":10}},{"ty":0,"nm":"A 和 B 中点","mn":"ADBE Glo2-0011","ix":11,"v":{"a":0,"k":0.5,"ix":11}},{"ty":2,"nm":"颜色 A","mn":"ADBE Glo2-0012","ix":12,"v":{"a":0,"k":[0,0.173070013523,1,1],"ix":12}},{"ty":2,"nm":"颜色 B","mn":"ADBE Glo2-0013","ix":13,"v":{"a":0,"k":[0,0.172549024224,1,1],"ix":13}},{"ty":7,"nm":"发光维度","mn":"ADBE Glo2-0014","ix":14,"v":{"a":0,"k":1,"ix":14}}]}],"shapes":[{"ty":"gr","it":[{"ind":0,"ty":"sh","ix":1,"ks":{"a":0,"k":{"i":[[-46.64,0],[-12.67,-42.54],[0,-46.91],[42.82,-12.49],[46.86,0],[12.5,42.8],[0,46.9],[-42.97,12.4]],"o":[[46.66,0],[42.9,12.44],[0,46.86],[-12.49,42.82],[-46.84,0],[-42.88,-12.45],[0,-46.96],[12.68,-42.52]],"v":[[0.053,-172.75],[98.793,-99.19],[173.053,-0.25],[98.953,98.64],[0.053,172.75],[-98.827,98.68],[-173.057,-0.25],[-98.667,-99.23]],"c":true},"ix":2},"nm":"路径 1","mn":"ADBE Vector Shape - Group","hd":false},{"ty":"st","c":{"a":0,"k":[1,1,1,1],"ix":3},"o":{"a":0,"k":100,"ix":4},"w":{"a":0,"k":16,"ix":5},"lc":2,"lj":1,"ml":4,"bm":0,"nm":"描边 1","mn":"ADBE Vector Graphic - Stroke","hd":false},{"ty":"tr","p":{"a":0,"k":[0,0],"ix":2},"a":{"a":0,"k":[0,0],"ix":1},"s":{"a":0,"k":[100,100],"ix":3},"r":{"a":0,"k":0,"ix":6},"o":{"a":0,"k":100,"ix":7},"sk":{"a":0,"k":0,"ix":4},"sa":{"a":0,"k":0,"ix":5},"nm":"变换"}],"nm":"路径","np":2,"cix":2,"bm":0,"ix":1,"mn":"ADBE Vector Group","hd":false},{"ty":"tm","s":{"a":1,"k":[{"i":{"x":[0.833],"y":[0.833]},"o":{"x":[0.167],"y":[0.167]},"t":10,"s":[50]},{"t":30,"s":[0]}],"ix":1},"e":{"a":1,"k":[{"i":{"x":[0.833],"y":[0.833]},"o":{"x":[0.167],"y":[0.167]},"t":10,"s":[50]},{"t":30,"s":[100]}],"ix":2},"o":{"a":0,"k":0,"ix":3},"m":1,"ix":2,"nm":"修剪路径 1","mn":"ADBE Vector Filter - Trim","hd":false}],"ip":0,"op":13,"st":0,"bm":0},{"ddd":0,"ind":4,"ty":4,"nm":"路径 7","sr":1,"ks":{"o":{"a":0,"k":100,"ix":11},"r":{"a":0,"k":0,"ix":10},"p":{"a":0,"k":[255.943,256.25,0],"ix":2},"a":{"a":0,"k":[0,0,0],"ix":1},"s":{"a":0,"k":[100,100,100],"ix":6}},"ao":0,"ef":[{"ty":5,"nm":"real glow","np":16,"mn":"ADBE Glo2","ix":1,"en":1,"ef":[{"ty":7,"nm":"发光基于","mn":"ADBE Glo2-0001","ix":1,"v":{"a":0,"k":2,"ix":1}},{"ty":0,"nm":"发光阈值","mn":"ADBE Glo2-0002","ix":2,"v":{"a":0,"k":153,"ix":2}},{"ty":0,"nm":"发光半径","mn":"ADBE Glo2-0003","ix":3,"v":{"a":0,"k":36,"ix":3}},{"ty":0,"nm":"发光强度","mn":"ADBE Glo2-0004","ix":4,"v":{"a":0,"k":1,"ix":4}},{"ty":7,"nm":"合成原始项目","mn":"ADBE Glo2-0005","ix":5,"v":{"a":0,"k":2,"ix":5}},{"ty":7,"nm":"发光操作","mn":"ADBE Glo2-0006","ix":6,"v":{"a":0,"k":3,"ix":6}},{"ty":7,"nm":"发光颜色","mn":"ADBE Glo2-0007","ix":7,"v":{"a":0,"k":2,"ix":7}},{"ty":7,"nm":"颜色循环","mn":"ADBE Glo2-0008","ix":8,"v":{"a":0,"k":3,"ix":8}},{"ty":0,"nm":"颜色循环","mn":"ADBE Glo2-0009","ix":9,"v":{"a":0,"k":1,"ix":9}},{"ty":0,"nm":"色彩相位","mn":"ADBE Glo2-0010","ix":10,"v":{"a":0,"k":0,"ix":10}},{"ty":0,"nm":"A 和 B 中点","mn":"ADBE Glo2-0011","ix":11,"v":{"a":0,"k":0.5,"ix":11}},{"ty":2,"nm":"颜色 A","mn":"ADBE Glo2-0012","ix":12,"v":{"a":0,"k":[0,0.173070013523,1,1],"ix":12}},{"ty":2,"nm":"颜色 B","mn":"ADBE Glo2-0013","ix":13,"v":{"a":0,"k":[0,0.172549024224,1,1],"ix":13}},{"ty":7,"nm":"发光维度","mn":"ADBE Glo2-0014","ix":14,"v":{"a":0,"k":1,"ix":14}}]},{"ty":27,"nm":"置换图","np":10,"mn":"ADBE Displacement Map","ix":9,"en":1,"ef":[{"ty":10,"nm":"置换图层","mn":"ADBE Displacement Map-0001","ix":1,"v":{"a":0,"k":0,"ix":1}},{"ty":7,"nm":"用于水平置换","mn":"ADBE Displacement Map-0002","ix":2,"v":{"a":0,"k":1,"ix":2}},{"ty":0,"nm":"最大水平置换","mn":"ADBE Displacement Map-0003","ix":3,"v":{"a":0,"k":5,"ix":3}},{"ty":7,"nm":"用于垂直置换","mn":"ADBE Displacement Map-0004","ix":4,"v":{"a":0,"k":2,"ix":4}},{"ty":0,"nm":"最大垂直置换","mn":"ADBE Displacement Map-0005","ix":5,"v":{"a":0,"k":5,"ix":5}},{"ty":7,"nm":"置换图特性","mn":"ADBE Displacement Map-0006","ix":6,"v":{"a":0,"k":1,"ix":6}},{"ty":7,"nm":"边缘特性","mn":"ADBE Displacement Map-0007","ix":7,"v":{"a":0,"k":0,"ix":7}},{"ty":7,"nm":"扩展输出","mn":"ADBE Displacement Map-0008","ix":8,"v":{"a":0,"k":1,"ix":8}}]}],"shapes":[{"ty":"gr","it":[{"ind":0,"ty":"sh","ix":1,"ks":{"a":0,"k":{"i":[[-46.64,0],[-12.67,-42.54],[0,-46.91],[42.82,-12.49],[46.86,0],[12.5,42.8],[0,46.9],[-42.97,12.4]],"o":[[46.66,0],[42.9,12.44],[0,46.86],[-12.49,42.82],[-46.84,0],[-42.88,-12.45],[0,-46.96],[12.68,-42.52]],"v":[[0.053,-172.75],[98.793,-99.19],[173.053,-0.25],[98.953,98.64],[0.053,172.75],[-98.827,98.68],[-173.057,-0.25],[-98.667,-99.23]],"c":true},"ix":2},"nm":"路径 1","mn":"ADBE Vector Shape - Group","hd":false},{"ty":"st","c":{"a":0,"k":[1,1,1,1],"ix":3},"o":{"a":0,"k":100,"ix":4},"w":{"a":0,"k":16,"ix":5},"lc":2,"lj":1,"ml":4,"bm":0,"nm":"描边 1","mn":"ADBE Vector Graphic - Stroke","hd":false},{"ty":"tr","p":{"a":0,"k":[0,0],"ix":2},"a":{"a":0,"k":[0,0],"ix":1},"s":{"a":0,"k":[100,100],"ix":3},"r":{"a":0,"k":0,"ix":6},"o":{"a":0,"k":100,"ix":7},"sk":{"a":0,"k":0,"ix":4},"sa":{"a":0,"k":0,"ix":5},"nm":"变换"}],"nm":"路径","np":2,"cix":2,"bm":0,"ix":1,"mn":"ADBE Vector Group","hd":false},{"ty":"tm","s":{"a":1,"k":[{"i":{"x":[0.833],"y":[0.833]},"o":{"x":[0.167],"y":[0.167]},"t":10,"s":[50]},{"t":30,"s":[0]}],"ix":1},"e":{"a":1,"k":[{"i":{"x":[0.833],"y":[0.833]},"o":{"x":[0.167],"y":[0.167]},"t":10,"s":[50]},{"t":30,"s":[100]}],"ix":2},"o":{"a":0,"k":0,"ix":3},"m":1,"ix":2,"nm":"修剪路径 1","mn":"ADBE Vector Filter - Trim","hd":false}],"ip":13,"op":17,"st":0,"bm":0},{"ddd":0,"ind":5,"ty":4,"nm":"路径 5","sr":1,"ks":{"o":{"a":0,"k":100,"ix":11},"r":{"a":0,"k":0,"ix":10},"p":{"a":0,"k":[255.943,256.25,0],"ix":2},"a":{"a":0,"k":[0,0,0],"ix":1},"s":{"a":0,"k":[100,100,100],"ix":6}},"ao":0,"ef":[{"ty":5,"nm":"real glow","np":16,"mn":"ADBE Glo2","ix":1,"en":1,"ef":[{"ty":7,"nm":"发光基于","mn":"ADBE Glo2-0001","ix":1,"v":{"a":0,"k":2,"ix":1}},{"ty":0,"nm":"发光阈值","mn":"ADBE Glo2-0002","ix":2,"v":{"a":0,"k":153,"ix":2}},{"ty":0,"nm":"发光半径","mn":"ADBE Glo2-0003","ix":3,"v":{"a":0,"k":36,"ix":3}},{"ty":0,"nm":"发光强度","mn":"ADBE Glo2-0004","ix":4,"v":{"a":0,"k":1,"ix":4}},{"ty":7,"nm":"合成原始项目","mn":"ADBE Glo2-0005","ix":5,"v":{"a":0,"k":2,"ix":5}},{"ty":7,"nm":"发光操作","mn":"ADBE Glo2-0006","ix":6,"v":{"a":0,"k":3,"ix":6}},{"ty":7,"nm":"发光颜色","mn":"ADBE Glo2-0007","ix":7,"v":{"a":0,"k":2,"ix":7}},{"ty":7,"nm":"颜色循环","mn":"ADBE Glo2-0008","ix":8,"v":{"a":0,"k":3,"ix":8}},{"ty":0,"nm":"颜色循环","mn":"ADBE Glo2-0009","ix":9,"v":{"a":0,"k":1,"ix":9}},{"ty":0,"nm":"色彩相位","mn":"ADBE Glo2-0010","ix":10,"v":{"a":0,"k":0,"ix":10}},{"ty":0,"nm":"A 和 B 中点","mn":"ADBE Glo2-0011","ix":11,"v":{"a":0,"k":0.5,"ix":11}},{"ty":2,"nm":"颜色 A","mn":"ADBE Glo2-0012","ix":12,"v":{"a":0,"k":[0,0.173070013523,1,1],"ix":12}},{"ty":2,"nm":"颜色 B","mn":"ADBE Glo2-0013","ix":13,"v":{"a":0,"k":[0,0.172549024224,1,1],"ix":13}},{"ty":7,"nm":"发光维度","mn":"ADBE Glo2-0014","ix":14,"v":{"a":0,"k":1,"ix":14}}]}],"shapes":[{"ty":"gr","it":[{"ind":0,"ty":"sh","ix":1,"ks":{"a":0,"k":{"i":[[-46.64,0],[-12.67,-42.54],[0,-46.91],[42.82,-12.49],[46.86,0],[12.5,42.8],[0,46.9],[-42.97,12.4]],"o":[[46.66,0],[42.9,12.44],[0,46.86],[-12.49,42.82],[-46.84,0],[-42.88,-12.45],[0,-46.96],[12.68,-42.52]],"v":[[0.053,-172.75],[98.793,-99.19],[173.053,-0.25],[98.953,98.64],[0.053,172.75],[-98.827,98.68],[-173.057,-0.25],[-98.667,-99.23]],"c":true},"ix":2},"nm":"路径 1","mn":"ADBE Vector Shape - Group","hd":false},{"ty":"st","c":{"a":0,"k":[1,1,1,1],"ix":3},"o":{"a":0,"k":100,"ix":4},"w":{"a":0,"k":16,"ix":5},"lc":2,"lj":1,"ml":4,"bm":0,"nm":"描边 1","mn":"ADBE Vector Graphic - Stroke","hd":false},{"ty":"tr","p":{"a":0,"k":[0,0],"ix":2},"a":{"a":0,"k":[0,0],"ix":1},"s":{"a":0,"k":[100,100],"ix":3},"r":{"a":0,"k":0,"ix":6},"o":{"a":0,"k":100,"ix":7},"sk":{"a":0,"k":0,"ix":4},"sa":{"a":0,"k":0,"ix":5},"nm":"变换"}],"nm":"路径","np":2,"cix":2,"bm":0,"ix":1,"mn":"ADBE Vector Group","hd":false},{"ty":"tm","s":{"a":1,"k":[{"i":{"x":[0.833],"y":[0.833]},"o":{"x":[0.167],"y":[0.167]},"t":10,"s":[50]},{"t":30,"s":[0]}],"ix":1},"e":{"a":1,"k":[{"i":{"x":[0.833],"y":[0.833]},"o":{"x":[0.167],"y":[0.167]},"t":10,"s":[50]},{"t":30,"s":[100]}],"ix":2},"o":{"a":0,"k":0,"ix":3},"m":1,"ix":2,"nm":"修剪路径 1","mn":"ADBE Vector Filter - Trim","hd":false}],"ip":17,"op":20,"st":0,"bm":0},{"ddd":0,"ind":6,"ty":4,"nm":"路径 2","sr":1,"ks":{"o":{"a":0,"k":100,"ix":11},"r":{"a":0,"k":0,"ix":10},"p":{"a":0,"k":[255.943,256.25,0],"ix":2},"a":{"a":0,"k":[0,0,0],"ix":1},"s":{"a":0,"k":[100,100,100],"ix":6}},"ao":0,"ef":[{"ty":5,"nm":"real glow","np":16,"mn":"ADBE Glo2","ix":1,"en":1,"ef":[{"ty":7,"nm":"发光基于","mn":"ADBE Glo2-0001","ix":1,"v":{"a":0,"k":2,"ix":1}},{"ty":0,"nm":"发光阈值","mn":"ADBE Glo2-0002","ix":2,"v":{"a":0,"k":153,"ix":2}},{"ty":0,"nm":"发光半径","mn":"ADBE Glo2-0003","ix":3,"v":{"a":0,"k":36,"ix":3}},{"ty":0,"nm":"发光强度","mn":"ADBE Glo2-0004","ix":4,"v":{"a":0,"k":1,"ix":4}},{"ty":7,"nm":"合成原始项目","mn":"ADBE Glo2-0005","ix":5,"v":{"a":0,"k":2,"ix":5}},{"ty":7,"nm":"发光操作","mn":"ADBE Glo2-0006","ix":6,"v":{"a":0,"k":3,"ix":6}},{"ty":7,"nm":"发光颜色","mn":"ADBE Glo2-0007","ix":7,"v":{"a":0,"k":2,"ix":7}},{"ty":7,"nm":"颜色循环","mn":"ADBE Glo2-0008","ix":8,"v":{"a":0,"k":3,"ix":8}},{"ty":0,"nm":"颜色循环","mn":"ADBE Glo2-0009","ix":9,"v":{"a":0,"k":1,"ix":9}},{"ty":0,"nm":"色彩相位","mn":"ADBE Glo2-0010","ix":10,"v":{"a":0,"k":0,"ix":10}},{"ty":0,"nm":"A 和 B 中点","mn":"ADBE Glo2-0011","ix":11,"v":{"a":0,"k":0.5,"ix":11}},{"ty":2,"nm":"颜色 A","mn":"ADBE Glo2-0012","ix":12,"v":{"a":0,"k":[0,0.173070013523,1,1],"ix":12}},{"ty":2,"nm":"颜色 B","mn":"ADBE Glo2-0013","ix":13,"v":{"a":0,"k":[0,0.172549024224,1,1],"ix":13}},{"ty":7,"nm":"发光维度","mn":"ADBE Glo2-0014","ix":14,"v":{"a":0,"k":1,"ix":14}}]}],"shapes":[{"ty":"gr","it":[{"ind":0,"ty":"sh","ix":1,"ks":{"a":0,"k":{"i":[[-46.64,0],[-12.67,-42.54],[0,-46.91],[42.82,-12.49],[46.86,0],[12.5,42.8],[0,46.9],[-42.97,12.4]],"o":[[46.66,0],[42.9,12.44],[0,46.86],[-12.49,42.82],[-46.84,0],[-42.88,-12.45],[0,-46.96],[12.68,-42.52]],"v":[[0.053,-172.75],[98.793,-99.19],[173.053,-0.25],[98.953,98.64],[0.053,172.75],[-98.827,98.68],[-173.057,-0.25],[-98.667,-99.23]],"c":true},"ix":2},"nm":"路径 1","mn":"ADBE Vector Shape - Group","hd":false},{"ty":"st","c":{"a":0,"k":[1,1,1,1],"ix":3},"o":{"a":0,"k":100,"ix":4},"w":{"a":0,"k":16,"ix":5},"lc":2,"lj":1,"ml":4,"bm":0,"nm":"描边 1","mn":"ADBE Vector Graphic - Stroke","hd":false},{"ty":"tr","p":{"a":0,"k":[0,0],"ix":2},"a":{"a":0,"k":[0,0],"ix":1},"s":{"a":0,"k":[100,100],"ix":3},"r":{"a":0,"k":0,"ix":6},"o":{"a":0,"k":100,"ix":7},"sk":{"a":0,"k":0,"ix":4},"sa":{"a":0,"k":0,"ix":5},"nm":"变换"}],"nm":"路径","np":2,"cix":2,"bm":0,"ix":1,"mn":"ADBE Vector Group","hd":false},{"ty":"tm","s":{"a":1,"k":[{"i":{"x":[0.833],"y":[0.833]},"o":{"x":[0.167],"y":[0.167]},"t":10,"s":[50]},{"t":30,"s":[0]}],"ix":1},"e":{"a":1,"k":[{"i":{"x":[0.833],"y":[0.833]},"o":{"x":[0.167],"y":[0.167]},"t":10,"s":[50]},{"t":30,"s":[100]}],"ix":2},"o":{"a":0,"k":0,"ix":3},"m":1,"ix":2,"nm":"修剪路径 1","mn":"ADBE Vector Filter - Trim","hd":false}],"ip":20,"op":30,"st":0,"bm":0},{"ddd":0,"ind":7,"ty":4,"nm":"路径 6","sr":1,"ks":{"o":{"a":0,"k":100,"ix":11},"r":{"a":0,"k":0,"ix":10},"p":{"a":0,"k":[255.943,256.25,0],"ix":2},"a":{"a":0,"k":[0,0,0],"ix":1},"s":{"a":0,"k":[100,100,100],"ix":6}},"ao":0,"ef":[{"ty":5,"nm":"real glow","np":16,"mn":"ADBE Glo2","ix":1,"en":1,"ef":[{"ty":7,"nm":"发光基于","mn":"ADBE Glo2-0001","ix":1,"v":{"a":0,"k":2,"ix":1}},{"ty":0,"nm":"发光阈值","mn":"ADBE Glo2-0002","ix":2,"v":{"a":0,"k":153,"ix":2}},{"ty":0,"nm":"发光半径","mn":"ADBE Glo2-0003","ix":3,"v":{"a":0,"k":36,"ix":3}},{"ty":0,"nm":"发光强度","mn":"ADBE Glo2-0004","ix":4,"v":{"a":0,"k":1,"ix":4}},{"ty":7,"nm":"合成原始项目","mn":"ADBE Glo2-0005","ix":5,"v":{"a":0,"k":2,"ix":5}},{"ty":7,"nm":"发光操作","mn":"ADBE Glo2-0006","ix":6,"v":{"a":0,"k":3,"ix":6}},{"ty":7,"nm":"发光颜色","mn":"ADBE Glo2-0007","ix":7,"v":{"a":0,"k":2,"ix":7}},{"ty":7,"nm":"颜色循环","mn":"ADBE Glo2-0008","ix":8,"v":{"a":0,"k":3,"ix":8}},{"ty":0,"nm":"颜色循环","mn":"ADBE Glo2-0009","ix":9,"v":{"a":0,"k":1,"ix":9}},{"ty":0,"nm":"色彩相位","mn":"ADBE Glo2-0010","ix":10,"v":{"a":0,"k":0,"ix":10}},{"ty":0,"nm":"A 和 B 中点","mn":"ADBE Glo2-0011","ix":11,"v":{"a":0,"k":0.5,"ix":11}},{"ty":2,"nm":"颜色 A","mn":"ADBE Glo2-0012","ix":12,"v":{"a":0,"k":[0,0.173070013523,1,1],"ix":12}},{"ty":2,"nm":"颜色 B","mn":"ADBE Glo2-0013","ix":13,"v":{"a":0,"k":[0,0.172549024224,1,1],"ix":13}},{"ty":7,"nm":"发光维度","mn":"ADBE Glo2-0014","ix":14,"v":{"a":0,"k":1,"ix":14}}]},{"ty":27,"nm":"置换图","np":10,"mn":"ADBE Displacement Map","ix":2,"en":1,"ef":[{"ty":10,"nm":"置换图层","mn":"ADBE Displacement Map-0001","ix":1,"v":{"a":0,"k":0,"ix":1}},{"ty":7,"nm":"用于水平置换","mn":"ADBE Displacement Map-0002","ix":2,"v":{"a":0,"k":1,"ix":2}},{"ty":0,"nm":"最大水平置换","mn":"ADBE Displacement Map-0003","ix":3,"v":{"a":0,"k":5,"ix":3}},{"ty":7,"nm":"用于垂直置换","mn":"ADBE Displacement Map-0004","ix":4,"v":{"a":0,"k":2,"ix":4}},{"ty":0,"nm":"最大垂直置换","mn":"ADBE Displacement Map-0005","ix":5,"v":{"a":0,"k":5,"ix":5}},{"ty":7,"nm":"置换图特性","mn":"ADBE Displacement Map-0006","ix":6,"v":{"a":0,"k":1,"ix":6}},{"ty":7,"nm":"边缘特性","mn":"ADBE Displacement Map-0007","ix":7,"v":{"a":0,"k":0,"ix":7}},{"ty":7,"nm":"扩展输出","mn":"ADBE Displacement Map-0008","ix":8,"v":{"a":0,"k":1,"ix":8}}]}],"shapes":[{"ty":"gr","it":[{"ind":0,"ty":"sh","ix":1,"ks":{"a":0,"k":{"i":[[46.66,0],[12.68,-42.52],[0,-46.96],[-42.88,-12.45],[-46.84,0],[-12.49,42.82],[0,46.86],[42.9,12.44]],"o":[[-46.64,0],[-42.97,12.4],[0,46.9],[12.5,42.8],[46.86,0],[42.82,-12.49],[0,-46.91],[-12.67,-42.54]],"v":[[0.053,-172.75],[-98.667,-99.23],[-173.057,-0.25],[-98.827,98.68],[0.053,172.75],[98.953,98.64],[173.053,-0.25],[98.793,-99.19]],"c":true},"ix":2},"nm":"路径 1","mn":"ADBE Vector Shape - Group","hd":false},{"ty":"st","c":{"a":0,"k":[1,1,1,1],"ix":3},"o":{"a":0,"k":100,"ix":4},"w":{"a":0,"k":16,"ix":5},"lc":2,"lj":1,"ml":4,"bm":0,"nm":"描边 1","mn":"ADBE Vector Graphic - Stroke","hd":false},{"ty":"tr","p":{"a":0,"k":[0,0],"ix":2},"a":{"a":0,"k":[0,0],"ix":1},"s":{"a":0,"k":[100,100],"ix":3},"r":{"a":0,"k":0,"ix":6},"o":{"a":0,"k":100,"ix":7},"sk":{"a":0,"k":0,"ix":4},"sa":{"a":0,"k":0,"ix":5},"nm":"变换"}],"nm":"路径","np":2,"cix":2,"bm":0,"ix":1,"mn":"ADBE Vector Group","hd":false},{"ty":"tm","s":{"a":1,"k":[{"i":{"x":[0.667],"y":[1]},"o":{"x":[0.333],"y":[0]},"t":35,"s":[0]},{"i":{"x":[0.833],"y":[0.833]},"o":{"x":[0.333],"y":[0]},"t":50,"s":[50]},{"t":65,"s":[0]}],"ix":1},"e":{"a":1,"k":[{"i":{"x":[0.667],"y":[1]},"o":{"x":[0.333],"y":[0]},"t":35,"s":[100]},{"i":{"x":[0.833],"y":[0.833]},"o":{"x":[0.333],"y":[0]},"t":50,"s":[50]},{"t":65,"s":[100]}],"ix":2},"o":{"a":0,"k":180,"ix":3},"m":1,"ix":2,"nm":"修剪路径 1","mn":"ADBE Vector Filter - Trim","hd":false}],"ip":35,"op":40,"st":66,"bm":0},{"ddd":0,"ind":8,"ty":4,"nm":"路径","sr":1,"ks":{"o":{"a":0,"k":100,"ix":11},"r":{"a":0,"k":0,"ix":10},"p":{"a":0,"k":[255.943,256.25,0],"ix":2},"a":{"a":0,"k":[0,0,0],"ix":1},"s":{"a":0,"k":[100,100,100],"ix":6}},"ao":0,"ef":[{"ty":5,"nm":"real glow","np":16,"mn":"ADBE Glo2","ix":1,"en":1,"ef":[{"ty":7,"nm":"发光基于","mn":"ADBE Glo2-0001","ix":1,"v":{"a":0,"k":2,"ix":1}},{"ty":0,"nm":"发光阈值","mn":"ADBE Glo2-0002","ix":2,"v":{"a":0,"k":153,"ix":2}},{"ty":0,"nm":"发光半径","mn":"ADBE Glo2-0003","ix":3,"v":{"a":0,"k":36,"ix":3}},{"ty":0,"nm":"发光强度","mn":"ADBE Glo2-0004","ix":4,"v":{"a":0,"k":1,"ix":4}},{"ty":7,"nm":"合成原始项目","mn":"ADBE Glo2-0005","ix":5,"v":{"a":0,"k":2,"ix":5}},{"ty":7,"nm":"发光操作","mn":"ADBE Glo2-0006","ix":6,"v":{"a":0,"k":3,"ix":6}},{"ty":7,"nm":"发光颜色","mn":"ADBE Glo2-0007","ix":7,"v":{"a":0,"k":2,"ix":7}},{"ty":7,"nm":"颜色循环","mn":"ADBE Glo2-0008","ix":8,"v":{"a":0,"k":3,"ix":8}},{"ty":0,"nm":"颜色循环","mn":"ADBE Glo2-0009","ix":9,"v":{"a":0,"k":1,"ix":9}},{"ty":0,"nm":"色彩相位","mn":"ADBE Glo2-0010","ix":10,"v":{"a":0,"k":0,"ix":10}},{"ty":0,"nm":"A 和 B 中点","mn":"ADBE Glo2-0011","ix":11,"v":{"a":0,"k":0.5,"ix":11}},{"ty":2,"nm":"颜色 A","mn":"ADBE Glo2-0012","ix":12,"v":{"a":0,"k":[0,0.173070013523,1,1],"ix":12}},{"ty":2,"nm":"颜色 B","mn":"ADBE Glo2-0013","ix":13,"v":{"a":0,"k":[0,0.172549024224,1,1],"ix":13}},{"ty":7,"nm":"发光维度","mn":"ADBE Glo2-0014","ix":14,"v":{"a":0,"k":1,"ix":14}}]}],"shapes":[{"ty":"gr","it":[{"ind":0,"ty":"sh","ix":1,"ks":{"a":0,"k":{"i":[[46.66,0],[12.68,-42.52],[0,-46.96],[-42.88,-12.45],[-46.84,0],[-12.49,42.82],[0,46.86],[42.9,12.44]],"o":[[-46.64,0],[-42.97,12.4],[0,46.9],[12.5,42.8],[46.86,0],[42.82,-12.49],[0,-46.91],[-12.67,-42.54]],"v":[[0.053,-172.75],[-98.667,-99.23],[-173.057,-0.25],[-98.827,98.68],[0.053,172.75],[98.953,98.64],[173.053,-0.25],[98.793,-99.19]],"c":true},"ix":2},"nm":"路径 1","mn":"ADBE Vector Shape - Group","hd":false},{"ty":"st","c":{"a":0,"k":[1,1,1,1],"ix":3},"o":{"a":0,"k":100,"ix":4},"w":{"a":0,"k":16,"ix":5},"lc":2,"lj":1,"ml":4,"bm":0,"nm":"描边 1","mn":"ADBE Vector Graphic - Stroke","hd":false},{"ty":"tr","p":{"a":0,"k":[0,0],"ix":2},"a":{"a":0,"k":[0,0],"ix":1},"s":{"a":0,"k":[100,100],"ix":3},"r":{"a":0,"k":0,"ix":6},"o":{"a":0,"k":100,"ix":7},"sk":{"a":0,"k":0,"ix":4},"sa":{"a":0,"k":0,"ix":5},"nm":"变换"}],"nm":"路径","np":2,"cix":2,"bm":0,"ix":1,"mn":"ADBE Vector Group","hd":false},{"ty":"tm","s":{"a":1,"k":[{"i":{"x":[0.667],"y":[1]},"o":{"x":[0.333],"y":[0]},"t":35,"s":[0]},{"i":{"x":[0.833],"y":[0.833]},"o":{"x":[0.333],"y":[0]},"t":50,"s":[50]},{"t":65,"s":[0]}],"ix":1},"e":{"a":1,"k":[{"i":{"x":[0.667],"y":[1]},"o":{"x":[0.333],"y":[0]},"t":35,"s":[100]},{"i":{"x":[0.833],"y":[0.833]},"o":{"x":[0.333],"y":[0]},"t":50,"s":[50]},{"t":65,"s":[100]}],"ix":2},"o":{"a":0,"k":180,"ix":3},"m":1,"ix":2,"nm":"修剪路径 1","mn":"ADBE Vector Filter - Trim","hd":false}],"ip":40,"op":70,"st":66,"bm":0}],"markers":[{"tm":0.001953125,"cm":"1","dr":0}]} \ No newline at end of file diff --git a/android/app/src/main/java/co/steamcloud/cargame/ActivityCollector.java b/android/app/src/main/java/co/steamcloud/cargame/ActivityCollector.java new file mode 100644 index 0000000..eff63e6 --- /dev/null +++ b/android/app/src/main/java/co/steamcloud/cargame/ActivityCollector.java @@ -0,0 +1,32 @@ +package co.steamcloud.cargame; + +import android.app.Activity; + +import java.util.ArrayList; +import java.util.List; + +/** + *一个专门的集合类对所有的活动( Activity)进行管理 + * + * */ +public class ActivityCollector { + + public static List activities = new ArrayList(); + + /** + * 添加Activity + * @param activity 添加的Activity对象 + * */ + public static void addActivity(Activity activity) { + activities.add(activity); + } + + /** + * 删除Activity + * @param activity 删除的Activity对象 + * */ + public static void removeActivity(Activity activity) { + activities.remove(activity); + } + +} diff --git a/android/app/src/main/java/co/steamcloud/cargame/App.java b/android/app/src/main/java/co/steamcloud/cargame/App.java new file mode 100644 index 0000000..a322139 --- /dev/null +++ b/android/app/src/main/java/co/steamcloud/cargame/App.java @@ -0,0 +1,33 @@ +package co.steamcloud.cargame; + +import android.content.Context; + + +import io.flutter.app.FlutterApplication; + +public class App extends FlutterApplication { + + + private final static String SA_SERVER_URL = "https://sj.datasink.sensorsdata.cn/sa?project=production&token=8749cbadc8e370e7"; + + private static App instance; + + @Override + protected void attachBaseContext(Context base) { + super.attachBaseContext(base); +// MultiDex.install(this); + } + + @Override + public void onCreate() { + super.onCreate(); + //initSensorsDataAPI(); + instance = this; + } + + + public static App getInstance() { + return instance; + } + +} diff --git a/android/app/src/main/java/co/steamcloud/cargame/BaseAlertDialog.java b/android/app/src/main/java/co/steamcloud/cargame/BaseAlertDialog.java new file mode 100644 index 0000000..d8c0cea --- /dev/null +++ b/android/app/src/main/java/co/steamcloud/cargame/BaseAlertDialog.java @@ -0,0 +1,160 @@ +package co.steamcloud.cargame; + +import android.app.Dialog; +import android.content.Context; +import android.view.Gravity; +import android.view.View; +import android.widget.Button; +import android.widget.ImageView; +import android.widget.TextView; + + +public class BaseAlertDialog extends Dialog { + + private Button cancelCallBtn, sureBtn; + private TextView msgTv, tvTitle; + private String msg, cancelStr, sureStr = "", titleStr; + private boolean siCancelBold = false; + private IDialogTwoView iDialogView; + private boolean isLeft = false; + + + private boolean isHandleDismiss = true; + private final ImageView imgClose; + + + public void setHandleDismiss(boolean handleDismiss) { + isHandleDismiss = handleDismiss; + } + + + public void disMissDialog() { + if (null != BaseAlertDialog.this && BaseAlertDialog.this.isShowing()) + BaseAlertDialog.this.dismiss(); + } + + + public BaseAlertDialog(Context context/*, int mDialogStyle, int mDialogCancel*/) { + super(context, R.style.MyDialog); + + setContentView(R.layout.dialog_with_title); + tvTitle = findViewById(R.id.tvTitle); + + //点击外部不消失 + setCanceledOnTouchOutside(false); + + cancelCallBtn = findViewById(R.id.cancelCallBtn); + sureBtn = findViewById(R.id.sureBtn); + msgTv = findViewById(R.id.msgTv); + tvTitle = findViewById(R.id.tvTitle); + imgClose = findViewById(R.id.img_close); + + } + + public void show(BaseAlertDialog baseAlertDialog) { + if (null != baseAlertDialog.tvTitle && null != baseAlertDialog.titleStr) { + baseAlertDialog.tvTitle.setText(baseAlertDialog.titleStr); + + } + + baseAlertDialog.msgTv.setText(baseAlertDialog.msg); + msgTv.setGravity(isLeft ? Gravity.LEFT : Gravity.CENTER); + baseAlertDialog.sureBtn.setText(baseAlertDialog.sureStr); + baseAlertDialog.cancelCallBtn.setText(baseAlertDialog.cancelStr); + + baseAlertDialog.msgTv.setVisibility(baseAlertDialog.msg.equals("") ? View.GONE : View.VISIBLE); + baseAlertDialog.cancelCallBtn.setVisibility(baseAlertDialog.cancelStr.equals("") ? View.GONE : View.VISIBLE); + + + baseAlertDialog.cancelCallBtn.getPaint().setFakeBoldText(siCancelBold); + //取消 + baseAlertDialog.imgClose.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View v) { + if (isHandleDismiss) { + if (null != BaseAlertDialog.this && BaseAlertDialog.this.isShowing()) + BaseAlertDialog.this.dismiss(); + } + iDialogView.cancel(); + } + }); + //确认退出游戏 + baseAlertDialog.cancelCallBtn.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View v) { + if (isHandleDismiss) { + if (null != BaseAlertDialog.this && BaseAlertDialog.this.isShowing()) + BaseAlertDialog.this.dismiss(); + } + iDialogView.onSure(); + } + }); + + //返回App + baseAlertDialog.sureBtn.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View v) { + if (isHandleDismiss) { + if (null != BaseAlertDialog.this && BaseAlertDialog.this.isShowing()) + BaseAlertDialog.this.dismiss(); + } +// iDialogView.returnApp(); + iDialogView.cancel(); + } + }); + + } + + + /** + * 调用完Builder类的create()方法后显示该对话框的方法 + */ + @Override + public void show() { + super.show(); + show(this); + } + + + public static class Builder { + + private BaseAlertDialog baseAlertDialog; + + public Builder(Context context) { + baseAlertDialog = new BaseAlertDialog(context); + + } + + /** + * 通过Builder类设置完属性后构造对话框的方法 + */ + public BaseAlertDialog create() { + return baseAlertDialog; + } + + public Builder isCancelbold(boolean isBold) { + baseAlertDialog.siCancelBold = isBold; + return this; + } + + + public Builder isLeft(boolean isLeft) { + baseAlertDialog.isLeft = isLeft; + return this; + } + + public Builder show(String titleStr, String msg, String cancelStr, String sureStr, IDialogTwoView iDialogView) { + baseAlertDialog.msg = msg; + baseAlertDialog.titleStr = titleStr; + baseAlertDialog.cancelStr = cancelStr; + baseAlertDialog.sureStr = sureStr; + baseAlertDialog.iDialogView = iDialogView; + return this; + + } + + + } + + +} diff --git a/android/app/src/main/java/co/steamcloud/cargame/Config.java b/android/app/src/main/java/co/steamcloud/cargame/Config.java new file mode 100644 index 0000000..b30125d --- /dev/null +++ b/android/app/src/main/java/co/steamcloud/cargame/Config.java @@ -0,0 +1,55 @@ +package co.steamcloud.cargame; + +public class Config { + public static String url = "https://api.onelight.vip/";//接口域名 + public static String BsUrl = "https://os.zhijierongxing.com/";//游戏域名 + + public static String channel_id = "d612a79436ef9ceeee4d6847d854b2e1"; + public static String sign_key = "";//加密key + public static String userToken = "";//用户token + public static String gameId = "";//游戏id + + public static String sn = "";//设备号 + public static String Language = "";//系统语言 + public static String Channel = "";//渠道号 + public static String Platform = "android";//平台类型 + public static String Version = "";//版本号 + + public static String client_sid = ""; + + public static String ip = "127.0.0.1"; + + public static GamePara gamePara = new GamePara(); + + public static int keyEvent_time = 0;//按键监听计时器 + + public static boolean is_Playing = false;//是否在游戏中 + + public static int time_out_prealarm = 540;//长时间未操作警告 + + public static int time_out_max_second = 600;//长时间未操作踢出 + + public static boolean s_keyboard = false;//是否是键盘编辑模式 + + + public static boolean is_immersion = false;//是否是沉浸式 + + public static String controllMode = "0"; //0 手柄 ,1 鼠标模式 + + public static int gamePing = 0;//游戏中ping值 提供给游戏画面显示 + + public static float NetworkDelay_Average = 0;//网络延迟平均值 + + public static float NetworkLoss_Rate = 0; //网络丢包率 + public static float AverageDecodSpeed = 0; //平均解码耗时 + public static float FPS_Average = 0;//fps平均值 + + public static int sc_id = 0;//会话id + + public static int play_queue_id = 0; //队列id + + public static int queue_grade = 11; //排队等级 + + public static int queue_pos = 0; //排队等级 + +} diff --git a/android/app/src/main/java/co/steamcloud/cargame/CountDownTimerUtil.java b/android/app/src/main/java/co/steamcloud/cargame/CountDownTimerUtil.java new file mode 100644 index 0000000..441418e --- /dev/null +++ b/android/app/src/main/java/co/steamcloud/cargame/CountDownTimerUtil.java @@ -0,0 +1,83 @@ +package co.steamcloud.cargame; + +import android.os.CountDownTimer; +import android.view.View; + +public class CountDownTimerUtil { + + + private boolean isHandleEvent = true; + private TimerCount timerCount; + + public boolean isHandleEvent() { + return isHandleEvent; + } + + public void setHandleEvent(boolean handleEvent) { + isHandleEvent = handleEvent; + } + + private OnCountDownFinish onCountDownFinish; + private View view; + private OnCountDownTick onCountDownTick; + + public CountDownTimerUtil(View view, int secondCount) { + this.view = view; + timerCount = new TimerCount(secondCount * 1000, 1000); + + } + + + public void startCountDown() { + if (timerCount != null) { + timerCount.start(); + } + if (isHandleEvent == true) + view.setClickable(false); + } + + public void cancelCountDown() { + if (timerCount != null) + timerCount.cancel(); + if (isHandleEvent == true) + view.setClickable(true); + } + + public void setOnCountDownFinish(OnCountDownFinish onCountDownFinish) { + this.onCountDownFinish = onCountDownFinish; + } + + public interface OnCountDownFinish { + void finish();//倒计时完成 + } + + public void setOnCountDownTick(OnCountDownTick onCountDownTick) { + this.onCountDownTick = onCountDownTick; + } + + public interface OnCountDownTick { + void tick(int second); + } + + private class TimerCount extends CountDownTimer { + + + public TimerCount(long millisInFuture, long countDownInterval) { + super(millisInFuture, countDownInterval); + } + + @Override + public void onFinish() { + if (isHandleEvent == true) + view.setClickable(true); + if (onCountDownFinish != null) + onCountDownFinish.finish(); + } + + @Override + public void onTick(long millisUntilFinished) { + if (onCountDownTick != null) + onCountDownTick.tick((int) (millisUntilFinished / 1000)); + } + } +} diff --git a/android/app/src/main/java/co/steamcloud/cargame/EventBusParams.java b/android/app/src/main/java/co/steamcloud/cargame/EventBusParams.java new file mode 100644 index 0000000..b6be937 --- /dev/null +++ b/android/app/src/main/java/co/steamcloud/cargame/EventBusParams.java @@ -0,0 +1,20 @@ +package co.steamcloud.cargame; + +/** + * + * eventBus变量 + */ + +public class EventBusParams { + + + /** + * + */ + public static final String GAME = "game"; + + + public static final String MAIN = "main"; + + public static final String PUSH = "push"; +} diff --git a/android/app/src/main/java/co/steamcloud/cargame/GameFrameLayOut.java b/android/app/src/main/java/co/steamcloud/cargame/GameFrameLayOut.java new file mode 100644 index 0000000..5663e32 --- /dev/null +++ b/android/app/src/main/java/co/steamcloud/cargame/GameFrameLayOut.java @@ -0,0 +1,44 @@ +package co.steamcloud.cargame; + +import android.content.Context; +import android.util.AttributeSet; +import android.widget.FrameLayout; + + +public class GameFrameLayOut extends FrameLayout { + private String TAG = "GameFrameLayOut"; + int MAX_WIDTH = 1; + int MAX_HEIGHT = 1; + int SCREEN_WIDTH = 1920; + int SCREEN_HEIGHT = 1080; + + public void setScreenSize(int width,int height){ + SCREEN_WIDTH = width; + SCREEN_HEIGHT = height; + } + public GameFrameLayOut(Context context) { + super((Context)context); + + } + + public GameFrameLayOut(Context context, AttributeSet attrs) { + super((Context)context, attrs); + + } + + public GameFrameLayOut(Context context, AttributeSet attrs, int defStyleAttr) { + super((Context)context, attrs, defStyleAttr); + + } + + + @Override + protected void onLayout(boolean changed, int left, int top, int right, int bottom) { + super.onLayout(changed, left, top, right, bottom); + + } + @Override + protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) { + super.onMeasure(widthMeasureSpec, heightMeasureSpec); + } +} diff --git a/android/app/src/main/java/co/steamcloud/cargame/GamePara.java b/android/app/src/main/java/co/steamcloud/cargame/GamePara.java new file mode 100644 index 0000000..381392f --- /dev/null +++ b/android/app/src/main/java/co/steamcloud/cargame/GamePara.java @@ -0,0 +1,46 @@ +package co.steamcloud.cargame; + +import android.os.Build; + +public class GamePara { + String game_key; + int display_grade; + int queue_grade; + int able_queue; + String gs_name; + String save_time; + String room_name; + String start_resolution; + int record_game_time; + String model_name; + String sc_id; + String hangup_time; + String handle_sc_id; + + //http://192.168.11.202//web/#/8?page_id=150 + String handle_device;//json string 设置归属玩家的控制设备,该字段优先级高于handle_pos。包含gp和kb两个属性,其中kb代表手柄的位置,手柄1-4分别用1248表示,比如3代表拥有1号和2号手柄,0代表没有手柄,kb代表键盘位,1是有,0是没有。 + int input_mode;//输入模式,可选默认为3,1-手柄,2-键鼠,3-手柄键盘 + int enable_restart;//是否支持重新启动游戏,可选, 1为支持,0为不支持,默认为0 + String room_key; //设置字符串房间随机密码,只有使用相同密码的操控设备权限变更才能判定有效 + + public GamePara(){ + game_key = ""; + display_grade = 1; + queue_grade = 1; + able_queue = 0; + gs_name = ""; + save_time = ""; + room_name = ""; + start_resolution = ""; + record_game_time = 0; + model_name = Build.MODEL; + sc_id = ""; + hangup_time = "0"; + handle_sc_id = ""; + //@20200709 + room_key = ""; + enable_restart = 0; + + } + +} diff --git a/android/app/src/main/java/co/steamcloud/cargame/Globe.java b/android/app/src/main/java/co/steamcloud/cargame/Globe.java new file mode 100644 index 0000000..0965768 --- /dev/null +++ b/android/app/src/main/java/co/steamcloud/cargame/Globe.java @@ -0,0 +1,100 @@ +package co.steamcloud.cargame; + + + +public class Globe { + + + public static String version = ""; + + + public static float scaleWidht = 0; + public static float scaleHeight = 0; + + public static float landscapeScaleWidht=0; + public static float landscapeScaleHeight=0; + + public final static int KEY_UP = 19; + public final static int KEY_DOWN = 20; + public final static int KEY_LEFT = 21; + public final static int KEY_RIGHT = 22; + public final static int KEY_OK = 66; + public final static int KEY_OK1 = 23; + public final static int KEY_OK2 = 188; + + + public static final int HCENTER = 1; + public static final int VCENTER = 2; + public static final int LEFT = 4; + public static final int RIGHT = 8; + public static final int TOP = 16; + public static final int BOTTOM = 32; + public static final int BASELINE = 64; + public static final int SOLID = 0; + public static final int DOTTED = 1; + + public final static int KEY_CAIDAN = 82; + public final static int KEY_CAIDAN1 = 189; + public final static int KEY_SOFT_R = 4;// right soft key + public final static int KEY_SOFT_R1 = 199;// right soft key + + public static final int ANCHOR_T_L = TOP | LEFT; + public static final int ANCHOR_T_R = TOP |RIGHT; + public static final int ANCHOR_B_L = BOTTOM |LEFT; + public static final int ANCHOR_B_R = BOTTOM | RIGHT; + public static final int ANCHOR_H_V = HCENTER |VCENTER; + public static final int ANCHOR_L_V = LEFT | VCENTER; + public static final int ANCHOR_R_V = RIGHT | VCENTER; + public static final int ANCHOR_T_H = TOP | HCENTER; + public static final int ANCHOR_B_H = BOTTOM | HCENTER; + + + public final static int KEY_0 = 7; + public final static int KEY_1 = 8; + public final static int KEY_2 = 9; + public final static int KEY_3 = 10; + public final static int KEY_4 = 11; + public final static int KEY_5 = 12; + public final static int KEY_6 = 13; + public final static int KEY_7 = 14; + public final static int KEY_8 = 15; + public final static int KEY_9 = 16; + + /********************************************************/ + /*************** ��ת���� *****************/ + /********************************************************/ + public static final int TRANS_MIRROR = 2; + public static final int TRANS_MIRROR_ROT180 = 1; + public static final int TRANS_MIRROR_ROT270 = 4; + public static final int TRANS_MIRROR_ROT90 = 7; + public static final int TRANS_NONE = 0; + public static final int TRANS_ROT180 = 3; + public static final int TRANS_ROT270 = 6; + public static final int TRANS_ROT90 = 5; + + public static int SLEEP_TIME = 30; + public static boolean isExit = false; + public static boolean isPause = false; + + + public static int SW = 1080; + public static int SH = 1920; + + public static int factSW = 0; + public static int factSH = 0; + //真实全部分辨率 + public static int practicalFactSW=0; + public static int practicalFactSH=0; + public static int landscapepracticalFactSW=0; + public static int landscapepracticalFactSH=0; + public static int landscapeSW = 1920; + public static int landscapeSH = 1080; + public static int landscapeFactSW=0; + public static int landscapeFactSH=0;//横屏分辨率 + public static boolean isZoom = false; + + + + + +} diff --git a/android/app/src/main/java/co/steamcloud/cargame/GsonJsonUtil.java b/android/app/src/main/java/co/steamcloud/cargame/GsonJsonUtil.java new file mode 100644 index 0000000..86a0dd1 --- /dev/null +++ b/android/app/src/main/java/co/steamcloud/cargame/GsonJsonUtil.java @@ -0,0 +1,82 @@ +package co.steamcloud.cargame; + +import com.google.gson.Gson; +import com.google.gson.reflect.TypeToken; + +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +/** + * 字符串转化为json + * + * @author chenye + * @date 2019/01/10 + */ +public class GsonJsonUtil { + private static Gson gson = null; + + static { + if (gson == null) { + gson = new Gson(); + } + } + + /** + * 字符串转化为map + * + * @param string 字符串 + * @return map + */ + public static Map stringToMap(String string) { + Map map = new HashMap(); + if (gson != null) { + map = gson.fromJson(string, new TypeToken() { + }.getType()); + } + return map; + } + + /** + * 字符串转类 + * + * @param string 字符串 + * @param clazz 类 + * @param t + * @return t + */ + public static T stringToObject(String string, Class clazz) { + return (T) gson.fromJson(string, clazz); + } + + + /** + * 转成list + * + * @param string 字符串 + * @param cls 类 + * @return list + */ + public static List stringToList(String string, Class cls) { + List list = null; + if (gson != null) { + list = gson.fromJson(string, new TypeToken>() { + }.getType()); + } + return list; + } + + /** + * 转成json + * + * @param object + * @return + */ + public static String stringToJsonString(Object object) { + String gsonString = null; + if (gson != null) { + gsonString = gson.toJson(object); + } + return gsonString; + } +} diff --git a/android/app/src/main/java/co/steamcloud/cargame/HttpUtils/HttpResultListener.java b/android/app/src/main/java/co/steamcloud/cargame/HttpUtils/HttpResultListener.java new file mode 100644 index 0000000..af7e9e4 --- /dev/null +++ b/android/app/src/main/java/co/steamcloud/cargame/HttpUtils/HttpResultListener.java @@ -0,0 +1,6 @@ +package co.steamcloud.cargame.HttpUtils; + +public interface HttpResultListener { + void onResponse(String data, int code, String msg); + void onFailure(Exception err); +} diff --git a/android/app/src/main/java/co/steamcloud/cargame/HttpUtils/HttpTool.java b/android/app/src/main/java/co/steamcloud/cargame/HttpUtils/HttpTool.java new file mode 100644 index 0000000..44dc053 --- /dev/null +++ b/android/app/src/main/java/co/steamcloud/cargame/HttpUtils/HttpTool.java @@ -0,0 +1,205 @@ +package co.steamcloud.cargame.HttpUtils; + + +import android.util.Log; + +import com.zjrx.common.util.LogUtil; + +import java.io.IOException; +import java.nio.charset.Charset; +import java.security.KeyStore; +import java.security.SecureRandom; +import java.security.cert.X509Certificate; +import java.util.Arrays; + +import javax.net.ssl.HostnameVerifier; +import javax.net.ssl.SSLContext; +import javax.net.ssl.SSLSession; +import javax.net.ssl.SSLSocketFactory; +import javax.net.ssl.TrustManager; +import javax.net.ssl.TrustManagerFactory; +import javax.net.ssl.X509TrustManager; + +import co.steamcloud.cargame.Config; +import okhttp3.Call; +import okhttp3.Callback; +import okhttp3.MediaType; +import okhttp3.OkHttpClient; +import okhttp3.Request; +import okhttp3.RequestBody; +import okhttp3.Response; +import okio.Buffer; + +public class HttpTool { + + public static void httpPost(String url, RequestBody requestBody, final HttpResultListener mListener) { + Log.d("httpTool", "url:" + url); + Log.d("httpTool", "http request body:" + requestBodyToString(requestBody)); + + OkHttpClient httpClient = null; + try { + TrustManagerFactory trustManagerFactory = null; + trustManagerFactory = TrustManagerFactory.getInstance(trustManagerFactory.getDefaultAlgorithm()); + trustManagerFactory.init((KeyStore) null); + TrustManager[] trustManagers = trustManagerFactory.getTrustManagers(); + if (trustManagers.length != 1 || !(trustManagers[0] instanceof X509TrustManager)) { + throw new IllegalStateException("Unexpected default trust managers:" + + Arrays.toString(trustManagers)); + } + X509TrustManager trustManager = (X509TrustManager) trustManagers[0]; + httpClient = new OkHttpClient.Builder() + .addInterceptor(new LoggingInterceptor()) + .sslSocketFactory(createSSLSocketFactory(trustManager), trustManager) + .hostnameVerifier(new TrustAllHostnameVerifier())//trust all?信任所有host + .build(); + } catch (Exception e) { + LogUtil.d("build okhttpclient error, " + e.getMessage()); + } + Request request = new Request.Builder() + .header("Authorization", "Bearer " + Config.userToken) + .header("Channel", Config.Channel) + .header("Platform", Config.Platform) + .header("Version", Config.Version) + .header("Language", Config.Language) + .addHeader("accept", "text/plain") + .addHeader("Content-Type", "application/json-patch+json") + .url(url) + .post(requestBody) + .build(); + httpClient.newCall(request).enqueue(new Callback() { + @Override + public void onFailure(Call call, IOException e) { + LogUtil.d("httpPost_onFailure=" + e.getMessage()); + if (mListener != null) + mListener.onFailure(e); + } + + @Override + public void onResponse(Call call, Response response) throws IOException { + Log.d("TAG", "onResponse: response.body()==" + response.body()); + if (mListener != null && response.body() != null) { + mListener.onResponse(response.body().string(), response.code(), response.message()); + } + } + }); + } + + public static void httpGet(String url, final HttpResultListener mListener) { + Log.d("httpTool", "url:" + url); + + OkHttpClient httpClient = null; + try { + TrustManagerFactory trustManagerFactory = null; + trustManagerFactory = TrustManagerFactory.getInstance(trustManagerFactory.getDefaultAlgorithm()); + trustManagerFactory.init((KeyStore) null); + TrustManager[] trustManagers = trustManagerFactory.getTrustManagers(); + if (trustManagers.length != 1 || !(trustManagers[0] instanceof X509TrustManager)) { + throw new IllegalStateException("Unexpected default trust managers:" + + Arrays.toString(trustManagers)); + } + X509TrustManager trustManager = (X509TrustManager) trustManagers[0]; + httpClient = new OkHttpClient.Builder() + .addInterceptor(new LoggingInterceptor()) + .sslSocketFactory(createSSLSocketFactory(trustManager), trustManager) + .hostnameVerifier(new TrustAllHostnameVerifier())//trust all?信任所有host + .build(); + } catch (Exception e) { + LogUtil.d("build okhttpclient error, " + e.getMessage()); + } + Request request = new Request.Builder() + .header("Authorization", "Bearer " + Config.userToken) + .header("Channel", Config.Channel) + .header("Platform", Config.Platform) + .header("Version", Config.Version) + .header("Language", Config.Language) + .addHeader("accept", "text/plain") + .addHeader("Content-Type", "application/json-patch+json") + .url(url) + .build(); + httpClient.newCall(request).enqueue(new Callback() { + @Override + public void onFailure(Call call, IOException e) { + LogUtil.d("httpPost_onFailure=" + e.getMessage()); + if (mListener != null) + mListener.onFailure(e); + } + + @Override + public void onResponse(Call call, Response response) throws IOException { + Log.d("TAG", "onResponse: response.body()==" + response.body()); + if (mListener != null && response.body() != null) { + mListener.onResponse(response.body().string(), response.code(), response.message()); + } + } + }); + } + + private static String requestBodyToString(RequestBody requestBody) { + Buffer buffer = new Buffer(); + try { + requestBody.writeTo(buffer); + } catch (IOException e) { + e.printStackTrace(); + return ""; + } + //编码设为UTF-8 + Charset charset = Charset.forName("UTF-8"); + MediaType contentType = requestBody.contentType(); + if (contentType != null) { + charset = contentType.charset(Charset.forName("UTF-8")); + } + //拿到request + String requestString = buffer.readString(charset); + return requestString; + } + + private static SSLSocketFactory createSSLSocketFactory() { + SSLSocketFactory ssfFactory = null; + try { + SSLContext sc = SSLContext.getInstance("TLS"); + sc.init(null, new TrustManager[]{new TrustAllCerts()}, new SecureRandom()); + ssfFactory = sc.getSocketFactory(); + } catch (Exception e) { + } + + return ssfFactory; + } + + private static SSLSocketFactory createSSLSocketFactory(X509TrustManager trustManager) { + SSLSocketFactory ssfFactory = null; + try { + SSLContext sslContext = SSLContext.getInstance("TLS"); + sslContext.init(null, new TrustManager[]{trustManager}, null); + ssfFactory = sslContext.getSocketFactory(); + } catch (Exception e) { + } + + return ssfFactory; + } + + private static class TrustAllCerts implements X509TrustManager { + + //checkServerTrusted和checkClientTrusted 这两个方法好像是用于,server和client双向验证 + @Override + public void checkServerTrusted(X509Certificate[] chain, String authType) { + } + + @Override + public void checkClientTrusted(X509Certificate[] chain, String authType) { + + } + + @Override + public X509Certificate[] getAcceptedIssuers() { + return new X509Certificate[0]; + } + } + + private static class TrustAllHostnameVerifier implements HostnameVerifier { + @Override + public boolean verify(String hostname, SSLSession session) { + return true;//trust All的写法就是在这里写的,直接无视hostName,直接返回true,表示信任所有主机 + } + + } +} \ No newline at end of file diff --git a/android/app/src/main/java/co/steamcloud/cargame/HttpUtils/LoggingInterceptor.java b/android/app/src/main/java/co/steamcloud/cargame/HttpUtils/LoggingInterceptor.java new file mode 100644 index 0000000..b0f15f5 --- /dev/null +++ b/android/app/src/main/java/co/steamcloud/cargame/HttpUtils/LoggingInterceptor.java @@ -0,0 +1,59 @@ +package co.steamcloud.cargame.HttpUtils; + +import java.io.IOException; +import java.util.logging.Logger; + +import okhttp3.Interceptor; +import okhttp3.MediaType; +import okhttp3.Request; +import okhttp3.Response; +import okhttp3.ResponseBody; +import okio.Buffer; + +public class LoggingInterceptor implements Interceptor { + + private static final Logger logger = Logger.getLogger(LoggingInterceptor.class.getName()); + + @Override + public Response intercept(Interceptor.Chain chain) throws IOException { + Request request = chain.request(); + + long t1 = System.nanoTime(); + logger.info("Sending request: " + request.url()); + + Response response = chain.proceed(request); + + long t2 = System.nanoTime(); + logger.info("Received response for " + response.request().url() + " in " + ((t2 - t1) / 1e6) + "ms"); + + if (response.body() != null) { + MediaType mediaType = response.body().contentType(); + if (mediaType != null) { + logger.info("Content-Type: " + mediaType); + + String content = response.body().string(); + logger.info("Content: " + content); + + // 重新建立请求体,确保请求可以被重复使用 + ResponseBody body = ResponseBody.create(mediaType, content); + return response.newBuilder().body(body).build(); + } + } + + return response; + } + + private String bodyToString(Request request) { + try { + final Request copy = request.newBuilder().build(); + final Buffer buffer = new Buffer(); + if (copy.body() != null) + copy.body().writeTo(buffer); + else + return ""; + return buffer.readUtf8(); + } catch (final IOException e) { + return "did not work"; + } + } +} \ No newline at end of file diff --git a/android/app/src/main/java/co/steamcloud/cargame/HttpUtils/OnHttpListener.java b/android/app/src/main/java/co/steamcloud/cargame/HttpUtils/OnHttpListener.java new file mode 100644 index 0000000..435c999 --- /dev/null +++ b/android/app/src/main/java/co/steamcloud/cargame/HttpUtils/OnHttpListener.java @@ -0,0 +1,6 @@ +package co.steamcloud.cargame.HttpUtils; + +public interface OnHttpListener { + void onResponse(String body, int code, String msg); + void onFailure(Exception err); +} diff --git a/android/app/src/main/java/co/steamcloud/cargame/HttpUtils/OpenApiRequest.java b/android/app/src/main/java/co/steamcloud/cargame/HttpUtils/OpenApiRequest.java new file mode 100644 index 0000000..399a363 --- /dev/null +++ b/android/app/src/main/java/co/steamcloud/cargame/HttpUtils/OpenApiRequest.java @@ -0,0 +1,179 @@ +package co.steamcloud.cargame.HttpUtils; + +import com.zjrx.common.util.LogUtil; +import com.zjrx.jyengine.bs.OnApiRequestListener; + +import org.json.JSONObject; + +import java.security.MessageDigest; +import java.security.NoSuchAlgorithmException; +import java.util.Arrays; +import java.util.HashMap; +import java.util.Map; +import java.util.Set; + +import co.steamcloud.cargame.Config; +import okhttp3.MediaType; +import okhttp3.RequestBody; + +public class OpenApiRequest { + + + /** + * 游戏心跳 扣费 + * + * @param mListener 监听 + */ + public void playGameHeartbeat(final OnApiRequestListener mListener) { + String url = Config.url + "api/PlayGame/PlayGameHeartbeat"; + final Map map = new HashMap<>(); + map.put("gameId", Config.gameId); + map.put("sign", sign(map, Config.sign_key)); + // 将HashMap转换为JSONObject + JSONObject jsonObject = new JSONObject(map); + + RequestBody requestBody = RequestBody.create( + MediaType.parse("application/json"), jsonObject.toString()); + HttpTool.httpPost(url, requestBody, new HttpResultListener() { + @Override + public void onResponse(String data, int code, String msg) { + if (mListener != null) { + mListener.onResponse(data, code, msg); + } + } + + @Override + public void onFailure(Exception err) { + LogUtil.d("err:" + err.getMessage()); + if (mListener != null) + mListener.onFailure(err); + } + }); + } + + /** + * 退出游戏 + * + * @param mListener 监听 + */ + public void exitPlayGame(String playGameDetails, final OnApiRequestListener mListener) { + String url = Config.url + "api/PlayGame/ExitPlayGame"; + final Map map = new HashMap<>(); + map.put("gameId", Config.gameId); + map.put("playGameDetails", playGameDetails); + map.put("sign", sign(map, Config.sign_key)); + // 将HashMap转换为JSONObject + JSONObject jsonObject = new JSONObject(map); + + RequestBody requestBody = RequestBody.create( + MediaType.parse("application/json"), jsonObject.toString()); + HttpTool.httpPost(url, requestBody, new HttpResultListener() { + @Override + public void onResponse(String data, int code, String msg) { + if (mListener != null) { + mListener.onResponse(data, code, msg); + } + } + + @Override + public void onFailure(Exception err) { + LogUtil.d("err:" + err.getMessage()); + if (mListener != null) + mListener.onFailure(err); + } + }); + } + + /** + * 获取游戏设置 + * + * @param mListener 回调 + */ + public void gameSetting(final OnApiRequestListener mListener) { + String url = Config.url + "api/PlayGame/GameSetting?gameId=" + Config.gameId; +// final Map map = new HashMap<>(); +// map.put("gameId", Config.gameId); +// map.put("sign", sign(map, Config.sign_key)); + // 将HashMap转换为JSONObject +// JSONObject jsonObject = new JSONObject(map); +// +// RequestBody requestBody = RequestBody.create( +// MediaType.parse("application/json"), jsonObject.toString()); + HttpTool.httpGet(url, new HttpResultListener() { + @Override + public void onResponse(String data, int code, String msg) { + if (mListener != null) { + mListener.onResponse(data, code, msg); + } + } + + @Override + public void onFailure(Exception err) { + LogUtil.d("err:" + err.getMessage()); + if (mListener != null) + mListener.onFailure(err); + } + }); + } + + + /** + * 排序加密 + * + * @param data data + * @param key key + * @return String + */ + public static String sign(Map data, String key) { + Set keySet = data.keySet(); + String[] keyArray = keySet.toArray(new String[keySet.size()]); + Arrays.sort(keyArray); + StringBuilder sb = new StringBuilder(); + StringBuilder requestData = new StringBuilder(); + for (String k : keyArray) { + if (k.equals("sign")) { + continue; + } + if (data.get(k) != null && data.get(k).trim().length() > 0) { // 参数值为空,则不参与签名 + sb.append(data.get(k)); + } + requestData.append(k).append("=").append(data.get(k)).append("&"); + } + sb.append(key); + String md5Sign = md5s(sb.toString()).toUpperCase(); + requestData.append("sign=").append(md5Sign); + //System.out.println("requestData:" + requestData); + try { + return md5Sign; + } catch (Exception e) { + e.printStackTrace(); + return ""; + } + } + + public static String md5s(String plainText) { + String str = ""; + try { + MessageDigest md = MessageDigest.getInstance("MD5"); + md.update(plainText.getBytes()); + byte b[] = md.digest(); + int i; + StringBuffer buf = new StringBuffer(""); + for (int offset = 0; offset < b.length; offset++) { + i = b[offset]; + if (i < 0) + i += 256; + if (i < 16) + buf.append("0"); + buf.append(Integer.toHexString(i)); + } + str = buf.toString(); + str = str.toUpperCase(); + } catch (NoSuchAlgorithmException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + return str; + } + +} diff --git a/android/app/src/main/java/co/steamcloud/cargame/IDialogTwoView.java b/android/app/src/main/java/co/steamcloud/cargame/IDialogTwoView.java new file mode 100644 index 0000000..0515348 --- /dev/null +++ b/android/app/src/main/java/co/steamcloud/cargame/IDialogTwoView.java @@ -0,0 +1,8 @@ +package co.steamcloud.cargame; + + +public interface IDialogTwoView { + void cancel();//取消 + void onSure();//确认 + void returnApp();//返回app +} diff --git a/android/app/src/main/java/co/steamcloud/cargame/JoystickView2.java b/android/app/src/main/java/co/steamcloud/cargame/JoystickView2.java new file mode 100644 index 0000000..a9f1181 --- /dev/null +++ b/android/app/src/main/java/co/steamcloud/cargame/JoystickView2.java @@ -0,0 +1,191 @@ +package co.steamcloud.cargame; + +import android.content.Context; +import android.graphics.Bitmap; +import android.graphics.BitmapFactory; +import android.graphics.Canvas; +import android.graphics.Matrix; +import android.graphics.Paint; +import android.util.AttributeSet; +import android.util.Log; +import android.view.MotionEvent; +import android.view.View; + +import androidx.annotation.Nullable; + +public class JoystickView2 extends View { + public float currentX ; + public float currentY ; + public float initX ; + public float initY ; + public float currentX2 ; + public float currentY2 ; + float lastX; + float lastY; + float lastVibX; + float lastVibY; + public int viewSize; + private float viewSizeW; + private float viewSizeH; + private float vibratorRanger; + public int pointSize; + private float maxRanger=150; + public float maxRanger2 = 150; + public Context context; + public Bitmap map; + private Bitmap mDirectionBmp; + public static Paint paint = new Paint(Paint.ANTI_ALIAS_FLAG); + public OnJoystickListener mListener; + public JoystickView2(Context context) { + super(context); + this.context = context; + } + + public JoystickView2(Context context, @Nullable AttributeSet attrs) { + super(context, attrs); + this.context = context; + } + + public JoystickView2(Context context, @Nullable AttributeSet attrs, int defStyleAttr) { + super(context, attrs, defStyleAttr); + this.context = context; + } + public Bitmap zoomImg(Bitmap bm, int newWidth, int newHeight) { + int width = bm.getWidth(); + int height = bm.getHeight(); + float scaleWidth = (float)newWidth / (float)width; + float scaleHeight = (float)newHeight / (float)height; + Matrix matrix = new Matrix(); + matrix.postScale(scaleWidth, scaleHeight); + Bitmap newbm = Bitmap.createBitmap(bm, 0, 0, width, height, matrix, true); + return newbm; + } + + + public void onLayout(boolean changed, int left, int top, int right, int bottom) { + super.onLayout(changed, left, top, right, bottom); + this.viewSize = this.getMeasuredWidth(); + int var10000 = this.viewSize; + this.pointSize = var10000 / 3; + viewSizeW=this.getMeasuredWidth(); + viewSizeH=this.getMeasuredHeight(); + vibratorRanger=viewSizeH/6; + if (maxRanger>viewSizeH/4) + { + maxRanger=viewSizeH/4; + } + if (maxRanger2>viewSizeH/3) + { + maxRanger2=viewSizeH/3; + } + + this.init(); + } + public void init() { + currentX = currentX2=initX=lastX=viewSizeW/2; + currentY= currentY2 =initY=lastY=viewSizeH/2; + int var1 = this.pointSize; + Bitmap var10000 = BitmapFactory.decodeResource(this.context.getResources(), R.mipmap.joystick_round); + Bitmap mDirectionBmp1 = BitmapFactory.decodeResource(this.context.getResources(), R.mipmap.joystick_down); + this.mDirectionBmp = this.zoomImg(mDirectionBmp1, viewSize, viewSize); + this.map = this.zoomImg(var10000, var1, var1); + + } + + @Override + protected void onDraw(Canvas canvas){ + super.onDraw(canvas); + paint.setDither(true); + canvas.drawBitmap(this.map, currentX2 - this.pointSize / 2, currentY2 - this.pointSize / 2, paint); + if (currentX != initX && currentY != initY) { + // 画方向指示箭头 + float rotationDegree = (float) RoundCalculator.calTwoPointAngleDegree(initX, initY, + currentX, currentY); + Matrix matrix = new Matrix(); + int offsetX = mDirectionBmp.getWidth() / 2; + int offsetY = mDirectionBmp.getHeight() / 2; + matrix.postTranslate(-offsetX, -offsetY); + matrix.postRotate(270 - rotationDegree); + matrix.postTranslate(initX - mDirectionBmp.getWidth()/2 + offsetX, initY - mDirectionBmp.getHeight()/2 + offsetY); + canvas.drawBitmap(mDirectionBmp, matrix, null); + } + + } + + public void setOnJoystickListener(OnJoystickListener listener) { + this.mListener = listener; + } + @Override + public boolean onTouchEvent(MotionEvent event) { + if(Config.s_keyboard){ + return false; + } + if (event.getAction()==MotionEvent.ACTION_DOWN||event.getAction()==MotionEvent.ACTION_MOVE){ + + /*if (event.getAction()==MotionEvent.ACTION_DOWN) { + initX2 = event.getX(); + initY2 = event.getY(); + }*/ + this.currentX = event.getX(); + this.currentY = event.getY(); + + this.currentX2 = event.getX(); + this.currentY2 = event.getY(); + + float tr = (float) RoundCalculator.calTwoPointDistant(initX, initY, event.getX(), event.getY()); + if (tr>maxRanger) + { + float dotCenterOnShow[] = RoundCalculator.calPointLocationByAngle( + initX, initY, event.getX(), event.getY(), maxRanger); + this.currentX = dotCenterOnShow[0]; + this.currentY = dotCenterOnShow[1]; + Log.e("currentXY1","...x="+currentX2+",y="+currentY2+",maxRanger2="+maxRanger2); + } + + + float tr2 = (float) RoundCalculator.calTwoPointDistant(initX, initY, event.getX(), event.getY()); + if (tr2>maxRanger2) + { + float dotCenterOnShow[] = RoundCalculator.calPointLocationByAngle( + initX, initY, event.getX(), event.getY(), maxRanger2); + this.currentX2 = dotCenterOnShow[0]; + this.currentY2 = dotCenterOnShow[1]; + + } + + }else { + this.currentX =initX; + this.currentY =initY; + + this.currentX2 = initX; + this.currentY2 = initY; + } + + + + if (mListener!=null){ + //if (Math.abs(currentX-lastX)>3||Math.abs(currentY-lastY)>3){ + + mListener.onPosition((currentX-initX)/(float)maxRanger,(currentY-initY)/(float)maxRanger); + + lastX=currentX; + lastY=currentY; + // } + if (Math.abs(currentX-lastVibX)>vibratorRanger||Math.abs(currentY-lastVibY)>vibratorRanger){//用来震动 + this.mListener.onVibrator(); + lastVibX=currentX; + lastVibY=currentY; + } + + } + this.invalidate(); + return true; + } + + public interface OnJoystickListener { + void onPosition(float var1, float var2); + + void onVibrator(); + } + +} diff --git a/android/app/src/main/java/co/steamcloud/cargame/KeyButton.java b/android/app/src/main/java/co/steamcloud/cargame/KeyButton.java new file mode 100644 index 0000000..8568f62 --- /dev/null +++ b/android/app/src/main/java/co/steamcloud/cargame/KeyButton.java @@ -0,0 +1,190 @@ +package co.steamcloud.cargame; + +import android.content.Context; +import android.util.AttributeSet; +import android.view.MotionEvent; +import android.view.View; + +import androidx.annotation.NonNull; +import androidx.annotation.Nullable; + +public class KeyButton extends androidx.appcompat.widget.AppCompatTextView { + + + public KeyButton(@NonNull Context context, String KeyIndex, String KeyName, int SX, int SY, + int SW, int SH, String SelectedImage, String KeyImage, float Scale) { + super(context); + this.KeyIndex = KeyIndex; + this.KeyName = KeyName; + this.SX = SX; + this.SY = SY; + this.SW = SW; + this.SH = SH; + this.SelectedImage = SelectedImage; + this.KeyImage = KeyImage; + this.Scale = Scale; + } + + public KeyButton(@NonNull Context context, @Nullable AttributeSet attrs, String KeyIndex, String KeyName, int SX, int SY, + int SW, int SH, String SelectedImage, String KeyImage, float Scale) { + super(context, attrs); + this.KeyIndex = KeyIndex; + this.KeyName = KeyName; + this.SX = SX; + this.SY = SY; + this.SW = SW; + this.SH = SH; + this.SelectedImage = SelectedImage; + this.KeyImage = KeyImage; + this.Scale = Scale; + } + + private OnClickCallBackListener mListener; + private ViewChangMsgListener viewChangMsgListener; + + private String KeyIndex; + private String KeyName; + private int SX; + private int SY; + private int SW; + private int SH; + private String SelectedImage; + private String KeyImage; + private float Scale; + + private float mOriginalX; + private float mOriginalY; + private float mOriginalRawX; + private float mOriginalRawY; + public float touchInitX; + public float touchInitY; + boolean isMove = false; + @Override + public boolean onTouchEvent(MotionEvent event) { + Config.keyEvent_time=0; + /* if(!Config.s_keyboard){ + return super.onTouchEvent(event); + }*/ + switch (event.getAction()) { + case MotionEvent.ACTION_DOWN: + mOriginalX = getX(); + mOriginalY = getY(); + mOriginalRawX = event.getRawX(); + mOriginalRawY = event.getRawY(); + + touchInitX = event.getX(); + touchInitY = event.getY(); + isMove = false; + + + if (mListener!=null){ + mListener.onActionDown(event); + } + + + + + break; + case MotionEvent.ACTION_MOVE: + if(Config.s_keyboard){ + if (Math.abs(event.getX() - touchInitX) > 10 || Math.abs(event.getY() - touchInitY) > 10) { + isMove = true; + setX(mOriginalX + event.getRawX() - mOriginalRawX); + setY(mOriginalY + event.getRawY() - mOriginalRawY); + } + }else { + if (Math.abs(event.getX() - touchInitX) > 10 || Math.abs(event.getY() - touchInitY) > 10) { + if (mListener!=null){ + mListener.onActionMove(event); + } + /* setX(mOriginalX + event.getRawX() - mOriginalRawX); + setY(mOriginalY + event.getRawY() - mOriginalRawY);*/ + } + } + + break; + case MotionEvent.ACTION_UP: + if (!isMove) { + if (mListener!=null){ + mListener.onActionUp(); + } + } + + break; + } + + + return true; + } + public void setOnClickCallBackListener(OnClickCallBackListener listener){ + this.mListener=listener; + } + + public void keyBoardDelectListener(ViewChangMsgListener viewChangMsgListener){ + this.viewChangMsgListener =viewChangMsgListener; + } + + + public interface OnClickCallBackListener{ + void onActionDown(MotionEvent event); + void onActionUp(); + void onActionMove(MotionEvent event); + } + + public void setPosition(float x,float y) { + this.setX(x); + this.setY(y); + } + + public interface ViewChangMsgListener{ + void changTexture(String path); + void showDeletPopup(KeyButton view); + void showDeletPopup(String index); + void showFloatPopup(); + } + + public interface virtualHandleChangeListener{ + void layerBtnSetVisible(int tag); + } + public interface virtualKeyboardChangeListener + { + void removeChild(View child); + void hideDirection(); + } + + public String getKeyIndex() { + return KeyIndex; + } + + public String getKeyName() { + return KeyName; + } + + public int getSX() { + return SX; + } + + public int getSY() { + return SY; + } + + public int getSW() { + return SW; + } + + public int getSH() { + return SH; + } + + public String getSelectedImage() { + return SelectedImage; + } + + public String getKeyImage() { + return KeyImage; + } + + public float getScale() { + return Scale; + } +} diff --git a/android/app/src/main/java/co/steamcloud/cargame/KeyboardUtil.java b/android/app/src/main/java/co/steamcloud/cargame/KeyboardUtil.java new file mode 100644 index 0000000..51fbe8d --- /dev/null +++ b/android/app/src/main/java/co/steamcloud/cargame/KeyboardUtil.java @@ -0,0 +1,443 @@ +package co.steamcloud.cargame; + +import android.app.Activity; +import android.content.Context; +import android.inputmethodservice.Keyboard; +import android.inputmethodservice.Keyboard.Key; +import android.inputmethodservice.KeyboardView; +import android.inputmethodservice.KeyboardView.OnKeyboardActionListener; +import android.os.SystemClock; +import android.view.KeyEvent; +import android.view.View; +import android.widget.EditText; + +import com.zjrx.jyengine.WhaleCloud; + +import java.util.List; + +public class KeyboardUtil { + private Context ctx; + private Activity act; + private KeyboardView keyboardView; + private Keyboard k1;// 字母键盘 + private Keyboard k2;// 数字键盘 + private Keyboard k3, k4, k5, k6;//标点符号键盘 + public boolean isnun = false;// 是否数据键盘 + public boolean ispun = false;//是否标点键盘 + public boolean isupper = false;// 是否大写 + public boolean isShow = false; + + public static final int KEYCODE_PUN = -7; + + private EditText ed; + + public KeyboardUtil(Activity act, Context ctx) { + this.act = act; + this.ctx = ctx; + //this.ed = edit; + k1 = new Keyboard(ctx, R.xml.qwerty); + k2 = new Keyboard(ctx, R.xml.symbols); + k3 = new Keyboard(ctx, R.xml.punctuate1); + k4 = new Keyboard(ctx, R.xml.punctuate2); + k5 = new Keyboard(ctx, R.xml.punctuate3); + k6 = new Keyboard(ctx, R.xml.punctuate4); + keyboardView = (KeyboardView) act.findViewById(R.id.keyboard_view); + keyboardView.setKeyboard(k1); + keyboardView.setEnabled(true); + keyboardView.setPreviewEnabled(false); + keyboardView.setOnKeyboardActionListener(listener); + } + + private OnKeyboardActionListener listener = new OnKeyboardActionListener() { + @Override + public void swipeUp() { + } + + @Override + public void swipeRight() { + } + + @Override + public void swipeLeft() { + } + + @Override + public void swipeDown() { + } + + @Override + public void onText(CharSequence text) { + } + + @Override + public void onRelease(int primaryCode) { + + if (primaryCode != 10003 && primaryCode != 10004 && primaryCode != 10005 && primaryCode != 10006 + && primaryCode != 10007 && primaryCode != 10008 && primaryCode != 10030 && primaryCode != 10031 + && primaryCode != 10032) {// 完成 + + long now3 = SystemClock.uptimeMillis(); + KeyEvent keyevent3, keyevent33; + switch (primaryCode) { + case 10009: + keyevent33 = new KeyEvent(now3, now3, KeyEvent.ACTION_UP, 220, 0); + WhaleCloud.getInstance().sendKeyBoardStatus(keyevent33); + keyevent3 = new KeyEvent(now3, now3, KeyEvent.ACTION_UP, 160, 0); + WhaleCloud.getInstance().sendKeyBoardStatus(keyevent3); + break; + case 10010: + keyevent33 = new KeyEvent(now3, now3, KeyEvent.ACTION_UP, 219, 0); + WhaleCloud.getInstance().sendKeyBoardStatus(keyevent33); + keyevent3 = new KeyEvent(now3, now3, KeyEvent.ACTION_UP, 160, 0); + WhaleCloud.getInstance().sendKeyBoardStatus(keyevent3); + break; + case 10011: + keyevent3 = new KeyEvent(now3, now3, KeyEvent.ACTION_UP, 221, 0); + WhaleCloud.getInstance().sendKeyBoardStatus(keyevent3); + keyevent33 = new KeyEvent(now3, now3, KeyEvent.ACTION_UP, 160, 0); + WhaleCloud.getInstance().sendKeyBoardStatus(keyevent33); + break; + case 10012: + keyevent3 = new KeyEvent(now3, now3, KeyEvent.ACTION_UP, 109, 0); + WhaleCloud.getInstance().sendKeyBoardStatus(keyevent3); + keyevent33 = new KeyEvent(now3, now3, KeyEvent.ACTION_UP, 160, 0); + WhaleCloud.getInstance().sendKeyBoardStatus(keyevent33); + break; + case 10013: + keyevent3 = new KeyEvent(now3, now3, KeyEvent.ACTION_UP, 222, 0); + WhaleCloud.getInstance().sendKeyBoardStatus(keyevent3); + keyevent33 = new KeyEvent(now3, now3, KeyEvent.ACTION_UP, 160, 0); + WhaleCloud.getInstance().sendKeyBoardStatus(keyevent33); + break; + case 10014: + keyevent3 = new KeyEvent(now3, now3, KeyEvent.ACTION_UP, 192, 0); + WhaleCloud.getInstance().sendKeyBoardStatus(keyevent3); + keyevent33 = new KeyEvent(now3, now3, KeyEvent.ACTION_UP, 160, 0); + WhaleCloud.getInstance().sendKeyBoardStatus(keyevent33); + break; + case 10015: + keyevent3 = new KeyEvent(now3, now3, KeyEvent.ACTION_UP, 49, 0); + WhaleCloud.getInstance().sendKeyBoardStatus(keyevent3); + keyevent33 = new KeyEvent(now3, now3, KeyEvent.ACTION_UP, 160, 0); + WhaleCloud.getInstance().sendKeyBoardStatus(keyevent33); + break; + case 10016: + keyevent3 = new KeyEvent(now3, now3, KeyEvent.ACTION_UP, 50, 0); + WhaleCloud.getInstance().sendKeyBoardStatus(keyevent3); + keyevent33 = new KeyEvent(now3, now3, KeyEvent.ACTION_UP, 160, 0); + WhaleCloud.getInstance().sendKeyBoardStatus(keyevent33); + break; + case 10017: + keyevent3 = new KeyEvent(now3, now3, KeyEvent.ACTION_UP, 51, 0); + WhaleCloud.getInstance().sendKeyBoardStatus(keyevent3); + keyevent33 = new KeyEvent(now3, now3, KeyEvent.ACTION_UP, 160, 0); + WhaleCloud.getInstance().sendKeyBoardStatus(keyevent33); + break; + case 10018: + keyevent3 = new KeyEvent(now3, now3, KeyEvent.ACTION_UP, 191, 0); + WhaleCloud.getInstance().sendKeyBoardStatus(keyevent3); + keyevent33 = new KeyEvent(now3, now3, KeyEvent.ACTION_UP, 160, 0); + WhaleCloud.getInstance().sendKeyBoardStatus(keyevent33); + break; + case 10019: + keyevent3 = new KeyEvent(now3, now3, KeyEvent.ACTION_UP, 53, 0); + WhaleCloud.getInstance().sendKeyBoardStatus(keyevent3); + keyevent33 = new KeyEvent(now3, now3, KeyEvent.ACTION_UP, 160, 0); + WhaleCloud.getInstance().sendKeyBoardStatus(keyevent33); + break; + case 10020: + keyevent3 = new KeyEvent(now3, now3, KeyEvent.ACTION_UP, 54, 0); + WhaleCloud.getInstance().sendKeyBoardStatus(keyevent3); + keyevent33 = new KeyEvent(now3, now3, KeyEvent.ACTION_UP, 160, 0); + WhaleCloud.getInstance().sendKeyBoardStatus(keyevent33); + break; + case 10021: + keyevent3 = new KeyEvent(now3, now3, KeyEvent.ACTION_UP, 55, 0); + WhaleCloud.getInstance().sendKeyBoardStatus(keyevent3); + keyevent33 = new KeyEvent(now3, now3, KeyEvent.ACTION_UP, 160, 0); + WhaleCloud.getInstance().sendKeyBoardStatus(keyevent33); + break; + case 10022: + keyevent3 = new KeyEvent(now3, now3, KeyEvent.ACTION_UP, 57, 0); + WhaleCloud.getInstance().sendKeyBoardStatus(keyevent3); + keyevent33 = new KeyEvent(now3, now3, KeyEvent.ACTION_UP, 160, 0); + WhaleCloud.getInstance().sendKeyBoardStatus(keyevent33); + break; + case 10023: + keyevent3 = new KeyEvent(now3, now3, KeyEvent.ACTION_UP, 48, 0); + WhaleCloud.getInstance().sendKeyBoardStatus(keyevent3); + keyevent33 = new KeyEvent(now3, now3, KeyEvent.ACTION_UP, 160, 0); + WhaleCloud.getInstance().sendKeyBoardStatus(keyevent33); + break; + case 10024: + keyevent3 = new KeyEvent(now3, now3, KeyEvent.ACTION_UP, 188, 0); + WhaleCloud.getInstance().sendKeyBoardStatus(keyevent3); + keyevent33 = new KeyEvent(now3, now3, KeyEvent.ACTION_UP, 160, 0); + WhaleCloud.getInstance().sendKeyBoardStatus(keyevent33); + break; + case 10025: + keyevent3 = new KeyEvent(now3, now3, KeyEvent.ACTION_UP, 190, 0); + WhaleCloud.getInstance().sendKeyBoardStatus(keyevent3); + keyevent33 = new KeyEvent(now3, now3, KeyEvent.ACTION_UP, 160, 0); + WhaleCloud.getInstance().sendKeyBoardStatus(keyevent33); + break; + case 10026: + keyevent3 = new KeyEvent(now3, now3, KeyEvent.ACTION_UP, 52, 0); + WhaleCloud.getInstance().sendKeyBoardStatus(keyevent3); + keyevent33 = new KeyEvent(now3, now3, KeyEvent.ACTION_UP, 160, 0); + WhaleCloud.getInstance().sendKeyBoardStatus(keyevent33); + break; + default: + if (isupper && isword2(primaryCode)) { + keyevent33 = new KeyEvent(now3, now3, KeyEvent.ACTION_UP, primaryCode, 0); + WhaleCloud.getInstance().sendKeyBoardStatus(keyevent33); + keyevent3 = new KeyEvent(now3, now3, KeyEvent.ACTION_UP, 160, 0); + WhaleCloud.getInstance().sendKeyBoardStatus(keyevent3); + } else { + KeyEvent keyevent = new KeyEvent(now3, now3, KeyEvent.ACTION_UP, primaryCode, 0); + WhaleCloud.getInstance().sendKeyBoardStatus(keyevent); + } + break; + + } + + } + } + + @Override + public void onPress(int primaryCode) { + + if (primaryCode != 10003 && primaryCode != 10004 && primaryCode != 10005 && primaryCode != 10006 + && primaryCode != 10007 && primaryCode != 10008 && primaryCode != 10030 && primaryCode != 10031 + && primaryCode != 10032) {// 完成 + long now3 = SystemClock.uptimeMillis(); + KeyEvent keyevent3, keyevent33; + switch (primaryCode) { + case 10009: + keyevent3 = new KeyEvent(now3, now3, KeyEvent.ACTION_DOWN, 160, 0); + WhaleCloud.getInstance().sendKeyBoardStatus(keyevent3); + keyevent33 = new KeyEvent(now3, now3, KeyEvent.ACTION_DOWN, 220, 0); + WhaleCloud.getInstance().sendKeyBoardStatus(keyevent33); + break; + case 10010: + keyevent3 = new KeyEvent(now3, now3, KeyEvent.ACTION_DOWN, 160, 0); + WhaleCloud.getInstance().sendKeyBoardStatus(keyevent3); + keyevent33 = new KeyEvent(now3, now3, KeyEvent.ACTION_DOWN, 219, 0); + WhaleCloud.getInstance().sendKeyBoardStatus(keyevent33); + break; + case 10011: + keyevent3 = new KeyEvent(now3, now3, KeyEvent.ACTION_DOWN, 160, 0); + WhaleCloud.getInstance().sendKeyBoardStatus(keyevent3); + keyevent33 = new KeyEvent(now3, now3, KeyEvent.ACTION_DOWN, 221, 0); + WhaleCloud.getInstance().sendKeyBoardStatus(keyevent33); + break; + case 10012: + keyevent3 = new KeyEvent(now3, now3, KeyEvent.ACTION_DOWN, 160, 0); + WhaleCloud.getInstance().sendKeyBoardStatus(keyevent3); + keyevent33 = new KeyEvent(now3, now3, KeyEvent.ACTION_DOWN, 109, 0); + WhaleCloud.getInstance().sendKeyBoardStatus(keyevent33); + break; + case 10013: + keyevent3 = new KeyEvent(now3, now3, KeyEvent.ACTION_DOWN, 160, 0); + WhaleCloud.getInstance().sendKeyBoardStatus(keyevent3); + keyevent33 = new KeyEvent(now3, now3, KeyEvent.ACTION_DOWN, 222, 0); + WhaleCloud.getInstance().sendKeyBoardStatus(keyevent33); + break; + case 10014: + keyevent3 = new KeyEvent(now3, now3, KeyEvent.ACTION_DOWN, 160, 0); + WhaleCloud.getInstance().sendKeyBoardStatus(keyevent3); + keyevent33 = new KeyEvent(now3, now3, KeyEvent.ACTION_DOWN, 192, 0); + WhaleCloud.getInstance().sendKeyBoardStatus(keyevent33); + break; + case 10015: + keyevent3 = new KeyEvent(now3, now3, KeyEvent.ACTION_DOWN, 160, 0); + WhaleCloud.getInstance().sendKeyBoardStatus(keyevent3); + keyevent33 = new KeyEvent(now3, now3, KeyEvent.ACTION_DOWN, 49, 0); + WhaleCloud.getInstance().sendKeyBoardStatus(keyevent33); + break; + case 10016: + keyevent3 = new KeyEvent(now3, now3, KeyEvent.ACTION_DOWN, 160, 0); + WhaleCloud.getInstance().sendKeyBoardStatus(keyevent3); + keyevent33 = new KeyEvent(now3, now3, KeyEvent.ACTION_DOWN, 50, 0); + WhaleCloud.getInstance().sendKeyBoardStatus(keyevent33); + break; + case 10017: + keyevent3 = new KeyEvent(now3, now3, KeyEvent.ACTION_DOWN, 160, 0); + WhaleCloud.getInstance().sendKeyBoardStatus(keyevent3); + keyevent33 = new KeyEvent(now3, now3, KeyEvent.ACTION_DOWN, 51, 0); + WhaleCloud.getInstance().sendKeyBoardStatus(keyevent33); + break; + case 10018: + keyevent3 = new KeyEvent(now3, now3, KeyEvent.ACTION_DOWN, 160, 0); + WhaleCloud.getInstance().sendKeyBoardStatus(keyevent3); + keyevent33 = new KeyEvent(now3, now3, KeyEvent.ACTION_DOWN, 191, 0); + WhaleCloud.getInstance().sendKeyBoardStatus(keyevent33); + break; + case 10019: + keyevent3 = new KeyEvent(now3, now3, KeyEvent.ACTION_DOWN, 160, 0); + WhaleCloud.getInstance().sendKeyBoardStatus(keyevent3); + keyevent33 = new KeyEvent(now3, now3, KeyEvent.ACTION_DOWN, 53, 0); + WhaleCloud.getInstance().sendKeyBoardStatus(keyevent33); + break; + case 10020: + keyevent3 = new KeyEvent(now3, now3, KeyEvent.ACTION_DOWN, 160, 0); + WhaleCloud.getInstance().sendKeyBoardStatus(keyevent3); + keyevent33 = new KeyEvent(now3, now3, KeyEvent.ACTION_DOWN, 54, 0); + WhaleCloud.getInstance().sendKeyBoardStatus(keyevent33); + break; + case 10021: + keyevent3 = new KeyEvent(now3, now3, KeyEvent.ACTION_DOWN, 160, 0); + WhaleCloud.getInstance().sendKeyBoardStatus(keyevent3); + keyevent33 = new KeyEvent(now3, now3, KeyEvent.ACTION_DOWN, 55, 0); + WhaleCloud.getInstance().sendKeyBoardStatus(keyevent33); + break; + case 10022: + keyevent3 = new KeyEvent(now3, now3, KeyEvent.ACTION_DOWN, 160, 0); + WhaleCloud.getInstance().sendKeyBoardStatus(keyevent3); + keyevent33 = new KeyEvent(now3, now3, KeyEvent.ACTION_DOWN, 57, 0); + WhaleCloud.getInstance().sendKeyBoardStatus(keyevent33); + break; + case 10023: + keyevent3 = new KeyEvent(now3, now3, KeyEvent.ACTION_DOWN, 160, 0); + WhaleCloud.getInstance().sendKeyBoardStatus(keyevent3); + keyevent33 = new KeyEvent(now3, now3, KeyEvent.ACTION_DOWN, 48, 0); + WhaleCloud.getInstance().sendKeyBoardStatus(keyevent33); + break; + case 10024: + keyevent3 = new KeyEvent(now3, now3, KeyEvent.ACTION_DOWN, 160, 0); + WhaleCloud.getInstance().sendKeyBoardStatus(keyevent3); + keyevent33 = new KeyEvent(now3, now3, KeyEvent.ACTION_DOWN, 188, 0); + WhaleCloud.getInstance().sendKeyBoardStatus(keyevent33); + break; + case 10025: + keyevent3 = new KeyEvent(now3, now3, KeyEvent.ACTION_DOWN, 160, 0); + WhaleCloud.getInstance().sendKeyBoardStatus(keyevent3); + keyevent33 = new KeyEvent(now3, now3, KeyEvent.ACTION_DOWN, 190, 0); + WhaleCloud.getInstance().sendKeyBoardStatus(keyevent33); + break; + case 10026: + keyevent3 = new KeyEvent(now3, now3, KeyEvent.ACTION_DOWN, 160, 0); + WhaleCloud.getInstance().sendKeyBoardStatus(keyevent3); + keyevent33 = new KeyEvent(now3, now3, KeyEvent.ACTION_DOWN, 52, 0); + WhaleCloud.getInstance().sendKeyBoardStatus(keyevent33); + break; + default: + if (isupper && isword2(primaryCode)) { + keyevent3 = new KeyEvent(now3, now3, KeyEvent.ACTION_DOWN, 160, 0); + WhaleCloud.getInstance().sendKeyBoardStatus(keyevent3); + keyevent33 = new KeyEvent(now3, now3, KeyEvent.ACTION_DOWN, primaryCode, 0); + WhaleCloud.getInstance().sendKeyBoardStatus(keyevent33); + } else { + KeyEvent keyevent = new KeyEvent(now3, now3, KeyEvent.ACTION_DOWN, primaryCode, 0); + WhaleCloud.getInstance().sendKeyBoardStatus(keyevent); + } + break; + + } + + + } + + } + + @Override + public void onKey(int primaryCode, int[] keyCodes) { + //Editable editable = ed.getText(); + //int start = ed.getSelectionStart(); + if (primaryCode == 10004) {// 关闭 + hideKeyboard(); + } else if (primaryCode == 10003) {// 符号 + keyboardView.setKeyboard(k3); + } else if (primaryCode == 10008) {//特殊字符返回 + keyboardView.setKeyboard(k1); + } else if (primaryCode == 10032) {// 大小写切换 + changeKey(); + keyboardView.setKeyboard(k1); + } else if (primaryCode == 10006) {// 符号上翻 + keyboardView.setKeyboard(k3); + } else if (primaryCode == 10007) {// 符号下翻 + keyboardView.setKeyboard(k4); + } else if (primaryCode == 10030 || primaryCode == 10005) {// 符号上翻 + keyboardView.setKeyboard(k5); + } else if (primaryCode == 10031) {// 符号下翻 + keyboardView.setKeyboard(k6); + } else { + /* long now = SystemClock.uptimeMillis(); + KeyEvent keyevent = new KeyEvent(now, now, KeyEvent.ACTION_DOWN, primaryCode, 0); + WhaleCloud.getInstance().sendKeyBoardStatus(keyevent); + keyevent = new KeyEvent(now, now, KeyEvent.ACTION_UP, primaryCode, 0); + WhaleCloud.getInstance().sendKeyBoardStatus(keyevent); +*/ + } + /*else if (primaryCode == 57419) { // go left + if (start > 0) { + ed.setSelection(start - 1); + } + } else if (primaryCode == 57421) { // go right + if (start < ed.length()) { + ed.setSelection(start + 1); + } + } else { + editable.insert(start, Character.toString((char) primaryCode)); + }*/ + + + } + }; + + /** + * 键盘大小写切换 + */ + private void changeKey() { + List keylist = k1.getKeys(); + if (isupper) {//大写切换小写 + isupper = false; + for (Key key : keylist) { + if (key.label != null && isword(key.label.toString())) { + key.label = key.label.toString().toLowerCase(); + //key.codes[0] = key.codes[0] + 32; + } + } + } else {//小写切换大写 + isupper = true; + for (Key key : keylist) { + if (key.label != null && isword(key.label.toString())) { + key.label = key.label.toString().toUpperCase(); + //key.codes[0] = key.codes[0] - 32; + } + } + } + } + + public void showKeyboard() { + int visibility = keyboardView.getVisibility(); + if (visibility == View.GONE || visibility == View.INVISIBLE) { + keyboardView.setVisibility(View.VISIBLE); + } + isShow = true; + } + + public void hideKeyboard() { + int visibility = keyboardView.getVisibility(); + if (visibility == View.VISIBLE) { + keyboardView.setVisibility(View.INVISIBLE); + } + isShow = false; + } + + private boolean isword(String str) { + String wordstr = "abcdefghijklmnopqrstuvwxyz"; + if (wordstr.indexOf(str.toLowerCase()) > -1) { + return true; + } + return false; + } + + private boolean isword2(int str) { + if (str >= 65 && str <= 90) { + return true; + } + return false; + } + +} \ No newline at end of file diff --git a/android/app/src/main/java/co/steamcloud/cargame/MainActivity.java b/android/app/src/main/java/co/steamcloud/cargame/MainActivity.java new file mode 100644 index 0000000..227c9f7 --- /dev/null +++ b/android/app/src/main/java/co/steamcloud/cargame/MainActivity.java @@ -0,0 +1,332 @@ +package co.steamcloud.cargame; + +import android.annotation.SuppressLint; +import android.content.Intent; +import android.os.Bundle; +import android.os.Handler; +import android.os.Message; +import android.text.TextUtils; +import android.util.Log; + +import androidx.annotation.NonNull; +import androidx.annotation.Nullable; + +import com.alipay.sdk.app.PayTask; +import com.tencent.mm.opensdk.modelpay.PayReq; +import com.tencent.mm.opensdk.openapi.IWXAPI; +import com.tencent.mm.opensdk.openapi.WXAPIFactory; +import com.zjrx.jyengine.WhaleCloud; + +import org.json.JSONException; +import org.json.JSONObject; +import org.simple.eventbus.EventBus; +import org.simple.eventbus.Subscriber; + +import java.util.HashMap; +import java.util.Map; + +import co.steamcloud.cargame.pay.PayResult; +import co.steamcloud.cargame.utils.AppUtil; +import io.flutter.embedding.android.FlutterActivity; +import io.flutter.embedding.engine.FlutterEngine; +import io.flutter.plugin.common.MethodCall; +import io.flutter.plugin.common.MethodChannel; +import io.flutter.plugin.common.StandardMethodCodec; + +public class MainActivity extends FlutterActivity { + private static final String TAG = "MainActivity"; + private static final String CHANNEL = "samples.flutter.dev/battery"; + + private MethodChannel nativeChannel; + + private final int SDK_PAY_FLAG = 1; + + @Override + public void onCreate(@Nullable Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + EventBus.getDefault().register(this); + WhaleCloud.getInstance().isShowLog(true); + } + +// @Override +// public boolean dispatchGenericMotionEvent(MotionEvent ev) { +// return super.dispatchGenericMotionEvent(ev); +// +// } + +// @Override +// public boolean dispatchKeyEvent(KeyEvent event) { +// //Log.d(TAG, "dispatchKeyEvent1: event==" + event); +// if (event.getAction() == KeyEvent.ACTION_DOWN) { +// // 处理按键按下事件 +// int keyCode = event.getKeyCode(); +// // 根据keyCode进行相应处理 +// Log.d(TAG, "dispatchKeyEvent: keyCode==" + keyCode); +// } +// return super.dispatchKeyEvent(event); +// } + + + @Override + protected void onDestroy() { + EventBus.getDefault().unregister(this); + super.onDestroy(); + } + + @SuppressLint("NotifyDataSetChanged") + @Subscriber(tag = EventBusParams.MAIN) + public void Ev(HashMap TagMap) { + final String tag = TagMap.get("tag"); + if (!TextUtils.isEmpty(tag)) { + switch (tag) { + case "exitGame": + Map exitGameMap = new HashMap<>(); + exitGameMap.put("exitGame", "exitGame"); + nativeChannel.invokeMethod("exitGame", exitGameMap); + break; + case "wxPaySuccess": + Map map = new HashMap<>(); + map.put("wxPaySuccess", "wxPaySuccess"); + nativeChannel.invokeMethod("wxPaySuccess", map); + break; + + case "payError": + Map mapError = new HashMap<>(); + mapError.put("payError", "payError"); + nativeChannel.invokeMethod("payError", mapError); + break; + } + } + + } + + @Override + public void configureFlutterEngine(@NonNull FlutterEngine flutterEngine) { + super.configureFlutterEngine(flutterEngine); + nativeChannel = new MethodChannel(flutterEngine.getDartExecutor().getBinaryMessenger(), CHANNEL, StandardMethodCodec.INSTANCE); + + nativeChannel.setMethodCallHandler(new MethodChannel.MethodCallHandler() { + @Override + public void onMethodCall(@NonNull MethodCall call, @NonNull MethodChannel.Result result) { + switch (call.method) { + case "initData": + Log.d(TAG, "onMethodCall: initData"); + String gameToken = call.argument("gameToken"); + Config.BsUrl = call.argument("BsUrl"); + Config.client_sid = call.argument("channelId"); + Config.sign_key = call.argument("signKey"); + Config.userToken = call.argument("userToken"); + Config.Channel = call.argument("Channel"); + Config.Version = call.argument("Version"); + Config.url = call.argument("Url"); + + initSdk(Config.BsUrl, Config.client_sid, gameToken, Config.sn); + Log.d(TAG, "onMethodCall: initData"); + Log.d(TAG, "onMethodCall: gameToken==" + gameToken); + Log.d(TAG, "onMethodCall: Config.client_sid==" + Config.client_sid); + Log.d(TAG, "onMethodCall: Config.BsUrl==" + Config.BsUrl); + break; + + case "playGame": + Log.d("TAG", "onMethodCall: 66666666666"); + Config.gameId = call.argument("gameId"); + String playGameData = call.argument("playGameData"); + String isReconPlay = call.argument("isReconPlay"); + + Log.d("TAG", "onMethodCall: gameId==" + Config.gameId); + Log.d("TAG", "onMethodCall: playGameData==" + playGameData); + Log.d("TAG", "onMethodCall: isReconPlay==" + isReconPlay); +// Config.gamePara.game_key = gameId; +// Config.gamePara.record_game_time = 5; +// Config.gamePara.start_resolution = "720p"; + +// initToken(); + startGame(playGameData, isReconPlay); + break; + + + case "getInfo": + Map map = new HashMap<>(); + Config.sn = AppUtil.getDeviceId(App.getInstance()); + Config.Language = AppUtil.getSystemLanguage(); + map.put("deviceID", Config.sn); + map.put("Language", Config.Language); + result.success(map); + + Log.d(TAG, "onMethodCall: getInfo"); + break; + + case "WxPay"://微信支付 + String orderInfoWx = call.argument("orderInfoWx"); + Log.d("TAG", "onMethodCall: orderInfoWx===" + orderInfoWx); + + WxPay(orderInfoWx); + + + break; + + case "Alipay"://支付宝支付 + + Log.d("TAG", "onMethodCall: Alipay"); + + String orderInfoZfb = call.argument("orderInfoZfb"); + Alipay(orderInfoZfb); + + break; + + case "test1": + Log.d("TAG1", "onMethodCall: 66666666666"); + break; + } + } + }); + } + + + /** + * 支付宝 支付结果回调 + */ + @SuppressLint("HandlerLeak") + private Handler mHandler = new Handler() { + @SuppressWarnings("unused") + public void handleMessage(Message msg) { + switch (msg.what) { + case SDK_PAY_FLAG: + //需要注意的是,支付结果一定要调用自己的服务端来确定,不能通过支付宝的回调结果来判断 + @SuppressWarnings("unchecked") + PayResult payResult = new PayResult((Map) msg.obj); + /** + * 对于支付结果,请商户依赖服务端的异步通知结果。同步通知结果,仅作为支付结束的通知。 + */ + String resultInfo = payResult.getResult();// 同步返回需要验证的信息 + String resultStatus = payResult.getResultStatus(); + // 判断resultStatus 为9000则代表支付成功 + if (TextUtils.equals(resultStatus, "9000")) { + // 该笔订单是否真实支付成功,需要依赖服务端的异步通知。 + Log.d("TAG", "handleMessage9000: payResult==" + payResult); + Map map = new HashMap<>(); + map.put("AlipaySuccess", "AlipaySuccess"); + nativeChannel.invokeMethod("AlipaySuccess", map); + } else { + // 该笔订单真实的支付结果,需要依赖服务端的异步通知。 + Log.d("TAG", "handleMessage: payResult==" + payResult); + + Map map = new HashMap<>(); + map.put("payError", "payError"); + nativeChannel.invokeMethod("payError", map); + } + break; + default: + break; + } + } + }; + + + /** + * 初始化游戏SDK + * + * @param bsUrl bsUrl + * @param channelId channelId + * @param token token + * @param sn 设备号 + */ + void initSdk(final String bsUrl, final String channelId, final String token, final String sn) { + WhaleCloud.getInstance().sdkLoading(getApplication(), channelId, bsUrl, token, sn, new WhaleCloud.OnSdkListener() { + @Override + public void onSdkFail(final int errCode, final String msg) { + runOnUiThread(new Runnable() { + @Override + public void run() { + Log.w(TAG, "鲸云 SDK 初始化失败|" + errCode + "|" + msg); + Map map = new HashMap<>(); + map.put("SDKSuccess", false); + nativeChannel.invokeMethod("SDKSuccess", map); + } + }); + } + + @Override + public void onSdkSucc() { + runOnUiThread(new Runnable() { + @Override + public void run() { + Log.w(TAG, "鲸云 SDK 初始化成功"); + Map map = new HashMap<>(); + map.put("SDKSuccess", true); + nativeChannel.invokeMethod("SDKSuccess", map); + } + }); + } + }); + } + + public void startGame(String gameData, String isReconPlay) { + String GameType = ""; + getIntent().putExtra("GameType", ""); + Config.is_Playing = true; + Intent intent = new Intent(this, PlayGameActivity.class); + intent.putExtra("GameData", gameData); + intent.putExtra("isReconPlay", isReconPlay); + startActivity(intent); + } + + + /** + * 微信支付 + * + * @param orderInfo 订单参数 + */ + private void WxPay(String orderInfo) { + try { + JSONObject jsonObject = new JSONObject(orderInfo); + String appid = jsonObject.getString("appid"); + String partnerId = jsonObject.getString("partnerid"); + String prepayId = jsonObject.getString("prepayid"); + String packageValue = jsonObject.getString("package"); + String nonceStr = jsonObject.getString("noncestr"); + String timeStamp = jsonObject.getString("timestamp"); + String sign = jsonObject.getString("sign"); + + IWXAPI api = WXAPIFactory.createWXAPI(MainActivity.this, appid); + + PayReq request = new PayReq(); + request.appId = appid; + request.partnerId = partnerId; + request.prepayId = prepayId; + request.packageValue = packageValue; + request.nonceStr = nonceStr; + request.timeStamp = timeStamp; + request.sign = sign; + api.sendReq(request); + + Log.d("TAG", "onMethodCall: appid===" + appid); + } catch (JSONException e) { + throw new RuntimeException(e); + } + } + + /** + * 支付宝支付 + * + * @param orderInfo 订单参数 + */ + private void Alipay(String orderInfo) { + final Runnable payRunnable = () -> { + PayTask alipay = new PayTask(MainActivity.this); + Map result = alipay.payV2(orderInfo, true); + Log.i("msp", result.toString()); + + Message msg = new Message(); + msg.what = SDK_PAY_FLAG; + msg.obj = result; + mHandler.sendMessage(msg); + }; + + // 必须异步调用 + Thread payThread = new Thread(payRunnable); + payThread.start(); + } + + +} diff --git a/android/app/src/main/java/co/steamcloud/cargame/MoveButton.java b/android/app/src/main/java/co/steamcloud/cargame/MoveButton.java new file mode 100644 index 0000000..1ba3826 --- /dev/null +++ b/android/app/src/main/java/co/steamcloud/cargame/MoveButton.java @@ -0,0 +1,97 @@ +package co.steamcloud.cargame; + +import android.content.Context; +import android.util.AttributeSet; +import android.view.MotionEvent; +import android.widget.RelativeLayout; + +public class MoveButton extends RelativeLayout { + + + private OnClickCallBackListener mListener; + private float mOriginalX; + private float mOriginalY; + private float mOriginalRawX; + private float mOriginalRawY; + public float touchInitX; + public float touchInitY; + boolean isMove = false; + public float moveX; + public float moveY; + + public MoveButton(Context context) { + super(context); + } + + public MoveButton(Context context, AttributeSet attrs) { + super(context, attrs); + } + + public MoveButton(Context context, AttributeSet attrs, int defStyleAttr) { + super(context, attrs, defStyleAttr); + } + + @Override + public boolean onTouchEvent(MotionEvent event) { + if (Config.s_keyboard) { + switch (event.getAction()) { + case MotionEvent.ACTION_DOWN: + moveX = 0; + moveY = 0; + mOriginalX = getX(); + mOriginalY = getY(); + mOriginalRawX = event.getRawX(); + mOriginalRawY = event.getRawY(); + + touchInitX = event.getX(); + touchInitY = event.getY(); + isMove = false; + + if (mListener != null) { + mListener.onActionDown(event); + } + break; + case MotionEvent.ACTION_MOVE: + if (Math.abs(event.getX() - touchInitX) > 10 || Math.abs(event.getY() - touchInitY) > 10) { + isMove = true; + moveX = mOriginalX + event.getRawX() - mOriginalRawX; + setX(moveX); + moveY = mOriginalY + event.getRawY() - mOriginalRawY; + setY(mOriginalY + event.getRawY() - mOriginalRawY); + if (mListener != null){ + mListener.onActionMove(moveX, moveY); + } + } + + break; + case MotionEvent.ACTION_UP: + if (!isMove) { + + } + break; + } + return true; + } + return false; + } + + public void setOnClickCallBackListener(OnClickCallBackListener listener) { + this.mListener = listener; + } + + + public interface OnClickCallBackListener { + void onActionDown(MotionEvent event); + + //void onActionUp(); + + void onActionMove(float moveX, float moveY); + } + + public void setPosition(float x, float y) { + this.setX(x); + this.setY(y); + } + + +} diff --git a/android/app/src/main/java/co/steamcloud/cargame/MyButton.java b/android/app/src/main/java/co/steamcloud/cargame/MyButton.java new file mode 100644 index 0000000..d13fbb9 --- /dev/null +++ b/android/app/src/main/java/co/steamcloud/cargame/MyButton.java @@ -0,0 +1,115 @@ +package co.steamcloud.cargame; + +import android.content.Context; +import android.util.AttributeSet; +import android.view.MotionEvent; +import android.view.View; + +import androidx.annotation.NonNull; +import androidx.annotation.Nullable; + +public class MyButton extends androidx.appcompat.widget.AppCompatTextView { + + + public MyButton(@NonNull Context context) { + super(context); + + } + + public MyButton(@NonNull Context context, @Nullable AttributeSet attrs) { + super(context, attrs); + } + + public MyButton(@NonNull Context context, @Nullable AttributeSet attrs, int defStyleAttr) { + super(context, attrs, defStyleAttr); + } + private OnClickCallBackListener mListener; + private ViewChangMsgListener viewChangMsgListener; + + private String KeyIndex; + private String KeyName; + private String X; + private String Y; + private int W; + private int H; + private String SelectedImage; + private String KeyImage; + private float Scale; + + private float mOriginalX; + private float mOriginalY; + private float mOriginalRawX; + private float mOriginalRawY; + public float touchInitX; + public float touchInitY; + boolean isMove = false; + @Override + public boolean onTouchEvent(MotionEvent event) { + + switch (event.getAction()) { + case MotionEvent.ACTION_DOWN: + mOriginalX = getX(); + mOriginalY = getY(); + mOriginalRawX = event.getRawX(); + mOriginalRawY = event.getRawY(); + + touchInitX = event.getX(); + touchInitY = event.getY(); + isMove = false; + + break; + case MotionEvent.ACTION_MOVE: + if (Math.abs(event.getX() - touchInitX) > 10 || Math.abs(event.getY() - touchInitY) > 10) { + isMove = true; + setX(mOriginalX + event.getRawX() - mOriginalRawX); + setY(mOriginalY + event.getRawY() - mOriginalRawY); + } + + break; + case MotionEvent.ACTION_UP: + if (!isMove) { + if (mListener!=null){ + mListener.onActionDown(); + } + } + + break; + } + + + return true; + } + public void setOnClickCallBackListener(OnClickCallBackListener listener){ + this.mListener=listener; + } + + public void keyBoardDelectListener(ViewChangMsgListener viewChangMsgListener){ + this.viewChangMsgListener =viewChangMsgListener; + } + + + public interface OnClickCallBackListener{ + void onActionDown(); + void onActionMove(float x,float y); + } + + public void setPosition(float x,float y) { + this.setX(x); + this.setY(y); + } + + public interface ViewChangMsgListener{ + void changTexture(String path); + void showDeletPopup(MyButton view); + void showDeletPopup(String index); + void showFloatPopup(); + } + public interface virtualHandleChangeListener{ + void layerBtnSetVisible(int tag); + } + public interface virtualKeyboardChangeListener + { + void removeChild(View child); + void hideDirection(); + } +} diff --git a/android/app/src/main/java/co/steamcloud/cargame/PeterTimeCountRefresh.java b/android/app/src/main/java/co/steamcloud/cargame/PeterTimeCountRefresh.java new file mode 100644 index 0000000..045ff3f --- /dev/null +++ b/android/app/src/main/java/co/steamcloud/cargame/PeterTimeCountRefresh.java @@ -0,0 +1,62 @@ +package co.steamcloud.cargame; + +import android.os.CountDownTimer; + +public class PeterTimeCountRefresh extends CountDownTimer { + private OnTimerFinishListener finishListener; + private OnTimerProgressListener progressListener; + + /** + * @param millisInFuture 分钟转换成 毫秒 + * @param countDownInterval 计时的时间间隔 + */ + public PeterTimeCountRefresh(long millisInFuture, long countDownInterval) { + super(millisInFuture, countDownInterval);//参数依次为总时长,和计时的时间间隔,要显示的按钮 + } + + + @Override + public void onTick(long millisUntilFinished) {//计时过程显示 + if (progressListener != null) { + progressListener.onTimerProgress(millisUntilFinished); + } + } + + @Override + public void onFinish() {//计时完毕时触发 + if (finishListener != null) { + finishListener.onTimerFinish(); + } + } + + /** + * 设置timer走完的回调 + */ + public void setOnTimerFinishListener(OnTimerFinishListener finishListener) { + this.finishListener = finishListener; + } + + /** + * 设置监听进度的 + */ + public void setOnTimerProgressListener(OnTimerProgressListener progressListener) { + this.progressListener = progressListener; + } + + /** + * Timer 执行完成的回调 + */ + public interface OnTimerFinishListener { + + void onTimerFinish(); + } + + /** + * Timer 进度的监听 + */ + public interface OnTimerProgressListener { + + void onTimerProgress(long timeLong); + } + +} diff --git a/android/app/src/main/java/co/steamcloud/cargame/PlayGameActivity.java b/android/app/src/main/java/co/steamcloud/cargame/PlayGameActivity.java new file mode 100644 index 0000000..cdfda5f --- /dev/null +++ b/android/app/src/main/java/co/steamcloud/cargame/PlayGameActivity.java @@ -0,0 +1,3935 @@ +package co.steamcloud.cargame; + + +import static co.steamcloud.cargame.Config.s_keyboard; + +import android.animation.ValueAnimator; +import android.annotation.SuppressLint; +import android.app.Activity; +import android.content.Context; +import android.content.Intent; +import android.content.res.Configuration; +import android.content.res.Resources; +import android.graphics.Bitmap; +import android.graphics.BitmapFactory; +import android.graphics.Color; +import android.graphics.drawable.BitmapDrawable; +import android.os.Build; +import android.os.Bundle; +import android.os.Handler; +import android.os.SystemClock; +import android.text.TextUtils; +import android.util.DisplayMetrics; +import android.util.Log; +import android.view.Gravity; +import android.view.HapticFeedbackConstants; +import android.view.KeyEvent; +import android.view.LayoutInflater; +import android.view.MotionEvent; +import android.view.SurfaceView; +import android.view.View; +import android.view.ViewConfiguration; +import android.view.Window; +import android.view.WindowManager; +import android.widget.Button; +import android.widget.FrameLayout; +import android.widget.ImageView; +import android.widget.ProgressBar; +import android.widget.RelativeLayout; +import android.widget.SeekBar; +import android.widget.TextView; +import android.widget.Toast; + +import androidx.annotation.NonNull; +import androidx.annotation.Nullable; +import androidx.constraintlayout.widget.ConstraintLayout; +import androidx.constraintlayout.widget.Group; + +import com.airbnb.lottie.LottieAnimationView; +import com.bumptech.glide.load.resource.drawable.GlideDrawable; +import com.bumptech.glide.request.animation.GlideAnimation; +import com.bumptech.glide.request.target.SimpleTarget; +import com.zjrx.common.util.LogUtil; +import com.zjrx.jyengine.JyCode; +import com.zjrx.jyengine.JyFeedBackEvent; +import com.zjrx.jyengine.JyGameStatusListener; +import com.zjrx.jyengine.JySurfaceView; +import com.zjrx.jyengine.WhaleCloud; +import com.zjrx.jyengine.bs.OnApiRequestListener; +import com.zjrx.jyengine.eventbus.MouseEvent; +import com.zjrx.jyengine.input.handle.GameHandle; +import com.zjrx.jyengine.input.tController; + +import org.json.JSONArray; +import org.json.JSONObject; +import org.simple.eventbus.EventBus; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.Objects; +import java.util.Timer; +import java.util.TimerTask; + +import co.steamcloud.cargame.HttpUtils.OpenApiRequest; +import co.steamcloud.cargame.entity.VirtualKeyListBean; +import co.steamcloud.cargame.glide.GlideImageLoader; +import co.steamcloud.cargame.time.SubscribeTimeManage; +import co.steamcloud.cargame.utils.AppConfigFileImpl; +import co.steamcloud.cargame.utils.AppUtil; + +public class PlayGameActivity extends Activity { + public static final String TAG = "PlayGameActivity"; + private ConstraintLayout content; + private JySurfaceView mVideoView; + private SurfaceView mVideoViewLegacy; + private GameFrameLayOut gameLayout; + private FrameLayout NetworkKeyboard, NetworkCursor, MNKeyboard; + private ImageView close_set, img_qr; + private MyButton menu_set, Move_show_hide; + private ConstraintLayout menu, seting, custom_button; + private Group seting_g1, seting_g2, seting_g3; + private TextView set_control, set_frame, set_GamePad, wifi, custom_button_default, custom_button_yg, custom_button_close; + private MyButton mImageCursor; + /*进度条*/ + private ConstraintLayout loadingCL; + private ImageView loading; + private LottieAnimationView animationView; + private ProgressBar progressbar1; + private TextView fadenum; + private TextView qosTextView; + private RelativeLayout qosLayout; + private CountDownTimerUtil countDownTimerUtil; + private ValueAnimator valueAnimator; + /*进度条*/ + private TextView speed1, speed2, speed3, speed4, speed5, handle1, handle2, handle3, handle4, proportion1, proportion2, tvDpi, tvDpi2; + private SeekBar skDpi, skDpi2; + private double multiple = 1.0; + private double multiple2 = 0.8f; + + public boolean bGameStart = false; + //接收视频流宽和高 + int mFrameWidth = 1920; + int mFrameHeight = 1080; + //手机屏幕宽和高 + private int SCREEN_WIDTH = 1920; + private int SCREEN_HEIGHT = 1080; + private int ZOOM_WIDTH = 1920;//等比缩放 + private int ZOOM_HEIGHT = 1080;//等比缩放 + private int ZOOM_W = 1920;//缩放 + private int ZOOM_H = 1080;//缩放 + + int orientation_now = Configuration.ORIENTATION_LANDSCAPE; + int orientation_last = Configuration.ORIENTATION_PORTRAIT; + JySurfaceView.ScaleType mScalingType = JySurfaceView.ScaleType.ASPECT_FULL_SCREEN;//ASPECT_FIT, ASPECT_FILL, ASPECT_BALANCED,ASPECT_FULL_SCREEN + private View handleView; + private ConstraintLayout HandleCL; + private FrameLayout VisualAngle; + private Button select; + private String gameData = "";//启动游戏数据 + private String isReconPlay = "false";//是否是重连游戏 + public boolean btn_right_close = false;//右边摇杆是否关闭 + public int virtual_mode = 1;//1表示虚拟手柄,2表示自定义虚拟手柄,3表示虚拟键盘,4表示自定义虚拟键盘 + public int shubiao_mode = 1;//鼠标模式 1=点击模式 2=滑屏点击 + //操控输入 + tController player1 = new tController((byte) 0); //手柄 + MouseEvent mouseEvent = new MouseEvent(); //鼠标 + Timer keyEventTimer = null; + TimerTask keyEventTimerTask = null; + private boolean IsGameInput = true;//虚拟手柄 + private boolean IsKeyBoard = true;//虚拟键盘 + private boolean IsGameMouse; + public int Ismode = 1;//1手柄 2键盘 + private boolean showKeyboard = false; + + private boolean textInput = false; + + int mDstx = 0; + int mDsty = 0; + + private float mouseEventX, mouseEventY, moveX, moveY; + private float lastMouseX, lastMouseY; + private float downX = 0, downY = 0, downX2 = 0, downY2 = 0; + private float lastMoveX = 0, lastMoveY = 0; + private float lastMoveX2 = 0, lastMoveY2 = 0; + + + private float downJoystickX = 0, downJoystickY = 0, moveJoystickX, moveJoystickY; + + + // NetHander netHander = new NetHander(); + int popupPraise; + + private int nounTime = 0; + + private int sY, sX; + private ConstraintLayout conDiamond; + private TextView tvCountDown; + private Button btRecharge; + // private ImageView imgShowHide; + private PeterTimeCountRefresh refresh; + + private Boolean isShow = false; + private String orderId; + private String QuickPaymentId; + private String payMoney; + private String payChannel; + private String rechargeId; + private String ProductId; + // private GameBuyDialog dialog; + private boolean isShock = false;//震动 + private boolean isInsufficientDialog = false; + + TextView button_a, button_b, button_x, button_y, lt, lb, rt, rb, ls, rs, start, back; + ImageView dpad_up, dpad_down, dpad_left, dpad_right, dpad_up_left, dpad_up_right, dpad_down_left, + dpad_down_right; + private boolean consumed; + private ImageView imgKeySet, imgSwitchKey, imgSwitchRightRocker, imgSwitchKeyboard, imgSwitchShock; + private KeyboardUtil keyboardUtil; + private TextView tvVipType, tvDiamanteNum, tvExitGame, tvReturnApp; + private ConstraintLayout conBuy; + private ImageView imgVipType; + private OpenApiRequest openApiRequest; + private Bitmap qrCodeBitmap; + // private JoinMembershipDialog joinMembershipDialog; + + /** + * 启动计时 + */ + private void startTime() { + SubscribeTimeManage.getInstance().register(onTimeListener); + } + + /** + * 取消计时 + */ + private void stopTime() { + SubscribeTimeManage.getInstance().unregister(onTimeListener); + } + + /** + * 一秒走一次 + */ + SubscribeTimeManage.OnTimeListener onTimeListener = new SubscribeTimeManage.OnTimeListener() { + @Override + public void oneSecond() { + nounTime++; + } + }; + private String pingNum = ""; + private String ipString = ""; + private boolean m_isPing = false; + + + @Override + protected void onCreate(@Nullable Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + requestWindowFeature(Window.FEATURE_NO_TITLE);//去掉标题栏 + Window w = getWindow(); + if (w != null) { + w.addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);//保持常亮 + w.setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);//全屏:隐藏状态栏 + w.addFlags(WindowManager.LayoutParams.FLAG_LAYOUT_NO_LIMITS);//将window扩展至全屏,并且不会覆盖状态栏。 + w.addFlags(WindowManager.LayoutParams.FLAG_LAYOUT_IN_SCREEN);//避免在状态栏的显示状态发生变化时重新布局,从而避免界面卡顿。 + } + + openApiRequest = new OpenApiRequest(); + //获取游戏设置 + openApiRequest.gameSetting(new OnApiRequestListener() { + @Override + public void onResponse(String data, int code, String msg) { + Log.d(TAG, "onResponse: data==" + data); + Log.d(TAG, "onResponse: code==" + code); + Log.d(TAG, "onResponse: msg==" + msg); + + + try { + JSONObject jsonObject = new JSONObject(data); + String jsonData = jsonObject.getString("data"); + if (jsonData.equals("null")) { + Log.d(TAG, "onResponse: 游戏设置数据异常"); + return; + } + Log.d(TAG, "onResponse: jsonData==" + jsonData); + JSONObject heartData = new JSONObject(jsonData); + + String handleQrCode = heartData.getString("handleQrCode");//H5手柄扫码二维码 + + Resources res = getResources(); + Bitmap logoBitmap = BitmapFactory.decodeResource(res, R.mipmap.ic_launcher); + + qrCodeBitmap = AppUtil.createQRCodeBitmap(handleQrCode, 200, 200, "UTF-8", "H", "1", R.color.black, Color.WHITE, logoBitmap, 0.2f); + + Log.d(TAG, "onResponse: data=" + jsonObject); + } catch (Exception e) { + throw new RuntimeException(e); + } + } + + @Override + public void onFailure(Exception e) { + Log.d(TAG, "onResponse: e==" + e); + } + }); + + //隐藏系统按钮 + hideBottomUIMenu(); + setContentView(R.layout.activity_game); +// EventBus.getDefault().register(this); + + //游戏数据 + gameData = getIntent().getStringExtra("GameData"); + //是否重连游戏 + isReconPlay = getIntent().getStringExtra("isReconPlay"); + Log.i(TAG, "onCreate: gameData==" + gameData); + if (gameData == null || gameData.isEmpty()) { + finish(); + return; + } + ActivityCollector.addActivity(PlayGameActivity.this); + + //初始化view + initUI(); + + bGameStart = true; + + //按键震动 + isShock = AppConfigFileImpl.getBooleanParams(getApplicationContext(), "isShock"); + if (imgSwitchShock != null) { + if (isShock) { + imgSwitchShock.setImageResource(R.mipmap.switch_open); + } else { + imgSwitchShock.setImageResource(R.mipmap.switch_close); + } + } + + startGame(); //启动游戏 + updateLayoutSize(); + startTime();//启动记时 + } + + @Override + protected void onResume() { + super.onResume(); + if (keyEventTimerTask != null && keyEventTimer != null) { + startKeyEventSchedule(); + } + } + + + @Override + protected void onPause() { + super.onPause(); + if (keyEventTimer != null) { + keyEventTimer.cancel(); + } + if (keyEventTimerTask != null) { + keyEventTimerTask.cancel(); + } + } + + @Override + protected void onDestroy() { + if (keyEventTimer != null) { + keyEventTimer.cancel(); + keyEventTimer = null; + } + if (keyEventTimerTask != null) { + keyEventTimerTask.cancel(); + keyEventTimerTask = null; + } + if (sameTimer != null) { + sameTimer.cancel(); + sameTimer = null; + } + if (sameTimerTask != null) { + sameTimerTask.cancel(); + sameTimerTask = null; + } + if (valueAnimator != null) { + valueAnimator.cancel(); + } + if (mVideoView != null) { + mVideoView.release(); + mVideoView = null; + } + if (refresh != null) { + refresh.cancel(); + } + stopTime(); + super.onDestroy(); + } + + @Override + public void onConfigurationChanged(Configuration newConfig) { + super.onConfigurationChanged(newConfig); + LogUtil.i("onLayoutChange SCREEN_WIDTH: " + SCREEN_WIDTH + " SCREEN_HEIGHT:" + SCREEN_HEIGHT); + if (newConfig.orientation == Configuration.ORIENTATION_PORTRAIT) { + orientation_now = Configuration.ORIENTATION_PORTRAIT; + } else { + orientation_now = Configuration.ORIENTATION_LANDSCAPE; + } + updateLayoutSize(); + } + + @Override + public boolean onKeyDown(int keyCode, KeyEvent event) { + onKeyEvent(keyCode, true); + LogUtil.d("key quit"); + + if (bGameStart) { + //键盘ESC 会发送ESC键值和back键值。该判断确保BACK(esc)能发送到游戏服务器 + if (keyCode == KeyEvent.KEYCODE_BACK) { + //WhaleCloud.getInstance().stopGame("返回键退出"); + showDialog("退出游戏", "确定退出游戏吗?", "退出游戏", "取消", new IDialogTwoView() { + @Override + public void cancel() { + hideBottomUIMenu(); + } + + @Override + public void onSure() { + closeGame(); + } + + @Override + public void returnApp() { +// returnAppMain(); + } + }); + return true; + } else { + consumed = WhaleCloud.getInstance().handleKeyEvent(keyCode, event, true); + Log.d(TAG, "onKeyDown: keyCode==" + keyCode); + } + } else { + finish(); + } + return consumed; + } + + //返回app + private void returnAppMain() { + Intent intent1 = new Intent(PlayGameActivity.this, MainActivity.class); + intent1.addFlags(Intent.FLAG_ACTIVITY_REORDER_TO_FRONT); + PlayGameActivity.this.startActivity(intent1); +// EventBus.getDefault().post("returnApp", EventBusParams.GAME); + } + + private void showUItoast(final String toastMsg) { + try { + runOnUiThread(() -> Toast.makeText(App.getInstance(), toastMsg, Toast.LENGTH_SHORT).show()); + } catch (Exception e) { + e.printStackTrace(); + } + } + + @Override + public boolean onKeyUp(int keyCode, KeyEvent event) { + boolean consumed = WhaleCloud.getInstance().handleKeyEvent(keyCode, event, false); + if (consumed) { + return true; + } + if (keyCode == KeyEvent.KEYCODE_BACK) { + return true; + } + return false; + } + + @Override + public boolean dispatchGenericMotionEvent(MotionEvent event) { + boolean consumed; + Log.d(TAG, "dispatchGenericMotionEvent: event==" + event); + LogUtil.d("...dispatchGenericMotionEvent:" + event); + consumed = WhaleCloud.getInstance().dispatchGenericMotionEvent(event); + return consumed; + } + + @Override + public boolean dispatchTouchEvent(MotionEvent event) { + boolean consumed; + if (event.getToolType(0) != MotionEvent.TOOL_TYPE_FINGER) { + consumed = WhaleCloud.getInstance().dispatchGenericMotionEvent(event); + if (consumed) { + return true; + } + } + + return super.dispatchTouchEvent(event); + } + + + public void startKeyEventSchedule() { + if (keyEventTimer != null) { + keyEventTimer.cancel(); + keyEventTimer = null; + } + if (keyEventTimerTask != null) { + keyEventTimerTask.cancel(); + keyEventTimerTask = null; + } + keyEventTimer = new Timer(); + keyEventTimerTask = new TimerTask() { + @Override + public void run() { + Config.keyEvent_time++; + if (Config.is_Playing == false) { + if (keyEventTimer != null) { + keyEventTimer.cancel(); + keyEventTimer = null; + } + if (keyEventTimerTask != null) { + keyEventTimerTask.cancel(); + keyEventTimerTask = null; + } + } + if (Config.keyEvent_time == Config.time_out_prealarm) { + Log.d(TAG, "run: 由于您长时间无操作,将60秒后退出游戏。"); + showUItoast("由于您长时间无操作,将60秒后退出游戏。"); + } else if (Config.keyEvent_time >= Config.time_out_max_second) { + if (keyEventTimer != null) { + keyEventTimer.cancel(); + keyEventTimer = null; + } + if (keyEventTimerTask != null) { + keyEventTimerTask.cancel(); + keyEventTimerTask = null; + } + closeGame(); + } + } + }; + keyEventTimer.schedule(keyEventTimerTask, 0, 1000); + } + + public void onKeyEvent(int keyCode, boolean isKeyDown) { + if (isKeyDown) { + Config.keyEvent_time = 0; + + } else { + //Config.myMultKeyTrigger.removeKey(keyCode, System.currentTimeMillis()); + } + } + + private void initUI() { +// dialog = new GameBuyDialog(PlayGameActivity.this, Config.gamePara.my_GameId); +// joinMembershipDialog = new JoinMembershipDialog(PlayGameActivity.this); + qosLayout = findViewById(R.id.qosLayout); +// if (NetHander.isDebug) { +// qosLayout.setVisibility(View.VISIBLE); +// } + qosTextView = findViewById(R.id.qosTextView); + content = findViewById(R.id.content); + gameLayout = findViewById(R.id.video_renderer_layout); + NetworkKeyboard = findViewById(R.id.NetworkKeyboard); + MNKeyboard = findViewById(R.id.MNKeyboard); + NetworkCursor = findViewById(R.id.NetworkCursor); + menu_set = findViewById(R.id.menu_set); + Move_show_hide = findViewById(R.id.Move_show_hide); + wifi = findViewById(R.id.wifi); + seting = findViewById(R.id.seting); + close_set = findViewById(R.id.close_set); + custom_button_close = findViewById(R.id.custom_button_close); + custom_button_yg = findViewById(R.id.custom_button_yg); + custom_button_default = findViewById(R.id.custom_button_default); + custom_button = findViewById(R.id.custom_button); + menu = findViewById(R.id.menu); + + loadingCL = findViewById(R.id.loadingCL); + loading = findViewById(R.id.loading); + animationView = findViewById(R.id.animation_view); + progressbar1 = findViewById(R.id.progressbar1); + fadenum = findViewById(R.id.fadenum); + + speed1 = findViewById(R.id.speed1); + speed2 = findViewById(R.id.speed2); + speed3 = findViewById(R.id.speed3); + speed4 = findViewById(R.id.speed4); + speed5 = findViewById(R.id.speed5); + handle1 = findViewById(R.id.handle1); + handle2 = findViewById(R.id.handle2); + proportion1 = findViewById(R.id.proportion1); + proportion2 = findViewById(R.id.proportion2); + handle3 = findViewById(R.id.handle3); + handle4 = findViewById(R.id.handle4); + skDpi = findViewById(R.id.sk_dpi); + tvDpi = findViewById(R.id.tv_dpi); + skDpi2 = findViewById(R.id.sk_dpi2); + tvDpi2 = findViewById(R.id.tv_dpi2); + + conDiamond = findViewById(R.id.con_diamonds); + tvCountDown = findViewById(R.id.tv_count_down); + btRecharge = findViewById(R.id.bt_recharge); + + imgKeySet = findViewById(R.id.img_key_set); + imgSwitchKey = findViewById(R.id.img_switch_key); + imgSwitchRightRocker = findViewById(R.id.img_switch_right_rocker); + imgSwitchKeyboard = findViewById(R.id.img_switch_keyboard); + imgSwitchShock = findViewById(R.id.img_switch_shock); + tvExitGame = findViewById(R.id.tv_exit_game); + tvReturnApp = findViewById(R.id.tv_return_app); + tvReturnApp.setOnClickListener(view -> { + if (menu != null) { + menu.setVisibility(View.GONE); + } + returnAppMain(); + }); + + //退出游戏按钮 + tvExitGame.setOnClickListener(view -> { + if (menu != null) { + menu.setVisibility(View.GONE); + } + showDialog("退出游戏", "确定退出游戏吗?", "退出游戏", "取消", new IDialogTwoView() { + @Override + public void cancel() { + hideBottomUIMenu(); + } + + @Override + public void onSure() { + closeGame(); + } + + @Override + public void returnApp() { +// returnAppMain(); + } + }); + }); + + imgSwitchShock.setOnClickListener(view -> { + isShock = !isShock; + if (isShock) { + imgSwitchShock.setImageResource(R.mipmap.switch_open); + AppConfigFileImpl.saveParams(getApplicationContext(), "isShock", true); + } else { + imgSwitchShock.setImageResource(R.mipmap.switch_close); + AppConfigFileImpl.saveParams(getApplicationContext(), "isShock", false); + } + }); + + imgSwitchKeyboard.setOnClickListener(view -> { + if (menu != null) { + menu.setVisibility(View.GONE); + } + textInput = !textInput; + showKeyboard = true; + keyboardUtil = new KeyboardUtil(PlayGameActivity.this, PlayGameActivity.this); + if (textInput) { + imgSwitchKeyboard.setImageResource(R.mipmap.switch_open); + keyboardUtil.showKeyboard(); + } else { + imgSwitchKeyboard.setImageResource(R.mipmap.switch_close); + keyboardUtil.hideKeyboard(); + } + }); + + imgSwitchRightRocker.setOnClickListener(view -> { + if (btn_right_close) { + btn_right_close = false; + custom_button_yg.setText("右摇杆:开"); + imgSwitchRightRocker.setImageResource(R.mipmap.switch_close); + yaogan_right.setVisibility(View.VISIBLE); + } else { + btn_right_close = true; + custom_button_yg.setText("右摇杆:关"); + imgSwitchRightRocker.setImageResource(R.mipmap.switch_open); + yaogan_right.setVisibility(View.GONE); + } + }); + + imgSwitchKey.setOnClickListener(view -> { + if (menu != null) { + menu.setVisibility(View.GONE); + } + //显示隐藏键盘 + if (Config.is_immersion) { + if (Move_show_hide != null) { + Move_show_hide.setBackgroundResource(R.mipmap.ic_key_hide); + } + imgSwitchKey.setImageResource(R.mipmap.switch_open); + if (Ismode == 1) { + if (HandleCL != null) { + HandleCL.setVisibility(View.VISIBLE); + } + } else if (Ismode == 2) { + NetworkKeyboard.setVisibility(View.VISIBLE); + } + } else { + if (Ismode == 1) { + if (HandleCL != null && select != null) { + HandleCL.setVisibility(View.GONE); + } + } else if (Ismode == 2) { + NetworkKeyboard.setVisibility(View.GONE); + } + if (Move_show_hide != null) { + Move_show_hide.setBackgroundResource(R.mipmap.ic_key_show); + } + imgSwitchKey.setImageResource(R.mipmap.switch_close); + } + Config.is_immersion = !Config.is_immersion; + }); + + imgKeySet.setOnClickListener(view -> { + seting.setVisibility(View.GONE); + wifi.setVisibility(View.GONE); + menu_set.setVisibility(View.GONE); + custom_button.setVisibility(View.VISIBLE); + s_keyboard = true; + CustomButton(s_keyboard); + }); + + //判断屏幕大小 + DisplayMetrics dm = new DisplayMetrics(); + getWindowManager().getDefaultDisplay().getMetrics(dm);//display = getWindowManager().getDefaultDisplay();display.getMetrics(dm)(把屏幕尺寸信息赋值给DisplayMetrics dm); + if (dm.widthPixels > dm.heightPixels) { + SCREEN_WIDTH = dm.widthPixels/*- getNavigationHeight(PlayGameActivity.this)*/; + SCREEN_HEIGHT = dm.heightPixels; + } else { + SCREEN_WIDTH = dm.heightPixels/*- getNavigationHeight(PlayGameActivity.this)*/; + SCREEN_HEIGHT = dm.widthPixels; + } + Globe.landscapeScaleWidht = ((float) SCREEN_WIDTH / Globe.landscapeSW); + Globe.landscapeScaleHeight = ((float) SCREEN_HEIGHT / Globe.landscapeSH); + + /*content.post(new Runnable() { + @Override + public void run() { + + ConstraintLayout.LayoutParams lp = (ConstraintLayout.LayoutParams) gameLayout.getLayoutParams(); + lp.width = SCREEN_WIDTH; + lp.height = SCREEN_HEIGHT; + gameLayout.setLayoutParams(lp); + } + });*/ + + //鼠标灵敏度 + skDpi.setOnSeekBarChangeListener(new SeekBar.OnSeekBarChangeListener() { + @SuppressLint("SetTextI18n") + @Override + public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) { + tvDpi.setText(progress + ""); + multiple = progress * 0.1 + 0.7; + Log.d(TAG, "onProgressChanged: multiple==" + multiple); + } + + @Override + public void onStartTrackingTouch(SeekBar seekBar) { + + } + + @Override + public void onStopTrackingTouch(SeekBar seekBar) { + + } + }); + + //滑屏灵敏度 + skDpi2.setOnSeekBarChangeListener(new SeekBar.OnSeekBarChangeListener() { + @SuppressLint("SetTextI18n") + @Override + public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) { + tvDpi2.setText(progress + ""); + switch (progress) { + case 1: + multiple2 = 0.55f; + break; + case 2: + multiple2 = 0.6f; + break; + case 3: + multiple2 = 0.65f; + break; + case 4: + multiple2 = 0.7f; + break; + case 5: + multiple2 = 0.75f; + break; + case 6: + multiple2 = 0.8f; + break; + case 7: + multiple2 = 0.85f; + break; + case 8: + multiple2 = 0.9f; + break; + case 9: + multiple2 = 0.95f; + break; + case 10: + multiple2 = 1; + break; + } + } + + @Override + public void onStartTrackingTouch(SeekBar seekBar) { + + } + + @Override + public void onStopTrackingTouch(SeekBar seekBar) { + + } + }); + + + proportion1.setOnClickListener(v -> { + proportion1.setBackgroundResource(R.drawable.shape_blue_bg); + proportion2.setBackgroundResource(R.drawable.bg_border_performance); + + gameLayout.post(new Runnable() { + @Override + public void run() { + //0.5625 1080/1920 + //横屏导致 + if (WhaleCloud.getInstance().isLegcyView()) { + //乐谱图片控件调整大小 + FrameLayout.LayoutParams lp = (FrameLayout.LayoutParams) mVideoViewLegacy.getLayoutParams(); + lp.width = ZOOM_WIDTH; + lp.height = ZOOM_HEIGHT; + mVideoViewLegacy.setLayoutParams(lp); + } else { + FrameLayout.LayoutParams lp = (FrameLayout.LayoutParams) mVideoView.getLayoutParams(); + lp.width = ZOOM_WIDTH; + lp.height = ZOOM_HEIGHT; + mVideoView.setLayoutParams(lp); + } + FrameLayout.LayoutParams clp = (FrameLayout.LayoutParams) NetworkCursor.getLayoutParams(); + clp.width = ZOOM_WIDTH; + clp.height = ZOOM_HEIGHT; + NetworkCursor.setLayoutParams(clp); + ZOOM_W = ZOOM_WIDTH; + ZOOM_H = ZOOM_HEIGHT; + } + }); + }); + proportion2.setOnClickListener(v -> { + proportion2.setBackgroundResource(R.drawable.shape_blue_bg); + proportion1.setBackgroundResource(R.drawable.bg_border_performance); + gameLayout.post(() -> { + ZOOM_W = 0; + //0.5625 1080/1920 + //横屏导致 + if (WhaleCloud.getInstance().isLegcyView()) { + //乐谱图片控件调整大小 + FrameLayout.LayoutParams lp = (FrameLayout.LayoutParams) mVideoViewLegacy.getLayoutParams(); + lp.width = SCREEN_WIDTH; + lp.height = SCREEN_HEIGHT; + mVideoViewLegacy.setLayoutParams(lp); + } else { + FrameLayout.LayoutParams lp = (FrameLayout.LayoutParams) mVideoView.getLayoutParams(); + lp.width = SCREEN_WIDTH; + lp.height = SCREEN_HEIGHT; + mVideoView.setLayoutParams(lp); + } + + FrameLayout.LayoutParams clp = (FrameLayout.LayoutParams) NetworkCursor.getLayoutParams(); + clp.width = SCREEN_WIDTH; + clp.height = SCREEN_HEIGHT; + NetworkCursor.setLayoutParams(clp); + ZOOM_W = SCREEN_WIDTH; + ZOOM_H = SCREEN_HEIGHT; + + }); + }); + +// speed1.setOnClickListener(v -> { +// setPictureQuality(6, speed1); +// }); +// speed2.setOnClickListener(v -> { +// setPictureQuality(7, speed2); +// }); +// speed3.setOnClickListener(v -> { +// setPictureQuality(8, speed3); +// }); +// speed4.setOnClickListener(v -> { +// setPictureQuality(9, speed4); +// }); +// speed5.setOnClickListener(v -> { +// setPictureQuality(10, speed5); +// }); + handle1.setOnClickListener(v -> { +// if (IsGameInput) { + handle1.setEnabled(false); + handle1.setBackgroundResource(R.drawable.shape_blue_bg1); + imgKeySet.setBackgroundResource(R.drawable.shape_blue_bg2); + imgKeySet.setEnabled(true); + if (MNKeyboard != null) { + MNKeyboard.setVisibility(View.VISIBLE); + } + if (IsKeyBoard) { + NetworkKeyboard.setVisibility(View.GONE); + Ismode = 1; + handle2.setEnabled(true); + handle2.setBackgroundResource(R.drawable.bg_border_performance); + custom_button_yg.setVisibility(View.VISIBLE); + } + +// } + }); + handle2.setOnClickListener(v -> { +// if (IsKeyBoard) { + handle2.setEnabled(false); + handle2.setBackgroundResource(R.drawable.shape_blue_bg); + NetworkKeyboard.setVisibility(View.VISIBLE); + if (IsGameInput) { + handle1.setBackgroundResource(R.drawable.bg_border_performance3); + imgKeySet.setBackgroundResource(R.drawable.bg_border_performance4); + handle1.setEnabled(true); + imgKeySet.setEnabled(false); + Ismode = 2; + if (MNKeyboard != null) { + MNKeyboard.setVisibility(View.GONE); + } + custom_button_yg.setVisibility(View.GONE); + } + +// } + }); + handle3.setOnClickListener(v -> { + if (shubiao_mode == 2) { + shubiao_mode = 1; + handle3.setEnabled(false); + handle3.setBackgroundResource(R.drawable.shape_blue_bg); + handle4.setEnabled(true); + handle4.setBackgroundResource(R.drawable.bg_border_performance); + } + }); + handle4.setOnClickListener(v -> { + if (shubiao_mode == 1) { + shubiao_mode = 2; + handle4.setEnabled(false); + handle4.setBackgroundResource(R.drawable.shape_blue_bg); + handle3.setEnabled(true); + handle3.setBackgroundResource(R.drawable.bg_border_performance); + } + }); + + menu_set.setOnClickCallBackListener(new MyButton.OnClickCallBackListener() { + @Override + public void onActionDown() { + seting.setVisibility(View.VISIBLE); + if (keyboardUtil != null) { + textInput = keyboardUtil.isShow; + if (textInput) { + imgSwitchKeyboard.setImageResource(R.mipmap.switch_open); + } else { + imgSwitchKeyboard.setImageResource(R.mipmap.switch_close); + } + } + selectSet(0); + + } + + @Override + public void onActionMove(float x, float y) { + + } + }); + + Move_show_hide.setOnClickCallBackListener(new MyButton.OnClickCallBackListener() { + @Override + public void onActionDown() { + Config.keyEvent_time = 0; + //显示隐藏键盘 + if (Config.is_immersion) { + if (HandleCL != null) { + HandleCL.setVisibility(View.VISIBLE); + } + Move_show_hide.setBackgroundResource(R.mipmap.ic_key_hide); + imgSwitchKey.setImageResource(R.mipmap.switch_open); + } else { + if (HandleCL != null) { + HandleCL.setVisibility(View.GONE); + } + Move_show_hide.setBackgroundResource(R.mipmap.ic_key_show); + imgSwitchKey.setImageResource(R.mipmap.switch_close); + } + Config.is_immersion = !Config.is_immersion; + } + + @Override + public void onActionMove(float x, float y) { + + } + }); + + seting.setOnClickListener(v -> { + }); + close_set.setOnClickListener(v -> { + hideBottomUIMenu(); + seting.setVisibility(View.GONE); + }); + menu.setOnClickListener(v -> { + }); + + if (WhaleCloud.getInstance().isLegcyView()) { + mVideoViewLegacy = findViewById(R.id.video_render_legacy); + mVideoViewLegacy.bringToFront(); + } else { + mVideoView = findViewById(R.id.video_render); + mVideoView.jySetScaleType(JySurfaceView.ScaleType.ASPECT_FULL_SCREEN); + } + gameLayout.post(new Runnable() { + @Override + public void run() { + //0.5625 1080/1920 + //横屏导致 + ZOOM_WIDTH = SCREEN_WIDTH;//1440 + ZOOM_HEIGHT = SCREEN_HEIGHT; + int ww = (int) (ZOOM_HEIGHT * 1.0 / 0.5625); + if (ZOOM_WIDTH > ww) { + ZOOM_WIDTH = ww; + } else { + proportion1.setEnabled(false); + proportion2.setEnabled(false); + proportion2.setBackgroundResource(R.drawable.bg_border_performance2); + } + + if (WhaleCloud.getInstance().isLegcyView()) { + if (mVideoViewLegacy == null) { + mVideoViewLegacy = findViewById(R.id.video_render_legacy); + mVideoViewLegacy.bringToFront(); + if (mVideoView != null) { + mVideoView.setVisibility(View.GONE); + } + } + //乐谱图片控件调整大小 + FrameLayout.LayoutParams lp = (FrameLayout.LayoutParams) mVideoViewLegacy.getLayoutParams(); + lp.width = ZOOM_WIDTH; + lp.height = ZOOM_HEIGHT; + mVideoViewLegacy.bringToFront(); + mVideoViewLegacy.setLayoutParams(lp); + mVideoViewLegacy.addOnLayoutChangeListener(OnVideoViewLayoutChange); + WhaleCloud.getInstance().initVideoViewLegacy(mVideoViewLegacy); + } else { + if (mVideoView == null) { + mVideoView = findViewById(R.id.video_render); + mVideoView.jySetScaleType(JySurfaceView.ScaleType.ASPECT_FULL_SCREEN); + if (mVideoViewLegacy != null) { + mVideoViewLegacy.setVisibility(View.GONE); + } + } + FrameLayout.LayoutParams lp = (FrameLayout.LayoutParams) mVideoView.getLayoutParams(); + lp.width = ZOOM_WIDTH; + lp.height = ZOOM_HEIGHT; + mVideoView.jySetScaleType(mScalingType); + mVideoView.setLayoutParams(lp); + mVideoView.addOnLayoutChangeListener(OnVideoViewLayoutChange); + WhaleCloud.getInstance().initVideoView(mVideoView); + + } + } + }); + NetworkKeyboard.post(() -> { + FrameLayout.LayoutParams clp = (FrameLayout.LayoutParams) NetworkCursor.getLayoutParams(); + clp.width = ZOOM_WIDTH; + clp.height = ZOOM_HEIGHT; + NetworkCursor.setLayoutParams(clp); + NetworkCursor.setOnTouchListener(touchListener);//按钮按中时滑屏 + //NetworkKeyboard.setOnTouchListener(touchListener);//非按钮按中时滑屏 + }); + + mImageCursor = findViewById(R.id.imageCursor); + initHandle(); + initSetView(); + + } + + + //设置画质 +// private void setPictureQuality(int type, TextView textView) { +// if (setCodeRate(type)) { +// speed1.setBackgroundResource(R.drawable.bg_border_performance); +// speed2.setBackgroundResource(R.drawable.bg_border_performance); +// speed3.setBackgroundResource(R.drawable.bg_border_performance); +// speed4.setBackgroundResource(R.drawable.bg_border_performance); +// speed5.setBackgroundResource(R.drawable.bg_border_performance); +// +// textView.setBackgroundResource(R.drawable.shape_blue_bg); +// } +// +// } + + private void initSetView() { + seting_g1 = findViewById(R.id.seting_g1); + seting_g2 = findViewById(R.id.seting_g2); + seting_g3 = findViewById(R.id.seting_g3); + set_control = findViewById(R.id.set_control); + set_frame = findViewById(R.id.set_frame); + set_GamePad = findViewById(R.id.set_GamePad); + custom_button = findViewById(R.id.custom_button); + img_qr = findViewById(R.id.img_qr); + + img_qr.setImageBitmap(qrCodeBitmap); + + set_control.setOnClickListener(v -> { + selectSet(0); + }); + set_frame.setOnClickListener(v -> { + selectSet(1); + }); + set_GamePad.setOnClickListener(v -> { + selectSet(2); + }); + custom_button_close.setOnClickListener(v -> { + custom_button.setVisibility(View.GONE); + menu_set.setVisibility(View.VISIBLE); + seting.setVisibility(View.VISIBLE); + s_keyboard = false; + CustomButton(s_keyboard); + }); + custom_button_default.setOnClickListener(v -> { + initDefault(); + initButtonPosition(); + }); + + custom_button_yg.setOnClickListener(v -> { + if (custom_button_yg.getText().equals("右摇杆:开")) { + custom_button_yg.setText("右摇杆:关"); + imgSwitchRightRocker.setImageResource(R.mipmap.switch_open); + yaogan_right.setVisibility(View.GONE); + btn_right_close = true; + } else { + custom_button_yg.setText("右摇杆:开"); + imgSwitchRightRocker.setImageResource(R.mipmap.switch_close); + yaogan_right.setVisibility(View.VISIBLE); + btn_right_close = false; + } + }); + + } + + //0控制 1画面 + private void selectSet(int type) { + + switch (type) { + case 0: + if (seting_g1 != null) { + seting_g1.setVisibility(View.GONE); + } + if (seting_g2 != null) { + seting_g2.setVisibility(View.VISIBLE); + } + if (seting_g3 != null) { + seting_g3.setVisibility(View.GONE); + } + if (set_control != null) { + set_control.setBackgroundResource(R.drawable.shape_set_item_bg); + } + if (set_frame != null) { + set_frame.setBackgroundResource(0); + } + if (set_GamePad != null) { + set_GamePad.setBackgroundResource(0); + } + break; + + case 1: + if (seting_g1 != null) { + seting_g1.setVisibility(View.VISIBLE); + } + if (seting_g2 != null) { + seting_g2.setVisibility(View.GONE); + } + if (seting_g3 != null) { + seting_g3.setVisibility(View.GONE); + } + if (set_control != null) { + set_control.setBackgroundResource(0); + } + if (set_frame != null) { + set_frame.setBackgroundResource(R.drawable.shape_set_item_bg); + } + if (set_GamePad != null) { + set_GamePad.setBackgroundResource(0); + } + break; + + case 2: + if (seting_g1 != null) { + seting_g1.setVisibility(View.GONE); + } + if (seting_g2 != null) { + seting_g2.setVisibility(View.GONE); + } + if (seting_g3 != null) { + seting_g3.setVisibility(View.VISIBLE); + } + if (set_control != null) { + set_control.setBackgroundResource(0); + } + if (set_frame != null) { + set_frame.setBackgroundResource(0); + } + if (set_GamePad != null) { + set_GamePad.setBackgroundResource(R.drawable.shape_set_item_bg); + } + break; + } + } + + + private View.OnLayoutChangeListener OnVideoViewLayoutChange = new View.OnLayoutChangeListener() { + @Override + public void onLayoutChange(View view, int i, int i1, int i2, int i3, int i4, int i5, int i6, int i7) { + LogUtil.i("onLayoutChange 游戏区域 videoView " + i + "," + i1 + "," + i2 + "," + i3); + setGameRect(); + //WhaleCloud.getInstance().setGameRect(i, i1, i2, i3); + //setGameRect(i, i1, i2, i3); + } + }; + + private void setGameRect() { + int[] outLocation = {0, 0}; + //gameLayout.getLocationInWindow(outLocation); + //LogUtil.i("onLayoutChange gameLayout 游戏区域 " + outLocation[0] + "," + outLocation[1] + "," + mVideoView.getLayoutParams().width + "," + mVideoView.getLayoutParams().height); + //LogUtil.i("onLayoutChange gameLayout 游戏区域: " + SCREEN_WIDTH + "," + SCREEN_HEIGHT); + if (WhaleCloud.getInstance().isLegcyView()) { + if (mVideoViewLegacy.getLayoutParams().width > 0 && mVideoViewLegacy.getLayoutParams().height > 0) { + WhaleCloud.getInstance().setGameRect(0, 0, mVideoViewLegacy.getLayoutParams().width, mVideoViewLegacy.getLayoutParams().height); + } else {// -1 = match_parent ,需要设置游戏区域 + WhaleCloud.getInstance().setGameRect(0, 0, SCREEN_WIDTH, SCREEN_HEIGHT); + } + } else { + if (mVideoView.getLayoutParams().width > 0 && mVideoView.getLayoutParams().height > 0) { + WhaleCloud.getInstance().setGameRect(0, 0, mVideoView.getLayoutParams().width, mVideoView.getLayoutParams().height); + } else {// -1 = match_parent ,需要设置游戏区域 + WhaleCloud.getInstance().setGameRect(0, 0, SCREEN_WIDTH, SCREEN_HEIGHT); + } + } + } + + Map CustomButtonMap = new HashMap<>(); + MoveButton yaogan_left, yaogan_right, direction_key, Move_a, Move_b, Move_x, Move_y, Move_rs, Move_rt, Move_rb, + Move_lt, Move_lb, Move_ls, Move_start, Move_back; + + public void initDefault() { + try { + CustomButtonMap.put("yaogan_left", 106 * Globe.landscapeScaleWidht + "@" + 653.5 * Globe.landscapeScaleHeight); + CustomButtonMap.put("direction_key", 565 * Globe.landscapeScaleWidht + "@" + 730.0 * Globe.landscapeScaleHeight); + CustomButtonMap.put("yaogan_right", 1248 * Globe.landscapeScaleWidht + "@" + 770 * Globe.landscapeScaleHeight); + CustomButtonMap.put("Move_a", 1645 * Globe.landscapeScaleWidht + "@" + 799 * Globe.landscapeScaleHeight); + CustomButtonMap.put("Move_b", 1774 * Globe.landscapeScaleWidht + "@" + 680 * Globe.landscapeScaleHeight); + CustomButtonMap.put("Move_x", 1521 * Globe.landscapeScaleWidht + "@" + 680 * Globe.landscapeScaleHeight); + CustomButtonMap.put("Move_y", 1645 * Globe.landscapeScaleWidht + "@" + 562 * Globe.landscapeScaleHeight); + CustomButtonMap.put("Move_rs", 1547 * Globe.landscapeScaleWidht + "@" + 300 * Globe.landscapeScaleHeight); + CustomButtonMap.put("Move_rt", 1698 * Globe.landscapeScaleWidht + "@" + 343 * Globe.landscapeScaleHeight); + CustomButtonMap.put("Move_rb", 1452 * Globe.landscapeScaleWidht + "@" + 453 * Globe.landscapeScaleHeight); + CustomButtonMap.put("Move_ls", 134 * Globe.landscapeScaleWidht + "@" + 303 * Globe.landscapeScaleHeight); + CustomButtonMap.put("Move_lt", 44 * Globe.landscapeScaleWidht + "@" + 480 * Globe.landscapeScaleHeight); + CustomButtonMap.put("Move_lb", 261 * Globe.landscapeScaleWidht + "@" + 404 * Globe.landscapeScaleHeight); + CustomButtonMap.put("Move_back", 1774 * Globe.landscapeScaleWidht + "@" + 30 * Globe.landscapeScaleHeight); + CustomButtonMap.put("Move_start", 1774 * Globe.landscapeScaleWidht + "@" + 149 * Globe.landscapeScaleHeight); + } catch (Exception e) { + e.printStackTrace(); + } + } + + //调用前必须先初始化按钮 + public void initButtonPosition() { + try { + if (CustomButtonMap.get("yaogan_left") != null && !TextUtils.isEmpty(CustomButtonMap.get("yaogan_left").toString())) { + String[] split = CustomButtonMap.get("yaogan_left").toString().split("@"); + yaogan_left.setPosition(Float.parseFloat(split[0]), Float.parseFloat(split[1])); + } + if (CustomButtonMap.get("direction_key") != null && !TextUtils.isEmpty(CustomButtonMap.get("direction_key").toString())) { + String[] split = CustomButtonMap.get("direction_key").toString().split("@"); + direction_key.setPosition(Float.parseFloat(split[0]), Float.parseFloat(split[1])); + } + if (CustomButtonMap.get("yaogan_right") != null && !TextUtils.isEmpty(CustomButtonMap.get("yaogan_right").toString())) { + String[] split = CustomButtonMap.get("yaogan_right").toString().split("@"); + yaogan_right.setPosition(Float.parseFloat(split[0]), Float.parseFloat(split[1])); + } + if (CustomButtonMap.get("Move_a") != null && !TextUtils.isEmpty(CustomButtonMap.get("Move_a").toString())) { + String[] split = CustomButtonMap.get("Move_a").toString().split("@"); + Move_a.setPosition(Float.parseFloat(split[0]), Float.parseFloat(split[1])); + } + if (CustomButtonMap.get("Move_b") != null && !TextUtils.isEmpty(CustomButtonMap.get("Move_b").toString())) { + String[] split = CustomButtonMap.get("Move_b").toString().split("@"); + Move_b.setPosition(Float.parseFloat(split[0]), Float.parseFloat(split[1])); + } + if (CustomButtonMap.get("Move_x") != null && !TextUtils.isEmpty(CustomButtonMap.get("Move_x").toString())) { + String[] split = CustomButtonMap.get("Move_x").toString().split("@"); + Move_x.setPosition(Float.parseFloat(split[0]), Float.parseFloat(split[1])); + } + if (CustomButtonMap.get("Move_y") != null && !TextUtils.isEmpty(CustomButtonMap.get("Move_y").toString())) { + String[] split = CustomButtonMap.get("Move_y").toString().split("@"); + Move_y.setPosition(Float.parseFloat(split[0]), Float.parseFloat(split[1])); + } + if (CustomButtonMap.get("Move_rs") != null && !TextUtils.isEmpty(CustomButtonMap.get("Move_rs").toString())) { + String[] split = CustomButtonMap.get("Move_rs").toString().split("@"); + Move_rs.setPosition(Float.parseFloat(split[0]), Float.parseFloat(split[1])); + } + if (CustomButtonMap.get("Move_rt") != null && !TextUtils.isEmpty(CustomButtonMap.get("Move_rt").toString())) { + String[] split = CustomButtonMap.get("Move_rt").toString().split("@"); + Move_rt.setPosition(Float.parseFloat(split[0]), Float.parseFloat(split[1])); + } + if (CustomButtonMap.get("Move_rb") != null && !TextUtils.isEmpty(CustomButtonMap.get("Move_rb").toString())) { + String[] split = CustomButtonMap.get("Move_rb").toString().split("@"); + Move_rb.setPosition(Float.parseFloat(split[0]), Float.parseFloat(split[1])); + } + if (CustomButtonMap.get("Move_lt") != null && !TextUtils.isEmpty(CustomButtonMap.get("Move_lt").toString())) { + String[] split = CustomButtonMap.get("Move_lt").toString().split("@"); + Move_lt.setPosition(Float.parseFloat(split[0]), Float.parseFloat(split[1])); + } + if (CustomButtonMap.get("Move_lb") != null && !TextUtils.isEmpty(CustomButtonMap.get("Move_lb").toString())) { + String[] split = CustomButtonMap.get("Move_lb").toString().split("@"); + Move_lb.setPosition(Float.parseFloat(split[0]), Float.parseFloat(split[1])); + } + if (CustomButtonMap.get("Move_ls") != null && !TextUtils.isEmpty(CustomButtonMap.get("Move_ls").toString())) { + String[] split = CustomButtonMap.get("Move_ls").toString().split("@"); + Move_ls.setPosition(Float.parseFloat(split[0]), Float.parseFloat(split[1])); + } + if (CustomButtonMap.get("Move_back") != null && !TextUtils.isEmpty(CustomButtonMap.get("Move_back").toString())) { + String[] split = CustomButtonMap.get("Move_back").toString().split("@"); + Move_back.setPosition(Float.parseFloat(split[0]), Float.parseFloat(split[1])); + } + if (CustomButtonMap.get("Move_start") != null && !TextUtils.isEmpty(CustomButtonMap.get("Move_start").toString())) { + String[] split = CustomButtonMap.get("Move_start").toString().split("@"); + Move_start.setPosition(Float.parseFloat(split[0]), Float.parseFloat(split[1])); + } + } catch (NumberFormatException e) { + e.printStackTrace(); + } + } + + + public void initHandle() { + + handleView = LayoutInflater.from(this).inflate(R.layout.layout_handle, null); + HandleCL = handleView.findViewById(R.id.HandleCL); + + VisualAngle = handleView.findViewById(R.id.visual_angle); + VisualAngle.setOnTouchListener(new joystickTouchListener());//按钮按中时滑屏 + + + String CustomButton = AppConfigFileImpl.getStringParams(getApplicationContext(), "CustomButton"); + if (!TextUtils.isEmpty(CustomButton)) { + Log.d(TAG, "CustomButton " + CustomButton); + CustomButtonMap = GsonJsonUtil.stringToMap(CustomButton); + } else { + initDefault();//默认配置 + } + yaogan_left = handleView.findViewById(R.id.yaogan_left); + yaogan_left.setOnClickCallBackListener(new MoveButton.OnClickCallBackListener() { + @Override + public void onActionDown(MotionEvent event) { + + } + + @Override + public void onActionMove(float moveX, float moveY) { + Log.d(TAG, "yaogan_left " + moveX + "@" + moveY); + CustomButtonMap.put("yaogan_left", moveX + "@" + moveY); + } + + }); + yaogan_right = handleView.findViewById(R.id.yaogan_right); + yaogan_right.setOnClickCallBackListener(new MoveButton.OnClickCallBackListener() { + @Override + public void onActionDown(MotionEvent event) { + + } + + @Override + public void onActionMove(float moveX, float moveY) { + Log.d(TAG, "yaogan_right " + moveX + "@" + moveY); + CustomButtonMap.put("yaogan_right", moveX + "@" + moveY); + } + + }); + + direction_key = handleView.findViewById(R.id.direction_key); + direction_key.setOnClickCallBackListener(new MoveButton.OnClickCallBackListener() { + @Override + public void onActionDown(MotionEvent event) { + + } + + @Override + public void onActionMove(float moveX, float moveY) { + Log.d(TAG, "direction_key " + moveX + "@" + moveY); + CustomButtonMap.put("direction_key", moveX + "@" + moveY); + } + + }); + + Move_a = handleView.findViewById(R.id.Move_a); + Move_a.setOnClickCallBackListener(new MoveButton.OnClickCallBackListener() { + @Override + public void onActionDown(MotionEvent event) { + + } + + @Override + public void onActionMove(float moveX, float moveY) { + Log.d(TAG, "Move_a " + moveX + "@" + moveY); + CustomButtonMap.put("Move_a", moveX + "@" + moveY); + } + + + }); + Move_b = handleView.findViewById(R.id.Move_b); + Move_b.setOnClickCallBackListener(new MoveButton.OnClickCallBackListener() { + @Override + public void onActionDown(MotionEvent event) { + + } + + @Override + public void onActionMove(float moveX, float moveY) { + Log.d(TAG, "Move_b " + moveX + "@" + moveY); + CustomButtonMap.put("Move_b", moveX + "@" + moveY); + } + + + }); + Move_x = handleView.findViewById(R.id.Move_x); + Move_x.setOnClickCallBackListener(new MoveButton.OnClickCallBackListener() { + @Override + public void onActionDown(MotionEvent event) { + + } + + @Override + public void onActionMove(float moveX, float moveY) { + Log.d(TAG, "Move_x " + moveX + "@" + moveY); + CustomButtonMap.put("Move_x", moveX + "@" + moveY); + } + + + }); + Move_y = handleView.findViewById(R.id.Move_y); + Move_y.setOnClickCallBackListener(new MoveButton.OnClickCallBackListener() { + @Override + public void onActionDown(MotionEvent event) { + + } + + @Override + public void onActionMove(float moveX, float moveY) { + Log.d(TAG, "Move_y " + moveX + "@" + moveY); + CustomButtonMap.put("Move_y", moveX + "@" + moveY); + } + + + }); + Move_rs = handleView.findViewById(R.id.Move_rs); + Move_rs.setOnClickCallBackListener(new MoveButton.OnClickCallBackListener() { + @Override + public void onActionDown(MotionEvent event) { + + } + + @Override + public void onActionMove(float moveX, float moveY) { + Log.d(TAG, "Move_rs " + moveX + "@" + moveY); + CustomButtonMap.put("Move_rs", moveX + "@" + moveY); + } + + + }); + Move_rt = handleView.findViewById(R.id.Move_rt); + Move_rt.setOnClickCallBackListener(new MoveButton.OnClickCallBackListener() { + @Override + public void onActionDown(MotionEvent event) { + } + + @Override + public void onActionMove(float moveX, float moveY) { + Log.d(TAG, "Move_rt " + moveX + "@" + moveY); + CustomButtonMap.put("Move_rt", moveX + "@" + moveY); + } + }); + Move_rb = handleView.findViewById(R.id.Move_rb); + Move_rb.setOnClickCallBackListener(new MoveButton.OnClickCallBackListener() { + @Override + public void onActionDown(MotionEvent event) { + } + + @Override + public void onActionMove(float moveX, float moveY) { + Log.d(TAG, "Move_rb " + moveX + "@" + moveY); + CustomButtonMap.put("Move_rb", moveX + "@" + moveY); + } + }); + Move_lt = handleView.findViewById(R.id.Move_lt); + Move_lt.setOnClickCallBackListener(new MoveButton.OnClickCallBackListener() { + @Override + public void onActionDown(MotionEvent event) { + } + + @Override + public void onActionMove(float moveX, float moveY) { + Log.d(TAG, "Move_lt " + moveX + "@" + moveY); + CustomButtonMap.put("Move_lt", moveX + "@" + moveY); + } + }); + Move_lb = handleView.findViewById(R.id.Move_lb); + Move_lb.setOnClickCallBackListener(new MoveButton.OnClickCallBackListener() { + @Override + public void onActionDown(MotionEvent event) { + } + + @Override + public void onActionMove(float moveX, float moveY) { + Log.d(TAG, "Move_lb " + moveX + "@" + moveY); + CustomButtonMap.put("Move_lb", moveX + "@" + moveY); + } + }); + + Move_ls = handleView.findViewById(R.id.Move_ls); + Move_ls.setOnClickCallBackListener(new MoveButton.OnClickCallBackListener() { + @Override + public void onActionDown(MotionEvent event) { + } + + @Override + public void onActionMove(float moveX, float moveY) { + Log.d(TAG, "Move_ls " + moveX + "@" + moveY); + CustomButtonMap.put("Move_ls", moveX + "@" + moveY); + } + }); + + Move_start = handleView.findViewById(R.id.Move_start); + Move_start.setOnClickCallBackListener(new MoveButton.OnClickCallBackListener() { + @Override + public void onActionDown(MotionEvent event) { + } + + @Override + public void onActionMove(float moveX, float moveY) { + Log.d(TAG, "Move_start " + moveX + "@" + moveY); + CustomButtonMap.put("Move_start", moveX + "@" + moveY); + } + }); + Move_back = handleView.findViewById(R.id.Move_back); + Move_back.setOnClickCallBackListener(new MoveButton.OnClickCallBackListener() { + @Override + public void onActionDown(MotionEvent event) { + } + + @Override + public void onActionMove(float moveX, float moveY) { + Log.d(TAG, "Move_back " + moveX + "@" + moveY); + CustomButtonMap.put("Move_back", moveX + "@" + moveY); + } + }); + + initButtonPosition(); + + button_a = handleView.findViewById(R.id.button_a); + button_a.setOnTouchListener(new CustomOnTouchListener(tController.BTN_A, false)); + button_b = handleView.findViewById(R.id.button_b); + button_b.setOnTouchListener(new CustomOnTouchListener(tController.BTN_B, false)); + button_x = handleView.findViewById(R.id.button_x); + button_x.setOnTouchListener(new CustomOnTouchListener(tController.BTN_X, false)); + button_y = handleView.findViewById(R.id.button_y); + button_y.setOnTouchListener(new CustomOnTouchListener(tController.BTN_Y, false)); + dpad_up = handleView.findViewById(R.id.dpad_up); + dpad_up.setOnTouchListener(new CustomOnTouchListener(tController.BTN_UP, false)); + dpad_down = handleView.findViewById(R.id.dpad_down); + dpad_down.setOnTouchListener(new CustomOnTouchListener(tController.BTN_DOWN, false)); + dpad_left = handleView.findViewById(R.id.dpad_left); + dpad_left.setOnTouchListener(new CustomOnTouchListener(tController.BTN_LEFT, false)); + dpad_right = handleView.findViewById(R.id.dpad_right); + dpad_right.setOnTouchListener(new CustomOnTouchListener(tController.BTN_RIGHT, false)); + dpad_up_left = handleView.findViewById(R.id.dpad_up_left); + dpad_up_left.setOnTouchListener(new CustomOnTouchListener(tController.BTN_UP_LEFT, true) { + @Override + public boolean onTouch(View v, MotionEvent event) { + dpad_up.onTouchEvent(event); + dpad_left.onTouchEvent(event); + return super.onTouch(v, event); + } + }); + dpad_up_right = handleView.findViewById(R.id.dpad_up_right); + dpad_up_right.setOnTouchListener(new CustomOnTouchListener(tController.BTN_UP_RIGHT, true) { + @Override + public boolean onTouch(View v, MotionEvent event) { + dpad_up.onTouchEvent(event); + dpad_right.onTouchEvent(event); + return super.onTouch(v, event); + } + }); + dpad_down_left = handleView.findViewById(R.id.dpad_down_left); + dpad_down_left.setOnTouchListener(new CustomOnTouchListener(tController.BTN_DOWN_LEFT, true) { + @Override + public boolean onTouch(View v, MotionEvent event) { + dpad_down.onTouchEvent(event); + dpad_left.onTouchEvent(event); + return super.onTouch(v, event); + } + }); + dpad_down_right = handleView.findViewById(R.id.dpad_down_right); + dpad_down_right.setOnTouchListener(new CustomOnTouchListener(tController.BTN_DOWN_RIGHT, true) { + @Override + public boolean onTouch(View v, MotionEvent event) { + dpad_down.onTouchEvent(event); + dpad_right.onTouchEvent(event); + return super.onTouch(v, event); + } + }); + JoystickView2 joystickLeft = (JoystickView2) handleView.findViewById(R.id.joystick_left); + joystickLeft.setOnJoystickListener(new JoystickView2.OnJoystickListener() { + @Override + public void onPosition(float x, float y) { + Config.keyEvent_time = 0; + Log.w(TAG, "stick x=" + x + " y=" + y); + player1.setXY(x, y, true); + WhaleCloud.getInstance().sendGamepadStatus(player1); + //System.out.println("player1 setXY x="+x+"y="+y); + } + + @Override + public void onVibrator() { + //joystickLeft.performHapticFeedback(HapticFeedbackConstants.LONG_PRESS, HapticFeedbackConstants.FLAG_IGNORE_GLOBAL_SETTING); + if (isShock) { + joystickLeft.performHapticFeedback(HapticFeedbackConstants.LONG_PRESS, HapticFeedbackConstants.FLAG_IGNORE_GLOBAL_SETTING); + } + } + }); + JoystickView2 joystickRight = (JoystickView2) handleView.findViewById(R.id.joystick_right); + joystickRight.setOnJoystickListener(new JoystickView2.OnJoystickListener() { + @Override + public void onPosition(float x, float y) { + Config.keyEvent_time = 0; + //Log.d(TAG, "onPosition: "); +// WhaleCloud.getInstance().virHandleJoystickRight(2000,x,y,false); + //Log.w(TAG,"stick " + x + "=" + y); + player1.setXY(x, y, false); + WhaleCloud.getInstance().sendGamepadStatus(player1); + } + + @Override + public void onVibrator() { + if (isShock) { + joystickRight.performHapticFeedback(HapticFeedbackConstants.LONG_PRESS, HapticFeedbackConstants.FLAG_IGNORE_GLOBAL_SETTING); + } + } + }); + + start = handleView.findViewById(R.id.start); + start.setOnTouchListener(new CustomOnTouchListener(tController.BTN_START, false)); + select = handleView.findViewById(R.id.select); + select.setOnClickListener(v -> { + Config.keyEvent_time = 0; + //显示隐藏键盘 + if (Config.is_immersion) { + if (HandleCL != null) { + HandleCL.setVisibility(View.VISIBLE); + } + if (select != null) { + select.setBackgroundResource(R.mipmap.conceal); + } +// if (menu_yincanganjian != null) { +// menu_yincanganjian.setImageResource(R.mipmap.btn_yincanganjian); +// } + + } else { + if (HandleCL != null) { + HandleCL.setVisibility(View.GONE); + } + if (select != null) { + select.setBackgroundResource(R.mipmap.display); + } +// if (menu_yincanganjian != null) { +// menu_yincanganjian.setImageResource(R.mipmap.btn_anjianxinashi); +// } + } + Config.is_immersion = !Config.is_immersion; + }); + back = handleView.findViewById(R.id.back); + back.setOnTouchListener(new CustomOnTouchListener(tController.BTN_BACK, false)); + lt = handleView.findViewById(R.id.lt); + lt.setOnTouchListener(new CustomOnTouchListener(tController.BTN_LT, false)); + lb = handleView.findViewById(R.id.lb); + lb.setOnTouchListener(new CustomOnTouchListener(tController.BTN_LB, false)); + rt = handleView.findViewById(R.id.rt); + rt.setOnTouchListener(new CustomOnTouchListener(tController.BTN_RT, false)); + rb = handleView.findViewById(R.id.rb); + rb.setOnTouchListener(new CustomOnTouchListener(tController.BTN_RB, false)); + ls = handleView.findViewById(R.id.ls); + ls.setOnTouchListener(new CustomOnTouchListener(tController.BTN_L3, false)); + rs = handleView.findViewById(R.id.rs); + rs.setOnTouchListener(new CustomOnTouchListener(tController.BTN_R3, false)); + + + button_a.setClickable(true); + button_b.setClickable(true); + button_x.setClickable(true); + button_y.setClickable(true); + start.setClickable(true); + back.setClickable(true); + dpad_up.setClickable(true); + dpad_left.setClickable(true); + dpad_right.setClickable(true); + dpad_down.setClickable(true); + rs.setClickable(true); + rt.setClickable(true); + rb.setClickable(true); + lt.setClickable(true); + lb.setClickable(true); + ls.setClickable(true); + + } + + + //编辑按钮 + public void CustomButton(boolean isCustom) { + if (isCustom) { + /*String CustomButton = AppConfigFileImpl.getStringParams(getApplicationContext(), "CustomButton"); + if(!TextUtils.isEmpty(CustomButton)){ + CustomButtonMap = GsonJsonUtil.stringToMap(CustomButton); + }*/ + button_a.setClickable(false); + button_b.setClickable(false); + button_x.setClickable(false); + button_y.setClickable(false); + start.setClickable(false); + back.setClickable(false); + dpad_up.setClickable(false); + dpad_left.setClickable(false); + dpad_right.setClickable(false); + dpad_down.setClickable(false); + rs.setClickable(false); + rt.setClickable(false); + rb.setClickable(false); + lt.setClickable(false); + lb.setClickable(false); + ls.setClickable(false); + button_a.setBackgroundResource(R.mipmap.play_ls); + button_b.setBackgroundResource(R.mipmap.play_ls); + button_x.setBackgroundResource(R.mipmap.play_ls); + button_y.setBackgroundResource(R.mipmap.play_ls); + start.setBackgroundResource(R.mipmap.start); + back.setBackgroundResource(R.mipmap.back); + dpad_up.setBackgroundResource(0); + dpad_left.setBackgroundResource(0); + dpad_right.setBackgroundResource(0); + dpad_down.setBackgroundResource(0); + rs.setBackgroundResource(R.mipmap.play_ls); + rt.setBackgroundResource(R.mipmap.play_ls); + rb.setBackgroundResource(R.mipmap.play_ls); + lt.setBackgroundResource(R.mipmap.play_ls); + lb.setBackgroundResource(R.mipmap.play_ls); + ls.setBackgroundResource(R.mipmap.play_ls); + } else { + String json = GsonJsonUtil.stringToJsonString(CustomButtonMap); + Log.d(TAG, "yaogan_left " + json); + AppConfigFileImpl.saveParams(getApplicationContext(), "CustomButton", json); + button_a.setBackgroundResource(R.drawable.handle_button_ls); + button_b.setBackgroundResource(R.drawable.handle_button_ls); + button_x.setBackgroundResource(R.drawable.handle_button_ls); + button_y.setBackgroundResource(R.drawable.handle_button_ls); + start.setBackgroundResource(R.drawable.button_play_start); + back.setBackgroundResource(R.drawable.button_back); + dpad_up.setBackgroundResource(R.drawable.button_up); + dpad_left.setBackgroundResource(R.drawable.button_left); + dpad_right.setBackgroundResource(R.drawable.button_right); + dpad_down.setBackgroundResource(R.drawable.button_down); + + rs.setBackgroundResource(R.drawable.handle_button_ls); + rt.setBackgroundResource(R.drawable.handle_button_ls); + rb.setBackgroundResource(R.drawable.handle_button_ls); + lt.setBackgroundResource(R.drawable.handle_button_ls); + lb.setBackgroundResource(R.drawable.handle_button_ls); + ls.setBackgroundResource(R.drawable.handle_button_ls); + + button_a.setClickable(true); + button_b.setClickable(true); + button_x.setClickable(true); + button_y.setClickable(true); + start.setClickable(true); + back.setClickable(true); + dpad_up.setClickable(true); + dpad_left.setClickable(true); + dpad_right.setClickable(true); + dpad_down.setClickable(true); + rs.setClickable(true); + rt.setClickable(true); + rb.setClickable(true); + lt.setClickable(true); + lb.setClickable(true); + ls.setClickable(true); + } + + } + + + private class CustomOnTouchListener implements View.OnTouchListener { + private boolean isConsume; + private short code; + + public CustomOnTouchListener(short keyCode, boolean isConsume) { + this.code = keyCode; + this.isConsume = isConsume; + } + + @Override + public boolean onTouch(View v, MotionEvent event) { + if (s_keyboard) { + return false; + } + if (event.getAction() == MotionEvent.ACTION_DOWN) { + if (code == tController.BTN_LT) { + player1.bLeftTrigger = (byte) 0xff; + } else if (code == tController.BTN_RT) { + player1.bRightTrigger = (byte) 0xff; + } else { + Log.w(TAG, "key down" + code); + player1.setButton(code, true); + } + WhaleCloud.getInstance().sendGamepadStatus(player1); + + if (isShock) { + v.performHapticFeedback(HapticFeedbackConstants.LONG_PRESS, HapticFeedbackConstants.FLAG_IGNORE_GLOBAL_SETTING); + } + } else if (event.getAction() == MotionEvent.ACTION_UP) { + if (code == tController.BTN_LT) { + player1.bLeftTrigger = (byte) 0x0; + } else if (code == tController.BTN_RT) { + player1.bRightTrigger = (byte) 0x0; + } else { + player1.setButton(code, false); + } + WhaleCloud.getInstance().sendGamepadStatus(player1); + } + return isConsume; + } + } + + float moveJoystickX1, moveJoystickY1; + + /** + * 视角滑动 + * 鲸云摇杆接口测得: + * 1摇杆是以自设圆心的x,y为1到-1的坐标轴圆 + * 2用x,y的坐标来描述视角移动的方向和速度 + * (0,-1)为速度最快的正上 (0,-0,5)为速度中等的正上 + * (0,1)为速度最快的正下 (0,0,5)为速度中等的正下 + * (-1,0)为速度最快的正左 (-0.5,0)为速度中等的正左 + * (1,0)为速度最快的正左 (0,5,0)为速度中等的正左 + *

+ * x <= -0.5 && x < 0 a y <= -0.5 && y < 0 w (左上) + * x >= 0.5 && x > 0 d y <= -0.5 && y < 0 w (右上) + * x <= -0.5 && x < 0 a y >= 0.5 && y > 0 s (左下) + * x >= 0.5 && x > 0 d y >= 0.5 && y > 0 s (右下) + *

+ * 算法1 + * 以0为圆点1为半径画圆,同时建立坐标系, + * 用圆点外的两个点连线,算出以圆点为起点的平行线,平行线与圆的交点为终点,圆点到终点的线为该方向上的所有点 + * 通过圆点到终点的线上的点来确定方向 + * 通过调整平行上的点来实现速度变换 + *

+ * 由两点得出直线,当直线不与x轴和y轴垂直时,套用用直线公式,如果垂直,那就是固定方向上的移动 + * a = y2-y1 b = x1-x2 c = x2*y1 - x1*y2 + * ax + by + c = 0 + *

+ * 由圆点(0,0)可以得出 c = 0 + *

+ * 圆的标准方程为(x-a)的平方+(y-b)的平方=r的平方 (a,b)为圆心,r为半径 + *

+ * 求圆上点的坐标需要已知的条件:圆心、半径、角度 + * 已知a(x1,y1) b(x2,y2),则k=(y1-y2)/(x1-x2) + *

+ * 算法2 + * 使用函数:1计算两个点的距离,2判断如果两个点的距离大于1的属于挪动视角,3对速度进行降频 + */ + + //视角滑动 + private class joystickTouchListener implements View.OnTouchListener { + + public joystickTouchListener() { + } + + @Override + public boolean onTouch(View v, MotionEvent event) { + Config.keyEvent_time = 0; + try { + switch (event.getAction()) { + case MotionEvent.ACTION_DOWN: + + downJoystickX = event.getX(0); + downJoystickY = event.getY(0); + + //player1.setXY(x, y, false); + //WhaleCloud.getInstance().sendGamepadStatus(player1); + break; + case MotionEvent.ACTION_UP: + if (sameTimer != null) { + sameTimer.cancel(); + sameTimer = null; + } + if (sameTimerTask != null) { + sameTimerTask.cancel(); + sameTimerTask = null; + } + player1.setXY(0, 0, false); + WhaleCloud.getInstance().sendGamepadStatus(player1); + break; + case MotionEvent.ACTION_MOVE: + + //计算两个点的距离 + float tr = (float) RoundCalculator.calTwoPointDistant(downJoystickX, downJoystickY, event.getX(0), event.getY(0)); + + Log.d(TAG, "downJoystick " + tr); + + //如果两个点的距离大于3 + if (tr > 1) { + float dotCenterOnShow[] = RoundCalculator.calPointLocationByAngle( + downJoystickX, downJoystickY, event.getX(0), event.getY(0), 1); + moveJoystickX = dotCenterOnShow[0]; + moveJoystickY = dotCenterOnShow[1]; + + float offsetX = moveJoystickX - downJoystickX; + float offsetY = moveJoystickY - downJoystickY; + + float x = offsetX / 1; + float y = offsetY / 1; + + if (x > 1.0F) { + x = 1.0F; + } + + if (x < -1.0F) { + x = -1.0F; + } + + if (y > 1.0F) { + y = 1.0F; + } + + if (y < -1.0F) { + y = -1.0F; + } + if ((x == 0 && y == -1) || (x == 0 && y == 1) || (x == 1 && y == 0) || (x == -1 && y == 0)) { + //操过正常值过滤处理 + } else { + Log.d(TAG, "downJoystick1 " + x + "=" + y); + player1.setXY((float) (x * multiple2), (float) (y * multiple2), false); + WhaleCloud.getInstance().sendGamepadStatus(player1); + } + + downJoystickX = event.getX(0); + downJoystickY = event.getY(0); + } else { + player1.setXY(0, 0, false); + WhaleCloud.getInstance().sendGamepadStatus(player1); + } + + + break; + } + return true; + } catch (Exception e) { + e.printStackTrace(); + } + return false; + } + } + + + public static int longPress = 0;//长按状态 0初始状态 1正常移动 2长按移动 + Timer sameTimer = null; + TimerTask sameTimerTask = null; + public boolean doubleSameTime = true; + private long lastClickTime = 0; + private int point_num = 0;//当前触摸的点数 + + + //鼠标滑动 + View.OnTouchListener touchListener = new View.OnTouchListener() { + + @Override + public boolean onTouch(View v, MotionEvent event) { + try { + + Log.w("onTouch", "2" + v); + + Config.keyEvent_time = 0; + + if (event.getToolType(0) == MotionEvent.TOOL_TYPE_FINGER) { + float x = 0; + float y = 0; + + if (shubiao_mode == 2) { + switch (event.getActionMasked()) { + case MotionEvent.ACTION_POINTER_DOWN: + point_num += 1; + + if (sameTimer != null) { + sameTimer.cancel(); + sameTimer = null; + } + if (sameTimerTask != null) { + sameTimerTask.cancel(); + sameTimerTask = null; + } + if (doubleSameTime) { + + if (sameTimer == null) { + sameTimer = new Timer(); + sameTimerTask = new TimerTask() { + @Override + public void run() { + if (sameTimer != null) { + sameTimer.cancel(); + sameTimer = null; + } + if (sameTimerTask != null) { + sameTimerTask.cancel(); + sameTimerTask = null; + } + doubleSameTime = false; + if (point_num == 2) { + mouseEvent.set_leftButton(false); + mouseEvent.set_RightButton(true); + mouseEvent.set_ScrollButton(false); + WhaleCloud.getInstance().sendMouseStatus(mouseEvent); + System.out.println("LQQQQQ event.getAction() = 2同时按下"); + } else if (point_num == 3) { + if (showKeyboard) { + showKeyboard = false; + runOnUiThread(() -> new KeyboardUtil(PlayGameActivity.this, PlayGameActivity.this).hideKeyboard()); + } else { + showKeyboard = true; + runOnUiThread(() -> new KeyboardUtil(PlayGameActivity.this, PlayGameActivity.this).showKeyboard()); + } + System.out.println("LQQQQQ event.getAction() = 3同时按下"); + } + + } + }; + sameTimer.schedule(sameTimerTask, 20, 100); + } + + } + + break; + case MotionEvent.ACTION_POINTER_UP: + point_num -= 1; + break; + + case MotionEvent.ACTION_DOWN: + point_num = 1; + if (!showKeyboard) { + downX = event.getX(0) * (float) multiple; + downY = event.getY(0) * (float) multiple; + moveX = 0; + moveY = 0; + longPress = 0; + lastClickTime = System.currentTimeMillis(); + doubleSameTime = true; + if (sameTimer == null) { + sameTimer = new Timer(); + if (sameTimerTask != null) { + sameTimerTask.cancel(); + sameTimerTask = null; + } + sameTimerTask = new TimerTask() { + @Override + public void run() { + if (sameTimer != null) { + sameTimer.cancel(); + sameTimer = null; + } + if (sameTimerTask != null) { + sameTimerTask.cancel(); + sameTimerTask = null; + } + doubleSameTime = false; + System.out.println("LQQQQQ event.getAction() = mouseEvent"); + WhaleCloud.getInstance().sendMouseStatus(mouseEvent); + } + }; + sameTimer.schedule(sameTimerTask, 20, 100); + } + } + + + break; + case MotionEvent.ACTION_UP: + point_num = 0; + if (showKeyboard) { + showKeyboard = false; + runOnUiThread(() -> new KeyboardUtil(PlayGameActivity.this, PlayGameActivity.this).hideKeyboard()); + } else { + if (sameTimer != null) { + sameTimer.cancel(); + sameTimer = null; + } + if (sameTimerTask != null) { + sameTimerTask.cancel(); + sameTimerTask = null; + } + + float UPX = event.getX(0); + float UPY = event.getY(0); + if ((moveX == 0 && moveY == 0) || Math.abs(UPX - downX) < 10 && Math.abs(UPY - downY) < 10) { + if (longPress == 0) { + mouseEvent.set_leftButton(true); + mouseEvent.set_RightButton(false); + mouseEvent.set_ScrollButton(false); + System.out.println("LQQQQQ event.getAction() = 手指移动位置按下鼠标左键"); + WhaleCloud.getInstance().sendMouseStatus(mouseEvent); + } + } + new Handler().postDelayed(() -> { + //鼠标抬起 + if (longPress != 1) { + mouseEvent.set_leftButton(false); + mouseEvent.set_RightButton(false); + mouseEvent.set_ScrollButton(false); + System.out.println("LQQQQQ event.getAction() = 手指移动位置离开鼠标左键"); + WhaleCloud.getInstance().sendMouseStatus(mouseEvent); + } + longPress = 0; + }, 10); + + lastMouseX = mouseEventX; + lastMouseY = mouseEventY; + + lastMoveX = 0; + lastMoveY = 0; + + mouseEvent.x_rel = 0; + mouseEvent.y_rel = 0; + } + + + break; + case MotionEvent.ACTION_MOVE: + // DisplayMetrics dm = getResources().getDisplayMetrics(); + + if (!showKeyboard) { + moveX = event.getX(0) * (float) multiple; + moveY = event.getY(0) * (float) multiple; + float offsetX = moveX - downX; + float offsetY = moveY - downY; + + if ((Math.abs(offsetX) > 10 || Math.abs(offsetY) > 10)) { + long time = System.currentTimeMillis(); + long timeD = time - lastClickTime; + if (longPress == 0 && timeD < 500) { + longPress = 1; + } else if (longPress == 0 && timeD >= 500) { + longPress = 2; + //鼠标轻点发送鼠标左键 + mouseEvent.set_leftButton(true); + mouseEvent.set_RightButton(false); + mouseEvent.set_ScrollButton(false); + System.out.println("LQQQQQ event.getAction() = 手指移动位置按下鼠标左键"); + WhaleCloud.getInstance().sendMouseStatus(mouseEvent); + } + } + + float mouseX = offsetX + lastMouseX; + float mouseY = offsetY + lastMouseY; + mouseEventX = mouseX <= 0 ? 0 : mouseX >= SCREEN_WIDTH ? SCREEN_WIDTH : mouseX; + mouseEventY = mouseY <= 0 ? 0 : mouseY >= SCREEN_HEIGHT ? SCREEN_HEIGHT : mouseY; + if (lastMoveX != 0) { + mouseEvent.x_rel = moveX - lastMoveX; + mouseEvent.y_rel = moveY - lastMoveY; + } else { + mouseEvent.x_rel = 0; + mouseEvent.y_rel = 0; + } + mouseEvent.x = mouseEventX; + mouseEvent.y = mouseEventY; + + lastMoveX = moveX; + lastMoveY = moveY; + updateCursorPosition(mouseEventX, mouseEventY); + WhaleCloud.getInstance().sendMouseStatus(mouseEvent); + } + break; + } + } else { + if (event.getActionMasked() == MotionEvent.ACTION_UP) { + point_num = 0; + if (sameTimer != null) { + sameTimer.cancel(); + sameTimer = null; + } + if (sameTimerTask != null) { + sameTimerTask.cancel(); + sameTimerTask = null; + } + float UPX = event.getX(0); + float UPY = event.getY(0); + if (Math.abs(UPX - downX2) < 10 && Math.abs(UPY - downY2) < 10) { + if (longPress == 0) { + mouseEvent.set_leftButton(true); + mouseEvent.set_RightButton(false); + mouseEvent.set_ScrollButton(false); + System.out.println("LQQQQQ event.getAction() = 手指移动位置按下鼠标左键"); + WhaleCloud.getInstance().sendMouseStatus(mouseEvent); + } + } + new Handler().postDelayed(() -> { + //鼠标抬起 + mouseEvent.set_leftButton(false); + mouseEvent.set_RightButton(false); + mouseEvent.set_ScrollButton(false); + System.out.println("LQQQQQ event.getAction() = 手指移动位置离开鼠标左键"); + WhaleCloud.getInstance().sendMouseStatus(mouseEvent); + }, 10); + + lastMouseX = mouseEventX; + lastMouseY = mouseEventY; + + lastMoveX = 0; + lastMoveY = 0; + + mouseEvent.x_rel = 0; + mouseEvent.y_rel = 0; + } else if (event.getActionMasked() == MotionEvent.ACTION_DOWN) { + if (showKeyboard) { + showKeyboard = false; + runOnUiThread(() -> new KeyboardUtil(PlayGameActivity.this, PlayGameActivity.this).hideKeyboard()); + } + + point_num = 1; + + //Log.w(TAG,"onTouch: "+"mouse left key down"); + float x1 = event.getX(0);// / Math.max(screen_width, 1); + float y1 = event.getY(0);// + + //虚拟鼠标测试坐标偏移 + if ((x1 - 0) < 0) { + x1 = 0; + } else { + x1 = x1 - 0; + } + if ((y1 - 0) < 0) { + y1 = 0; + } else { + y1 = y1 - 0; + } + mouseEvent.x = x1; + mouseEvent.y = y1; + + lastMoveX2 = x1 - downX2; + lastMoveY2 = y1 - downY2; + + if (lastMoveX2 != 0 || lastMoveY2 != 0) { + mouseEvent.x_rel = lastMoveX2; + mouseEvent.y_rel = lastMoveY2; + } else { + mouseEvent.x_rel = 0; + mouseEvent.y_rel = 0; + } + downX2 = x1; + downY2 = y1; + updateCursorPosition(downX2, downY2); + doubleSameTime = true; + if (sameTimer == null) { + sameTimer = new Timer(); + if (sameTimerTask != null) { + sameTimerTask.cancel(); + sameTimerTask = null; + } + sameTimerTask = new TimerTask() { + @Override + public void run() { + if (sameTimer != null) { + sameTimer.cancel(); + sameTimer = null; + } + if (sameTimerTask != null) { + sameTimerTask.cancel(); + sameTimerTask = null; + } + doubleSameTime = false; + System.out.println("LQQQQQ event.getAction() = sameTimer"); + /* mouseEvent.set_leftButton(true); + mouseEvent.set_RightButton(false); + mouseEvent.set_ScrollButton(false);*/ + WhaleCloud.getInstance().sendMouseStatus(mouseEvent); + } + }; + sameTimer.schedule(sameTimerTask, 20, 100); + } + //WhaleCloud.getInstance().sendMouseStatus(mouseEvent); + //System.out.println("LQQQQQ event.getAction() = 手指点击位置按下鼠标左键"); + } else if (event.getActionMasked() == MotionEvent.ACTION_MOVE) { + float x1 = event.getX(0);// / Math.max(screen_width, 1); + float y1 = event.getY(0);// / Math.max(screen_height, 1); + //虚拟鼠标测试坐标偏移 + if ((x1 - 0) < 0) { + x1 = 0; + } else { + x1 = x1 - 0; + } + if ((y1 - 0) < 0) { + y1 = 0; + } else { + y1 = y1 - 0; + } + // 虚拟鼠标测试坐标偏移 end + mouseEvent.x = x1; + mouseEvent.y = y1; + lastMoveX2 = x1 - downX2; + lastMoveY2 = y1 - downY2; + + if (lastMoveX2 != 0 || lastMoveY2 != 0) { + mouseEvent.x_rel = lastMoveX2; + mouseEvent.y_rel = lastMoveY2; + } else { + mouseEvent.x_rel = 0; + mouseEvent.y_rel = 0; + } + downX2 = x1; + downY2 = y1; + updateCursorPosition(downX2, downY2); + WhaleCloud.getInstance().sendMouseStatus(mouseEvent); + //System.out.println("LQQQQQ event.getAction() = 手指移动位置"); + } else if (event.getActionMasked() == MotionEvent.ACTION_POINTER_DOWN) { + point_num += 1; + + if (sameTimer != null) { + sameTimer.cancel(); + sameTimer = null; + } + if (sameTimerTask != null) { + sameTimerTask.cancel(); + sameTimerTask = null; + } + if (doubleSameTime) { + + if (sameTimer == null) { + sameTimer = new Timer(); + sameTimerTask = new TimerTask() { + @Override + public void run() { + if (sameTimer != null) { + sameTimer.cancel(); + sameTimer = null; + } + if (sameTimerTask != null) { + sameTimerTask.cancel(); + sameTimerTask = null; + } + doubleSameTime = false; + if (point_num == 2) { + mouseEvent.set_leftButton(false); + mouseEvent.set_RightButton(true); + mouseEvent.set_ScrollButton(false); + WhaleCloud.getInstance().sendMouseStatus(mouseEvent); + System.out.println("LQQQQQ event.getAction() = 2同时按下"); + } else if (point_num == 3) { + if (showKeyboard) { + showKeyboard = false; + runOnUiThread(() -> new KeyboardUtil(PlayGameActivity.this, PlayGameActivity.this).hideKeyboard()); + } else { + showKeyboard = true; + runOnUiThread(() -> new KeyboardUtil(PlayGameActivity.this, PlayGameActivity.this).showKeyboard()); + } + System.out.println("LQQQQQ event.getAction() = 3同时按下"); + } + + } + }; + sameTimer.schedule(sameTimerTask, 20, 100); + } + + } + } else if (event.getActionMasked() == MotionEvent.ACTION_POINTER_UP) { + point_num -= 1; + } + + } + } + + return true; + } catch (Exception e) { + e.printStackTrace(); + } + return false; + } + }; + + + public void updateCursorPosition(float x, float y) { + final int dstx = mDstx = (int) x; + final int dsty = mDsty = (int) y; + if (NetworkKeyboard != null) { + runOnUiThread(() -> { + mImageCursor.setTranslationX(dstx); + mImageCursor.setTranslationY(dsty); + } + ); + } + } + + //鼠标 + public void updateCursorIcon(byte[] iconData, byte x_offset, byte y_offset) { + try { + final Bitmap bmp = BitmapFactory.decodeByteArray(iconData, 0, iconData.length); + /* if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {//安卓7 以上支持物理鼠标图标修改 + runOnUiThread(() -> { + if (bmp != null) { + PointerIcon mNewPI = PointerIcon.create(bmp, (float) x_offset, (float) y_offset); + getWindow().getDecorView().setPointerIcon(mNewPI); + } else { + //没有接口可以隐藏鼠标,画个空图标 + Bitmap bitmap = BitmapFactory.decodeResource(getResources(), R.drawable.cursor_null, null); + PointerIcon mNewPI = PointerIcon.create(bitmap, (float) x_offset, (float) y_offset); + getWindow().getDecorView().setPointerIcon(mNewPI); + } + }); + }else {*/ + final int dstx = mDstx - x_offset; + final int dsty = mDsty - y_offset; + + /*if (NetworkKeyboard != null) { + runOnUiThread(() -> { + mImageCursor.setTranslationX(dstx); + mImageCursor.setTranslationY(dsty); + } + ); + }*/ + /* }*/ + runOnUiThread(() -> { + if (NetworkKeyboard != null) { + if (bmp != null) { + mImageCursor.setBackground(new BitmapDrawable(getResources(), bmp)); + /* mImageCursor.setHeight(50); + mImageCursor.setWidth(50);*/ + } else { + if (!IsGameMouse) { + mImageCursor.setBackgroundResource(R.drawable.cursor); + } else { + mImageCursor.setBackground(null); + } + } + //mImageCursor.setBackground(new BitmapDrawable(getResources(), bmp)); + } + }); + + } catch (Exception e) { + e.printStackTrace(); + } + } + + //run on UI thread + private void updateLayoutSize() { + if (WhaleCloud.getInstance().isLegcyView()) { + if (orientation_now != orientation_last) { + LogUtil.i("updateLayoutSize SCREEN_WIDTH: " + orientation_last + "-->" + orientation_now); + orientation_last = orientation_now; + if (orientation_now == Configuration.ORIENTATION_PORTRAIT) { + /* gameLayout.getLayoutParams().height = SCREEN_WIDTH / 3; + gameLayout.getLayoutParams().width = gameLayout.getLayoutParams().height * mFrameWidth / mFrameHeight;*/ + LogUtil.i("updateLayoutSize gameLayout : " + mVideoViewLegacy.getLayoutParams().width + " x " + mVideoViewLegacy.getLayoutParams().height); + + } else { + /*gameLayout.getLayoutParams().width = ViewGroup.LayoutParams.MATCH_PARENT; + gameLayout.getLayoutParams().height = ViewGroup.LayoutParams.MATCH_PARENT;*/ + LogUtil.i("updateLayoutSize gameLayout : " + mVideoViewLegacy.getLayoutParams().width + " x " + mVideoViewLegacy.getLayoutParams().height); + + } + } + } else { + if (orientation_now != orientation_last) { + LogUtil.i("updateLayoutSize orientation: " + orientation_last + "-->" + orientation_now); + orientation_last = orientation_now; + if (orientation_now == Configuration.ORIENTATION_PORTRAIT) { + + LogUtil.i("ORIENTATION_PORTRAIT updateLayoutSize gameLayout: " + gameLayout.getLayoutParams().width + " x " + gameLayout.getLayoutParams().height); + } else { + + LogUtil.i("ORIENTATION_LAND updateLayoutSize gameLayout: " + gameLayout.getLayoutParams().width + " x " + gameLayout.getLayoutParams().height); + + } + } + } + // 横屏添加手柄或鼠标 + try { + if (Config.controllMode.equals("0")) { + //gameLayout.addView(handleView); + } else if (Config.controllMode.equals("1")) { + //gameLayout.addView(cursorLayout); + } else { + //gameLayout.addView(touchLayout); + } + } catch (Exception e) { + e.printStackTrace(); + } + //更新游戏区域坐标 + } + + private String gameConfig = ""; + +// private void startGame(JyConfig.START_GAME_MODE startGameMode) { +//// GameLoading(); +// getGameSetting(); +// +// try { +// switch (startGameMode) { +// case GAME_MODE_NORMAL: +// WhaleCloud.getInstance().start(gameData, mListener); +// //setGameRect(); +// break; +// case GAME_MODE_RECONNECT: +// WhaleCloud.getInstance().reconPlayGame(gameData, mListener); +// //setGameRect(); +// break; +// } +// } catch (Exception e) { +// e.printStackTrace(); +// finish(); +// } +// } + + private void startGame() { + getGameSetting();//获取游戏设置 + if (isReconPlay.equals("false")) { + //正常启动 + WhaleCloud.getInstance().start(gameData, mListener); + } else { + //断线重连 + WhaleCloud.getInstance().reconPlayGame(gameData, mListener); + } + + +// OpenApiRequest.playGame(this, Config.gamePara, new OnApiRequestListener() { +// @Override +// public void onResponse(String body, int code, String httpmsg) { +// Log.w(TAG, "playGame body: " + body); +// Log.w(TAG, "playGame code: " + code); +// Log.w(TAG, "playGame msg: " + httpmsg); +// if (code == 200) { +// Gson gs = new Gson(); +// playGameEntityResp result; +// +// try { +// result = gs.fromJson(body, playGameEntityResp.class); +// int status = result.status; +// Log.w(TAG, "result.data.getAsString()" + result.data.toString()); +// if (status == 200) { +// Config.sc_id = result.getSc_id(); +// Config.gamePara.sc_id = String.valueOf(Config.sc_id); +// bGameStart = true; +// if (queTimerTask != null) { +// queTimerTask.cancel(); +// } +// +//// SharedPreferences sp = PreferenceManager.getDefaultSharedPreferences(CustomGameActivity.this); +//// int tmpInt = sp.getInt(SP_DECODE_TYPE, -1); +//// int mouseModel = sp.getInt(SP_MOUSE_MODULE, MOUSE_MODEL_ABSOLUTE); +//// WhaleCloud.getInstance().setDecodeType(2); +//// WhaleCloud.getInstance().setMouseModel(mImageCursor, mouseModel); +//// WhaleCloud.getInstance().setMouseModel(mouseModel); +// WhaleCloud.getInstance().start(result.data.toString(), mListener); +// +//// if (WhaleCloud.getInstance().isLegcyView()) { +//// setGameRect(0, 0, SCREEN_WIDTH, SCREEN_HEIGHT); +//// } +// } else if (status == 201) { +// +//// if (queTimer != null) { +//// queTimer.cancel(); +//// } +//// queTimer = new Timer(); +//// queTimer.schedule(queTimerTask, 10 * 1000, 10 * 1000); +// +// try { +// JSONObject jsonObject = new JSONObject(body); +// status = jsonObject.getInt("status"); +// String msg = jsonObject.getString("msg"); +// JSONObject data = jsonObject.getJSONObject("data"); +// Config.play_queue_id = data.getInt("play_queue_id"); +// Config.queue_pos = data.getInt("queue_pos"); +// } catch (JSONException e) { +// showUItoast("开始游戏接口解析出错: " + body); +// LogUtil.e("开始游戏接口解析出错: " + body); +// } +// final String toastMsg = "排队中,排队ID:" + Config.play_queue_id + " 排队位置:" + Config.queue_pos; +// showUItoast(toastMsg); +// +// } else { +// final String toastMsg = "游戏申请失败:" + status + "|" + result.msg; +// Log.w(TAG, toastMsg); +// runOnUiThread(new Runnable() { +// @Override +// public void run() { +// showToast(toastMsg); +// finish(); +//// createDialog(DIALOG_QUIT_OK, toastMsg); +// } +// }); +// } +// } catch (JsonSyntaxException e) { +// Log.w(TAG, "OpenApiRequest.playGame json 解析错误"); +// return; +// } +// } else { +// final String toastMsg = "启动游戏失败!|" + code + "|" + httpmsg; +// runOnUiThread(new Runnable() { +// @Override +// public void run() { +// showToast(toastMsg); +// } +// }); +// } +// } +// +// @Override +// public void onFailure(Exception err) { +// showUItoast(err.getMessage()); +// finish(); +// } +// }); + + } + + String s_FloatingIcon = ""; + int loadingTime = 0; + + private void GameLoading() { + //String dataInfo = new NetHander().getGameLoadingImage(Config.gamePara.my_GameId); +// netHander.getGameLoadingImage(Config.gamePara.my_GameId, new DataResponseCallback() { +// @Override +// public void onResponseSuccess(ResponseDao response) { +// try { +// if (!PlayGameActivity.this.isFinishing()) { +// JSONObject jo1 = new JSONObject(response.getData().toString()); +// JSONObject jo2 = new JSONObject(jo1.getString("LoadBgImage")); +// JSONObject jo3 = new JSONObject(jo1.getString("IconImage")); +// s_FloatingIcon = jo2.getString("Url"); +// GlideImageLoader.display(PlayGameActivity.this, loading, s_FloatingIcon); +// loadingTime = jo1.getInt("GameLoadTime") + 2; +// +// valueAnimator = ValueAnimator.ofInt(0, 100).setDuration(loadingTime * 1000); +// valueAnimator.addUpdateListener(animator -> { +// final int value = (int) animator.getAnimatedValue(); +// +// fadenum.setText(value + ""); +// progressbar1.setProgress(value); +// if (value == 100) { +// showUItoast("提示:长时间无操作,将会退出游戏。"); +// loadingCL.setVisibility(View.GONE); +// } +// }); +// valueAnimator.start(); +// } +// } catch (JSONException e) { +// e.printStackTrace(); +// } +// +// } +// +// @Override +// public void onResponseFail(String errorString) { +// +// } +// }); + + + //gameConfig = new NetHander().getGameConfig(); + } + + public void getGameSetting() { + //有虚拟键盘 + if (IsKeyBoard) { + //请求虚拟键盘 + //JSONArray keyboardList = new JSONArray(netHander.getGameVirKeyboard(PlayGameActivity.this)); +// netHander.getGameVirKeyboard(new DataResponseCallback() { +// @Override +// public void onResponseSuccess(ResponseDao response) { +// if (response.getCode() == 0 && response.getResult() == 0) { +// //JSONObject jo1 = null; +// VirtualKey(response.getData().toString()); +// } +// } +// +// @Override +// public void onResponseFail(String errorString) { +// +// } +// }); + mImageCursor.setVisibility(View.VISIBLE); + mImageCursor.setFocusableInTouchMode(false); + + handle3.setTextColor(getResources().getColor(R.color.white)); +// handle3.setBackgroundColor(getResources().getColor(R.color.handle2_gb)); +// handle4.setTextColor(getResources().getColor(R.color.colorAccent1)); +// handle4.setBackgroundColor(getResources().getColor(R.color.handle1_gb)); + + if (IsGameInput) { + MNKeyboard.addView(handleView); + NetworkKeyboard.setVisibility(View.GONE); + Ismode = 1; +// handle1.setBackgroundColor(getResources().getColor(R.color.handle1_gb)); +// handle2.setBackgroundColor(getResources().getColor(R.color.handle2_gb)); + handle2.setTextColor(Color.parseColor("#FFFFFF")); + custom_button_yg.setVisibility(View.VISIBLE); + } else { + handle1.setEnabled(false); +// handle1.setBackgroundColor(getResources().getColor(R.color.handle2_gb)); + handle1.setTextColor(Color.parseColor("#33FFFFFF")); + + MNKeyboard.setVisibility(View.GONE); + NetworkKeyboard.setVisibility(View.VISIBLE); + Ismode = 2; +// handle2.setBackgroundColor(getResources().getColor(R.color.handle1_gb)); + handle2.setTextColor(Color.parseColor("#FFFFFF")); + custom_button_yg.setVisibility(View.GONE); + } + + } + +// netHander.getGameSetting(new DataResponseCallback() { +// @Override +// public void onResponseSuccess(ResponseDao response) { +// Log.i(TAG, "onResponseSuccess: getGameSetting" + response.getData().toString()); +// try { +// if (response.getCode() == 0 && response.getResult() == 0) { +// +// JSONObject totalJo = new JSONObject(response.getData().toString()); +// IsGameMouse = totalJo.getBoolean("IsGameMouse"); +// IsGameInput = totalJo.getBoolean("IsGameInput"); +// IsKeyBoard = totalJo.getBoolean("IsKeyBoard"); +// //IsKeyBoard = IsGameInput = true; +// if (IsGameInput == true && IsKeyBoard == false) { +// virtual_mode = 1; +// } else if (IsGameInput == false && IsKeyBoard == true) { +// virtual_mode = 3; +// } +// JSONObject keyBtnConfigJo = new JSONObject();//默认虚拟手柄按键配置 +// keyBtnConfigJo.put("btn_right_close", btn_right_close); +// keyBtnConfigJo.put("virtual_mode", virtual_mode); +// //writeKeyBtnConfig(keyBtnConfigJo.toString()); +// +// boolean IsGuideShow = totalJo.getBoolean("IsGuideShow"); +// if (IsGuideShow) { +// String IsGuide = AppConfigFileImpl.getStringParams(getApplicationContext(), "IsGuide"); +// if (IsGuide.isEmpty()) { +// runOnUiThread(() -> TipsDialog(new IDialogTwoView() { +// @Override +// public void cancel() { +// hideBottomUIMenu(); +// } +// +// @Override +// public void onSure() { +// AppConfigFileImpl.saveParams(getApplicationContext(), "IsGuide", "1"); +// } +// +// @Override +// public void returnApp() { +// returnAppMain(); +// } +// })); +// } +// } +// +// //有虚拟键盘 +// if (IsKeyBoard) { +// //请求虚拟键盘 +// //JSONArray keyboardList = new JSONArray(netHander.getGameVirKeyboard(PlayGameActivity.this)); +// netHander.getGameVirKeyboard(new DataResponseCallback() { +// @Override +// public void onResponseSuccess(ResponseDao response) { +// if (response.getCode() == 0 && response.getResult() == 0) { +// //JSONObject jo1 = null; +// VirtualKey(response.getData().toString()); +// } +// } +// +// @Override +// public void onResponseFail(String errorString) { +// +// } +// }); +// mImageCursor.setVisibility(View.VISIBLE); +// mImageCursor.setFocusableInTouchMode(false); +// +// handle3.setTextColor(Color.parseColor("#FFFFFF")); +// handle4.setTextColor(Color.parseColor("#FFFFFF")); +// handle3.setBackgroundResource(R.drawable.bg_border_performance); +// handle4.setBackgroundResource(R.drawable.shape_blue_bg); +// +// if (IsGameInput) { +// MNKeyboard.addView(handleView); +// NetworkKeyboard.setVisibility(View.GONE); +// Ismode = 1; +// handle1.setBackgroundResource(R.drawable.shape_blue_bg1); +// imgKeySet.setBackgroundResource(R.drawable.shape_blue_bg2); +// handle2.setBackgroundResource(R.drawable.bg_border_performance); +// handle2.setTextColor(Color.parseColor("#FFFFFF")); +// custom_button_yg.setVisibility(View.VISIBLE); +// } else { +// handle1.setEnabled(false); +// handle1.setBackgroundResource(R.drawable.bg_border_performance2); +// handle1.setTextColor(Color.parseColor("#33FFFFFF")); +// +// MNKeyboard.setVisibility(View.GONE); +// NetworkKeyboard.setVisibility(View.VISIBLE); +// Ismode = 2; +// handle2.setBackgroundResource(R.drawable.shape_blue_bg); +// handle2.setTextColor(Color.parseColor("#FFFFFF")); +// custom_button_yg.setVisibility(View.GONE); +// } +// +// } else { +// //没有虚拟键盘,直接加载默认手柄 +// MNKeyboard.addView(handleView); +// NetworkKeyboard.setVisibility(View.GONE); +// +// Ismode = 1; +// handle1.setBackgroundResource(R.drawable.shape_blue_bg1); +// imgKeySet.setBackgroundResource(R.drawable.shape_blue_bg2); +//// handle2.setBackgroundResource(R.drawable.bg_border_performance2); +//// handle2.setTextColor(Color.parseColor("#33FFFFFF")); +// handle3.setEnabled(false); +// handle4.setEnabled(false); +// } +// +// } else { +// showUItoast(response.getDescription().toString()); +// } +// } catch (JSONException e) { +// e.printStackTrace(); +// } +// } +// +// @Override +// public void onResponseFail(String errorString) { +// Log.i(TAG, "onResponseFail: getGameSetting" + errorString); +// } +// }); + + } + + + /** + * 游戏监听 + */ + JyGameStatusListener mListener = new JyGameStatusListener() { + @Override + public void onGameFeedBack(@NonNull JyFeedBackEvent event) { + if (event.eventID == JyFeedBackEvent.EVENT_CURSOR_UPDATE) { + updateCursorIcon(event.cursorIcon, event.x_offset, event.y_offset); + } else if (event.eventID == JyFeedBackEvent.EVENT_POSITION_UPDATE) { + //updateCursorPosition(event.position_x, event.position_y); + } else if (event.eventID == JyFeedBackEvent.EVENT_INPUT) {//输入提示 + //LogUtil.d("EVENT_INPUT:"); + runOnUiThread(new Runnable() { + @Override + public void run() { + showKeyboard = true; + new KeyboardUtil(PlayGameActivity.this, App.getInstance().getApplicationContext()).showKeyboard(); + } + }); + + } + } + + @Override + public void onForwardMsgFromGs(String s) { + + } + + + @Override + public void onGameStarting() { + Log.i(TAG, "onGameStarting: "); + } + + @Override + public void onGameBegin() { + Log.i(TAG, "onGameBegin: "); + } + + + @Override + public void onGameStop() { + //游戏结束 + Log.i(TAG, "onGameStop: 游戏结束"); + if (ActivityCollector.activities != null && ActivityCollector.activities.size() > 0) { + ActivityCollector.removeActivity(PlayGameActivity.this); + } + + HashMap playGameDetailsMap = new HashMap<>(); + playGameDetailsMap.put("FPS_Average", Config.FPS_Average); + playGameDetailsMap.put("NetworkDelay_Average", Config.NetworkDelay_Average); + JSONObject jsonObject = new JSONObject(playGameDetailsMap); + + //退出游戏 + openApiRequest.exitPlayGame(jsonObject.toString(), new OnApiRequestListener() { + @Override + public void onResponse(String data, int i, String s1) { + Log.i(TAG, "exitPlayGame: data==" + data); + } + + @Override + public void onFailure(Exception e) { + + } + }); + + HashMap TagMap = new HashMap<>(); + TagMap.put("tag", "exitGame"); + EventBus.getDefault().post(TagMap, EventBusParams.MAIN); + + finish(); + } + + @Override + public void onGameQos(Map mapStatus) { + controlGameFromTime(); + try { + Config.gamePing = (int) Double.parseDouble(Objects.requireNonNull(mapStatus.get("Rtt"))); + Log.d(TAG, "onGameQos: Config.gamePing==" + Config.gamePing); + String str1 = Config.gamePing + "ms"; + runOnUiThread(() -> { + if (wifi.getVisibility() == View.VISIBLE) { + if (Config.gamePing > 61 && Config.gamePing <= 130) { + wifi.setCompoundDrawablesRelativeWithIntrinsicBounds(R.mipmap.wifi_2, 0, 0, 0); + wifi.setTextColor(Color.parseColor("#FF9431")); + wifi.setText(str1); + } else if (Config.gamePing > 130) { + wifi.setCompoundDrawablesRelativeWithIntrinsicBounds(R.mipmap.wifi_3, 0, 0, 0); + wifi.setTextColor(Color.parseColor("#FF2020")); + wifi.setText(str1); + } else { + wifi.setCompoundDrawablesRelativeWithIntrinsicBounds(R.mipmap.wifi_1, 0, 0, 0); + wifi.setTextColor(Color.parseColor("#90FF7E")); + wifi.setText(str1); + } + } + }); + + updateGameInfo(mapStatus); + //Log.d(TAG, "onQos: "+ reports); + } catch (Exception e) { + e.printStackTrace(); + } + } + + public long count = 0; + + public void updateGameInfo(Map map) { + count++; + if (count <= 10) { + return; + } + int averageDecodSpeed = (int) Double.parseDouble(Objects.requireNonNull(map.get("DecodeMs"))); + Config.AverageDecodSpeed = getNewAverage(Config.AverageDecodSpeed, averageDecodSpeed, count - 10); + int fps_Average = (int) Double.parseDouble(Objects.requireNonNull(map.get("FrameRateOutput"))); + Config.FPS_Average = getNewAverage(Config.FPS_Average, fps_Average, count - 10); + int rtt = (int) Double.parseDouble(Objects.requireNonNull(map.get("Rtt"))); + Config.NetworkDelay_Average = getNewAverage(Config.NetworkDelay_Average, rtt, count - 10); + + } + + //刷新平均值 + public float getNewAverage(float average, float newValue, long connt) { + float newAverage = ((average * (connt - 1) + newValue) / connt); + + return newAverage; + } + + @Override + public void onError(int code, String msg) { + Log.i(TAG, "startGame onError: " + code + "| " + msg); + } + + @Override + public void onEvent(int code, String msg) { + final String showMsg = msg; + switch (code) { + case JyCode.EVENT_RTC_CONNECTED: //流已经建立连接 + break; + case JyCode.EVENT_MS_OK: //MS登录成功 + break; + case JyCode.EVENT_RTC_DATA://画面尺寸改变事件。第一次到该事件可以作为首帧渲染事件。 + break; + case JyCode.EVENT_GS_GAME_EXIT: //用户退出游戏 + break; + case JyCode.EVENT_GS_GAME_STARTED: //游戏启动成功 + startKeyEventSchedule(); + runOnUiThread(() -> { + if (valueAnimator != null) { + valueAnimator.cancel(); + } + fadenum.setText("100"); + if (progressbar1 != null) { + progressbar1.setProgress(100); + } + new Handler().postDelayed(() -> { + showUItoast("提示:长时间无操作,将会退出游戏。"); + animationView.cancelAnimation(); + loadingCL.setVisibility(View.GONE); + }, 1000); + }); + break; + + case JyCode.EVENT_SET_LEVEL_SUCC: //视频修改成功 + showUItoast("修改成功"); + break; + case JyCode.EVENT_SET_LEVEL_FAIL: //视频修改失败 + showUItoast("服务等级切换失败"); + break; + case JyCode.WRN_GAME_GET_SAVE_FAIL: //存档获取失败 + if (!msg.contains("NoSuchKey")) { + showUItoast("该游戏存档获取失败,如有疑问请反馈给客服,代码30002。"); + } + + break; + case JyCode.WRN_GAME_POST_SAVE_FAIL: //存档修改失败 + showUItoast("该游戏存档修改失败,如有疑问请反馈给客服,代码30003。"); + break; + case JyCode.WRN_GAME_SAVE_NOT_CHANGED: //戏存档修改失败 + showUItoast("该游戏没有新的游戏进度哦,存档未更新。"); + break; + default: + Log.i(TAG, "startGame onEvent default: " + code + "| " + msg); + break; + } + } + }; + + + long cur_Time = 0; + long last_Time = 0; + int UpdatePlayTimeOverTimeCount = 2;//扣费接口超时 + private int[] diamondNum = new int[0]; + + /** + * 扣费 + */ + public void controlGameFromTime() { + cur_Time = System.currentTimeMillis(); + if (cur_Time - last_Time < 1000 * 60) { + return; + } + last_Time = cur_Time; + + Log.d(TAG, "controlGameFromTime: last_Time"); + openApiRequest.playGameHeartbeat(new OnApiRequestListener() { + @Override + public void onResponse(String data, int code, String msg) { + Log.d(TAG, "onResponse: data==" + data); + Log.d(TAG, "onResponse: code==" + code); + Log.d(TAG, "onResponse: msg==" + msg); + + try { + JSONObject jsonObject = new JSONObject(data); + String jsonData = jsonObject.getString("data"); + if (jsonData.equals("null")) { + Log.d(TAG, "onResponse: 心跳数据异常"); + return; + } + Log.d(TAG, "onResponse: jsonData==" + jsonData); + JSONObject heartData = new JSONObject(jsonData); + + int gameConsumeDiamond = heartData.getInt("gameConsumeDiamond");//当前游戏消耗钻石数/每分钟 + int userPlayGameTime = heartData.getInt("userPlayGameTime");//用户剩余游玩时间(分钟) + int diamond = heartData.getInt("diamond");//钻石数 + + if (userPlayGameTime <= 3) { + Toast.makeText(PlayGameActivity.this, "游玩时间不足,钻石耗尽将会自动退出游戏!", Toast.LENGTH_SHORT).show(); + } + + Log.d(TAG, "onResponse: data=" + jsonObject); + } catch (Exception e) { + throw new RuntimeException(e); + } + + + } + + @Override + public void onFailure(Exception e) { + Log.d(TAG, "onResponse: e==" + e); + } + }); + + } + + + public void closeGame() { + Log.d(TAG, "closeGame: "); + ActivityCollector.removeActivity(this); + WhaleCloud.getInstance().stopGame(); + } + + + public long count = 0; + + + //刷新平均值 + public float getNewAverage(float average, float newValue, long connt) { + float newAverage = ((average * (connt - 1) + newValue) / connt); + + return newAverage; + } + + + public boolean isHandelEnter() { + boolean b = false; + GameHandle[] gameHandles = WhaleCloud.getInstance().getHandleList(); + + for (int i = 0; i < 4; i++) { + GameHandle handle = gameHandles[i]; + + if (handle != null) { + System.out.println(i + "device id=" + handle.getDevicedId()); + System.out.println(i + "getName id=" + handle.getName()); + System.out.println(i + "getProductId id=" + handle.getProductId()); + if (handle.getDevicedId() != -999) { + + return true; + } + } + } + System.out.println("isHandelEnter:" + b); + return b; + } + + + public void showDialog(String title, String content, String cancelStr, String sureStr, final IDialogTwoView iDialogView) { + BaseAlertDialog baseAlertDialog = new BaseAlertDialog.Builder(this).show(title, content, cancelStr, sureStr, iDialogView).create(); + try { + baseAlertDialog.show(); + } catch (Exception e) { + } + } + +// public void TipsDialog(final IDialogTwoView iDialogView) { +// TipsDialog baseAlertDialog = new TipsDialog.Builder(this).show(iDialogView).create(); +// try { +// baseAlertDialog.show(); +// } catch (Exception e) { +// } +// } + + + //设置清晰度 +// public boolean setCodeRate(int level) { +//// if (level >= 8 && Config.vipType <= 1) { +//// showUItoast("成为星耀2才可以选择哦"); +//// showJoinVip(); +//// return false; +//// } +// netHander.displayGrade(Config.sc_id, level, new DataResponseCallback() { +// @Override +// public void onResponseSuccess(ResponseDao response) { +// try { +// JSONObject dataJo = new JSONObject(response.getData().toString()); +// JSONObject jyData = new JSONObject(dataJo.getString("JyData")); +// boolean b = WhaleCloud.getInstance().setServiceLevel(jyData.getString("level_config")); +// if (!b) { +// showUItoast("切换失败"); +// } +// +// } catch (Exception e) { +// e.printStackTrace(); +// } +// } +// +// @Override +// public void onResponseFail(String errorString) { +// showUItoast("切换失败"); +// } +// }); +// /*NetHanderApiRequest.displayGrade(Config.sc_id, level, new OnApiRequestListener() { +// @Override +// public void onResponse(String body, int i, String s1) { +// Gson gs = new Gson(); +// displayGrade result; +// try { +// result = gs.fromJson(body, displayGrade.class); +// boolean b = WhaleCloud.getInstance().setServiceLevel(result.data.level_config); +// if (!b) { +// showUItoast("切换失败"); +// } +// +// } catch (Exception e) { +// e.printStackTrace(); +// } +// } +// +// @Override +// public void onFailure(Exception e) { +// +// } +// });*/ +// return true; +// +// } + + public static int getNavigationBarHeight(Context var0) { + boolean var1 = ViewConfiguration.get(var0).hasPermanentMenuKey(); + int var2; + return (var2 = var0.getResources().getIdentifier("navigation_bar_height", "dimen", "android")) > 0 && !var1 ? var0.getResources().getDimensionPixelSize(var2) : 0; + } + + + public static boolean hasNavigationBar(Context var0) { + boolean var1 = false; + int var2; + Resources var4; + if ((var2 = (var4 = var0.getResources()).getIdentifier("config_showNavigationBar", "bool", "android")) > 0) { + var1 = var4.getBoolean(var2); + } + + try { + Class var5; + String var6 = (String) (var5 = Class.forName("android.os.SystemProperties")).getMethod("get", new Class[]{String.class}).invoke(var5, new Object[]{"qemu.hw.mainkeys"}); + if ("1".equals(var6)) { + var1 = false; + } else if ("0".equals(var6)) { + var1 = true; + } + } catch (Exception var3) { + var3.printStackTrace(); + } + + return var1; + } + +// public static boolean isNavigationBarShowing(Context var0) { +// if (!hasNavigationBar(var0)) { +// return false; +// } else { +// if (Build.VERSION.SDK_INT >= 17) { +// String var1; +// if (RomUtils.isXiaomi()) { +// var1 = "force_fsg_nav_bar"; +// if (Settings.Global.getInt(var0.getContentResolver(), var1, 0) != 0) { +// return false; +// } +// +// return true; +// } +// +// if (RomUtils.isVivo()) { +// var1 = "navigation_gesture_on"; +// if (Settings.Secure.getInt(var0.getContentResolver(), var1, 0) != 0) { +// return true; +// } +// +// return false; +// } +// } +// +// return true; +// } +// } + + private void extracted(String data) { + try { + JSONObject jsonObject = new JSONObject(data); + String gameInfo = jsonObject.getString("GameInfo"); + JSONObject js = new JSONObject(gameInfo); + double score = js.getDouble("Score"); + String issuerName = js.getString("IssuerName"); + double moguNum = js.getDouble("moguNum"); + double diamondNum = js.getDouble("diamondNum"); + double userMoguNum = js.getDouble("userMoguNum"); + double userDiamondNum = js.getDouble("userDiamondNum"); + double playTime = js.getDouble("playTime"); + JSONArray labelList = js.getJSONArray("labelList"); + String label = (String) labelList.get(0); + JSONArray typeList = js.getJSONArray("typeList"); + String type = (String) typeList.get(0); + + + } catch (Exception e) { + Log.e(TAG, "extracted: " + e); + e.printStackTrace(); + } + } + + List VirtualkeyList = new ArrayList<>(); + + //虚拟按键配置 + private void VirtualKey(String data) { + try { + VirtualKeyListBean result = GsonJsonUtil.stringToObject(data, VirtualKeyListBean.class); + if (result != null && result.getList() != null && result.getList().size() > 0) { + List beanList = new ArrayList<>(); + int dpValue = AppUtil.dip2px(PlayGameActivity.this, 60); + for (int i = 0; i < result.getList().size(); i++) { + VirtualKeyListBean.ListBean bean = result.getList().get(i); + + final String GameIdentification = bean.getGameIdentification(); + final String keyName = bean.getKeyName(); + final String keyIndexStr = bean.getKeyIndex(); + final int posX = bean.getX(); + final int posY = bean.getY(); + final boolean IsKeyDrag = bean.isKeyDrag(); + final boolean IsPressLock = bean.isPressLock(); + float scale = 1.0f; + if (bean.getScale() != 0) { + scale = bean.getScale(); + } + final int sw = (int) (dpValue * scale); + final int sh = (int) (dpValue * scale); + if (!TextUtils.isEmpty(GameIdentification)) { + //组合键 + beanList.add(bean); + } else { + //非组合键 + final KeyButton virKey; + if (bean.getImage() != null) { + //JSONObject imagejo = new JSONObject(keyboardList.getJSONObject(i).getString("Image")); + String imgUrl = bean.getImage().getUrl(); + if (!TextUtils.isEmpty(imgUrl)) { + if (bean.getSelectedImage() != null) { + //JSONObject selectjo = new JSONObject(keyboardList.getJSONObject(i).getString("SelectedImage")); + String selUrl = bean.getSelectedImage().getUrl(); + if (!TextUtils.isEmpty(selUrl)) { + virKey = new KeyButton(PlayGameActivity.this, keyIndexStr, keyName, posX, posY, + bean.getW(), bean.getH(), selUrl, imgUrl, scale); + } else { + virKey = new KeyButton(PlayGameActivity.this, keyIndexStr, keyName, posX, posY, + bean.getW(), bean.getH(), "", imgUrl, scale); + } + } else { + virKey = new KeyButton(PlayGameActivity.this, keyIndexStr, keyName, posX, posY, + bean.getW(), bean.getH(), "", imgUrl, scale); + } + } else { + virKey = new KeyButton(PlayGameActivity.this, keyIndexStr, keyName, posX, posY, + bean.getW(), bean.getH(), "", "", scale); + } + + } else { + virKey = new KeyButton(PlayGameActivity.this, keyIndexStr, keyName, posX, posY, + 0, 0, "", "", scale); + } + + virKey.setX((int) ((float) posX * Globe.landscapeScaleWidht)); + virKey.setY((int) ((float) posY * Globe.landscapeScaleHeight)); + virKey.setTextSize((int) (12 * scale)); + virKey.setText(keyName); + virKey.setTextColor(Color.parseColor("#FFFFFF")); + virKey.setGravity(Gravity.CENTER); + FrameLayout.LayoutParams params = new FrameLayout.LayoutParams(sw, sh); + NetworkKeyboard.addView(virKey, params); + if (!virKey.getKeyImage().isEmpty() && !"null".equals(virKey.getKeyImage())) { + /*sw = virKey.getSW(); + sh = virKey.getSH();*/ +// if (Looper.myLooper() == Looper.getMainLooper()) { //只能在主线程执行 +// +// } + GlideImageLoader.display1(PlayGameActivity.this, virKey.getKeyImage(), new SimpleTarget() { + @Override + public void onResourceReady(GlideDrawable resource, GlideAnimation glideAnimation) { + virKey.setBackground(resource); + } + }, sw, sh); + GlideImageLoader.display1(PlayGameActivity.this, virKey.getSelectedImage(), new SimpleTarget() { + @Override + public void onResourceReady(GlideDrawable resource, GlideAnimation glideAnimation) { + } + }, sw, sh); + } else { + if (IsPressLock) { + virKey.setBackgroundResource(R.mipmap.btn_suoding); + virKey.setPadding(0, 0, 0, 20); + } else { + virKey.setBackgroundResource(R.mipmap.play_ls); + } + + } + virKey.setOnClickCallBackListener(new KeyButton.OnClickCallBackListener() { + @Override + public void onActionDown(MotionEvent event) { + Config.keyEvent_time = 0; + try { + if (IsKeyDrag) { + downX = event.getX(0) * (float) multiple; + downY = event.getY(0) * (float) multiple; + moveX = 0; + moveY = 0; + } + + if (!virKey.getKeyImage().isEmpty() && !"null".equals(virKey.getKeyImage())) { + GlideImageLoader.display1(PlayGameActivity.this, virKey.getSelectedImage(), new SimpleTarget() { + @Override + public void onResourceReady(GlideDrawable resource, GlideAnimation glideAnimation) { + virKey.setBackground(resource); + } + }, sw, sh); + } else { + if (IsPressLock) { + virKey.setBackgroundResource(R.mipmap.btn_suoding_w); + } else { + virKey.setBackgroundResource(R.mipmap.play_ls2); + } + //virKey.setBackgroundResource(R.mipmap.vkeyboard_bg_selected); + } + + if (keyIndexStr.indexOf("+") == -1) {//单个键盘按下 + int key = 0; + if (keyIndexStr.indexOf("0xA") != -1) { + String temp = keyIndexStr.substring(3); + key = 16 * 10 + Integer.valueOf(temp); + System.out.println("keyIndex = " + key); + } else { + key = Integer.valueOf(keyIndexStr); + } + if (key == -1 || key == -2 || key == 1 || key == 2) {//发送鼠标指令 + + mouseEvent.x = mImageCursor.getX(); + mouseEvent.y = mImageCursor.getY(); + if (key == -1) { + mouseEvent.set_scroll((byte) 1);//向上滑动滚轮 + } else if (key == -2) { + mouseEvent.set_scroll((byte) -1);//向下滑动滚轮 + } else if (key == 1) { + mouseEvent.set_leftButton(true);//鼠标左键 + } else if (key == 2) { + mouseEvent.set_RightButton(true);//鼠标右键 + } + WhaleCloud.getInstance().sendMouseStatus(mouseEvent); + } else if (key == 3333) { + showKeyboard = true; + runOnUiThread(() -> new KeyboardUtil(PlayGameActivity.this, PlayGameActivity.this).showKeyboard()); + } else {//发送键盘指令 + long now = SystemClock.uptimeMillis(); + KeyEvent keyevent = new KeyEvent(now, now, KeyEvent.ACTION_DOWN, key, 0); + WhaleCloud.getInstance().sendKeyBoardStatus(keyevent); + } + } else {//组合键盘按下 + int key1 = 0; + String temp1 = keyIndexStr.substring(0, keyIndexStr.indexOf("+")); + if (temp1.indexOf("0xA") != -1) { + String temp = temp1.substring(3); + key1 = 16 * 10 + Integer.valueOf(temp); + } else { + key1 = Integer.valueOf(temp1); + } + int key2 = 0; + String temp2 = ""; + String subStr = keyIndexStr.substring(keyIndexStr.indexOf("+") + 1); + if (subStr.indexOf("+") == -1) {//没有找到+ + temp2 = subStr; + } else {//找到+ + temp2 = subStr.substring(0, subStr.indexOf("+")); + } + if (temp2.indexOf("0xA") != -1) { + String temp = temp2.substring(3); + key2 = 16 * 10 + Integer.valueOf(temp); + } else { + key2 = Integer.valueOf(temp2); + } + int key3 = 0; + String temp3 = ""; + if (subStr.indexOf("+") != -1) {//找到+ + temp3 = subStr.substring(subStr.indexOf("+") + 1); + if (temp3.indexOf("0xA") != -1) { + String temp = temp3.substring(3); + key3 = 16 * 10 + Integer.valueOf(temp); + } else { + key3 = Integer.valueOf(temp3); + } + } + if (key1 == -1 || key1 == -2 || key1 == 1 || key1 == 2) {//发送鼠标指令 + mouseEvent.x = mImageCursor.getX(); + mouseEvent.y = mImageCursor.getY(); + if (key1 == -1) { + mouseEvent.set_scroll((byte) 1);//向上滑动滚轮 + } else if (key1 == -2) { + mouseEvent.set_scroll((byte) -1);//向下滑动滚轮 + } else if (key1 == 1) { + mouseEvent.set_leftButton(true);//鼠标左键 + } else if (key1 == 2) { + mouseEvent.set_RightButton(true);//鼠标右键 + } + WhaleCloud.getInstance().sendMouseStatus(mouseEvent); + } else {//发送键盘指令 + long now = SystemClock.uptimeMillis(); + KeyEvent keyevent = new KeyEvent(now, now, KeyEvent.ACTION_DOWN, key1, 0); + WhaleCloud.getInstance().sendKeyBoardStatus(keyevent); + } + if (key2 == -1 || key2 == -2 || key2 == 1 || key2 == 2) {//发送鼠标指令 + mouseEvent.x = mImageCursor.getX(); + mouseEvent.y = mImageCursor.getY(); + if (key2 == -1) { + mouseEvent.set_scroll((byte) 1);//向上滑动滚轮 + } else if (key2 == -2) { + mouseEvent.set_scroll((byte) -1);//向下滑动滚轮 + } else if (key2 == 1) { + mouseEvent.set_leftButton(true);//鼠标左键 + } else if (key2 == 2) { + mouseEvent.set_RightButton(true);//鼠标右键 + } + WhaleCloud.getInstance().sendMouseStatus(mouseEvent); + } else {//发送键盘指令 + long now = SystemClock.uptimeMillis(); + KeyEvent keyevent = new KeyEvent(now, now, KeyEvent.ACTION_DOWN, key2, 0); + WhaleCloud.getInstance().sendKeyBoardStatus(keyevent); + } + if (key3 != 0) { + if (key3 == -1 || key3 == -2 || key3 == 1 || key3 == 2) {//发送鼠标指令 + mouseEvent.x = mImageCursor.getX(); + mouseEvent.y = mImageCursor.getY(); + if (key3 == -1) { + mouseEvent.set_scroll((byte) 1);//向上滑动滚轮 + } else if (key3 == -2) { + mouseEvent.set_scroll((byte) -1);//向下滑动滚轮 + } else if (key3 == 1) { + mouseEvent.set_leftButton(true);//鼠标左键 + } else if (key3 == 2) { + mouseEvent.set_RightButton(true);//鼠标右键 + } + WhaleCloud.getInstance().sendMouseStatus(mouseEvent); + } else {//发送键盘指令 + long now = SystemClock.uptimeMillis(); + KeyEvent keyevent = new KeyEvent(now, now, KeyEvent.ACTION_DOWN, key3, 0); + WhaleCloud.getInstance().sendKeyBoardStatus(keyevent); + } + } + + } + + if (IsPressLock) { + if (!VirtualkeyList.contains(keyIndexStr)) { + VirtualkeyList.add(keyIndexStr); + } else { + VirtualkeyList.remove(keyIndexStr); + } + } + + } catch (Exception e) { + e.printStackTrace(); + } + } + + @Override + public void onActionUp() { + try { + if (IsKeyDrag) { + lastMouseX = mouseEventX; + lastMouseY = mouseEventY; + lastMoveX = 0; + lastMoveY = 0; + mouseEvent.x_rel = 0; + mouseEvent.y_rel = 0; + } + if (!VirtualkeyList.contains(keyIndexStr)) { + if (!virKey.getKeyImage().isEmpty() && !"null".equals(virKey.getKeyImage())) { + GlideImageLoader.display1(PlayGameActivity.this, virKey.getKeyImage(), new SimpleTarget() { + @Override + public void onResourceReady(GlideDrawable resource, GlideAnimation glideAnimation) { + virKey.setBackground(resource); + } + }, sw, sh); + } else { + if (IsPressLock) { + virKey.setBackgroundResource(R.mipmap.btn_suoding); + } else { + virKey.setBackgroundResource(R.mipmap.play_ls); + } + //virKey.setBackgroundResource(R.mipmap.vkeyboard_bg); + } + if (keyIndexStr.indexOf("+") == -1) {//单个键盘抬起 + int key = 0; + if (keyIndexStr.indexOf("0xA") != -1) { + String temp = keyIndexStr.substring(3); + key = 16 * 10 + Integer.valueOf(temp); + System.out.println("keyIndex = " + key); + } else { + key = Integer.valueOf(keyIndexStr); + } + if (key == -1 || key == -2 || key == 1 || key == 2) {//发送鼠标指令 + mouseEvent.x = mImageCursor.getX(); + mouseEvent.y = mImageCursor.getY(); + if (key == 1) { + mouseEvent.set_leftButton(false);//鼠标左键 + } else if (key == 2) { + mouseEvent.set_RightButton(false);//鼠标右键 + } else { + mouseEvent.set_scroll((byte) 0);//取消滑动滚轮 + } + WhaleCloud.getInstance().sendMouseStatus(mouseEvent); + } else if (key == 3333) { + + } else {//发送键盘指令 + long now = SystemClock.uptimeMillis(); + KeyEvent keyevent = new KeyEvent(now, now, KeyEvent.ACTION_UP, key, 0); + WhaleCloud.getInstance().sendKeyBoardStatus(keyevent); + } + } else {//组合键盘抬起 + int key1 = 0; + String temp1 = keyIndexStr.substring(0, keyIndexStr.indexOf("+")); + + if (temp1.indexOf("0xA") != -1) { + String temp = temp1.substring(3); + key1 = 16 * 10 + Integer.valueOf(temp); + } else { + key1 = Integer.valueOf(temp1); + } + + int key2 = 0; + String temp2 = ""; + String subStr = keyIndexStr.substring(keyIndexStr.indexOf("+") + 1); + if (subStr.indexOf("+") == -1) {//没有找到+ + temp2 = subStr; + } else {//找到+ + temp2 = subStr.substring(0, subStr.indexOf("+")); + } + if (temp2.indexOf("0xA") != -1) { + String temp = temp2.substring(3); + key2 = 16 * 10 + Integer.valueOf(temp); + } else { + key2 = Integer.valueOf(temp2); + } + int key3 = 0; + String temp3 = ""; + if (subStr.indexOf("+") != -1) {//找到+ + temp3 = subStr.substring(subStr.indexOf("+") + 1); + + if (temp3.indexOf("0xA") != -1) { + String temp = temp3.substring(3); + key3 = 16 * 10 + Integer.valueOf(temp); + } else { + key3 = Integer.valueOf(temp3); + } + } + + if (key1 != -1 && key1 != -2 && key1 != 1 && key1 != 2) { + long now = SystemClock.uptimeMillis(); + KeyEvent keyevent = new KeyEvent(now, now, KeyEvent.ACTION_UP, key1, 0); + WhaleCloud.getInstance().sendKeyBoardStatus(keyevent); + } else { + mouseEvent.x = mImageCursor.getX(); + mouseEvent.y = mImageCursor.getY(); + if (key1 == 1) { + mouseEvent.set_leftButton(false);//鼠标左键 + } else if (key1 == 2) { + mouseEvent.set_RightButton(false);//鼠标右键 + } else { + mouseEvent.set_scroll((byte) 0);//取消滑动滚轮 + } + WhaleCloud.getInstance().sendMouseStatus(mouseEvent); + } + + if (key2 != -1 || key2 != -2 && key2 != 1 && key2 != 2) { + long now = SystemClock.uptimeMillis(); + KeyEvent keyevent = new KeyEvent(now, now, KeyEvent.ACTION_UP, key2, 0); + WhaleCloud.getInstance().sendKeyBoardStatus(keyevent); + } else { + mouseEvent.x = mImageCursor.getX(); + mouseEvent.y = mImageCursor.getY(); + if (key2 == 1) { + mouseEvent.set_leftButton(false);//鼠标左键 + } else if (key2 == 2) { + mouseEvent.set_RightButton(false);//鼠标右键 + } else { + mouseEvent.set_scroll((byte) 0);//取消滑动滚轮 + } + WhaleCloud.getInstance().sendMouseStatus(mouseEvent); + } + + if (key3 != 0) { + if (key3 != -1 || key3 != -2 && key3 != 1 && key3 != 2) {//发送鼠标指令 + long now = SystemClock.uptimeMillis(); + KeyEvent keyevent = new KeyEvent(now, now, KeyEvent.ACTION_UP, key3, 0); + WhaleCloud.getInstance().sendKeyBoardStatus(keyevent); + } else { + mouseEvent.x = mImageCursor.getX(); + mouseEvent.y = mImageCursor.getY(); + if (key3 == 1) { + mouseEvent.set_leftButton(false);//鼠标左键 + } else if (key3 == 2) { + mouseEvent.set_RightButton(false);//鼠标右键 + } else { + mouseEvent.set_scroll((byte) 0);//取消滑动滚轮 + } + WhaleCloud.getInstance().sendMouseStatus(mouseEvent); + } + } + } + } + + + } catch (Exception e) { + e.printStackTrace(); + } + + //clickReset(); + //this.setBackground(new BitmapDrawable(getResources(),getTexture())); + //this.setAlpha(1.0f); + } + + @Override + public void onActionMove(MotionEvent event) { + if (IsKeyDrag) { + Config.keyEvent_time = 0; + if (event.getToolType(0) == MotionEvent.TOOL_TYPE_FINGER) { + switch (event.getActionMasked()) { + + case MotionEvent.ACTION_MOVE: + + moveX = event.getX(0) * (float) multiple; + moveY = event.getY(0) * (float) multiple; + float offsetX = moveX - downX; + float offsetY = moveY - downY; + + float mouseX = offsetX + lastMouseX; + float mouseY = offsetY + lastMouseY; + mouseEventX = mouseX <= 0 ? 0 : mouseX >= SCREEN_WIDTH ? SCREEN_WIDTH : mouseX; + mouseEventY = mouseY <= 0 ? 0 : mouseY >= SCREEN_HEIGHT ? SCREEN_HEIGHT : mouseY; + if (lastMoveX != 0) { + mouseEvent.x_rel = moveX - lastMoveX; + mouseEvent.y_rel = moveY - lastMoveY; + } else { + mouseEvent.x_rel = 0; + mouseEvent.y_rel = 0; + } + mouseEvent.x = mouseEventX; + mouseEvent.y = mouseEventY; + + lastMoveX = moveX; + lastMoveY = moveY; + updateCursorPosition(mouseEventX, mouseEventY); + WhaleCloud.getInstance().sendMouseStatus(mouseEvent); + break; + } + } + } + + } + }); + } + + } + if (beanList.size() > 0) { + + Map keyMap = new HashMap(); + keyMap.put("DirectionUp", 0); + keyMap.put("DirectionLeft", 0); + keyMap.put("DirectionRight", 0); + keyMap.put("DirectionDown", 0); + + int kup = 0; + int kdn = 0; + int klf = 0; + int krg = 0; + int posX = beanList.get(0).getX(); + int posY = beanList.get(0).getY(); + for (int i = 0; i < beanList.size(); i++) { + if (beanList.get(i).getGameIdentification().equals("DirectionUp")) { + kup = Integer.parseInt(beanList.get(i).getKeyIndex()); + posY = beanList.get(i).getY(); + } else if (beanList.get(i).getGameIdentification().equals("DirectionDown")) { + kdn = Integer.parseInt(beanList.get(i).getKeyIndex()); + } else if (beanList.get(i).getGameIdentification().equals("DirectionLeft")) { + posX = beanList.get(i).getX(); + klf = Integer.parseInt(beanList.get(i).getKeyIndex()); + } else if (beanList.get(i).getGameIdentification().equals("DirectionRight")) { + krg = Integer.parseInt(beanList.get(i).getKeyIndex()); + } + } + + int dp = AppUtil.dip2px(PlayGameActivity.this, 135); + final JoystickView2 virKey = new JoystickView2(PlayGameActivity.this); + final int finalKup = kup; + final int finalKdn = kdn; + final int finalKlf = klf; + final int finalKrg = krg; + virKey.setOnJoystickListener(new JoystickView2.OnJoystickListener() { + @Override + public void onPosition(float x, float y) { + Log.w(TAG, "stick x=" + x + " y=" + y); + + if (y <= -0.5 && y < 0) { + if (keyMap.get("DirectionUp") != 1) { + long now = SystemClock.uptimeMillis(); + KeyEvent keyevent = new KeyEvent(now, now, KeyEvent.ACTION_DOWN, finalKup, 0); + //KeyEvent keyevent = new KeyEvent(now, now, KeyEvent.ACTION_DOWN, 38, 0); + WhaleCloud.getInstance().sendKeyBoardStatus(keyevent); + keyMap.put("DirectionUp", 1); + } + + } + if (y >= -0.5 && y < 0) { + if (keyMap.get("DirectionUp") == 1) { + long now = SystemClock.uptimeMillis(); + KeyEvent keyevent = new KeyEvent(now, now, KeyEvent.ACTION_UP, finalKup, 0); + //KeyEvent keyevent = new KeyEvent(now, now, KeyEvent.ACTION_UP, 38, 0); + WhaleCloud.getInstance().sendKeyBoardStatus(keyevent); + keyMap.put("DirectionUp", 0); + } + } + + + if (y >= 0.5 && y > 0) { + if (keyMap.get("DirectionDown") != 1) { + long now = SystemClock.uptimeMillis(); + KeyEvent keyevent = new KeyEvent(now, now, KeyEvent.ACTION_DOWN, finalKdn, 0); + //KeyEvent keyevent = new KeyEvent(now, now, KeyEvent.ACTION_DOWN, 40, 0); + WhaleCloud.getInstance().sendKeyBoardStatus(keyevent); + keyMap.put("DirectionDown", 1); + } + } + if (y < 0.5 && y > 0) { + if (keyMap.get("DirectionDown") == 1) { + long now = SystemClock.uptimeMillis(); + KeyEvent keyevent = new KeyEvent(now, now, KeyEvent.ACTION_UP, finalKdn, 0); + //KeyEvent keyevent = new KeyEvent(now, now, KeyEvent.ACTION_UP, 40, 0); + WhaleCloud.getInstance().sendKeyBoardStatus(keyevent); + keyMap.put("DirectionDown", 0); + } + + + } + + if (x <= -0.5 && x < 0) { + if (keyMap.get("DirectionLeft") != 1) { + long now = SystemClock.uptimeMillis(); + KeyEvent keyevent = new KeyEvent(now, now, KeyEvent.ACTION_DOWN, finalKlf, 0); + //KeyEvent keyevent = new KeyEvent(now, now, KeyEvent.ACTION_DOWN, 37, 0); + WhaleCloud.getInstance().sendKeyBoardStatus(keyevent); + keyMap.put("DirectionLeft", 1); + } + + } + if (x >= -0.5 && x < 0) { + if (keyMap.get("DirectionLeft") == 1) { + long now = SystemClock.uptimeMillis(); + KeyEvent keyevent = new KeyEvent(now, now, KeyEvent.ACTION_UP, finalKlf, 0); + //KeyEvent keyevent = new KeyEvent(now, now, KeyEvent.ACTION_UP, 37, 0); + WhaleCloud.getInstance().sendKeyBoardStatus(keyevent); + keyMap.put("DirectionLeft", 0); + } + } + + if (x >= 0.5 && x > 0) { + if (keyMap.get("DirectionRight") != 1) { + long now = SystemClock.uptimeMillis(); + KeyEvent keyevent = new KeyEvent(now, now, KeyEvent.ACTION_DOWN, finalKrg, 0); + //KeyEvent keyevent = new KeyEvent(now, now, KeyEvent.ACTION_DOWN, 39, 0); + WhaleCloud.getInstance().sendKeyBoardStatus(keyevent); + keyMap.put("DirectionRight", 1); + } + } + if (x < 0.5 && x > 0) { + if (keyMap.get("DirectionRight") == 1) { + long now = SystemClock.uptimeMillis(); + KeyEvent keyevent = new KeyEvent(now, now, KeyEvent.ACTION_UP, finalKrg, 0); + //KeyEvent keyevent = new KeyEvent(now, now, KeyEvent.ACTION_UP, 39, 0); + WhaleCloud.getInstance().sendKeyBoardStatus(keyevent); + keyMap.put("DirectionRight", 0); + } + + } + + + if (y == 0) { + if (keyMap.get("DirectionUp") == 1) { + long now = SystemClock.uptimeMillis(); + KeyEvent keyevent = new KeyEvent(now, now, KeyEvent.ACTION_UP, finalKup, 0); + //KeyEvent keyevent = new KeyEvent(now, now, KeyEvent.ACTION_UP, 38, 0); + WhaleCloud.getInstance().sendKeyBoardStatus(keyevent); + keyMap.put("DirectionUp", 0); + } + if (keyMap.get("DirectionDown") == 1) { + long now = SystemClock.uptimeMillis(); + KeyEvent keyevent = new KeyEvent(now, now, KeyEvent.ACTION_UP, finalKdn, 0); + //KeyEvent keyevent = new KeyEvent(now, now, KeyEvent.ACTION_UP, 40, 0); + WhaleCloud.getInstance().sendKeyBoardStatus(keyevent); + keyMap.put("DirectionDown", 0); + } + } + if (x == 0) { + if (keyMap.get("DirectionRight") == 1) { + long now = SystemClock.uptimeMillis(); + KeyEvent keyevent = new KeyEvent(now, now, KeyEvent.ACTION_UP, finalKrg, 0); + //KeyEvent keyevent = new KeyEvent(now, now, KeyEvent.ACTION_UP, 39, 0); + WhaleCloud.getInstance().sendKeyBoardStatus(keyevent); + keyMap.put("DirectionRight", 0); + } + if (keyMap.get("DirectionLeft") == 1) { + long now = SystemClock.uptimeMillis(); + KeyEvent keyevent = new KeyEvent(now, now, KeyEvent.ACTION_UP, finalKlf, 0); + //KeyEvent keyevent = new KeyEvent(now, now, KeyEvent.ACTION_UP, 37, 0); + WhaleCloud.getInstance().sendKeyBoardStatus(keyevent); + keyMap.put("DirectionLeft", 0); + } + } + + } + + @Override + public void onVibrator() { + //joystickLeft.performHapticFeedback(HapticFeedbackConstants.LONG_PRESS, HapticFeedbackConstants.FLAG_IGNORE_GLOBAL_SETTING); + if (isShock) { + virKey.performHapticFeedback(HapticFeedbackConstants.LONG_PRESS, HapticFeedbackConstants.FLAG_IGNORE_GLOBAL_SETTING); + } + } + }); + + + virKey.setX((int) ((float) posX * Globe.landscapeScaleWidht)); + virKey.setY((int) ((float) posY * Globe.landscapeScaleHeight) + 60); + float scale = 1.0f; + /*float sw = dp * scale; + float sh = dp * scale;*/ + FrameLayout.LayoutParams params = new FrameLayout.LayoutParams((int) dp, (int) dp); + NetworkKeyboard.addView(virKey, params); + + //有组合键,重新编辑组合键 + /*for (int i = 0; i < beanList.size(); i++) { + if(beanList.get(i).getGameIdentification().equals("DirectionUp")){ + + }else if(beanList.get(i).getGameIdentification().equals("DirectionLeft")){ + + }else if(beanList.get(i).getGameIdentification().equals("DirectionRight")){ + + }else if(beanList.get(i).getGameIdentification().equals("DirectionDown")){ + + } + }*/ + + + } + + } + + } catch (Exception e) { + e.printStackTrace(); + } + } + + @Override + protected void onActivityResult(int requestCode, int resultCode, Intent data) { + } + + public void showToast(final String toast) { + runOnUiThread(() -> Toast.makeText(PlayGameActivity.this, toast, Toast.LENGTH_SHORT).show()); + } + + + protected void hideBottomUIMenu() { + //隐藏虚拟按键,并且全屏 + if (Build.VERSION.SDK_INT > 11 && Build.VERSION.SDK_INT < 19) { // lower api + View v = this.getWindow().getDecorView(); + v.setSystemUiVisibility(View.GONE); + } else if (Build.VERSION.SDK_INT >= 19) { + //for new api versions. + View decorView = getWindow().getDecorView(); + int uiOptions = View.SYSTEM_UI_FLAG_HIDE_NAVIGATION + | View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY | View.SYSTEM_UI_FLAG_FULLSCREEN; + decorView.setSystemUiVisibility(uiOptions); + + } + } + +} diff --git a/android/app/src/main/java/co/steamcloud/cargame/RoundCalculator.java b/android/app/src/main/java/co/steamcloud/cargame/RoundCalculator.java new file mode 100644 index 0000000..ec534ba --- /dev/null +++ b/android/app/src/main/java/co/steamcloud/cargame/RoundCalculator.java @@ -0,0 +1,47 @@ +package co.steamcloud.cargame; + + +/** + * 圆形计算器 + */ +public class RoundCalculator { + + /** + * @return 计算(x1, y1)和(x0, y0)两点之间的直线距离 + */ + public static double calTwoPointDistant(double x0, double y0, double x1, double y1) { + return Math.sqrt(Math.pow((x1 - x0), 2) + Math.pow((y1 - y0), 2)); + } + + /** + * @return 计算(x1, y1)相对于(x0, y0)为圆点的圆的角度[0, 360] + */ + public static double calTwoPointAngleDegree(double x0, double y0, double x1, double y1) { + double z = calTwoPointDistant(x0, y0, x1, y1); + double angle = Math.asin(Math.abs(y1 - y0) / z) * 180 / Math.PI; + if (x1 < x0 && y1 < y0) { + angle = 180 - angle; + } else if (x1 < x0 && y1 >= y0) { + angle = 180 + angle; + } else if (x1 >= x0 && y1 >= y0) { + angle = 360 - angle; + } + return angle; + } + + /** + * (x0, y0)为圆心 + * (x1, y1)为触摸点 + * + * @param limitRadius 滚动球的圆心能移动的最大范围 限制滚动球(圆心)的移动半径 + * @return 计算得到滚动球的圆心坐标 + */ + public static float[] calPointLocationByAngle(double x0, double y0, double x1, double y1, double limitRadius) { + double angle = RoundCalculator.calTwoPointAngleDegree(x0, y0, x1, y1); + + float x = (float) (x0 + limitRadius * Math.cos(angle * Math.PI / 180)); + float y = (float) (y0 - limitRadius * Math.sin(angle * Math.PI / 180)); + + return new float[]{x, y}; + } +} diff --git a/android/app/src/main/java/co/steamcloud/cargame/entity/SessionHandle.java b/android/app/src/main/java/co/steamcloud/cargame/entity/SessionHandle.java new file mode 100644 index 0000000..77e3a73 --- /dev/null +++ b/android/app/src/main/java/co/steamcloud/cargame/entity/SessionHandle.java @@ -0,0 +1,16 @@ +package co.steamcloud.cargame.entity; + +public class SessionHandle { + public String sc_id; + public Handle_Device handle_device = new Handle_Device(); + + public SessionHandle(int sc_id, int gp, int kb) { + this.sc_id = String.valueOf(sc_id); + this.handle_device.gp = String.valueOf(gp); + this.handle_device.kb = String.valueOf(kb); + } + public class Handle_Device{ + public String gp; //手柄位置,手柄1-4分别用1248表示,比如3代表1号和2号手柄,0代表没有手柄 + public String kb; //键盘位,1是有,0是没有。 + } +} diff --git a/android/app/src/main/java/co/steamcloud/cargame/entity/StreamEntityResp.java b/android/app/src/main/java/co/steamcloud/cargame/entity/StreamEntityResp.java new file mode 100644 index 0000000..e13d926 --- /dev/null +++ b/android/app/src/main/java/co/steamcloud/cargame/entity/StreamEntityResp.java @@ -0,0 +1,17 @@ +package co.steamcloud.cargame.entity; + +import com.google.gson.JsonObject; + +public class StreamEntityResp { + public int status; + public String msg; + public JsonObject data; + + public String getToken() { + if (data.get("token") != null) { + return data.get("token").getAsString(); + } else { + return ""; + } + } +} diff --git a/android/app/src/main/java/co/steamcloud/cargame/entity/VirtualKeyListBean.java b/android/app/src/main/java/co/steamcloud/cargame/entity/VirtualKeyListBean.java new file mode 100644 index 0000000..af44d79 --- /dev/null +++ b/android/app/src/main/java/co/steamcloud/cargame/entity/VirtualKeyListBean.java @@ -0,0 +1,226 @@ +package co.steamcloud.cargame.entity; + +import com.google.gson.annotations.SerializedName; + +import java.io.Serializable; +import java.util.List; + +public class VirtualKeyListBean implements Serializable { + + private List list; + + + public List getList() { + return list; + } + + public void setList(List list) { + this.list = list; + } + + public static class ListBean implements Serializable { + /** + * Image : {"Type":0,"ImageId":0,"Name":null,"W":0,"H":0,"Url":null,"MD5":null} + * SelectedImage : {"Type":0,"ImageId":0,"Name":null,"W":0,"H":0,"Url":null,"MD5":null} + * KeyIndex : 87 + * KeyName : W + * X : 240 + * Y : 606 + * W : 1 + * H : 1 + * Scale : 1 + * GameIdentification : + */ + + private ImageBean Image; + private ImageBean SelectedImage; + private String KeyIndex; + private String KeyName; + @SerializedName("X") + private int x; + @SerializedName("Y") + private int y; + @SerializedName("W") + private int w; + @SerializedName("H") + private int h; + private float Scale; + private String GameIdentification; + private boolean IsKeyDrag; + private boolean IsPressLock; + + public ImageBean getImage() { + return Image; + } + + public void setImage(ImageBean image) { + Image = image; + } + + public ImageBean getSelectedImage() { + return SelectedImage; + } + + public void setSelectedImage(ImageBean selectedImage) { + SelectedImage = selectedImage; + } + + public String getKeyIndex() { + return KeyIndex; + } + + public void setKeyIndex(String keyIndex) { + KeyIndex = keyIndex; + } + + public String getKeyName() { + return KeyName; + } + + public void setKeyName(String keyName) { + KeyName = keyName; + } + + public int getX() { + return x; + } + + public void setX(int x) { + this.x = x; + } + + public int getY() { + return y; + } + + public void setY(int y) { + this.y = y; + } + + public int getW() { + return w; + } + + public void setW(int w) { + this.w = w; + } + + public int getH() { + return h; + } + + public void setH(int h) { + this.h = h; + } + + public float getScale() { + return Scale; + } + + public boolean isPressLock() { + return IsPressLock; + } + + public void setPressLock(boolean pressLock) { + IsPressLock = pressLock; + } + + public boolean isKeyDrag() { + return IsKeyDrag; + } + + public void setKeyDrag(boolean keyDrag) { + IsKeyDrag = keyDrag; + } + + public void setScale(float scale) { + Scale = scale; + } + + public String getGameIdentification() { + return GameIdentification; + } + + public void setGameIdentification(String gameIdentification) { + GameIdentification = gameIdentification; + } + + public static class ImageBean implements Serializable { + /** + * Type : 0 + * ImageId : 0 + * Name : null + * W : 0 + * H : 0 + * Url : null + * MD5 : null + */ + + private int Type; + private int ImageId; + private String Name; + @SerializedName("W") + private int w; + @SerializedName("H") + private int h; + private String Url; + private Object MD5; + + public int getType() { + return Type; + } + + public void setType(int type) { + Type = type; + } + + public int getImageId() { + return ImageId; + } + + public void setImageId(int imageId) { + ImageId = imageId; + } + + public String getName() { + return Name; + } + + public void setName(String name) { + Name = name; + } + + public int getW() { + return w; + } + + public void setW(int w) { + this.w = w; + } + + public int getH() { + return h; + } + + public void setH(int h) { + this.h = h; + } + + public String getUrl() { + return Url; + } + + public void setUrl(String url) { + Url = url; + } + + public Object getMD5() { + return MD5; + } + + public void setMD5(Object MD5) { + this.MD5 = MD5; + } + } + } +} diff --git a/android/app/src/main/java/co/steamcloud/cargame/entity/displayGrade.java b/android/app/src/main/java/co/steamcloud/cargame/entity/displayGrade.java new file mode 100644 index 0000000..b3fba1e --- /dev/null +++ b/android/app/src/main/java/co/steamcloud/cargame/entity/displayGrade.java @@ -0,0 +1,11 @@ +package co.steamcloud.cargame.entity; + +public class displayGrade { + public String msg; + public int status; + public LevelConfig data; + + public class LevelConfig { + public String level_config; + } +} diff --git a/android/app/src/main/java/co/steamcloud/cargame/entity/getTokenEntity.java b/android/app/src/main/java/co/steamcloud/cargame/entity/getTokenEntity.java new file mode 100644 index 0000000..332262b --- /dev/null +++ b/android/app/src/main/java/co/steamcloud/cargame/entity/getTokenEntity.java @@ -0,0 +1,13 @@ +package co.steamcloud.cargame.entity; + +public class getTokenEntity { + public String msg; + public int status; + public tokenResp data; + + public class tokenResp { + public String token; + public String expire_time; + } + +} diff --git a/android/app/src/main/java/co/steamcloud/cargame/entity/manualSaveEntity.java b/android/app/src/main/java/co/steamcloud/cargame/entity/manualSaveEntity.java new file mode 100644 index 0000000..fc336b1 --- /dev/null +++ b/android/app/src/main/java/co/steamcloud/cargame/entity/manualSaveEntity.java @@ -0,0 +1,11 @@ +package co.steamcloud.cargame.entity; + +public class manualSaveEntity { + public String msg; + public int status; + public SaveConfig data; + + public class SaveConfig { + public String save_config; + } +} diff --git a/android/app/src/main/java/co/steamcloud/cargame/entity/playGameEntityResp.java b/android/app/src/main/java/co/steamcloud/cargame/entity/playGameEntityResp.java new file mode 100644 index 0000000..eba585e --- /dev/null +++ b/android/app/src/main/java/co/steamcloud/cargame/entity/playGameEntityResp.java @@ -0,0 +1,13 @@ +package co.steamcloud.cargame.entity; + +import com.google.gson.JsonObject; + +public class playGameEntityResp { + public int status; + public String msg; + public JsonObject data; + + public int getSc_id(){ + return data.get("sc_id").getAsInt(); + } +} diff --git a/android/app/src/main/java/co/steamcloud/cargame/glide/GlideImageLoader.java b/android/app/src/main/java/co/steamcloud/cargame/glide/GlideImageLoader.java new file mode 100644 index 0000000..bd691a5 --- /dev/null +++ b/android/app/src/main/java/co/steamcloud/cargame/glide/GlideImageLoader.java @@ -0,0 +1,245 @@ +package co.steamcloud.cargame.glide; + +import android.content.Context; +import android.graphics.drawable.Drawable; +import android.os.Looper; +import android.util.Log; +import android.widget.ImageView; + +import androidx.appcompat.app.AppCompatActivity; +import androidx.fragment.app.Fragment; + +import com.bumptech.glide.Glide; +import com.bumptech.glide.load.engine.DiskCacheStrategy; +import com.bumptech.glide.load.resource.drawable.GlideDrawable; +import com.bumptech.glide.request.animation.GlideAnimation; +import com.bumptech.glide.request.target.SimpleTarget; +import com.bumptech.glide.util.Util; + + +/** + * @说明:图片加载类 图片加载库使用 Glide框架 + * @作者:WangQi + * @时间:2016-03-17 + */ +public class GlideImageLoader { + + + /** + * 载入图像资源至imageview + * + * @param context + * @param imageView + * @param url + */ + public static void display(Context context, ImageView imageView, String url) { + if (context != null) { + Glide.with(context).load(url).into(imageView); + } + } + + public static void display(Context context, ImageView imageView, int loadRes) { + if (context != null) { + Glide.with(context).load(loadRes).into(imageView); + } + } + + public static void display(Fragment fragment, ImageView imageView, String url) { + if (fragment != null) + Glide.with(fragment.getActivity().getApplicationContext()).load(url).into(imageView); + } + + /** + * 设置默认图片和加载错误的图片 + * + * @param context + * @param imageView + * @param url + * @param defaultRes + * @param errorRes + */ + public static void display(Context context, ImageView imageView, String url, int defaultRes, int errorRes) { + if (context != null) + Glide.with(context).load(url)/*.placeholder(defaultRes)*/.error(errorRes).into(imageView); + } + + public static void display1(Context context, ImageView imageView, String url, int defaultRes, int errorRes) { + if (context != null) + Glide.with(context).load(url).placeholder(defaultRes).error(errorRes).into(imageView); + } + + + /** + * 载入图像资源并只设置默认图像 + * + * @param context + * @param imageView + * @param url + * @param defaultResId + */ + public static void display(Context context, final ImageView imageView, String url, int defaultResId) { + if (context != null) + Glide.with(context.getApplicationContext()).load(url).placeholder(defaultResId).skipMemoryCache(true).dontAnimate().into(imageView); + + } + + + public static void displayDefaultRes(Context context, final ImageView imageView, String url) { + + Glide.with(context).load(url).into(new SimpleTarget() { + @Override + public void onResourceReady(GlideDrawable resource, GlideAnimation glideAnimation) { + imageView.setImageDrawable(resource); + + } + + @Override + public void onLoadStarted(Drawable placeholder) { + Log.i("displayRotateUrl", "准备显示"); + super.onLoadStarted(placeholder); + } + + @Override + public void onLoadFailed(Exception e, Drawable errorDrawable) { + e.printStackTrace(); + super.onLoadFailed(e, errorDrawable); + } + }); + + } + + + public static void glideRotate(Context context, String url, final ImageView imageView, int rotate) { + Glide.with(context) + .load(url) + .dontAnimate() + .transform(new RotateTransformation(context, rotate)) + .into(imageView); + + + } + + + public static void displayNoCache(Context context, final ImageView imageView, String url, int defaultResId) { + if (context != null) + Glide.with(context).load(url) + .asBitmap() + .diskCacheStrategy(DiskCacheStrategy.NONE)//禁用磁盘缓存 + .skipMemoryCache(true)//跳过内存缓存 + .placeholder(defaultResId).into(imageView); + } + + + public static void displayNoCache(Context context, final ImageView imageView, String url) { + if (context != null) + Glide.with(context).load(url) + .asBitmap() + .diskCacheStrategy(DiskCacheStrategy.NONE)//禁用磁盘缓存 + .skipMemoryCache(true)//跳过内存缓存 + .into(imageView); + } + + + /** + * 载入图像资源并只设置默认图像 + * + * @param fragment + * @param imageView + * @param url + * @param defaultResId + */ + public static void display(Fragment fragment, ImageView imageView, String url, int defaultResId) { + if (fragment != null) + Glide.with(fragment.getActivity().getApplicationContext()).load(url)/*.placeholder(defaultResId)*/.into(imageView); + } + + /** + * 载入图像时的回调接口 + * + * @param context + * @param url + * @param loadImageCallBack + */ + public static void display(Context context, String url, + SimpleTarget loadImageCallBack) { + if (context != null) + Glide.with(context).load(url).into(loadImageCallBack); + } + public static void display1(Context context, String url, + SimpleTarget loadImageCallBack,int width, int height) { + if (context != null) + Glide.with(context).load(url).override(width,height).diskCacheStrategy(DiskCacheStrategy.ALL).into(loadImageCallBack); + } + + /** + * 清除图片内存缓存 + */ + public static void clearImageMemoryCache(Context context) { + try { + if (Looper.myLooper() == Looper.getMainLooper()) { //只能在主线程执行 + Glide.get(context).clearMemory(); + } + } catch (Exception e) { + e.printStackTrace(); + } + } + + + /** + * 加载资源文件gif图片 + * + * @param activity + * @param resId + * @param iv + */ + public static void loadGifImg(AppCompatActivity activity, int resId, ImageView iv) { + if (Util.isOnMainThread()) { //是否是UI线程 + try { + //设置缓存策略为Source缓存原型,提高加载速度 + Glide.with(activity).load(resId).asGif().diskCacheStrategy(DiskCacheStrategy.SOURCE).into(iv); + } catch (Exception e) { + //AppLogUtil.i("图片加载失败:" + e.toString()); + //偶尔退出activity有这个错 IllegalArgumentException: You cannot start a load for a destroyed activity + } + } + } + + + /** + * 加载本地gif图片 + * + * @param activity + * @param resId + * @param iv + */ + public static void loadLocalGif(Context activity, String resId, ImageView iv) { + if (Util.isOnMainThread()) { //是否是UI线程 + try { + //设置缓存策略为Source缓存原型,提高加载速度 + Glide.with(activity).load(resId).asGif().diskCacheStrategy(DiskCacheStrategy.SOURCE).into(iv); + } catch (Exception e) { + //AppLogUtil.i("图片加载失败:" + e.toString()); + //偶尔退出activity有这个错 IllegalArgumentException: You cannot start a load for a destroyed activity + } + } + } + /** + * 加载图片并设置圆角 + * @param context + * @param imgUrl + * @param iv + * @param dp 圆角 + */ + public static void loadFilletImg(Context context, String imgUrl, ImageView iv,int dp){ + if(Util.isOnMainThread()) { //是否是UI线程 + try { + Glide.with(context).load(imgUrl).transform((new GlideRoundTransform(context,dp))).into(iv); + }catch (Exception e){ + //AppLogUtil.i("图片加载失败:"+e.toString()); + //偶尔退出activity有这个错 IllegalArgumentException: You cannot start a load for a destroyed activity + } + } + } +} + + diff --git a/android/app/src/main/java/co/steamcloud/cargame/glide/GlideRoundTransform.java b/android/app/src/main/java/co/steamcloud/cargame/glide/GlideRoundTransform.java new file mode 100644 index 0000000..517fa66 --- /dev/null +++ b/android/app/src/main/java/co/steamcloud/cargame/glide/GlideRoundTransform.java @@ -0,0 +1,57 @@ +package co.steamcloud.cargame.glide; + +import android.content.Context; +import android.content.res.Resources; +import android.graphics.Bitmap; +import android.graphics.BitmapShader; +import android.graphics.Canvas; +import android.graphics.Paint; +import android.graphics.RectF; + +import com.bumptech.glide.load.engine.bitmap_recycle.BitmapPool; +import com.bumptech.glide.load.resource.bitmap.BitmapTransformation; + +/** + * Created by vivianWQ on 2017/10/27 + * Mail: wangqi_vivian@sina.com + * desc: glide 圆角处理类 + * Version: 1.0 + */ +public class GlideRoundTransform extends BitmapTransformation { + + private static float radius = 0f; + + public GlideRoundTransform(Context context) { + this(context, 4); + } + + public GlideRoundTransform(Context context, int dp) { + super(context); + this.radius = Resources.getSystem().getDisplayMetrics().density * dp; + } + + @Override protected Bitmap transform(BitmapPool pool, Bitmap toTransform, int outWidth, int outHeight) { + return roundCrop(pool, toTransform); + } + + private static Bitmap roundCrop(BitmapPool pool, Bitmap source) { + if (source == null) return null; + + Bitmap result = pool.get(source.getWidth(), source.getHeight(), Bitmap.Config.ARGB_8888); + if (result == null) { + result = Bitmap.createBitmap(source.getWidth(), source.getHeight(), Bitmap.Config.ARGB_8888); + } + + Canvas canvas = new Canvas(result); + Paint paint = new Paint(); + paint.setShader(new BitmapShader(source, BitmapShader.TileMode.CLAMP, BitmapShader.TileMode.CLAMP)); + paint.setAntiAlias(true); + RectF rectF = new RectF(0f, 0f, source.getWidth(), source.getHeight()); + canvas.drawRoundRect(rectF, radius, radius, paint); + return result; + } + + @Override public String getId() { + return getClass().getName() + Math.round(radius); + } +} \ No newline at end of file diff --git a/android/app/src/main/java/co/steamcloud/cargame/glide/RotateTransformation.java b/android/app/src/main/java/co/steamcloud/cargame/glide/RotateTransformation.java new file mode 100644 index 0000000..b7f4891 --- /dev/null +++ b/android/app/src/main/java/co/steamcloud/cargame/glide/RotateTransformation.java @@ -0,0 +1,40 @@ +package co.steamcloud.cargame.glide; + +import android.content.Context; +import android.graphics.Bitmap; +import android.graphics.Matrix; + +import com.bumptech.glide.load.engine.bitmap_recycle.BitmapPool; +import com.bumptech.glide.load.resource.bitmap.BitmapTransformation; + +/** + * Created by vivianWQ on 2017/7/19 + * Mail: wangqi_vivian@sina.com + * desc: 图片旋转帮助对象 + * Version: 1.0 + */ +public class RotateTransformation extends BitmapTransformation { + + private float rotateRotationAngle = 0f; + + public RotateTransformation(Context context, float rotateRotationAngle) { + super(context); + + this.rotateRotationAngle = rotateRotationAngle; + } + + @Override + protected Bitmap transform(BitmapPool pool, Bitmap toTransform, int outWidth, int outHeight) { + Matrix matrix = new Matrix(); + + matrix.postRotate(rotateRotationAngle); + + return Bitmap.createBitmap(toTransform, 0, 0, toTransform.getWidth(), toTransform.getHeight(), matrix, true); + } + + @Override + public String getId() { + return "rotate" + rotateRotationAngle; + } +} + diff --git a/android/app/src/main/java/co/steamcloud/cargame/pay/PayResult.java b/android/app/src/main/java/co/steamcloud/cargame/pay/PayResult.java new file mode 100644 index 0000000..8e43faf --- /dev/null +++ b/android/app/src/main/java/co/steamcloud/cargame/pay/PayResult.java @@ -0,0 +1 @@ +package co.steamcloud.cargame.pay; import android.text.TextUtils; import java.util.Map; public class PayResult { private String resultStatus; private String result; private String memo; public PayResult(Map rawResult) { if (rawResult == null) { return; } for (String key : rawResult.keySet()) { if (TextUtils.equals(key, "resultStatus")) { resultStatus = rawResult.get(key); } else if (TextUtils.equals(key, "result")) { result = rawResult.get(key); } else if (TextUtils.equals(key, "memo")) { memo = rawResult.get(key); } } } @Override public String toString() { return "resultStatus={" + resultStatus + "};memo={" + memo + "};result={" + result + "}"; } /** * @return the resultStatus */ public String getResultStatus() { return resultStatus; } /** * @return the memo */ public String getMemo() { return memo; } /** * @return the result */ public String getResult() { return result; } } \ No newline at end of file diff --git a/android/app/src/main/java/co/steamcloud/cargame/time/SubscribeTimeManage.java b/android/app/src/main/java/co/steamcloud/cargame/time/SubscribeTimeManage.java new file mode 100644 index 0000000..1011b72 --- /dev/null +++ b/android/app/src/main/java/co/steamcloud/cargame/time/SubscribeTimeManage.java @@ -0,0 +1,63 @@ +package co.steamcloud.cargame.time; + +import java.util.ArrayList; + + +public class SubscribeTimeManage { + + private ArrayList subscribeList=new ArrayList<>(); + + private static class SingletonHolder + { + public final static SubscribeTimeManage instance = new SubscribeTimeManage(); + } + public static SubscribeTimeManage getInstance() + { + //使用内部类的形式,需要用到时才会java虚拟机才回去创建内部类对象 + return SingletonHolder.instance; + } + + public ArrayList getSubscribeList(){ + return subscribeList; + } + + /** + * 订阅 + * @param onTimeListener + */ + public void register(OnTimeListener onTimeListener){ + if(subscribeList.contains(onTimeListener)){ + //已经订阅了,不做处理 + }else { + //未订阅过 + //订阅 + subscribeList.add(onTimeListener); + + //检查定时器是否在运行 + if(!TimeManage.getInstance().isRuning()){ + //如果定时器没有在运行,启动定时器 + TimeManage.getInstance().startTime(); + } + } + } + + /** + * 取消订阅 + * @param onTimeListener + */ + public void unregister(OnTimeListener onTimeListener){ + if(subscribeList.contains(onTimeListener)){ + //已经订阅 + //取消订阅 + subscribeList.remove(onTimeListener); + }else { + //未订阅过 + //不做处理 + } + } + + public interface OnTimeListener{ + //每秒调用一次 + void oneSecond(); + } +} diff --git a/android/app/src/main/java/co/steamcloud/cargame/time/TimeManage.java b/android/app/src/main/java/co/steamcloud/cargame/time/TimeManage.java new file mode 100644 index 0000000..cd500e6 --- /dev/null +++ b/android/app/src/main/java/co/steamcloud/cargame/time/TimeManage.java @@ -0,0 +1,78 @@ +package co.steamcloud.cargame.time; + +import android.os.Handler; +import android.os.Message; +import android.util.Log; + + +public class TimeManage { + + //计时器是否在运行 + private boolean isRuning=false; + + private final long DELAY=1000;//一秒钟走一次 + + private long stratTime;//处理任务开始时的系统时间 + + private long endTime;////任务处理完的系统时间 + + //计时,一秒钟走一次 + Handler handleProgress = new Handler() { + public void handleMessage(Message msg) { + stratTime=System.currentTimeMillis(); + //处理任务 + processSubscribe(); + endTime=System.currentTimeMillis(); + if(isRuning) { + //计算出做任务耗的时间,然后调整一下DELAY时间(真正的DELAY=原DELAY-处理任务耗的时间) + handleProgress.sendEmptyMessageDelayed(0, DELAY-(endTime-stratTime)); + } + } + }; + + private static class SingletonHolder + { + public final static TimeManage instance = new TimeManage(); + } + public static TimeManage getInstance() + { + //使用内部类的形式,需要用到时才会java虚拟机才回去创建内部类对象 + return SingletonHolder.instance; + } + + /** + * 返回计时器运行状态 + * @return + */ + public boolean isRuning(){ + return isRuning; + } + + /** + * 开始计时 + */ + public void startTime(){ + if(!isRuning) { + isRuning=true; + handleProgress.sendEmptyMessage(0); + Log.i("TimeManage","定时器启动"); + } + } + + /** + * 处理任务 + */ + private void processSubscribe(){ + if(SubscribeTimeManage.getInstance().getSubscribeList().size()==0){ + //当没有订阅者时,停止定时器 + isRuning=false; + Log.i("TimeManage","没有订阅者,定时器自动关闭"); + }else { + //当有订阅者时 + //给所有的订阅者回调一次 + for (int i = 0; i < SubscribeTimeManage.getInstance().getSubscribeList().size(); i++) { + SubscribeTimeManage.getInstance().getSubscribeList().get(i).oneSecond(); + } + } + } +} diff --git a/android/app/src/main/java/co/steamcloud/cargame/utils/AppConfigFile.java b/android/app/src/main/java/co/steamcloud/cargame/utils/AppConfigFile.java new file mode 100644 index 0000000..f9f768d --- /dev/null +++ b/android/app/src/main/java/co/steamcloud/cargame/utils/AppConfigFile.java @@ -0,0 +1,114 @@ +package co.steamcloud.cargame.utils; + +import android.content.Context; +import android.content.SharedPreferences; +import android.content.SharedPreferences.Editor; + +import java.util.Map; + +/** + * APP中BaseConfigFile保存数据操作类 保证整个应用只有一个SharedPreferences + */ +public class AppConfigFile { + public static final String SHARE_XML_NAME = "app_config"; //保存xml名称 + private static SharedPreferences sharedPreferences; + private static Editor sharedEdit; + + private AppConfigFile() { + } + + private static AppConfigFile baseSharedPreferences; + + public static AppConfigFile getInstance(Context context) { + if (null == baseSharedPreferences) { + baseSharedPreferences = new AppConfigFile(); + } + if (null == sharedPreferences) { + sharedPreferences = context.getSharedPreferences(SHARE_XML_NAME, Context.MODE_PRIVATE); + sharedEdit = sharedPreferences.edit(); + } + return baseSharedPreferences; + } + + //保存数据 + public void saveParams(String key, int value) { + sharedEdit.putInt(key, value); + sharedEdit.commit(); + } + + + public void saveParams(String key, String value) { + sharedEdit.putString(key, value); + sharedEdit.commit(); + } + + + public void saveParams(String key, boolean value) { + sharedEdit.putBoolean(key, value); + sharedEdit.commit(); + } + + + public void saveParams(String key, long value) { + sharedEdit.putLong(key, value); + sharedEdit.commit(); + } + + + /** + * @param @return + * @return Map + * @description 获取所有的配置信息 + * @author jiaBF + */ + public Map getAll() { + return sharedPreferences.getAll(); + } + + //读取保存数据 + public String getStrParams(String key) { + return sharedPreferences.getString(key, ""); + } + + + public String getStrParams(String key, String defaultVal) { + return sharedPreferences.getString(key, defaultVal); + } + + + public int getIntParams(String key) { + return sharedPreferences.getInt(key, 0); + } + + + public int getIntParams(String key, int defaultVal) { + return sharedPreferences.getInt(key, defaultVal); + } + + + public float getFloatParams(String key, float defaultVal) { + return sharedPreferences.getFloat(key, defaultVal); + } + + + public boolean getBooleanParams(String key) { + return sharedPreferences.getBoolean(key, false); + } + + + public boolean getBooleanParams(String key, boolean defaultVal) { + return sharedPreferences.getBoolean(key, defaultVal); + } + + + public long getLongParams(String key) { + return sharedPreferences.getLong(key, 0); + } + + + public long getLongParams(String key, long defaultVal) { + return sharedPreferences.getLong(key, defaultVal); + } + + +} diff --git a/android/app/src/main/java/co/steamcloud/cargame/utils/AppConfigFileImpl.java b/android/app/src/main/java/co/steamcloud/cargame/utils/AppConfigFileImpl.java new file mode 100644 index 0000000..f73e021 --- /dev/null +++ b/android/app/src/main/java/co/steamcloud/cargame/utils/AppConfigFileImpl.java @@ -0,0 +1,103 @@ +package co.steamcloud.cargame.utils; + +import android.content.Context; + +import java.util.Map; + +/** + * AppConfigFile操作类 + */ +public class AppConfigFileImpl { + /** + * 保存String类型的信息 + * + * @param context + */ + public static void saveParams(Context context, String key, String value) { + AppConfigFile.getInstance(context).saveParams(key, value); + } + + /** + * 获取String类型的信息 + * + * @param context + */ + public static String getStringParams(Context context, String key) { + return AppConfigFile.getInstance(context).getStrParams(key); + } + + /** + * 保存int类型的信息 + * + * @param context + */ + public static void saveParams(Context context, String key, int value) { + AppConfigFile.getInstance(context).saveParams(key, value); + } + + /** + * 获取int类型的信息 + * + * @param context + */ + public static int getIntParams(Context context, String key) { + return AppConfigFile.getInstance(context).getIntParams(key); + } + + /** + * 保存boolean类型的信息 + * + * @param context + */ + public static void saveParams(Context context, String key, boolean value) { + AppConfigFile.getInstance(context).saveParams(key, value); + } + + /** + * 获取boolean类型的信息 + * + * @param context + */ + public static boolean getBooleanParams(Context context, String key) { + return AppConfigFile.getInstance(context).getBooleanParams(key); + } + + /** + * 获取boolean类型的信息 + * + * @param context + */ + public static boolean getBooleanParams(Context context, String key, boolean defValue) { + return AppConfigFile.getInstance(context).getBooleanParams(key, defValue); + } + + /** + * 保存long类型的信息 + * + * @param context + */ + public static void saveParams(Context context, String key, long value) { + AppConfigFile.getInstance(context).saveParams(key, value); + } + + /** + * 获取long类型的信息 + * + * @param context + */ + public static long getLongParams(Context context, String key) { + return AppConfigFile.getInstance(context).getLongParams(key); + } + + + /** + * @param @return + * @return Map + * @description 获取所有的配置信息 + */ + public static Map getAll(Context context) { + return AppConfigFile.getInstance(context).getAll(); + } + + +} diff --git a/android/app/src/main/java/co/steamcloud/cargame/utils/AppUtil.java b/android/app/src/main/java/co/steamcloud/cargame/utils/AppUtil.java new file mode 100644 index 0000000..a12851a --- /dev/null +++ b/android/app/src/main/java/co/steamcloud/cargame/utils/AppUtil.java @@ -0,0 +1,910 @@ +package co.steamcloud.cargame.utils; + + +import android.Manifest; +import android.app.Activity; +import android.app.ActivityManager; +import android.app.AppOpsManager; +import android.content.ComponentName; +import android.content.Context; +import android.content.pm.ApplicationInfo; +import android.content.pm.PackageInfo; +import android.content.pm.PackageManager; +import android.content.res.Resources; +import android.graphics.Bitmap; +import android.graphics.Canvas; +import android.media.AudioManager; +import android.net.ConnectivityManager; +import android.net.NetworkInfo; +import android.net.wifi.WifiInfo; +import android.net.wifi.WifiManager; +import android.os.Build; +import android.provider.Settings; +import android.telephony.TelephonyManager; +import android.text.TextUtils; +import android.util.DisplayMetrics; +import android.util.Log; +import android.view.WindowManager; +import android.view.inputmethod.InputMethodManager; +import android.widget.EditText; +import android.widget.Toast; + +import androidx.annotation.RequiresApi; +import androidx.core.app.ActivityCompat; +import androidx.core.app.NotificationManagerCompat; + +import com.google.zxing.BarcodeFormat; +import com.google.zxing.EncodeHintType; +import com.google.zxing.WriterException; +import com.google.zxing.common.BitMatrix; +import com.google.zxing.qrcode.QRCodeWriter; + +import java.io.BufferedReader; +import java.io.IOException; +import java.io.InputStream; +import java.io.InputStreamReader; +import java.io.LineNumberReader; +import java.lang.reflect.Field; +import java.lang.reflect.Method; +import java.net.HttpURLConnection; +import java.net.MalformedURLException; +import java.net.URL; +import java.net.URLConnection; +import java.util.Hashtable; +import java.util.List; +import java.util.Locale; +import java.util.TimeZone; +import java.util.regex.Matcher; +import java.util.regex.Pattern; + +import co.steamcloud.cargame.App; + +/** + * App工具类 + */ +public class AppUtil { + + /** + * + * @param content 字符串内容 + * @param width 二维码宽度 + * @param height 二维码高度 + * @param character_set 编码方式(一般使用UTF-8) + * @param error_correction_level 容错率 L:7% M:15% Q:25% H:35% + * @param margin 空白边距(二维码与边框的空白区域) + * @param color_black 黑色色块 + * @param color_white 白色色块 + * @param logoBitmap logo图片 + * @param logoPercent logo所占百分比 + * @return + */ + public static Bitmap createQRCodeBitmap(String content, int width, int height, String character_set, + String error_correction_level,String margin, int color_black, + int color_white,Bitmap logoBitmap, float logoPercent) { + // 字符串内容判空 + if (TextUtils.isEmpty(content)) { + return null; + } + // 宽和高>=0 + if (width < 0 || height < 0) { + return null; + } + try { + /** 1.设置二维码相关配置,生成BitMatrix(位矩阵)对象 */ + Hashtable hints = new Hashtable<>(); + // 字符转码格式设置 + if (!TextUtils.isEmpty(character_set)) { + hints.put(EncodeHintType.CHARACTER_SET, character_set); + } + // 容错率设置 + if (!TextUtils.isEmpty(error_correction_level)) { + hints.put(EncodeHintType.ERROR_CORRECTION, error_correction_level); + } + // 空白边距设置 + if (!TextUtils.isEmpty(margin)) { + hints.put(EncodeHintType.MARGIN, margin); + } + /** 2.将配置参数传入到QRCodeWriter的encode方法生成BitMatrix(位矩阵)对象 */ + BitMatrix bitMatrix = new QRCodeWriter().encode(content, BarcodeFormat.QR_CODE, width, height, hints); + + /** 3.创建像素数组,并根据BitMatrix(位矩阵)对象为数组元素赋颜色值 */ + int[] pixels = new int[width * height]; + for (int y = 0; y < height; y++) { + for (int x = 0; x < width; x++) { + //bitMatrix.get(x,y)方法返回true是黑色色块,false是白色色块 + if (bitMatrix.get(x, y)) { + pixels[y * width + x] = color_black;//黑色色块像素设置 + } else { + pixels[y * width + x] = color_white;// 白色色块像素设置 + } + } + } + + /** 4.创建Bitmap对象,根据像素数组设置Bitmap每个像素点的颜色值,并返回Bitmap对象 */ + Bitmap bitmap = Bitmap.createBitmap(width, height, Bitmap.Config.ARGB_8888); + bitmap.setPixels(pixels, 0, width, 0, 0, width, height); + + /** 5.为二维码添加logo图标 */ + if(logoBitmap != null){ + return addLogo(bitmap, logoBitmap, logoPercent); + } + return bitmap; + } catch (WriterException e) { + e.printStackTrace(); + return null; + } + } + + + /** + * 向二维码中间添加logo图片(图片合成) + * + * @param srcBitmap 原图片(生成的简单二维码图片) + * @param logoBitmap logo图片 + * @param logoPercent 百分比 (用于调整logo图片在原图片中的显示大小, 取值范围[0,1] ) + * @return + */ + private static Bitmap addLogo(Bitmap srcBitmap, Bitmap logoBitmap, float logoPercent) { + if (srcBitmap == null) { + return null; + } + if (logoBitmap == null) { + return srcBitmap; + } + //传值不合法时使用0.2F + if (logoPercent < 0F || logoPercent > 1F) { + logoPercent = 0.2F; + } + + /** 1. 获取原图片和Logo图片各自的宽、高值 */ + int srcWidth = srcBitmap.getWidth(); + int srcHeight = srcBitmap.getHeight(); + int logoWidth = logoBitmap.getWidth(); + int logoHeight = logoBitmap.getHeight(); + + /** 2. 计算画布缩放的宽高比 */ + float scaleWidth = srcWidth * logoPercent / logoWidth; + float scaleHeight = srcHeight * logoPercent / logoHeight; + + /** 3. 使用Canvas绘制,合成图片 */ + Bitmap bitmap = Bitmap.createBitmap(srcWidth, srcHeight, Bitmap.Config.ARGB_8888); + Canvas canvas = new Canvas(bitmap); + canvas.drawBitmap(srcBitmap, 0, 0, null); + canvas.scale(scaleWidth, scaleHeight, srcWidth / 2, srcHeight / 2); + canvas.drawBitmap(logoBitmap, srcWidth / 2 - logoWidth / 2, srcHeight / 2 - logoHeight / 2, null); + + return bitmap; + } + + + public static boolean checkURL(String url) { + boolean value = false; + try { + HttpURLConnection conn = (HttpURLConnection) new URL(url).openConnection(); + int code = conn.getResponseCode(); + if (code != 200) { + value = false; + } else { + value = true; + } + } catch (MalformedURLException e) { + e.printStackTrace(); + } catch (IOException e) { + e.printStackTrace(); + } + return value; + } + + /** + * 获得屏幕宽度 + * + * @param context + * @return + */ + public static int getScreenWidth(Context context) { + WindowManager wm = (WindowManager) context + .getSystemService(Context.WINDOW_SERVICE); + DisplayMetrics outMetrics = new DisplayMetrics(); + wm.getDefaultDisplay().getMetrics(outMetrics); + return outMetrics.widthPixels; + } + + /** + * 获得屏幕高度 + * 小于android4.4去掉状态栏高度 + * + * @param context + * @return + */ + public static int getScreenHeight(Context context) { + WindowManager wm = (WindowManager) context + .getSystemService(Context.WINDOW_SERVICE); + DisplayMetrics outMetrics = new DisplayMetrics(); + wm.getDefaultDisplay().getMetrics(outMetrics); + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) { + return outMetrics.heightPixels; + } else { + return outMetrics.heightPixels - getStatusBarHeight(context); + } + + } + + /** + * 获取状态栏高度 + * + * @param context + * @return + */ + public static int getStatusBarHeight(Context context) { + int result = 0; + try { + int resourceId = context.getResources().getIdentifier("status_bar_height", "dimen", "android"); + if (resourceId > 0) { + result = context.getResources().getDimensionPixelSize(resourceId); + } + } catch (Exception e) { + e.printStackTrace(); + } + + return result; + } + + // 根据手机的分辨率从 px(像素) 的单位 转成为 dp + public static int px2dip(Context context, float pxValue) { + // 获取当前手机的像素密度(1个dp对应几个px) + float scale = context.getResources().getDisplayMetrics().density; + return (int) (pxValue / scale + 0.5f); // 四舍五入取整 + } + + /** + * 获取屏幕宽度 + * + * @param context + * @return + */ + public static int getWindowWidth(Context context) { + // 获取屏幕分辨率 + WindowManager wm = (WindowManager) (context + .getSystemService(Context.WINDOW_SERVICE)); + DisplayMetrics dm = new DisplayMetrics(); + wm.getDefaultDisplay().getMetrics(dm); + int mScreenWidth = dm.widthPixels; + return mScreenWidth; + } + + /** + * 获取屏幕高度 + * + * @param context + * @return + */ + public static int getWindowHight(Context context) { + // 获取屏幕分辨率 + WindowManager wm = (WindowManager) (context.getSystemService(Context.WINDOW_SERVICE)); + DisplayMetrics dm = new DisplayMetrics(); + wm.getDefaultDisplay().getMetrics(dm); + int mScreenHight = dm.heightPixels; + return mScreenHight; + } + + /** + * 检测耳机是否接入 + * 0:无插入,1:耳机和话筒均插入,2:仅插入话筒 + * + * @return + */ + public static boolean isHeadsetExists(Context context) { + AudioManager audioManager = (AudioManager) context.getSystemService(Context.AUDIO_SERVICE); + return audioManager.isWiredHeadsetOn(); + } + + public static boolean isBlueTooth(Context context) { + + AudioManager audioManager = (AudioManager) context.getSystemService(Context.AUDIO_SERVICE); + return audioManager.isBluetoothA2dpOn(); + } + + + /** + * 获取唯一设备号 + * + * @param context + * @return + */ + public static String getDeviceId(Context context) { + String android_id = Settings.Secure.getString(context.getContentResolver(), Settings.Secure.ANDROID_ID); + Log.d("TAG", "getDeviceId: ==" + android_id); + return android_id; + } + + /** + * 隐藏软键盘 + * + * @param context + * @param editText + * @return + */ + public static void hideInputMethod(Context context, EditText editText) { + InputMethodManager imm = (InputMethodManager) context.getSystemService(Context.INPUT_METHOD_SERVICE); + imm.hideSoftInputFromWindow(editText.getWindowToken(), 0); + } + + /** + * 隐藏软键盘 + * + * @param activity + * @return + */ + public static boolean hideInputMethod(Activity activity) { + InputMethodManager imm = (InputMethodManager) activity + .getSystemService(Context.INPUT_METHOD_SERVICE); + if (activity.getCurrentFocus() == null) + return false; + return imm.hideSoftInputFromWindow(activity.getCurrentFocus() + .getApplicationWindowToken(), + InputMethodManager.HIDE_NOT_ALWAYS); + } + + /** + * 显示或者隐藏状态栏;true隐藏,false显示 + * + * @param @param context + * @param @param enable + * @return void + * @description + * @author yanqin + */ + public static void full(Context context, boolean enable) { + if (enable) { + ((Activity) context).getWindow().addFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN);//隐藏状态栏 + } else { + ((Activity) context).getWindow().clearFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN); //显示状态栏 + } + } + + + // 判断一个字符是否是中文 + public static boolean isChinese(char c) { + return c >= 0x4E00 && c <= 0x9FA5;// 根据字节码判断 + } + + // 判断一个字符串是否含有中文 + public static boolean isChinese(String str) { + if (str == null) + return false; + for (char c : str.toCharArray()) { + if (isChinese(c)) + return true;// 有一个中文字符就返回 + } + return false; + } + + public static String chinaToUnicode(String str) { + String result = null; + for (int i = 0; i < str.length(); i++) { + int chr1 = (char) str.charAt(i); + result += "\\u" + Integer.toHexString(chr1); + } + return result; + } + + + /** + * 描述:判断网络是否有效. + * + * @param context the context + * @return true, if is network available + */ + public static boolean isNetworkAvailable(Context context) { + try { + ConnectivityManager connectivity = (ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE); + if (connectivity != null) { + NetworkInfo info = connectivity.getActiveNetworkInfo(); + if (info != null && info.isConnected()) { + if (info.getState() == NetworkInfo.State.CONNECTED) { + return true; + } + } + } + } catch (Exception e) { + return false; + } + return false; + } + + + /** + * 描述:判断网络是否有效.没有网络时进行提示 + * + * @param context the context + * @return true, if is network available + */ + public static boolean isNetworkAvailableMsg(Context context, int msgId) { + try { + ConnectivityManager connectivity = (ConnectivityManager) context + .getSystemService(Context.CONNECTIVITY_SERVICE); + if (connectivity != null) { + NetworkInfo info = connectivity.getActiveNetworkInfo(); + if (info != null && info.isConnected()) { + if (info.getState() == NetworkInfo.State.CONNECTED) { + return true; + } else { + Toast.makeText(context, msgId, Toast.LENGTH_SHORT).show(); + } + } else { + Toast.makeText(context, msgId, Toast.LENGTH_SHORT).show(); + } + } + } catch (Exception e) { + return false; + } + return false; + } + + /** + * 判断当前网络是否是wifi网络. + * + * @param context the context + * @return boolean + */ + public static boolean isWifi(Context context) { + ConnectivityManager connectivityManager = (ConnectivityManager) context + .getSystemService(Context.CONNECTIVITY_SERVICE); + NetworkInfo activeNetInfo = connectivityManager.getActiveNetworkInfo(); + if (activeNetInfo != null + && activeNetInfo.getType() == ConnectivityManager.TYPE_WIFI) { + return true; + } + return false; + } + + //版本号 + public static int getVersionCode(Context context) { + return getPackageInfo(context).versionCode; + } + + private static PackageInfo getPackageInfo(Context context) { + PackageInfo pi = null; + + try { + PackageManager pm = context.getPackageManager(); + pi = pm.getPackageInfo(context.getPackageName(), + PackageManager.GET_CONFIGURATIONS); + + + return pi; + } catch (Exception e) { + e.printStackTrace(); + } + + return pi; + } + + + /** + * 获取当前应用的版本名 + * + * @return + */ + public static String getVersionName(Context context) { + // 获取packagemanager的实例 + if (context == null) { + return ""; + } + PackageManager packageManager = context.getPackageManager(); + if (packageManager == null) + return ""; + // getPackageName()是你当前类的包名,0代表是获取版本信息 + PackageInfo packInfo; + String version = ""; + try { + packInfo = packageManager.getPackageInfo(context.getPackageName(), + 0); + version = packInfo.versionName; + } catch (PackageManager.NameNotFoundException e) { + e.printStackTrace(); + } + return version; + } + + + /** + * 初始化手机屏幕的宽高 + * + * @param activity + */ + public static DisplayMetrics getScreenSize(Activity activity) { + DisplayMetrics dm = new DisplayMetrics(); + activity.getWindowManager().getDefaultDisplay().getMetrics(dm); + return dm; + } + + /** + * 根据手机的分辨率从 dp 的单位 转成为 px(像素) + */ + public static int dip2px(Context context, double dpValue) { + Context mContext = context;//防止获取的上下文为空 + final float scale = mContext.getResources().getDisplayMetrics().density; + return (int) (dpValue * scale + 0.5f); + } + + /** + * 判断是否有sim卡 + * + * @param context + * @return + */ + public static boolean hasSimCard(Context context) { + TelephonyManager telMgr = (TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE); + int simState = telMgr.getSimState(); + boolean result = true; + switch (simState) { + case TelephonyManager.SIM_STATE_ABSENT: + result = false; // 没有SIM卡 + break; + case TelephonyManager.SIM_STATE_UNKNOWN: + result = false; + break; + } + return result; + } + + /** + * 判断是否是通话设备 + * + * @param context + * @return + */ + public static boolean isPhoneDevice(Context context) { + TelephonyManager telephony = (TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE); + int type = telephony.getPhoneType(); + if (type == TelephonyManager.PHONE_TYPE_NONE) { + //是通话设备 + return false; + } else { + //不是通话设备 + return true; + } + + } + + + /** + * 获取手机系统版本 + * + * @param @return + * @return String + * @description + * @author yanqin + */ + public static String getAndroidSDKVersionString() { + + return "Android " + Build.VERSION.RELEASE; + } + + + /** + * 获取外网的IP(要访问Url,要放到后台线程里处理) + * + * @param @return + * @return String + * @throws + * @Title: GetNetIp + * @Description: + */ + public static String getNetIp() { + URL infoUrl = null; + InputStream inStream = null; + String ipLine = ""; + HttpURLConnection httpConnection = null; + try { + infoUrl = new URL("http://pv.sohu.com/cityjson?ie=utf-8");//必须要用这个网址,因为这个网址返回了我们的ip地址。 + URLConnection connection = infoUrl.openConnection(); + httpConnection = (HttpURLConnection) connection; + int responseCode = httpConnection.getResponseCode(); + if (responseCode == HttpURLConnection.HTTP_OK) { + inStream = httpConnection.getInputStream(); + BufferedReader reader = new BufferedReader( + new InputStreamReader(inStream, "utf-8")); + StringBuilder strber = new StringBuilder(); + String line = null; + while ((line = reader.readLine()) != null) { + strber.append(line + "\n"); + } + + Pattern pattern = Pattern + .compile("((?:(?:25[0-5]|2[0-4]\\d|((1\\d{2})|([1-9]?\\d)))\\.){3}(?:25[0-5]|2[0-4]\\d|((1\\d{2})|([1-9]?\\d))))"); + Matcher matcher = pattern.matcher(strber.toString()); + if (matcher.find()) { + ipLine = matcher.group(); + } + //释放资源 + reader.close(); + } + } catch (MalformedURLException e) { + e.printStackTrace(); + } catch (IOException e) { + e.printStackTrace(); + } finally { + try { + inStream.close(); + httpConnection.disconnect(); + } catch (IOException e) { + e.printStackTrace(); + } catch (Exception ex) { + ex.printStackTrace(); + } + } + return ipLine; + } + + /** + * 判断android activity是否运行(可见) + * + * @param mContext + * @param activityClassName + * @return + */ + public static boolean isActivityRunning(Context mContext, String activityClassName) { + ActivityManager activityManager = (ActivityManager) mContext.getSystemService(Context.ACTIVITY_SERVICE); + List info = activityManager.getRunningTasks(1); + if (info != null && info.size() > 0) { + ComponentName component = info.get(0).topActivity; + if (activityClassName.equals(component.getClassName())) { + return true; + } + } + return false; + } + + /** + * 获取手机型号 + * + * @return 手机型号 + */ + public static String getSystemModel() { + return Build.MODEL; + } + + /** + * 获取手机厂商 + * + * @return 手机厂商 + */ + public static String getDeviceBrand() { + return Build.BRAND; + } + + /** + * 获取手机IMEI(需要“android.permission.READ_PHONE_STATE”权限) + * + * @return 手机IMEI + */ + public static String getIMEI(Context ctx) { + TelephonyManager tm = (TelephonyManager) ctx.getSystemService(Activity.TELEPHONY_SERVICE); + if (tm != null) { + if (ActivityCompat.checkSelfPermission(ctx, Manifest.permission.READ_PHONE_STATE) != PackageManager.PERMISSION_GRANTED) { + return ""; + } + return tm.getDeviceId(); + } + return null; + } + + /** + * 获取手机mac地址 + * 注:并不是所有机型都适配 + * + * @param ctx + * @return + */ + public static String getWifiMac(Context ctx) { + WifiManager wifi = (WifiManager) ctx.getSystemService(Context.WIFI_SERVICE); + WifiInfo info = wifi.getConnectionInfo(); + String str = info.getMacAddress(); + if (str == null) str = ""; + return str; + } + + /** + * 这是使用adb shell命令来获取mac地址的方式 + * + * @return + */ + public static String getMac(Context ctx) { + String macSerial = null; + String str = ""; + + try { + Process pp = Runtime.getRuntime().exec("cat /sys/class/net/wlan0/address "); + InputStreamReader ir = new InputStreamReader(pp.getInputStream()); + LineNumberReader input = new LineNumberReader(ir); + + for (; null != str; ) { + str = input.readLine(); + if (str != null) { + macSerial = str.trim();// 去空格 + break; + } + } + //释放资源 + ir.close(); + input.close(); + } catch (IOException ex) { + // 赋予默认值 + ex.printStackTrace(); + } + if ("".equals(str)) { + return getWifiMac(ctx); + } + + + return macSerial; + } + + /** + * 获取系统音量 + * + * @return + */ + public static int getMediaVolume(Context context) { + AudioManager audioMgr = (AudioManager) context.getSystemService(Context.AUDIO_SERVICE); + return audioMgr.getStreamVolume(AudioManager.STREAM_MUSIC); + } + + /** + * 获取系统最大音量 + * + * @param streamType AudioManager.STREAM_MUSIC 声道 + * @return + */ + public static int getMediaMaxVolume(Context context, int streamType) { + AudioManager audioMgr = (AudioManager) context.getSystemService(Context.AUDIO_SERVICE); + return audioMgr.getStreamMaxVolume(streamType); + } + + /** + * 设置音量 + * + * @param volume + */ + public static void setMediaVolume(int volume, Context context) { + AudioManager audioMgr = (AudioManager) context.getSystemService(Context.AUDIO_SERVICE); + audioMgr.setStreamVolume(AudioManager.STREAM_MUSIC, volume, AudioManager.FLAG_PLAY_SOUND); + } + + /** + * 设置音量 + * + * @param volume + */ + public static void setMediaVolumeNoSound(int volume, Context context) { + AudioManager audioMgr = (AudioManager) context.getSystemService(Context.AUDIO_SERVICE); + audioMgr.setStreamVolume(AudioManager.STREAM_MUSIC, volume, 0); + } + + /** + * 获取是否存在NavigationBar(虚拟按键) + * + * @param @param context + * @param @return + * @return boolean + * @description + * @author yanqin + */ + private static boolean checkDeviceHasNavigationBar(Context context) { + boolean hasNavigationBar = false; + Resources rs = context.getResources(); + int id = rs + .getIdentifier("config_showNavigationBar", "bool", "android"); + if (id > 0) { + hasNavigationBar = rs.getBoolean(id); + } + try { + Class systemPropertiesClass = Class + .forName("android.os.SystemProperties"); + Method m = systemPropertiesClass.getMethod("get", String.class); + String navBarOverride = (String) m.invoke(systemPropertiesClass, + "qemu.hw.mainkeys"); + if ("1".equals(navBarOverride)) { + hasNavigationBar = false; + } else if ("0".equals(navBarOverride)) { + hasNavigationBar = true; + } + } catch (Exception e) { + + } + return hasNavigationBar; + } + + + /** + * 获取NavigationBar(虚拟按键)的高度: + * + * @param @param context + * @param @return + * @return int + * @description + * @author yangqin + */ + public static int getNavigationBarHeight(Context context) { + int navigationBarHeight = 0; + Resources rs = context.getResources(); + int id = rs.getIdentifier("navigation_bar_height", "dimen", "android"); + if (id > 0 && checkDeviceHasNavigationBar(context)) { + navigationBarHeight = rs.getDimensionPixelSize(id); + } + return navigationBarHeight; + } + + //判断该app是否打开了通知 + + /** + * 可以通过NotificationManagerCompat 中的 areNotificationsEnabled()来判断是否开启通知权限。NotificationManagerCompat 在 android.support.v4.app包中,是API 22.1.0 中加入的。而 areNotificationsEnabled()则是在 API 24.1.0之后加入的。 + * areNotificationsEnabled 只对 API 19 及以上版本有效,低于API 19 会一直返回true + */ + @RequiresApi(api = Build.VERSION_CODES.KITKAT) + public static boolean isNotificationEnabled(Context context) { + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) { + NotificationManagerCompat notificationManagerCompat = NotificationManagerCompat.from(context); + boolean areNotificationsEnabled = notificationManagerCompat.areNotificationsEnabled(); + return areNotificationsEnabled; + } + + String CHECK_OP_NO_THROW = "checkOpNoThrow"; + String OP_POST_NOTIFICATION = "OP_POST_NOTIFICATION"; + + AppOpsManager mAppOps = (AppOpsManager) context.getSystemService(Context.APP_OPS_SERVICE); + ApplicationInfo appInfo = context.getApplicationInfo(); + String pkg = context.getApplicationContext().getPackageName(); + int uid = appInfo.uid; + + Class appOpsClass = null; + /* Context.APP_OPS_MANAGER */ + try { + appOpsClass = Class.forName(AppOpsManager.class.getName()); + Method checkOpNoThrowMethod = appOpsClass.getMethod(CHECK_OP_NO_THROW, Integer.TYPE, Integer.TYPE, + String.class); + Field opPostNotificationValue = appOpsClass.getDeclaredField(OP_POST_NOTIFICATION); + + int value = (Integer) opPostNotificationValue.get(Integer.class); + return ((Integer) checkOpNoThrowMethod.invoke(mAppOps, value, uid, pkg) == AppOpsManager.MODE_ALLOWED); + + } catch (Exception e) { + e.printStackTrace(); + } + return false; + + } + + //获取系统语言 + public static String getSystemLanguage() { + + Locale locale; + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) { + locale = App.getInstance().getResources().getConfiguration().getLocales().get(0); + } else { + locale = App.getInstance().getResources().getConfiguration().locale; + } + + //获取语言的正确姿势: + return locale.getLanguage(); + } + + + //获取系统时区 + public static String getTimeZone() { + TimeZone timeZone = TimeZone.getDefault(); + String id = timeZone.getID(); //获取时区id,如“Asia/Shanghai” + String name = timeZone.getDisplayName(); //获取名字,如“” + String shotName = timeZone.getDisplayName(false, TimeZone.SHORT); //获取名字,如“GMT+08:00” + int time = timeZone.getRawOffset(); //获取时差,返回值毫秒 + + Log.d("TAG", "getTimeZone: id==" + id); + Log.d("TAG", "getTimeZone: name==" + name); + Log.d("TAG", "getTimeZone: shotName==" + shotName); + Log.d("TAG", "getTimeZone: time==" + time); + return shotName; + } + +} diff --git a/android/app/src/main/java/co/steamcloud/cargame/wxapi/WXPayEntryActivity.java b/android/app/src/main/java/co/steamcloud/cargame/wxapi/WXPayEntryActivity.java new file mode 100644 index 0000000..3e2d343 --- /dev/null +++ b/android/app/src/main/java/co/steamcloud/cargame/wxapi/WXPayEntryActivity.java @@ -0,0 +1,98 @@ +package co.steamcloud.cargame.wxapi; + +import android.app.Activity; +import android.content.Intent; +import android.os.Bundle; +import android.util.Log; + +import androidx.annotation.Nullable; + +import com.tencent.mm.opensdk.modelbase.BaseReq; +import com.tencent.mm.opensdk.modelbase.BaseResp; +import com.tencent.mm.opensdk.openapi.IWXAPI; +import com.tencent.mm.opensdk.openapi.IWXAPIEventHandler; +import com.tencent.mm.opensdk.openapi.WXAPIFactory; + +import org.simple.eventbus.EventBus; + +import java.util.HashMap; + +import co.steamcloud.cargame.EventBusParams; +import co.steamcloud.cargame.MainActivity; + + +public class WXPayEntryActivity extends Activity implements IWXAPIEventHandler { + + private final String APP_ID = "wxa4009a51b6438a06"; + private IWXAPI api; + + @Override + protected void onCreate(@Nullable Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + api = WXAPIFactory.createWXAPI(this, APP_ID); + api.handleIntent(getIntent(), this); + } + + @Override + protected void onNewIntent(Intent intent) { + super.onNewIntent(intent); + setIntent(getIntent()); + api.handleIntent(intent, this); + Log.d("TAG", "onNewIntent: 8888888888888"); + } + + @Override + public void onReq(BaseReq baseReq) { + Log.d("TAG", "onPay, errCode = " + baseReq); + } + + @Override + public void onResp(BaseResp resp) { + + switch (resp.errCode) { + case BaseResp.ErrCode.ERR_OK: + //发送成功 + // 该笔订单真实的支付结果,需要依赖服务端的异步通知。 + Log.d("TAG", "支付成功"); + + HashMap TagMap = new HashMap<>(); + TagMap.put("tag", "wxPaySuccess"); + EventBus.getDefault().post(TagMap, EventBusParams.MAIN); + + + Intent intent = new Intent(this, MainActivity.class); + intent.addFlags(Intent.FLAG_ACTIVITY_REORDER_TO_FRONT); + startActivity(intent); + + break; + case BaseResp.ErrCode.ERR_USER_CANCEL: + //发送取消 + Log.d("TAG", "取消支付"); + HashMap Tag = new HashMap<>(); + Tag.put("tag", "payError"); + EventBus.getDefault().post(Tag, EventBusParams.MAIN); + break; + case BaseResp.ErrCode.ERR_AUTH_DENIED: + //发送被拒绝 + Log.d("TAG", "拒绝支付"); + + HashMap tagDenied = new HashMap<>(); + tagDenied.put("tag", "payError"); + EventBus.getDefault().post(tagDenied, EventBusParams.MAIN); + break; + case BaseResp.ErrCode.ERR_UNSUPPORT: + //不支持错误 + Log.d("TAG", "不支持支付"); + HashMap tagUnSupport = new HashMap<>(); + tagUnSupport.put("tag", "payError"); + EventBus.getDefault().post(tagUnSupport, EventBusParams.MAIN); + break; + default: + //发送返回 + Log.d("TAG", "返回支付"); + break; + } + finish(); + + } +} diff --git a/android/app/src/main/res/drawable/bg_base_dialog1.xml b/android/app/src/main/res/drawable/bg_base_dialog1.xml new file mode 100644 index 0000000..e1b3758 --- /dev/null +++ b/android/app/src/main/res/drawable/bg_base_dialog1.xml @@ -0,0 +1,7 @@ + + + + + + \ No newline at end of file diff --git a/android/app/src/main/res/drawable/bg_border_performance.xml b/android/app/src/main/res/drawable/bg_border_performance.xml new file mode 100644 index 0000000..0a20076 --- /dev/null +++ b/android/app/src/main/res/drawable/bg_border_performance.xml @@ -0,0 +1,16 @@ + + + + + + + + + + + + + + \ No newline at end of file diff --git a/android/app/src/main/res/drawable/bg_border_performance2.xml b/android/app/src/main/res/drawable/bg_border_performance2.xml new file mode 100644 index 0000000..ec41661 --- /dev/null +++ b/android/app/src/main/res/drawable/bg_border_performance2.xml @@ -0,0 +1,16 @@ + + + + + + + + + + + + + + \ No newline at end of file diff --git a/android/app/src/main/res/drawable/bg_border_performance3.xml b/android/app/src/main/res/drawable/bg_border_performance3.xml new file mode 100644 index 0000000..cc934e8 --- /dev/null +++ b/android/app/src/main/res/drawable/bg_border_performance3.xml @@ -0,0 +1,12 @@ + + + + + + + + \ No newline at end of file diff --git a/android/app/src/main/res/drawable/bg_border_performance4.xml b/android/app/src/main/res/drawable/bg_border_performance4.xml new file mode 100644 index 0000000..325a988 --- /dev/null +++ b/android/app/src/main/res/drawable/bg_border_performance4.xml @@ -0,0 +1,12 @@ + + + + + + + + \ No newline at end of file diff --git a/android/app/src/main/res/drawable/bg_hf.xml b/android/app/src/main/res/drawable/bg_hf.xml new file mode 100644 index 0000000..6784db2 --- /dev/null +++ b/android/app/src/main/res/drawable/bg_hf.xml @@ -0,0 +1,7 @@ + + + + + + \ No newline at end of file diff --git a/android/app/src/main/res/drawable/bg_play_p1.xml b/android/app/src/main/res/drawable/bg_play_p1.xml new file mode 100644 index 0000000..e75cca9 --- /dev/null +++ b/android/app/src/main/res/drawable/bg_play_p1.xml @@ -0,0 +1,16 @@ + + + + + + + + + + + + + + \ No newline at end of file diff --git a/android/app/src/main/res/drawable/button_back.xml b/android/app/src/main/res/drawable/button_back.xml new file mode 100644 index 0000000..364d6cb --- /dev/null +++ b/android/app/src/main/res/drawable/button_back.xml @@ -0,0 +1,7 @@ + + + + + + + diff --git a/android/app/src/main/res/drawable/button_down.xml b/android/app/src/main/res/drawable/button_down.xml new file mode 100644 index 0000000..b594da1 --- /dev/null +++ b/android/app/src/main/res/drawable/button_down.xml @@ -0,0 +1,6 @@ + + + + + + diff --git a/android/app/src/main/res/drawable/button_left.xml b/android/app/src/main/res/drawable/button_left.xml new file mode 100644 index 0000000..76ae3aa --- /dev/null +++ b/android/app/src/main/res/drawable/button_left.xml @@ -0,0 +1,6 @@ + + + + + + diff --git a/android/app/src/main/res/drawable/button_play_start.xml b/android/app/src/main/res/drawable/button_play_start.xml new file mode 100644 index 0000000..5d22298 --- /dev/null +++ b/android/app/src/main/res/drawable/button_play_start.xml @@ -0,0 +1,6 @@ + + + + + + diff --git a/android/app/src/main/res/drawable/button_right.xml b/android/app/src/main/res/drawable/button_right.xml new file mode 100644 index 0000000..a0a8546 --- /dev/null +++ b/android/app/src/main/res/drawable/button_right.xml @@ -0,0 +1,5 @@ + + + + + diff --git a/android/app/src/main/res/drawable/button_up.xml b/android/app/src/main/res/drawable/button_up.xml new file mode 100644 index 0000000..5767c3c --- /dev/null +++ b/android/app/src/main/res/drawable/button_up.xml @@ -0,0 +1,6 @@ + + + + + + diff --git a/android/app/src/main/res/drawable/handle_button_ls.xml b/android/app/src/main/res/drawable/handle_button_ls.xml new file mode 100644 index 0000000..d4b56a5 --- /dev/null +++ b/android/app/src/main/res/drawable/handle_button_ls.xml @@ -0,0 +1,6 @@ + + + + + + diff --git a/android/app/src/main/res/drawable/handle_button_lt.xml b/android/app/src/main/res/drawable/handle_button_lt.xml new file mode 100644 index 0000000..c1fb767 --- /dev/null +++ b/android/app/src/main/res/drawable/handle_button_lt.xml @@ -0,0 +1,7 @@ + + + + + + + diff --git a/android/app/src/main/res/drawable/keyboard_key.xml b/android/app/src/main/res/drawable/keyboard_key.xml new file mode 100644 index 0000000..cb33ae3 --- /dev/null +++ b/android/app/src/main/res/drawable/keyboard_key.xml @@ -0,0 +1,6 @@ + + + + + \ No newline at end of file diff --git a/android/app/src/main/res/drawable/keyboard_key_bg.xml b/android/app/src/main/res/drawable/keyboard_key_bg.xml new file mode 100644 index 0000000..3f6d8a7 --- /dev/null +++ b/android/app/src/main/res/drawable/keyboard_key_bg.xml @@ -0,0 +1,13 @@ + + + + + + + + + + + \ No newline at end of file diff --git a/android/app/src/main/res/drawable/keyboard_key_bg_c.xml b/android/app/src/main/res/drawable/keyboard_key_bg_c.xml new file mode 100644 index 0000000..79dc50a --- /dev/null +++ b/android/app/src/main/res/drawable/keyboard_key_bg_c.xml @@ -0,0 +1,13 @@ + + + + + + + + + + + + + \ No newline at end of file diff --git a/android/app/src/main/res/drawable/launch_background.xml b/android/app/src/main/res/drawable/launch_background.xml new file mode 100644 index 0000000..304732f --- /dev/null +++ b/android/app/src/main/res/drawable/launch_background.xml @@ -0,0 +1,12 @@ + + + + + + + + diff --git a/android/app/src/main/res/drawable/layer_list_progress_drawable_1.xml b/android/app/src/main/res/drawable/layer_list_progress_drawable_1.xml new file mode 100644 index 0000000..f3cedce --- /dev/null +++ b/android/app/src/main/res/drawable/layer_list_progress_drawable_1.xml @@ -0,0 +1,12 @@ + + + + + + + + + + \ No newline at end of file diff --git a/android/app/src/main/res/drawable/seek_bar_bg.xml b/android/app/src/main/res/drawable/seek_bar_bg.xml new file mode 100644 index 0000000..16c1729 --- /dev/null +++ b/android/app/src/main/res/drawable/seek_bar_bg.xml @@ -0,0 +1,18 @@ + + + + + + + + + + + + + + + + + + diff --git a/android/app/src/main/res/drawable/select_thumb.xml b/android/app/src/main/res/drawable/select_thumb.xml new file mode 100644 index 0000000..a7dd8ce --- /dev/null +++ b/android/app/src/main/res/drawable/select_thumb.xml @@ -0,0 +1,21 @@ + + + + + + + + + + + + + + + + + + + + + diff --git a/android/app/src/main/res/drawable/shap_exit_game.xml b/android/app/src/main/res/drawable/shap_exit_game.xml new file mode 100644 index 0000000..d195500 --- /dev/null +++ b/android/app/src/main/res/drawable/shap_exit_game.xml @@ -0,0 +1,5 @@ + + + + + \ No newline at end of file diff --git a/android/app/src/main/res/drawable/shap_exit_game_cancel.xml b/android/app/src/main/res/drawable/shap_exit_game_cancel.xml new file mode 100644 index 0000000..c7544a0 --- /dev/null +++ b/android/app/src/main/res/drawable/shap_exit_game_cancel.xml @@ -0,0 +1,5 @@ + + + + + \ No newline at end of file diff --git a/android/app/src/main/res/drawable/shape_black_bg.xml b/android/app/src/main/res/drawable/shape_black_bg.xml new file mode 100644 index 0000000..3200a71 --- /dev/null +++ b/android/app/src/main/res/drawable/shape_black_bg.xml @@ -0,0 +1,7 @@ + + + + + + + \ No newline at end of file diff --git a/android/app/src/main/res/drawable/shape_blue_bg.xml b/android/app/src/main/res/drawable/shape_blue_bg.xml new file mode 100644 index 0000000..a2c84fa --- /dev/null +++ b/android/app/src/main/res/drawable/shape_blue_bg.xml @@ -0,0 +1,8 @@ + + + + + + + + \ No newline at end of file diff --git a/android/app/src/main/res/drawable/shape_blue_bg1.xml b/android/app/src/main/res/drawable/shape_blue_bg1.xml new file mode 100644 index 0000000..e50c24d --- /dev/null +++ b/android/app/src/main/res/drawable/shape_blue_bg1.xml @@ -0,0 +1,10 @@ + + + + + + + + \ No newline at end of file diff --git a/android/app/src/main/res/drawable/shape_blue_bg2.xml b/android/app/src/main/res/drawable/shape_blue_bg2.xml new file mode 100644 index 0000000..190edce --- /dev/null +++ b/android/app/src/main/res/drawable/shape_blue_bg2.xml @@ -0,0 +1,10 @@ + + + + + + + + \ No newline at end of file diff --git a/android/app/src/main/res/drawable/shape_exit_game_bg.xml b/android/app/src/main/res/drawable/shape_exit_game_bg.xml new file mode 100644 index 0000000..b5f6d38 --- /dev/null +++ b/android/app/src/main/res/drawable/shape_exit_game_bg.xml @@ -0,0 +1,10 @@ + + + + + + + + \ No newline at end of file diff --git a/android/app/src/main/res/drawable/shape_orange_bg.xml b/android/app/src/main/res/drawable/shape_orange_bg.xml new file mode 100644 index 0000000..79dc088 --- /dev/null +++ b/android/app/src/main/res/drawable/shape_orange_bg.xml @@ -0,0 +1,10 @@ + + + + + + + + \ No newline at end of file diff --git a/android/app/src/main/res/drawable/shape_recarga_diamante_bg.xml b/android/app/src/main/res/drawable/shape_recarga_diamante_bg.xml new file mode 100644 index 0000000..3dcbe38 --- /dev/null +++ b/android/app/src/main/res/drawable/shape_recarga_diamante_bg.xml @@ -0,0 +1,11 @@ + + + + + + + + + \ No newline at end of file diff --git a/android/app/src/main/res/drawable/shape_return_app_bg.xml b/android/app/src/main/res/drawable/shape_return_app_bg.xml new file mode 100644 index 0000000..220c40e --- /dev/null +++ b/android/app/src/main/res/drawable/shape_return_app_bg.xml @@ -0,0 +1,10 @@ + + + + + + + + \ No newline at end of file diff --git a/android/app/src/main/res/drawable/shape_set_item_bg.xml b/android/app/src/main/res/drawable/shape_set_item_bg.xml new file mode 100644 index 0000000..54bcc16 --- /dev/null +++ b/android/app/src/main/res/drawable/shape_set_item_bg.xml @@ -0,0 +1,10 @@ + + + + + + + + \ No newline at end of file diff --git a/android/app/src/main/res/layout/activity_game.xml b/android/app/src/main/res/layout/activity_game.xml new file mode 100644 index 0000000..62694bf --- /dev/null +++ b/android/app/src/main/res/layout/activity_game.xml @@ -0,0 +1,464 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +