增加显示webpage
This commit is contained in:
parent
61d915ba55
commit
c386669773
File diff suppressed because one or more lines are too long
@ -209,6 +209,16 @@ function showQRCode(funId, content) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function showWebPage(funId, url) {
|
||||||
|
try {
|
||||||
|
jsb.showWebPage(funId, url);
|
||||||
|
// jsb.openURL(url);
|
||||||
|
return JSON.stringify({ errcode: 0, data: 1 });
|
||||||
|
} catch (err) {
|
||||||
|
return JSON.stringify({ errcode: 1, errmsg: err });
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
function scanQRCode(funId, title) {
|
function scanQRCode(funId, title) {
|
||||||
console.log("scanQRCode: " + title);
|
console.log("scanQRCode: " + title);
|
||||||
promiseCb(funId, jc.wallet.nativeSvr.scanQRCode(title));
|
promiseCb(funId, jc.wallet.nativeSvr.scanQRCode(title));
|
||||||
|
@ -19,6 +19,7 @@ import com.bytedance.sdk.open.tiktok.TikTokOpenApiFactory;
|
|||||||
import com.bytedance.sdk.open.tiktok.api.TikTokOpenApi;
|
import com.bytedance.sdk.open.tiktok.api.TikTokOpenApi;
|
||||||
import com.bytedance.sdk.open.tiktok.authorize.model.Authorization;
|
import com.bytedance.sdk.open.tiktok.authorize.model.Authorization;
|
||||||
import com.cege.games.release.activity.CustomCaptureActivity;
|
import com.cege.games.release.activity.CustomCaptureActivity;
|
||||||
|
import com.cege.games.release.activity.WebPageActivity;
|
||||||
import com.cege.games.release.dialog.QRCodeActivity;
|
import com.cege.games.release.dialog.QRCodeActivity;
|
||||||
import com.facebook.AccessToken;
|
import com.facebook.AccessToken;
|
||||||
import com.facebook.CallbackManager;
|
import com.facebook.CallbackManager;
|
||||||
@ -120,6 +121,7 @@ public class MainActivity extends UnityPlayerActivity
|
|||||||
private String oid;
|
private String oid;
|
||||||
|
|
||||||
private QRCodeActivity qrCodeActivity;
|
private QRCodeActivity qrCodeActivity;
|
||||||
|
private WebPageActivity webPageActivity;
|
||||||
|
|
||||||
// AppAuth
|
// AppAuth
|
||||||
private AuthorizationService mAuthService;
|
private AuthorizationService mAuthService;
|
||||||
@ -261,9 +263,12 @@ public class MainActivity extends UnityPlayerActivity
|
|||||||
// begin for unity
|
// begin for unity
|
||||||
@Override
|
@Override
|
||||||
protected void onNewIntent(Intent intent) {
|
protected void onNewIntent(Intent intent) {
|
||||||
// To support deep linking, we need to make sure that the client can get access to
|
// To support deep linking, we need to make sure that the client can get access
|
||||||
// the last sent intent. The clients access this through a JNI api that allows them
|
// to
|
||||||
// to get the intent set on launch. To update that after launch we have to manually
|
// the last sent intent. The clients access this through a JNI api that allows
|
||||||
|
// them
|
||||||
|
// to get the intent set on launch. To update that after launch we have to
|
||||||
|
// manually
|
||||||
// replace the intent with the one caught here.
|
// replace the intent with the one caught here.
|
||||||
setIntent(intent);
|
setIntent(intent);
|
||||||
}
|
}
|
||||||
@ -288,6 +293,7 @@ public class MainActivity extends UnityPlayerActivity
|
|||||||
public void runOnGLThread(Runnable pRunnable) {
|
public void runOnGLThread(Runnable pRunnable) {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/** begin of easypermissions */
|
/** begin of easypermissions */
|
||||||
@Override
|
@Override
|
||||||
public void onRequestPermissionsResult(int requestCode, String[] permissions, int[] grantResults) {
|
public void onRequestPermissionsResult(int requestCode, String[] permissions, int[] grantResults) {
|
||||||
@ -331,6 +337,7 @@ public class MainActivity extends UnityPlayerActivity
|
|||||||
RC_CAMERA, perms);
|
RC_CAMERA, perms);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@AfterPermissionGranted(RC_LOAD_KEY)
|
@AfterPermissionGranted(RC_LOAD_KEY)
|
||||||
private void checkImagePermissions() {
|
private void checkImagePermissions() {
|
||||||
String[] perms;
|
String[] perms;
|
||||||
@ -352,6 +359,7 @@ public class MainActivity extends UnityPlayerActivity
|
|||||||
RC_LOAD_KEY, perms);
|
RC_LOAD_KEY, perms);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@AfterPermissionGranted(RC_SAVE_QR)
|
@AfterPermissionGranted(RC_SAVE_QR)
|
||||||
private void checkSavePermissions() {
|
private void checkSavePermissions() {
|
||||||
String[] perms = { Manifest.permission.WRITE_EXTERNAL_STORAGE };
|
String[] perms = { Manifest.permission.WRITE_EXTERNAL_STORAGE };
|
||||||
@ -361,7 +369,8 @@ public class MainActivity extends UnityPlayerActivity
|
|||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// Do not have permissions, request them now
|
// Do not have permissions, request them now
|
||||||
EasyPermissions.requestPermissions(MainActivity.app, "We need Write WRITE_EXTERNAL_STORAGE for backup Wallet Restore Key",
|
EasyPermissions.requestPermissions(MainActivity.app,
|
||||||
|
"We need Write WRITE_EXTERNAL_STORAGE for backup Wallet Restore Key",
|
||||||
RC_SAVE_QR, perms);
|
RC_SAVE_QR, perms);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -396,6 +405,7 @@ public class MainActivity extends UnityPlayerActivity
|
|||||||
funId = "";
|
funId = "";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void parsePhotoData(Bitmap bitmap) {
|
private void parsePhotoData(Bitmap bitmap) {
|
||||||
asyncThread(() -> {
|
asyncThread(() -> {
|
||||||
final String result = CodeUtils.parseQRCode(bitmap);
|
final String result = CodeUtils.parseQRCode(bitmap);
|
||||||
@ -483,14 +493,16 @@ public class MainActivity extends UnityPlayerActivity
|
|||||||
// Signed in successfully, show authenticated UI.
|
// Signed in successfully, show authenticated UI.
|
||||||
} catch (ApiException e) {
|
} catch (ApiException e) {
|
||||||
// The ApiException status code indicates the detailed failure reason.
|
// The ApiException status code indicates the detailed failure reason.
|
||||||
// Please refer to the GoogleSignInStatusCodes class reference for more information.
|
// Please refer to the GoogleSignInStatusCodes class reference for more
|
||||||
|
// information.
|
||||||
Log.w(TAG, "signInResult:failed code=" + e.getStatusCode());
|
Log.w(TAG, "signInResult:failed code=" + e.getStatusCode());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// begin of AppAuth
|
// begin of AppAuth
|
||||||
/**
|
/**
|
||||||
* Initializes the authorization service configuration if necessary, either from the local
|
* Initializes the authorization service configuration if necessary, either from
|
||||||
|
* the local
|
||||||
* static values or by retrieving an OpenID discovery document.
|
* static values or by retrieving an OpenID discovery document.
|
||||||
*/
|
*/
|
||||||
@WorkerThread
|
@WorkerThread
|
||||||
@ -505,7 +517,8 @@ public class MainActivity extends UnityPlayerActivity
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// if we are not using discovery, build the authorization service configuration directly
|
// if we are not using discovery, build the authorization service configuration
|
||||||
|
// directly
|
||||||
// from the static configuration values.
|
// from the static configuration values.
|
||||||
if (mConfiguration.getDiscoveryUri() == null) {
|
if (mConfiguration.getDiscoveryUri() == null) {
|
||||||
Log.i(TAG, "Creating auth config from res/raw/auth_config.json");
|
Log.i(TAG, "Creating auth config from res/raw/auth_config.json");
|
||||||
@ -582,8 +595,7 @@ public class MainActivity extends UnityPlayerActivity
|
|||||||
mAuthIntentLatch = new CountDownLatch(1);
|
mAuthIntentLatch = new CountDownLatch(1);
|
||||||
mExecutor.execute(() -> {
|
mExecutor.execute(() -> {
|
||||||
Log.i(TAG, "Warming up browser instance for auth request");
|
Log.i(TAG, "Warming up browser instance for auth request");
|
||||||
CustomTabsIntent.Builder intentBuilder =
|
CustomTabsIntent.Builder intentBuilder = mAuthService.createCustomTabsIntentBuilder(mAuthRequest.get().toUri());
|
||||||
mAuthService.createCustomTabsIntentBuilder(mAuthRequest.get().toUri());
|
|
||||||
mAuthIntent.set(intentBuilder.build());
|
mAuthIntent.set(intentBuilder.build());
|
||||||
mAuthIntentLatch.countDown();
|
mAuthIntentLatch.countDown();
|
||||||
});
|
});
|
||||||
@ -597,7 +609,8 @@ public class MainActivity extends UnityPlayerActivity
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Initiates a dynamic registration request if a client ID is not provided by the static
|
* Initiates a dynamic registration request if a client ID is not provided by
|
||||||
|
* the static
|
||||||
* configuration.
|
* configuration.
|
||||||
*/
|
*/
|
||||||
@WorkerThread
|
@WorkerThread
|
||||||
@ -610,8 +623,7 @@ public class MainActivity extends UnityPlayerActivity
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
RegistrationResponse lastResponse =
|
RegistrationResponse lastResponse = mAuthStateManager.getCurrent().getLastRegistrationResponse();
|
||||||
mAuthStateManager.getCurrent().getLastRegistrationResponse();
|
|
||||||
if (lastResponse != null) {
|
if (lastResponse != null) {
|
||||||
Log.i(TAG, "Using dynamic client ID: " + lastResponse.clientId);
|
Log.i(TAG, "Using dynamic client ID: " + lastResponse.clientId);
|
||||||
// already dynamically registered a client ID
|
// already dynamically registered a client ID
|
||||||
@ -673,7 +685,8 @@ public class MainActivity extends UnityPlayerActivity
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Performs the authorization request, using the browser selected in the spinner,
|
* Performs the authorization request, using the browser selected in the
|
||||||
|
* spinner,
|
||||||
* and a user-provided `login_hint` if available.
|
* and a user-provided `login_hint` if available.
|
||||||
*/
|
*/
|
||||||
@WorkerThread
|
@WorkerThread
|
||||||
@ -738,6 +751,7 @@ public class MainActivity extends UnityPlayerActivity
|
|||||||
runOnUiThread(() -> successSdkCb(state.getIdToken()));
|
runOnUiThread(() -> successSdkCb(state.getIdToken()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@MainThread
|
@MainThread
|
||||||
private void successSdkCb(String idToken) {
|
private void successSdkCb(String idToken) {
|
||||||
JcSDK.nativeCb(this.funId, null, idToken);
|
JcSDK.nativeCb(this.funId, null, idToken);
|
||||||
@ -762,7 +776,6 @@ public class MainActivity extends UnityPlayerActivity
|
|||||||
tiktokOpenApi.authorize(request);
|
tiktokOpenApi.authorize(request);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public void showQRCode(String funid, String str, String title, String oid) {
|
public void showQRCode(String funid, String str, String title, String oid) {
|
||||||
runOnUiThread(() -> {
|
runOnUiThread(() -> {
|
||||||
if (qrCodeActivity == null) {
|
if (qrCodeActivity == null) {
|
||||||
@ -799,6 +812,7 @@ public class MainActivity extends UnityPlayerActivity
|
|||||||
runOnUiThread(() -> errorSdkCb("access token expired"));
|
runOnUiThread(() -> errorSdkCb("access token expired"));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onCancel() {
|
public void onCancel() {
|
||||||
Log.d(TAG, "Login cancel");
|
Log.d(TAG, "Login cancel");
|
||||||
@ -862,5 +876,14 @@ public class MainActivity extends UnityPlayerActivity
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void showPage(String fid, String url) {
|
||||||
|
runOnUiThread(() -> {
|
||||||
|
if (webPageActivity == null) {
|
||||||
|
webPageActivity = new WebPageActivity(getContext());
|
||||||
|
}
|
||||||
|
webPageActivity.showWebPage(url);
|
||||||
|
webPageActivity.show();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
21
app/src/com/cege/games/release/activity/WebPageActivity.java
Normal file
21
app/src/com/cege/games/release/activity/WebPageActivity.java
Normal file
@ -0,0 +1,21 @@
|
|||||||
|
package com.cege.games.release.activity;
|
||||||
|
|
||||||
|
import android.app.Dialog;
|
||||||
|
import android.content.Context;
|
||||||
|
import android.webkit.WebView;
|
||||||
|
public class WebPageActivity extends Dialog {
|
||||||
|
|
||||||
|
public WebPageActivity(Context context) {
|
||||||
|
super(context);
|
||||||
|
}
|
||||||
|
|
||||||
|
// show web view
|
||||||
|
public void showWebPage(String url) {
|
||||||
|
WebView webView = new WebView(getContext());
|
||||||
|
setContentView(webView);
|
||||||
|
|
||||||
|
webView.loadUrl(url);
|
||||||
|
|
||||||
|
show();
|
||||||
|
}
|
||||||
|
}
|
@ -68,6 +68,7 @@ public class JcSDK {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
public static void showQRCode(String funid, String content) { MainActivity.app.showQRCode(funid, content, "", "");}
|
public static void showQRCode(String funid, String content) { MainActivity.app.showQRCode(funid, content, "", "");}
|
||||||
|
public static void showWebPage(String funid, String url) { MainActivity.app.showPage(funid, url);}
|
||||||
public static void showRestoreQR(String funid, String content, String title, String oid) { MainActivity.app.showQRCode(funid, content, title, oid);}
|
public static void showRestoreQR(String funid, String content, String title, String oid) { MainActivity.app.showQRCode(funid, content, title, oid);}
|
||||||
public static void scanQRCode(String funid, String title) {
|
public static void scanQRCode(String funid, String title) {
|
||||||
MainActivity.app.showQRScan(funid, title);
|
MainActivity.app.showQRScan(funid, title);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user