First push
44
.gitignore
vendored
Normal file
|
|
@ -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
|
||||
33
.metadata
Normal file
|
|
@ -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'
|
||||
16
README.md
Normal file
|
|
@ -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.
|
||||
28
analysis_options.yaml
Normal file
|
|
@ -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
|
||||
13
android/.gitignore
vendored
Normal file
|
|
@ -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
|
||||
121
android/app/build.gradle
Normal file
|
|
@ -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 '../..'
|
||||
}
|
||||
BIN
android/app/game.jks
Normal file
BIN
android/app/libs/cloudgamelibrary-2.4.115.aar
Normal file
7
android/app/src/debug/AndroidManifest.xml
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
<manifest xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<!-- The INTERNET permission is required for development. Specifically,
|
||||
the Flutter tool needs it to communicate with the running application
|
||||
to allow setting breakpoints, to provide hot reload, etc.
|
||||
-->
|
||||
<uses-permission android:name="android.permission.INTERNET"/>
|
||||
</manifest>
|
||||
111
android/app/src/main/AndroidManifest.xml
Normal file
|
|
@ -0,0 +1,111 @@
|
|||
<manifest xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
|
||||
<uses-permission android:name="android.permission.INTERNET"/>
|
||||
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
|
||||
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE"/>
|
||||
<uses-permission android:name="android.permission.CHANGE_NETWORK_STATE"/>
|
||||
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
|
||||
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
|
||||
<uses-permission android:name="android.permission.BLUETOOTH" />
|
||||
<uses-permission android:name="android.permission.MODIFY_AUDIO_SETTINGS" />
|
||||
<uses-permission android:name="android.permission.VIBRATE" />
|
||||
|
||||
<uses-permission android:name="android.permission.BLUETOOTH"/>
|
||||
|
||||
|
||||
|
||||
<uses-permission android:name="android.permission.RECORD_AUDIO" />
|
||||
<uses-permission android:name="android.permission.FLASHLIGHT" />
|
||||
<uses-permission android:name="android.permission.WAKE_LOCK" />
|
||||
<uses-permission android:name="android.permission.SYSTEM_ALERT_WINDOW" />
|
||||
|
||||
<application
|
||||
android:label="蒸汽云游 车机版"
|
||||
android:name=".App"
|
||||
android:icon="@mipmap/ic_launcher">
|
||||
<activity
|
||||
android:name=".MainActivity"
|
||||
android:exported="true"
|
||||
android:launchMode="singleTop"
|
||||
android:theme="@style/LaunchTheme"
|
||||
android:configChanges="orientation|keyboardHidden|keyboard|screenSize|smallestScreenSize|locale|layoutDirection|fontScale|screenLayout|density|uiMode"
|
||||
android:hardwareAccelerated="true"
|
||||
android:windowSoftInputMode="adjustResize">
|
||||
<!-- Specifies an Android theme to apply to this Activity as soon as
|
||||
the Android process has started. This theme is visible to the user
|
||||
while the Flutter UI initializes. After that, this theme continues
|
||||
to determine the Window background behind the Flutter UI. -->
|
||||
<meta-data
|
||||
android:name="io.flutter.embedding.android.NormalTheme"
|
||||
android:resource="@style/NormalTheme"
|
||||
/>
|
||||
<intent-filter>
|
||||
<action android:name="android.intent.action.MAIN"/>
|
||||
<category android:name="android.intent.category.LAUNCHER"/>
|
||||
</intent-filter>
|
||||
</activity>
|
||||
|
||||
<activity
|
||||
android:name=".PlayGameActivity"
|
||||
android:configChanges="keyboardHidden|orientation|screenSize|smallestScreenSize|screenLayout|keyboard|navigation"
|
||||
android:exported="false"
|
||||
android:screenOrientation="landscape"
|
||||
android:theme="@style/NormalTheme" />
|
||||
|
||||
<!-- Don't delete the meta-data below.
|
||||
This is used by the Flutter tool to generate GeneratedPluginRegistrant.java -->
|
||||
<meta-data
|
||||
android:name="flutterEmbedding"
|
||||
android:value="2" />
|
||||
|
||||
<activity
|
||||
android:name=".wxapi.WXPayEntryActivity"
|
||||
android:exported="true"
|
||||
android:launchMode="singleTask"
|
||||
android:theme="@android:style/Theme.Translucent.NoTitleBar">
|
||||
</activity>
|
||||
<activity-alias
|
||||
android:name="${applicationId}.wxapi.WXPayEntryActivity"
|
||||
android:exported="true"
|
||||
android:targetActivity=".wxapi.WXPayEntryActivity" />
|
||||
|
||||
<receiver
|
||||
android:name="com.zjrx.common.reciver.UsbDeviceReciver"
|
||||
android:exported="true">
|
||||
|
||||
<intent-filter>
|
||||
|
||||
<action android:name="android.hardware.usb.action.USB_DEVICE_ATTACHED" />
|
||||
|
||||
<action android:name="android.hardware.usb.action.USB_DEVICE_DETACHED" />
|
||||
</intent-filter>
|
||||
</receiver>
|
||||
|
||||
<receiver
|
||||
android:name="com.zjrx.common.reciver.BluetoothReciver"
|
||||
android:exported="true">
|
||||
|
||||
<intent-filter>
|
||||
|
||||
<action android:name="android.bluetooth.device.action.ACL_CONNECTED" />
|
||||
|
||||
<action android:name="android.bluetooth.device.action.ACL_DISCONNECTED" />
|
||||
</intent-filter>
|
||||
</receiver>
|
||||
|
||||
</application>
|
||||
<!-- Required to query activities that can process text, see:
|
||||
https://developer.android.com/training/package-visibility?hl=en and
|
||||
https://developer.android.com/reference/android/content/Intent#ACTION_PROCESS_TEXT.
|
||||
|
||||
In particular, this is used by the Flutter engine in io.flutter.plugin.text.ProcessTextPlugin. -->
|
||||
<queries>
|
||||
<intent>
|
||||
<action android:name="android.intent.action.PROCESS_TEXT"/>
|
||||
<data android:mimeType="text/plain"/>
|
||||
</intent>
|
||||
</queries>
|
||||
<queries>
|
||||
<package android:name="com.tencent.mm" />
|
||||
</queries>
|
||||
</manifest>
|
||||
1
android/app/src/main/assets/loading.json
Normal file
|
|
@ -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<Activity> activities = new ArrayList<Activity>();
|
||||
|
||||
/**
|
||||
* 添加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);
|
||||
}
|
||||
|
||||
}
|
||||
33
android/app/src/main/java/co/steamcloud/cargame/App.java
Normal file
|
|
@ -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;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -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;
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
55
android/app/src/main/java/co/steamcloud/cargame/Config.java
Normal file
|
|
@ -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; //排队等级
|
||||
|
||||
}
|
||||
|
|
@ -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));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -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";
|
||||
}
|
||||
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
|
@ -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;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
100
android/app/src/main/java/co/steamcloud/cargame/Globe.java
Normal file
|
|
@ -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;
|
||||
|
||||
/********************************************************/
|
||||
/*************** <20><>ת<EFBFBD><D7AA><EFBFBD><EFBFBD> *****************/
|
||||
/********************************************************/
|
||||
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;
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
|
@ -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<Map>() {
|
||||
}.getType());
|
||||
}
|
||||
return map;
|
||||
}
|
||||
|
||||
/**
|
||||
* 字符串转类
|
||||
*
|
||||
* @param string 字符串
|
||||
* @param clazz 类
|
||||
* @param <T> t
|
||||
* @return t
|
||||
*/
|
||||
public static <T> T stringToObject(String string, Class clazz) {
|
||||
return (T) gson.fromJson(string, clazz);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 转成list
|
||||
*
|
||||
* @param string 字符串
|
||||
* @param cls 类
|
||||
* @return list
|
||||
*/
|
||||
public static <T> List<T> stringToList(String string, Class<T> cls) {
|
||||
List<T> list = null;
|
||||
if (gson != null) {
|
||||
list = gson.fromJson(string, new TypeToken<List<T>>() {
|
||||
}.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;
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,6 @@
|
|||
package co.steamcloud.cargame.HttpUtils;
|
||||
|
||||
public interface HttpResultListener {
|
||||
void onResponse(String data, int code, String msg);
|
||||
void onFailure(Exception err);
|
||||
}
|
||||
|
|
@ -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,表示信任所有主机
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
|
@ -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";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,6 @@
|
|||
package co.steamcloud.cargame.HttpUtils;
|
||||
|
||||
public interface OnHttpListener {
|
||||
void onResponse(String body, int code, String msg);
|
||||
void onFailure(Exception err);
|
||||
}
|
||||
|
|
@ -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<String, String> 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<String, String> 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<String, String> 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<String, String> data, String key) {
|
||||
Set<String> 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;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,8 @@
|
|||
package co.steamcloud.cargame;
|
||||
|
||||
|
||||
public interface IDialogTwoView {
|
||||
void cancel();//取消
|
||||
void onSure();//确认
|
||||
void returnApp();//返回app
|
||||
}
|
||||
|
|
@ -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();
|
||||
}
|
||||
|
||||
}
|
||||
190
android/app/src/main/java/co/steamcloud/cargame/KeyButton.java
Normal file
|
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
|
@ -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<Key> 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;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -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<String, String> TagMap) {
|
||||
final String tag = TagMap.get("tag");
|
||||
if (!TextUtils.isEmpty(tag)) {
|
||||
switch (tag) {
|
||||
case "exitGame":
|
||||
Map<String, String> exitGameMap = new HashMap<>();
|
||||
exitGameMap.put("exitGame", "exitGame");
|
||||
nativeChannel.invokeMethod("exitGame", exitGameMap);
|
||||
break;
|
||||
case "wxPaySuccess":
|
||||
Map<String, String> map = new HashMap<>();
|
||||
map.put("wxPaySuccess", "wxPaySuccess");
|
||||
nativeChannel.invokeMethod("wxPaySuccess", map);
|
||||
break;
|
||||
|
||||
case "payError":
|
||||
Map<String, String> 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<String, Object> 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<String, String>) msg.obj);
|
||||
/**
|
||||
* 对于支付结果,请商户依赖服务端的异步通知结果。同步通知结果,仅作为支付结束的通知。
|
||||
*/
|
||||
String resultInfo = payResult.getResult();// 同步返回需要验证的信息
|
||||
String resultStatus = payResult.getResultStatus();
|
||||
// 判断resultStatus 为9000则代表支付成功
|
||||
if (TextUtils.equals(resultStatus, "9000")) {
|
||||
// 该笔订单是否真实支付成功,需要依赖服务端的异步通知。
|
||||
Log.d("TAG", "handleMessage9000: payResult==" + payResult);
|
||||
Map<String, String> map = new HashMap<>();
|
||||
map.put("AlipaySuccess", "AlipaySuccess");
|
||||
nativeChannel.invokeMethod("AlipaySuccess", map);
|
||||
} else {
|
||||
// 该笔订单真实的支付结果,需要依赖服务端的异步通知。
|
||||
Log.d("TAG", "handleMessage: payResult==" + payResult);
|
||||
|
||||
Map<String, String> 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<String, Object> 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<String, Object> 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<String, String> 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();
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
@ -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);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
115
android/app/src/main/java/co/steamcloud/cargame/MyButton.java
Normal file
|
|
@ -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();
|
||||
}
|
||||
}
|
||||
|
|
@ -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);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -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};
|
||||
}
|
||||
}
|
||||
|
|
@ -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是没有。
|
||||
}
|
||||
}
|
||||
|
|
@ -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 "";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -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<ListBean> list;
|
||||
|
||||
|
||||
public List<ListBean> getList() {
|
||||
return list;
|
||||
}
|
||||
|
||||
public void setList(List<ListBean> 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;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
|
@ -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;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
|
@ -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();
|
||||
}
|
||||
}
|
||||
|
|
@ -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<GlideDrawable>() {
|
||||
@Override
|
||||
public void onResourceReady(GlideDrawable resource, GlideAnimation<? super GlideDrawable> 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<GlideDrawable> loadImageCallBack) {
|
||||
if (context != null)
|
||||
Glide.with(context).load(url).into(loadImageCallBack);
|
||||
}
|
||||
public static void display1(Context context, String url,
|
||||
SimpleTarget<GlideDrawable> 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
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -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<String, String> 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;
}
}
|
||||
|
|
@ -0,0 +1,63 @@
|
|||
package co.steamcloud.cargame.time;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
|
||||
public class SubscribeTimeManage {
|
||||
|
||||
private ArrayList<OnTimeListener> subscribeList=new ArrayList<>();
|
||||
|
||||
private static class SingletonHolder
|
||||
{
|
||||
public final static SubscribeTimeManage instance = new SubscribeTimeManage();
|
||||
}
|
||||
public static SubscribeTimeManage getInstance()
|
||||
{
|
||||
//使用内部类的形式,需要用到时才会java虚拟机才回去创建内部类对象
|
||||
return SingletonHolder.instance;
|
||||
}
|
||||
|
||||
public ArrayList<OnTimeListener> 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();
|
||||
}
|
||||
}
|
||||
|
|
@ -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();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -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<String,?>
|
||||
* @description 获取所有的配置信息
|
||||
* @author jiaBF
|
||||
*/
|
||||
public Map<String, ?> 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);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
@ -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<String,?>
|
||||
* @description 获取所有的配置信息
|
||||
*/
|
||||
public static Map<String, ?> getAll(Context context) {
|
||||
return AppConfigFile.getInstance(context).getAll();
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
@ -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<EncodeHintType, String> 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<ActivityManager.RunningTaskInfo> 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;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -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<String, String> 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<String, String> Tag = new HashMap<>();
|
||||
Tag.put("tag", "payError");
|
||||
EventBus.getDefault().post(Tag, EventBusParams.MAIN);
|
||||
break;
|
||||
case BaseResp.ErrCode.ERR_AUTH_DENIED:
|
||||
//发送被拒绝
|
||||
Log.d("TAG", "拒绝支付");
|
||||
|
||||
HashMap<String, String> tagDenied = new HashMap<>();
|
||||
tagDenied.put("tag", "payError");
|
||||
EventBus.getDefault().post(tagDenied, EventBusParams.MAIN);
|
||||
break;
|
||||
case BaseResp.ErrCode.ERR_UNSUPPORT:
|
||||
//不支持错误
|
||||
Log.d("TAG", "不支持支付");
|
||||
HashMap<String, String> tagUnSupport = new HashMap<>();
|
||||
tagUnSupport.put("tag", "payError");
|
||||
EventBus.getDefault().post(tagUnSupport, EventBusParams.MAIN);
|
||||
break;
|
||||
default:
|
||||
//发送返回
|
||||
Log.d("TAG", "返回支付");
|
||||
break;
|
||||
}
|
||||
finish();
|
||||
|
||||
}
|
||||
}
|
||||
7
android/app/src/main/res/drawable/bg_base_dialog1.xml
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<shape xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:shape="rectangle">
|
||||
<corners android:radius="6dp" />
|
||||
<stroke android:width="1dp" android:color="#80898989"/>
|
||||
|
||||
</shape>
|
||||
16
android/app/src/main/res/drawable/bg_border_performance.xml
Normal file
|
|
@ -0,0 +1,16 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!-- shape如果不声明形状则默认为正方形 -->
|
||||
<shape xmlns:android="http://schemas.android.com/apk/res/android" >
|
||||
|
||||
<corners android:radius="3.0dp" />
|
||||
<!-- 圆角,你也可以对不同的角设置不同的数值 -->
|
||||
|
||||
<!-- <solid android:color="#F4FFF0" />-->
|
||||
<!-- 形状的填充色 -->
|
||||
|
||||
<stroke
|
||||
android:width="1dp"
|
||||
android:color="#6882A0" />
|
||||
<!-- 边框宽度和颜色 -->
|
||||
|
||||
</shape>
|
||||
16
android/app/src/main/res/drawable/bg_border_performance2.xml
Normal file
|
|
@ -0,0 +1,16 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!-- shape如果不声明形状则默认为正方形 -->
|
||||
<shape xmlns:android="http://schemas.android.com/apk/res/android" >
|
||||
|
||||
<corners android:radius="3.0dp" />
|
||||
<!-- 圆角,你也可以对不同的角设置不同的数值 -->
|
||||
|
||||
<!-- <solid android:color="#F4FFF0" />-->
|
||||
<!-- 形状的填充色 -->
|
||||
|
||||
<stroke
|
||||
android:width="1dp"
|
||||
android:color="#33FFFFFF" />
|
||||
<!-- 边框宽度和颜色 -->
|
||||
|
||||
</shape>
|
||||
12
android/app/src/main/res/drawable/bg_border_performance3.xml
Normal file
|
|
@ -0,0 +1,12 @@
|
|||
<?xml version="1.0" encoding="utf-8"?><!-- shape如果不声明形状则默认为正方形 -->
|
||||
<shape xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
|
||||
<corners
|
||||
android:bottomLeftRadius="2dp"
|
||||
android:topLeftRadius="2dp" />
|
||||
|
||||
<stroke
|
||||
android:width="1dp"
|
||||
android:color="#6882A0" />
|
||||
|
||||
</shape>
|
||||
12
android/app/src/main/res/drawable/bg_border_performance4.xml
Normal file
|
|
@ -0,0 +1,12 @@
|
|||
<?xml version="1.0" encoding="utf-8"?><!-- shape如果不声明形状则默认为正方形 -->
|
||||
<shape xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
|
||||
<corners
|
||||
android:bottomRightRadius="2dp"
|
||||
android:topRightRadius="2dp" />
|
||||
|
||||
<stroke
|
||||
android:width="1dp"
|
||||
android:color="#6882A0" />
|
||||
|
||||
</shape>
|
||||
7
android/app/src/main/res/drawable/bg_hf.xml
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<shape xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:shape="rectangle">
|
||||
<corners android:radius="3.33dp" />
|
||||
<solid android:color="#8E8F94" />
|
||||
|
||||
</shape>
|
||||
16
android/app/src/main/res/drawable/bg_play_p1.xml
Normal file
|
|
@ -0,0 +1,16 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!-- shape如果不声明形状则默认为正方形 -->
|
||||
<shape xmlns:android="http://schemas.android.com/apk/res/android" >
|
||||
|
||||
<corners android:radius="15.0dp" />
|
||||
<!-- 圆角,你也可以对不同的角设置不同的数值 -->
|
||||
|
||||
<solid android:color="#99000000" />
|
||||
<!-- 形状的填充色 -->
|
||||
|
||||
<stroke
|
||||
android:width="0.5dp"
|
||||
android:color="#FFFFFF" />
|
||||
<!-- 边框宽度和颜色 -->
|
||||
|
||||
</shape>
|
||||
7
android/app/src/main/res/drawable/button_back.xml
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<selector xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<item android:drawable="@mipmap/back_2" android:state_pressed="true" />
|
||||
<!--<item android:state_focused="false" android:drawable="@drawable/view_normal"/>-->
|
||||
<item android:drawable="@mipmap/back" />
|
||||
</selector>
|
||||
|
||||
6
android/app/src/main/res/drawable/button_down.xml
Normal file
|
|
@ -0,0 +1,6 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<selector xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<item android:state_pressed="true" android:drawable="@mipmap/down_2" />
|
||||
<!--<item android:state_focused="false" android:drawable="@drawable/view_normal"/>-->
|
||||
</selector>
|
||||
|
||||
6
android/app/src/main/res/drawable/button_left.xml
Normal file
|
|
@ -0,0 +1,6 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<selector xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<item android:state_pressed="true" android:drawable="@mipmap/left_2" />
|
||||
<!--<item android:state_focused="false" android:drawable="@drawable/view_normal"/>-->
|
||||
</selector>
|
||||
|
||||
6
android/app/src/main/res/drawable/button_play_start.xml
Normal file
|
|
@ -0,0 +1,6 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<selector xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<item android:drawable="@mipmap/start_2" android:state_pressed="true" />
|
||||
<item android:drawable="@mipmap/start" />
|
||||
</selector>
|
||||
|
||||
5
android/app/src/main/res/drawable/button_right.xml
Normal file
|
|
@ -0,0 +1,5 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<selector xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<item android:state_pressed="true" android:drawable="@mipmap/right_2" />
|
||||
</selector>
|
||||
|
||||
6
android/app/src/main/res/drawable/button_up.xml
Normal file
|
|
@ -0,0 +1,6 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<selector xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<item android:state_pressed="true" android:drawable="@mipmap/up_2" />
|
||||
<!--<item android:state_focused="false" android:drawable="@drawable/view_normal"/>-->
|
||||
</selector>
|
||||
|
||||
6
android/app/src/main/res/drawable/handle_button_ls.xml
Normal file
|
|
@ -0,0 +1,6 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<selector xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<item android:drawable="@mipmap/play_ls2" android:state_pressed="true" />
|
||||
<item android:drawable="@mipmap/play_ls" />
|
||||
</selector>
|
||||
|
||||
7
android/app/src/main/res/drawable/handle_button_lt.xml
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<selector xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<item android:state_pressed="true" android:drawable="@mipmap/play_lt2" />
|
||||
<!--<item android:state_focused="false" android:drawable="@drawable/view_normal"/>-->
|
||||
<item android:state_pressed="false" android:drawable="@mipmap/play_lt" />
|
||||
</selector>
|
||||
|
||||
6
android/app/src/main/res/drawable/keyboard_key.xml
Normal file
|
|
@ -0,0 +1,6 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<selector
|
||||
xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<item android:state_pressed="true" android:drawable="@drawable/keyboard_key_bg_c"/>
|
||||
<item android:drawable="@drawable/keyboard_key_bg"/>
|
||||
</selector>
|
||||
13
android/app/src/main/res/drawable/keyboard_key_bg.xml
Normal file
|
|
@ -0,0 +1,13 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<selector xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<item>
|
||||
<shape>
|
||||
<solid android:color="#99000000" />
|
||||
<corners android:radius="4.0dip"/>
|
||||
<!-- <stroke android:width="1.0dip" android:color="#ffffff" />
|
||||
|
||||
-->
|
||||
</shape>
|
||||
</item>
|
||||
|
||||
</selector>
|
||||
13
android/app/src/main/res/drawable/keyboard_key_bg_c.xml
Normal file
|
|
@ -0,0 +1,13 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<selector xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<item>
|
||||
<shape>
|
||||
<solid android:color="#995C5959" />
|
||||
|
||||
<!-- <stroke android:width="1.0dip" android:color="#ff888888" />-->
|
||||
|
||||
<corners android:radius="4.0dip"/>
|
||||
</shape>
|
||||
</item>
|
||||
|
||||
</selector>
|
||||
12
android/app/src/main/res/drawable/launch_background.xml
Normal file
|
|
@ -0,0 +1,12 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!-- Modify this file to customize your launch splash screen -->
|
||||
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<item android:drawable="@android:color/white" />
|
||||
|
||||
<!-- You can insert your own image assets here -->
|
||||
<!-- <item>
|
||||
<bitmap
|
||||
android:gravity="center"
|
||||
android:src="@mipmap/launch_image" />
|
||||
</item> -->
|
||||
</layer-list>
|
||||
|
|
@ -0,0 +1,12 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
|
||||
<!-- <item
|
||||
android:id="@android:id/background"
|
||||
android:drawable="@drawable/shape_progressbar_bg" />-->
|
||||
|
||||
<item android:id="@android:id/progress" android:drawable="@mipmap/loading_bar">
|
||||
<!--<clip android:drawable="@drawable/shape_progressbar_progress" />-->
|
||||
|
||||
</item>
|
||||
</layer-list>
|
||||
18
android/app/src/main/res/drawable/seek_bar_bg.xml
Normal file
|
|
@ -0,0 +1,18 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
|
||||
<item android:id="@android:id/background" >
|
||||
<shape>
|
||||
<solid android:color="#FF202530" />
|
||||
<corners android:radius="5dp"/>
|
||||
</shape>
|
||||
</item>
|
||||
<item android:id="@android:id/progress" >
|
||||
<clip>
|
||||
<shape>
|
||||
<solid android:color="#FF074CE7" />
|
||||
<corners android:radius="5dp"/>
|
||||
</shape>
|
||||
</clip>
|
||||
</item>
|
||||
</layer-list>
|
||||
21
android/app/src/main/res/drawable/select_thumb.xml
Normal file
|
|
@ -0,0 +1,21 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<selector xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<item android:state_selected="true">
|
||||
<shape android:shape="oval">
|
||||
<size android:width="24dp" android:height="24dp" />
|
||||
<solid android:color="#989696" />
|
||||
</shape>
|
||||
</item>
|
||||
<item android:state_pressed="true">
|
||||
<shape android:shape="oval">
|
||||
<size android:width="24dp" android:height="24dp" />
|
||||
<solid android:color="#989696" />
|
||||
</shape>
|
||||
</item>
|
||||
<item>
|
||||
<shape android:shape="oval">
|
||||
<size android:width="24dp" android:height="24dp" />
|
||||
<solid android:color="#FFFFFF" />
|
||||
</shape>
|
||||
</item>
|
||||
</selector>
|
||||
5
android/app/src/main/res/drawable/shap_exit_game.xml
Normal file
|
|
@ -0,0 +1,5 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<shape xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<solid android:color="#FF202530" />
|
||||
<corners android:radius="14dp" />
|
||||
</shape>
|
||||
|
|
@ -0,0 +1,5 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<shape xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<solid android:color="#FF074CE7" />
|
||||
<corners android:radius="6dp" />
|
||||
</shape>
|
||||
7
android/app/src/main/res/drawable/shape_black_bg.xml
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<shape xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
|
||||
<solid android:color="@color/tt_white" />
|
||||
<corners android:radius="14dp" />
|
||||
|
||||
</shape>
|
||||
8
android/app/src/main/res/drawable/shape_blue_bg.xml
Normal file
|
|
@ -0,0 +1,8 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<shape xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
|
||||
<solid android:color="#FF074CE7" />
|
||||
|
||||
<corners android:radius="2dp" />
|
||||
|
||||
</shape>
|
||||
10
android/app/src/main/res/drawable/shape_blue_bg1.xml
Normal file
|
|
@ -0,0 +1,10 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<shape xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
|
||||
<solid android:color="#FF074CE7" />
|
||||
|
||||
<corners
|
||||
android:bottomLeftRadius="2dp"
|
||||
android:topLeftRadius="2dp" />
|
||||
|
||||
</shape>
|
||||
10
android/app/src/main/res/drawable/shape_blue_bg2.xml
Normal file
|
|
@ -0,0 +1,10 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<shape xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
|
||||
<solid android:color="#FF074CE7" />
|
||||
|
||||
<corners
|
||||
android:bottomRightRadius="2dp"
|
||||
android:topRightRadius="2dp" />
|
||||
|
||||
</shape>
|
||||
10
android/app/src/main/res/drawable/shape_exit_game_bg.xml
Normal file
|
|
@ -0,0 +1,10 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<shape xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
|
||||
<solid android:color="#101B2C" />
|
||||
<stroke
|
||||
android:width="1dp"
|
||||
android:color="#4C688A" />
|
||||
<corners android:radius="3dp" />
|
||||
|
||||
</shape>
|
||||
10
android/app/src/main/res/drawable/shape_orange_bg.xml
Normal file
|
|
@ -0,0 +1,10 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<shape xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
|
||||
<solid android:color="#F37622" />
|
||||
|
||||
<corners
|
||||
android:bottomLeftRadius="2dp"
|
||||
android:topRightRadius="2dp" />
|
||||
|
||||
</shape>
|
||||
|
|
@ -0,0 +1,11 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<shape xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
|
||||
|
||||
<stroke
|
||||
android:width="0.67dp"
|
||||
android:color="#6882A0" />
|
||||
|
||||
<corners android:radius="2dp" />
|
||||
|
||||
</shape>
|
||||
10
android/app/src/main/res/drawable/shape_return_app_bg.xml
Normal file
|
|
@ -0,0 +1,10 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<shape xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
|
||||
<solid android:color="#1C283E" />
|
||||
<stroke
|
||||
android:width="1dp"
|
||||
android:color="#4C688A" />
|
||||
<corners android:radius="3dp" />
|
||||
|
||||
</shape>
|
||||
10
android/app/src/main/res/drawable/shape_set_item_bg.xml
Normal file
|
|
@ -0,0 +1,10 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<shape xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
|
||||
<solid android:color="#FF074CE7" />
|
||||
|
||||
<corners
|
||||
android:bottomRightRadius="4dp"
|
||||
android:topRightRadius="4dp" />
|
||||
|
||||
</shape>
|
||||
464
android/app/src/main/res/layout/activity_game.xml
Normal file
|
|
@ -0,0 +1,464 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:id="@+id/content"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:background="#000000">
|
||||
|
||||
<co.steamcloud.cargame.GameFrameLayOut
|
||||
android:id="@+id/video_renderer_layout"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="0dp"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintLeft_toLeftOf="parent"
|
||||
app:layout_constraintRight_toRightOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent">
|
||||
|
||||
|
||||
<com.zjrx.jyengine.JySurfaceView
|
||||
android:id="@+id/video_render"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_gravity="center" />
|
||||
|
||||
<SurfaceView
|
||||
android:id="@+id/video_render_legacy"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_gravity="center"
|
||||
android:visibility="visible"
|
||||
tools:visibility="visible" />
|
||||
</co.steamcloud.cargame.GameFrameLayOut>
|
||||
|
||||
<RelativeLayout
|
||||
android:id="@+id/qosLayout"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginStart="50dp"
|
||||
android:layout_marginTop="50dp"
|
||||
android:visibility="gone"
|
||||
app:layout_constraintLeft_toLeftOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/qosTextView"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:textColor="#00FF00"
|
||||
android:textSize="11sp" />
|
||||
|
||||
</RelativeLayout>
|
||||
|
||||
<FrameLayout
|
||||
android:id="@+id/MNKeyboard"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="0dp"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintLeft_toLeftOf="parent"
|
||||
app:layout_constraintRight_toRightOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent" />
|
||||
|
||||
<FrameLayout
|
||||
android:id="@+id/NetworkKeyboard"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="0dp"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintLeft_toLeftOf="parent"
|
||||
app:layout_constraintRight_toRightOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent">
|
||||
|
||||
<FrameLayout
|
||||
android:id="@+id/NetworkCursor"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_gravity="center">
|
||||
|
||||
<co.steamcloud.cargame.MyButton
|
||||
android:id="@+id/imageCursor"
|
||||
android:layout_width="25dp"
|
||||
android:layout_height="25dp"
|
||||
android:background="@drawable/cursor"
|
||||
android:visibility="gone" />
|
||||
</FrameLayout>
|
||||
|
||||
|
||||
</FrameLayout>
|
||||
|
||||
<android.inputmethodservice.KeyboardView
|
||||
android:id="@+id/keyboard_view"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_alignParentBottom="true"
|
||||
android:layout_marginBottom="1dp"
|
||||
android:background="#00FFFFFF"
|
||||
android:focusable="true"
|
||||
android:focusableInTouchMode="true"
|
||||
android:keyBackground="@drawable/keyboard_key"
|
||||
android:keyTextColor="#FFFFFF"
|
||||
android:visibility="gone"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintLeft_toLeftOf="parent"
|
||||
app:layout_constraintRight_toRightOf="parent" />
|
||||
|
||||
<!--<Button
|
||||
android:id="@+id/keyboard_text"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginBottom="80dp"
|
||||
android:visibility="gone"
|
||||
android:text=""
|
||||
app:layout_constraintBottom_toTopOf="@+id/keyboard_view"
|
||||
app:layout_constraintLeft_toLeftOf="parent"
|
||||
app:layout_constraintRight_toRightOf="parent" />-->
|
||||
|
||||
|
||||
<androidx.constraintlayout.widget.ConstraintLayout
|
||||
android:id="@+id/menu"
|
||||
android:layout_width="178dp"
|
||||
android:layout_height="267dp"
|
||||
android:layout_marginRight="50dp"
|
||||
android:layout_marginBottom="20dp"
|
||||
android:background="@drawable/bg_play_p1"
|
||||
android:visibility="gone"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintRight_toRightOf="parent">
|
||||
|
||||
<View
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="0.5dp"
|
||||
android:layout_marginTop="89dp"
|
||||
android:background="#fff"
|
||||
app:layout_constraintLeft_toLeftOf="parent"
|
||||
app:layout_constraintRight_toRightOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent" />
|
||||
|
||||
<View
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="0.5dp"
|
||||
android:layout_marginBottom="89dp"
|
||||
android:background="#fff"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintLeft_toLeftOf="parent"
|
||||
app:layout_constraintRight_toRightOf="parent" />
|
||||
|
||||
<View
|
||||
android:layout_width="0.5dp"
|
||||
android:layout_height="0dp"
|
||||
android:layout_marginLeft="89dp"
|
||||
android:background="#fff"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintLeft_toLeftOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent" />
|
||||
|
||||
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||
|
||||
<co.steamcloud.cargame.MyButton
|
||||
android:id="@+id/menu_set"
|
||||
android:layout_width="33dp"
|
||||
android:layout_height="33dp"
|
||||
android:layout_marginStart="12dp"
|
||||
android:layout_marginTop="12dp"
|
||||
android:background="@mipmap/img_setting"
|
||||
app:layout_constraintLeft_toLeftOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent" />
|
||||
|
||||
<co.steamcloud.cargame.MyButton
|
||||
android:id="@+id/Move_show_hide"
|
||||
android:layout_width="33dp"
|
||||
android:layout_height="33dp"
|
||||
android:layout_marginStart="12dp"
|
||||
android:layout_marginTop="60dp"
|
||||
android:background="@mipmap/ic_key_hide"
|
||||
android:gravity="center_vertical"
|
||||
android:paddingStart="23dp"
|
||||
android:textColor="#FFFFFF"
|
||||
android:textSize="12sp"
|
||||
app:layout_constraintLeft_toLeftOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent"
|
||||
tools:ignore="RtlSymmetry" />
|
||||
|
||||
|
||||
<!-- <TextView-->
|
||||
<!-- android:id="@+id/wifi"-->
|
||||
<!-- android:layout_width="wrap_content"-->
|
||||
<!-- android:layout_height="wrap_content"-->
|
||||
<!-- android:layout_marginTop="10dp"-->
|
||||
<!-- android:layout_marginRight="60dp"-->
|
||||
<!-- android:drawableLeft="@mipmap/wifi_1"-->
|
||||
<!-- android:drawablePadding="3dp"-->
|
||||
<!-- android:text="0ms"-->
|
||||
<!-- android:textColor="#90FF7E"-->
|
||||
<!-- android:visibility="gone"-->
|
||||
<!-- app:layout_constraintRight_toRightOf="parent"-->
|
||||
<!-- app:layout_constraintTop_toTopOf="parent" />-->
|
||||
|
||||
|
||||
<androidx.constraintlayout.widget.ConstraintLayout
|
||||
android:id="@+id/seting"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="0dp"
|
||||
android:visibility="gone"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintLeft_toLeftOf="parent"
|
||||
app:layout_constraintRight_toRightOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent">
|
||||
|
||||
<include layout="@layout/layout_game_setting" />
|
||||
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||
|
||||
<androidx.constraintlayout.widget.ConstraintLayout
|
||||
android:id="@+id/loadingCL"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
app:layout_constraintLeft_toLeftOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent">
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/loading"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:background="#FF17181A"
|
||||
android:scaleType="centerCrop"
|
||||
app:layout_constraintLeft_toLeftOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent" />
|
||||
|
||||
<com.airbnb.lottie.LottieAnimationView
|
||||
android:id="@+id/animation_view"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintLeft_toLeftOf="parent"
|
||||
app:layout_constraintRight_toRightOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent"
|
||||
app:lottie_autoPlay="true"
|
||||
app:lottie_fileName="loading.json"
|
||||
app:lottie_loop="true" />
|
||||
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/lCLv1"
|
||||
android:layout_width="332dp"
|
||||
android:layout_height="62dp"
|
||||
android:layout_marginBottom="30dp"
|
||||
android:scaleType="fitXY"
|
||||
android:src="@mipmap/loading_bg"
|
||||
android:visibility="gone"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintLeft_toLeftOf="parent"
|
||||
app:layout_constraintRight_toRightOf="parent" />
|
||||
|
||||
<ProgressBar
|
||||
android:id="@+id/progressbar1"
|
||||
style="@android:style/Widget.ProgressBar.Horizontal"
|
||||
android:layout_width="330dp"
|
||||
android:layout_height="18dp"
|
||||
android:layout_marginBottom="2dp"
|
||||
android:max="100"
|
||||
android:progress="00"
|
||||
android:progressDrawable="@drawable/layer_list_progress_drawable_1"
|
||||
android:visibility="gone"
|
||||
app:layout_constraintBottom_toBottomOf="@+id/lCLv1"
|
||||
app:layout_constraintLeft_toLeftOf="parent"
|
||||
app:layout_constraintRight_toRightOf="parent" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/fadenum"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginStart="32dp"
|
||||
android:layout_marginBottom="22dp"
|
||||
android:src="@mipmap/percent"
|
||||
android:text="0"
|
||||
android:textColor="#fff"
|
||||
android:textSize="13sp"
|
||||
android:textStyle="bold"
|
||||
android:visibility="gone"
|
||||
app:layout_constraintBottom_toBottomOf="@+id/progressbar1"
|
||||
app:layout_constraintLeft_toLeftOf="@+id/progressbar1" />
|
||||
|
||||
<ImageView
|
||||
android:layout_width="8dp"
|
||||
android:layout_height="10dp"
|
||||
android:layout_marginStart="3dp"
|
||||
android:src="@mipmap/percent"
|
||||
android:visibility="gone"
|
||||
app:layout_constraintBottom_toBottomOf="@+id/fadenum"
|
||||
app:layout_constraintLeft_toRightOf="@+id/fadenum"
|
||||
app:layout_constraintTop_toTopOf="@+id/fadenum" />
|
||||
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||
|
||||
<View
|
||||
android:layout_width="10dp"
|
||||
android:layout_height="10dp"
|
||||
app:layout_constraintLeft_toLeftOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent" />
|
||||
|
||||
<View
|
||||
android:layout_width="10dp"
|
||||
android:layout_height="10dp"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintRight_toRightOf="parent" />
|
||||
|
||||
<androidx.constraintlayout.widget.ConstraintLayout
|
||||
android:id="@+id/custom_button"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="47.33dp"
|
||||
android:background="#4f454545"
|
||||
android:visibility="gone"
|
||||
app:layout_constraintLeft_toLeftOf="parent"
|
||||
app:layout_constraintRight_toRightOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent">
|
||||
|
||||
<!--<ImageView
|
||||
android:id="@+id/custom_button_close"
|
||||
android:layout_width="25dp"
|
||||
android:layout_height="25dp"
|
||||
android:layout_marginLeft="40dp"
|
||||
android:padding="5dp"
|
||||
android:src="@mipmap/btn_cuohao3"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintLeft_toLeftOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent" />-->
|
||||
|
||||
<TextView
|
||||
android:id="@+id/custom_button_info"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginStart="100dp"
|
||||
android:text="按住并拖动按键,可调整位置"
|
||||
android:textColor="#FF0066FF"
|
||||
android:textSize="12sp"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintLeft_toLeftOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent" />
|
||||
|
||||
|
||||
<TextView
|
||||
android:id="@+id/custom_button_close"
|
||||
android:layout_width="83dp"
|
||||
android:layout_height="32dp"
|
||||
android:layout_marginRight="61dp"
|
||||
android:background="#FF0066FF"
|
||||
android:gravity="center"
|
||||
android:text="保存"
|
||||
android:textColor="#FFFFFF"
|
||||
android:textSize="14sp"
|
||||
android:textStyle="bold"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintRight_toRightOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/custom_button_yg"
|
||||
android:layout_width="83dp"
|
||||
android:layout_height="32dp"
|
||||
android:layout_marginRight="20dp"
|
||||
android:background="#FF0066FF"
|
||||
android:gravity="center"
|
||||
android:text="右摇杆:开"
|
||||
android:textColor="#FFFFFF"
|
||||
android:textSize="14sp"
|
||||
android:textStyle="bold"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintRight_toLeftOf="@+id/custom_button_close"
|
||||
app:layout_constraintTop_toTopOf="parent" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/custom_button_default"
|
||||
android:layout_width="83dp"
|
||||
android:layout_height="32dp"
|
||||
android:layout_marginRight="20dp"
|
||||
android:background="@drawable/bg_hf"
|
||||
android:gravity="center"
|
||||
android:text="恢复默认"
|
||||
android:textColor="#FFFFFF"
|
||||
android:textSize="14sp"
|
||||
android:textStyle="bold"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintRight_toLeftOf="@+id/custom_button_yg"
|
||||
app:layout_constraintTop_toTopOf="parent" />
|
||||
|
||||
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||
|
||||
|
||||
<androidx.constraintlayout.widget.ConstraintLayout
|
||||
android:id="@+id/con_diamonds"
|
||||
android:layout_width="531.33dp"
|
||||
android:layout_height="47.33dp"
|
||||
android:background="@mipmap/diamonds_dialog_bg"
|
||||
android:visibility="gone"
|
||||
app:layout_constraintLeft_toLeftOf="parent"
|
||||
app:layout_constraintRight_toRightOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/tv_info"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginStart="23dp"
|
||||
android:text="钻石不足了,充值钻石继续畅玩!"
|
||||
android:textColor="#FFFFFF"
|
||||
android:textSize="14sp"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintLeft_toLeftOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent" />
|
||||
|
||||
<Button
|
||||
android:id="@+id/bt_recharge"
|
||||
android:layout_width="93dp"
|
||||
android:layout_height="32dp"
|
||||
android:layout_marginTop="8dp"
|
||||
android:layout_marginEnd="10dp"
|
||||
android:background="@mipmap/btn_lijichongzhi"
|
||||
android:gravity="center"
|
||||
android:textColor="#FFCC00"
|
||||
android:textSize="16sp"
|
||||
app:layout_constraintRight_toLeftOf="@id/tv_time"
|
||||
app:layout_constraintTop_toTopOf="parent" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/tv_time"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginEnd="10dp"
|
||||
android:text="剩余时长"
|
||||
android:textColor="#9F9F9F"
|
||||
android:textSize="14sp"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintRight_toLeftOf="@id/tv_count_down"
|
||||
app:layout_constraintTop_toTopOf="parent" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/tv_count_down"
|
||||
android:layout_width="71.67dp"
|
||||
android:layout_height="27.67dp"
|
||||
android:layout_marginEnd="29dp"
|
||||
android:background="@drawable/shape_black_bg"
|
||||
android:gravity="center"
|
||||
android:text="10:00"
|
||||
android:textColor="#1992F8"
|
||||
android:textSize="14sp"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintRight_toRightOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent" />
|
||||
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/img_show_hide"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginEnd="10dp"
|
||||
android:visibility="gone"
|
||||
app:layout_constraintLeft_toLeftOf="parent"
|
||||
app:layout_constraintRight_toRightOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@id/con_diamonds" />
|
||||
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||
89
android/app/src/main/res/layout/dialog_with_title.xml
Normal file
|
|
@ -0,0 +1,89 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:layout_width="320dp"
|
||||
android:layout_height="188dp"
|
||||
android:background="@drawable/shap_exit_game"
|
||||
android:orientation="vertical">
|
||||
|
||||
|
||||
<TextView
|
||||
android:id="@+id/tvTitle"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="14dp"
|
||||
android:gravity="center"
|
||||
android:textColor="@color/white"
|
||||
android:textSize="20sp"
|
||||
android:textStyle="bold"
|
||||
app:layout_constraintLeft_toLeftOf="parent"
|
||||
app:layout_constraintRight_toRightOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent"
|
||||
tools:text="" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/msgTv"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center"
|
||||
android:layout_marginTop="30dp"
|
||||
android:gravity="center"
|
||||
android:textColor="@color/white"
|
||||
android:textSize="16sp"
|
||||
app:layout_constraintLeft_toLeftOf="parent"
|
||||
app:layout_constraintRight_toRightOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@+id/tvTitle"
|
||||
tools:text="" />
|
||||
|
||||
|
||||
<Button
|
||||
android:id="@+id/cancelCallBtn"
|
||||
android:layout_width="120dp"
|
||||
android:layout_height="40dp"
|
||||
android:layout_gravity="center"
|
||||
android:layout_marginTop="30dp"
|
||||
android:layout_marginBottom="20dp"
|
||||
android:layout_weight="1"
|
||||
android:background="@drawable/bg_base_dialog1"
|
||||
android:gravity="center"
|
||||
android:text="退出游戏"
|
||||
android:textColor="#BABABA"
|
||||
android:textSize="14sp"
|
||||
android:textStyle="bold"
|
||||
app:layout_constraintLeft_toLeftOf="parent"
|
||||
app:layout_constraintRight_toLeftOf="@+id/sureBtn"
|
||||
app:layout_constraintTop_toBottomOf="@+id/msgTv" />
|
||||
|
||||
|
||||
<Button
|
||||
android:id="@+id/sureBtn"
|
||||
android:layout_width="120dp"
|
||||
android:layout_height="40dp"
|
||||
android:layout_gravity="center"
|
||||
android:layout_marginTop="30dp"
|
||||
android:layout_marginBottom="20dp"
|
||||
android:layout_weight="1"
|
||||
android:background="@drawable/shap_exit_game_cancel"
|
||||
android:gravity="center"
|
||||
android:text="取消"
|
||||
android:textColor="#FFFFFF"
|
||||
android:textSize="14sp"
|
||||
android:textStyle="bold"
|
||||
app:layout_constraintLeft_toRightOf="@+id/cancelCallBtn"
|
||||
app:layout_constraintRight_toRightOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@+id/msgTv" />
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/img_close"
|
||||
android:layout_width="40dp"
|
||||
android:layout_height="40dp"
|
||||
android:layout_marginTop="5dp"
|
||||
android:layout_marginEnd="5dp"
|
||||
android:visibility="gone"
|
||||
android:padding="10dp"
|
||||
android:src="@mipmap/btn_cuohao3"
|
||||
app:layout_constraintRight_toRightOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent" />
|
||||
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||
635
android/app/src/main/res/layout/layout_game_setting.xml
Normal file
|
|
@ -0,0 +1,635 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:background="#FF17181A"
|
||||
android:clickable="true"
|
||||
android:focusable="true">
|
||||
|
||||
|
||||
<androidx.constraintlayout.widget.ConstraintLayout
|
||||
android:id="@+id/con_one"
|
||||
android:layout_width="105dp"
|
||||
android:layout_height="match_parent"
|
||||
android:background="#FF17181A"
|
||||
android:clickable="true"
|
||||
android:focusable="true"
|
||||
app:layout_constraintLeft_toLeftOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent">
|
||||
|
||||
|
||||
<TextView
|
||||
android:id="@+id/tv_set"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="46dp"
|
||||
android:gravity="center"
|
||||
android:text="设置"
|
||||
android:textColor="#FFFFFF"
|
||||
android:textSize="18sp"
|
||||
android:textStyle="bold"
|
||||
app:layout_constraintLeft_toLeftOf="parent"
|
||||
app:layout_constraintRight_toRightOf="parent"
|
||||
tools:ignore="MissingConstraints" />
|
||||
|
||||
<View
|
||||
android:id="@+id/view_line"
|
||||
android:layout_width="1dp"
|
||||
android:layout_height="242dp"
|
||||
android:layout_marginStart="18dp"
|
||||
android:layout_marginTop="23dp"
|
||||
android:background="#FF202530"
|
||||
app:layout_constraintLeft_toLeftOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@id/tv_set" />
|
||||
|
||||
|
||||
<TextView
|
||||
android:id="@+id/set_control"
|
||||
android:layout_width="83dp"
|
||||
android:layout_height="46dp"
|
||||
android:layout_marginTop="23dp"
|
||||
android:background="@drawable/shape_set_item_bg"
|
||||
android:gravity="center"
|
||||
android:text="控制"
|
||||
android:textColor="#FFFFFF"
|
||||
android:textSize="18sp"
|
||||
app:layout_constraintLeft_toRightOf="@id/view_line"
|
||||
app:layout_constraintTop_toBottomOf="@id/tv_set" />
|
||||
|
||||
|
||||
<TextView
|
||||
android:id="@+id/set_frame"
|
||||
android:layout_width="83dp"
|
||||
android:layout_height="46dp"
|
||||
android:layout_marginTop="10dp"
|
||||
android:gravity="center"
|
||||
android:text="画面"
|
||||
android:textColor="#FFFFFF"
|
||||
android:textSize="18sp"
|
||||
app:layout_constraintLeft_toRightOf="@id/view_line"
|
||||
app:layout_constraintTop_toBottomOf="@+id/set_control" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/set_GamePad"
|
||||
android:layout_width="83dp"
|
||||
android:layout_height="46dp"
|
||||
android:layout_marginTop="10dp"
|
||||
android:gravity="center"
|
||||
android:text="手柄"
|
||||
android:textColor="#FFFFFF"
|
||||
android:textSize="18sp"
|
||||
app:layout_constraintLeft_toRightOf="@id/view_line"
|
||||
app:layout_constraintTop_toBottomOf="@+id/set_frame" />
|
||||
|
||||
|
||||
<TextView
|
||||
android:id="@+id/tv_exit_game"
|
||||
android:layout_width="77dp"
|
||||
android:layout_height="28dp"
|
||||
android:layout_marginBottom="11dp"
|
||||
android:background="@drawable/shape_exit_game_bg"
|
||||
android:gravity="center"
|
||||
android:text="退出游戏"
|
||||
android:textColor="#FFFFFF"
|
||||
android:textSize="12sp"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintLeft_toLeftOf="parent"
|
||||
app:layout_constraintRight_toRightOf="parent" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/tv_return_app"
|
||||
android:layout_width="77dp"
|
||||
android:layout_height="28dp"
|
||||
android:layout_marginBottom="11dp"
|
||||
android:background="@drawable/shape_return_app_bg"
|
||||
android:gravity="center"
|
||||
android:text="返回APP"
|
||||
android:textColor="#FFFFFF"
|
||||
android:textSize="12sp"
|
||||
android:visibility="gone"
|
||||
app:layout_constraintBottom_toTopOf="@id/tv_exit_game"
|
||||
app:layout_constraintLeft_toLeftOf="parent"
|
||||
app:layout_constraintRight_toRightOf="parent" />
|
||||
|
||||
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||
|
||||
|
||||
<androidx.constraintlayout.widget.Group
|
||||
android:id="@+id/seting_g1"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:visibility="gone"
|
||||
app:constraint_referenced_ids="src_g1" />
|
||||
|
||||
<androidx.constraintlayout.widget.Group
|
||||
android:id="@+id/seting_g2"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:visibility="visible"
|
||||
app:constraint_referenced_ids="scr_g2" />
|
||||
|
||||
<androidx.constraintlayout.widget.Group
|
||||
android:id="@+id/seting_g3"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:visibility="gone"
|
||||
app:constraint_referenced_ids="scr_g3" />
|
||||
|
||||
<!--g1-->
|
||||
<ScrollView
|
||||
android:id="@+id/src_g1"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_marginStart="105dp"
|
||||
android:layout_marginTop="70dp"
|
||||
app:layout_constraintLeft_toLeftOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent">
|
||||
|
||||
<androidx.constraintlayout.widget.ConstraintLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content">
|
||||
|
||||
|
||||
<TextView
|
||||
android:id="@+id/operation2"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginLeft="38dp"
|
||||
android:text="清晰度"
|
||||
android:textColor="#FFA2A2A2"
|
||||
android:textSize="15sp"
|
||||
app:layout_constraintBottom_toBottomOf="@id/set_control"
|
||||
app:layout_constraintLeft_toLeftOf="parent"
|
||||
app:layout_constraintTop_toTopOf="@id/set_control"
|
||||
tools:ignore="NotSibling" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/speed1"
|
||||
android:layout_width="76dp"
|
||||
android:layout_height="28dp"
|
||||
android:layout_marginTop="20dp"
|
||||
android:background="@drawable/bg_border_performance2"
|
||||
android:gravity="center"
|
||||
android:text="480P"
|
||||
android:textColor="#33FFFFFF"
|
||||
android:textSize="11sp"
|
||||
app:layout_constraintLeft_toLeftOf="@+id/operation2"
|
||||
app:layout_constraintTop_toBottomOf="@+id/operation2" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/speed2"
|
||||
android:layout_width="76dp"
|
||||
android:layout_height="28dp"
|
||||
android:layout_marginStart="16dp"
|
||||
android:background="@drawable/shape_blue_bg"
|
||||
android:gravity="center"
|
||||
android:text="720P"
|
||||
android:textColor="#ffffffff"
|
||||
android:textSize="11sp"
|
||||
app:layout_constraintLeft_toRightOf="@+id/speed1"
|
||||
app:layout_constraintTop_toBottomOf="@+id/operation2"
|
||||
app:layout_constraintTop_toTopOf="@id/speed1" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/speed3"
|
||||
android:layout_width="76dp"
|
||||
android:layout_height="28dp"
|
||||
android:layout_marginStart="16dp"
|
||||
android:background="@drawable/bg_border_performance2"
|
||||
android:gravity="center"
|
||||
android:text="720P 60"
|
||||
android:textColor="#33FFFFFF"
|
||||
android:textSize="11sp"
|
||||
app:layout_constraintLeft_toRightOf="@+id/speed2"
|
||||
app:layout_constraintTop_toBottomOf="@+id/operation2"
|
||||
app:layout_constraintTop_toTopOf="@id/speed1" />
|
||||
|
||||
|
||||
<TextView
|
||||
android:id="@+id/speed4"
|
||||
android:layout_width="76dp"
|
||||
android:layout_height="28dp"
|
||||
android:layout_marginStart="16dp"
|
||||
android:background="@drawable/bg_border_performance2"
|
||||
android:gravity="center"
|
||||
android:text="1080P"
|
||||
android:textColor="#33FFFFFF"
|
||||
android:textSize="11sp"
|
||||
app:layout_constraintLeft_toRightOf="@+id/speed3"
|
||||
app:layout_constraintTop_toBottomOf="@+id/operation2"
|
||||
app:layout_constraintTop_toTopOf="@id/speed1" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/speed5"
|
||||
android:layout_width="76dp"
|
||||
android:layout_height="28dp"
|
||||
android:layout_marginStart="13dp"
|
||||
android:background="@drawable/bg_border_performance2"
|
||||
android:gravity="center"
|
||||
android:text="1080P 60"
|
||||
android:textColor="#33FFFFFF"
|
||||
android:textSize="11sp"
|
||||
app:layout_constraintBottom_toBottomOf="@id/speed4"
|
||||
app:layout_constraintLeft_toRightOf="@id/speed4"
|
||||
app:layout_constraintTop_toTopOf="@id/speed1" />
|
||||
|
||||
|
||||
<TextView
|
||||
android:id="@+id/operation4"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="40dp"
|
||||
android:text="全屏显示"
|
||||
android:textColor="#FFA2A2A2"
|
||||
android:textSize="15sp"
|
||||
app:layout_constraintLeft_toLeftOf="@id/operation2"
|
||||
app:layout_constraintTop_toBottomOf="@id/speed1" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/proportion1"
|
||||
android:layout_width="68dp"
|
||||
android:layout_height="28dp"
|
||||
android:layout_marginTop="20dp"
|
||||
android:background="@drawable/shape_blue_bg"
|
||||
android:gravity="center"
|
||||
android:text="原始比列"
|
||||
android:textColor="#FFFFFF"
|
||||
android:textSize="11sp"
|
||||
app:layout_constraintLeft_toLeftOf="@+id/operation4"
|
||||
app:layout_constraintTop_toBottomOf="@+id/operation4" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/proportion2"
|
||||
android:layout_width="68dp"
|
||||
android:layout_height="28dp"
|
||||
android:layout_marginLeft="16dp"
|
||||
android:background="@drawable/bg_border_performance"
|
||||
android:gravity="center"
|
||||
android:text="拉伸全屏"
|
||||
android:textColor="#ffffff"
|
||||
android:textSize="11sp"
|
||||
app:layout_constraintLeft_toRightOf="@+id/proportion1"
|
||||
app:layout_constraintTop_toTopOf="@+id/proportion1" />
|
||||
|
||||
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||
|
||||
</ScrollView>
|
||||
|
||||
<!--g2-->
|
||||
<ScrollView
|
||||
android:id="@+id/scr_g2"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_marginStart="105dp"
|
||||
android:layout_marginTop="60dp"
|
||||
android:scrollbars="none"
|
||||
app:layout_constraintLeft_toLeftOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent">
|
||||
|
||||
<androidx.constraintlayout.widget.ConstraintLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:paddingBottom="40dp">
|
||||
|
||||
|
||||
<TextView
|
||||
android:id="@+id/operation6"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginStart="38dp"
|
||||
android:text="游戏按键模式"
|
||||
android:textColor="#FFA2A2A2"
|
||||
android:textSize="15sp"
|
||||
app:layout_constraintLeft_toLeftOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/handle1"
|
||||
android:layout_width="72dp"
|
||||
android:layout_height="28dp"
|
||||
android:layout_marginTop="16dp"
|
||||
android:background="@drawable/shape_blue_bg1"
|
||||
android:gravity="center"
|
||||
android:text="官方手柄"
|
||||
android:textColor="#ffffffff"
|
||||
android:textSize="11sp"
|
||||
app:layout_constraintLeft_toLeftOf="@id/operation6"
|
||||
app:layout_constraintTop_toBottomOf="@id/operation6" />
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/img_key_set"
|
||||
android:layout_width="28dp"
|
||||
android:layout_height="28dp"
|
||||
android:layout_marginStart="1dp"
|
||||
android:background="@drawable/shape_blue_bg2"
|
||||
android:padding="6dp"
|
||||
android:src="@mipmap/key_set"
|
||||
app:layout_constraintBottom_toBottomOf="@id/handle1"
|
||||
app:layout_constraintLeft_toRightOf="@id/handle1"
|
||||
app:layout_constraintTop_toTopOf="@id/handle1" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/handle2"
|
||||
android:layout_width="100dp"
|
||||
android:layout_height="28dp"
|
||||
android:layout_marginStart="17dp"
|
||||
android:background="@drawable/bg_border_performance"
|
||||
android:gravity="center"
|
||||
android:text="虚拟鼠标"
|
||||
android:textColor="#FFFFFFFF"
|
||||
android:textSize="11sp"
|
||||
android:visibility="visible"
|
||||
app:layout_constraintBottom_toBottomOf="@id/img_key_set"
|
||||
app:layout_constraintLeft_toRightOf="@id/img_key_set"
|
||||
app:layout_constraintTop_toTopOf="@id/img_key_set" />
|
||||
|
||||
|
||||
<TextView
|
||||
android:id="@+id/operation8"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginStart="38dp"
|
||||
android:layout_marginTop="20dp"
|
||||
android:text="鼠标模式"
|
||||
android:textColor="#FFA2A2A2"
|
||||
android:textSize="15sp"
|
||||
android:visibility="visible"
|
||||
app:layout_constraintLeft_toLeftOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@id/handle1" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/handle3"
|
||||
android:layout_width="68dp"
|
||||
android:layout_height="28dp"
|
||||
android:layout_marginTop="16dp"
|
||||
android:background="@drawable/shape_blue_bg"
|
||||
android:gravity="center"
|
||||
android:text="点击模式"
|
||||
android:textColor="#FFFFFFFF"
|
||||
android:textSize="11sp"
|
||||
android:visibility="visible"
|
||||
app:layout_constraintLeft_toLeftOf="@id/operation8"
|
||||
app:layout_constraintTop_toBottomOf="@id/operation8" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/handle4"
|
||||
android:layout_width="68dp"
|
||||
android:layout_height="28dp"
|
||||
android:layout_marginLeft="16dp"
|
||||
android:background="@drawable/bg_border_performance"
|
||||
android:gravity="center"
|
||||
android:text="滑屏点击"
|
||||
android:textColor="#FFFFFFFF"
|
||||
android:textSize="11sp"
|
||||
android:visibility="visible"
|
||||
app:layout_constraintLeft_toRightOf="@+id/handle3"
|
||||
app:layout_constraintTop_toTopOf="@+id/handle3" />
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/ll_dip"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="20dp"
|
||||
android:gravity="center_vertical"
|
||||
android:visibility="visible"
|
||||
app:layout_constraintLeft_toLeftOf="@+id/handle1"
|
||||
app:layout_constraintTop_toBottomOf="@+id/handle4">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/tv_sensitivity"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="25dp"
|
||||
android:gravity="center"
|
||||
android:text="鼠标灵敏度"
|
||||
android:textColor="#FFA2A2A2"
|
||||
android:textSize="15sp" />
|
||||
|
||||
<SeekBar
|
||||
android:id="@+id/sk_dpi"
|
||||
android:layout_width="260dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginStart="20dp"
|
||||
android:max="10"
|
||||
android:maxHeight="4dp"
|
||||
android:min="1"
|
||||
android:paddingStart="12dp"
|
||||
android:paddingEnd="12dp"
|
||||
android:progress="3"
|
||||
android:progressDrawable="@drawable/seek_bar_bg"
|
||||
android:thumb="@mipmap/select_thumb" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/tv_dpi"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginStart="10dp"
|
||||
android:text="3"
|
||||
android:textColor="#FFFFFF"
|
||||
android:textSize="18sp" />
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/ll_dip2"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="34dp"
|
||||
android:gravity="center_vertical"
|
||||
app:layout_constraintLeft_toLeftOf="@id/ll_dip"
|
||||
app:layout_constraintTop_toBottomOf="@+id/ll_dip">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/tv_sensitivity2"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="25dp"
|
||||
android:gravity="center"
|
||||
android:text="滑屏灵敏度"
|
||||
android:textColor="#FFA2A2A2"
|
||||
android:textSize="15sp" />
|
||||
|
||||
<SeekBar
|
||||
android:id="@+id/sk_dpi2"
|
||||
android:layout_width="260dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginStart="20dp"
|
||||
android:max="10"
|
||||
android:maxHeight="4dp"
|
||||
android:min="1"
|
||||
android:paddingStart="12dp"
|
||||
android:paddingEnd="12dp"
|
||||
android:progress="6"
|
||||
android:progressDrawable="@drawable/seek_bar_bg"
|
||||
android:thumb="@mipmap/select_thumb" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/tv_dpi2"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginStart="10dp"
|
||||
android:text="6"
|
||||
android:textColor="#FFFFFF"
|
||||
android:textSize="18sp" />
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
<TextView
|
||||
android:id="@+id/tv_show_key"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="34dp"
|
||||
android:text="显示虚拟按键"
|
||||
android:textColor="#FFA2A2A2"
|
||||
android:textSize="15sp"
|
||||
app:layout_constraintLeft_toLeftOf="@id/handle1"
|
||||
app:layout_constraintTop_toBottomOf="@id/ll_dip2" />
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/img_switch_key"
|
||||
android:layout_width="42dp"
|
||||
android:layout_height="36dp"
|
||||
android:layout_marginStart="23dp"
|
||||
android:src="@mipmap/switch_open"
|
||||
app:layout_constraintBottom_toBottomOf="@id/tv_show_key"
|
||||
app:layout_constraintLeft_toRightOf="@id/tv_show_key"
|
||||
app:layout_constraintTop_toTopOf="@id/tv_show_key" />
|
||||
|
||||
|
||||
<TextView
|
||||
android:id="@+id/tv_right_rocker"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginStart="66dp"
|
||||
android:text="右摇杆隐藏"
|
||||
android:textColor="#FFA2A2A2"
|
||||
android:textSize="15sp"
|
||||
app:layout_constraintBottom_toBottomOf="@id/img_switch_key"
|
||||
app:layout_constraintLeft_toRightOf="@id/img_switch_key"
|
||||
app:layout_constraintTop_toTopOf="@id/img_switch_key" />
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/img_switch_right_rocker"
|
||||
android:layout_width="42dp"
|
||||
android:layout_height="36dp"
|
||||
android:layout_marginStart="23dp"
|
||||
android:src="@mipmap/switch_close"
|
||||
app:layout_constraintBottom_toBottomOf="@id/tv_right_rocker"
|
||||
app:layout_constraintLeft_toRightOf="@id/tv_right_rocker"
|
||||
app:layout_constraintTop_toTopOf="@id/tv_right_rocker" />
|
||||
|
||||
|
||||
<TextView
|
||||
android:id="@+id/tv_show_keyboard"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="34dp"
|
||||
android:text="文字输入键盘"
|
||||
android:textColor="#FFA2A2A2"
|
||||
android:textSize="15sp"
|
||||
app:layout_constraintLeft_toLeftOf="@id/tv_show_key"
|
||||
app:layout_constraintTop_toBottomOf="@id/tv_show_key" />
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/img_switch_keyboard"
|
||||
android:layout_width="42dp"
|
||||
android:layout_height="36dp"
|
||||
android:layout_marginStart="23dp"
|
||||
android:src="@mipmap/switch_close"
|
||||
app:layout_constraintBottom_toBottomOf="@id/tv_show_keyboard"
|
||||
app:layout_constraintLeft_toRightOf="@id/tv_show_keyboard"
|
||||
app:layout_constraintTop_toTopOf="@id/tv_show_keyboard" />
|
||||
|
||||
|
||||
<TextView
|
||||
android:id="@+id/tv_shock"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="按键震动"
|
||||
android:textColor="#FFA2A2A2"
|
||||
android:textSize="15sp"
|
||||
app:layout_constraintLeft_toLeftOf="@id/tv_right_rocker"
|
||||
app:layout_constraintTop_toTopOf="@id/tv_show_keyboard" />
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/img_switch_shock"
|
||||
android:layout_width="42dp"
|
||||
android:layout_height="36dp"
|
||||
android:src="@mipmap/switch_open"
|
||||
app:layout_constraintBottom_toBottomOf="@id/tv_shock"
|
||||
app:layout_constraintLeft_toLeftOf="@id/img_switch_right_rocker"
|
||||
app:layout_constraintTop_toTopOf="@id/tv_shock" />
|
||||
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||
|
||||
</ScrollView>
|
||||
|
||||
<!--g3-->
|
||||
<ScrollView
|
||||
android:id="@+id/scr_g3"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_marginStart="105dp"
|
||||
android:layout_marginTop="60dp"
|
||||
android:scrollbars="none"
|
||||
app:layout_constraintLeft_toLeftOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent">
|
||||
|
||||
<androidx.constraintlayout.widget.ConstraintLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:paddingBottom="40dp">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/tv_game_pad"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="模拟手柄"
|
||||
android:textColor="@color/white"
|
||||
android:textSize="20dp"
|
||||
app:layout_constraintLeft_toLeftOf="parent"
|
||||
app:layout_constraintRight_toRightOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent" />
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/img_qr"
|
||||
android:layout_width="200dp"
|
||||
android:layout_height="200dp"
|
||||
android:layout_marginTop="20dp"
|
||||
app:layout_constraintLeft_toLeftOf="parent"
|
||||
app:layout_constraintRight_toRightOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@id/tv_game_pad" />
|
||||
|
||||
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||
|
||||
</ScrollView>
|
||||
|
||||
|
||||
<TextView
|
||||
android:id="@+id/wifi"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginRight="23dp"
|
||||
android:layout_marginBottom="22dp"
|
||||
android:drawableLeft="@mipmap/wifi_1"
|
||||
android:drawablePadding="3dp"
|
||||
android:text="0ms"
|
||||
android:textColor="#41FB00"
|
||||
android:textSize="18sp"
|
||||
android:visibility="visible"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintRight_toRightOf="parent" />
|
||||
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/close_set"
|
||||
android:layout_width="80dp"
|
||||
android:layout_height="60dp"
|
||||
android:padding="10dp"
|
||||
android:src="@mipmap/btn_cuohao"
|
||||
app:layout_constraintRight_toRightOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent" />
|
||||
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||
367
android/app/src/main/res/layout/layout_handle.xml
Normal file
|
|
@ -0,0 +1,367 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
android:id="@+id/handle"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:descendantFocusability="blocksDescendants">
|
||||
|
||||
<Button
|
||||
android:id="@+id/select"
|
||||
android:layout_width="88dp"
|
||||
android:layout_height="27dp"
|
||||
android:background="@mipmap/conceal"
|
||||
android:gravity="center"
|
||||
android:visibility="gone"
|
||||
app:layout_constraintLeft_toLeftOf="parent"
|
||||
app:layout_constraintRight_toRightOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent" />
|
||||
|
||||
<androidx.constraintlayout.widget.ConstraintLayout
|
||||
android:id="@+id/HandleCL"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
app:layout_constraintLeft_toLeftOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent">
|
||||
|
||||
<FrameLayout
|
||||
android:id="@+id/visual_angle"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="0dp"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintHorizontal_bias="1.0"
|
||||
app:layout_constraintLeft_toLeftOf="parent"
|
||||
app:layout_constraintRight_toRightOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent"
|
||||
app:layout_constraintVertical_bias="1.0" />
|
||||
|
||||
<co.steamcloud.cargame.MoveButton
|
||||
android:id="@+id/yaogan_left"
|
||||
android:layout_width="135dp"
|
||||
android:layout_height="135dp"
|
||||
app:layout_constraintLeft_toLeftOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent">
|
||||
|
||||
<ImageView
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:padding="5dp"
|
||||
android:src="@mipmap/joystick" />
|
||||
|
||||
<co.steamcloud.cargame.JoystickView2
|
||||
android:id="@+id/joystick_left"
|
||||
android:layout_width="135dp"
|
||||
android:layout_height="135dp"
|
||||
android:layout_centerInParent="true" />
|
||||
</co.steamcloud.cargame.MoveButton>
|
||||
|
||||
<co.steamcloud.cargame.MoveButton
|
||||
android:id="@+id/direction_key"
|
||||
android:layout_width="95dp"
|
||||
android:layout_height="95dp"
|
||||
android:background="@mipmap/direction_bg"
|
||||
app:layout_constraintLeft_toLeftOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent">
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/dpad_up"
|
||||
android:layout_width="40dp"
|
||||
android:layout_height="40dp"
|
||||
android:layout_centerHorizontal="true"
|
||||
android:src="@drawable/button_up" />
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/dpad_left"
|
||||
android:layout_width="40dp"
|
||||
android:layout_height="40dp"
|
||||
android:layout_centerVertical="true"
|
||||
android:src="@drawable/button_left" />
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/dpad_right"
|
||||
android:layout_width="40dp"
|
||||
android:layout_height="40dp"
|
||||
android:layout_alignParentEnd="true"
|
||||
android:layout_centerVertical="true"
|
||||
android:src="@drawable/button_right" />
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/dpad_down"
|
||||
android:layout_width="40dp"
|
||||
android:layout_height="40dp"
|
||||
android:layout_alignParentBottom="true"
|
||||
android:layout_centerHorizontal="true"
|
||||
android:src="@drawable/button_down" />
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/dpad_up_left"
|
||||
android:layout_width="35dp"
|
||||
android:layout_height="35dp"
|
||||
android:layout_above="@+id/dpad_left"
|
||||
android:layout_toStartOf="@+id/dpad_up" />
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/dpad_up_right"
|
||||
android:layout_width="35dp"
|
||||
android:layout_height="35dp"
|
||||
android:layout_above="@+id/dpad_right"
|
||||
android:layout_toEndOf="@+id/dpad_up" />
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/dpad_down_left"
|
||||
android:layout_width="35dp"
|
||||
android:layout_height="35dp"
|
||||
android:layout_below="@+id/dpad_left"
|
||||
android:layout_toStartOf="@+id/dpad_down" />
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/dpad_down_right"
|
||||
android:layout_width="35dp"
|
||||
android:layout_height="35dp"
|
||||
android:layout_below="@+id/dpad_right"
|
||||
android:layout_toEndOf="@+id/dpad_down" />
|
||||
</co.steamcloud.cargame.MoveButton>
|
||||
|
||||
<co.steamcloud.cargame.MoveButton
|
||||
android:id="@+id/yaogan_right"
|
||||
android:layout_width="100dp"
|
||||
android:layout_height="100dp"
|
||||
app:layout_constraintLeft_toLeftOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent">
|
||||
|
||||
<ImageView
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:padding="5dp"
|
||||
android:src="@mipmap/joystick" />
|
||||
|
||||
<co.steamcloud.cargame.JoystickView2
|
||||
android:id="@+id/joystick_right"
|
||||
android:layout_width="100dp"
|
||||
android:layout_height="100dp"
|
||||
android:layout_centerInParent="true" />
|
||||
</co.steamcloud.cargame.MoveButton>
|
||||
|
||||
<co.steamcloud.cargame.MoveButton
|
||||
android:id="@+id/Move_a"
|
||||
android:layout_width="52dp"
|
||||
android:layout_height="52dp"
|
||||
app:layout_constraintLeft_toLeftOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/button_a"
|
||||
android:layout_width="52dp"
|
||||
android:layout_height="52dp"
|
||||
android:background="@drawable/handle_button_ls"
|
||||
android:gravity="center"
|
||||
android:text="A"
|
||||
android:textColor="#FFFFFF"
|
||||
android:textSize="20sp" />
|
||||
</co.steamcloud.cargame.MoveButton>
|
||||
|
||||
<co.steamcloud.cargame.MoveButton
|
||||
android:id="@+id/Move_b"
|
||||
android:layout_width="52dp"
|
||||
android:layout_height="52dp"
|
||||
app:layout_constraintLeft_toLeftOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/button_b"
|
||||
android:layout_width="52dp"
|
||||
android:layout_height="52dp"
|
||||
android:background="@drawable/handle_button_ls"
|
||||
android:gravity="center"
|
||||
android:text="B"
|
||||
android:textColor="#FFFFFF"
|
||||
android:textSize="20sp" />
|
||||
|
||||
|
||||
</co.steamcloud.cargame.MoveButton>
|
||||
|
||||
|
||||
<co.steamcloud.cargame.MoveButton
|
||||
android:id="@+id/Move_x"
|
||||
android:layout_width="52dp"
|
||||
android:layout_height="52dp"
|
||||
app:layout_constraintLeft_toLeftOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/button_x"
|
||||
android:layout_width="60dp"
|
||||
android:layout_height="60dp"
|
||||
android:background="@drawable/handle_button_ls"
|
||||
android:gravity="center"
|
||||
android:text="X"
|
||||
android:textColor="#FFFFFF"
|
||||
android:textSize="20sp" />
|
||||
</co.steamcloud.cargame.MoveButton>
|
||||
|
||||
|
||||
<co.steamcloud.cargame.MoveButton
|
||||
android:id="@+id/Move_y"
|
||||
android:layout_width="52dp"
|
||||
android:layout_height="52dp"
|
||||
app:layout_constraintLeft_toLeftOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/button_y"
|
||||
android:layout_width="52dp"
|
||||
android:layout_height="52dp"
|
||||
android:layout_centerHorizontal="true"
|
||||
android:background="@drawable/handle_button_ls"
|
||||
android:gravity="center"
|
||||
android:text="Y"
|
||||
android:textColor="#FFFFFF"
|
||||
android:textSize="20sp" />
|
||||
</co.steamcloud.cargame.MoveButton>
|
||||
|
||||
|
||||
<co.steamcloud.cargame.MoveButton
|
||||
android:id="@+id/Move_rs"
|
||||
android:layout_width="48dp"
|
||||
android:layout_height="48dp"
|
||||
app:layout_constraintLeft_toLeftOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/rs"
|
||||
android:layout_width="48dp"
|
||||
android:layout_height="48dp"
|
||||
android:background="@drawable/handle_button_ls"
|
||||
android:gravity="center"
|
||||
android:text="RS"
|
||||
android:textColor="#FFFFFF"
|
||||
android:textSize="12sp" />
|
||||
</co.steamcloud.cargame.MoveButton>
|
||||
|
||||
|
||||
<co.steamcloud.cargame.MoveButton
|
||||
android:id="@+id/Move_rt"
|
||||
android:layout_width="52dp"
|
||||
android:layout_height="52dp"
|
||||
app:layout_constraintLeft_toLeftOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/rt"
|
||||
android:layout_width="52dp"
|
||||
android:layout_height="52dp"
|
||||
android:background="@drawable/handle_button_ls"
|
||||
android:gravity="center"
|
||||
android:text="RT"
|
||||
android:textColor="#FFFFFF"
|
||||
android:textSize="20sp" />
|
||||
</co.steamcloud.cargame.MoveButton>
|
||||
|
||||
<co.steamcloud.cargame.MoveButton
|
||||
android:id="@+id/Move_rb"
|
||||
android:layout_width="52dp"
|
||||
android:layout_height="52dp"
|
||||
app:layout_constraintLeft_toLeftOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/rb"
|
||||
android:layout_width="52dp"
|
||||
android:layout_height="52dp"
|
||||
android:background="@drawable/handle_button_ls"
|
||||
android:gravity="center"
|
||||
android:text="RB"
|
||||
android:textColor="#FFFFFF"
|
||||
android:textSize="16sp" />
|
||||
</co.steamcloud.cargame.MoveButton>
|
||||
|
||||
<co.steamcloud.cargame.MoveButton
|
||||
android:id="@+id/Move_lt"
|
||||
android:layout_width="52dp"
|
||||
android:layout_height="52dp"
|
||||
app:layout_constraintLeft_toLeftOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/lt"
|
||||
android:layout_width="52dp"
|
||||
android:layout_height="52dp"
|
||||
android:background="@drawable/handle_button_ls"
|
||||
android:gravity="center"
|
||||
android:text="LT"
|
||||
android:textColor="#FFFFFF"
|
||||
android:textSize="16sp" />
|
||||
</co.steamcloud.cargame.MoveButton>
|
||||
|
||||
<co.steamcloud.cargame.MoveButton
|
||||
android:id="@+id/Move_lb"
|
||||
android:layout_width="52dp"
|
||||
android:layout_height="52dp"
|
||||
app:layout_constraintLeft_toLeftOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/lb"
|
||||
android:layout_width="52dp"
|
||||
android:layout_height="52dp"
|
||||
android:background="@drawable/handle_button_ls"
|
||||
android:gravity="center"
|
||||
android:text="LB"
|
||||
android:textColor="#FFFFFF"
|
||||
android:textSize="16sp" />
|
||||
</co.steamcloud.cargame.MoveButton>
|
||||
|
||||
<co.steamcloud.cargame.MoveButton
|
||||
android:id="@+id/Move_ls"
|
||||
android:layout_width="48dp"
|
||||
android:layout_height="48dp"
|
||||
app:layout_constraintLeft_toLeftOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/ls"
|
||||
android:layout_width="48dp"
|
||||
android:layout_height="48dp"
|
||||
android:background="@drawable/handle_button_ls"
|
||||
android:gravity="center"
|
||||
android:text="LS"
|
||||
android:textColor="#FFFFFF"
|
||||
android:textSize="12sp" />
|
||||
</co.steamcloud.cargame.MoveButton>
|
||||
|
||||
<co.steamcloud.cargame.MoveButton
|
||||
android:id="@+id/Move_back"
|
||||
android:layout_width="33dp"
|
||||
android:layout_height="33dp"
|
||||
app:layout_constraintLeft_toLeftOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/back"
|
||||
android:layout_width="33dp"
|
||||
android:layout_height="33dp"
|
||||
android:background="@drawable/button_back"
|
||||
android:gravity="center_vertical" />
|
||||
|
||||
</co.steamcloud.cargame.MoveButton>
|
||||
|
||||
<co.steamcloud.cargame.MoveButton
|
||||
android:id="@+id/Move_start"
|
||||
android:layout_width="33dp"
|
||||
android:layout_height="33dp"
|
||||
app:layout_constraintLeft_toLeftOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/start"
|
||||
android:layout_width="33dp"
|
||||
android:layout_height="33dp"
|
||||
android:background="@drawable/button_play_start"
|
||||
android:gravity="center_vertical" />
|
||||
|
||||
</co.steamcloud.cargame.MoveButton>
|
||||
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||
|
||||
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||
BIN
android/app/src/main/res/mipmap-hdpi/ic_launcher.png
Normal file
|
After Width: | Height: | Size: 33 KiB |
BIN
android/app/src/main/res/mipmap-mdpi/ic_launcher.png
Normal file
|
After Width: | Height: | Size: 33 KiB |
BIN
android/app/src/main/res/mipmap-xhdpi/ic_launcher.png
Normal file
|
After Width: | Height: | Size: 33 KiB |
BIN
android/app/src/main/res/mipmap-xxhdpi/altl.png
Normal file
|
After Width: | Height: | Size: 1.4 KiB |
BIN
android/app/src/main/res/mipmap-xxhdpi/altr.png
Normal file
|
After Width: | Height: | Size: 1.5 KiB |
BIN
android/app/src/main/res/mipmap-xxhdpi/back.png
Normal file
|
After Width: | Height: | Size: 6.2 KiB |
BIN
android/app/src/main/res/mipmap-xxhdpi/back_2.png
Normal file
|
After Width: | Height: | Size: 6.4 KiB |
BIN
android/app/src/main/res/mipmap-xxhdpi/bg_base_dialog.png
Normal file
|
After Width: | Height: | Size: 34 KiB |
BIN
android/app/src/main/res/mipmap-xxhdpi/btn_cuohao.webp
Normal file
|
After Width: | Height: | Size: 2.2 KiB |
BIN
android/app/src/main/res/mipmap-xxhdpi/btn_cuohao3.png
Normal file
|
After Width: | Height: | Size: 1.1 KiB |