修改 .idea/gradle.xml
This commit is contained in:
commit
ead48d9261
5
.idea/jarRepositories.xml
generated
5
.idea/jarRepositories.xml
generated
@ -21,5 +21,10 @@
|
||||
<option name="name" value="Google" />
|
||||
<option name="url" value="https://dl.google.com/dl/android/maven2/" />
|
||||
</remote-repository>
|
||||
<remote-repository>
|
||||
<option name="id" value="maven" />
|
||||
<option name="name" value="maven" />
|
||||
<option name="url" value="https://artifact.bytedance.com/repository/AwemeOpenSDK" />
|
||||
</remote-repository>
|
||||
</component>
|
||||
</project>
|
@ -72,6 +72,10 @@
|
||||
</intent-filter>
|
||||
|
||||
</activity>
|
||||
<activity
|
||||
android:name=".tiktokapi.TikTokEntryActivity"
|
||||
android:exported="true">
|
||||
</activity>
|
||||
<service android:name ="com.youme.voiceengine.VoiceEngineService"
|
||||
android:exported="true">
|
||||
<intent-filter>
|
||||
@ -122,4 +126,8 @@
|
||||
<uses-permission
|
||||
android:name="android.permission.WRITE_EXTERNAL_STORAGE"
|
||||
android:maxSdkVersion="29" />
|
||||
<queries>
|
||||
<package android:name="com.zhiliaoapp.musically" />
|
||||
<package android:name="com.ss.android.ugc.trill" />
|
||||
</queries>
|
||||
</manifest>
|
@ -139,4 +139,5 @@ dependencies {
|
||||
implementation 'com.android.volley:volley:1.2.1'
|
||||
implementation 'org.greenrobot:eventbus:3.0.0'
|
||||
implementation 'androidx.constraintlayout:constraintlayout:2.0.4'
|
||||
implementation 'com.bytedance.ies.ugc.aweme:opensdk-oversea-external:0.2.1.0'
|
||||
}
|
@ -18,6 +18,9 @@ import android.view.MotionEvent;
|
||||
import android.view.Window;
|
||||
import android.widget.Toast;
|
||||
|
||||
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.dialog.QRCodeActivity;
|
||||
import com.google.android.gms.auth.api.signin.GoogleSignIn;
|
||||
@ -118,6 +121,10 @@ public class MainActivity extends Activity
|
||||
private CountDownLatch mAuthIntentLatch = new CountDownLatch(1);
|
||||
private static final String EXTRA_FAILED = "failed";
|
||||
|
||||
public String getFunId() {
|
||||
return funId;
|
||||
}
|
||||
|
||||
@NonNull
|
||||
private final BrowserMatcher mBrowserMatcher = AnyBrowserMatcher.INSTANCE;
|
||||
|
||||
@ -804,7 +811,21 @@ public class MainActivity extends Activity
|
||||
}
|
||||
@MainThread
|
||||
private void verifyGoogleIDToken(String idToken) {
|
||||
JcSDK.googleOauthCb(this.funId, null, idToken);
|
||||
JcSDK.oauthCb(this.funId, null, idToken);
|
||||
}
|
||||
|
||||
// sign with tiktok
|
||||
public void signWithTiktok(String funId) {
|
||||
this.funId = funId;
|
||||
Log.i(TAG, "login with tiktok: " + funId);
|
||||
// STEP 1: Create an instance of TiktokOpenApi
|
||||
TikTokOpenApi tiktokOpenApi= TikTokOpenApiFactory.create(this);
|
||||
|
||||
// STEP 2: Create an instance of Authorization.Request and set parameters
|
||||
Authorization.Request request = new Authorization.Request();
|
||||
request.scope = "user.info.basic,video.list";
|
||||
request.state = funId;
|
||||
tiktokOpenApi.authorize(request);
|
||||
}
|
||||
|
||||
|
||||
|
@ -3,6 +3,9 @@ package com.cege.games.release;
|
||||
import android.app.Application;
|
||||
import android.content.SharedPreferences;
|
||||
|
||||
import com.bytedance.sdk.open.tiktok.TikTokOpenApiFactory;
|
||||
import com.bytedance.sdk.open.tiktok.TikTokOpenConfig;
|
||||
|
||||
public class MainApplication extends Application {
|
||||
public static MainApplication application;
|
||||
public static SharedPreferences _pref;
|
||||
@ -11,5 +14,7 @@ public class MainApplication extends Application {
|
||||
super.onCreate();
|
||||
application = this;
|
||||
_pref = getSharedPreferences(Constants.PREF_NAME, 0);
|
||||
String tiktokClientKey = "awqbuzh2qymmq8hs";
|
||||
TikTokOpenApiFactory.init(new TikTokOpenConfig(tiktokClientKey));
|
||||
}
|
||||
}
|
||||
|
@ -0,0 +1,50 @@
|
||||
package com.cege.games.release.tiktokapi;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.content.Intent;
|
||||
import android.os.Bundle;
|
||||
|
||||
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.bytedance.sdk.open.tiktok.common.handler.IApiEventHandler;
|
||||
import com.bytedance.sdk.open.tiktok.common.model.BaseReq;
|
||||
import com.bytedance.sdk.open.tiktok.common.model.BaseResp;
|
||||
import com.jc.jcfw.JcSDK;
|
||||
|
||||
import androidx.annotation.Nullable;
|
||||
|
||||
public class TikTokEntryActivity extends Activity implements IApiEventHandler {
|
||||
private static final String TAG = TikTokEntryActivity.class.getSimpleName();
|
||||
TikTokOpenApi ttOpenApi;
|
||||
@Override
|
||||
public void onCreate(@Nullable Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
ttOpenApi= TikTokOpenApiFactory.create(this);
|
||||
ttOpenApi.handleIntent(getIntent(),this); // receive and parse callback
|
||||
}
|
||||
@Override
|
||||
public void onReq(BaseReq req) {
|
||||
}
|
||||
@Override
|
||||
public void onResp(BaseResp resp) {
|
||||
if (resp instanceof Authorization.Response) {
|
||||
Authorization.Response response = (Authorization.Response) resp;
|
||||
// Log.i(TAG, "errorCode: " + response.errorCode);
|
||||
// Log.i(TAG, "errorMsg: " + response.errorMsg);
|
||||
// Log.i(TAG, "authCode: " + response.authCode);
|
||||
// Log.i(TAG, "state: " + response.state);
|
||||
// Log.i(TAG, "grantedPermissions: " + response.grantedPermissions);
|
||||
if (response.errorCode == 0) {
|
||||
JcSDK.oauthCb(response.state, null, response.authCode);
|
||||
} else {
|
||||
JcSDK.oauthCb(response.state, response.errorMsg, null);
|
||||
}
|
||||
finish();
|
||||
}
|
||||
}
|
||||
@Override
|
||||
public void onErrorIntent(@Nullable Intent intent) {
|
||||
JcSDK.oauthCb(null, "error intent", null);
|
||||
}
|
||||
}
|
@ -76,6 +76,10 @@ public class JcSDK {
|
||||
MainActivity.app.loadRestoreKey(funid, oid);
|
||||
}
|
||||
|
||||
public static void signWithTiktok(String funid) {
|
||||
MainActivity.app.signWithTiktok(funid);
|
||||
}
|
||||
|
||||
public static void signWithGoogle(String funid) {
|
||||
MainActivity.app.signWithGoogle(funid);
|
||||
}
|
||||
@ -84,7 +88,7 @@ public class JcSDK {
|
||||
MainActivity.app.signOutGoogle(funid);
|
||||
}
|
||||
|
||||
public static void googleOauthCb(String funId, String error, String idToken) {
|
||||
public static void oauthCb(String funId, String error, String idToken) {
|
||||
JSONObject result = new JSONObject();
|
||||
try {
|
||||
if (error != "" && null != error) {
|
||||
@ -97,7 +101,10 @@ public class JcSDK {
|
||||
} catch (JSONException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
if (null == funId || "".equals(funId)) {
|
||||
funId = MainActivity.app.getFunId();
|
||||
}
|
||||
Log.i("TAG" ,result.toString());
|
||||
String methodName = "jniCallback";
|
||||
JcSDK.runJS(funId, methodName, result.toString());
|
||||
}
|
||||
|
@ -4,6 +4,7 @@ buildscript {
|
||||
repositories {
|
||||
google()
|
||||
jcenter()
|
||||
maven { url "https://artifact.bytedance.com/repository/AwemeOpenSDK" }
|
||||
}
|
||||
dependencies {
|
||||
classpath "com.android.tools.build:gradle:4.1.1"
|
||||
@ -17,6 +18,7 @@ allprojects {
|
||||
repositories {
|
||||
google()
|
||||
jcenter()
|
||||
maven { url "https://artifact.bytedance.com/repository/AwemeOpenSDK" }
|
||||
flatDir {
|
||||
dirs 'libs'
|
||||
}
|
||||
|
File diff suppressed because one or more lines are too long
44
js/main.js
44
js/main.js
@ -138,10 +138,12 @@ function getEthBalance(funId, account) {
|
||||
* send ETH from current account
|
||||
* @param {string} to: target account
|
||||
* @param {string} amount:
|
||||
* @param {number} estimate: 1: only estimate gas price
|
||||
*/
|
||||
function sendEth(funId, to, amount) {
|
||||
function sendEth(funId, to, amount, estimate) {
|
||||
estimate = (estimate || '0') | 0
|
||||
jc.wallet
|
||||
.sendEth(to, amount)
|
||||
.sendEth(to, amount, estimate)
|
||||
.then((result) => {
|
||||
jsb.jcCallback(funId, JSON.stringify({ errcode: 0, data: result }));
|
||||
})
|
||||
@ -197,9 +199,10 @@ function erc20Balance(funId, address, account) {
|
||||
/**
|
||||
* send ERC20 token to to
|
||||
*/
|
||||
function sendErc20(funId, address, to, amount) {
|
||||
function sendErc20(funId, address, to, amount, estimate) {
|
||||
estimate = (estimate || '0') | 0
|
||||
jc.wallet
|
||||
.sendErc20(address, to, amount)
|
||||
.sendErc20(address, to, amount, estimate)
|
||||
.then((result) => {
|
||||
jsb.jcCallback(funId, JSON.stringify({ errcode: 0, data: result }));
|
||||
})
|
||||
@ -208,6 +211,39 @@ function sendErc20(funId, address, to, amount) {
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* send ERC721 NFT to to
|
||||
*/
|
||||
function sendErc721(funId, address, to, tokenId, estimate) {
|
||||
estimate = (estimate || '0') | 0
|
||||
jc.wallet
|
||||
.sendNFT(address, to, tokenId, estimate)
|
||||
.then((result) => {
|
||||
jsb.jcCallback(funId, JSON.stringify({ errcode: 0, data: result }));
|
||||
})
|
||||
.catch((err) => {
|
||||
jsb.jcCallback(funId, JSON.stringify({ errcode: 1, errmsg: err }));
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* send ERC1155 to to
|
||||
*/
|
||||
function sendErc1155(funId, address, to, tokenIds, amounts, estimate) {
|
||||
tokenIds = JSON.parse(tokenIds);
|
||||
amounts = JSON.parse(amounts);
|
||||
estimate = (estimate || '0') | 0
|
||||
jc.wallet
|
||||
.sendErc1155(address, to, tokenIds, amounts, estimate)
|
||||
.then((result) => {
|
||||
jsb.jcCallback(funId, JSON.stringify({ errcode: 0, data: result }));
|
||||
})
|
||||
.catch((err) => {
|
||||
jsb.jcCallback(funId, JSON.stringify({ errcode: 1, errmsg: err }));
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
function showQRCode(funId, content) {
|
||||
try {
|
||||
jsb.showQRCode(funId, content);
|
||||
|
@ -1,4 +1,4 @@
|
||||
function jniCallback(...args) {
|
||||
console.log(`jniCallback: ${args[0]}`)
|
||||
jc.wallet.nativeSvr.handleNativeCallback(...args);
|
||||
console.log(`jniCallback: ${args[0]} | ${args[1]}`);
|
||||
jc.wallet.nativeSvr.handleNativeCallback(...args);
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user