Skip to content

Commit 1d29df7

Browse files
committed
Optimize the function of Google drive and update aar file.
1 parent ff0a99f commit 1d29df7

5 files changed

Lines changed: 147 additions & 140 deletions

File tree

app/libs/Obdmobile.aar

30.5 KB
Binary file not shown.

app/src/main/java/com/omni/wallet_mainnet/ui/activity/AccountLightningActivity.java

Lines changed: 69 additions & 71 deletions
Original file line numberDiff line numberDiff line change
@@ -360,40 +360,6 @@ private void setAssetTrendChartViewShow() {
360360

361361
}
362362

363-
364-
/**
365-
* Get wallet related information
366-
* 获取钱包相关信息
367-
*/
368-
private void getInfo() {
369-
Obdmobile.oB_GetInfo(LightningOuterClass.GetInfoRequest.newBuilder().build().toByteArray(), new Callback() {
370-
@Override
371-
public void onError(Exception e) {
372-
LogUtils.e(TAG, "------------------getInfoOnError------------------" + e.getMessage());
373-
}
374-
375-
@Override
376-
public void onResponse(byte[] bytes) {
377-
if (bytes == null) {
378-
return;
379-
}
380-
try {
381-
LightningOuterClass.GetInfoResponse resp = LightningOuterClass.GetInfoResponse.parseFrom(bytes);
382-
LogUtils.e(TAG, "------------------getInfoOnResponse-----------------" + resp);
383-
runOnUiThread(() -> {
384-
pubkey = resp.getIdentityPubkey();
385-
// mNetworkTypeTv.setText(resp.getChains(0).getNetwork());
386-
User.getInstance().setNetwork(mContext, resp.getChains(0).getNetwork());
387-
User.getInstance().setNodeVersion(mContext, resp.getVersion());
388-
User.getInstance().setFromPubKey(mContext, resp.getIdentityPubkey());
389-
});
390-
} catch (InvalidProtocolBufferException e) {
391-
e.printStackTrace();
392-
}
393-
}
394-
});
395-
}
396-
397363
/**
398364
* Create a new wallet address first, and then request the interface of each asset balance list
399365
* 先创建新的钱包地址后再去请求各资产余额列表的接口
@@ -704,9 +670,11 @@ public void convert(ViewHolder holder, final int position, final ListAssetItemEn
704670
if ((position + 1) % 2 == 0) {
705671
holder.getView(R.id.iv_asset_logo).setVisibility(View.INVISIBLE);
706672
holder.getView(R.id.tv_asset_name).setVisibility(View.INVISIBLE);
673+
holder.getView(R.id.view_space).setVisibility(View.VISIBLE);
707674
} else {
708675
holder.getView(R.id.iv_asset_logo).setVisibility(View.VISIBLE);
709676
holder.getView(R.id.tv_asset_name).setVisibility(View.VISIBLE);
677+
holder.getView(R.id.view_space).setVisibility(View.GONE);
710678
}
711679
ImageView imageView = holder.getView(R.id.iv_asset_logo);
712680
mAssetData.clear();
@@ -1171,50 +1139,80 @@ public void run() {
11711139
User.getInstance().setUserId(mContext, "1");
11721140
User.getInstance().setBackUp(mContext, true);
11731141
subscribeChannelChange();
1142+
getInfo();
11741143
}
11751144
});
1176-
if (StringUtils.isEmpty(User.getInstance().getWalletAddress(mContext))) {
1177-
LightningOuterClass.NewAddressRequest newAddressRequest = LightningOuterClass.NewAddressRequest.newBuilder().setTypeValue(2).build();
1178-
Obdmobile.oB_NewAddress(newAddressRequest.toByteArray(), new Callback() {
1179-
@Override
1180-
public void onError(Exception e) {
1181-
e.printStackTrace();
1182-
}
1145+
}
1146+
};
1147+
WalletState.getInstance().setWalletStateCallback(walletStateCallback);
1148+
}
11831149

1184-
@Override
1185-
public void onResponse(byte[] bytes) {
1186-
if (bytes == null) {
1187-
return;
1188-
}
1189-
try {
1190-
LightningOuterClass.NewAddressResponse newAddressResponse = LightningOuterClass.NewAddressResponse.parseFrom(bytes);
1191-
String address = newAddressResponse.getAddress();
1192-
runOnUiThread(() -> {
1193-
// 保存地址到本地(save wallet address to local)
1194-
User.getInstance().setWalletAddress(mContext, address);
1195-
mWalletAddressTv.setText(User.getInstance().getWalletAddress(mContext));
1196-
getAssetAndBtcData();
1197-
getInfo();
1198-
setDefaultAddress();
1199-
setAssetTrendChartViewShow();
1200-
});
1201-
} catch (InvalidProtocolBufferException e) {
1202-
e.printStackTrace();
1203-
}
1204-
}
1205-
});
1206-
} else {
1150+
/**
1151+
* Get wallet related information
1152+
* 获取钱包相关信息
1153+
*/
1154+
private void getInfo() {
1155+
Obdmobile.oB_GetInfo(LightningOuterClass.GetInfoRequest.newBuilder().build().toByteArray(), new Callback() {
1156+
@Override
1157+
public void onError(Exception e) {
1158+
LogUtils.e(TAG, "------------------getInfoOnError------------------" + e.getMessage());
1159+
}
1160+
1161+
@Override
1162+
public void onResponse(byte[] bytes) {
1163+
if (bytes == null) {
1164+
return;
1165+
}
1166+
try {
1167+
LightningOuterClass.GetInfoResponse resp = LightningOuterClass.GetInfoResponse.parseFrom(bytes);
1168+
LogUtils.e(TAG, "------------------getInfoOnResponse-----------------" + resp);
12071169
runOnUiThread(() -> {
1208-
mWalletAddressTv.setText(User.getInstance().getWalletAddress(mContext));
1209-
getAssetAndBtcData();
1210-
getInfo();
1211-
setDefaultAddress();
1212-
setAssetTrendChartViewShow();
1170+
pubkey = resp.getIdentityPubkey();
1171+
User.getInstance().setNetwork(mContext, resp.getChains(0).getNetwork());
1172+
User.getInstance().setNodeVersion(mContext, resp.getVersion());
1173+
User.getInstance().setFromPubKey(mContext, resp.getIdentityPubkey());
1174+
if (StringUtils.isEmpty(resp.getCoinAddress())) {
1175+
LightningOuterClass.NewAddressRequest newAddressRequest = LightningOuterClass.NewAddressRequest.newBuilder().setTypeValue(2).build();
1176+
Obdmobile.oB_NewAddress(newAddressRequest.toByteArray(), new Callback() {
1177+
@Override
1178+
public void onError(Exception e) {
1179+
e.printStackTrace();
1180+
}
1181+
1182+
@Override
1183+
public void onResponse(byte[] bytes) {
1184+
if (bytes == null) {
1185+
return;
1186+
}
1187+
try {
1188+
LightningOuterClass.NewAddressResponse newAddressResponse = LightningOuterClass.NewAddressResponse.parseFrom(bytes);
1189+
String address = newAddressResponse.getAddress();
1190+
runOnUiThread(() -> {
1191+
// 保存地址到本地(save wallet address to local)
1192+
User.getInstance().setWalletAddress(mContext, address);
1193+
mWalletAddressTv.setText(User.getInstance().getWalletAddress(mContext));
1194+
getAssetAndBtcData();
1195+
setDefaultAddress();
1196+
setAssetTrendChartViewShow();
1197+
});
1198+
} catch (InvalidProtocolBufferException e) {
1199+
e.printStackTrace();
1200+
}
1201+
}
1202+
});
1203+
} else {
1204+
User.getInstance().setWalletAddress(mContext, resp.getCoinAddress());
1205+
mWalletAddressTv.setText(User.getInstance().getWalletAddress(mContext));
1206+
getAssetAndBtcData();
1207+
setDefaultAddress();
1208+
setAssetTrendChartViewShow();
1209+
}
12131210
});
1211+
} catch (InvalidProtocolBufferException e) {
1212+
e.printStackTrace();
12141213
}
12151214
}
1216-
};
1217-
WalletState.getInstance().setWalletStateCallback(walletStateCallback);
1215+
});
12181216
}
12191217

12201218
private void subscribeChannelChange() {

app/src/main/java/com/omni/wallet_mainnet/ui/activity/ChooseRestoreTypeActivity.java

Lines changed: 10 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -27,17 +27,14 @@
2727
import com.omni.wallet_mainnet.baselibrary.utils.ToastUtils;
2828
import com.omni.wallet_mainnet.common.ConstantInOB;
2929
import com.omni.wallet_mainnet.common.ConstantWithNetwork;
30-
import com.omni.wallet_mainnet.framelibrary.entity.User;
3130
import com.omni.wallet_mainnet.ui.activity.createwallet.CreateWalletStepThreeActivity;
3231
import com.omni.wallet_mainnet.utils.DriveServiceHelper;
3332
import com.omni.wallet_mainnet.utils.MoveCacheFileToFileObd;
3433
import com.omni.wallet_mainnet.view.dialog.LoadingDialog;
3534

3635
import java.io.BufferedOutputStream;
37-
import java.io.BufferedReader;
3836
import java.io.File;
3937
import java.io.FileOutputStream;
40-
import java.io.FileReader;
4138
import java.io.IOException;
4239
import java.util.ArrayList;
4340
import java.util.Collections;
@@ -154,14 +151,14 @@ public void clickStart() {
154151
MoveCacheFileToFileObd.createDirs(storageChannelPath);
155152
MoveCacheFileToFileObd.copyFile(fromWalletPath, toWalletPath);
156153
MoveCacheFileToFileObd.copyFile(fromChannelPath, toChannelPath);
157-
try {
158-
BufferedReader bf = new BufferedReader(new FileReader(Environment.getExternalStorageDirectory() + "/OBMainnetBackupFiles/address.txt"));
159-
for (String line = bf.readLine(); line != null; line = bf.readLine()) {
160-
User.getInstance().setWalletAddress(mContext, line);
161-
}
162-
} catch (IOException e) {
163-
e.printStackTrace();
164-
}
154+
// try {
155+
// BufferedReader bf = new BufferedReader(new FileReader(Environment.getExternalStorageDirectory() + "/OBMainnetBackupFiles/address.txt"));
156+
// for (String line = bf.readLine(); line != null; line = bf.readLine()) {
157+
// User.getInstance().setWalletAddress(mContext, line);
158+
// }
159+
// } catch (IOException e) {
160+
// e.printStackTrace();
161+
// }
165162
switchActivity(CreateWalletStepThreeActivity.class);
166163
} else {
167164
ToastUtils.showToast(mContext, "The backup file does not exist");
@@ -278,8 +275,8 @@ private void readAddressFile(String walletFileId, String channelFileId, String a
278275

279276
mDriveServiceHelper.readFile(addressFileId)
280277
.addOnSuccessListener(nameAndContent -> {
281-
String address = nameAndContent.first.substring(0, nameAndContent.first.lastIndexOf("_"));
282-
User.getInstance().setWalletAddress(mContext, address);
278+
// String address = nameAndContent.first.substring(0, nameAndContent.first.lastIndexOf("_"));
279+
// User.getInstance().setWalletAddress(mContext, address);
283280
readWalletFile(walletFileId, channelFileId);
284281
})
285282
.addOnFailureListener(exception ->

app/src/main/res/layout/activity_account_lightning.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -278,7 +278,7 @@
278278
android:layout_marginBottom="@dimen/main_40"
279279
android:layout_marginLeft="@dimen/main_32"
280280
android:layout_marginRight="@dimen/main_40"
281-
android:layout_marginTop="@dimen/main_25"/>
281+
android:layout_marginTop="@dimen/main_30"/>
282282
</LinearLayout>
283283

284284
<LinearLayout
Lines changed: 67 additions & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -1,73 +1,85 @@
11
<?xml version="1.0" encoding="utf-8"?>
2-
<RelativeLayout
2+
<LinearLayout
33
xmlns:android="http://schemas.android.com/apk/res/android"
44
android:layout_width="match_parent"
55
android:layout_height="wrap_content"
6-
android:layout_marginTop="@dimen/main_8"
7-
android:layout_marginBottom="@dimen/main_8">
6+
android:orientation="vertical">
87

9-
<LinearLayout
10-
android:layout_width="wrap_content"
8+
<RelativeLayout
9+
android:layout_width="match_parent"
1110
android:layout_height="wrap_content"
12-
android:orientation="horizontal">
13-
14-
<ImageView
15-
android:id="@+id/iv_asset_logo"
16-
android:layout_width="@dimen/main_24"
17-
android:layout_height="@dimen/main_24"
18-
android:src="@mipmap/icon_usdt_logo_small"/>
11+
android:layout_marginBottom="@dimen/main_4"
12+
android:layout_marginTop="@dimen/main_4">
1913

20-
<TextView
21-
android:id="@+id/tv_asset_name"
14+
<LinearLayout
2215
android:layout_width="wrap_content"
2316
android:layout_height="wrap_content"
24-
android:layout_marginLeft="@dimen/main_5"
25-
android:textStyle="bold"
26-
android:text="BTC"
27-
android:textColor="@color/color_A6_transparent"
28-
android:textSize="@dimen/text_16"/>
29-
</LinearLayout>
17+
android:orientation="horizontal">
3018

31-
<LinearLayout
32-
android:layout_width="wrap_content"
33-
android:layout_height="wrap_content"
34-
android:gravity="right"
35-
android:layout_centerVertical="true"
36-
android:layout_toLeftOf="@+id/layout_asset_net"
37-
android:layout_marginRight="@dimen/main_15"
38-
android:orientation="vertical">
19+
<ImageView
20+
android:id="@+id/iv_asset_logo"
21+
android:layout_width="@dimen/main_24"
22+
android:layout_height="@dimen/main_24"
23+
android:src="@mipmap/icon_usdt_logo_small" />
3924

40-
<TextView
41-
android:id="@+id/tv_asset_amount"
42-
android:layout_width="wrap_content"
43-
android:layout_height="wrap_content"
44-
android:text="0"
45-
android:textStyle="bold"
46-
android:textColor="@color/color_black"
47-
android:textSize="@dimen/text_16"/>
25+
<TextView
26+
android:id="@+id/tv_asset_name"
27+
android:layout_width="wrap_content"
28+
android:layout_height="wrap_content"
29+
android:layout_marginLeft="@dimen/main_5"
30+
android:text="BTC"
31+
android:textColor="@color/color_A6_transparent"
32+
android:textSize="@dimen/text_16"
33+
android:textStyle="bold" />
34+
</LinearLayout>
4835

49-
<TextView
50-
android:id="@+id/tv_asset_value"
36+
<LinearLayout
5137
android:layout_width="wrap_content"
5238
android:layout_height="wrap_content"
53-
android:layout_marginTop="@dimen/main_5"
54-
android:text="0"
55-
android:textStyle="bold"
56-
android:textColor="@color/color_80p_transparent"
57-
android:textSize="@dimen/text_12"/>
58-
</LinearLayout>
39+
android:layout_centerVertical="true"
40+
android:layout_marginRight="@dimen/main_15"
41+
android:layout_toLeftOf="@+id/layout_asset_net"
42+
android:gravity="right"
43+
android:orientation="vertical">
5944

60-
<RelativeLayout
61-
android:id="@+id/layout_asset_net"
62-
android:layout_width="@dimen/main_28"
63-
android:layout_height="wrap_content"
64-
android:layout_alignParentRight="true">
45+
<TextView
46+
android:id="@+id/tv_asset_amount"
47+
android:layout_width="wrap_content"
48+
android:layout_height="wrap_content"
49+
android:text="0"
50+
android:textColor="@color/color_black"
51+
android:textSize="@dimen/text_16"
52+
android:textStyle="bold" />
6553

66-
<ImageView
67-
android:id="@+id/iv_asset_net"
68-
android:layout_width="wrap_content"
54+
<TextView
55+
android:id="@+id/tv_asset_value"
56+
android:layout_width="wrap_content"
57+
android:layout_height="wrap_content"
58+
android:layout_marginTop="@dimen/main_5"
59+
android:text="0"
60+
android:textColor="@color/color_80p_transparent"
61+
android:textSize="@dimen/text_12"
62+
android:textStyle="bold" />
63+
</LinearLayout>
64+
65+
<RelativeLayout
66+
android:id="@+id/layout_asset_net"
67+
android:layout_width="@dimen/main_28"
6968
android:layout_height="wrap_content"
70-
android:layout_alignParentRight="true"
71-
android:src="@mipmap/icon_network_link_black_small"/>
69+
android:layout_alignParentRight="true">
70+
71+
<ImageView
72+
android:id="@+id/iv_asset_net"
73+
android:layout_width="wrap_content"
74+
android:layout_height="wrap_content"
75+
android:layout_alignParentRight="true"
76+
android:src="@mipmap/icon_network_link_black_small" />
77+
</RelativeLayout>
7278
</RelativeLayout>
73-
</RelativeLayout>
79+
80+
<View
81+
android:id="@+id/view_space"
82+
android:layout_width="match_parent"
83+
android:layout_height="@dimen/main_20"
84+
android:visibility="gone" />
85+
</LinearLayout>

0 commit comments

Comments
 (0)