From 3d740af26202f36cc711d5645a85d7b04257b424 Mon Sep 17 00:00:00 2001 From: syalon Date: Fri, 20 Sep 2019 11:25:10 +0800 Subject: [PATCH] android: release bitshares v2.7 --- android/app/build.gradle | 9 ++++-- .../main/assets/fowallet_config_btspp.json | 1 + .../main/java/bitshares/ChainObjectManager.kt | 29 ++++++++++++++----- .../fowallet/FragmentRegisterAccountMode.kt | 2 +- .../fowallet/FragmentRegisterWalletMode.kt | 2 +- 5 files changed, 31 insertions(+), 12 deletions(-) create mode 100644 android/app/src/main/assets/fowallet_config_btspp.json diff --git a/android/app/build.gradle b/android/app/build.gradle index 3d7ea62c..d40f231d 100644 --- a/android/app/build.gradle +++ b/android/app/build.gradle @@ -16,8 +16,8 @@ android { applicationId "org.bitshares.app" minSdkVersion 21 targetSdkVersion 28 - versionCode 201908151 - versionName "2.6" + versionCode 201909201 + versionName "2.7" testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner" externalNativeBuild { cmake { @@ -35,6 +35,7 @@ android { buildConfigField "boolean", "kAppCheckUpdate", "true" buildConfigField "String", "kAppCommunityFaucetAddress", "\"\"" + buildConfigField "String", "kAppConfigFile", "\"fowallet_config.json\"" // 不区分维度 flavorDimensions "default" @@ -44,8 +45,10 @@ android { // 0:iOS企业版 1:AppStore版 10:btspp 20:community(bbf) 100:baichenglian buildConfigField "int", "kAppChannelID", "10" buildConfigField "boolean", "kUseCommunityFaucet", "false" + buildConfigField "String", "kAppConfigFile", "\"fowallet_config_btspp.json\"" } - community_bbf { + // for community_bbf + bitshares { buildConfigField "int", "kAppChannelID", "20" buildConfigField "boolean", "kUseCommunityFaucet", "true" buildConfigField "String", "kAppCommunityFaucetAddress", "\"https://faucet.bitshares.eu/onboarding/api/v1/accounts\"" diff --git a/android/app/src/main/assets/fowallet_config_btspp.json b/android/app/src/main/assets/fowallet_config_btspp.json new file mode 100644 index 00000000..c0eee018 --- /dev/null +++ b/android/app/src/main/assets/fowallet_config_btspp.json @@ -0,0 +1 @@ +{"internal_themes":[{"themeCode":"blue","themeName":"静谧蓝","themeNameLangKey":"kThemeNameBlue","themeStatusBarWhite":true,"colors":{"appBackColor":"131f30","contentBackColor":"333333","bottomLineColor":"1a273a","buyColor":"03c087","sellColor":"e76d42","zeroColor":"8c9fad","callOrderColor":"ffff00","textColorPercent":"ffffff","textColorHighlight":"5786d2","textColorGray":"3d526b","textColorNormal":"6d87a8","textColorMain":"ffffff","ma5Color":"f6dc93","ma10Color":"61d1c0","ma30Color":"cb92fe","navigationBarBackColor":"131f30","navigationBarTextColor":"ffffff","tabBarColor":"172941","blockButtonBackColor":"607D8B","blockButtonTextColor":"ffffff","mainButtonBackColor":"e76d42","mainButtonTextColor":"ffffff","frameButtonBorderColor":"607D8B","frameButtonTextColor":"607D8B","tintColor":"e76d42","iconColor":"fe6c5a","textColor01":"212121","textColor02":"727272","noticeColor":"fe6c5a","ticketColor":"8d9caa"}},{"themeCode":"white","themeName":"珍珠白","themeNameLangKey":"kThemeNameWhite","themeStatusBarWhite":false,"colors":{"appBackColor":"ffffff","contentBackColor":"333333","bottomLineColor":"e7ebee","buyColor":"03c087","sellColor":"e76d42","zeroColor":"8c9fad","callOrderColor":"ffff00","textColorPercent":"ffffff","textColorHighlight":"5786d2","textColorGray":"c5cfd5","textColorNormal":"8c9fad","textColorMain":"1f3f59","ma5Color":"f6dc93","ma10Color":"61d1c0","ma30Color":"cb92fe","navigationBarBackColor":"ffffff","navigationBarTextColor":"1f3f59","tabBarColor":"f2f2f2","blockButtonBackColor":"607D8B","blockButtonTextColor":"ffffff","mainButtonBackColor":"fe6c5a","mainButtonTextColor":"ffffff","frameButtonBorderColor":"607D8B","frameButtonTextColor":"607D8B","tintColor":"fe6c5a","iconColor":"fe6c5a","textColor01":"212121","textColor02":"727272","noticeColor":"fe6c5a","ticketColor":"8d9caa"}}],"internal_assets":{"BTS":{"symbol":"BTS","id":"1.3.0","precision":5},"CNY":{"symbol":"CNY","id":"1.3.113","precision":4,"bitasset_data_id":"2.4.13"},"USD":{"symbol":"USD","id":"1.3.121","precision":4,"bitasset_data_id":"2.4.21"},"EUR":{"symbol":"EUR","id":"1.3.120","precision":4,"bitasset_data_id":"2.4.20"},"JPY":{"symbol":"JPY","id":"1.3.119","precision":2,"bitasset_data_id":"2.4.19"},"KRW":{"symbol":"KRW","id":"1.3.102","precision":4,"bitasset_data_id":"2.4.2"},"YOYOW":{"symbol":"YOYOW","id":"1.3.1093","precision":5},"GDEX.BTC":{"symbol":"GDEX.BTC","id":"1.3.2241","precision":8},"GDEX.ETH":{"symbol":"GDEX.ETH","id":"1.3.2598","precision":6},"GDEX.EOS":{"symbol":"GDEX.EOS","id":"1.3.2635","precision":6},"GDEX.SEER":{"symbol":"GDEX.SEER","id":"1.3.3736","precision":5},"FEEFREE":{"symbol":"FEEFREE","id":"1.3.5442","precision":5},"CNVOTE":{"symbol":"CNVOTE","id":"1.3.5476","precision":4},"BEOS":{"symbol":"BEOS","id":"1.3.4485","precision":5}},"estimate_unit":[{"namekey":"kSettingCurrencyNameCNY","symbol":"CNY"},{"namekey":"kSettingCurrencyNameUSD","symbol":"USD"},{"namekey":"kSettingCurrencyNameEUR","symbol":"EUR"},{"namekey":"kSettingCurrencyNameJPY","symbol":"JPY"},{"namekey":"kSettingCurrencyNameKRW","symbol":"KRW"},{"namekey":"kSettingCurrencyNameBTS","symbol":"BTS"}],"network_infos":{"max_parallel_num":5,"max_retry_num":3,"connect_timeout":5,"ws_node_list":[{"url":"wss://node.market.rudex.org","location":"Germany","enable":true,"username":"","password":""},{"url":"wss://api.weaccount.cn","location":"China(btspp)","enable":true,"username":"","password":""},{"url":"wss://api.bts.mobi/ws","location":"USA","enable":true,"username":"","password":""},{"url":"wss://btsapi.magicw.net/ws","location":"China(MagicWallet)","enable":true,"username":"","password":""}]},"parameters":{"default_kline_index":{"kMain":"ma","kSub":"","ma_value":[5,10,30],"ema_value":[9,15,30],"boll_value":{"n":20,"p":2},"macd_value":{"s":12,"l":26,"m":9}},"kline_period_ary":[1,30,50,60,70],"kline_query_callorder_number":50,"kline_query_limitorder_number":100,"kline_query_fillorder_number":20,"trade_query_callorder_number":50,"trade_query_limitorder_number":20,"trade_query_fillorder_number":20,"kline_period_default":2,"display_precision":5,"display_min_fraction":2,"num_price_total_max_precision":10,"max_custom_pair_num":20,"order_book_num_kline":20,"order_book_num_trade":5,"wallet_import_account_max_num":20,"collateral_ratio_default":3.0,"mcr_default":1.75,"max_ratio":6.0,"max_target_ratio":4.0,"base_budget_id":"2.13.25084","base_budget_time":"2018-08-24T03:00:00","voting_proxy_to_self":"1.2.5","voting_proxy_max_level":3},"faucet":{"url":"http://120.26.136.190:7773/v1/chain/"},"call_order_ranking_list":["CNY","USD"],"detail_feedprice_list":["CNY","USD"],"debt_asset_list":["CNY","USD","EUR","JPY","KRW"],"fee_assets_list":["FEEFREE","BTS","CNY","USD"],"internal_groups":{"MAIN":{"id":10,"key":"MAIN","name":"主区","name_key":"kLabelGroupNameMain","main":true,"intro":false},"COMMUNITY":{"id":90,"key":"MAIN","name":"社区","name_key":"kLabelGroupNameCommunity","intro":false},"GDEX":{"id":20,"key":"GDEX","issuer":["1.2.442525"],"name":"GDEX(网关)","name_key":"kLabelGroupNameGDEX","gateway":true,"prefix":"GDEX","intro":true},"WWW":{"id":30,"key":"WWW","issuer":["1.2.471972"],"name":"WWW(网关)","name_key":"kLabelGroupNameWWW","gateway":true,"prefix":"WWW"},"OPEN":{"id":40,"key":"OPEN","issuer":["1.2.96397","1.2.100614"],"name":"OPEN(网关)","name_key":"kLabelGroupNameOPEN","gateway":true,"prefix":"OPEN"},"WIN":{"id":50,"key":"WIN","issuer":["1.2.452990"],"name":"WIN(网关)","name_key":"kLabelGroupNameWIN","gateway":true,"prefix":"WIN"},"__OTHER":{"id":100,"key":"__OTHER","name":"其他","name_key":"kLabelGroupNameOther","other":true,"intro":false}},"markets":[{"base":{"symbol":"CNY","name":"BitCNY"},"group_list":[{"group_key":"MAIN","quote_list":["BTS","USD"]},{"group_key":"GDEX","quote_list":["GDEX.BTC","GDEX.ETH","GDEX.EOS","GDEX.SEER"]},{"group_key":"COMMUNITY","quote_list":["CNVOTE"]}]},{"base":{"symbol":"USD","name":"BitUSD"},"group_list":[{"group_key":"MAIN","quote_list":["BTS","CNY"]},{"group_key":"GDEX","quote_list":["GDEX.BTC","GDEX.EOS"]}]},{"base":{"symbol":"BTS","name":"BTS"},"group_list":[{"group_key":"MAIN","quote_list":["CNY","USD"]},{"group_key":"GDEX","quote_list":["GDEX.EOS"]},{"group_key":"COMMUNITY","quote_list":["CNVOTE","BEOS"]}]}]} \ No newline at end of file diff --git a/android/app/src/main/java/bitshares/ChainObjectManager.kt b/android/app/src/main/java/bitshares/ChainObjectManager.kt index 8a6e8475..d9f89cda 100644 --- a/android/app/src/main/java/bitshares/ChainObjectManager.kt +++ b/android/app/src/main/java/bitshares/ChainObjectManager.kt @@ -92,7 +92,8 @@ class ChainObjectManager { if (_defaultMarketInfos != null) { return } - _defaultMarketInfos = Utils.readJsonToMap(ctx, "fowallet_config.json") + + _defaultMarketInfos = Utils.readJsonToMap(ctx, com.btsplusplus.fowallet.BuildConfig.kAppConfigFile) assert(_defaultMarketInfos != null) // 获取 markets @@ -1390,17 +1391,31 @@ class ChainObjectManager { } /** - * (public) 查询指定帐号的完整信息 + * (public) 查询指定帐号的完整信息 */ fun queryFullAccountInfo(account_name_or_id: String): Promise { - val conn = GrapheneConnectionManager.sharedGrapheneConnectionManager().any_connection() + return queryFullAccountInfoWithRetry(account_name_or_id, retry_num = 1) + } - return conn.async_exec_db("get_full_accounts", jsonArrayfrom(jsonArrayfrom(account_name_or_id), false)).then { data: Any? -> - val data = data as JSONArray? + /** + * (public) 查询完整账号信息,带重试。REMARK:刚注册成功的账号可能查询失败,网络尚未同步完毕。 + */ + fun queryFullAccountInfoWithRetry(account_name_or_id: String, retry_num: Int): Promise { + val conn = GrapheneConnectionManager.sharedGrapheneConnectionManager().any_connection() + return conn.async_exec_db("get_full_accounts", jsonArrayfrom(jsonArrayfrom(account_name_or_id), false)).then { + val data = it as? JSONArray + // 查询失败的情况下 if (data == null || data.length() <= 0) { - return@then null + if (retry_num > 1) { + // 等待一会 & 重试 + return@then OrgUtils.asyncWait(2000).then { + return@then queryFullAccountInfoWithRetry(account_name_or_id, retry_num - 1) + } + } else { + // 失败 + return@then null + } } - val _data = data // 获取帐号信息 val full_account_data = data.getJSONArray(0).getJSONObject(1) // [缓存] 添加到缓存 diff --git a/android/app/src/main/java/com/btsplusplus/fowallet/FragmentRegisterAccountMode.kt b/android/app/src/main/java/com/btsplusplus/fowallet/FragmentRegisterAccountMode.kt index 321a11d5..b004bc4b 100644 --- a/android/app/src/main/java/com/btsplusplus/fowallet/FragmentRegisterAccountMode.kt +++ b/android/app/src/main/java/com/btsplusplus/fowallet/FragmentRegisterAccountMode.kt @@ -90,7 +90,7 @@ class FragmentRegisterAccountMode : Fragment() { } // 3、注册成功(查询full_account_data) - chainMgr.queryFullAccountInfo(username).then { + chainMgr.queryFullAccountInfoWithRetry(username, retry_num = 3).then { mask.dismiss() val new_full_account_data = it as? JSONObject if (new_full_account_data == null) { diff --git a/android/app/src/main/java/com/btsplusplus/fowallet/FragmentRegisterWalletMode.kt b/android/app/src/main/java/com/btsplusplus/fowallet/FragmentRegisterWalletMode.kt index 2a7d7322..171c16e5 100644 --- a/android/app/src/main/java/com/btsplusplus/fowallet/FragmentRegisterWalletMode.kt +++ b/android/app/src/main/java/com/btsplusplus/fowallet/FragmentRegisterWalletMode.kt @@ -91,7 +91,7 @@ class FragmentRegisterWalletMode : Fragment() { // 3、注册成功 val full_wallet_bin = WalletManager.sharedWalletManager().genFullWalletData(activity!!, username, jsonArrayfrom(private_active, private_owner), password) // 查询完整帐号信息 - chainMgr.queryFullAccountInfo(username).then { + chainMgr.queryFullAccountInfoWithRetry(username, retry_num = 3).then { mask.dismiss() val new_full_account_data = it as? JSONObject if (new_full_account_data == null) {