diff --git a/CHANGELOG.md b/CHANGELOG.md index 0a849dd9..99f479f0 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,11 @@ # OST Wallet SDK Changelog +## Version 2.3.4 +### Bug Fixes: +* Device list inconsistency fix in manage devices. +* User entity current device caching fix. +* Converted Toast error message of enter mnemonics view to inline error message + ## Version 2.3.3 ### Changes: * Proguard usage to remove verbose and debug logs. diff --git a/README.md b/README.md index 6dfd45a0..f41f7bcb 100644 --- a/README.md +++ b/README.md @@ -108,7 +108,7 @@ compileOptions { ``` dependencies { - implementation 'com.ost:ost-wallet-sdk-android:2.3.3' + implementation 'com.ost:ost-wallet-sdk-android:2.3.4' ... ... ... diff --git a/ostsdk/gradle.properties b/ostsdk/gradle.properties index 69a89188..58fbc8ab 100644 --- a/ostsdk/gradle.properties +++ b/ostsdk/gradle.properties @@ -22,9 +22,9 @@ # org.gradle.parallel=true #Increase version when publishing. -VERSION_NAME=2.3.3 +VERSION_NAME=2.3.4 #Increase version code when publishing. -VERSION_CODE=38 +VERSION_CODE=43 #Everything else. GROUP=com.ost diff --git a/ostsdk/src/main/java/com/ost/walletsdk/models/Impls/OstDeviceManagerModelRepository.java b/ostsdk/src/main/java/com/ost/walletsdk/models/Impls/OstDeviceManagerModelRepository.java index 86282418..373de54d 100644 --- a/ostsdk/src/main/java/com/ost/walletsdk/models/Impls/OstDeviceManagerModelRepository.java +++ b/ostsdk/src/main/java/com/ost/walletsdk/models/Impls/OstDeviceManagerModelRepository.java @@ -20,7 +20,7 @@ class OstDeviceManagerModelRepository extends OstBaseModelCacheRepository implements OstDeviceManagerModel { - private static final int LRU_CACHE_SIZE = 5; + private static final int LRU_CACHE_SIZE = 150; private OstDeviceManagerDao mOstDeviceManagerDao; OstDeviceManagerModelRepository() { diff --git a/ostsdk/src/main/java/com/ost/walletsdk/models/Impls/OstSessionModelRepository.java b/ostsdk/src/main/java/com/ost/walletsdk/models/Impls/OstSessionModelRepository.java index f9c162d6..1833d949 100644 --- a/ostsdk/src/main/java/com/ost/walletsdk/models/Impls/OstSessionModelRepository.java +++ b/ostsdk/src/main/java/com/ost/walletsdk/models/Impls/OstSessionModelRepository.java @@ -20,7 +20,7 @@ class OstSessionModelRepository extends OstBaseModelCacheRepository implements OstSessionModel { - private static final int LRU_CACHE_SIZE = 5; + private static final int LRU_CACHE_SIZE = 150; private OstSessionDao mOstSessionDao; OstSessionModelRepository() { diff --git a/ostsdk/src/main/java/com/ost/walletsdk/models/Impls/OstTransactionModelRepository.java b/ostsdk/src/main/java/com/ost/walletsdk/models/Impls/OstTransactionModelRepository.java index 292fb1be..85647a11 100644 --- a/ostsdk/src/main/java/com/ost/walletsdk/models/Impls/OstTransactionModelRepository.java +++ b/ostsdk/src/main/java/com/ost/walletsdk/models/Impls/OstTransactionModelRepository.java @@ -18,7 +18,7 @@ class OstTransactionModelRepository extends OstBaseModelCacheRepository implements OstTransactionModel { - private static final int LRU_CACHE_SIZE = 5; + private static final int LRU_CACHE_SIZE = 150; private OstTransactionDao mOstTransactionDao; OstTransactionModelRepository() { diff --git a/ostsdk/src/main/java/com/ost/walletsdk/models/entities/OstUser.java b/ostsdk/src/main/java/com/ost/walletsdk/models/entities/OstUser.java index 4ee2f8af..b0862e91 100644 --- a/ostsdk/src/main/java/com/ost/walletsdk/models/entities/OstUser.java +++ b/ostsdk/src/main/java/com/ost/walletsdk/models/entities/OstUser.java @@ -50,7 +50,7 @@ public static String getIdentifier() { } @Ignore - private OstDevice currentDevice = null; + private String mCurrentDeviceAddress = null; public static OstUser getById(String id) { return OstModelFactory.getUserModel().getEntityById(id); @@ -75,14 +75,17 @@ public static OstUser init(String id, String tokenId) { } public OstDevice getCurrentDevice() { - if (null == currentDevice) { + OstDevice currentDevice = null; + if (null == mCurrentDeviceAddress) { OstKeyManager ostKeyManager = new OstKeyManager(getId()); - String currentDeviceAddress = ostKeyManager.getDeviceAddress(); - if (null != currentDeviceAddress) { - currentDevice = OstDevice.getById(currentDeviceAddress); - Log.d(TAG, String.format("currentDeviceAddress: %s", currentDeviceAddress)); + mCurrentDeviceAddress = ostKeyManager.getDeviceAddress(); + if (null == mCurrentDeviceAddress) { + Log.e(TAG, "Current Device address is null, seems like device has been revoked"); + return null; } } + Log.d(TAG, String.format("currentDeviceAddress: %s", mCurrentDeviceAddress)); + currentDevice = OstDevice.getById(mCurrentDeviceAddress); return currentDevice; } @@ -289,7 +292,7 @@ public boolean isActivating() { } public void flushCurrentDevice() { - this.currentDevice = null; + this.mCurrentDeviceAddress = null; } public UserStatus getUserStatus() { diff --git a/ostsdk/src/main/java/com/ost/walletsdk/ui/entermnemonics/EnterMnemonicsFragment.java b/ostsdk/src/main/java/com/ost/walletsdk/ui/entermnemonics/EnterMnemonicsFragment.java index 2dcff068..12382657 100644 --- a/ostsdk/src/main/java/com/ost/walletsdk/ui/entermnemonics/EnterMnemonicsFragment.java +++ b/ostsdk/src/main/java/com/ost/walletsdk/ui/entermnemonics/EnterMnemonicsFragment.java @@ -25,6 +25,7 @@ import com.ost.walletsdk.ui.sdkInteract.SdkInteract; import com.ost.walletsdk.ui.sdkInteract.WorkFlowListener; import com.ost.walletsdk.ui.uicomponents.AppBar; +import com.ost.walletsdk.ui.uicomponents.OstTextView; import com.ost.walletsdk.ui.uicomponents.uiutils.content.ContentConfig; import com.ost.walletsdk.ui.uicomponents.uiutils.content.StringConfig; @@ -45,6 +46,8 @@ public class EnterMnemonicsFragment extends BaseFragment implements EnterMnemoni EnterMnemonicsPresenter mEnterMnemonicsPresenter = EnterMnemonicsPresenter.getInstance(); JSONObject contentConfig = ContentConfig.getInstance().getStringConfig("add_current_device_with_mnemonics").optJSONObject("provide_mnemonics"); + private OstTextView mErrorMessage; + public EnterMnemonicsFragment() { // Required empty public constructor } @@ -110,6 +113,8 @@ public void onClick(View v) { } }); + mErrorMessage = viewGroup.findViewById(R.id.otv_error_message); + mEnterMnemonicsPresenter.attachView(this); AppBar appBar = AppBar.newInstance(getContext(), false); setUpAppBar(viewGroup, appBar); @@ -121,4 +126,13 @@ public void onDestroyView() { mEnterMnemonicsPresenter.detachView(); mEnterMnemonicsPresenter = null; } + + @Override + public void showErrorMessage(boolean show) { + if (show) { + mErrorMessage.setVisibility(View.VISIBLE); + } else { + mErrorMessage.setVisibility(View.INVISIBLE); + } + } } \ No newline at end of file diff --git a/ostsdk/src/main/java/com/ost/walletsdk/ui/entermnemonics/EnterMnemonicsPresenter.java b/ostsdk/src/main/java/com/ost/walletsdk/ui/entermnemonics/EnterMnemonicsPresenter.java index d3876dd3..1e43405d 100644 --- a/ostsdk/src/main/java/com/ost/walletsdk/ui/entermnemonics/EnterMnemonicsPresenter.java +++ b/ostsdk/src/main/java/com/ost/walletsdk/ui/entermnemonics/EnterMnemonicsPresenter.java @@ -47,9 +47,10 @@ void recoverWallet(String mnemonicsPhrase) { //mnemonics validation String[] mnemonicsArray = mnemonicsPhrase.split(" "); if (mnemonicsArray.length != 12) { - getMvpView().showToastMessage("Mnemonics length should be of 12 words", false); + getMvpView().showErrorMessage(true); return; } + getMvpView().showErrorMessage(false); getMvpView().showProgress(true, StringConfig.instance(contentConfig.optJSONObject("initial_loader")).getString()); diff --git a/ostsdk/src/main/java/com/ost/walletsdk/ui/entermnemonics/EnterMnemonicsView.java b/ostsdk/src/main/java/com/ost/walletsdk/ui/entermnemonics/EnterMnemonicsView.java index bfa615af..67e908f1 100644 --- a/ostsdk/src/main/java/com/ost/walletsdk/ui/entermnemonics/EnterMnemonicsView.java +++ b/ostsdk/src/main/java/com/ost/walletsdk/ui/entermnemonics/EnterMnemonicsView.java @@ -14,5 +14,5 @@ import com.ost.walletsdk.ui.BaseView; interface EnterMnemonicsView extends BaseView { - + void showErrorMessage(boolean show); } \ No newline at end of file diff --git a/ostsdk/src/main/java/com/ost/walletsdk/ui/managedevices/DeviceListFragment.java b/ostsdk/src/main/java/com/ost/walletsdk/ui/managedevices/DeviceListFragment.java index 243d6aa0..b66c7646 100644 --- a/ostsdk/src/main/java/com/ost/walletsdk/ui/managedevices/DeviceListFragment.java +++ b/ostsdk/src/main/java/com/ost/walletsdk/ui/managedevices/DeviceListFragment.java @@ -46,6 +46,7 @@ public class DeviceListFragment extends BaseFragment implements DeviceListView { private static final String ACTION_NAME = "action_name"; private static final String INITIATED_RECOVERY = "initiate_recovery"; private static final String MANAGE_DEVICE = "manage_device"; + private static final int SCROLL_ITEM_THRESHOLD = 5; public JSONObject contentConfig = new JSONObject(); private DeviceListRecyclerViewAdapter.OnDeviceListInteractionListener mListener; @@ -148,8 +149,8 @@ public void onScrolled(@NonNull RecyclerView recyclerView, int dx, int dy) { int visibleItemCount = layoutManager.getChildCount(); int totalItemCount = layoutManager.getItemCount(); int firstVisibleItemPosition = layoutManager.findFirstVisibleItemPosition(); - if (!paginationRequestSent && dy > 0 && (visibleItemCount + firstVisibleItemPosition) >= - totalItemCount && firstVisibleItemPosition >= 0) { + if (!paginationRequestSent && dy > 0 && (SCROLL_ITEM_THRESHOLD + firstVisibleItemPosition) >= + totalItemCount) { paginationRequestSent = true; mDeviceListPresenter.updateDeviceList(false); } @@ -197,5 +198,6 @@ public void notifyDataSetChanged() { @Override public void setRefreshing(boolean refreshing) { mPullToRefresh.setRefreshing(refreshing); + paginationRequestSent = false; } } \ No newline at end of file diff --git a/ostsdk/src/main/java/com/ost/walletsdk/ui/managedevices/DeviceListPresenter.java b/ostsdk/src/main/java/com/ost/walletsdk/ui/managedevices/DeviceListPresenter.java index 917828e3..adb214c7 100644 --- a/ostsdk/src/main/java/com/ost/walletsdk/ui/managedevices/DeviceListPresenter.java +++ b/ostsdk/src/main/java/com/ost/walletsdk/ui/managedevices/DeviceListPresenter.java @@ -34,10 +34,12 @@ class DeviceListPresenter extends BasePresenter { private static final String LOG_TAG = "OstDeviceListPresenter"; + private static final int MINIMUM_DEVICES = 5; private String mUserId; private String currentDeviceAddress; private String mLoaderString = "Loading..."; private boolean mRunningLoader = false; + private boolean mClearDeviceList; private DeviceListPresenter() {} @@ -59,57 +61,72 @@ public void attachView(DeviceListView mvpView) { updateDeviceList(true); } - void updateDeviceList(Boolean clearList) { + void updateDeviceList(boolean clearList) { if(httpRequestPending){ return; } + httpRequestPending = true; if(clearList){ + mClearDeviceList = true; nextPayload = new JSONObject(); } else if(!hasMoreData){ return; } - httpRequestPending = true; + showProgress(true); + getDeviceList(); + } + private void getDeviceList() { Map mapPayload = new HashMap<>(); try { mapPayload = new CommonUtils().convertJsonToMap(nextPayload); } catch (JSONException e) { Log.e(LOG_TAG, "Exception while converting payload map", e); } - showProgress(true); OstJsonApi.getDeviceList(mUserId, mapPayload, new OstJsonApiCallback() { @Override public void onOstJsonApiSuccess(@Nullable JSONObject dataJSONObject) { - showLoaderProgress(false); - showProgress(false); - if (null == dataJSONObject) { - httpRequestPending = false; - return; - } - try { - JSONObject meta = dataJSONObject.optJSONObject("meta"); - if (null != meta) nextPayload = meta.optJSONObject("next_page_payload"); - - hasMoreData = (nextPayload != null && !nextPayload.toString().equals("{}")); - JSONArray deviceJSONArray = (JSONArray) dataJSONObject.get(dataJSONObject.getString(OstConstants.RESULT_TYPE)); - - if (clearList) ostDeviceList.clear(); - for (int i = 0; i < deviceJSONArray.length(); i++) { - JSONObject deviceJSONObject = deviceJSONArray.getJSONObject(i); - Device device = Device.newInstance(deviceJSONObject); - if (device.isAuthorized() && !device.getDeviceAddress().equalsIgnoreCase(currentDeviceAddress)) { - ostDeviceList.add(device); + if (null != dataJSONObject) { + try { + JSONObject meta = dataJSONObject.optJSONObject("meta"); + if (null != meta) nextPayload = meta.optJSONObject("next_page_payload"); + + + hasMoreData = (nextPayload != null && !nextPayload.toString().equals("{}")); + JSONArray deviceJSONArray = (JSONArray) dataJSONObject.get(dataJSONObject.getString(OstConstants.RESULT_TYPE)); + + //Clear list if new device request received + if (mClearDeviceList) { + ostDeviceList.clear(); + mClearDeviceList = false; } + + //Populate authorized device in the list + for (int i = 0; i < deviceJSONArray.length(); i++) { + JSONObject deviceJSONObject = deviceJSONArray.getJSONObject(i); + Device device = Device.newInstance(deviceJSONObject); + if (device.isAuthorized() && !device.getDeviceAddress().equalsIgnoreCase(currentDeviceAddress)) { + ostDeviceList.add(device); + } + } + + if (ostDeviceList.isEmpty()) { + ostDeviceList.add(Device.newInstance(new JSONObject())); + } + + // Make request if did not get enough devices + if (hasMoreData && ostDeviceList.size() < MINIMUM_DEVICES) { + getDeviceList(); + return; + } + } catch (JSONException e) { + //Exception not expected } - if (ostDeviceList.isEmpty()) { - ostDeviceList.add(Device.newInstance(new JSONObject())); - } - } catch (JSONException e) { - //Exception not expected } - getMvpView().notifyDataSetChanged(); - httpRequestPending = false; + showLoaderProgress(false); + showProgress(false); + getMvpView().notifyDataSetChanged(); } @Override @@ -122,7 +139,6 @@ public void onOstJsonApiError(@NonNull OstError err, @Nullable JSONObject respon } }); } - private void showProgress(boolean show) { if (mRunningLoader) return; if (null != getMvpView()) getMvpView().setRefreshing(show); diff --git a/ostsdk/src/main/java/com/ost/walletsdk/ui/recovery/RecoveryPresenter.java b/ostsdk/src/main/java/com/ost/walletsdk/ui/recovery/RecoveryPresenter.java index 982a493e..4213f89b 100644 --- a/ostsdk/src/main/java/com/ost/walletsdk/ui/recovery/RecoveryPresenter.java +++ b/ostsdk/src/main/java/com/ost/walletsdk/ui/recovery/RecoveryPresenter.java @@ -18,6 +18,8 @@ import com.ost.walletsdk.ui.sdkInteract.SdkInteract; import com.ost.walletsdk.ui.sdkInteract.WorkFlowListener; import com.ost.walletsdk.workflows.OstWorkflowContext; +import com.ost.walletsdk.workflows.errors.OstError; +import com.ost.walletsdk.workflows.errors.OstErrors; class RecoveryPresenter extends BasePresenter { @@ -46,7 +48,9 @@ public void setPassphrase(String passphrase) { @Override public void cancelFlow() { Log.d("getPinSalt", "Exception in fetching Pin Salt."); - recoverySaltFetchFailed(); + getMvpView().showProgress(false); + OstError error = new OstError("ws_wsp_cf", OstErrors.ErrorCode.WORKFLOW_CANCELLED); + workFlowListener.flowInterrupt(getWorkFlowContext(), error); } }); } @@ -59,12 +63,6 @@ void startWorkFlow(String ostUserId, UserPassphrase currentUserPassPhrase, Strin } - private void recoverySaltFetchFailed(){ - getMvpView().showProgress(false); - getMvpView().gotoDashboard(null); - getMvpView().showToastMessage("Recovery could not be initiated. Please try after sometime.", false); - } - public void setArguments(String userId, String workflowId, String deviceAddress) { this.mUserId = userId; this.mWorkflowId = workflowId; diff --git a/ostsdk/src/main/java/com/ost/walletsdk/ui/resetpin/ResetPinPresenter.java b/ostsdk/src/main/java/com/ost/walletsdk/ui/resetpin/ResetPinPresenter.java index 0f8b23ac..b17d8b56 100644 --- a/ostsdk/src/main/java/com/ost/walletsdk/ui/resetpin/ResetPinPresenter.java +++ b/ostsdk/src/main/java/com/ost/walletsdk/ui/resetpin/ResetPinPresenter.java @@ -21,6 +21,8 @@ import com.ost.walletsdk.ui.uicomponents.uiutils.content.ContentConfig; import com.ost.walletsdk.ui.uicomponents.uiutils.content.StringConfig; import com.ost.walletsdk.workflows.OstWorkflowContext; +import com.ost.walletsdk.workflows.errors.OstError; +import com.ost.walletsdk.workflows.errors.OstErrors; import org.json.JSONObject; @@ -81,8 +83,8 @@ public void setPassphrase(String passphrase) { public void cancelFlow() { Log.d("getPinSalt", "Exception in fetching Pin Salt."); getMvpView().showProgress(false); - getMvpView().showToastMessage("Reset PIN failed. Please try after sometime.", false); - getMvpView().gotoDashboard(null); + OstError error = new OstError("rpp_ope_cf", OstErrors.ErrorCode.WORKFLOW_CANCELLED); + workFlowListener.flowInterrupt(new OstWorkflowContext(OstWorkflowContext.WORKFLOW_TYPE.RESET_PIN), error); } }); diff --git a/ostsdk/src/main/java/com/ost/walletsdk/ui/walletsetup/WalletSetUpPresenter.java b/ostsdk/src/main/java/com/ost/walletsdk/ui/walletsetup/WalletSetUpPresenter.java index c3142bbc..f6cdd46b 100644 --- a/ostsdk/src/main/java/com/ost/walletsdk/ui/walletsetup/WalletSetUpPresenter.java +++ b/ostsdk/src/main/java/com/ost/walletsdk/ui/walletsetup/WalletSetUpPresenter.java @@ -27,6 +27,7 @@ import com.ost.walletsdk.workflows.OstContextEntity; import com.ost.walletsdk.workflows.OstWorkflowContext; import com.ost.walletsdk.workflows.errors.OstError; +import com.ost.walletsdk.workflows.errors.OstErrors; import org.json.JSONObject; @@ -107,7 +108,8 @@ public void setPassphrase(String passphrase) { @Override public void cancelFlow() { getMvpView().showProgress(false); - getMvpView().showToastMessage("User Activation failed. Please try after sometime.", false); + OstError error = new OstError("ws_swf_cf", OstErrors.ErrorCode.WORKFLOW_CANCELLED); + workFlowListener.flowInterrupt(new OstWorkflowContext(OstWorkflowContext.WORKFLOW_TYPE.ACTIVATE_USER), error); } }); } diff --git a/ostsdk/src/main/java/com/ost/walletsdk/ui/workflow/OstAuthorizeDeviceViaQRWorkflow.java b/ostsdk/src/main/java/com/ost/walletsdk/ui/workflow/OstAuthorizeDeviceViaQRWorkflow.java index 72920287..00ad7a16 100644 --- a/ostsdk/src/main/java/com/ost/walletsdk/ui/workflow/OstAuthorizeDeviceViaQRWorkflow.java +++ b/ostsdk/src/main/java/com/ost/walletsdk/ui/workflow/OstAuthorizeDeviceViaQRWorkflow.java @@ -94,7 +94,6 @@ public void onResultString(Intent data) { } catch (JSONException e) { Log.e(LOG_TAG, "Exception in Data;"); showProgress(false); - showToastMessage("QR Reading failed.. Try Again", false); } } } diff --git a/ostsdk/src/main/java/com/ost/walletsdk/ui/workflow/OstExecuteTxnViaQRWorkflow.java b/ostsdk/src/main/java/com/ost/walletsdk/ui/workflow/OstExecuteTxnViaQRWorkflow.java index f3a9282a..104e2a8c 100644 --- a/ostsdk/src/main/java/com/ost/walletsdk/ui/workflow/OstExecuteTxnViaQRWorkflow.java +++ b/ostsdk/src/main/java/com/ost/walletsdk/ui/workflow/OstExecuteTxnViaQRWorkflow.java @@ -98,7 +98,6 @@ public void onResultString(Intent data) { } catch (JSONException e) { Log.e(LOG_TAG, "Exception in Data;"); showProgress(false); - showToastMessage("QR Reading failed.. Try Again", false); } } } diff --git a/ostsdk/src/main/java/com/ost/walletsdk/ui/workflow/OstWorkFlowActivity.java b/ostsdk/src/main/java/com/ost/walletsdk/ui/workflow/OstWorkFlowActivity.java index 19d6ef9a..18dee44b 100644 --- a/ostsdk/src/main/java/com/ost/walletsdk/ui/workflow/OstWorkFlowActivity.java +++ b/ostsdk/src/main/java/com/ost/walletsdk/ui/workflow/OstWorkFlowActivity.java @@ -5,6 +5,7 @@ import android.content.Intent; import android.os.Bundle; import android.support.v4.app.Fragment; +import android.util.Log; import android.view.View; import com.ost.walletsdk.OstSdk; @@ -14,9 +15,6 @@ import com.ost.walletsdk.ui.ChildFragmentStack; import com.ost.walletsdk.ui.WebViewFragment; import com.ost.walletsdk.ui.WorkFlowPinFragment; -import com.ost.walletsdk.ui.interfaces.FlowCompleteListener; -import com.ost.walletsdk.ui.interfaces.FlowInterruptListener; -import com.ost.walletsdk.ui.interfaces.RequestAcknowledgedListener; import com.ost.walletsdk.ui.managedevices.Device; import com.ost.walletsdk.ui.managedevices.DeviceListRecyclerViewAdapter; import com.ost.walletsdk.ui.recovery.AbortRecoveryFragment; @@ -73,6 +71,7 @@ public class OstWorkFlowActivity extends BaseActivity implements WalletSetUpFrag private static final String CROSS_BUTTON_CLICK_CODE = "owfa_gb"; WorkFlowListener mWorkFlowListener; + private boolean mUiWorkflowFinished = false; private Intent mIntent; String mWorkflowId; String mWorkFlowName; @@ -98,13 +97,13 @@ protected void onCreate(Bundle savedInstanceState) { ensureValidState(); } catch (OstError error) { mWorkFlowListener.flowInterrupt(getWorkflowContext(), error); - finish(); + finishWorkflow(); return; } catch (Throwable th) { OstError error = new OstError("owfa_onc_1", OstErrors.ErrorCode.UNCAUGHT_EXCEPTION_HANDELED); error.setStackTrace( th.getStackTrace() ); mWorkFlowListener.flowInterrupt(getWorkflowContext(), error); - finish(); + finishWorkflow(); return; } @@ -229,20 +228,21 @@ public boolean pinValidated(String workflowId, OstWorkflowContext ostWorkflowCon @Override public boolean flowComplete(String workflowId, OstWorkflowContext ostWorkflowContext, OstContextEntity ostContextEntity) { showProgress(false); - finish(); + finishWorkflow(); return false; } @Override public boolean flowInterrupt(String workflowId, OstWorkflowContext ostWorkflowContext, OstError ostError) { showProgress(false); - finish(); + finishWorkflow(); return false; } @Override public boolean requestAcknowledged(String workflowId, OstWorkflowContext ostWorkflowContext, OstContextEntity ostContextEntity) { showProgress(false); + setUiWorkfLowFinished(); finish(); return false; } @@ -252,6 +252,15 @@ public boolean verifyData(String workflowId, OstWorkflowContext ostWorkflowConte return false; } + private void finishWorkflow() { + setUiWorkfLowFinished(); + finish(); + } + + private void setUiWorkfLowFinished() { + mUiWorkflowFinished = true; + } + private void showGetPinFragment(String workflowId, String userId, OstWorkflowContext ostWorkflowContext, OstPinAcceptInterface ostPinAcceptInterface) { JSONObject stringConfigJsonObject = getContentString(ostWorkflowContext); WorkFlowPinFragment fragment = WorkFlowPinFragment.newInstance("Get Pin", getResources().getString(R.string.pin_sub_heading_get_pin), showBackButton()); @@ -301,4 +310,14 @@ public void invalidPin(long workflowId, OstWorkflowContext ostWorkflowContext, S protected boolean isCrossButtonClicked(OstError ostError) { return CROSS_BUTTON_CLICK_CODE.equals(ostError.getInternalErrorCode()); } + + @Override + protected void onDestroy() { + super.onDestroy(); + OstError error = new OstError("owfa_ond_2", OstErrors.ErrorCode.WORKFLOW_VIEW_DESTROYED); + if (!mUiWorkflowFinished) { + Log.d(LOG_TAG, "Workflow view destroyed"); + if (null != mWorkFlowListener) mWorkFlowListener.flowInterrupt(getWorkflowContext(), error); + } + } } \ No newline at end of file diff --git a/ostsdk/src/main/java/com/ost/walletsdk/workflows/errors/OstErrors.java b/ostsdk/src/main/java/com/ost/walletsdk/workflows/errors/OstErrors.java index d8502513..5aed6479 100644 --- a/ostsdk/src/main/java/com/ost/walletsdk/workflows/errors/OstErrors.java +++ b/ostsdk/src/main/java/com/ost/walletsdk/workflows/errors/OstErrors.java @@ -201,6 +201,9 @@ public static String getMessage(ErrorCode code) { case WORKFLOW_FAILED: return "Something went wrong, please try again"; + case WORKFLOW_VIEW_DESTROYED: + return "The application interrupted the workflow. The view got terminated while performing the workflow"; + //deprecated case GET_USER_API_FAILED: return "Failed to fetch user information. Either OST server is unavailable temporarily OR your connection is going idle. Check your connection and re-submit the request a bit later."; @@ -310,6 +313,7 @@ public enum ErrorCode { UNKNOWN, WORKFLOW_CANCELLED, WORKFLOW_FAILED, + WORKFLOW_VIEW_DESTROYED, UNCAUGHT_EXCEPTION_HANDELED, FAILED_TO_GENERATE_ETH_KEY, OST_PLATFORM_API_ERROR, diff --git a/ostsdk/src/main/res/layout/ost_fragment_enter_mnemonics.xml b/ostsdk/src/main/res/layout/ost_fragment_enter_mnemonics.xml index da5f127f..4c4792ac 100644 --- a/ostsdk/src/main/res/layout/ost_fragment_enter_mnemonics.xml +++ b/ostsdk/src/main/res/layout/ost_fragment_enter_mnemonics.xml @@ -50,6 +50,17 @@ android:layout_marginEnd="15dp" android:layout_marginBottom="10dp"/> + The Wallet setup process takes about 30 seconds. You can continue to use the app and we’ll notify when the wallet is ready to use. No Transactions Completed! Looks like you have not made any transactions, send some tokens to other users. + + + Invalid Mnemonics passed