diff --git a/android/app/build.gradle b/android/app/build.gradle
index 2b4c347..6a083c8 100644
--- a/android/app/build.gradle
+++ b/android/app/build.gradle
@@ -112,6 +112,9 @@ android {
//配置eventbus
implementation 'org.simple:androideventbus:1.0.5.1'
+ //二维码
+ implementation 'com.google.zxing:core:3.3.0'
+
}
}
diff --git a/android/app/libs/cloudgamelibrary.aar b/android/app/libs/cloudgamelibrary-2.4.46.aar
similarity index 100%
rename from android/app/libs/cloudgamelibrary.aar
rename to android/app/libs/cloudgamelibrary-2.4.46.aar
diff --git a/android/app/src/main/AndroidManifest.xml b/android/app/src/main/AndroidManifest.xml
index dcc014e..c22026c 100644
--- a/android/app/src/main/AndroidManifest.xml
+++ b/android/app/src/main/AndroidManifest.xml
@@ -11,6 +11,7 @@
+
@@ -71,7 +72,7 @@
+ android:exported="true">
@@ -83,7 +84,7 @@
+ android:exported="true">
diff --git a/android/app/src/main/java/co/steamcloud/game/HttpUtils/HttpTool.java b/android/app/src/main/java/co/steamcloud/game/HttpUtils/HttpTool.java
index 63cfc0e..08776fa 100644
--- a/android/app/src/main/java/co/steamcloud/game/HttpUtils/HttpTool.java
+++ b/android/app/src/main/java/co/steamcloud/game/HttpUtils/HttpTool.java
@@ -80,11 +80,58 @@ public class HttpTool {
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) {
diff --git a/android/app/src/main/java/co/steamcloud/game/HttpUtils/OpenApiRequest.java b/android/app/src/main/java/co/steamcloud/game/HttpUtils/OpenApiRequest.java
index fc8e2db..7c0d8a2 100644
--- a/android/app/src/main/java/co/steamcloud/game/HttpUtils/OpenApiRequest.java
+++ b/android/app/src/main/java/co/steamcloud/game/HttpUtils/OpenApiRequest.java
@@ -84,6 +84,38 @@ public class OpenApiRequest {
});
}
+ /**
+ * 获取游戏设置
+ *
+ * @param mListener 回调
+ */
+ public void gameSetting(final OnApiRequestListener mListener) {
+ String url = Config.url + "api/PlayGame/GameSetting?gameId=" + Config.gameId;
+// final Map map = new HashMap<>();
+// map.put("gameId", Config.gameId);
+// map.put("sign", sign(map, Config.sign_key));
+ // 将HashMap转换为JSONObject
+// JSONObject jsonObject = new JSONObject(map);
+//
+// RequestBody requestBody = RequestBody.create(
+// MediaType.parse("application/json"), jsonObject.toString());
+ HttpTool.httpGet(url, new HttpResultListener() {
+ @Override
+ public void onResponse(String data, int code, String msg) {
+ if (mListener != null) {
+ mListener.onResponse(data, code, msg);
+ }
+ }
+
+ @Override
+ public void onFailure(Exception err) {
+ LogUtil.d("err:" + err.getMessage());
+ if (mListener != null)
+ mListener.onFailure(err);
+ }
+ });
+ }
+
/**
* 排序加密
diff --git a/android/app/src/main/java/co/steamcloud/game/MainActivity.java b/android/app/src/main/java/co/steamcloud/game/MainActivity.java
index 8451dea..dede014 100644
--- a/android/app/src/main/java/co/steamcloud/game/MainActivity.java
+++ b/android/app/src/main/java/co/steamcloud/game/MainActivity.java
@@ -8,6 +8,7 @@ import android.os.Message;
import android.os.PersistableBundle;
import android.text.TextUtils;
import android.util.Log;
+import android.view.KeyEvent;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
@@ -49,6 +50,17 @@ public class MainActivity extends FlutterActivity {
WhaleCloud.getInstance().isShowLog(true);
}
+ @Override
+ public boolean dispatchKeyEvent(KeyEvent 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() {
diff --git a/android/app/src/main/java/co/steamcloud/game/PlayGameActivity.java b/android/app/src/main/java/co/steamcloud/game/PlayGameActivity.java
index c545145..11141f0 100644
--- a/android/app/src/main/java/co/steamcloud/game/PlayGameActivity.java
+++ b/android/app/src/main/java/co/steamcloud/game/PlayGameActivity.java
@@ -86,16 +86,15 @@ public class PlayGameActivity extends Activity {
private SurfaceView mVideoViewLegacy;
private GameFrameLayOut gameLayout;
private FrameLayout NetworkKeyboard, NetworkCursor, MNKeyboard;
- private ImageView close_set;
+ private ImageView close_set, img_qr;
private MyButton menu_set, Move_show_hide;
private ConstraintLayout menu, seting, custom_button;
- private Group seting_g1, seting_g2;
- private TextView set_control, set_frame, wifi, custom_button_default, custom_button_yg, custom_button_close;
+ private Group seting_g1, seting_g2, seting_g3;
+ private TextView set_control, set_frame, set_GamePad, wifi, custom_button_default, custom_button_yg, custom_button_close;
private MyButton mImageCursor;
/*进度条*/
private ConstraintLayout loadingCL;
private ImageView loading;
-
private LottieAnimationView animationView;
private ProgressBar progressbar1;
private TextView fadenum;
@@ -192,6 +191,7 @@ public class PlayGameActivity extends Activity {
private ConstraintLayout conBuy;
private ImageView imgVipType;
private OpenApiRequest openApiRequest;
+ private Bitmap qrCodeBitmap;
// private JoinMembershipDialog joinMembershipDialog;
/**
@@ -215,9 +215,6 @@ public class PlayGameActivity extends Activity {
@Override
public void oneSecond() {
nounTime++;
- /*if (Config.gamePara.is_ShowOSD) {
- runPingIPprocess(ipString);
- }*/
}
};
private String pingNum = "";
@@ -238,6 +235,43 @@ public class PlayGameActivity extends Activity {
}
openApiRequest = new OpenApiRequest();
+ //获取游戏设置
+ openApiRequest.gameSetting(new OnApiRequestListener() {
+ @Override
+ public void onResponse(String data, int code, String msg) {
+ Log.d(TAG, "onResponse: data==" + data);
+ Log.d(TAG, "onResponse: code==" + code);
+ Log.d(TAG, "onResponse: msg==" + msg);
+
+
+ try {
+ JSONObject jsonObject = new JSONObject(data);
+ String jsonData = jsonObject.getString("data");
+ if (jsonData.equals("null")) {
+ Log.d(TAG, "onResponse: 游戏设置数据异常");
+ return;
+ }
+ Log.d(TAG, "onResponse: jsonData==" + jsonData);
+ JSONObject heartData = new JSONObject(jsonData);
+
+ String handleQrCode = heartData.getString("handleQrCode");//H5手柄扫码二维码
+
+ Resources res = getResources();
+ Bitmap logoBitmap = BitmapFactory.decodeResource(res, R.mipmap.ic_launcher);
+
+ qrCodeBitmap = AppUtil.createQRCodeBitmap(handleQrCode, 200, 200, "UTF-8", "H", "1", R.color.black, Color.WHITE, logoBitmap, 0.2f);
+
+ Log.d(TAG, "onResponse: data=" + jsonObject);
+ } catch (Exception e) {
+ throw new RuntimeException(e);
+ }
+ }
+
+ @Override
+ public void onFailure(Exception e) {
+ Log.d(TAG, "onResponse: e==" + e);
+ }
+ });
//隐藏系统按钮
hideBottomUIMenu();
@@ -313,30 +347,18 @@ public class PlayGameActivity extends Activity {
sameTimerTask.cancel();
sameTimerTask = null;
}
-
if (valueAnimator != null) {
valueAnimator.cancel();
}
-
if (mVideoView != null) {
mVideoView.release();
mVideoView = null;
}
-
if (refresh != null) {
refresh.cancel();
}
-
-
stopTime();
-// Glide.with(getApplicationContext()).pauseRequests();
super.onDestroy();
-// EventBus.getDefault().unregister(this);
- }
-
- @Override
- public boolean moveTaskToBack(boolean nonRoot) {
- return super.moveTaskToBack(nonRoot);
}
@Override
@@ -413,15 +435,12 @@ public class PlayGameActivity extends Activity {
return true;
}
return false;
- //onKeyEvent(keyCode, false);
-
}
@Override
public boolean dispatchGenericMotionEvent(MotionEvent event) {
boolean consumed;
LogUtil.d("...dispatchGenericMotionEvent:" + event);
- //onKeyEvent(-999, true);
consumed = WhaleCloud.getInstance().dispatchGenericMotionEvent(event);
return consumed;
}
@@ -441,7 +460,6 @@ public class PlayGameActivity extends Activity {
public void startKeyEventSchedule() {
-
if (keyEventTimer != null) {
keyEventTimer.cancel();
keyEventTimer = null;
@@ -516,12 +534,6 @@ public class PlayGameActivity extends Activity {
custom_button_default = findViewById(R.id.custom_button_default);
custom_button = findViewById(R.id.custom_button);
menu = findViewById(R.id.menu);
-// menu_setting = findViewById(R.id.menu_setting);
-// menu_exit = findViewById(R.id.menu_exit);
-// menu_yincanganjian = findViewById(R.id.menu_yincanganjian);
-// menu_huamianshezhi = findViewById(R.id.menu_huamianshezhi);
-// menu_keyboard = findViewById(R.id.menu_keyboard);
-// menu_return = findViewById(R.id.menu_return);
loadingCL = findViewById(R.id.loadingCL);
loading = findViewById(R.id.loading);
@@ -548,23 +560,14 @@ public class PlayGameActivity extends Activity {
conDiamond = findViewById(R.id.con_diamonds);
tvCountDown = findViewById(R.id.tv_count_down);
btRecharge = findViewById(R.id.bt_recharge);
-// imgShowHide = findViewById(R.id.img_show_hide);
-
-// imgShowHide.setImageResource(R.mipmap.btn_shang);
imgKeySet = findViewById(R.id.img_key_set);
imgSwitchKey = findViewById(R.id.img_switch_key);
imgSwitchRightRocker = findViewById(R.id.img_switch_right_rocker);
imgSwitchKeyboard = findViewById(R.id.img_switch_keyboard);
imgSwitchShock = findViewById(R.id.img_switch_shock);
-// tvVipType = findViewById(R.id.tv_vip_type);
-// tvDiamanteNum = findViewById(R.id.tv_diamante_num);
tvExitGame = findViewById(R.id.tv_exit_game);
tvReturnApp = findViewById(R.id.tv_return_app);
-// conBuy = findViewById(R.id.con_buy);
-// imgVipType = findViewById(R.id.img_vip_type);
-
-
tvReturnApp.setOnClickListener(view -> {
if (menu != null) {
menu.setVisibility(View.GONE);
@@ -572,7 +575,7 @@ public class PlayGameActivity extends Activity {
returnAppMain();
});
-
+ //退出游戏按钮
tvExitGame.setOnClickListener(view -> {
if (menu != null) {
menu.setVisibility(View.GONE);
@@ -593,10 +596,8 @@ public class PlayGameActivity extends Activity {
// returnAppMain();
}
});
-
});
-
imgSwitchShock.setOnClickListener(view -> {
isShock = !isShock;
if (isShock) {
@@ -680,25 +681,6 @@ public class PlayGameActivity extends Activity {
CustomButton(s_keyboard);
});
-// imgShowHide.setOnClickListener(v -> {
-// isShow = !isShow;
-// if (isShow) {
-// conDiamond.setVisibility(View.GONE);
-// imgShowHide.setImageResource(R.mipmap.btn_xia);
-// } else {
-// conDiamond.setVisibility(View.VISIBLE);
-// imgShowHide.setImageResource(R.mipmap.btn_shang);
-// }
-// });
-
-// btRecharge.setOnClickListener(new View.OnClickListener() {
-// @Override
-// public void onClick(View v) {
-// showbuyDialog();
-// }
-// });
-
-
//判断屏幕大小
DisplayMetrics dm = new DisplayMetrics();
getWindowManager().getDefaultDisplay().getMetrics(dm);//display = getWindowManager().getDefaultDisplay();display.getMetrics(dm)(把屏幕尺寸信息赋值给DisplayMetrics dm);
@@ -931,14 +913,6 @@ public class PlayGameActivity extends Activity {
menu_set.setOnClickCallBackListener(new MyButton.OnClickCallBackListener() {
@Override
public void onActionDown() {
-// if (menu.getVisibility() == View.GONE) {
-// menu.setVisibility(View.VISIBLE);
-// wifi.setVisibility(View.VISIBLE);
-// } else {
-// menu.setVisibility(View.GONE);
-// wifi.setVisibility(View.GONE);
-// }
-
seting.setVisibility(View.VISIBLE);
if (keyboardUtil != null) {
textInput = keyboardUtil.isShow;
@@ -969,18 +943,11 @@ public class PlayGameActivity extends Activity {
}
Move_show_hide.setBackgroundResource(R.mipmap.ic_key_hide);
imgSwitchKey.setImageResource(R.mipmap.switch_open);
-// if (menu_yincanganjian != null) {
-// menu_yincanganjian.setImageResource(R.mipmap.btn_yincanganjian);
-// }
-
} else {
if (HandleCL != null) {
HandleCL.setVisibility(View.GONE);
}
Move_show_hide.setBackgroundResource(R.mipmap.ic_key_show);
-// if (menu_yincanganjian != null) {
-// menu_yincanganjian.setImageResource(R.mipmap.btn_anjianxinashi);
-// }
imgSwitchKey.setImageResource(R.mipmap.switch_close);
}
Config.is_immersion = !Config.is_immersion;
@@ -1000,103 +967,6 @@ public class PlayGameActivity extends Activity {
});
menu.setOnClickListener(v -> {
});
-// menu_exit.setOnClickListener(v -> {
-// if (menu != null) {
-// menu.setVisibility(View.GONE);
-// }
-// showDialog("退出游戏", "确定退出游戏吗?", "退出游戏", "返回至APP", new IDialogTwoView() {
-// @Override
-// public void cancel() {
-// hideBottomUIMenu();
-// }
-//
-// @Override
-// public void onSure() {
-// closeGame();
-// }
-//
-// @Override
-// public void returnApp() {
-// returnAppMain();
-// }
-// });
-//
-// });
-// menu_setting.setOnClickListener(v -> {
-// seting.setVisibility(View.VISIBLE);
-// if (menu != null) {
-// menu.setVisibility(View.GONE);
-// }
-// selectSet(0);
-//
-// });
-// menu_huamianshezhi.setOnClickListener(v -> {
-// seting.setVisibility(View.VISIBLE);
-// if (menu != null) {
-// menu.setVisibility(View.GONE);
-// }
-// selectSet(1);
-// });
-// menu_yincanganjian.setOnClickListener(v -> {
-// if (menu != null) {
-// menu.setVisibility(View.GONE);
-// }
-// //显示隐藏键盘
-// if (Config.is_immersion) {
-//
-// if (Move_show_hide != null) {
-// Move_show_hide.setBackgroundResource(R.mipmap.yingcang);
-// Move_show_hide.setText("按键隐藏");
-// }
-//
-// if (Ismode == 1) {
-// if (HandleCL != null) {
-// HandleCL.setVisibility(View.VISIBLE);
-// }
-// } else if (Ismode == 2) {
-// NetworkKeyboard.setVisibility(View.VISIBLE);
-// }
-//
-//
-// if (menu_yincanganjian != null) {
-// menu_yincanganjian.setImageResource(R.mipmap.btn_yincanganjian);
-// }
-// } else {
-//
-//
-// if (Ismode == 1) {
-// if (HandleCL != null && select != null) {
-// HandleCL.setVisibility(View.GONE);
-// }
-// } else if (Ismode == 2) {
-// NetworkKeyboard.setVisibility(View.GONE);
-// }
-//
-// if (Move_show_hide != null) {
-// Move_show_hide.setBackgroundResource(R.mipmap.xianshi);
-// Move_show_hide.setText("按键显示");
-// }
-// if (menu_yincanganjian != null) {
-// menu_yincanganjian.setImageResource(R.mipmap.btn_anjianxinashi);
-// }
-// }
-// Config.is_immersion = !Config.is_immersion;
-// });
-// menu_keyboard.setOnClickListener(v -> {
-// if (menu != null) {
-// menu.setVisibility(View.GONE);
-// }
-// showKeyboard = true;
-// new KeyboardUtil(PlayGameActivity.this, this).showKeyboard();
-// });
-// menu_return.setOnClickListener(v -> {
-// if (menu != null) {
-// menu.setVisibility(View.GONE);
-// }
-//
-// returnAppMain();
-// //App.getInstance().push(map);
-// });
if (WhaleCloud.getInstance().isLegcyView()) {
mVideoViewLegacy = findViewById(R.id.video_render_legacy);
@@ -1189,13 +1059,22 @@ public class PlayGameActivity extends Activity {
private void initSetView() {
seting_g1 = findViewById(R.id.seting_g1);
seting_g2 = findViewById(R.id.seting_g2);
+ seting_g3 = findViewById(R.id.seting_g3);
set_control = findViewById(R.id.set_control);
set_frame = findViewById(R.id.set_frame);
+ set_GamePad = findViewById(R.id.set_GamePad);
custom_button = findViewById(R.id.custom_button);
+ img_qr = findViewById(R.id.img_qr);
+
+ img_qr.setImageBitmap(qrCodeBitmap);
+
set_control.setOnClickListener(v -> {
selectSet(0);
});
set_frame.setOnClickListener(v -> {
+ selectSet(1);
+ });
+ set_GamePad.setOnClickListener(v -> {
selectSet(2);
});
custom_button_close.setOnClickListener(v -> {
@@ -1228,46 +1107,70 @@ public class PlayGameActivity extends Activity {
//0控制 1画面
private void selectSet(int type) {
- if (type == 0) {
- if (seting_g1 != null) {
- seting_g1.setVisibility(View.GONE);
- }
- if (seting_g2 != null) {
- seting_g2.setVisibility(View.VISIBLE);
- }
- if (set_control != null) {
- set_control.setBackgroundResource(R.drawable.shape_set_item_bg);
- }
- if (set_frame != null) {
- set_frame.setBackgroundResource(0);
- }
- } else if (type == 1) {
- if (seting_g1 != null) {
- seting_g1.setVisibility(View.GONE);
- }
- if (seting_g2 != null) {
- seting_g2.setVisibility(View.GONE);
- }
- if (set_control != null) {
- set_control.setBackgroundResource(0);
- }
- if (set_frame != null) {
- set_frame.setBackgroundResource(0);
- }
- } else {
- if (seting_g1 != null) {
- seting_g1.setVisibility(View.VISIBLE);
- }
- if (seting_g2 != null) {
- seting_g2.setVisibility(View.GONE);
- }
- if (set_frame != null) {
- set_frame.setBackgroundResource(R.drawable.shape_set_item_bg);
- }
- if (set_frame != null) {
- set_control.setBackgroundResource(0);
- }
+ switch (type) {
+ case 0:
+ if (seting_g1 != null) {
+ seting_g1.setVisibility(View.GONE);
+ }
+ if (seting_g2 != null) {
+ seting_g2.setVisibility(View.VISIBLE);
+ }
+ if (seting_g3 != null) {
+ seting_g3.setVisibility(View.GONE);
+ }
+ if (set_control != null) {
+ set_control.setBackgroundResource(R.drawable.shape_set_item_bg);
+ }
+ if (set_frame != null) {
+ set_frame.setBackgroundResource(0);
+ }
+ if (set_GamePad != null) {
+ set_GamePad.setBackgroundResource(0);
+ }
+ break;
+
+ case 1:
+ if (seting_g1 != null) {
+ seting_g1.setVisibility(View.VISIBLE);
+ }
+ if (seting_g2 != null) {
+ seting_g2.setVisibility(View.GONE);
+ }
+ if (seting_g3 != null) {
+ seting_g3.setVisibility(View.GONE);
+ }
+ if (set_control != null) {
+ set_control.setBackgroundResource(0);
+ }
+ if (set_frame != null) {
+ set_frame.setBackgroundResource(R.drawable.shape_set_item_bg);
+ }
+ if (set_GamePad != null) {
+ set_GamePad.setBackgroundResource(0);
+ }
+ break;
+
+ case 2:
+ if (seting_g1 != null) {
+ seting_g1.setVisibility(View.GONE);
+ }
+ if (seting_g2 != null) {
+ seting_g2.setVisibility(View.GONE);
+ }
+ if (seting_g3 != null) {
+ seting_g3.setVisibility(View.VISIBLE);
+ }
+ if (set_control != null) {
+ set_control.setBackgroundResource(0);
+ }
+ if (set_frame != null) {
+ set_frame.setBackgroundResource(0);
+ }
+ if (set_GamePad != null) {
+ set_GamePad.setBackgroundResource(R.drawable.shape_set_item_bg);
+ }
+ break;
}
}
diff --git a/android/app/src/main/java/co/steamcloud/game/utils/AppUtil.java b/android/app/src/main/java/co/steamcloud/game/utils/AppUtil.java
index 28fb74d..f526509 100644
--- a/android/app/src/main/java/co/steamcloud/game/utils/AppUtil.java
+++ b/android/app/src/main/java/co/steamcloud/game/utils/AppUtil.java
@@ -11,6 +11,8 @@ 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;
@@ -19,6 +21,7 @@ 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;
@@ -30,6 +33,12 @@ 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;
@@ -41,6 +50,7 @@ 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;
@@ -54,6 +64,119 @@ import co.steamcloud.game.App;
*/
public class AppUtil {
+ /**
+ *
+ * @param content 字符串内容
+ * @param width 二维码宽度
+ * @param height 二维码高度
+ * @param character_set 编码方式(一般使用UTF-8)
+ * @param error_correction_level 容错率 L:7% M:15% Q:25% H:35%
+ * @param margin 空白边距(二维码与边框的空白区域)
+ * @param color_black 黑色色块
+ * @param color_white 白色色块
+ * @param logoBitmap logo图片
+ * @param logoPercent logo所占百分比
+ * @return
+ */
+ public static Bitmap createQRCodeBitmap(String content, int width, int height, String character_set,
+ String error_correction_level,String margin, int color_black,
+ int color_white,Bitmap logoBitmap, float logoPercent) {
+ // 字符串内容判空
+ if (TextUtils.isEmpty(content)) {
+ return null;
+ }
+ // 宽和高>=0
+ if (width < 0 || height < 0) {
+ return null;
+ }
+ try {
+ /** 1.设置二维码相关配置,生成BitMatrix(位矩阵)对象 */
+ Hashtable hints = new Hashtable<>();
+ // 字符转码格式设置
+ if (!TextUtils.isEmpty(character_set)) {
+ hints.put(EncodeHintType.CHARACTER_SET, character_set);
+ }
+ // 容错率设置
+ if (!TextUtils.isEmpty(error_correction_level)) {
+ hints.put(EncodeHintType.ERROR_CORRECTION, error_correction_level);
+ }
+ // 空白边距设置
+ if (!TextUtils.isEmpty(margin)) {
+ hints.put(EncodeHintType.MARGIN, margin);
+ }
+ /** 2.将配置参数传入到QRCodeWriter的encode方法生成BitMatrix(位矩阵)对象 */
+ BitMatrix bitMatrix = new QRCodeWriter().encode(content, BarcodeFormat.QR_CODE, width, height, hints);
+
+ /** 3.创建像素数组,并根据BitMatrix(位矩阵)对象为数组元素赋颜色值 */
+ int[] pixels = new int[width * height];
+ for (int y = 0; y < height; y++) {
+ for (int x = 0; x < width; x++) {
+ //bitMatrix.get(x,y)方法返回true是黑色色块,false是白色色块
+ if (bitMatrix.get(x, y)) {
+ pixels[y * width + x] = color_black;//黑色色块像素设置
+ } else {
+ pixels[y * width + x] = color_white;// 白色色块像素设置
+ }
+ }
+ }
+
+ /** 4.创建Bitmap对象,根据像素数组设置Bitmap每个像素点的颜色值,并返回Bitmap对象 */
+ Bitmap bitmap = Bitmap.createBitmap(width, height, Bitmap.Config.ARGB_8888);
+ bitmap.setPixels(pixels, 0, width, 0, 0, width, height);
+
+ /** 5.为二维码添加logo图标 */
+ if(logoBitmap != null){
+ return addLogo(bitmap, logoBitmap, logoPercent);
+ }
+ return bitmap;
+ } catch (WriterException e) {
+ e.printStackTrace();
+ return null;
+ }
+ }
+
+
+ /**
+ * 向二维码中间添加logo图片(图片合成)
+ *
+ * @param srcBitmap 原图片(生成的简单二维码图片)
+ * @param logoBitmap logo图片
+ * @param logoPercent 百分比 (用于调整logo图片在原图片中的显示大小, 取值范围[0,1] )
+ * @return
+ */
+ private static Bitmap addLogo(Bitmap srcBitmap, Bitmap logoBitmap, float logoPercent) {
+ if (srcBitmap == null) {
+ return null;
+ }
+ if (logoBitmap == null) {
+ return srcBitmap;
+ }
+ //传值不合法时使用0.2F
+ if (logoPercent < 0F || logoPercent > 1F) {
+ logoPercent = 0.2F;
+ }
+
+ /** 1. 获取原图片和Logo图片各自的宽、高值 */
+ int srcWidth = srcBitmap.getWidth();
+ int srcHeight = srcBitmap.getHeight();
+ int logoWidth = logoBitmap.getWidth();
+ int logoHeight = logoBitmap.getHeight();
+
+ /** 2. 计算画布缩放的宽高比 */
+ float scaleWidth = srcWidth * logoPercent / logoWidth;
+ float scaleHeight = srcHeight * logoPercent / logoHeight;
+
+ /** 3. 使用Canvas绘制,合成图片 */
+ Bitmap bitmap = Bitmap.createBitmap(srcWidth, srcHeight, Bitmap.Config.ARGB_8888);
+ Canvas canvas = new Canvas(bitmap);
+ canvas.drawBitmap(srcBitmap, 0, 0, null);
+ canvas.scale(scaleWidth, scaleHeight, srcWidth / 2, srcHeight / 2);
+ canvas.drawBitmap(logoBitmap, srcWidth / 2 - logoWidth / 2, srcHeight / 2 - logoHeight / 2, null);
+
+ return bitmap;
+ }
+
+
public static boolean checkURL(String url) {
boolean value = false;
try {
diff --git a/android/app/src/main/res/layout/layout_game_setting.xml b/android/app/src/main/res/layout/layout_game_setting.xml
index 9a55457..a69311c 100644
--- a/android/app/src/main/res/layout/layout_game_setting.xml
+++ b/android/app/src/main/res/layout/layout_game_setting.xml
@@ -70,6 +70,18 @@
app:layout_constraintLeft_toRightOf="@id/view_line"
app:layout_constraintTop_toBottomOf="@+id/set_control" />
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
#25282c
#303237
- #ffffff
+ #FFFFFF
#dddddd
#0094FE
#E3E3E3
diff --git a/lib/beans/game_info_bean.dart b/lib/beans/game_info_bean.dart
index 503d0e1..c35bbdb 100644
--- a/lib/beans/game_info_bean.dart
+++ b/lib/beans/game_info_bean.dart
@@ -19,10 +19,9 @@ class GameInfoBean {
String? gameIntroduce;
String? gameShare;
String? gameShareUserIcon;
- bool? isCollect;
GameInfoBean(this.gameId, this.gameName, this.subtitle, this.gameDetailsofCharges, this.gameIcon, this.gameBg, this.gameTags, this.score,
- this.gameLoadTime, this.gameIntroduce, this.gameShare, this.gameShareUserIcon,this.isCollect);
+ this.gameLoadTime, this.gameIntroduce, this.gameShare, this.gameShareUserIcon);
factory GameInfoBean.fromJson(Map json) => _$GameInfoBeanFromJson(json);
diff --git a/lib/beans/game_info_bean.g.dart b/lib/beans/game_info_bean.g.dart
index a3c17ba..be7f202 100644
--- a/lib/beans/game_info_bean.g.dart
+++ b/lib/beans/game_info_bean.g.dart
@@ -21,7 +21,6 @@ GameInfoBean _$GameInfoBeanFromJson(Map json) => GameInfoBean(
json['gameIntroduce'] as String?,
json['gameShare'] as String?,
json['gameShareUserIcon'] as String?,
- json['isCollect'] as bool?,
);
Map _$GameInfoBeanToJson(GameInfoBean instance) =>
@@ -38,5 +37,4 @@ Map _$GameInfoBeanToJson(GameInfoBean instance) =>
'gameIntroduce': instance.gameIntroduce,
'gameShare': instance.gameShare,
'gameShareUserIcon': instance.gameShareUserIcon,
- 'isCollect': instance.isCollect,
};
diff --git a/lib/beans/game_user_info_bean.dart b/lib/beans/game_user_info_bean.dart
new file mode 100644
index 0000000..9765e99
--- /dev/null
+++ b/lib/beans/game_user_info_bean.dart
@@ -0,0 +1,15 @@
+import 'package:json_annotation/json_annotation.dart';
+
+part 'game_user_info_bean.g.dart';
+
+///
+@JsonSerializable(explicitToJson: true)
+class GameUserInfoBean {
+ bool? isCollect;
+
+ GameUserInfoBean(this.isCollect);
+
+ factory GameUserInfoBean.fromJson(Map json) => _$GameUserInfoBeanFromJson(json);
+
+ Map toJson() => _$GameUserInfoBeanToJson(this);
+}
diff --git a/lib/beans/game_user_info_bean.g.dart b/lib/beans/game_user_info_bean.g.dart
new file mode 100644
index 0000000..94572bd
--- /dev/null
+++ b/lib/beans/game_user_info_bean.g.dart
@@ -0,0 +1,17 @@
+// GENERATED CODE - DO NOT MODIFY BY HAND
+
+part of 'game_user_info_bean.dart';
+
+// **************************************************************************
+// JsonSerializableGenerator
+// **************************************************************************
+
+GameUserInfoBean _$GameUserInfoBeanFromJson(Map json) =>
+ GameUserInfoBean(
+ json['isCollect'] as bool?,
+ );
+
+Map _$GameUserInfoBeanToJson(GameUserInfoBean instance) =>
+ {
+ 'isCollect': instance.isCollect,
+ };
diff --git a/lib/beans/user_info_bean.g.dart b/lib/beans/user_info_bean.g.dart
index e61f6cf..0a0b287 100644
--- a/lib/beans/user_info_bean.g.dart
+++ b/lib/beans/user_info_bean.g.dart
@@ -18,11 +18,14 @@ UserInfoBean _$UserInfoBeanFromJson(Map json) => UserInfoBean(
json['isJuveniles'] as bool?,
json['userName'] as String?,
json['idCard'] as String?,
- json['nightCard'] == null ? null : NightCardBean.fromJson(json['nightCard'] as Map),
+ json['nightCard'] == null
+ ? null
+ : NightCardBean.fromJson(json['nightCard'] as Map),
(json['userPlayGameTime'] as num?)?.toInt(),
);
-Map _$UserInfoBeanToJson(UserInfoBean instance) => {
+Map _$UserInfoBeanToJson(UserInfoBean instance) =>
+ {
'nickName': instance.nickName,
'userId': instance.userId,
'phoneNum': instance.phoneNum,
diff --git a/lib/network/NetworkConfig.dart b/lib/network/NetworkConfig.dart
index 7e06757..4d5b469 100644
--- a/lib/network/NetworkConfig.dart
+++ b/lib/network/NetworkConfig.dart
@@ -114,4 +114,6 @@ class NetworkConfig {
static const String accountLogOff = "api/Account/AccountLogOff"; //注销账号
+ static const String getGameUserInfo = "api/Game/GetGameUserInfo"; //获取用户游戏详情数据
+
}
diff --git a/lib/tools/game/game_info_page.dart b/lib/tools/game/game_info_page.dart
index c989e2d..2fd81a2 100644
--- a/lib/tools/game/game_info_page.dart
+++ b/lib/tools/game/game_info_page.dart
@@ -8,6 +8,7 @@ import 'package:game/network/NetworkConfig.dart';
import '../../beans/game_info_bean.dart';
import '../../beans/game_info_recommend_bean.dart';
+import '../../beans/game_user_info_bean.dart';
import '../../common/EventBusUtil.dart';
import '../../common/func.dart';
import 'game_model.dart';
@@ -29,6 +30,7 @@ class _GameInfoPageState extends State {
late GameInfoBean gameData;
bool _isInitialized = false;
bool isCollect = false;
+ late GameUserInfoBean gameUserInfoBean;
List infoRecommendList = [];
@@ -43,7 +45,6 @@ class _GameInfoPageState extends State {
case "getGameInfo":
EasyLoading.dismiss();
gameData = event['data'];
- isCollect = gameData.isCollect!;
_isInitialized = true;
break;
@@ -54,6 +55,11 @@ class _GameInfoPageState extends State {
case "gameCollect":
isCollect = event['data'];
break;
+
+ case "getGameUserInfo":
+ gameUserInfoBean = event['data'];
+ isCollect = gameUserInfoBean.isCollect!;
+ break;
}
setState(() {});
@@ -63,6 +69,7 @@ class _GameInfoPageState extends State {
FunctionUtil.loading();
_viewModel.getGameInfo(widget.gameId);
_viewModel.gameRecommendations(widget.gameId);
+ _viewModel.getGameUserInfo(widget.gameId);
}
///开始游戏
diff --git a/lib/tools/game/game_model.dart b/lib/tools/game/game_model.dart
index 8d295a8..b912cb7 100644
--- a/lib/tools/game/game_model.dart
+++ b/lib/tools/game/game_model.dart
@@ -7,6 +7,7 @@ import '../../beans/game_info_recommend_bean.dart';
import '../../beans/game_list_bean.dart';
import '../../beans/game_play_time_bean.dart';
import '../../beans/game_type_bean.dart';
+import '../../beans/game_user_info_bean.dart';
import '../../network/BaseEntity.dart';
import '../../network/NetworkConfig.dart';
import '../../network/RequestCenter.dart';
@@ -151,4 +152,26 @@ class GameModel {
print("errorEntity==${errorEntity.message}");
});
}
+
+ ///获取用户游戏详情数据
+ Future getGameUserInfo(gameId) async {
+ RequestCenter.instance.requestGet(NetworkConfig.getGameUserInfo, {"gameId": gameId}, (BaseEntity dataEntity) {
+ if (dataEntity.code == 0) {
+
+ GameUserInfoBean gameUserInfoBean = GameUserInfoBean.fromJson(dataEntity.data);
+
+ streamController.sink.add({
+ 'code': "getGameUserInfo", //有数据
+ 'data': gameUserInfoBean
+ });
+ } else {
+ streamController.sink.add({
+ 'code': "-1", //有数据
+ 'data': dataEntity.message
+ });
+ }
+ }, (ErrorEntity errorEntity) {
+ print("errorEntity==${errorEntity.message}");
+ });
+ }
}
diff --git a/lib/tools/me/my_page.dart b/lib/tools/me/my_page.dart
index 693d2c0..5cd9f4a 100644
--- a/lib/tools/me/my_page.dart
+++ b/lib/tools/me/my_page.dart
@@ -193,7 +193,7 @@ class _MyPageState extends State with AutomaticKeepAliveClientMixin {
left: l23,
top: t22,
child: Text(
- "我的游戏时长",
+ "已游玩时长",
style: TextStyle(fontSize: l11, color: Color(0xFFE2F3FF)),
)),
Positioned(