diff --git a/app/build.gradle b/app/build.gradle index 2da7ecee..1b94066d 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -53,8 +53,8 @@ android { applicationId "com.cybexmobile" minSdkVersion rootProject.ext.android.minSdkVersion targetSdkVersion rootProject.ext.android.targetSdkVersion - versionCode 1011 - versionName "1.10.11" + versionCode 1012 + versionName "1.10.12" multiDexEnabled true javaCompileOptions { @@ -162,5 +162,5 @@ dependencies { implementation project(':core') //Flutter - implementation project(':flutter') +// implementation project(':flutter') } diff --git a/app/src/main/java/com/cybexmobile/activity/gateway/withdraw/WithdrawActivity.java b/app/src/main/java/com/cybexmobile/activity/gateway/withdraw/WithdrawActivity.java index c2313c90..830ce6a4 100644 --- a/app/src/main/java/com/cybexmobile/activity/gateway/withdraw/WithdrawActivity.java +++ b/app/src/main/java/com/cybexmobile/activity/gateway/withdraw/WithdrawActivity.java @@ -37,27 +37,19 @@ import com.apollographql.apollo.cache.normalized.CacheControl; import com.apollographql.apollo.fragment.WithdrawinfoObject; import com.apollographql.apollo.rx2.Rx2Apollo; -import com.cybex.basemodule.constant.Constant; -import com.cybex.provider.SettingConfig; -import com.cybex.provider.db.DBManager; -import com.cybex.provider.db.entity.Address; -import com.cybex.provider.graphene.chain.GlobalConfigObject; -import com.cybex.provider.http.RetrofitFactory; -import com.cybex.provider.utils.SpUtil; -import com.cybex.provider.websocket.MessageCallback; -import com.cybex.provider.websocket.Reply; -import com.cybexmobile.R; -import com.cybexmobile.activity.gateway.records.DepositWithdrawRecordsActivity; -import com.cybexmobile.activity.address.AddTransferAccountActivity; -import com.cybex.provider.apollo.ApolloClientApi; import com.cybex.basemodule.BitsharesWalletWraper; import com.cybex.basemodule.base.BaseActivity; -import com.cybexmobile.activity.setting.enotes.SetCloudPasswordActivity; -import com.cybexmobile.data.GatewayLogInRecordRequest; -import com.cybexmobile.dialog.CommonSelectDialog; +import com.cybex.basemodule.constant.Constant; import com.cybex.basemodule.dialog.CybexDialog; import com.cybex.basemodule.dialog.UnlockDialog; import com.cybex.basemodule.event.Event; +import com.cybex.basemodule.service.WebSocketService; +import com.cybex.basemodule.toastmessage.ToastMessage; +import com.cybex.basemodule.utils.SoftKeyBoardListener; +import com.cybex.provider.SettingConfig; +import com.cybex.provider.apollo.ApolloClientApi; +import com.cybex.provider.db.DBManager; +import com.cybex.provider.db.entity.Address; import com.cybex.provider.exception.NetworkStatusException; import com.cybex.provider.graphene.chain.AccountBalanceObject; import com.cybex.provider.graphene.chain.AccountObject; @@ -68,16 +60,19 @@ import com.cybex.provider.graphene.chain.FullAccountObjectReply; import com.cybex.provider.graphene.chain.ObjectId; import com.cybex.provider.graphene.chain.Operations; -import com.cybex.provider.graphene.chain.PrivateKey; import com.cybex.provider.graphene.chain.SignedTransaction; import com.cybex.provider.graphene.chain.Types; -import com.cybex.basemodule.service.WebSocketService; -import com.cybex.basemodule.toastmessage.ToastMessage; +import com.cybex.provider.http.RetrofitFactory; +import com.cybex.provider.utils.SpUtil; +import com.cybex.provider.websocket.MessageCallback; +import com.cybex.provider.websocket.Reply; +import com.cybexmobile.R; +import com.cybexmobile.activity.address.AddTransferAccountActivity; +import com.cybexmobile.activity.gateway.records.DepositWithdrawRecordsActivity; +import com.cybexmobile.activity.setting.enotes.SetCloudPasswordActivity; +import com.cybexmobile.dialog.CommonSelectDialog; import com.cybexmobile.shake.AntiShake; import com.cybexmobile.utils.DecimalDigitsInputFilter; -import com.cybex.basemodule.utils.SoftKeyBoardListener; -import com.google.gson.Gson; -import com.google.gson.JsonObject; import org.apache.commons.lang3.math.NumberUtils; import org.greenrobot.eventbus.EventBus; @@ -87,9 +82,8 @@ import org.json.JSONObject; import java.io.Serializable; +import java.math.BigDecimal; import java.util.ArrayList; -import java.util.Calendar; -import java.util.Date; import java.util.List; import java.util.Locale; import java.util.Map; @@ -101,32 +95,21 @@ import butterknife.OnTextChanged; import butterknife.OnTouch; import butterknife.Unbinder; -import io.reactivex.Observable; -import io.reactivex.ObservableOnSubscribe; -import io.reactivex.ObservableSource; import io.reactivex.android.schedulers.AndroidSchedulers; import io.reactivex.disposables.CompositeDisposable; import io.reactivex.functions.Consumer; -import io.reactivex.functions.Function; import io.reactivex.schedulers.Schedulers; -import okhttp3.MediaType; -import okhttp3.RequestBody; import okhttp3.ResponseBody; import static com.cybex.basemodule.constant.Constant.ASSET_ID_CYB; -import static com.cybex.basemodule.constant.Constant.INTENT_PARAM_CRYPTO_TAG; -import static com.cybex.basemodule.constant.Constant.PREF_SERVER; -import static com.cybex.basemodule.constant.Constant.SERVER_OFFICIAL; -import static com.cybex.basemodule.constant.Constant.PREF_ADDRESS_TO_PUB_MAP; -import static com.cybex.basemodule.constant.Constant.PREF_SERVER; -import static com.cybex.basemodule.constant.Constant.SERVER_OFFICIAL; -import static com.cybex.provider.graphene.chain.Operations.ID_TRANSER_OPERATION; import static com.cybex.basemodule.constant.Constant.INTENT_PARAM_ADDRESS; import static com.cybex.basemodule.constant.Constant.INTENT_PARAM_CRYPTO_ID; -import static com.cybex.basemodule.constant.Constant.INTENT_PARAM_CRYPTO_MEMO; import static com.cybex.basemodule.constant.Constant.INTENT_PARAM_CRYPTO_NAME; +import static com.cybex.basemodule.constant.Constant.INTENT_PARAM_CRYPTO_TAG; import static com.cybex.basemodule.constant.Constant.INTENT_PARAM_ITEMS; import static com.cybex.basemodule.constant.Constant.INTENT_PARAM_SELECTED_ITEM; +import static com.cybex.basemodule.constant.Constant.PREF_ADDRESS_TO_PUB_MAP; +import static com.cybex.provider.graphene.chain.Operations.ID_TRANSER_OPERATION; public class WithdrawActivity extends BaseActivity { @@ -558,7 +541,7 @@ private void toWithdraw() { @Override public void onMessage(Reply reply) { mDynamicGlobalPropertyObject = reply.result; - if (mFeeAmountObject.amount <= getBalance(mFullAccountObject, ASSET_ID_CYB)) { + if (mFeeAmountObject.asset_id.equals(ASSET_ID_CYB) && mFeeAmountObject.amount <= getBalance(mFullAccountObject, ASSET_ID_CYB)) { mTransferOperation = getTransferOperation(mAccountObject, mToAccountObject, mAssetObject, mMemo, mWithdrawAmountEditText.getText().toString().trim(), mFeeAmountObject.asset_id, mFeeAmountObject.amount); } else { mTransferOperation = getTransferOperation(mAccountObject, mToAccountObject, mAssetObject, mMemo, getSubmitAmount(mFeeAmountObject), mFeeAmountObject.asset_id, mFeeAmountObject.amount); @@ -691,16 +674,17 @@ public void onFailure() { } private void calculateReceiveAmount(FeeAmountObject feeAmountObject) { - double amount = Double.parseDouble(mWithdrawAmountEditText.getText().toString()); + String amount = mWithdrawAmountEditText.getText().toString().trim(); double fee = (feeAmountObject.amount / Math.pow(10, mAssetObject.precision)); double receiveAmount = 0; if (feeAmountObject.asset_id.equals(ASSET_ID_CYB)) { - receiveAmount = amount - mGatewayFee; + receiveAmount = Double.parseDouble(amount) - mGatewayFee; } else { - if (amount + fee > mAvailableAmount) { - receiveAmount = amount - mGatewayFee - fee; + double checkValue = new BigDecimal(amount).add(new BigDecimal(Double.toString(fee))).subtract(new BigDecimal(Double.toString(mAvailableAmount))).doubleValue(); + if (checkValue > 0) { + receiveAmount = new BigDecimal(amount).subtract(new BigDecimal(Double.toString(fee))).subtract(new BigDecimal(Double.toString(mGatewayFee))).doubleValue(); } else { - receiveAmount = amount - mGatewayFee; + receiveAmount = new BigDecimal(amount).subtract(new BigDecimal(Double.toString(mGatewayFee))).doubleValue(); } } mReceiveAmountTextView.setText(String.format("%." + (mAssetPrecision != null ? mAssetPrecision : mAssetObject.precision) + "f %s", receiveAmount, mAssetName)); @@ -763,15 +747,16 @@ public void onFailure() { } private String getSubmitAmount(FeeAmountObject feeAmountObject) { - double amount = Double.parseDouble(mWithdrawAmountEditText.getText().toString().trim()); + String amount = mWithdrawAmountEditText.getText().toString().trim(); double fee = (feeAmountObject.amount / Math.pow(10, mAssetObject.precision)); - double submitAmount = 0; - if (amount + fee > mAvailableAmount) { - submitAmount = amount - fee; + String submitAmount; + BigDecimal checkValue = new BigDecimal(amount).add(new BigDecimal(Double.toString(fee))).subtract(new BigDecimal(Double.toString(mAvailableAmount))); + if (checkValue.doubleValue() > 0) { + submitAmount = new BigDecimal(amount).subtract(new BigDecimal(Double.toString(fee))).toString(); } else { submitAmount = amount; } - return String.valueOf(submitAmount); + return submitAmount; } private void verifyAddress(String address) { diff --git a/app/src/main/java/com/cybexmobile/activity/main/BottomNavigationActivity.java b/app/src/main/java/com/cybexmobile/activity/main/BottomNavigationActivity.java index 10db5bcf..33554a0b 100644 --- a/app/src/main/java/com/cybexmobile/activity/main/BottomNavigationActivity.java +++ b/app/src/main/java/com/cybexmobile/activity/main/BottomNavigationActivity.java @@ -391,7 +391,7 @@ private void showFragment(int resId) { @Override protected void onResume() { super.onResume(); - if (mSavedInstance != null && !mAccountFragment.isHidden()) { + if (mSavedInstance != null && (mAccountFragment != null && !mAccountFragment.isHidden())) { mBottomNavigationView.setSelectedItemId(mSelectedId); } else { mSavedInstance = null; diff --git a/settings.gradle b/settings.gradle index c90372e1..c8620e4c 100644 --- a/settings.gradle +++ b/settings.gradle @@ -1,8 +1,8 @@ rootProject.name = 'cybexMobile' include ':MPChartLib', ':ui-smart-refresh', ':module-eto', ':data-provider', ':module-base', ':module-resource', ':material-spinner', ':js-bridge', ':core' include ':app' -setBinding(new Binding([gradle: this])) // new -evaluate(new File( // new - settingsDir.parentFile, // new - 'cybex-android/cybex_flutter/.android/include_flutter.groovy' // new -)) +//setBinding(new Binding([gradle: this])) // new +//evaluate(new File( // new +// settingsDir.parentFile, // new +// 'cybex-android/cybex_flutter/.android/include_flutter.groovy' // new +//))