增加显示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) {
|
||||
console.log("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.authorize.model.Authorization;
|
||||
import com.cege.games.release.activity.CustomCaptureActivity;
|
||||
import com.cege.games.release.activity.WebPageActivity;
|
||||
import com.cege.games.release.dialog.QRCodeActivity;
|
||||
import com.facebook.AccessToken;
|
||||
import com.facebook.CallbackManager;
|
||||
@ -120,6 +121,7 @@ public class MainActivity extends UnityPlayerActivity
|
||||
private String oid;
|
||||
|
||||
private QRCodeActivity qrCodeActivity;
|
||||
private WebPageActivity webPageActivity;
|
||||
|
||||
// AppAuth
|
||||
private AuthorizationService mAuthService;
|
||||
@ -261,9 +263,12 @@ public class MainActivity extends UnityPlayerActivity
|
||||
// begin for unity
|
||||
@Override
|
||||
protected void onNewIntent(Intent intent) {
|
||||
// To support deep linking, we need to make sure that the client can get access to
|
||||
// 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
|
||||
// To support deep linking, we need to make sure that the client can get access
|
||||
// to
|
||||
// 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.
|
||||
setIntent(intent);
|
||||
}
|
||||
@ -288,6 +293,7 @@ public class MainActivity extends UnityPlayerActivity
|
||||
public void runOnGLThread(Runnable pRunnable) {
|
||||
|
||||
}
|
||||
|
||||
/** begin of easypermissions */
|
||||
@Override
|
||||
public void onRequestPermissionsResult(int requestCode, String[] permissions, int[] grantResults) {
|
||||
@ -331,6 +337,7 @@ public class MainActivity extends UnityPlayerActivity
|
||||
RC_CAMERA, perms);
|
||||
}
|
||||
}
|
||||
|
||||
@AfterPermissionGranted(RC_LOAD_KEY)
|
||||
private void checkImagePermissions() {
|
||||
String[] perms;
|
||||
@ -352,6 +359,7 @@ public class MainActivity extends UnityPlayerActivity
|
||||
RC_LOAD_KEY, perms);
|
||||
}
|
||||
}
|
||||
|
||||
@AfterPermissionGranted(RC_SAVE_QR)
|
||||
private void checkSavePermissions() {
|
||||
String[] perms = { Manifest.permission.WRITE_EXTERNAL_STORAGE };
|
||||
@ -361,7 +369,8 @@ public class MainActivity extends UnityPlayerActivity
|
||||
}
|
||||
} else {
|
||||
// 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);
|
||||
}
|
||||
}
|
||||
@ -396,6 +405,7 @@ public class MainActivity extends UnityPlayerActivity
|
||||
funId = "";
|
||||
}
|
||||
}
|
||||
|
||||
private void parsePhotoData(Bitmap bitmap) {
|
||||
asyncThread(() -> {
|
||||
final String result = CodeUtils.parseQRCode(bitmap);
|
||||
@ -483,14 +493,16 @@ public class MainActivity extends UnityPlayerActivity
|
||||
// Signed in successfully, show authenticated UI.
|
||||
} catch (ApiException e) {
|
||||
// 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());
|
||||
}
|
||||
}
|
||||
|
||||
// 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.
|
||||
*/
|
||||
@WorkerThread
|
||||
@ -505,7 +517,8 @@ public class MainActivity extends UnityPlayerActivity
|
||||
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.
|
||||
if (mConfiguration.getDiscoveryUri() == null) {
|
||||
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);
|
||||
mExecutor.execute(() -> {
|
||||
Log.i(TAG, "Warming up browser instance for auth request");
|
||||
CustomTabsIntent.Builder intentBuilder =
|
||||
mAuthService.createCustomTabsIntentBuilder(mAuthRequest.get().toUri());
|
||||
CustomTabsIntent.Builder intentBuilder = mAuthService.createCustomTabsIntentBuilder(mAuthRequest.get().toUri());
|
||||
mAuthIntent.set(intentBuilder.build());
|
||||
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.
|
||||
*/
|
||||
@WorkerThread
|
||||
@ -610,8 +623,7 @@ public class MainActivity extends UnityPlayerActivity
|
||||
return;
|
||||
}
|
||||
|
||||
RegistrationResponse lastResponse =
|
||||
mAuthStateManager.getCurrent().getLastRegistrationResponse();
|
||||
RegistrationResponse lastResponse = mAuthStateManager.getCurrent().getLastRegistrationResponse();
|
||||
if (lastResponse != null) {
|
||||
Log.i(TAG, "Using dynamic client ID: " + lastResponse.clientId);
|
||||
// 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.
|
||||
*/
|
||||
@WorkerThread
|
||||
@ -738,6 +751,7 @@ public class MainActivity extends UnityPlayerActivity
|
||||
runOnUiThread(() -> successSdkCb(state.getIdToken()));
|
||||
}
|
||||
}
|
||||
|
||||
@MainThread
|
||||
private void successSdkCb(String idToken) {
|
||||
JcSDK.nativeCb(this.funId, null, idToken);
|
||||
@ -762,7 +776,6 @@ public class MainActivity extends UnityPlayerActivity
|
||||
tiktokOpenApi.authorize(request);
|
||||
}
|
||||
|
||||
|
||||
public void showQRCode(String funid, String str, String title, String oid) {
|
||||
runOnUiThread(() -> {
|
||||
if (qrCodeActivity == null) {
|
||||
@ -799,6 +812,7 @@ public class MainActivity extends UnityPlayerActivity
|
||||
runOnUiThread(() -> errorSdkCb("access token expired"));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCancel() {
|
||||
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 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 scanQRCode(String funid, String title) {
|
||||
MainActivity.app.showQRScan(funid, title);
|
||||
|
Loading…
x
Reference in New Issue
Block a user