增加显示二维码的功能
This commit is contained in:
parent
5de9f17494
commit
f2dbcf604c
10
.idea/misc.xml
generated
10
.idea/misc.xml
generated
@ -1,5 +1,15 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="DesignSurface">
|
||||
<option name="filePathToZoomLevelMap">
|
||||
<map>
|
||||
<entry key="app/src/main/res/layout/qr_vew.xml" value="0.125" />
|
||||
<entry key="app/src/main/res/layout/qrcode_view.xml" value="0.1421875" />
|
||||
<entry key="res/drawable/ic_launcher_background.xml" value="0.225" />
|
||||
<entry key="res/layout/activity_main.xml" value="0.18840579710144928" />
|
||||
</map>
|
||||
</option>
|
||||
</component>
|
||||
<component name="ProjectRootManager" version="2" languageLevel="JDK_1_8" default="true" project-jdk-name="Android Studio default JDK" project-jdk-type="JavaSDK">
|
||||
<output url="file://$PROJECT_DIR$/build/classes" />
|
||||
</component>
|
||||
|
@ -16,6 +16,7 @@ import android.view.KeyEvent;
|
||||
import android.view.MotionEvent;
|
||||
import android.view.Window;
|
||||
|
||||
import com.fitchgc.jcwallet.dialog.QRCodeActivity;
|
||||
import com.google.android.gms.auth.api.signin.GoogleSignIn;
|
||||
import com.google.android.gms.auth.api.signin.GoogleSignInAccount;
|
||||
import com.google.android.gms.auth.api.signin.GoogleSignInClient;
|
||||
@ -95,6 +96,8 @@ public class MainActivity extends Activity
|
||||
private String title;
|
||||
private String funId;
|
||||
|
||||
private QRCodeActivity qrCodeActivity;
|
||||
|
||||
//AppAuth
|
||||
private AuthorizationService mAuthService;
|
||||
private AuthStateManager mAuthStateManager;
|
||||
@ -719,4 +722,14 @@ public class MainActivity extends Activity
|
||||
JcSDK.googleOauthCb(this.funId, null, idToken);
|
||||
}
|
||||
|
||||
|
||||
public void showQRCode(String funid, String str, String title) {
|
||||
runOnUiThread(() -> {
|
||||
if (qrCodeActivity == null) {
|
||||
qrCodeActivity = new QRCodeActivity(getContext());
|
||||
}
|
||||
qrCodeActivity.showQRCode(str, title);
|
||||
qrCodeActivity.show();
|
||||
});
|
||||
}
|
||||
}
|
29
app/src/com/fitchgc/jcwallet/dialog/BaseDialog.java
Normal file
29
app/src/com/fitchgc/jcwallet/dialog/BaseDialog.java
Normal file
@ -0,0 +1,29 @@
|
||||
package com.fitchgc.jcwallet.dialog;
|
||||
|
||||
import android.app.Dialog;
|
||||
import android.content.Context;
|
||||
import android.view.Window;
|
||||
import android.view.WindowManager;
|
||||
|
||||
import com.fitchgc.jcwallet.R;
|
||||
|
||||
public class BaseDialog extends Dialog {
|
||||
|
||||
public BaseDialog(Context context, int themeResId) {
|
||||
super(context, R.style.DialogStyle);
|
||||
Window win = getWindow();
|
||||
// win.setWindowAnimations(R.style.Dialog_bottom_enter_ani);
|
||||
// win.getDecorView().setPadding(0, 0, 0, 0);
|
||||
// win.setGravity(Gravity.BOTTOM);
|
||||
WindowManager.LayoutParams lp = win.getAttributes();
|
||||
lp.width = WindowManager.LayoutParams.MATCH_PARENT;
|
||||
lp.height = WindowManager.LayoutParams.WRAP_CONTENT;
|
||||
win.setAttributes(lp);
|
||||
}
|
||||
|
||||
public BaseDialog(Context context) {
|
||||
this(context, 0);
|
||||
}
|
||||
|
||||
|
||||
}
|
45
app/src/com/fitchgc/jcwallet/dialog/QRCodeActivity.java
Normal file
45
app/src/com/fitchgc/jcwallet/dialog/QRCodeActivity.java
Normal file
@ -0,0 +1,45 @@
|
||||
package com.fitchgc.jcwallet.dialog;
|
||||
|
||||
import android.content.Context;
|
||||
import android.graphics.Bitmap;
|
||||
import android.graphics.BitmapFactory;
|
||||
import android.os.Bundle;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.TextView;
|
||||
|
||||
import com.fitchgc.jcwallet.MainActivity;
|
||||
import com.fitchgc.jcwallet.R;
|
||||
import com.king.zxing.util.CodeUtils;
|
||||
|
||||
public class QRCodeActivity extends BaseDialog{
|
||||
|
||||
private final Context baseContent;
|
||||
private TextView titleLabel;
|
||||
private ImageView ivCode;
|
||||
|
||||
|
||||
public QRCodeActivity(Context context) {
|
||||
super(context);
|
||||
baseContent = context;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
setContentView(R.layout.qrcode_view);
|
||||
ivCode = findViewById(R.id.ivCode);
|
||||
titleLabel = findViewById(R.id.qrTitleLabel);
|
||||
}
|
||||
|
||||
public void showQRCode(String content, String title){
|
||||
new Thread(() -> {
|
||||
Bitmap logo = BitmapFactory.decodeResource(baseContent.getResources(),R.drawable.zxl_flashlight_on);
|
||||
Bitmap bitmap = CodeUtils.createQRCode(content,600, logo);
|
||||
MainActivity.app.runOnUiThread(()->{
|
||||
titleLabel.setText(title);
|
||||
ivCode.setImageBitmap(bitmap);
|
||||
});
|
||||
}).start();
|
||||
|
||||
}
|
||||
}
|
@ -67,7 +67,7 @@ public class JcSDK {
|
||||
MainActivity.app.startActivity(i);
|
||||
}
|
||||
}
|
||||
|
||||
public static void showQRCode(String funid, String content, String title) { MainActivity.app.showQRCode(funid, content, title);}
|
||||
public static void scanQRCode(String funid, String title) {
|
||||
MainActivity.app.showQRScan(funid, title);
|
||||
}
|
||||
|
22
app/src/main/res/layout/qrcode_view.xml
Normal file
22
app/src/main/res/layout/qrcode_view.xml
Normal file
@ -0,0 +1,22 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:orientation="vertical"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent">
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/ivCode"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_alignParentBottom="true"
|
||||
android:layout_centerHorizontal="true"
|
||||
/>
|
||||
<TextView
|
||||
android:id="@+id/qrTitleLabel"
|
||||
android:text="假装是 APP 主页"
|
||||
android:gravity="center"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"/>
|
||||
</LinearLayout>
|
49
js/main.js
49
js/main.js
@ -163,40 +163,18 @@ function createAccount(funId) {
|
||||
* @return {string} account actived
|
||||
*/
|
||||
function importAccount(funId, privateKey) {
|
||||
// try {
|
||||
// let address = jc.wallet.importAccount(privateKey);
|
||||
// return JSON.stringify({
|
||||
// errcode: 0,
|
||||
// data: address,
|
||||
// });
|
||||
// } catch (err) {
|
||||
// return JSON.stringify({
|
||||
// errcode: 1,
|
||||
// errmsg: err,
|
||||
// });
|
||||
// }
|
||||
let addresses = ["0x90F8bf6A479f320ead074411a4B0e7944Ea8c9C1","0xCd36bFD6f5c9685A5b1DD953E8279eeC7d41e1E1","0xb3212b66C337F83D277172D891Daf31776FF9D79"]
|
||||
let values = ["1024168356010420","0","110241683560010039000000000000000134390000000000000003020000000000000000000000","1667381156"]
|
||||
let signature = '0x5788bc2812b31165aff7c344321076b55d61f84ee1cb064f12fac3cea7cfbbd03f180a2228b4cce665a00d52fd08c10e3e09d1bf22a008c999bd72dcb372f6fb1b'
|
||||
jc.wallet.jcStandard
|
||||
.buyNft721({
|
||||
addresses,
|
||||
values,
|
||||
signature,
|
||||
})
|
||||
.then((result) => {
|
||||
jsb.jcCallback(
|
||||
funId,
|
||||
JSON.stringify({
|
||||
errcode: 0,
|
||||
data: result,
|
||||
})
|
||||
);
|
||||
})
|
||||
.catch((err) => {
|
||||
console.log(JSON.stringify(err))
|
||||
jsb.jcCallback(funId,JSON.stringify({errcode: 1,errmsg: err}));
|
||||
try {
|
||||
let address = jc.wallet.importAccount(privateKey);
|
||||
return JSON.stringify({
|
||||
errcode: 0,
|
||||
data: address,
|
||||
});
|
||||
} catch (err) {
|
||||
return JSON.stringify({
|
||||
errcode: 1,
|
||||
errmsg: err,
|
||||
});
|
||||
}
|
||||
}
|
||||
/**
|
||||
* active one account
|
||||
@ -355,6 +333,7 @@ function restoreFromMnemonic(funId, mnemonic, password) {
|
||||
|
||||
function scanQRCode(funId, title) {
|
||||
try {
|
||||
console.log('scanQRCode: ' + title)
|
||||
jsb.scanQRCode(funId, title);
|
||||
} catch (err) {
|
||||
return JSON.stringify({
|
||||
@ -400,9 +379,6 @@ function signOutGoogle(funId) {
|
||||
//}
|
||||
|
||||
function buyNft721(funId, addresses, values, signature) {
|
||||
addresses = ["0x90F8bf6A479f320ead074411a4B0e7944Ea8c9C1","0xCd36bFD6f5c9685A5b1DD953E8279eeC7d41e1E1","0xb3212b66C337F83D277172D891Daf31776FF9D79"]
|
||||
values = ["1024168356010499","0","110241683560010039000000000000000134390000000000000003020000000000000000000000","1667381156"]
|
||||
signature = '0x4278d777d25fa96bb9733dd6c924adf9a79a88de60c684894f29f02c739ff79231d62ecd10d9a07121d88f6719f6b49814fc2e9438a03a46e6bf0def5c1e3ad71b'
|
||||
jc.wallet.jcStandard
|
||||
.buyNft721({
|
||||
addresses,
|
||||
@ -566,6 +542,7 @@ function shardMixByUser(
|
||||
.catch((err) => {
|
||||
jsb.jcCallback(funId,JSON.stringify({errcode: 1,errmsg: err}));
|
||||
});
|
||||
}
|
||||
|
||||
function pluginChip(
|
||||
funId,
|
||||
|
@ -7,4 +7,5 @@
|
||||
<color name="teal_700">#FF018786</color>
|
||||
<color name="black">#FF000000</color>
|
||||
<color name="white">#FFFFFFFF</color>
|
||||
<color name="transparent">#00000000</color>
|
||||
</resources>
|
@ -2,5 +2,6 @@
|
||||
<string name="app_name">HeadlessCocos</string>
|
||||
<string name="game_view_content_description">Game view</string>
|
||||
<string name="permission_camera">Scan QRCode need camera permission</string>
|
||||
<string name="qr_code_title">QRCode</string>
|
||||
<string name="default_web_client_id">165555585193-j22geb66hjku5ns5lq5voaj4v7811cl7.apps.googleusercontent.com</string>
|
||||
</resources>
|
@ -9,4 +9,15 @@
|
||||
<item name="android:windowIsTranslucent">true</item>
|
||||
<item name="android:windowBackground">@android:color/transparent</item>
|
||||
</style>
|
||||
<style name="DialogStyle" parent="@android:style/Theme.Dialog">
|
||||
<item name="android:windowFrame">@null</item>
|
||||
<item name="android:windowBackground">@color/transparent</item>
|
||||
<item name="android:windowNoTitle">true</item>
|
||||
<item name="android:windowIsFloating">true</item>
|
||||
<item name="android:windowContentOverlay">@null</item>
|
||||
</style>
|
||||
<style name="Dialog_bottom_enter_ani">
|
||||
<item name="android:windowEnterAnimation">@anim/dlg_enter</item>
|
||||
<item name="android:windowExitAnimation">@anim/dlg_exit</item>
|
||||
</style>
|
||||
</resources>
|
||||
|
Loading…
x
Reference in New Issue
Block a user