增加显示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,8 +121,9 @@ 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;
|
||||||
private AuthStateManager mAuthStateManager;
|
private AuthStateManager mAuthStateManager;
|
||||||
private JConfiguration mConfiguration;
|
private JConfiguration mConfiguration;
|
||||||
@ -169,8 +171,8 @@ public class MainActivity extends UnityPlayerActivity
|
|||||||
// begin of google sign
|
// begin of google sign
|
||||||
GoogleSignInOptions gso = new GoogleSignInOptions.Builder(GoogleSignInOptions.DEFAULT_SIGN_IN)
|
GoogleSignInOptions gso = new GoogleSignInOptions.Builder(GoogleSignInOptions.DEFAULT_SIGN_IN)
|
||||||
.requestIdToken(getString(R.string.default_web_client_id1))
|
.requestIdToken(getString(R.string.default_web_client_id1))
|
||||||
.requestScopes(new Scope(Scopes.EMAIL))
|
.requestScopes(new Scope(Scopes.EMAIL))
|
||||||
// .requestScopes(new Scope("https://www.googleapis.com/auth/drive.appdata"))
|
// .requestScopes(new Scope("https://www.googleapis.com/auth/drive.appdata"))
|
||||||
.build();
|
.build();
|
||||||
mGoogleSignInClient = GoogleSignIn.getClient(this, gso);
|
mGoogleSignInClient = GoogleSignIn.getClient(this, gso);
|
||||||
// end of google sign
|
// end of google sign
|
||||||
@ -191,11 +193,11 @@ public class MainActivity extends UnityPlayerActivity
|
|||||||
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
|
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
|
||||||
super.onActivityResult(requestCode, resultCode, data);
|
super.onActivityResult(requestCode, resultCode, data);
|
||||||
mCallbackManager.onActivityResult(requestCode, resultCode, data);
|
mCallbackManager.onActivityResult(requestCode, resultCode, data);
|
||||||
if(resultCode == RESULT_OK && data!=null){
|
if (resultCode == RESULT_OK && data != null) {
|
||||||
switch (requestCode){
|
switch (requestCode) {
|
||||||
case REQUEST_CODE_SCAN:
|
case REQUEST_CODE_SCAN:
|
||||||
String result = CameraScan.parseScanResult(data);
|
String result = CameraScan.parseScanResult(data);
|
||||||
Log.i(TAG, "scan qrcode with funId: " +funId+ " result: " + result);
|
Log.i(TAG, "scan qrcode with funId: " + funId + " result: " + result);
|
||||||
JcSDK.nativeCb(funId, null, result);
|
JcSDK.nativeCb(funId, null, result);
|
||||||
funId = "";
|
funId = "";
|
||||||
break;
|
break;
|
||||||
@ -233,7 +235,7 @@ public class MainActivity extends UnityPlayerActivity
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (!next) {
|
if (!next) {
|
||||||
if (requestCode == RC_SIGN_IN) {
|
if (requestCode == RC_SIGN_IN) {
|
||||||
Task<GoogleSignInAccount> task = GoogleSignIn.getSignedInAccountFromIntent(data);
|
Task<GoogleSignInAccount> task = GoogleSignIn.getSignedInAccountFromIntent(data);
|
||||||
handleSignInResult(task);
|
handleSignInResult(task);
|
||||||
}
|
}
|
||||||
@ -246,7 +248,7 @@ public class MainActivity extends UnityPlayerActivity
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private Context getContext(){
|
private Context getContext() {
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -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,7 +293,8 @@ 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) {
|
||||||
super.onRequestPermissionsResult(requestCode, permissions, grantResults);
|
super.onRequestPermissionsResult(requestCode, permissions, grantResults);
|
||||||
@ -321,8 +327,8 @@ public class MainActivity extends UnityPlayerActivity
|
|||||||
* check if had permission for camera
|
* check if had permission for camera
|
||||||
*/
|
*/
|
||||||
@AfterPermissionGranted(RC_CAMERA)
|
@AfterPermissionGranted(RC_CAMERA)
|
||||||
private void checkCameraPermissions(){
|
private void checkCameraPermissions() {
|
||||||
String[] perms = {Manifest.permission.CAMERA};
|
String[] perms = { Manifest.permission.CAMERA };
|
||||||
if (EasyPermissions.hasPermissions(this, perms)) {
|
if (EasyPermissions.hasPermissions(this, perms)) {
|
||||||
startScan(title);
|
startScan(title);
|
||||||
} else {
|
} else {
|
||||||
@ -331,13 +337,14 @@ 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;
|
||||||
if (Build.VERSION.SDK_INT >= 33) {
|
if (Build.VERSION.SDK_INT >= 33) {
|
||||||
perms = new String[]{"android.permission.READ_MEDIA_IMAGES"};
|
perms = new String[] { "android.permission.READ_MEDIA_IMAGES" };
|
||||||
} else {
|
} else {
|
||||||
perms = new String[]{Manifest.permission.READ_EXTERNAL_STORAGE};
|
perms = new String[] { Manifest.permission.READ_EXTERNAL_STORAGE };
|
||||||
}
|
}
|
||||||
if (EasyPermissions.hasPermissions(this, perms)) {
|
if (EasyPermissions.hasPermissions(this, perms)) {
|
||||||
Bitmap bitmap = FileUtils.loadImgData(this, oid);
|
Bitmap bitmap = FileUtils.loadImgData(this, oid);
|
||||||
@ -352,16 +359,18 @@ 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 };
|
||||||
if (EasyPermissions.hasPermissions(this, perms)) {
|
if (EasyPermissions.hasPermissions(this, perms)) {
|
||||||
if (qrCodeActivity != null) {
|
if (qrCodeActivity != null) {
|
||||||
qrCodeActivity.saveAndClose();
|
qrCodeActivity.saveAndClose();
|
||||||
}
|
}
|
||||||
} 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);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -369,10 +378,10 @@ public class MainActivity extends UnityPlayerActivity
|
|||||||
/**
|
/**
|
||||||
* scan qrcode
|
* scan qrcode
|
||||||
*/
|
*/
|
||||||
private void startScan(String title){
|
private void startScan(String title) {
|
||||||
ActivityOptionsCompat optionsCompat = ActivityOptionsCompat.makeCustomAnimation(this,R.anim.in,R.anim.out);
|
ActivityOptionsCompat optionsCompat = ActivityOptionsCompat.makeCustomAnimation(this, R.anim.in, R.anim.out);
|
||||||
Intent intent = new Intent(this, CustomCaptureActivity.class);
|
Intent intent = new Intent(this, CustomCaptureActivity.class);
|
||||||
// Intent intent = new Intent(this, CaptureActivity.class);
|
// Intent intent = new Intent(this, CaptureActivity.class);
|
||||||
intent.putExtra(KEY_TITLE, title);
|
intent.putExtra(KEY_TITLE, title);
|
||||||
intent.putExtra(KEY_IS_CONTINUOUS, false);
|
intent.putExtra(KEY_IS_CONTINUOUS, false);
|
||||||
runOnUiThread(() -> {
|
runOnUiThread(() -> {
|
||||||
@ -381,13 +390,13 @@ public class MainActivity extends UnityPlayerActivity
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void asyncThread(Runnable runnable){
|
private void asyncThread(Runnable runnable) {
|
||||||
new Thread(runnable).start();
|
new Thread(runnable).start();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void parsePhoto(Intent data){
|
private void parsePhoto(Intent data) {
|
||||||
try {
|
try {
|
||||||
Bitmap bitmap = MediaStore.Images.Media.getBitmap(getContentResolver(),data.getData());
|
Bitmap bitmap = MediaStore.Images.Media.getBitmap(getContentResolver(), data.getData());
|
||||||
parsePhotoData(bitmap);
|
parsePhotoData(bitmap);
|
||||||
|
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
@ -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);
|
||||||
@ -425,7 +435,7 @@ public class MainActivity extends UnityPlayerActivity
|
|||||||
/**
|
/**
|
||||||
* start image scan
|
* start image scan
|
||||||
*/
|
*/
|
||||||
public void startPhotoCode(String funId){
|
public void startPhotoCode(String funId) {
|
||||||
Intent pickIntent = new Intent(Intent.ACTION_PICK,
|
Intent pickIntent = new Intent(Intent.ACTION_PICK,
|
||||||
MediaStore.Images.Media.EXTERNAL_CONTENT_URI);
|
MediaStore.Images.Media.EXTERNAL_CONTENT_URI);
|
||||||
pickIntent.setDataAndType(MediaStore.Images.Media.EXTERNAL_CONTENT_URI, "image/*");
|
pickIntent.setDataAndType(MediaStore.Images.Media.EXTERNAL_CONTENT_URI, "image/*");
|
||||||
@ -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
|
||||||
@ -728,7 +741,7 @@ public class MainActivity extends UnityPlayerActivity
|
|||||||
+ ((authException != null) ? authException.error : "");
|
+ ((authException != null) ? authException.error : "");
|
||||||
|
|
||||||
// WrongThread inference is incorrect for lambdas
|
// WrongThread inference is incorrect for lambdas
|
||||||
//noinspection WrongThread
|
// noinspection WrongThread
|
||||||
Log.d(TAG, message);
|
Log.d(TAG, message);
|
||||||
} else {
|
} else {
|
||||||
AuthState state = mAuthStateManager.getCurrent();
|
AuthState state = mAuthStateManager.getCurrent();
|
||||||
@ -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);
|
||||||
@ -752,17 +766,16 @@ public class MainActivity extends UnityPlayerActivity
|
|||||||
public void signWithTiktok(String funId) {
|
public void signWithTiktok(String funId) {
|
||||||
this.funId = funId;
|
this.funId = funId;
|
||||||
Log.i(TAG, "login with tiktok: " + funId);
|
Log.i(TAG, "login with tiktok: " + funId);
|
||||||
// STEP 1: Create an instance of TiktokOpenApi
|
// STEP 1: Create an instance of TiktokOpenApi
|
||||||
TikTokOpenApi tiktokOpenApi= TikTokOpenApiFactory.create(this);
|
TikTokOpenApi tiktokOpenApi = TikTokOpenApiFactory.create(this);
|
||||||
|
|
||||||
// STEP 2: Create an instance of Authorization.Request and set parameters
|
// STEP 2: Create an instance of Authorization.Request and set parameters
|
||||||
Authorization.Request request = new Authorization.Request();
|
Authorization.Request request = new Authorization.Request();
|
||||||
request.scope = "user.info.basic,video.list";
|
request.scope = "user.info.basic,video.list";
|
||||||
request.state = funId;
|
request.state = funId;
|
||||||
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) {
|
||||||
@ -775,9 +788,9 @@ public class MainActivity extends UnityPlayerActivity
|
|||||||
|
|
||||||
public void showToast(String text) {
|
public void showToast(String text) {
|
||||||
runOnUiThread(() -> {
|
runOnUiThread(() -> {
|
||||||
if(toast == null){
|
if (toast == null) {
|
||||||
toast = Toast.makeText(this,text,Toast.LENGTH_SHORT);
|
toast = Toast.makeText(this, text, Toast.LENGTH_SHORT);
|
||||||
}else{
|
} else {
|
||||||
toast.setDuration(Toast.LENGTH_SHORT);
|
toast.setDuration(Toast.LENGTH_SHORT);
|
||||||
toast.setText(text);
|
toast.setText(text);
|
||||||
}
|
}
|
||||||
@ -790,46 +803,47 @@ public class MainActivity extends UnityPlayerActivity
|
|||||||
mCallbackManager = CallbackManager.Factory.create();
|
mCallbackManager = CallbackManager.Factory.create();
|
||||||
fbLogger = AppEventsLogger.newLogger(this);
|
fbLogger = AppEventsLogger.newLogger(this);
|
||||||
LoginManager.getInstance().registerCallback(mCallbackManager,
|
LoginManager.getInstance().registerCallback(mCallbackManager,
|
||||||
new FacebookCallback<LoginResult>() {
|
new FacebookCallback<LoginResult>() {
|
||||||
@Override
|
@Override
|
||||||
public void onSuccess(LoginResult loginResult) {
|
public void onSuccess(LoginResult loginResult) {
|
||||||
AccessToken accessToken = AccessToken.getCurrentAccessToken();
|
AccessToken accessToken = AccessToken.getCurrentAccessToken();
|
||||||
Log.d(TAG, "Login Success:: accessToken: " + accessToken.getToken());
|
Log.d(TAG, "Login Success:: accessToken: " + accessToken.getToken());
|
||||||
if (!verifyFbAccessToken(accessToken)) {
|
if (!verifyFbAccessToken(accessToken)) {
|
||||||
runOnUiThread(() -> errorSdkCb("access token expired"));
|
runOnUiThread(() -> errorSdkCb("access token expired"));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
@Override
|
|
||||||
public void onCancel() {
|
|
||||||
Log.d(TAG, "Login cancel");
|
|
||||||
runOnUiThread(() -> errorSdkCb("user login cancel"));
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onError(FacebookException exception) {
|
public void onCancel() {
|
||||||
Log.i(TAG, "Login error: " + exception.getMessage());
|
Log.d(TAG, "Login cancel");
|
||||||
runOnUiThread(() -> errorSdkCb(exception.getMessage()));
|
runOnUiThread(() -> errorSdkCb("user login cancel"));
|
||||||
}
|
}
|
||||||
});
|
|
||||||
|
@Override
|
||||||
|
public void onError(FacebookException exception) {
|
||||||
|
Log.i(TAG, "Login error: " + exception.getMessage());
|
||||||
|
runOnUiThread(() -> errorSdkCb(exception.getMessage()));
|
||||||
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
public void signWithFacebook(String funId) {
|
public void signWithFacebook(String funId) {
|
||||||
Log.i(TAG, "login with facebook: " + funId);
|
Log.i(TAG, "login with facebook: " + funId);
|
||||||
this.funId = funId;
|
this.funId = funId;
|
||||||
AccessToken accessToken = AccessToken.getCurrentAccessToken();
|
AccessToken accessToken = AccessToken.getCurrentAccessToken();
|
||||||
// Log.d("Success", "Login:: accessToken: " + accessToken.getToken());
|
// Log.d("Success", "Login:: accessToken: " + accessToken.getToken());
|
||||||
if (!verifyFbAccessToken(accessToken)) {
|
if (!verifyFbAccessToken(accessToken)) {
|
||||||
LoginManager.getInstance().logInWithReadPermissions(this, Arrays.asList("public_profile", "email"));
|
LoginManager.getInstance().logInWithReadPermissions(this, Arrays.asList("public_profile", "email"));
|
||||||
}
|
}
|
||||||
|
|
||||||
// AccessToken.getCurrentAccessToken();
|
// AccessToken.getCurrentAccessToken();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void shareWithFacebook(String content) {
|
public void shareWithFacebook(String content) {
|
||||||
ShareLinkContent linkContent = new ShareLinkContent.Builder()
|
ShareLinkContent linkContent = new ShareLinkContent.Builder()
|
||||||
.setContentUrl(Uri.parse("https://www.baidu.com"))
|
.setContentUrl(Uri.parse("https://www.baidu.com"))
|
||||||
.setQuote(content)
|
.setQuote(content)
|
||||||
.build();
|
.build();
|
||||||
ShareDialog.show(this, linkContent);
|
ShareDialog.show(this, linkContent);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -861,6 +875,15 @@ public class MainActivity extends UnityPlayerActivity
|
|||||||
Log.e(TAG, "log event Exception: " + e.getMessage());
|
Log.e(TAG, "log event Exception: " + e.getMessage());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
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