From 29adf705d26f6ec268afffe33b55dc35f0f8e40b Mon Sep 17 00:00:00 2001 From: GaidamakUA Date: Wed, 2 Sep 2015 14:38:08 +0300 Subject: [PATCH] Poi creation: poi has to have at least poi type. Dashboard now always shows if critical message appears. --- OsmAnd/res/values/strings.xml | 1 + OsmAnd/src/net/osmand/plus/activities/MapActivity.java | 2 +- OsmAnd/src/net/osmand/plus/dashboard/DashboardOnMap.java | 7 +++++++ OsmAnd/src/net/osmand/plus/osmedit/EditPoiFragment.java | 8 ++++++-- 4 files changed, 15 insertions(+), 3 deletions(-) diff --git a/OsmAnd/res/values/strings.xml b/OsmAnd/res/values/strings.xml index bd60143fcb..41f2b11200 100644 --- a/OsmAnd/res/values/strings.xml +++ b/OsmAnd/res/values/strings.xml @@ -2255,4 +2255,5 @@ Afghanistan, Albania, Algeria, Andorra, Angola, Anguilla, Antigua and Barbuda, A Add opening hours POI Type Number of rows in dash %1$s + Please specify POI type. diff --git a/OsmAnd/src/net/osmand/plus/activities/MapActivity.java b/OsmAnd/src/net/osmand/plus/activities/MapActivity.java index 6c881012e3..ef8228d8d7 100644 --- a/OsmAnd/src/net/osmand/plus/activities/MapActivity.java +++ b/OsmAnd/src/net/osmand/plus/activities/MapActivity.java @@ -389,7 +389,7 @@ public class MapActivity extends AccessibleActivity { if (!dashboardOnMap.isVisible()) { final OsmandSettings.CommonPreference shouldShowDashboardOnStart = settings.registerBooleanPreference(MapActivity.SHOULD_SHOW_DASHBOARD_ON_START, true); - if (shouldShowDashboardOnStart.get()) + if (shouldShowDashboardOnStart.get() || dashboardOnMap.hasCriticalMessages()) dashboardOnMap.setDashboardVisibility(true, DashboardOnMap.staticVisibleType); } } diff --git a/OsmAnd/src/net/osmand/plus/dashboard/DashboardOnMap.java b/OsmAnd/src/net/osmand/plus/dashboard/DashboardOnMap.java index 2593be0526..60326ccafe 100644 --- a/OsmAnd/src/net/osmand/plus/dashboard/DashboardOnMap.java +++ b/OsmAnd/src/net/osmand/plus/dashboard/DashboardOnMap.java @@ -910,6 +910,13 @@ public class DashboardOnMap implements ObservableScrollViewCallbacks { transaction.show(frag).commit(); } + public boolean hasCriticalMessages() { + + final OsmandSettings settings = getMyApplication().getSettings(); + return rateUsShouldShow.shouldShow(settings, mapActivity, DashRateUsFragment.TAG) + || errorShouldShow.shouldShow(settings, mapActivity, DashErrorFragment.TAG); + } + View getParentView() { return dashboardView; } diff --git a/OsmAnd/src/net/osmand/plus/osmedit/EditPoiFragment.java b/OsmAnd/src/net/osmand/plus/osmedit/EditPoiFragment.java index 04bb78ac7e..acec769765 100644 --- a/OsmAnd/src/net/osmand/plus/osmedit/EditPoiFragment.java +++ b/OsmAnd/src/net/osmand/plus/osmedit/EditPoiFragment.java @@ -19,6 +19,7 @@ import android.support.v4.view.ViewPager; import android.support.v7.app.AppCompatActivity; import android.support.v7.widget.Toolbar; import android.text.Editable; +import android.text.TextUtils; import android.text.TextWatcher; import android.view.LayoutInflater; import android.view.View; @@ -196,7 +197,7 @@ public class EditPoiFragment extends Fragment { ((MapActivity) getActivity()).getMyApplication().getIconsCache() .getPaintedContentIcon(R.drawable.ic_action_help, getResources().getColor(R.color.inactive_item_orange))); - ImageButton poiTypeButton = (ImageButton) view.findViewById(R.id.poiTypeButton); + final ImageButton poiTypeButton = (ImageButton) view.findViewById(R.id.poiTypeButton); poiTypeButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { @@ -265,7 +266,10 @@ public class EditPoiFragment extends Fragment { saveButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { - // TODO implement saving + if (TextUtils.isEmpty(poiTypeEditText.getText())) { + poiTypeEditText.setError(getResources().getString(R.string.please_specify_poi_type)); + return; + } OsmPoint.Action action = node.getId() == -1 ? OsmPoint.Action.CREATE : OsmPoint.Action.MODIFY; String description = ""; for (Tag tag : editPoiData.tags) {