正在显示
12 个修改的文件
包含
179 行增加
和
287 行删除
| @@ -9,7 +9,6 @@ | @@ -9,7 +9,6 @@ | ||
| 9 | android:allowBackup="true" | 9 | android:allowBackup="true" |
| 10 | android:icon="@drawable/icon" | 10 | android:icon="@drawable/icon" |
| 11 | android:label="@string/app_name" | 11 | android:label="@string/app_name" |
| 12 | - android:requestLegacyExternalStorage="true" | ||
| 13 | android:supportsRtl="true" | 12 | android:supportsRtl="true" |
| 14 | android:theme="@android:style/Theme.NoTitleBar.Fullscreen" | 13 | android:theme="@android:style/Theme.NoTitleBar.Fullscreen" |
| 15 | android:usesCleartextTraffic="true"> | 14 | android:usesCleartextTraffic="true"> |
| @@ -25,16 +24,13 @@ | @@ -25,16 +24,13 @@ | ||
| 25 | <activity | 24 | <activity |
| 26 | android:name="com.agg.h5game.AggH5MainActivity" | 25 | android:name="com.agg.h5game.AggH5MainActivity" |
| 27 | android:configChanges="keyboardHidden|orientation|screenSize|screenLayout" | 26 | android:configChanges="keyboardHidden|orientation|screenSize|screenLayout" |
| 28 | - android:screenOrientation="sensorLandscape" /> | 27 | + android:screenOrientation="portrait" /> |
| 29 | 28 | ||
| 30 | <meta-data | 29 | <meta-data |
| 31 | - android:name="GAME_ID" | ||
| 32 | - android:value="1" /> | 30 | + android:name="android.max_aspect" |
| 31 | + android:value="2.4" /> | ||
| 33 | <meta-data | 32 | <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" /> | 33 | + android:name="stss_agg_h5game" |
| 34 | + android:value="https://cdn.kky.cn/unite/h5sdk/%s/%s/sdk.html" /> | ||
| 39 | </application> | 35 | </application> |
| 40 | </manifest> | 36 | </manifest> |
| @@ -2,31 +2,38 @@ package com.agg.h5game; | @@ -2,31 +2,38 @@ package com.agg.h5game; | ||
| 2 | 2 | ||
| 3 | import android.webkit.JavascriptInterface; | 3 | import android.webkit.JavascriptInterface; |
| 4 | 4 | ||
| 5 | -import com.agg.h5game.tools.AggH5Log; | 5 | +import com.agg.h5game.tools.ParamsTools; |
| 6 | +import com.stss.sdk.STSSAggGame; | ||
| 7 | +import com.stss.sdk.bean.STSSPayParams; | ||
| 8 | +import com.stss.sdk.bean.STSSUserExtraData; | ||
| 6 | 9 | ||
| 7 | public class AggH5AndroidToJs extends Object { | 10 | public class AggH5AndroidToJs extends Object { |
| 8 | @JavascriptInterface | 11 | @JavascriptInterface |
| 9 | public void roleCreate(String roleParams) { | 12 | public void roleCreate(String roleParams) { |
| 10 | - AggH5Log.d("ZhenWan", "roleCreate " + roleParams); | 13 | + STSSUserExtraData userExtraData = ParamsTools.jsonToSTSSUserExtraData(roleParams); |
| 14 | + STSSAggGame.roleCreate(userExtraData); | ||
| 11 | } | 15 | } |
| 12 | 16 | ||
| 13 | @JavascriptInterface | 17 | @JavascriptInterface |
| 14 | public void roleEnterGame(String roleParams) { | 18 | public void roleEnterGame(String roleParams) { |
| 15 | - AggH5Log.d("ZhenWan", "roleEnterGame " + roleParams); | 19 | + STSSUserExtraData userExtraData = ParamsTools.jsonToSTSSUserExtraData(roleParams); |
| 20 | + STSSAggGame.roleEnterGame(userExtraData); | ||
| 16 | } | 21 | } |
| 17 | 22 | ||
| 18 | @JavascriptInterface | 23 | @JavascriptInterface |
| 19 | public void roleUpgrade(String roleParams) { | 24 | public void roleUpgrade(String roleParams) { |
| 20 | - AggH5Log.d("ZhenWan", "roleUpgrade " + roleParams); | 25 | + STSSUserExtraData userExtraData = ParamsTools.jsonToSTSSUserExtraData(roleParams); |
| 26 | + STSSAggGame.roleUpdateInfor(userExtraData); | ||
| 21 | } | 27 | } |
| 22 | 28 | ||
| 23 | @JavascriptInterface | 29 | @JavascriptInterface |
| 24 | public void logout() { | 30 | public void logout() { |
| 25 | - | 31 | + STSSAggGame.exit(); |
| 26 | } | 32 | } |
| 27 | 33 | ||
| 28 | @JavascriptInterface | 34 | @JavascriptInterface |
| 29 | public void orderAndPay(String payParams) { | 35 | public void orderAndPay(String payParams) { |
| 30 | - AggH5Log.d("ZhenWan", "orderAndPay " + payParams); | 36 | + STSSPayParams params = ParamsTools.jsonToSTSSPayParams(payParams); |
| 37 | + STSSAggGame.orderAndPay(params); | ||
| 31 | } | 38 | } |
| 32 | } | 39 | } |
| 1 | package com.agg.h5game; | 1 | package com.agg.h5game; |
| 2 | 2 | ||
| 3 | import android.app.Application; | 3 | import android.app.Application; |
| 4 | +import android.content.Context; | ||
| 4 | 5 | ||
| 5 | import com.agg.h5game.tools.AggH5Log; | 6 | import com.agg.h5game.tools.AggH5Log; |
| 6 | import com.stss.sdk.STSSAggApplication; | 7 | import com.stss.sdk.STSSAggApplication; |
| 7 | 8 | ||
| 8 | public class AggH5GameApplication extends STSSAggApplication { | 9 | public class AggH5GameApplication extends STSSAggApplication { |
| 9 | private static Application application; | 10 | private static Application application; |
| 11 | + private static Context context; | ||
| 10 | 12 | ||
| 11 | public static Application getApplication() { | 13 | public static Application getApplication() { |
| 12 | return application; | 14 | return application; |
| @@ -16,6 +18,11 @@ public class AggH5GameApplication extends STSSAggApplication { | @@ -16,6 +18,11 @@ public class AggH5GameApplication extends STSSAggApplication { | ||
| 16 | public void onCreate() { | 18 | public void onCreate() { |
| 17 | super.onCreate(); | 19 | super.onCreate(); |
| 18 | AggH5Log.d("AggH5GameApplication", "app 启动"); | 20 | AggH5Log.d("AggH5GameApplication", "app 启动"); |
| 21 | + context = this; | ||
| 19 | application = this; | 22 | application = this; |
| 20 | } | 23 | } |
| 24 | + | ||
| 25 | + public static Context getContext() { | ||
| 26 | + return context; | ||
| 27 | + } | ||
| 21 | } | 28 | } |
| @@ -4,12 +4,14 @@ import android.app.Activity; | @@ -4,12 +4,14 @@ import android.app.Activity; | ||
| 4 | import android.content.Intent; | 4 | import android.content.Intent; |
| 5 | import android.content.pm.ActivityInfo; | 5 | import android.content.pm.ActivityInfo; |
| 6 | import android.content.res.Configuration; | 6 | import android.content.res.Configuration; |
| 7 | +import android.graphics.Color; | ||
| 7 | import android.net.Uri; | 8 | import android.net.Uri; |
| 8 | import android.os.Build; | 9 | import android.os.Build; |
| 9 | import android.os.Bundle; | 10 | import android.os.Bundle; |
| 10 | import android.os.Handler; | 11 | import android.os.Handler; |
| 11 | import android.text.TextUtils; | 12 | import android.text.TextUtils; |
| 12 | import android.view.KeyEvent; | 13 | import android.view.KeyEvent; |
| 14 | +import android.view.View; | ||
| 13 | import android.view.Window; | 15 | import android.view.Window; |
| 14 | import android.view.WindowManager; | 16 | import android.view.WindowManager; |
| 15 | import android.webkit.JavascriptInterface; | 17 | import android.webkit.JavascriptInterface; |
| @@ -25,27 +27,35 @@ import com.stss.sdk.PayResult; | @@ -25,27 +27,35 @@ import com.stss.sdk.PayResult; | ||
| 25 | import com.stss.sdk.STSSAggGame; | 27 | import com.stss.sdk.STSSAggGame; |
| 26 | import com.stss.sdk.STSSAggSdkListener; | 28 | import com.stss.sdk.STSSAggSdkListener; |
| 27 | import com.stss.sdk.constant.STSSAggCode; | 29 | import com.stss.sdk.constant.STSSAggCode; |
| 30 | +import com.stss.sdk.constant.STSSConstants; | ||
| 28 | import com.stss.sdk.verify.STSSUToken; | 31 | import com.stss.sdk.verify.STSSUToken; |
| 29 | 32 | ||
| 30 | public class AggH5MainActivity extends Activity { | 33 | public class AggH5MainActivity extends Activity { |
| 31 | - private final String TAG = "STSSAgg"; | 34 | + private final String TAG = "STSSAggSdk"; |
| 32 | private Activity mContext; | 35 | private Activity mContext; |
| 33 | 36 | ||
| 34 | private WebView webView; | 37 | private WebView webView; |
| 35 | - private String h5game = "https://m.baidu.com"; | 38 | + private String h5game = "https://cdn.kky.cn/unite/h5sdk/%s/%s/sdk.html"; |
| 36 | private Boolean isToLogin = false; | 39 | private Boolean isToLogin = false; |
| 37 | 40 | ||
| 38 | private STSSUToken currToken = null; | 41 | private STSSUToken currToken = null; |
| 39 | 42 | ||
| 40 | @Override | 43 | @Override |
| 41 | protected void onCreate(Bundle savedInstanceState) { | 44 | 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); | 45 | + this.getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, |
| 46 | + WindowManager.LayoutParams.FLAG_FULLSCREEN); | ||
| 47 | + this.requestWindowFeature(Window.FEATURE_NO_TITLE); | ||
| 48 | + View decorView = getWindow().getDecorView(); | ||
| 49 | + decorView.setSystemUiVisibility(View.SYSTEM_UI_FLAG_LAYOUT_STABLE | View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN); | ||
| 46 | if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { | 50 | if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { |
| 47 | - window.setStatusBarColor(getResources().getColor(R.color.status_bar_color)); | 51 | + getWindow().setStatusBarColor(Color.TRANSPARENT); |
| 48 | } | 52 | } |
| 53 | + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.P) { | ||
| 54 | + WindowManager.LayoutParams lp = getWindow().getAttributes(); | ||
| 55 | + lp.layoutInDisplayCutoutMode = WindowManager.LayoutParams.LAYOUT_IN_DISPLAY_CUTOUT_MODE_SHORT_EDGES; | ||
| 56 | + getWindow().setAttributes(lp); | ||
| 57 | + } | ||
| 58 | + getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON); | ||
| 49 | super.onCreate(savedInstanceState); | 59 | super.onCreate(savedInstanceState); |
| 50 | mContext = this; | 60 | mContext = this; |
| 51 | 61 | ||
| @@ -53,10 +63,11 @@ public class AggH5MainActivity extends Activity { | @@ -53,10 +63,11 @@ public class AggH5MainActivity extends Activity { | ||
| 53 | initView(); | 63 | initView(); |
| 54 | initSDK(); | 64 | initSDK(); |
| 55 | 65 | ||
| 56 | - String gameUrl = AggH5Tools.getMetaData(mContext, "h5game"); | 66 | + String gameUrl = AggH5Tools.getMetaData(mContext, "stss_agg_h5game"); |
| 57 | if (!TextUtils.isEmpty(gameUrl)) { | 67 | if (!TextUtils.isEmpty(gameUrl)) { |
| 58 | h5game = gameUrl; | 68 | h5game = gameUrl; |
| 59 | } | 69 | } |
| 70 | + h5game = String.format(h5game, STSSConstants.sdkParams.getGame_id(),"0"); | ||
| 60 | String newH5Url = h5game + "?" + ParamsTools.getParams(mContext, currToken); | 71 | String newH5Url = h5game + "?" + ParamsTools.getParams(mContext, currToken); |
| 61 | AggH5Log.d(TAG, newH5Url); | 72 | AggH5Log.d(TAG, newH5Url); |
| 62 | webView.loadUrl(newH5Url); | 73 | webView.loadUrl(newH5Url); |
| @@ -74,7 +85,6 @@ public class AggH5MainActivity extends Activity { | @@ -74,7 +85,6 @@ public class AggH5MainActivity extends Activity { | ||
| 74 | webView.getSettings().setDomStorageEnabled(true); | 85 | webView.getSettings().setDomStorageEnabled(true); |
| 75 | webView.getSettings().setDefaultTextEncodingName("UTF-8"); | 86 | webView.getSettings().setDefaultTextEncodingName("UTF-8"); |
| 76 | webView.getSettings().setCacheMode(WebSettings.LOAD_DEFAULT); | 87 | webView.getSettings().setCacheMode(WebSettings.LOAD_DEFAULT); |
| 77 | - | ||
| 78 | //加载页面时如果不加改代码,页面会跳转到系统自带浏览器显示。 | 88 | //加载页面时如果不加改代码,页面会跳转到系统自带浏览器显示。 |
| 79 | webView.setWebViewClient(new WebViewClient() { | 89 | webView.setWebViewClient(new WebViewClient() { |
| 80 | @Override | 90 | @Override |
| @@ -168,26 +178,19 @@ public class AggH5MainActivity extends Activity { | @@ -168,26 +178,19 @@ public class AggH5MainActivity extends Activity { | ||
| 168 | super.onAuthResult(authResult); | 178 | super.onAuthResult(authResult); |
| 169 | final String msg = "UserID=" + authResult.getGame_uid() + ", Token=" + authResult.getToken(); | 179 | final String msg = "UserID=" + authResult.getGame_uid() + ", Token=" + authResult.getToken(); |
| 170 | AggH5Log.e(TAG, "onAuthResult(); " + msg); | 180 | 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失败"); | 181 | + if (authResult.isSuc()) { |
| 182 | + currToken = authResult; | ||
| 183 | + runOnUiThread(new Runnable() { | ||
| 184 | + @Override | ||
| 185 | + public void run() { | ||
| 186 | + String newH5Url = h5game + "?" + ParamsTools.getParams(mContext, currToken); | ||
| 187 | + AggH5Log.d(TAG, newH5Url); | ||
| 188 | + webView.loadUrl(newH5Url); | ||
| 187 | } | 189 | } |
| 188 | - } | ||
| 189 | - }); | ||
| 190 | - | 190 | + }); |
| 191 | + } else { | ||
| 192 | + //showToast("获取Token失败"); | ||
| 193 | + } | ||
| 191 | } | 194 | } |
| 192 | 195 | ||
| 193 | // 支付回调 | 196 | // 支付回调 |
| @@ -195,12 +198,6 @@ public class AggH5MainActivity extends Activity { | @@ -195,12 +198,6 @@ public class AggH5MainActivity extends Activity { | ||
| 195 | public void onPayResult(final PayResult result) { | 198 | public void onPayResult(final PayResult result) { |
| 196 | super.onPayResult(result); | 199 | super.onPayResult(result); |
| 197 | AggH5Log.e(TAG, "onPayResult(); result.productName=" + result.getProductName()); | 200 | 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 | } | 201 | } |
| 205 | 202 | ||
| 206 | // 注销回调 | 203 | // 注销回调 |
| @@ -2,37 +2,64 @@ package com.agg.h5game; | @@ -2,37 +2,64 @@ package com.agg.h5game; | ||
| 2 | 2 | ||
| 3 | import android.app.Activity; | 3 | import android.app.Activity; |
| 4 | import android.content.Intent; | 4 | import android.content.Intent; |
| 5 | +import android.graphics.Color; | ||
| 6 | +import android.os.Build; | ||
| 5 | import android.os.Bundle; | 7 | import android.os.Bundle; |
| 6 | -import android.os.Handler; | 8 | +import android.view.View; |
| 7 | import android.view.Window; | 9 | import android.view.Window; |
| 8 | import android.view.WindowManager; | 10 | import android.view.WindowManager; |
| 11 | +import android.view.animation.AlphaAnimation; | ||
| 12 | +import android.view.animation.Animation; | ||
| 9 | import android.widget.ImageView; | 13 | import android.widget.ImageView; |
| 10 | 14 | ||
| 11 | public class AggH5SplashActivity extends Activity { | 15 | public class AggH5SplashActivity extends Activity { |
| 12 | - private final static int TIME = 2000; //闪屏保持的时间(毫秒计) | ||
| 13 | - | ||
| 14 | @Override | 16 | @Override |
| 15 | protected void onCreate(Bundle savedInstanceState) { | 17 | protected void onCreate(Bundle savedInstanceState) { |
| 16 | - // 隐藏标题栏 | ||
| 17 | - requestWindowFeature(Window.FEATURE_NO_TITLE); | ||
| 18 | - // 隐藏状态栏 | ||
| 19 | - getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, | 18 | + this.getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, |
| 20 | WindowManager.LayoutParams.FLAG_FULLSCREEN); | 19 | WindowManager.LayoutParams.FLAG_FULLSCREEN); |
| 20 | + this.requestWindowFeature(Window.FEATURE_NO_TITLE); | ||
| 21 | + View decorView = getWindow().getDecorView(); | ||
| 22 | + decorView.setSystemUiVisibility(View.SYSTEM_UI_FLAG_LAYOUT_STABLE | View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN); | ||
| 23 | + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { | ||
| 24 | + getWindow().setStatusBarColor(Color.TRANSPARENT); | ||
| 25 | + } | ||
| 26 | + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.P) { | ||
| 27 | + WindowManager.LayoutParams lp = getWindow().getAttributes(); | ||
| 28 | + lp.layoutInDisplayCutoutMode = WindowManager.LayoutParams.LAYOUT_IN_DISPLAY_CUTOUT_MODE_SHORT_EDGES; | ||
| 29 | + getWindow().setAttributes(lp); | ||
| 30 | + } | ||
| 21 | 31 | ||
| 22 | super.onCreate(savedInstanceState); | 32 | super.onCreate(savedInstanceState); |
| 23 | setContentView(R.layout.activity_splash); | 33 | setContentView(R.layout.activity_splash); |
| 24 | 34 | ||
| 25 | - ImageView img_splash = findViewById(R.id.img_splash); | ||
| 26 | - img_splash.setImageResource(R.drawable.splash); | 35 | + ImageView mIvSplash = findViewById(R.id.img_splash); |
| 36 | + | ||
| 37 | + Animation animation = new AlphaAnimation(1.0f,0.5f); | ||
| 38 | + animation.setDuration(2000); | ||
| 39 | + animation.setFillAfter(true); | ||
| 40 | + animation.setAnimationListener(new Animation.AnimationListener() { | ||
| 41 | + @Override | ||
| 42 | + public void onAnimationStart(Animation animation) { | ||
| 43 | + | ||
| 44 | + } | ||
| 27 | 45 | ||
| 28 | - new Handler().postDelayed(new Runnable() { | ||
| 29 | @Override | 46 | @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); | 47 | + public void onAnimationEnd(Animation animation) { |
| 48 | + ToMainActivity(); | ||
| 35 | } | 49 | } |
| 36 | - }, TIME); | 50 | + |
| 51 | + @Override | ||
| 52 | + public void onAnimationRepeat(Animation animation) { | ||
| 53 | + | ||
| 54 | + } | ||
| 55 | + }); | ||
| 56 | + mIvSplash.startAnimation(animation);//开始动画 | ||
| 57 | + } | ||
| 58 | + | ||
| 59 | + private void ToMainActivity() { | ||
| 60 | + Intent intent = new Intent(AggH5SplashActivity.this, AggH5MainActivity.class); | ||
| 61 | + startActivity(intent); | ||
| 62 | + finish(); | ||
| 63 | + overridePendingTransition(R.anim.alpha_in, R.anim.alpha_out); | ||
| 37 | } | 64 | } |
| 38 | } | 65 | } |
| 1 | package com.agg.h5game.tools; | 1 | package com.agg.h5game.tools; |
| 2 | 2 | ||
| 3 | import android.content.Context; | 3 | import android.content.Context; |
| 4 | -import android.content.SharedPreferences; | ||
| 5 | import android.content.pm.ApplicationInfo; | 4 | import android.content.pm.ApplicationInfo; |
| 6 | import android.content.pm.PackageManager; | 5 | import android.content.pm.PackageManager; |
| 7 | import android.text.TextUtils; | 6 | import android.text.TextUtils; |
| 8 | 7 | ||
| 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; | 8 | 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; | 9 | import java.util.zip.ZipEntry; |
| 24 | import java.util.zip.ZipFile; | 10 | import java.util.zip.ZipFile; |
| 25 | 11 | ||
| @@ -44,100 +30,6 @@ public class AggH5Tools { | @@ -44,100 +30,6 @@ public class AggH5Tools { | ||
| 44 | return null; | 30 | return null; |
| 45 | } | 31 | } |
| 46 | 32 | ||
| 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) { | 33 | public static String getLogicChannel(Context context, String prefix) { |
| 142 | ApplicationInfo appInfo = context.getApplicationInfo(); | 34 | ApplicationInfo appInfo = context.getApplicationInfo(); |
| 143 | String sourceDir = appInfo.sourceDir; | 35 | String sourceDir = appInfo.sourceDir; |
| @@ -166,112 +58,4 @@ public class AggH5Tools { | @@ -166,112 +58,4 @@ public class AggH5Tools { | ||
| 166 | } | 58 | } |
| 167 | return ""; | 59 | return ""; |
| 168 | } | 60 | } |
| 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 | } | 61 | } |
| @@ -2,8 +2,13 @@ package com.agg.h5game.tools; | @@ -2,8 +2,13 @@ package com.agg.h5game.tools; | ||
| 2 | 2 | ||
| 3 | import android.content.Context; | 3 | import android.content.Context; |
| 4 | 4 | ||
| 5 | +import com.stss.sdk.bean.STSSPayParams; | ||
| 6 | +import com.stss.sdk.bean.STSSUserExtraData; | ||
| 5 | import com.stss.sdk.verify.STSSUToken; | 7 | import com.stss.sdk.verify.STSSUToken; |
| 6 | 8 | ||
| 9 | +import org.json.JSONException; | ||
| 10 | +import org.json.JSONObject; | ||
| 11 | + | ||
| 7 | import java.util.HashMap; | 12 | import java.util.HashMap; |
| 8 | import java.util.Map; | 13 | import java.util.Map; |
| 9 | 14 | ||
| @@ -13,10 +18,9 @@ public class ParamsTools { | @@ -13,10 +18,9 @@ public class ParamsTools { | ||
| 13 | params.put("isAppType", "Android"); | 18 | params.put("isAppType", "Android"); |
| 14 | params.put("cid", AggH5Tools.getLogicChannel(context, "sid")); | 19 | params.put("cid", AggH5Tools.getLogicChannel(context, "sid")); |
| 15 | if (token != null) { | 20 | if (token != null) { |
| 16 | - params.put("channel_uid", token.getChannel_uid()); | 21 | + params.put("uid", token.getGame_uid()); |
| 17 | params.put("game_uid", token.getGame_uid()); | 22 | params.put("game_uid", token.getGame_uid()); |
| 18 | params.put("token", token.getToken()); | 23 | params.put("token", token.getToken()); |
| 19 | - params.put("extension", token.getExtension()); | ||
| 20 | } | 24 | } |
| 21 | return mapToQueryString(params); | 25 | return mapToQueryString(params); |
| 22 | } | 26 | } |
| @@ -31,4 +35,63 @@ public class ParamsTools { | @@ -31,4 +35,63 @@ public class ParamsTools { | ||
| 31 | } | 35 | } |
| 32 | return stringBuilder.toString(); | 36 | return stringBuilder.toString(); |
| 33 | } | 37 | } |
| 38 | + | ||
| 39 | + // JS调用Android 支付订单json转STSSPayParams | ||
| 40 | + public static STSSUserExtraData jsonToSTSSUserExtraData(String jsonParams) { | ||
| 41 | + STSSUserExtraData userExtraData = new STSSUserExtraData(); | ||
| 42 | + try { | ||
| 43 | + JSONObject jsonObject = new JSONObject(jsonParams); | ||
| 44 | + userExtraData.setDataType(jsonObject.getString("data_type")); | ||
| 45 | + userExtraData.setServerID(jsonObject.getString("server_id")); | ||
| 46 | + userExtraData.setServerName(jsonObject.getString("server_name")); | ||
| 47 | + userExtraData.setRoleID(jsonObject.getString("role_id")); | ||
| 48 | + userExtraData.setRoleName(jsonObject.getString("role_name")); | ||
| 49 | + userExtraData.setRoleLevel(jsonObject.getString("role_level")); | ||
| 50 | + userExtraData.setCreateTime(String.valueOf(jsonObject.getLong("role_create_time"))); | ||
| 51 | + userExtraData.setVipLv(String.valueOf(jsonObject.getInt("role_vip"))); | ||
| 52 | + userExtraData.setBalance(jsonObject.getString("role_balance")); | ||
| 53 | + userExtraData.setGender(jsonObject.getString("role_gender")); | ||
| 54 | + userExtraData.setOccupationId(jsonObject.getString("role_occupation_id")); | ||
| 55 | + userExtraData.setOccupationName(jsonObject.getString("role_occupation_name")); | ||
| 56 | + userExtraData.setPower(jsonObject.getString("role_power")); | ||
| 57 | + userExtraData.setPartyId(jsonObject.getString("party_id")); | ||
| 58 | + userExtraData.setPartyName(jsonObject.getString("party_name")); | ||
| 59 | + userExtraData.setPartyMasterId(jsonObject.getString("party_master_id")); | ||
| 60 | + userExtraData.setPartyMasterName(jsonObject.getString("party_master_name")); | ||
| 61 | + userExtraData.setUpdateTime(String.valueOf(jsonObject.optLong("add_time"))); | ||
| 62 | + userExtraData.setExtension(jsonObject.getString("extension")); | ||
| 63 | + } catch (JSONException e) { | ||
| 64 | + e.printStackTrace(); | ||
| 65 | + } | ||
| 66 | + return userExtraData; | ||
| 67 | + } | ||
| 68 | + | ||
| 69 | + // JS调用Android 支付订单json转STSSPayParams | ||
| 70 | + public static STSSPayParams jsonToSTSSPayParams(String jsonString) { | ||
| 71 | + STSSPayParams params = new STSSPayParams(); | ||
| 72 | + try { | ||
| 73 | + JSONObject jsonObject = new JSONObject(jsonString); | ||
| 74 | + params.setCpOrderId(jsonObject.optString("out_trade_no")); | ||
| 75 | + params.setProductId(String.valueOf(jsonObject.optInt("product_id"))); | ||
| 76 | + params.setProductName(jsonObject.optString("product_name")); | ||
| 77 | + params.setProductDesc(jsonObject.optString("product_desc")); | ||
| 78 | + params.setPrice(jsonObject.optString("product_price")); | ||
| 79 | + params.setRatio(jsonObject.optString("exchange_rate")); | ||
| 80 | + params.setBuyNum(String.valueOf(jsonObject.optInt("product_count"))); | ||
| 81 | + params.setCurrencyName(jsonObject.optString("currency_name")); | ||
| 82 | + params.setServerId(jsonObject.optString("server_id")); | ||
| 83 | + params.setServerName(jsonObject.optString("server_name")); | ||
| 84 | + params.setRoleId(jsonObject.optString("role_id")); | ||
| 85 | + params.setRoleName(jsonObject.optString("role_name")); | ||
| 86 | + params.setRoleLevel(jsonObject.optString("role_level")); | ||
| 87 | + params.setVip(String.valueOf(jsonObject.optInt("role_vip"))); | ||
| 88 | + params.setAddTime(String.valueOf(jsonObject.optLong("add_time"))); | ||
| 89 | + params.setCallBack(jsonObject.optString("call_back")); | ||
| 90 | + params.setPayNotifyUrl(jsonObject.optString("notify_url")); | ||
| 91 | + params.setExtension(jsonObject.optString("extension")); | ||
| 92 | + } catch (JSONException e) { | ||
| 93 | + e.printStackTrace(); | ||
| 94 | + } | ||
| 95 | + return params; | ||
| 96 | + } | ||
| 34 | } | 97 | } |
| 1 | +package com.agg.h5game.tools; | ||
| 2 | + | ||
| 3 | +import android.widget.Toast; | ||
| 4 | + | ||
| 5 | +import com.agg.h5game.AggH5GameApplication; | ||
| 6 | + | ||
| 7 | +public class ZWToast { | ||
| 8 | + public static void showToast(String message) { | ||
| 9 | + Toast.makeText(AggH5GameApplication.getContext(), message, Toast.LENGTH_SHORT).show(); | ||
| 10 | + } | ||
| 11 | +} |
app/src/main/res/drawable-v24/splash.png
已删除
100644 → 0
53.9 KB
app/src/main/res/drawable/splash.png
0 → 100644
55.6 KB
| 1 | <?xml version="1.0" encoding="utf-8"?> | 1 | <?xml version="1.0" encoding="utf-8"?> |
| 2 | <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" | 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" | 3 | android:layout_width="match_parent" |
| 5 | android:layout_height="match_parent" | 4 | android:layout_height="match_parent" |
| 6 | android:orientation="vertical"> | 5 | android:orientation="vertical"> |
| @@ -8,6 +7,7 @@ | @@ -8,6 +7,7 @@ | ||
| 8 | <ImageView | 7 | <ImageView |
| 9 | android:id="@+id/img_splash" | 8 | android:id="@+id/img_splash" |
| 10 | android:layout_width="match_parent" | 9 | android:layout_width="match_parent" |
| 10 | + android:scaleType="fitXY" | ||
| 11 | android:layout_height="match_parent" | 11 | android:layout_height="match_parent" |
| 12 | - android:src="@drawable/splash" /> | 12 | + android:src="@drawable/splash"/> |
| 13 | </LinearLayout> | 13 | </LinearLayout> |
-
请 注册 或 登录 后发表评论