作者 潘达康

H5聚合调原生SDK,初步调试完成

  1 +*.iml
  2 +.gradle
  3 +/local.properties
  4 +/.idea/caches
  5 +/.idea/libraries
  6 +/.idea/modules.xml
  7 +/.idea/workspace.xml
  8 +/.idea/navEditor.xml
  9 +/.idea/assetWizardSettings.xml
  10 +.DS_Store
  11 +/build
  12 +.externalNativeBuild
  13 +.cxx
  14 +
  15 +
  16 +# Built application files
  17 +*.apk
  18 +*.ap_
  19 +
  20 +# Files for the Dalvik VM
  21 +*.dex
  22 +
  23 +# Java class files
  24 +*.class
  25 +
  26 +# Generated files
  27 +bin/
  28 +gen/
  29 +out/
  30 +
  31 +# Gradle files
  32 +.gradle/
  33 +build/
  34 +
  35 +# Local configuration file (sdk path, etc)
  36 +local.properties
  37 +
  38 +# Proguard folder generated by Eclipse
  39 +proguard/
  40 +
  41 +# Log Files
  42 +*.log
  43 +
  44 +# Android Studio Navigation editor temp files
  45 +.navigation/
  46 +
  47 +# Android Studio captures folder
  48 +captures/
  49 +
  50 +# Intellij
  51 +*.iml
  52 +
  53 +# Keystore files
  54 +*.jks
  1 +# Default ignored files
  2 +/shelf/
  3 +/workspace.xml
  1 +<?xml version="1.0" encoding="UTF-8"?>
  2 +<project version="4">
  3 + <component name="CompilerConfiguration">
  4 + <bytecodeTargetLevel target="11" />
  5 + </component>
  6 +</project>
  1 +<?xml version="1.0" encoding="UTF-8"?>
  2 +<project version="4">
  3 + <component name="GradleMigrationSettings" migrationVersion="1" />
  4 + <component name="GradleSettings">
  5 + <option name="linkedExternalProjectsSettings">
  6 + <GradleProjectSettings>
  7 + <option name="testRunner" value="GRADLE" />
  8 + <option name="distributionType" value="DEFAULT_WRAPPED" />
  9 + <option name="externalProjectPath" value="$PROJECT_DIR$" />
  10 + <option name="modules">
  11 + <set>
  12 + <option value="$PROJECT_DIR$" />
  13 + <option value="$PROJECT_DIR$/app" />
  14 + </set>
  15 + </option>
  16 + </GradleProjectSettings>
  17 + </option>
  18 + </component>
  19 +</project>
  1 +<?xml version="1.0" encoding="UTF-8"?>
  2 +<project version="4">
  3 + <component name="RemoteRepositoriesConfiguration">
  4 + <remote-repository>
  5 + <option name="id" value="central" />
  6 + <option name="name" value="Maven Central repository" />
  7 + <option name="url" value="https://repo1.maven.org/maven2" />
  8 + </remote-repository>
  9 + <remote-repository>
  10 + <option name="id" value="jboss.community" />
  11 + <option name="name" value="JBoss Community repository" />
  12 + <option name="url" value="https://repository.jboss.org/nexus/content/repositories/public/" />
  13 + </remote-repository>
  14 + <remote-repository>
  15 + <option name="id" value="MavenRepo" />
  16 + <option name="name" value="MavenRepo" />
  17 + <option name="url" value="https://repo.maven.apache.org/maven2/" />
  18 + </remote-repository>
  19 + <remote-repository>
  20 + <option name="id" value="BintrayJCenter" />
  21 + <option name="name" value="BintrayJCenter" />
  22 + <option name="url" value="https://jcenter.bintray.com/" />
  23 + </remote-repository>
  24 + <remote-repository>
  25 + <option name="id" value="Google" />
  26 + <option name="name" value="Google" />
  27 + <option name="url" value="https://dl.google.com/dl/android/maven2/" />
  28 + </remote-repository>
  29 + </component>
  30 +</project>
  1 +<?xml version="1.0" encoding="UTF-8"?>
  2 +<project version="4">
  3 + <component name="ProjectRootManager" version="2" languageLevel="JDK_11" default="true" project-jdk-name="11" project-jdk-type="JavaSDK">
  4 + <output url="file://$PROJECT_DIR$/build/classes" />
  5 + </component>
  6 + <component name="ProjectType">
  7 + <option name="id" value="Android" />
  8 + </component>
  9 +</project>
  1 +<?xml version="1.0" encoding="UTF-8"?>
  2 +<project version="4">
  3 + <component name="VcsDirectoryMappings">
  4 + <mapping directory="$PROJECT_DIR$" vcs="Git" />
  5 + </component>
  6 +</project>
  1 +plugins {
  2 + id 'com.android.application'
  3 +}
  4 +
  5 +android {
  6 + compileSdkVersion 29
  7 + buildToolsVersion "30.0.1"
  8 + aaptOptions.cruncherEnabled = false
  9 + aaptOptions.useNewCruncher = false
  10 +
  11 + defaultConfig {
  12 + applicationId "com.stss.h5sdk.demo"
  13 + minSdkVersion 23
  14 + targetSdkVersion 29
  15 + versionCode 1
  16 + versionName "1.0"
  17 + }
  18 +
  19 + buildTypes {
  20 + release {
  21 + minifyEnabled false
  22 + proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
  23 + }
  24 + }
  25 + compileOptions {
  26 + sourceCompatibility JavaVersion.VERSION_1_8
  27 + targetCompatibility JavaVersion.VERSION_1_8
  28 + }
  29 +}
  30 +
  31 +dependencies {
  32 + implementation fileTree(include: ["*.jar", "*.aar"], dir: "libs")
  33 +}
不能预览此文件类型
  1 +# Add project specific ProGuard rules here.
  2 +# You can control the set of applied configuration files using the
  3 +# proguardFiles setting in build.gradle.
  4 +#
  5 +# For more details, see
  6 +# http://developer.android.com/guide/developing/tools/proguard.html
  7 +
  8 +# If your project uses WebView with JS, uncomment the following
  9 +# and specify the fully qualified class name to the JavaScript interface
  10 +# class:
  11 +#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
  12 +# public *;
  13 +#}
  14 +
  15 +# Uncomment this to preserve the line number information for
  16 +# debugging stack traces.
  17 +#-keepattributes SourceFile,LineNumberTable
  18 +
  19 +# If you keep the line number information, uncomment this to
  20 +# hide the original source file name.
  21 +#-renamesourcefileattribute SourceFile
  1 +<?xml version="1.0" encoding="utf-8"?>
  2 +<manifest xmlns:android="http://schemas.android.com/apk/res/android"
  3 + package="com.agg.h5game">
  4 +
  5 + <uses-permission android:name="android.permission.INTERNET" />
  6 +
  7 + <application
  8 + android:name="com.agg.h5game.AggH5GameApplication"
  9 + android:allowBackup="true"
  10 + android:icon="@drawable/icon"
  11 + android:label="@string/app_name"
  12 + android:requestLegacyExternalStorage="true"
  13 + android:supportsRtl="true"
  14 + android:theme="@android:style/Theme.NoTitleBar.Fullscreen"
  15 + android:usesCleartextTraffic="true">
  16 + <activity
  17 + android:name="com.agg.h5game.AggH5SplashActivity"
  18 + android:configChanges="keyboardHidden|orientation|screenSize|screenLayout"
  19 + android:screenOrientation="portrait">
  20 + <intent-filter>
  21 + <action android:name="android.intent.action.MAIN" />
  22 + <category android:name="android.intent.category.LAUNCHER" />
  23 + </intent-filter>
  24 + </activity>
  25 + <activity
  26 + android:name="com.agg.h5game.AggH5MainActivity"
  27 + android:configChanges="keyboardHidden|orientation|screenSize|screenLayout"
  28 + android:screenOrientation="sensorLandscape" />
  29 +
  30 + <meta-data
  31 + android:name="GAME_ID"
  32 + android:value="1" />
  33 + <meta-data
  34 + android:name="CLIENT_ID"
  35 + android:value="1" />
  36 + <meta-data
  37 + android:name="h5game"
  38 + android:value="https://cdn.7277.cn/unite/h5sdk/710/1/sdk.html" />
  39 + </application>
  40 +</manifest>
  1 +stss_channel=1
  2 +stss_gameId=1
  3 +stss_appKey=987654321
  4 +stss_ORIENTATION=landscape
  5 +stss_logcat = 1
  1 +package com.agg.h5game;
  2 +
  3 +import android.webkit.JavascriptInterface;
  4 +
  5 +import com.agg.h5game.tools.AggH5Log;
  6 +
  7 +public class AggH5AndroidToJs extends Object {
  8 + @JavascriptInterface
  9 + public void roleCreate(String roleParams) {
  10 + AggH5Log.d("ZhenWan", "roleCreate " + roleParams);
  11 + }
  12 +
  13 + @JavascriptInterface
  14 + public void roleEnterGame(String roleParams) {
  15 + AggH5Log.d("ZhenWan", "roleEnterGame " + roleParams);
  16 + }
  17 +
  18 + @JavascriptInterface
  19 + public void roleUpgrade(String roleParams) {
  20 + AggH5Log.d("ZhenWan", "roleUpgrade " + roleParams);
  21 + }
  22 +
  23 + @JavascriptInterface
  24 + public void logout() {
  25 +
  26 + }
  27 +
  28 + @JavascriptInterface
  29 + public void orderAndPay(String payParams) {
  30 + AggH5Log.d("ZhenWan", "orderAndPay " + payParams);
  31 + }
  32 +}
  1 +package com.agg.h5game;
  2 +
  3 +import android.app.Application;
  4 +
  5 +import com.agg.h5game.tools.AggH5Log;
  6 +import com.stss.sdk.STSSAggApplication;
  7 +
  8 +public class AggH5GameApplication extends STSSAggApplication {
  9 + private static Application application;
  10 +
  11 + public static Application getApplication() {
  12 + return application;
  13 + }
  14 +
  15 + @Override
  16 + public void onCreate() {
  17 + super.onCreate();
  18 + AggH5Log.d("AggH5GameApplication", "app 启动");
  19 + application = this;
  20 + }
  21 +}
  1 +package com.agg.h5game;
  2 +
  3 +import android.app.Activity;
  4 +import android.content.Intent;
  5 +import android.content.pm.ActivityInfo;
  6 +import android.content.res.Configuration;
  7 +import android.net.Uri;
  8 +import android.os.Build;
  9 +import android.os.Bundle;
  10 +import android.os.Handler;
  11 +import android.text.TextUtils;
  12 +import android.view.KeyEvent;
  13 +import android.view.Window;
  14 +import android.view.WindowManager;
  15 +import android.webkit.JavascriptInterface;
  16 +import android.webkit.WebSettings;
  17 +import android.webkit.WebView;
  18 +import android.webkit.WebViewClient;
  19 +
  20 +import com.agg.h5game.tools.AggH5Log;
  21 +import com.agg.h5game.tools.AggH5Tools;
  22 +import com.agg.h5game.tools.ParamsTools;
  23 +import com.stss.sdk.InitResult;
  24 +import com.stss.sdk.PayResult;
  25 +import com.stss.sdk.STSSAggGame;
  26 +import com.stss.sdk.STSSAggSdkListener;
  27 +import com.stss.sdk.constant.STSSAggCode;
  28 +import com.stss.sdk.verify.STSSUToken;
  29 +
  30 +public class AggH5MainActivity extends Activity {
  31 + private final String TAG = "STSSAgg";
  32 + private Activity mContext;
  33 +
  34 + private WebView webView;
  35 + private String h5game = "https://m.baidu.com";
  36 + private Boolean isToLogin = false;
  37 +
  38 + private STSSUToken currToken = null;
  39 +
  40 + @Override
  41 + protected void onCreate(Bundle savedInstanceState) {
  42 + requestWindowFeature(Window.FEATURE_NO_TITLE);
  43 + Window window = getWindow();
  44 + window.clearFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS);
  45 + window.addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS);
  46 + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
  47 + window.setStatusBarColor(getResources().getColor(R.color.status_bar_color));
  48 + }
  49 + super.onCreate(savedInstanceState);
  50 + mContext = this;
  51 +
  52 + setContentView(R.layout.activity_main);
  53 + initView();
  54 + initSDK();
  55 +
  56 + String gameUrl = AggH5Tools.getMetaData(mContext, "h5game");
  57 + if (!TextUtils.isEmpty(gameUrl)) {
  58 + h5game = gameUrl;
  59 + }
  60 + String newH5Url = h5game + "?" + ParamsTools.getParams(mContext, currToken);
  61 + AggH5Log.d(TAG, newH5Url);
  62 + webView.loadUrl(newH5Url);
  63 + }
  64 +
  65 + private void initView() {
  66 + setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
  67 + webView = findViewById(R.id.webview);
  68 + webView.addJavascriptInterface(new AggH5AndroidToJs(), "AggH5Game");
  69 +
  70 + //页面缩放,适应手机屏幕
  71 + webView.getSettings().setJavaScriptEnabled(true);
  72 + webView.getSettings().setUseWideViewPort(true);
  73 + webView.getSettings().setLoadWithOverviewMode(false);
  74 + webView.getSettings().setDomStorageEnabled(true);
  75 + webView.getSettings().setDefaultTextEncodingName("UTF-8");
  76 + webView.getSettings().setCacheMode(WebSettings.LOAD_DEFAULT);
  77 +
  78 + //加载页面时如果不加改代码,页面会跳转到系统自带浏览器显示。
  79 + webView.setWebViewClient(new WebViewClient() {
  80 + @Override
  81 + public boolean shouldOverrideUrlLoading(WebView view, String url) {
  82 + AggH5Log.d(TAG, "url for load: " + url);
  83 + try {
  84 + if (url.endsWith("qnsdkyhxy2.html") || url.endsWith("qnsdkysxy2.html")) {
  85 + Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse(url));
  86 + startActivity(intent);
  87 + return false;
  88 + } else if (url.startsWith("http:") || url.startsWith("https:")) {
  89 + //view.loadUrl(url);
  90 + return true;
  91 + } else {
  92 + Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse(url));
  93 + startActivity(intent);
  94 + return false;
  95 + }
  96 + } catch (Exception e) {
  97 + return false;
  98 + }
  99 + }
  100 +
  101 + @Override
  102 + public void onPageFinished(WebView view, String url) {
  103 + super.onPageFinished(view, url);
  104 + AggH5Log.d(TAG, "url for finish: " + url);
  105 + login();
  106 + }
  107 + });
  108 + }
  109 +
  110 + private void initSDK() {
  111 + STSSAggGame.setSDKListener(mSdkListener);
  112 + STSSAggGame.init(mContext);
  113 + STSSAggGame.onCreate();
  114 + }
  115 +
  116 + @Override
  117 + public boolean onKeyDown(int keyCode, KeyEvent event) {
  118 + if (keyCode == KeyEvent.KEYCODE_BACK && event.getAction() == KeyEvent.ACTION_DOWN) {
  119 + STSSAggGame.exit();
  120 + }
  121 + return false;
  122 + }
  123 +
  124 + private STSSAggSdkListener mSdkListener = new STSSAggSdkListener() {
  125 + // 状态回调(一般只用于日志打印)
  126 + @Override
  127 + public void onResult(final int code, final String msg) {
  128 + super.onResult(code, msg);
  129 + AggH5Log.e(TAG, "onResult(); code=" + code + ", msg=" + msg);
  130 + switch (code) {
  131 + case STSSAggCode.CODE_INIT_SUCCESS:
  132 + AggH5Log.d(TAG, "onResult 初始化成功");
  133 + break;
  134 + case STSSAggCode.CODE_INIT_FAIL:
  135 + AggH5Log.d(TAG, "onResult 初始化失败");
  136 + break;
  137 + case STSSAggCode.CODE_LOGIN_FAIL:
  138 + AggH5Log.d(TAG, "onResult 登录失败");
  139 + break;
  140 + case STSSAggCode.CODE_LOGIN_SUCCESS:
  141 + AggH5Log.d(TAG, "onResult 登录成功");
  142 + break;
  143 + case STSSAggCode.CODE_LOGOUT_SUCCESS:
  144 + AggH5Log.d(TAG, "onResult 注销成功");
  145 + break;
  146 + case STSSAggCode.CODE_EXIT_SUCCESS:
  147 + AggH5Log.d(TAG, "onResult 退出成功");
  148 + break;
  149 + default:
  150 + break;
  151 + }
  152 + }
  153 +
  154 + // 初始化回调
  155 + @Override
  156 + public void onInitResult(InitResult result) {
  157 + super.onInitResult(result);
  158 + AggH5Log.e(TAG, "onInitResult(); result.extension=" + result.getExtension());
  159 + if (result.isSDKExit()) {
  160 + AggH5Log.d(TAG, "onInitResult->有退出框显示");
  161 + }
  162 + login();
  163 + }
  164 +
  165 + // 登录成功回调
  166 + @Override
  167 + public void onAuthResult(final STSSUToken authResult) {
  168 + super.onAuthResult(authResult);
  169 + final String msg = "UserID=" + authResult.getGame_uid() + ", Token=" + authResult.getToken();
  170 + AggH5Log.e(TAG, "onAuthResult(); " + msg);
  171 + AggH5MainActivity.this.runOnUiThread(new Runnable() {
  172 +
  173 + @Override
  174 + public void run() {
  175 + if (authResult.isSuc()) {
  176 + currToken = authResult;
  177 + runOnUiThread(new Runnable() {
  178 + @Override
  179 + public void run() {
  180 + String newH5Url = h5game + "?" + ParamsTools.getParams(mContext, currToken);
  181 + AggH5Log.d(TAG, newH5Url);
  182 + webView.loadUrl(newH5Url);
  183 + }
  184 + });
  185 + } else {
  186 + //showToast("获取Token失败");
  187 + }
  188 + }
  189 + });
  190 +
  191 + }
  192 +
  193 + // 支付回调
  194 + @Override
  195 + public void onPayResult(final PayResult result) {
  196 + super.onPayResult(result);
  197 + AggH5Log.e(TAG, "onPayResult(); result.productName=" + result.getProductName());
  198 + AggH5MainActivity.this.runOnUiThread(new Runnable() {
  199 + @Override
  200 + public void run() {
  201 + //showToast("支付成功,商品:" + result.getProductName());
  202 + }
  203 + });
  204 + }
  205 +
  206 + // 注销回调
  207 + @Override
  208 + public void onLogout() {
  209 + super.onLogout();
  210 + currToken = null;
  211 + AggH5Log.e(TAG, "onLogout();");
  212 + AggH5MainActivity.this.runOnUiThread(new Runnable() {
  213 + @Override
  214 + public void run() {
  215 + //showToast("个人中心退出帐号成功");
  216 + AggH5Log.d(TAG, "实现游戏的切换或注销帐号的流程,比如回到登陆界面");
  217 + }
  218 + });
  219 + }
  220 +
  221 + // 退出回调
  222 + @Override
  223 + public void onExitResult() {
  224 + super.onExitResult();
  225 + AggH5MainActivity.this.finish();
  226 + System.exit(0);
  227 + }
  228 + };
  229 +
  230 + private void login() {
  231 + if (!isToLogin) {
  232 + isToLogin = true;
  233 + return;
  234 + }
  235 + if (currToken != null) {
  236 + return;
  237 + }
  238 + new Handler().postDelayed(new Runnable() {
  239 + @Override
  240 + public void run() {
  241 + runOnUiThread(new Runnable() {
  242 + @Override
  243 + public void run() {
  244 + STSSAggGame.login();
  245 + }
  246 + });
  247 + }
  248 + }, 1000);
  249 + }
  250 +
  251 + @JavascriptInterface
  252 + public void logout() {
  253 + STSSAggGame.logout();
  254 + }
  255 +
  256 + @JavascriptInterface
  257 + public void exit() {
  258 + STSSAggGame.exit();
  259 + }
  260 +
  261 + public void onActivityResult(int requestCode, int resultCode, Intent data) {
  262 + STSSAggGame.onActivityResult(requestCode, resultCode, data);
  263 + super.onActivityResult(requestCode, resultCode, data);
  264 + }
  265 +
  266 + public void onStart() {
  267 + STSSAggGame.onStart();
  268 + super.onStart();
  269 + }
  270 +
  271 + public void onPause() {
  272 + STSSAggGame.onPause();
  273 + webView.onPause();
  274 + super.onPause();
  275 + }
  276 +
  277 + public void onResume() {
  278 + STSSAggGame.onResume();
  279 + webView.onResume();
  280 + super.onResume();
  281 + }
  282 +
  283 + public void onNewIntent(Intent newIntent) {
  284 + STSSAggGame.onNewIntent(newIntent);
  285 + super.onNewIntent(newIntent);
  286 + }
  287 +
  288 + public void onStop() {
  289 + STSSAggGame.onStop();
  290 + super.onStop();
  291 + }
  292 +
  293 + public void onDestroy() {
  294 + STSSAggGame.onDestroy();
  295 + super.onDestroy();
  296 + }
  297 +
  298 + public void onRestart() {
  299 + STSSAggGame.onRestart();
  300 + super.onRestart();
  301 + }
  302 +
  303 + public void onConfigurationChanged(Configuration newConfig) {
  304 + super.onConfigurationChanged(newConfig);
  305 + STSSAggGame.onConfigurationChanged(newConfig);
  306 + }
  307 +
  308 + // 如果是unity开发的游戏,需要把onBackPressed和onKeyDown注释掉
  309 + public void onBackPressed() {
  310 + AggH5Log.d(TAG, "OnBackPressed.");
  311 + STSSAggGame.onBackPressed();
  312 + STSSAggGame.exit();
  313 + // super.onBackPressed();
  314 + }
  315 +
  316 + @Override
  317 + public void onRequestPermissionsResult(int requestCode, String[] permissions, int[] grantResults) {
  318 + STSSAggGame.onRequestPermissionsResult(requestCode, permissions, grantResults);
  319 + super.onRequestPermissionsResult(requestCode, permissions, grantResults);
  320 + }
  321 +}
  1 +package com.agg.h5game;
  2 +
  3 +import android.app.Activity;
  4 +import android.content.Intent;
  5 +import android.os.Bundle;
  6 +import android.os.Handler;
  7 +import android.view.Window;
  8 +import android.view.WindowManager;
  9 +import android.widget.ImageView;
  10 +
  11 +public class AggH5SplashActivity extends Activity {
  12 + private final static int TIME = 2000; //闪屏保持的时间(毫秒计)
  13 +
  14 + @Override
  15 + protected void onCreate(Bundle savedInstanceState) {
  16 + // 隐藏标题栏
  17 + requestWindowFeature(Window.FEATURE_NO_TITLE);
  18 + // 隐藏状态栏
  19 + getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
  20 + WindowManager.LayoutParams.FLAG_FULLSCREEN);
  21 +
  22 + super.onCreate(savedInstanceState);
  23 + setContentView(R.layout.activity_splash);
  24 +
  25 + ImageView img_splash = findViewById(R.id.img_splash);
  26 + img_splash.setImageResource(R.drawable.splash);
  27 +
  28 + new Handler().postDelayed(new Runnable() {
  29 + @Override
  30 + public void run() {
  31 + Intent intent = new Intent(AggH5SplashActivity.this, AggH5MainActivity.class);
  32 + startActivity(intent);
  33 + finish();
  34 + overridePendingTransition(R.anim.alpha_in, R.anim.alpha_out);
  35 + }
  36 + }, TIME);
  37 + }
  38 +}
  1 +package com.agg.h5game.tools;
  2 +
  3 +import android.util.Log;
  4 +
  5 +public class AggH5Log {
  6 + public static boolean enable = true;
  7 + public static int LOG_LEVEL = 4;
  8 + public static String TAG = "AggH5Game";
  9 +
  10 + public static void setLogLevel(int level){
  11 + LOG_LEVEL = level;
  12 + }
  13 + public static void e(String tag, String log){
  14 + if (enable && LOG_LEVEL>=1) {
  15 + Log.e(TAG + "_" + tag, ""+log);
  16 + }
  17 + }
  18 + public static void w(String tag, String log){
  19 + if (enable && LOG_LEVEL>=2) {
  20 + Log.w(TAG + "_" + tag, ""+log);
  21 + }
  22 + }
  23 + public static void d(String tag, String log){
  24 + if (enable && LOG_LEVEL>=3) {
  25 + Log.d(TAG + "_" + tag, ""+log);
  26 + }
  27 + }
  28 + public static void i(String tag, String log){
  29 + if (enable && LOG_LEVEL>=4) {
  30 + Log.i(TAG + "_" + tag, ""+log);
  31 + }
  32 + }
  33 +}
  1 +package com.agg.h5game.tools;
  2 +
  3 +import android.content.Context;
  4 +import android.content.SharedPreferences;
  5 +import android.content.pm.ApplicationInfo;
  6 +import android.content.pm.PackageManager;
  7 +import android.text.TextUtils;
  8 +
  9 +import org.json.JSONArray;
  10 +import org.json.JSONException;
  11 +import org.json.JSONObject;
  12 +
  13 +import java.io.BufferedReader;
  14 +import java.io.IOException;
  15 +import java.io.InputStreamReader;
  16 +import java.text.SimpleDateFormat;
  17 +import java.util.Date;
  18 +import java.util.Enumeration;
  19 +import java.util.HashMap;
  20 +import java.util.Locale;
  21 +import java.util.Map;
  22 +import java.util.Properties;
  23 +import java.util.zip.ZipEntry;
  24 +import java.util.zip.ZipFile;
  25 +
  26 +public class AggH5Tools {
  27 +
  28 + // 获取Manifest.xml 中MetaData属性
  29 + public static String getMetaData(Context ctx, String key) {
  30 + try {
  31 + ApplicationInfo appInfo = ctx.getPackageManager()
  32 + .getApplicationInfo(ctx.getPackageName(),
  33 + PackageManager.GET_META_DATA);
  34 + if (appInfo != null && appInfo.metaData != null
  35 + && appInfo.metaData.containsKey(key)) {
  36 +
  37 + return "" + appInfo.metaData.get(key);
  38 + } else {
  39 + AggH5Log.e("TFSDK", "The meta-data key is not exists." + key);
  40 + }
  41 + } catch (Exception e) {
  42 + e.printStackTrace();
  43 + }
  44 + return null;
  45 + }
  46 +
  47 + /***
  48 + * 获取assets目录下文件内容
  49 + *
  50 + * @param context
  51 + * @param assetsFile
  52 + * @return
  53 + */
  54 + public static String getAssetConfigs(Context context, String assetsFile) {
  55 + InputStreamReader reader = null;
  56 + BufferedReader br = null;
  57 + try {
  58 + reader = new InputStreamReader(context.getAssets().open(assetsFile));
  59 + br = new BufferedReader(reader);
  60 +
  61 + StringBuilder sb = new StringBuilder();
  62 + String line = null;
  63 + while ((line = br.readLine()) != null) {
  64 + sb.append(line);
  65 + }
  66 +
  67 + return sb.toString();
  68 + } catch (Exception e) {
  69 + e.printStackTrace();
  70 + } finally {
  71 + if (br != null) {
  72 + try {
  73 + br.close();
  74 + br = null;
  75 + } catch (IOException e) {
  76 + e.printStackTrace();
  77 + }
  78 +
  79 + }
  80 +
  81 + if (reader != null) {
  82 + try {
  83 + reader.close();
  84 + reader = null;
  85 + } catch (IOException e) {
  86 + e.printStackTrace();
  87 + }
  88 +
  89 + }
  90 + }
  91 +
  92 + return null;
  93 +
  94 + }
  95 +
  96 + public static String getAssetsPropertiesContext(Context context, String fileName, String valueName) {
  97 + String value = "";
  98 + Properties properties = new Properties();
  99 + try {
  100 + properties.load(context.getAssets()
  101 + .open(fileName));
  102 + value = properties.getProperty(valueName);
  103 + } catch (IOException e) {
  104 + // TODO Auto-generated catch block
  105 + e.printStackTrace();
  106 + }
  107 + return value;
  108 + }
  109 +
  110 + /**
  111 + * 获取assets目录下面指定的.properties文件内容
  112 + *
  113 + * @param context
  114 + * @param assetsPropertiesFile
  115 + * @return
  116 + */
  117 + public static Map<String, String> getAssetPropConfig(Context context,
  118 + String assetsPropertiesFile) {
  119 + try {
  120 + Properties pro = new Properties();
  121 + pro.load(context.getAssets().open(assetsPropertiesFile));
  122 +
  123 + Map<String, String> result = new HashMap<String, String>();
  124 +
  125 + for (Map.Entry<Object, Object> entry : pro.entrySet()) {
  126 + String keyStr = entry.getKey().toString().trim();
  127 + String keyVal = entry.getValue().toString().trim();
  128 + if (!result.containsKey(keyStr)) {
  129 + result.put(keyStr, keyVal);
  130 + }
  131 + }
  132 +
  133 + return result;
  134 + } catch (Exception e) {
  135 + e.printStackTrace();
  136 + }
  137 +
  138 + return null;
  139 + }
  140 +
  141 + public static String getLogicChannel(Context context, String prefix) {
  142 + ApplicationInfo appInfo = context.getApplicationInfo();
  143 + String sourceDir = appInfo.sourceDir;
  144 + String targetEntryName = findTargetEntryName(sourceDir, prefix);
  145 + if (!TextUtils.isEmpty(targetEntryName)) {
  146 + // 去掉 prefix_
  147 + String replaceStr = prefix + "_";
  148 + return targetEntryName.replace(replaceStr, "");
  149 + }
  150 + return "1";
  151 + }
  152 +
  153 + private static String findTargetEntryName(String sourceDir, String prefix) {
  154 + String key = "META-INF/" + prefix;
  155 + try (ZipFile zip = new ZipFile(sourceDir)) {
  156 + Enumeration<? extends ZipEntry> entries = zip.entries();
  157 + while (entries.hasMoreElements()) {
  158 + ZipEntry entry = entries.nextElement();
  159 + String entryName = entry.getName();
  160 + if (entryName.startsWith(key)) {
  161 + return entryName;
  162 + }
  163 + }
  164 + } catch (Exception e) {
  165 + e.printStackTrace();
  166 + }
  167 + return "";
  168 + }
  169 +
  170 + /**
  171 + * 是否第一次进入APP
  172 + *
  173 + * @param context
  174 + * @return
  175 + */
  176 + public static boolean firstIn(Context context) {
  177 + SharedPreferences shared = context.getSharedPreferences("info", Context.MODE_PRIVATE);
  178 + boolean isfer = shared.getBoolean("isfer", true);
  179 + SharedPreferences.Editor editor = shared.edit();
  180 + if (isfer) {
  181 + //第一次进入
  182 + editor.putBoolean("isfer", false);
  183 + editor.commit();
  184 + return true;
  185 + } else {
  186 + //非第一次进入
  187 + return false;
  188 + }
  189 + }
  190 +
  191 + /**
  192 + * 获取时间
  193 + *
  194 + * @return 返回时间,如20170829
  195 + */
  196 + public static String getDay() {
  197 + SimpleDateFormat df = new SimpleDateFormat("yyyyMMdd", Locale.getDefault());// 设置日期格式
  198 + Date now = new Date();
  199 + String day = df.format(now);// 获取当前的日期
  200 + return day;
  201 + }
  202 +
  203 + /**
  204 + * 获取手机型号
  205 + *
  206 + * @return 手机型号
  207 + */
  208 + public static String getSystemModel() {
  209 + return android.os.Build.MODEL;
  210 + }
  211 +
  212 + public static Map<String, String> common2map(boolean is2h5) {
  213 + Map<String, String> datas = new HashMap<String, String>();
  214 + /*datas.put("game_id", ConfigInfor.gameId);
  215 + datas.put("client_id", ConfigInfor.clientId);
  216 + datas.put("dyClientId", ConfigInfor.dyClientId);
  217 + datas.put("imei", "0000-000000-0000000000000");
  218 + datas.put("oaid", ConfigInfor.oaid);
  219 + datas.put("device", AndroidTools.getDeviceInfor());
  220 + datas.put("os", "1");
  221 + datas.put("version", AndroidTools.getAndroidSDKVersion());
  222 + datas.put("sdkVersion", QNConstant.versionName);
  223 + datas.put("android_id", AndroidTools.getAndroidID(QNSdkManager.getInstance().getsApplication()));
  224 +
  225 + if (switchWithKey("is_permissAuth").equals("Y")) {
  226 + //datas.put("imei", AndroidTools.getAndroidID(QNSdkManager.getInstance().getsApplication()));
  227 + datas.put("imei", AndroidTools.getImei(QNSdkManager.getInstance().getsApplication()));
  228 + } else {
  229 + datas.put("imei", AndroidTools.getAndroidID(QNSdkManager.getInstance().getsApplication()));
  230 + }
  231 +
  232 + if (!is2h5 && QNSdkManager.getInstance().isLogin()) {
  233 + datas.put("uid", ConfigInfor.getInstance().getCurrentUserKey("uid"));
  234 + datas.put("username", ConfigInfor.getInstance().getCurrentUserKey("username"));
  235 + datas.put("token", ConfigInfor.getInstance().getCurrentUserKey("token"));
  236 + }
  237 + if (is2h5) {
  238 + datas.put("appKey", ConfigInfor.appKey);
  239 + datas.put("payJump", ConfigInfor.payJump);
  240 + datas.putAll(ConfigInfor.getInstance().swithConfigs);
  241 + }*/
  242 + return datas;
  243 + }
  244 +
  245 + public static String map2string(Map<String, String> jsondatas) {
  246 + JSONObject json = new JSONObject();
  247 + for (String key : jsondatas.keySet()) {
  248 + String value = jsondatas.get(key);
  249 + if (value == null) {
  250 + continue;
  251 + }
  252 + if (value.contains("[") && value.contains("]")) {
  253 + try {
  254 + json.put(key, new JSONArray(value));
  255 + } catch (JSONException e) {
  256 + // TODO Auto-generated catch block
  257 + e.printStackTrace();
  258 + }
  259 + } else if (value.contains("{") && value.contains("}")) {
  260 + try {
  261 + json.put(key, new JSONObject(value));
  262 + } catch (JSONException e) {
  263 + // TODO Auto-generated catch block
  264 + e.printStackTrace();
  265 + }
  266 + } else {
  267 + try {
  268 + json.put(key, jsondatas.get(key).toString());
  269 + } catch (JSONException e) {
  270 + // TODO Auto-generated catch block
  271 + e.printStackTrace();
  272 + }
  273 + }
  274 + }
  275 + return json.toString();
  276 + }
  277 +}
  1 +package com.agg.h5game.tools;
  2 +
  3 +import android.content.Context;
  4 +
  5 +import com.stss.sdk.verify.STSSUToken;
  6 +
  7 +import java.util.HashMap;
  8 +import java.util.Map;
  9 +
  10 +public class ParamsTools {
  11 + public static String getParams(Context context, STSSUToken token) {
  12 + HashMap<String, String> params = new HashMap<>();
  13 + params.put("isAppType", "Android");
  14 + params.put("cid", AggH5Tools.getLogicChannel(context, "sid"));
  15 + if (token != null) {
  16 + params.put("channel_uid", token.getChannel_uid());
  17 + params.put("game_uid", token.getGame_uid());
  18 + params.put("token", token.getToken());
  19 + params.put("extension", token.getExtension());
  20 + }
  21 + return mapToQueryString(params);
  22 + }
  23 +
  24 + public static String mapToQueryString(HashMap<String, String> map) {
  25 + StringBuilder stringBuilder = new StringBuilder();
  26 + for (Map.Entry<String, String> entry : map.entrySet()) {
  27 + if (stringBuilder.length() > 0) {
  28 + stringBuilder.append("&");
  29 + }
  30 + stringBuilder.append(entry.getKey()).append("=").append(entry.getValue());
  31 + }
  32 + return stringBuilder.toString();
  33 + }
  34 +}
  1 +package com.agg.h5game.tools.http;
  2 +
  3 +import android.app.Activity;
  4 +import android.os.AsyncTask;
  5 +
  6 +import org.json.JSONException;
  7 +import org.json.JSONObject;
  8 +
  9 +import java.io.BufferedReader;
  10 +import java.io.DataOutputStream;
  11 +import java.io.IOException;
  12 +import java.io.InputStream;
  13 +import java.io.InputStreamReader;
  14 +import java.io.UnsupportedEncodingException;
  15 +import java.net.HttpURLConnection;
  16 +import java.net.URL;
  17 +import java.net.URLEncoder;
  18 +import java.util.Comparator;
  19 +import java.util.Iterator;
  20 +import java.util.Map;
  21 +import java.util.Set;
  22 +import java.util.TreeMap;
  23 +
  24 +public class AggH5HttpUtils extends AsyncTask<String, Integer, AggH5ResResult> {
  25 + QNHttpCallBack qnHttpCallBack;
  26 + Activity activity;
  27 +
  28 + AggH5ResResult beginGetRequest(String urlAddress, String parame) {
  29 + AggH5ResResult responeResult = new AggH5ResResult(-1);
  30 + HttpURLConnection httpURLConnection = null;
  31 + try {
  32 + URL url = new URL(urlAddress);
  33 + httpURLConnection = (HttpURLConnection) url.openConnection();
  34 + httpURLConnection.setConnectTimeout(30 * 1000);
  35 + httpURLConnection.setReadTimeout(30 * 1000);
  36 + httpURLConnection.setRequestMethod("GET");
  37 + InputStream is = httpURLConnection.getInputStream();
  38 + BufferedReader br = new BufferedReader(new InputStreamReader(is,
  39 + "UTF-8"));
  40 + String response = "";
  41 + String readLine = null;
  42 + while ((readLine = br.readLine()) != null) {
  43 + response = response + readLine;
  44 + }
  45 + is.close();
  46 + br.close();
  47 + response = new String(response.getBytes(), "utf-8");
  48 + responeResult.setStatus(0);
  49 + responeResult.setResult(response);
  50 + } catch (IOException e) {
  51 + responeResult.setResult(e.getLocalizedMessage());
  52 + } finally {
  53 + if (httpURLConnection != null) {
  54 + // 释放资源
  55 + httpURLConnection.disconnect();
  56 + }
  57 + }
  58 + return responeResult;
  59 + }
  60 +
  61 + AggH5ResResult beginPostRequest(String urlAddress, String parame) {
  62 + AggH5ResResult responeResult = new AggH5ResResult(-1);
  63 + HttpURLConnection httpURLConnection = null;
  64 + try {
  65 + URL url = new URL(urlAddress);
  66 + httpURLConnection = (HttpURLConnection) url.openConnection();
  67 + httpURLConnection.setConnectTimeout(30 * 1000);
  68 + httpURLConnection.setReadTimeout(30 * 1000);
  69 + httpURLConnection.setRequestMethod("POST");
  70 + DataOutputStream data = new DataOutputStream(httpURLConnection.getOutputStream());
  71 + data.writeBytes(parame);
  72 + InputStream is = httpURLConnection.getInputStream();
  73 + BufferedReader br = new BufferedReader(new InputStreamReader(is,
  74 + "UTF-8"));
  75 + String response = "";
  76 + String readLine = null;
  77 + while ((readLine = br.readLine()) != null) {
  78 + response += readLine;
  79 + }
  80 + is.close();
  81 + br.close();
  82 + response = new String(response.getBytes(), "utf-8");
  83 +
  84 + responeResult.setStatus(0);
  85 + responeResult.setResult(response);
  86 +
  87 + } catch (IOException e) {
  88 + responeResult.setResult(e.getLocalizedMessage());
  89 + } finally {
  90 + if (httpURLConnection != null) {
  91 + // 释放资源
  92 + httpURLConnection.disconnect();
  93 + }
  94 + }
  95 + return responeResult;
  96 + }
  97 +
  98 +
  99 + String getParams(JSONObject clientData) {
  100 + if (clientData == null) {
  101 + return null;
  102 + }
  103 + String data = clientData.toString();
  104 + try {
  105 + data = URLEncoder.encode(clientData.toString(), "UTF-8");
  106 + } catch (UnsupportedEncodingException e) {
  107 + e.printStackTrace();
  108 + }
  109 + return data;
  110 + }
  111 +
  112 + /**
  113 + * 把游戏发来的数据进行处理,拼接成与服务器交互进行get请求的字符串
  114 + *
  115 + * @param data 游戏传来的数据
  116 + * @return str 返回排序过的一个字符串
  117 + */
  118 + public static String jsonToString(JSONObject data) {
  119 + JSONObject jsonObject = new JSONObject();
  120 + jsonObject = data;
  121 + Iterator<String> sIterator = jsonObject.keys();
  122 + Map<String, String> map = new TreeMap<String, String>(
  123 + new Comparator<String>() {
  124 + @Override
  125 + public int compare(String obj1, String obj2) {
  126 + return obj1.compareTo(obj2);
  127 + }
  128 + });
  129 + String str = "";
  130 + while (sIterator.hasNext()) {
  131 + // 获得key
  132 + String key = sIterator.next();
  133 + if (jsonObject.isNull(key)) {
  134 + continue;
  135 + }
  136 + // 根据key获得value, value也可以是JSONObject,JSONArray,使用对应的参数接收即可
  137 + map.put(key, jsonObject.optString(key));
  138 + }
  139 + Set<String> keySet = map.keySet();
  140 + Iterator<String> iter = keySet.iterator();
  141 + while (iter.hasNext()) {
  142 + String key = iter.next();
  143 + if (map.isEmpty()) {
  144 + continue;
  145 + }
  146 + String mapValue = map.get(key);
  147 + try {
  148 + str = str + key + "=" + URLEncoder.encode(mapValue, "UTF-8") + "&";
  149 + } catch (UnsupportedEncodingException e) {
  150 + e.printStackTrace();
  151 + }
  152 + }
  153 + return str;
  154 + }
  155 +
  156 +
  157 + /**
  158 + * 请求
  159 + */
  160 + public void connect(String urlAddress, String method, JSONObject parame,
  161 + Activity activity, QNHttpCallBack httpCallBack) {
  162 + if (method == "get") {
  163 + qnHttpCallBack = httpCallBack;
  164 + this.activity = activity;
  165 + // progressDialog = ProgressDialog.show(activity, null, null);
  166 + String client = getParams(parame);
  167 + if (urlAddress == null || urlAddress.length() == 0) {
  168 + return;
  169 + }
  170 + if (parame == null) {
  171 + this.execute(urlAddress, null, "get");
  172 + } else {
  173 + this.execute(urlAddress, client, "get");
  174 + }
  175 + } else if (method == "post") {
  176 + qnHttpCallBack = httpCallBack;
  177 + this.activity = activity;
  178 + // progressDialog = ProgressDialog.show(activity, null, null);
  179 + String client = AggH5HttpUtils.jsonToString(parame);
  180 + if (urlAddress == null || urlAddress.length() == 0) {
  181 + return;
  182 + }
  183 + if (parame == null) {
  184 + this.execute(urlAddress, null, "post");
  185 + } else {
  186 + this.execute(urlAddress, client, "post");
  187 + }
  188 + }
  189 + }
  190 +
  191 +
  192 + @Override
  193 + protected AggH5ResResult doInBackground(String... strings) {
  194 + if (strings[2] == "get") {
  195 + return beginGetRequest(strings[0], strings[1]);
  196 + } else if (strings[2] == "post") {
  197 + return beginPostRequest(strings[0], strings[1]);
  198 + }
  199 + return beginPostRequest(strings[0], strings[1]);
  200 + }
  201 +
  202 + @Override
  203 + protected void onPostExecute(AggH5ResResult result) {
  204 + super.onPostExecute(result);
  205 + if (result.getStatus() == 0) {
  206 + JSONObject rObject = null;
  207 + try {
  208 +
  209 + rObject = new JSONObject(result.getResult());
  210 + if (rObject.getInt("code") == 0) {
  211 + JSONObject jsonObject = new JSONObject();
  212 + jsonObject.put("msg", "" + rObject.optString("msg"));
  213 + qnHttpCallBack.onFailure(jsonObject);
  214 + return;
  215 + }
  216 +
  217 + if (qnHttpCallBack == null) {
  218 + return;
  219 + }
  220 + qnHttpCallBack.onSuccess(rObject);
  221 +
  222 + } catch (JSONException e) {
  223 +
  224 + JSONObject jsonObject = new JSONObject();
  225 + try {
  226 + jsonObject.put("catchMsg", result.getResult());
  227 + qnHttpCallBack.onFailure(jsonObject);
  228 + } catch (JSONException e1) {
  229 + // TODO Auto-generated catch block
  230 + e1.printStackTrace();
  231 + }
  232 +
  233 + }
  234 +
  235 + } else {
  236 + JSONObject json = new JSONObject();
  237 + try {
  238 + json.put("msg", "网络错误");
  239 + } catch (JSONException e) {
  240 + e.printStackTrace();
  241 + }
  242 + qnHttpCallBack.onFailure(json);
  243 + }
  244 + }
  245 +}
  1 +package com.agg.h5game.tools.http;
  2 +
  3 +public class AggH5ResResult {
  4 + public AggH5ResResult(int status) {
  5 + super();
  6 + this.status = status;
  7 + }
  8 +
  9 + /**
  10 + * 结果标志,0为合法结果 非0为非法结果
  11 + */
  12 + int status;
  13 +
  14 + public int getStatus() {
  15 + return status;
  16 + }
  17 +
  18 + public void setStatus(int status) {
  19 + this.status = status;
  20 + }
  21 +
  22 + /**
  23 + * 0时,里面为合法结果 非0时,里面有网络请求结果
  24 + */
  25 + String result;
  26 +
  27 + public String getResult() {
  28 + return result;
  29 + }
  30 +
  31 + public void setResult(String result) {
  32 + this.result = result;
  33 + }
  34 +}
  1 +package com.agg.h5game.tools.http;
  2 +
  3 +import org.json.JSONObject;
  4 +
  5 +public interface QNHttpCallBack {
  6 + void onSuccess(JSONObject result);
  7 + void onFailure(JSONObject result);
  8 +}
  1 +<?xml version="1.0" encoding="utf-8"?>
  2 +<set xmlns:android="http://schemas.android.com/apk/res/android">
  3 +
  4 + <alpha
  5 + android:fromAlpha = "0.0"
  6 + android:toAlpha = "1.0"
  7 + android:duration = "2000" />
  8 +
  9 +</set>
  1 +<?xml version="1.0" encoding="utf-8"?>
  2 +<set xmlns:android="http://schemas.android.com/apk/res/android">
  3 +
  4 + <alpha
  5 + android:fromAlpha = "1.0"
  6 + android:toAlpha = "0.0"
  7 + android:duration = "2000" />
  8 +
  9 +</set>
  1 +<?xml version="1.0" encoding="utf-8"?>
  2 +<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
  3 + android:layout_width="match_parent"
  4 + android:layout_height="match_parent"
  5 + android:orientation="vertical">
  6 +
  7 + <WebView
  8 + android:id="@+id/webview"
  9 + android:layout_width="match_parent"
  10 + android:layout_height="match_parent" />
  11 +</LinearLayout>
  1 +<?xml version="1.0" encoding="utf-8"?>
  2 +<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
  3 + xmlns:app="http://schemas.android.com/apk/res-auto"
  4 + android:layout_width="match_parent"
  5 + android:layout_height="match_parent"
  6 + android:orientation="vertical">
  7 +
  8 + <ImageView
  9 + android:id="@+id/img_splash"
  10 + android:layout_width="match_parent"
  11 + android:layout_height="match_parent"
  12 + android:src="@drawable/splash" />
  13 +</LinearLayout>
  1 +<?xml version="1.0" encoding="utf-8"?>
  2 +<resources>
  3 + <color name="purple_200">#FFBB86FC</color>
  4 + <color name="purple_500">#FF6200EE</color>
  5 + <color name="purple_700">#FF3700B3</color>
  6 + <color name="teal_200">#FF03DAC5</color>
  7 + <color name="teal_700">#FF018786</color>
  8 + <color name="black">#FF000000</color>
  9 + <color name="white">#FFFFFFFF</color>
  10 + <color name="status_bar_color">#fff0da</color>
  11 +</resources>
  1 +<resources>
  2 + <string name="app_name">柒玩H5聚合</string>
  3 +</resources>
  1 +<resources xmlns:tools="http://schemas.android.com/tools">
  2 + <!-- Base application theme. -->
  3 +</resources>
  1 +// Top-level build file where you can add configuration options common to all sub-projects/modules.
  2 +buildscript {
  3 + repositories {
  4 + google()
  5 + mavenCentral()
  6 + }
  7 + dependencies {
  8 + classpath 'com.android.tools.build:gradle:3.4.1'
  9 + }
  10 +}
  11 +
  12 +allprojects {
  13 + repositories {
  14 + google()
  15 + mavenCentral()
  16 + jcenter()
  17 + }
  18 +}
  19 +
  20 +task clean(type: Delete) {
  21 + delete rootProject.buildDir
  22 +}
  1 +# Project-wide Gradle settings.
  2 +# IDE (e.g. Android Studio) users:
  3 +# Gradle settings configured through the IDE *will override*
  4 +# any settings specified in this file.
  5 +# For more details on how to configure your build environment visit
  6 +# http://www.gradle.org/docs/current/userguide/build_environment.html
  7 +# Specifies the JVM arguments used for the daemon process.
  8 +# The setting is particularly useful for tweaking memory settings.
  9 +org.gradle.jvmargs=-Xmx2048m -Dfile.encoding=UTF-8
  10 +# When configured, Gradle will run in incubating parallel mode.
  11 +# This option should only be used with decoupled projects. More details, visit
  12 +# http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects
  13 +# org.gradle.parallel=true
  14 +# AndroidX package structure to make it clearer which packages are bundled with the
  15 +# Android operating system, and which are packaged with your app"s APK
  16 +# https://developer.android.com/topic/libraries/support-library/androidx-rn
  17 +android.useAndroidX=true
不能预览此文件类型
  1 +#Tue Sep 14 17:17:01 CST 2021
  2 +distributionBase=GRADLE_USER_HOME
  3 +distributionUrl=https\://services.gradle.org/distributions/gradle-5.1.1-all.zip
  4 +distributionPath=wrapper/dists
  5 +zipStorePath=wrapper/dists
  6 +zipStoreBase=GRADLE_USER_HOME
  1 +#!/usr/bin/env sh
  2 +
  3 +##############################################################################
  4 +##
  5 +## Gradle start up script for UN*X
  6 +##
  7 +##############################################################################
  8 +
  9 +# Attempt to set APP_HOME
  10 +# Resolve links: $0 may be a link
  11 +PRG="$0"
  12 +# Need this for relative symlinks.
  13 +while [ -h "$PRG" ] ; do
  14 + ls=`ls -ld "$PRG"`
  15 + link=`expr "$ls" : '.*-> \(.*\)$'`
  16 + if expr "$link" : '/.*' > /dev/null; then
  17 + PRG="$link"
  18 + else
  19 + PRG=`dirname "$PRG"`"/$link"
  20 + fi
  21 +done
  22 +SAVED="`pwd`"
  23 +cd "`dirname \"$PRG\"`/" >/dev/null
  24 +APP_HOME="`pwd -P`"
  25 +cd "$SAVED" >/dev/null
  26 +
  27 +APP_NAME="Gradle"
  28 +APP_BASE_NAME=`basename "$0"`
  29 +
  30 +# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
  31 +DEFAULT_JVM_OPTS=""
  32 +
  33 +# Use the maximum available, or set MAX_FD != -1 to use that value.
  34 +MAX_FD="maximum"
  35 +
  36 +warn () {
  37 + echo "$*"
  38 +}
  39 +
  40 +die () {
  41 + echo
  42 + echo "$*"
  43 + echo
  44 + exit 1
  45 +}
  46 +
  47 +# OS specific support (must be 'true' or 'false').
  48 +cygwin=false
  49 +msys=false
  50 +darwin=false
  51 +nonstop=false
  52 +case "`uname`" in
  53 + CYGWIN* )
  54 + cygwin=true
  55 + ;;
  56 + Darwin* )
  57 + darwin=true
  58 + ;;
  59 + MINGW* )
  60 + msys=true
  61 + ;;
  62 + NONSTOP* )
  63 + nonstop=true
  64 + ;;
  65 +esac
  66 +
  67 +CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
  68 +
  69 +# Determine the Java command to use to start the JVM.
  70 +if [ -n "$JAVA_HOME" ] ; then
  71 + if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
  72 + # IBM's JDK on AIX uses strange locations for the executables
  73 + JAVACMD="$JAVA_HOME/jre/sh/java"
  74 + else
  75 + JAVACMD="$JAVA_HOME/bin/java"
  76 + fi
  77 + if [ ! -x "$JAVACMD" ] ; then
  78 + die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
  79 +
  80 +Please set the JAVA_HOME variable in your environment to match the
  81 +location of your Java installation."
  82 + fi
  83 +else
  84 + JAVACMD="java"
  85 + which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
  86 +
  87 +Please set the JAVA_HOME variable in your environment to match the
  88 +location of your Java installation."
  89 +fi
  90 +
  91 +# Increase the maximum file descriptors if we can.
  92 +if [ "$cygwin" = "false" -a "$darwin" = "false" -a "$nonstop" = "false" ] ; then
  93 + MAX_FD_LIMIT=`ulimit -H -n`
  94 + if [ $? -eq 0 ] ; then
  95 + if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then
  96 + MAX_FD="$MAX_FD_LIMIT"
  97 + fi
  98 + ulimit -n $MAX_FD
  99 + if [ $? -ne 0 ] ; then
  100 + warn "Could not set maximum file descriptor limit: $MAX_FD"
  101 + fi
  102 + else
  103 + warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT"
  104 + fi
  105 +fi
  106 +
  107 +# For Darwin, add options to specify how the application appears in the dock
  108 +if $darwin; then
  109 + GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\""
  110 +fi
  111 +
  112 +# For Cygwin, switch paths to Windows format before running java
  113 +if $cygwin ; then
  114 + APP_HOME=`cygpath --path --mixed "$APP_HOME"`
  115 + CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
  116 + JAVACMD=`cygpath --unix "$JAVACMD"`
  117 +
  118 + # We build the pattern for arguments to be converted via cygpath
  119 + ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null`
  120 + SEP=""
  121 + for dir in $ROOTDIRSRAW ; do
  122 + ROOTDIRS="$ROOTDIRS$SEP$dir"
  123 + SEP="|"
  124 + done
  125 + OURCYGPATTERN="(^($ROOTDIRS))"
  126 + # Add a user-defined pattern to the cygpath arguments
  127 + if [ "$GRADLE_CYGPATTERN" != "" ] ; then
  128 + OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)"
  129 + fi
  130 + # Now convert the arguments - kludge to limit ourselves to /bin/sh
  131 + i=0
  132 + for arg in "$@" ; do
  133 + CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -`
  134 + CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option
  135 +
  136 + if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition
  137 + eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"`
  138 + else
  139 + eval `echo args$i`="\"$arg\""
  140 + fi
  141 + i=$((i+1))
  142 + done
  143 + case $i in
  144 + (0) set -- ;;
  145 + (1) set -- "$args0" ;;
  146 + (2) set -- "$args0" "$args1" ;;
  147 + (3) set -- "$args0" "$args1" "$args2" ;;
  148 + (4) set -- "$args0" "$args1" "$args2" "$args3" ;;
  149 + (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;;
  150 + (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;;
  151 + (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;;
  152 + (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;;
  153 + (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;;
  154 + esac
  155 +fi
  156 +
  157 +# Escape application args
  158 +save () {
  159 + for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done
  160 + echo " "
  161 +}
  162 +APP_ARGS=$(save "$@")
  163 +
  164 +# Collect all arguments for the java command, following the shell quoting and substitution rules
  165 +eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS"
  166 +
  167 +# by default we should be in the correct project dir, but when run from Finder on Mac, the cwd is wrong
  168 +if [ "$(uname)" = "Darwin" ] && [ "$HOME" = "$PWD" ]; then
  169 + cd "$(dirname "$0")"
  170 +fi
  171 +
  172 +exec "$JAVACMD" "$@"
  1 +@if "%DEBUG%" == "" @echo off
  2 +@rem ##########################################################################
  3 +@rem
  4 +@rem Gradle startup script for Windows
  5 +@rem
  6 +@rem ##########################################################################
  7 +
  8 +@rem Set local scope for the variables with windows NT shell
  9 +if "%OS%"=="Windows_NT" setlocal
  10 +
  11 +set DIRNAME=%~dp0
  12 +if "%DIRNAME%" == "" set DIRNAME=.
  13 +set APP_BASE_NAME=%~n0
  14 +set APP_HOME=%DIRNAME%
  15 +
  16 +@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
  17 +set DEFAULT_JVM_OPTS=
  18 +
  19 +@rem Find java.exe
  20 +if defined JAVA_HOME goto findJavaFromJavaHome
  21 +
  22 +set JAVA_EXE=java.exe
  23 +%JAVA_EXE% -version >NUL 2>&1
  24 +if "%ERRORLEVEL%" == "0" goto init
  25 +
  26 +echo.
  27 +echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
  28 +echo.
  29 +echo Please set the JAVA_HOME variable in your environment to match the
  30 +echo location of your Java installation.
  31 +
  32 +goto fail
  33 +
  34 +:findJavaFromJavaHome
  35 +set JAVA_HOME=%JAVA_HOME:"=%
  36 +set JAVA_EXE=%JAVA_HOME%/bin/java.exe
  37 +
  38 +if exist "%JAVA_EXE%" goto init
  39 +
  40 +echo.
  41 +echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
  42 +echo.
  43 +echo Please set the JAVA_HOME variable in your environment to match the
  44 +echo location of your Java installation.
  45 +
  46 +goto fail
  47 +
  48 +:init
  49 +@rem Get command-line arguments, handling Windows variants
  50 +
  51 +if not "%OS%" == "Windows_NT" goto win9xME_args
  52 +
  53 +:win9xME_args
  54 +@rem Slurp the command line arguments.
  55 +set CMD_LINE_ARGS=
  56 +set _SKIP=2
  57 +
  58 +:win9xME_args_slurp
  59 +if "x%~1" == "x" goto execute
  60 +
  61 +set CMD_LINE_ARGS=%*
  62 +
  63 +:execute
  64 +@rem Setup the command line
  65 +
  66 +set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
  67 +
  68 +@rem Execute Gradle
  69 +"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS%
  70 +
  71 +:end
  72 +@rem End local scope for the variables with windows NT shell
  73 +if "%ERRORLEVEL%"=="0" goto mainEnd
  74 +
  75 +:fail
  76 +rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
  77 +rem the _cmd.exe /c_ return code!
  78 +if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
  79 +exit /b 1
  80 +
  81 +:mainEnd
  82 +if "%OS%"=="Windows_NT" endlocal
  83 +
  84 +:omega
  1 +rootProject.name = "AggH5Game"
  2 +include ':app'