diff --git a/app/build.gradle b/app/build.gradle index f76de23..86f4987 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -55,11 +55,11 @@ android { productFlavors { production { applicationId "com.bentonow.bentonow" - versionName '1.22-rc07' + versionName '1.22-rc08' } stage { applicationId "com.bentonow.bentonow.stage" - versionName '1.22-rc07-dev' + versionName '1.22-rc08-dev' } } diff --git a/app/src/main/java/com/bentonow/bentonow/controllers/geolocation/DeliveryLocationActivity.java b/app/src/main/java/com/bentonow/bentonow/controllers/geolocation/DeliveryLocationActivity.java index 933c4b2..4af5ed5 100644 --- a/app/src/main/java/com/bentonow/bentonow/controllers/geolocation/DeliveryLocationActivity.java +++ b/app/src/main/java/com/bentonow/bentonow/controllers/geolocation/DeliveryLocationActivity.java @@ -31,9 +31,9 @@ import com.bentonow.bentonow.Utils.ConstantUtils; import com.bentonow.bentonow.Utils.DebugUtils; import com.bentonow.bentonow.Utils.GoogleAnalyticsUtil; -import com.bentonow.bentonow.Utils.maps.LocationUtils; import com.bentonow.bentonow.Utils.SharedPreferencesUtil; import com.bentonow.bentonow.Utils.WidgetsUtils; +import com.bentonow.bentonow.Utils.maps.LocationUtils; import com.bentonow.bentonow.controllers.BaseFragmentActivity; import com.bentonow.bentonow.controllers.dialog.ConfirmationDialog; import com.bentonow.bentonow.controllers.dialog.ProgressDialog; @@ -446,48 +446,7 @@ private void getMenusByLocation(String responseString) { DebugUtils.logDebug(TAG, "onContinuePressed AppState " + MenuDao.gateKeeper.getAppState()); - if (MenuDao.gateKeeper.getAppState().contains("map,no_service")) { - CouponRequest mCoupon = new CouponRequest(); - mCoupon.reason = "outside of delivery zone"; - mCoupon.address = getTxtAddress().getText().toString(); - mCoupon.lat = String.valueOf(mLastOrderLocation.latitude); - mCoupon.lng = String.valueOf(mLastOrderLocation.longitude); - - Intent mIntentBummer = new Intent(DeliveryLocationActivity.this, BummerActivity.class); - mIntentBummer.putExtra(CouponRequest.TAG, mCoupon); - startActivity(mIntentBummer); - } else if (MenuDao.gateKeeper.getAppState().contains("build")) { - switch (optOpenScreen) { - case COMPLETE_ORDER: - if (BentoNowUtils.isValidCompleteOrder(DeliveryLocationActivity.this)) - BentoNowUtils.openCompleteOrderActivity(DeliveryLocationActivity.this, MenuDao.getCurrentMenu()); - break; - case BUILD_BENTO: - BentoNowUtils.openBuildBentoActivity(DeliveryLocationActivity.this); - break; - case SUMMARY: - BentoNowUtils.saveOrderLocation(mLastOrderLocation, mOrderAddress); - if (SharedPreferencesUtil.getBooleanPreference(SharedPreferencesUtil.IS_ORDER_AHEAD_MENU)) - BentoNowUtils.openBuildBentoActivity(DeliveryLocationActivity.this); - else - onBackPressed(); - break; - default: - onBackPressed(); - break; - } - finish(); - } else if (MenuDao.gateKeeper.getAppState().contains("closed_wall")) { - BentoNowUtils.openErrorActivity(DeliveryLocationActivity.this); - finish(); - } else if (MenuDao.gateKeeper.getAppState().contains("sold")) { - BentoNowUtils.openErrorActivity(DeliveryLocationActivity.this); - finish(); - } else { - DebugUtils.logError(TAG, "Unknown State: " + MenuDao.gateKeeper.getAppState()); - } - - + nextStepViaAppState(MenuDao.gateKeeper.getAppState()); } public void onContinuePressed() { @@ -522,15 +481,17 @@ public void onSuccess(int statusCode, Header[] headers, String responseString) { switch (optOpenScreen) { case SUMMARY: Order mCurrentOrder = mOrderDao.getCurrentOrder(); - if (SharedPreferencesUtil.getBooleanPreference(SharedPreferencesUtil.IS_ORDER_AHEAD_MENU)) - if (mCurrentOrder != null && responseString.contains("\"menu_id\":\"" + mCurrentOrder.MenuId + "\"")) { + if (mCurrentOrder != null) + if (responseString.contains("\"menu_id\":\"" + mCurrentOrder.MenuId + "\"")) { BentoNowUtils.saveOrderLocation(mLastOrderLocation, mOrderAddress); onBackPressed(); } else { - getMenusByLocation(responseString); + String sAppState = InitParse.getAppState(responseString); + if (sAppState.contains("build")) + showChangeMenuDialog(responseString); + else + nextStepViaAppState(sAppState); } - else - getMenusByLocation(responseString); break; default: getMenusByLocation(responseString); @@ -546,6 +507,46 @@ public void onFinish() { }); } + private void nextStepViaAppState(String sAppState) { + if (sAppState.contains("map,no_service")) { + CouponRequest mCoupon = new CouponRequest(); + mCoupon.reason = "outside of delivery zone"; + mCoupon.address = getTxtAddress().getText().toString(); + mCoupon.lat = String.valueOf(mLastOrderLocation.latitude); + mCoupon.lng = String.valueOf(mLastOrderLocation.longitude); + + Intent mIntentBummer = new Intent(DeliveryLocationActivity.this, BummerActivity.class); + mIntentBummer.putExtra(CouponRequest.TAG, mCoupon); + startActivity(mIntentBummer); + } else if (sAppState.contains("build")) { + switch (optOpenScreen) { + case COMPLETE_ORDER: + if (BentoNowUtils.isValidCompleteOrder(DeliveryLocationActivity.this)) + BentoNowUtils.openCompleteOrderActivity(DeliveryLocationActivity.this, MenuDao.getCurrentMenu()); + break; + case BUILD_BENTO: + BentoNowUtils.openBuildBentoActivity(DeliveryLocationActivity.this); + break; + case SUMMARY: + BentoNowUtils.saveOrderLocation(mLastOrderLocation, mOrderAddress); + BentoNowUtils.openBuildBentoActivity(DeliveryLocationActivity.this); + break; + default: + onBackPressed(); + break; + } + finish(); + } else if (sAppState.contains("closed_wall")) { + BentoNowUtils.openErrorActivity(DeliveryLocationActivity.this); + finish(); + } else if (sAppState.contains("sold")) { + BentoNowUtils.openErrorActivity(DeliveryLocationActivity.this); + finish(); + } else { + DebugUtils.logError(TAG, "Unknown State: " + MenuDao.gateKeeper.getAppState()); + } + } + @TargetApi(Build.VERSION_CODES.JELLY_BEAN_MR1) void setupAutocomplete() { getTxtAddress().setAdapter(new GooglePlacesAutocompleteAdapter(this, R.layout.listitem_locationaddress)); @@ -647,33 +648,6 @@ public void onFinish() { } }); -/* - BentoApplication.instance.webRequest(new RequestGetPlaceDetail(sPlaceId, new ListenerWebRequest() { - @Override - public void onError(String sError, int statusCode) { - checkAddress(sAddress); - onComplete(); - } - - @Override - public void onResponse(final Object oResponse, int statusCode) { - runOnUiThread(new Runnable() { - @Override - - public void run() { - moveMapToCenter((LatLng) oResponse, sAddress); - } - }); - onComplete(); - } - - - @Override - public void onComplete() { - dismissDialog(); - } - }));*/ - } @TargetApi(Build.VERSION_CODES.JELLY_BEAN_MR1) @@ -687,6 +661,21 @@ private void restartSearch() { mLastOrderLocation = null; } + private void showChangeMenuDialog(final String sResponse) { + if (mConfirmationDialog == null || !mConfirmationDialog.isShowing()) { + mConfirmationDialog = new ConfirmationDialog(DeliveryLocationActivity.this, "Change Menu", "If you change delivery zone, you will have to create an order again, do you want to continue?"); + mConfirmationDialog.addAcceptButton(IosCopyDao.get("build-not-complete-confirmation-2"), new View.OnClickListener() { + @Override + public void onClick(View view) { + getMenusByLocation(sResponse); + } + }); + mConfirmationDialog.addCancelButton(IosCopyDao.get("build-not-complete-confirmation-1"), null); + mConfirmationDialog.show(); + } + + } + private void dismissDialog() { runOnUiThread(new Runnable() { @Override diff --git a/app/src/main/java/com/bentonow/bentonow/controllers/order/OrderStatusActivity.java b/app/src/main/java/com/bentonow/bentonow/controllers/order/OrderStatusActivity.java index 111be5b..149c57f 100644 --- a/app/src/main/java/com/bentonow/bentonow/controllers/order/OrderStatusActivity.java +++ b/app/src/main/java/com/bentonow/bentonow/controllers/order/OrderStatusActivity.java @@ -617,6 +617,7 @@ public void onMapReady(GoogleMap map) { map.setBuildingsEnabled(true); map.getUiSettings().setZoomControlsEnabled(false); googleMap = map; + googleMap.getUiSettings().setAllGesturesEnabled(false); addMarker(getOrderMarker(), false); diff --git a/app/src/main/java/com/bentonow/bentonow/parse/InitParse.java b/app/src/main/java/com/bentonow/bentonow/parse/InitParse.java index b5e8378..8945436 100644 --- a/app/src/main/java/com/bentonow/bentonow/parse/InitParse.java +++ b/app/src/main/java/com/bentonow/bentonow/parse/InitParse.java @@ -405,4 +405,26 @@ public static void parseGateKeeper(String sGateKeeper) { DebugUtils.logDebug(TAG, "GateKeeper Saved: " + (MenuDao.gateKeeper != null)); } + + public static String getAppState(String sResponse) { + JSONObject jsonInit; + + try { + jsonInit = new JSONObject(sResponse); + + String sGateKeeper = jsonInit.getString("/gatekeeper/here/{lat}/{long}"); + + if (sGateKeeper == null || sGateKeeper.equals("null") || sGateKeeper.isEmpty()) + return ""; + + JSONObject jsonGateKeeper = new JSONObject(sGateKeeper); + + if (jsonGateKeeper.has("appState")) + return jsonGateKeeper.getString("appState"); + + } catch (Exception e) { + DebugUtils.logError(TAG, "getAppState: " + e.getMessage()); + } + return ""; + } }