use of com.lingtuan.firefly.wallet.vo.StorableWallet in project SmartMesh_Android by SmartMeshFoundation.
the class GesturePasswordLoginActivity method onConstellationPicker.
public void onConstellationPicker() {
ArrayList<StorableWallet> storableWallets;
if (type == 4) {
storableWallets = WalletStorage.getInstance(NextApplication.mContext).getAll();
} else {
storableWallets = WalletStorage.getInstance(NextApplication.mContext).get();
}
if (storableWallets == null || storableWallets.size() <= 0) {
return;
}
int index = -1;
String[] nameArray = new String[storableWallets.size()];
for (int i = 0; i < storableWallets.size(); i++) {
String address = storableWallets.get(i).getPublicKey();
if (storableWallets.get(i).isSelect()) {
index = i;
}
if (!address.startsWith("0x")) {
address = "0x" + address;
}
nameArray[i] = address.replace(address.substring(12, 30), "...");
}
OptionPicker picker = new OptionPicker(this, nameArray);
// Do not disable loops
picker.setCycleDisable(true);
picker.setTopBackgroundColor(0xFFEEEEEE);
picker.setTopHeight(40);
picker.setTextSize(14);
picker.setOffset(3);
picker.setTopLineColor(getResources().getColor(R.color.textColorCard));
picker.setTopLineHeight(1);
picker.setCancelTextColor(getResources().getColor(R.color.textColorCard));
picker.setCancelTextSize(13);
picker.setSubmitTextColor(getResources().getColor(R.color.gesture_lock_select));
picker.setSubmitTextSize(13);
picker.setTextColor(getResources().getColor(R.color.black), getResources().getColor(R.color.textColorCard));
WheelView.DividerConfig config = new WheelView.DividerConfig();
// Line color
config.setColor(getResources().getColor(R.color.tab_sep_line));
// Line transparency
config.setAlpha(140);
// Line ratio
config.setRatio(1);
picker.setDividerConfig(config);
picker.setBackgroundColor(0xFFE1E1E1);
picker.setSelectedIndex(index);
picker.setCanceledOnTouchOutside(true);
picker.setOnOptionPickListener(new OptionPicker.OnOptionPickListener() {
@Override
public void onOptionPicked(int index, String item) {
ArrayList<StorableWallet> storableWallets;
if (type == 4) {
storableWallets = WalletStorage.getInstance(NextApplication.mContext).getAll();
} else {
storableWallets = WalletStorage.getInstance(NextApplication.mContext).get();
}
for (int i = 0; i < storableWallets.size(); i++) {
if (i != index) {
if (type == 4) {
WalletStorage.getInstance(NextApplication.mContext).getAll().get(i).setSelect(false);
} else {
WalletStorage.getInstance(getApplicationContext()).get().get(i).setSelect(false);
}
} else {
if (type == 4) {
WalletStorage.getInstance(NextApplication.mContext).getAll().get(i).setSelect(true);
} else {
WalletStorage.getInstance(getApplicationContext()).get().get(i).setSelect(true);
}
}
}
initWalletInfo();
if (type != 4) {
Utils.sendBroadcastReceiver(GesturePasswordLoginActivity.this, new Intent(Constants.WALLET_REFRESH_GESTURE), false);
}
}
});
picker.show();
}
use of com.lingtuan.firefly.wallet.vo.StorableWallet in project SmartMesh_Android by SmartMeshFoundation.
the class GesturePasswordLoginActivity method initWalletInfo.
/**
* Load or refresh the wallet information
*/
private void initWalletInfo() {
ArrayList<StorableWallet> storableWallets;
if (type == 4) {
storableWallets = WalletStorage.getInstance(NextApplication.mContext).getAll();
} else {
storableWallets = WalletStorage.getInstance(NextApplication.mContext).get();
}
if (storableWallets == null || storableWallets.size() <= 0) {
return;
}
for (int i = 0; i < storableWallets.size(); i++) {
if (storableWallets.get(i).isSelect()) {
index = i;
int imgId = Utils.getWalletImg(GesturePasswordLoginActivity.this, i);
walletImg.setImageResource(imgId);
storableWallet = storableWallets.get(i);
storableWallet.setImgId(imgId);
walletName.setText(storableWallet.getWalletName());
String address = storableWallet.getPublicKey();
if (!address.startsWith("0x")) {
address = "0x" + address;
}
walletAddress.setText(address);
break;
}
}
if (index == -1 && storableWallets.size() > 0) {
int imgId = Utils.getWalletImg(GesturePasswordLoginActivity.this, 0);
walletImg.setImageResource(imgId);
storableWallet = storableWallets.get(0);
storableWallet.setImgId(imgId);
walletName.setText(storableWallet.getWalletName());
String address = storableWallet.getPublicKey();
if (!address.startsWith("0x")) {
address = "0x" + address;
}
walletAddress.setText(address);
}
}
use of com.lingtuan.firefly.wallet.vo.StorableWallet in project SmartMesh_Android by SmartMeshFoundation.
the class WalletHandler method handleMessage.
@Override
public void handleMessage(Message msg) {
switch(msg.what) {
case WALLET_ING:
break;
case WALLET_SUCCESS:
Intent intent = new Intent(Constants.WALLET_SUCCESS);
StorableWallet storableWallet = (StorableWallet) msg.obj;
intent.putExtra(Constants.WALLET_INFO, storableWallet);
Utils.sendBroadcastReceiver(mContext, intent, false);
break;
case WALLET_ERROR:
Utils.sendBroadcastReceiver(mContext, new Intent(Constants.WALLET_ERROR), false);
break;
case NO_MEMORY:
Utils.sendBroadcastReceiver(mContext, new Intent(Constants.NO_MEMORY), false);
break;
case WALLET_PWD_ERROR:
Utils.sendBroadcastReceiver(mContext, new Intent(Constants.WALLET_PWD_ERROR), false);
break;
case WALLET_REPEAT_ERROR:
Utils.sendBroadcastReceiver(mContext, new Intent(Constants.WALLET_REPEAT_ERROR), false);
break;
}
}
use of com.lingtuan.firefly.wallet.vo.StorableWallet in project SmartMesh_Android by SmartMeshFoundation.
the class WalletCreateSuccessActivity method onClick.
@Override
public void onClick(View v) {
switch(v.getId()) {
case R.id.walletCopy:
int imgId = Utils.getWalletImg(WalletCreateSuccessActivity.this, (WalletStorage.getInstance(getApplicationContext()).get().size() - 1));
Intent copyIntent = new Intent(WalletCreateSuccessActivity.this, WalletCopyActivity.class);
ArrayList<StorableWallet> list = WalletStorage.getInstance(getApplicationContext()).get();
copyIntent.putExtra(Constants.WALLET_INFO, list.get(list.size() - 1));
copyIntent.putExtra(Constants.WALLET_ICON, imgId);
startActivity(copyIntent);
break;
case R.id.app_back:
startActivity(new Intent(WalletCreateSuccessActivity.this, MainFragmentUI.class));
finish();
break;
default:
super.onClick(v);
}
}
use of com.lingtuan.firefly.wallet.vo.StorableWallet in project SmartMesh_Android by SmartMeshFoundation.
the class WalletStorage method loadAll.
/**
* Read in json
* @param context context
*/
@SuppressWarnings("unchecked")
public synchronized ArrayList<StorableWallet> loadAll(Context context) {
String walletList = MySharedPrefs.readWalletModeAllList(context);
if (TextUtils.isEmpty(walletList)) {
return null;
}
if (mapdbLogin == null) {
mapdbLogin = new ArrayList<>();
} else {
mapdbLogin.clear();
}
try {
JSONObject object = new JSONObject(walletList);
JSONArray walletArray = object.optJSONArray("data");
for (int i = 0; i < walletArray.length(); i++) {
JSONObject walletObj = walletArray.optJSONObject(i);
StorableWallet storableWallet = new StorableWallet();
storableWallet.setPublicKey(walletObj.optString(Constants.WALLET_ADDRESS));
storableWallet.setWalletName(walletObj.optString(Constants.WALLET_NAME));
storableWallet.setCanExportPrivateKey(walletObj.optInt(Constants.WALLET_EXTRA));
storableWallet.setBackup(walletObj.optBoolean(Constants.WALLET_BACKUP));
if (i == 0) {
storableWallet.setSelect(true);
}
File destination = new File(new File(context.getFilesDir(), SDCardCtrl.WALLERPATH), storableWallet.getPublicKey());
if (!destination.exists()) {
storableWallet.setWalletType(1);
}
mapdbLogin.add(storableWallet);
}
} catch (JSONException e) {
e.printStackTrace();
}
return mapdbLogin;
}
Aggregations