diff --git a/OsmAnd/res/layout/dash_osmo_item.xml b/OsmAnd/res/layout/dash_osmo_item.xml index f36715ffb7..d5c1ae7cd3 100644 --- a/OsmAnd/res/layout/dash_osmo_item.xml +++ b/OsmAnd/res/layout/dash_osmo_item.xml @@ -1,41 +1,64 @@ - - - + android:layout_height="@dimen/dashListItemHeight" + android:orientation="horizontal"> - - - - - + + + + + + + + + + + + + + + - + \ No newline at end of file diff --git a/OsmAnd/res/layout/dash_parking_fragment.xml b/OsmAnd/res/layout/dash_parking_fragment.xml index 9c93d7ef84..2458d0a9d7 100644 --- a/OsmAnd/res/layout/dash_parking_fragment.xml +++ b/OsmAnd/res/layout/dash_parking_fragment.xml @@ -23,53 +23,52 @@ android:src="@drawable/ic_parking_postion_arrow"/> - + android:orientation="horizontal"> + + + + + + + + + - + android:textSize="@dimen/dash_parking_small_text_size" + tools:text="@string/parking_place_limited"/> - - - - diff --git a/OsmAnd/res/layout/editing_poi.xml b/OsmAnd/res/layout/editing_poi.xml index ef2936388a..fd8b514c79 100644 --- a/OsmAnd/res/layout/editing_poi.xml +++ b/OsmAnd/res/layout/editing_poi.xml @@ -222,27 +222,7 @@ android:layout_marginLeft="5dp" android:text="@string/poi_dialog_other_tags_message" /> - - - - - \ No newline at end of file diff --git a/OsmAnd/res/layout/editing_poi_filter.xml b/OsmAnd/res/layout/editing_poi_filter.xml index a7bd5b8971..ba07244a61 100644 --- a/OsmAnd/res/layout/editing_poi_filter.xml +++ b/OsmAnd/res/layout/editing_poi_filter.xml @@ -2,7 +2,6 @@ + android:layout_width="fill_parent" + android:layout_height="fill_parent" + android:orientation="vertical"> + - + diff --git a/OsmAnd/res/values-be/strings.xml b/OsmAnd/res/values-be/strings.xml index f8b510c2d3..e3a2f88198 100644 --- a/OsmAnd/res/values-be/strings.xml +++ b/OsmAnd/res/values-be/strings.xml @@ -1,4 +1,4 @@ - + Без аўтаматычнага маштабаваньня Буйней Для сярэдняга маштаба @@ -2051,8 +2051,11 @@ OsmAnd мае адкрыты зыходны код і актыўна разві Пункты маршруту Больш дзеяньняў - Састарэлі - гхвЗасталося Стварыць дзеяньне + Састарэлі + г + хв + Засталося + Стварыць дзеяньне Зьмяніць дзеяньне Выдаліць дзеяньне праўкі OSM diff --git a/OsmAnd/res/values-da/strings.xml b/OsmAnd/res/values-da/strings.xml index 3ab14f1578..3b5937104a 100644 --- a/OsmAnd/res/values-da/strings.xml +++ b/OsmAnd/res/values-da/strings.xml @@ -1969,7 +1969,7 @@ OSM redigeringer tmTilbage Tidsbegrænset parkering Dine redigeringer - Udløbet + Udløbet Start navigation automatisk efter angivne interval Spring ruteplanlægning over Udfør diff --git a/OsmAnd/res/values-es/strings.xml b/OsmAnd/res/values-es/strings.xml index a7e8d1bc8e..6662cb3a8d 100644 --- a/OsmAnd/res/values-es/strings.xml +++ b/OsmAnd/res/values-es/strings.xml @@ -1985,7 +1985,7 @@ Foto Puntos de la ruta Liberado - Obsoleto + Obsoleto Salta la planificación de ruta Ir Comienza la navegación automáticamente después de un intervalo dado diff --git a/OsmAnd/res/values-fr/strings.xml b/OsmAnd/res/values-fr/strings.xml index 24d9fcc871..459894c04a 100644 --- a/OsmAnd/res/values-fr/strings.xml +++ b/OsmAnd/res/values-fr/strings.xml @@ -1991,7 +1991,7 @@ Afghanistan, Albanie, Algérie, Allemagne, Andorre, Angola, Anguilla, Antigua-et Éditions OSM hmRestant Stationnement à durée limitée Vos modifications - Expiré + Expiré Démarrer automatiquement la navigation après le temps indiqué Aller Non utilisé diff --git a/OsmAnd/res/values-it/strings.xml b/OsmAnd/res/values-it/strings.xml index 5f1a7e10bf..3d2b128b35 100644 --- a/OsmAnd/res/values-it/strings.xml +++ b/OsmAnd/res/values-it/strings.xml @@ -2146,7 +2146,7 @@ Si consiglia di aggiungere uno o più punti intermedi per migliorarne le prestaz Modifiche OSM hmMancano Parcheggio a tempo limitato Le tue modifiche - Obsoleto + Obsoleto Avvia automaticamente la novigazione dopo l\'intervallo specificato Salta la pianificazione del percorso Vai diff --git a/OsmAnd/res/values-ja/strings.xml b/OsmAnd/res/values-ja/strings.xml index 6cc5ebddcd..00f2cf6591 100644 --- a/OsmAnd/res/values-ja/strings.xml +++ b/OsmAnd/res/values-ja/strings.xml @@ -2160,7 +2160,7 @@ OsmAndはオープンソースであり、活発に開発が進められいま 音声プロンプト 有効 無効 -期限切れ +期限切れ アクションの作成 アクションの変更 アクションの削除 diff --git a/OsmAnd/res/values-ko/strings.xml b/OsmAnd/res/values-ko/strings.xml index 4656297a7d..2ce6a6edc5 100644 --- a/OsmAnd/res/values-ko/strings.xml +++ b/OsmAnd/res/values-ko/strings.xml @@ -2202,7 +2202,7 @@ OSM 편집 시간남은 시간 주차 장소 시간 제한 편집 - 시간 초과 + 시간 초과 지정된 시간 경과후 자동으로 운행 시작 경로 계획 생략 실행 diff --git a/OsmAnd/res/values-nb/strings.xml b/OsmAnd/res/values-nb/strings.xml index 4db81acc65..7744c1edc2 100644 --- a/OsmAnd/res/values-nb/strings.xml +++ b/OsmAnd/res/values-nb/strings.xml @@ -1,4 +1,4 @@ - + Velg fargeskjema for veier: Veifargeskjema Vis retning til målet @@ -1249,7 +1249,7 @@ Rutepunkter - Utdatert + Utdatert OSM-redigeringer Igjen Dine redigeringer Besøk etter diff --git a/OsmAnd/res/values-pl/strings.xml b/OsmAnd/res/values-pl/strings.xml index f94aef28ea..77e6b24588 100644 --- a/OsmAnd/res/values-pl/strings.xml +++ b/OsmAnd/res/values-pl/strings.xml @@ -2014,7 +2014,7 @@ Afganistan, Afryka Południowa, Albania, Algieria, Andora, Angola, Anguilla, Ant Port proxy Opis Do zainstalowania tej wtyczki potrzebujesz połączenia internetowego. - Przestarzały + Przestarzały Utwórz Zmodyfikuj Usuń diff --git a/OsmAnd/res/values-ru/strings.xml b/OsmAnd/res/values-ru/strings.xml index fd33953fc4..fff8b9f449 100644 --- a/OsmAnd/res/values-ru/strings.xml +++ b/OsmAnd/res/values-ru/strings.xml @@ -1929,7 +1929,7 @@ Посетить после Посетить до Туристическая карта - Просрочено + Просрочено Автоматический запуск навигации после заданного интервала Задержка планирования маршрута Поехали diff --git a/OsmAnd/res/values-sc/strings.xml b/OsmAnd/res/values-sc/strings.xml index b175030b8f..25496b4960 100644 --- a/OsmAnd/res/values-sc/strings.xml +++ b/OsmAnd/res/values-sc/strings.xml @@ -1917,7 +1917,7 @@ Foto Puntos de s\'àndala Essidu - Iscadidu + Iscadidu Incumentza automaticamente su nàvigu a pustis de s\'intervallu dislindadu No impreare Bae diff --git a/OsmAnd/res/values-sv/strings.xml b/OsmAnd/res/values-sv/strings.xml index a44e7d3ad7..8fab9f7518 100644 --- a/OsmAnd/res/values-sv/strings.xml +++ b/OsmAnd/res/values-sv/strings.xml @@ -1833,7 +1833,7 @@ OSM-redigeringar hmkvar Tidsbegränsad parkering Dina redigeringar - Föråldrad + Föråldrad Starta navigering automatiskt efter bestämd tid Hoppa över ruttplanering Kör diff --git a/OsmAnd/res/values-uk/strings.xml b/OsmAnd/res/values-uk/strings.xml index 86fb3182e3..55ff4bf412 100644 --- a/OsmAnd/res/values-uk/strings.xml +++ b/OsmAnd/res/values-uk/strings.xml @@ -1,4 +1,4 @@ - + Зміни в 0.8.1: \n\t* Більш точні маршрути (трохи повільніше) \n\t* Розумний і швидкий перерахунок маршруту @@ -2061,7 +2061,7 @@ OsmAnd має відкриті сирці і активно розвиваєть \n\nФайл з даними містить всі навігаційні символи, у вигляди єдиного файлу з назвою \'World seamarks\'. \n\nЦей стиль може бути скасовано шляхом його деактивації тут або зміною в пункті \'Стиль мапи\' меню \'Налаштування мапи\' на потрібний. -Застарілі +Застарілі Створити дію Змінити дію Вилучити дію diff --git a/OsmAnd/res/values-zh-rTW/strings.xml b/OsmAnd/res/values-zh-rTW/strings.xml index 180424ce17..5f224a2553 100644 --- a/OsmAnd/res/values-zh-rTW/strings.xml +++ b/OsmAnd/res/values-zh-rTW/strings.xml @@ -1947,7 +1947,7 @@ 行動建立 行動修改 行動刪除 - 已過時 + 已過時 指定的時間間隔後自動開始導航 跳過航路規劃 執行 diff --git a/OsmAnd/res/values/colors.xml b/OsmAnd/res/values/colors.xml index 3b45295024..c191e0e3eb 100644 --- a/OsmAnd/res/values/colors.xml +++ b/OsmAnd/res/values/colors.xml @@ -1,6 +1,7 @@ + #f41a34 #2d383d #b36d12 diff --git a/OsmAnd/res/values/sizes.xml b/OsmAnd/res/values/sizes.xml index 3254bf07e1..b062c5bf95 100644 --- a/OsmAnd/res/values/sizes.xml +++ b/OsmAnd/res/values/sizes.xml @@ -92,5 +92,6 @@ 14sp 14sp 24sp - 22sp + 18sp + 14sp \ No newline at end of file diff --git a/OsmAnd/res/values/strings.xml b/OsmAnd/res/values/strings.xml index c29f71bded..48b2874e81 100644 --- a/OsmAnd/res/values/strings.xml +++ b/OsmAnd/res/values/strings.xml @@ -9,22 +9,22 @@ 3. All your modified/created strings are in the top of the file (to make easier find what\'s translated). PLEASE: Have a look at http://code.google.com/p/osmand/wiki/UIConsistency, it may really improve your and our work :-) Thx - Hardy --> + You are going to upload %1$d changes to osm. Are you sure? Do you want to clear the whole history? Automatically start navigation after specified interval Skip route planning Go - Outdated + overdue Action create Action modify Action delete OSM edits - - h + h + min - m + Parking place time limited to Left - Parking place time limited Your Edits Visit after Visit before diff --git a/OsmAnd/src/net/osmand/plus/activities/search/SearchPOIActivity.java b/OsmAnd/src/net/osmand/plus/activities/search/SearchPOIActivity.java index 1e33cf960f..59070bca5b 100644 --- a/OsmAnd/src/net/osmand/plus/activities/search/SearchPOIActivity.java +++ b/OsmAnd/src/net/osmand/plus/activities/search/SearchPOIActivity.java @@ -4,45 +4,6 @@ package net.osmand.plus.activities.search; -import gnu.trove.set.hash.TLongHashSet; - -import java.util.ArrayList; -import java.util.Calendar; -import java.util.Collection; -import java.util.Collections; -import java.util.Iterator; -import java.util.List; -import java.util.Map; -import java.util.Map.Entry; - -import net.osmand.ResultMatcher; -import net.osmand.access.AccessibleToast; -import net.osmand.access.NavigationInfo; -import net.osmand.data.Amenity; -import net.osmand.data.LatLon; -import net.osmand.data.PointDescription; -import net.osmand.osm.PoiCategory; -import net.osmand.osm.PoiType; -import net.osmand.plus.OsmAndConstants; -import net.osmand.plus.OsmAndFormatter; -import net.osmand.plus.OsmAndLocationProvider.OsmAndCompassListener; -import net.osmand.plus.OsmAndLocationProvider.OsmAndLocationListener; -import net.osmand.plus.OsmandApplication; -import net.osmand.plus.OsmandSettings; -import net.osmand.plus.R; -import net.osmand.plus.activities.EditPOIFilterActivity; -import net.osmand.plus.activities.MapActivity; -import net.osmand.plus.activities.OsmandListActivity; -import net.osmand.plus.dialogs.DirectionsDialogs; -import net.osmand.plus.poi.NameFinderPoiFilter; -import net.osmand.plus.poi.PoiLegacyFilter; -import net.osmand.plus.poi.SearchByNameFilter; -import net.osmand.plus.render.RenderingIcons; -import net.osmand.plus.views.DirectionDrawable; -import net.osmand.util.Algorithms; -import net.osmand.util.MapUtils; -import net.osmand.util.OpeningHoursParser; -import net.osmand.util.OpeningHoursParser.OpeningHours; import android.app.AlertDialog; import android.app.AlertDialog.Builder; import android.content.Context; @@ -83,6 +44,46 @@ import android.widget.ImageView; import android.widget.TextView; import android.widget.Toast; +import net.osmand.ResultMatcher; +import net.osmand.access.AccessibleToast; +import net.osmand.access.NavigationInfo; +import net.osmand.data.Amenity; +import net.osmand.data.LatLon; +import net.osmand.data.PointDescription; +import net.osmand.osm.PoiCategory; +import net.osmand.osm.PoiType; +import net.osmand.plus.OsmAndConstants; +import net.osmand.plus.OsmAndFormatter; +import net.osmand.plus.OsmAndLocationProvider.OsmAndCompassListener; +import net.osmand.plus.OsmAndLocationProvider.OsmAndLocationListener; +import net.osmand.plus.OsmandApplication; +import net.osmand.plus.OsmandSettings; +import net.osmand.plus.R; +import net.osmand.plus.activities.EditPOIFilterActivity; +import net.osmand.plus.activities.MapActivity; +import net.osmand.plus.activities.OsmandListActivity; +import net.osmand.plus.dialogs.DirectionsDialogs; +import net.osmand.plus.poi.NameFinderPoiFilter; +import net.osmand.plus.poi.PoiLegacyFilter; +import net.osmand.plus.poi.SearchByNameFilter; +import net.osmand.plus.render.RenderingIcons; +import net.osmand.plus.views.DirectionDrawable; +import net.osmand.util.Algorithms; +import net.osmand.util.MapUtils; +import net.osmand.util.OpeningHoursParser; +import net.osmand.util.OpeningHoursParser.OpeningHours; + +import java.util.ArrayList; +import java.util.Calendar; +import java.util.Collection; +import java.util.Collections; +import java.util.Iterator; +import java.util.List; +import java.util.Map; +import java.util.Map.Entry; + +import gnu.trove.set.hash.TLongHashSet; + /** * Search poi activity @@ -147,7 +148,7 @@ public class SearchPOIActivity extends OsmandListActivity implements OsmAndCompa showFilterItem = menu.add(0, FILTER, 0, R.string.search_poi_filter); MenuItemCompat.setShowAsAction(showFilterItem, MenuItemCompat.SHOW_AS_ACTION_ALWAYS); - showFilterItem = showFilterItem.setIcon(R.drawable.ic_action_filter_dark); + showFilterItem = showFilterItem.setIcon(getMyApplication().getIconsCache().getContentIcon(R.drawable.ic_action_filter_dark)); showFilterItem.setOnMenuItemClickListener(new OnMenuItemClickListener() { @Override public boolean onMenuItemClick(MenuItem item) { diff --git a/OsmAnd/src/net/osmand/plus/activities/search/SearchPoiFilterFragment.java b/OsmAnd/src/net/osmand/plus/activities/search/SearchPoiFilterFragment.java index 8b528802e2..7ffda193a6 100644 --- a/OsmAnd/src/net/osmand/plus/activities/search/SearchPoiFilterFragment.java +++ b/OsmAnd/src/net/osmand/plus/activities/search/SearchPoiFilterFragment.java @@ -3,28 +3,15 @@ */ package net.osmand.plus.activities.search; -import java.util.ArrayList; -import java.util.List; - -import android.support.v4.app.FragmentActivity; -import android.support.v4.app.ListFragment; -import android.support.v7.app.ActionBarActivity; -import android.support.v7.widget.Toolbar; -import android.view.*; -import net.osmand.access.AccessibleToast; -import net.osmand.data.LatLon; -import net.osmand.plus.OsmandApplication; -import net.osmand.plus.R; -import net.osmand.plus.activities.EditPOIFilterActivity; -import net.osmand.plus.activities.search.SearchActivity.SearchActivityChild; -import net.osmand.plus.poi.NameFinderPoiFilter; -import net.osmand.plus.poi.PoiLegacyFilter; -import net.osmand.plus.poi.PoiFiltersHelper; -import net.osmand.plus.poi.SearchByNameFilter; -import net.osmand.plus.render.RenderingIcons; -import net.osmand.plus.resources.ResourceManager; import android.content.Intent; import android.os.Bundle; +import android.support.v4.app.FragmentActivity; +import android.support.v4.app.ListFragment; +import android.view.LayoutInflater; +import android.view.Menu; +import android.view.MenuInflater; +import android.view.View; +import android.view.ViewGroup; import android.widget.AdapterView; import android.widget.ArrayAdapter; import android.widget.ImageView; @@ -32,6 +19,23 @@ import android.widget.ListView; import android.widget.TextView; import android.widget.Toast; +import net.osmand.access.AccessibleToast; +import net.osmand.data.LatLon; +import net.osmand.plus.IconsCache; +import net.osmand.plus.OsmandApplication; +import net.osmand.plus.R; +import net.osmand.plus.activities.EditPOIFilterActivity; +import net.osmand.plus.activities.search.SearchActivity.SearchActivityChild; +import net.osmand.plus.poi.NameFinderPoiFilter; +import net.osmand.plus.poi.PoiFiltersHelper; +import net.osmand.plus.poi.PoiLegacyFilter; +import net.osmand.plus.poi.SearchByNameFilter; +import net.osmand.plus.render.RenderingIcons; +import net.osmand.plus.resources.ResourceManager; + +import java.util.ArrayList; +import java.util.List; + public class SearchPoiFilterFragment extends ListFragment implements SearchActivityChild { @@ -151,8 +155,9 @@ public class SearchPoiFilterFragment extends ListFragment implements SearchActiv OsmandApplication app = getMyApplication(); final PoiLegacyFilter model = getItem(position); label.setText(model.getName()); + IconsCache iconsCache = app.getIconsCache(); if(model.getFilterId().equals(PoiLegacyFilter.CUSTOM_FILTER_ID)) { - icon.setImageDrawable(app.getIconsCache().getContentIcon(R.drawable.ic_action_filter_dark)); + icon.setImageDrawable(iconsCache.getContentIcon(R.drawable.ic_action_filter_dark)); } else if (model.getFilterId().equals(PoiLegacyFilter.BY_NAME_FILTER_ID)) { icon.setImageResource(android.R.drawable.ic_search_category_default); } else { @@ -163,6 +168,7 @@ public class SearchPoiFilterFragment extends ListFragment implements SearchActiv } } ImageView editIcon = (ImageView) row.findViewById(R.id.folder_edit_icon); + editIcon.setImageDrawable(iconsCache.getContentIcon(R.drawable.ic_action_filter_dark)); if (model.isStandardFilter()) { editIcon.setVisibility(View.GONE); } else { diff --git a/OsmAnd/src/net/osmand/plus/dashboard/DashLocationFragment.java b/OsmAnd/src/net/osmand/plus/dashboard/DashLocationFragment.java index 115b203f94..794e78f71b 100644 --- a/OsmAnd/src/net/osmand/plus/dashboard/DashLocationFragment.java +++ b/OsmAnd/src/net/osmand/plus/dashboard/DashLocationFragment.java @@ -1,15 +1,5 @@ package net.osmand.plus.dashboard; -import java.util.ArrayList; -import java.util.List; - -import net.osmand.Location; -import net.osmand.data.LatLon; -import net.osmand.plus.OsmAndFormatter; -import net.osmand.plus.OsmandApplication; -import net.osmand.plus.R; -import net.osmand.plus.views.DirectionDrawable; - import android.annotation.SuppressLint; import android.app.Activity; import android.content.Context; @@ -19,6 +9,16 @@ import android.view.WindowManager; import android.widget.ImageView; import android.widget.TextView; +import net.osmand.Location; +import net.osmand.data.LatLon; +import net.osmand.plus.OsmAndFormatter; +import net.osmand.plus.OsmandApplication; +import net.osmand.plus.R; +import net.osmand.plus.views.DirectionDrawable; + +import java.util.ArrayList; +import java.util.List; + /** * Created by Denis * on 26.01.2015. @@ -134,7 +134,7 @@ public abstract class DashLocationFragment extends DashBaseFragment { if (paint) { dd.setImage(arrowResId, useCenter ? R.color.color_distance : R.color.color_myloc_distance); } else { - dd.setImage(arrowResId); + dd.setImage(arrowResId, useCenter ? R.color.color_distance : R.color.color_white); } if (fromLoc == null || h == null) { dd.setAngle(0); diff --git a/OsmAnd/src/net/osmand/plus/dashboard/DashboardOnMap.java b/OsmAnd/src/net/osmand/plus/dashboard/DashboardOnMap.java index a9b96703f7..9df5f1695c 100644 --- a/OsmAnd/src/net/osmand/plus/dashboard/DashboardOnMap.java +++ b/OsmAnd/src/net/osmand/plus/dashboard/DashboardOnMap.java @@ -19,6 +19,7 @@ import net.osmand.plus.development.OsmandDevelopmentPlugin; import net.osmand.plus.download.DownloadActivity; import net.osmand.plus.helpers.ScreenOrientationHelper; import net.osmand.plus.monitoring.DashTrackFragment; +import net.osmand.plus.osmedit.DashOsmEditsFragment; import net.osmand.plus.osmo.DashOsmoFragment; import net.osmand.plus.parkingpoint.DashParkingFragment; import net.osmand.plus.routing.RoutingHelper; @@ -387,6 +388,7 @@ public class DashboardOnMap { FragmentManager manager = mapActivity.getSupportFragmentManager(); FragmentTransaction fragmentTransaction = manager.beginTransaction(); + showFragment(manager, fragmentTransaction, DashErrorFragment.TAG, DashErrorFragment.class, @@ -398,8 +400,8 @@ public class DashboardOnMap { showFragment(manager, fragmentTransaction, DashFavoritesFragment.TAG, DashFavoritesFragment.class, showCards); showFragment(manager, fragmentTransaction, DashAudioVideoNotesFragment.TAG, DashAudioVideoNotesFragment.class, showCards); showFragment(manager, fragmentTransaction, DashTrackFragment.TAG, DashTrackFragment.class, showCards); - showFragment(manager, fragmentTransaction, DashOsmoFragment.TAG, DashOsmoFragment.class, showCards); - //showFragment(manager, fragmentTransaction, DashOsmEditsFragment.TAG, DashOsmEditsFragment.class, showCards); + //showFragment(manager, fragmentTransaction, DashOsmoFragment.TAG, DashOsmoFragment.class, showCards); + showFragment(manager, fragmentTransaction, DashOsmEditsFragment.TAG, DashOsmEditsFragment.class, showCards); // showFragment(manager, fragmentTransaction, DashUpdatesFragment.TAG, DashUpdatesFragment.class, showCards); showFragment(manager, fragmentTransaction, DashPluginsFragment.TAG, DashPluginsFragment.class, showCards); showFragment(manager, fragmentTransaction, DashSimulateFragment.TAG, DashSimulateFragment.class, diff --git a/OsmAnd/src/net/osmand/plus/osmedit/DashOsmEditsFragment.java b/OsmAnd/src/net/osmand/plus/osmedit/DashOsmEditsFragment.java index b6f3442e39..d92cb1ff0c 100644 --- a/OsmAnd/src/net/osmand/plus/osmedit/DashOsmEditsFragment.java +++ b/OsmAnd/src/net/osmand/plus/osmedit/DashOsmEditsFragment.java @@ -1,18 +1,8 @@ package net.osmand.plus.osmedit; -import net.osmand.data.PointDescription; -import net.osmand.plus.OsmAndAppCustomization; -import net.osmand.plus.OsmandPlugin; -import net.osmand.plus.ProgressImplementation; -import net.osmand.plus.R; -import net.osmand.plus.activities.MapActivity; -import net.osmand.plus.dashboard.DashBaseFragment; -import net.osmand.plus.helpers.FontCache; -import net.osmand.plus.myplaces.FavoritesActivity; - -import android.app.Activity; +import android.app.AlertDialog; import android.app.ProgressDialog; -import android.content.Intent; +import android.content.DialogInterface; import android.graphics.Typeface; import android.os.Bundle; import android.view.LayoutInflater; @@ -23,6 +13,15 @@ import android.widget.ImageButton; import android.widget.LinearLayout; import android.widget.TextView; +import net.osmand.data.PointDescription; +import net.osmand.plus.OsmandPlugin; +import net.osmand.plus.ProgressImplementation; +import net.osmand.plus.R; +import net.osmand.plus.activities.MapActivity; +import net.osmand.plus.dashboard.DashBaseFragment; +import net.osmand.plus.helpers.FontCache; +import net.osmand.plus.myplaces.FavoritesActivity; + import java.util.ArrayList; import java.util.List; @@ -91,22 +90,11 @@ public class DashOsmEditsFragment extends DashBaseFragment implements OsmEditsUp OsmEditsFragment.getOsmEditView(view, point, getMyApplication()); ImageButton send =(ImageButton) view.findViewById(R.id.play); - send.setImageDrawable(getMyApplication().getIconsCache().getContentIcon(R.drawable.ic_action_gup_dark)); + send.setImageDrawable(getMyApplication().getIconsCache().getContentIcon(R.drawable.ic_action_export)); send.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { - OpenstreetmapRemoteUtil remotepoi = new OpenstreetmapRemoteUtil(getActivity()); - OsmPoint[] toUpload = new OsmPoint[]{point}; - OsmBugsRemoteUtil remotebug = new OsmBugsRemoteUtil(getMyApplication()); - ProgressDialog dialog = ProgressImplementation.createProgressDialog( - getActivity(), - getString(R.string.uploading), - getString(R.string.local_openstreetmap_uploading), - ProgressDialog.STYLE_HORIZONTAL).getDialog(); - UploadOpenstreetmapPointAsyncTask uploadTask = new UploadOpenstreetmapPointAsyncTask(dialog,DashOsmEditsFragment.this, remotepoi, - remotebug, toUpload.length); - uploadTask.execute(toUpload); - dialog.show(); + uploadItem(point); } }); view.findViewById(R.id.options).setVisibility(View.GONE); @@ -127,6 +115,34 @@ public class DashOsmEditsFragment extends DashBaseFragment implements OsmEditsUp } } + private void uploadItem(final OsmPoint point){ + AlertDialog.Builder b = new AlertDialog.Builder(getActivity()); + b.setMessage(getString(R.string.local_osm_changes_upload_all_confirm, 1)); + b.setPositiveButton(R.string.shared_string_yes, new DialogInterface.OnClickListener() { + @Override + public void onClick(DialogInterface dialog, int which) { + showProgressDialog(point); + } + }); + b.setNegativeButton(R.string.shared_string_cancel, null); + b.show(); + } + + private void showProgressDialog(OsmPoint point) { + OpenstreetmapRemoteUtil remotepoi = new OpenstreetmapRemoteUtil(getActivity()); + OsmPoint[] toUpload = new OsmPoint[]{point}; + OsmBugsRemoteUtil remotebug = new OsmBugsRemoteUtil(getMyApplication()); + ProgressDialog dialog = ProgressImplementation.createProgressDialog( + getActivity(), + getString(R.string.uploading), + getString(R.string.local_openstreetmap_uploading), + ProgressDialog.STYLE_HORIZONTAL).getDialog(); + UploadOpenstreetmapPointAsyncTask uploadTask = new UploadOpenstreetmapPointAsyncTask(dialog,DashOsmEditsFragment.this, remotepoi, + remotebug, toUpload.length); + uploadTask.execute(toUpload); + dialog.show(); + } + private void getOsmPoints(ArrayList dataPoints) { OpenstreetmapsDbHelper dbpoi = new OpenstreetmapsDbHelper(getActivity()); OsmBugsDbHelper dbbug = new OsmBugsDbHelper(getActivity()); diff --git a/OsmAnd/src/net/osmand/plus/osmedit/EditingPOIActivity.java b/OsmAnd/src/net/osmand/plus/osmedit/EditingPOIActivity.java index 2ea692ac10..02da9f4169 100644 --- a/OsmAnd/src/net/osmand/plus/osmedit/EditingPOIActivity.java +++ b/OsmAnd/src/net/osmand/plus/osmedit/EditingPOIActivity.java @@ -1,35 +1,5 @@ package net.osmand.plus.osmedit; -import java.text.MessageFormat; -import java.util.ArrayList; -import java.util.LinkedHashMap; -import java.util.LinkedHashSet; -import java.util.List; -import java.util.Map; -import java.util.Set; -import java.util.TreeSet; - -import net.osmand.access.AccessibleToast; -import net.osmand.data.Amenity; -import net.osmand.osm.MapPoiTypes; -import net.osmand.osm.MapRenderingTypes; -import net.osmand.osm.PoiCategory; -import net.osmand.osm.PoiType; -import net.osmand.osm.edit.EntityInfo; -import net.osmand.osm.edit.EntityParser; -import net.osmand.osm.edit.Node; -import net.osmand.osm.edit.OSMSettings.OSMTagKey; -import net.osmand.plus.OsmAndFormatter; -import net.osmand.plus.OsmandApplication; -import net.osmand.plus.OsmandSettings; -import net.osmand.plus.R; -import net.osmand.plus.activities.DialogProvider; -import net.osmand.plus.activities.MapActivity; -import net.osmand.plus.activities.OpeningHoursView; -import net.osmand.util.OpeningHoursParser; -import net.osmand.util.OpeningHoursParser.BasicOpeningHourRule; -import net.osmand.util.OpeningHoursParser.OpeningHours; -import net.osmand.util.OpeningHoursParser.OpeningHoursRule; import android.app.Activity; import android.app.AlertDialog; import android.app.AlertDialog.Builder; @@ -60,6 +30,37 @@ import android.widget.TableRow; import android.widget.TextView; import android.widget.Toast; +import net.osmand.access.AccessibleToast; +import net.osmand.data.Amenity; +import net.osmand.osm.MapPoiTypes; +import net.osmand.osm.MapRenderingTypes; +import net.osmand.osm.PoiCategory; +import net.osmand.osm.PoiType; +import net.osmand.osm.edit.EntityInfo; +import net.osmand.osm.edit.EntityParser; +import net.osmand.osm.edit.Node; +import net.osmand.osm.edit.OSMSettings.OSMTagKey; +import net.osmand.plus.OsmAndFormatter; +import net.osmand.plus.OsmandApplication; +import net.osmand.plus.OsmandSettings; +import net.osmand.plus.R; +import net.osmand.plus.activities.DialogProvider; +import net.osmand.plus.activities.MapActivity; +import net.osmand.plus.activities.OpeningHoursView; +import net.osmand.util.OpeningHoursParser; +import net.osmand.util.OpeningHoursParser.BasicOpeningHourRule; +import net.osmand.util.OpeningHoursParser.OpeningHours; +import net.osmand.util.OpeningHoursParser.OpeningHoursRule; + +import java.text.MessageFormat; +import java.util.ArrayList; +import java.util.LinkedHashMap; +import java.util.LinkedHashSet; +import java.util.List; +import java.util.Map; +import java.util.Set; +import java.util.TreeSet; + public class EditingPOIActivity implements DialogProvider { private final Activity activity; @@ -145,7 +146,7 @@ public class EditingPOIActivity implements DialogProvider { Amenity a = EntityParser.parseAmenity(n, type, subType, null, MapRenderingTypes.getDefault()); dialogBundle.putSerializable(KEY_AMENITY, a); dialogBundle.putSerializable(KEY_AMENITY_NODE, n); - activity.showDialog(dialogID); + createPOIDialog(dialogID, dialogBundle).show(); } public void showDeleteDialog(final Amenity a){ @@ -205,10 +206,9 @@ public class EditingPOIActivity implements DialogProvider { return builder.create(); } - private void preparePOIDialog(int dialogId, Dialog dlg, Bundle args, int title) { + private void preparePOIDialog(View dlg, Bundle args) { Amenity a = (Amenity) args.getSerializable(KEY_AMENITY); Node n = (Node) args.getSerializable(KEY_AMENITY_NODE); - dlg.setTitle(title); EditText nameText = ((EditText)dlg.findViewById(R.id.Name)); nameText.setText(a.getName()); EditText openingHours = ((EditText)dlg.findViewById(R.id.OpeningHours)); @@ -224,7 +224,6 @@ public class EditingPOIActivity implements DialogProvider { final TableLayout layout = ((TableLayout)dlg.findViewById(R.id.advancedModeTable)); layout.setVisibility(View.GONE); updateType(a); - attachListeners(dialogId, dlg, a, n); } private void addTagValueRow(final Node n, final TableLayout layout, String tg, String vl) { @@ -327,27 +326,37 @@ public class EditingPOIActivity implements DialogProvider { layout.invalidate(); } - private Dialog createPOIDialog(final int dialogID, Bundle args) { - final Dialog dlg = new Dialog(activity); - dlg.setContentView(R.layout.editing_poi); + private Builder createPOIDialog(final int dialogID, Bundle args) { + final View view = activity.getLayoutInflater().inflate(R.layout.editing_poi, null); + final Builder dlg = new Builder(activity); + dlg.setView(view); + switch (dialogID) { + case DIALOG_CREATE_POI: + dlg.setTitle(R.string.poi_create_title); + break; + case DIALOG_EDIT_POI: + dlg.setTitle(R.string.poi_edit_title); + break; + } + + //dlg.getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_ADJUST_RESIZE);; - dlg.getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_ADJUST_RESIZE);; - - nameText = ((EditText)dlg.findViewById(R.id.Name)); - openingHours = ((EditText)dlg.findViewById(R.id.OpeningHours)); - typeText = ((AutoCompleteTextView)dlg.findViewById(R.id.Type)); - typeButton = ((Button)dlg.findViewById(R.id.TypeButton)); - openHoursButton = ((Button)dlg.findViewById(R.id.OpenHoursButton)); - typeText = ((AutoCompleteTextView)dlg.findViewById(R.id.Type)); + nameText = ((EditText)view.findViewById(R.id.Name)); + openingHours = ((EditText)view.findViewById(R.id.OpeningHours)); + typeText = ((AutoCompleteTextView)view.findViewById(R.id.Type)); + typeButton = ((Button)view.findViewById(R.id.TypeButton)); + openHoursButton = ((Button)view.findViewById(R.id.OpenHoursButton)); + typeText = ((AutoCompleteTextView)view.findViewById(R.id.Type)); typeText.setThreshold(1); - commentText = ((EditText)dlg.findViewById(R.id.Comment)); - phoneText = ((EditText)dlg.findViewById(R.id.Phone)); - hnoText = ((EditText)dlg.findViewById(R.id.HouseNumber)); - streetNameText = ((EditText)dlg.findViewById(R.id.StreetName)); - websiteText = ((EditText)dlg.findViewById(R.id.Website)); - closeChange = ((CheckBox) dlg.findViewById(R.id.CloseChangeset)); - - TextView linkToOsmDoc = (TextView) dlg.findViewById(R.id.LinkToOsmDoc); + commentText = ((EditText)view.findViewById(R.id.Comment)); + phoneText = ((EditText)view.findViewById(R.id.Phone)); + hnoText = ((EditText)view.findViewById(R.id.HouseNumber)); + streetNameText = ((EditText)view.findViewById(R.id.StreetName)); + websiteText = ((EditText)view.findViewById(R.id.Website)); + closeChange = ((CheckBox) view.findViewById(R.id.CloseChangeset)); + + + TextView linkToOsmDoc = (TextView) view.findViewById(R.id.LinkToOsmDoc); linkToOsmDoc.setOnClickListener(new View.OnClickListener() { @Override @@ -357,14 +366,79 @@ public class EditingPOIActivity implements DialogProvider { }); linkToOsmDoc.setMovementMethod(LinkMovementMethod.getInstance()); -// final Amenity a = (Amenity) args.getSerializable(KEY_AMENITY); -// final Node n = (Node) args.getSerializable(KEY_AMENITY_NODE); -// attachListeners(dialogID, dlg, a, n); - + final Amenity a = (Amenity) args.getSerializable(KEY_AMENITY); + final Node n = (Node) args.getSerializable(KEY_AMENITY_NODE); + dlg.setNegativeButton(R.string.shared_string_cancel, null); + dlg.setPositiveButton(R.string.default_buttons_commit, new DialogInterface.OnClickListener() { + @Override + public void onClick(DialogInterface dialog, int which) { + Resources resources = view.getResources(); + final String msg = n.getId() == -1 ? resources.getString(R.string.poi_action_add) : resources + .getString(R.string.poi_action_change); + OsmPoint.Action action = n.getId() == -1 ? OsmPoint.Action.CREATE : OsmPoint.Action.MODIFY; + String subType = typeText.getText().toString(); + if(allTranslatedSubTypes.get(subType.trim()) != null) { + PoiType pt = allTranslatedSubTypes.get(subType); + n.putTag(pt.getOsmTag() , pt.getOsmValue()); + if(pt.getOsmTag2() != null) { + n.putTag(pt.getOsmTag2(), pt.getOsmValue2()); + } + } else { + n.putTag(a.getType().getDefaultTag(), subType); + } + String name = nameText.getText().toString(); + if(name.length() > 0) { + n.putTag(OSMTagKey.NAME.getValue(), name); + } + if (openingHours.getText().toString().length() == 0) { + n.removeTag(OSMTagKey.OPENING_HOURS.getValue()); + } else { + n.putTag(OSMTagKey.OPENING_HOURS.getValue(), openingHours.getText().toString()); + } + String website = websiteText.getText().toString(); + if (website.length() > 0 ){ + n.putTag(OSMTagKey.WEBSITE.getValue(),website); + } else { + n.removeTag(OSMTagKey.WEBSITE.getValue()); + } + String phone = phoneText.getText().toString(); + if (phone.length() > 0 ){ + n.putTag(OSMTagKey.PHONE.getValue(),phone); + } else { + n.removeTag(OSMTagKey.PHONE.getValue()); + } + String str = streetNameText.getText().toString(); + if (str .length() > 0 ){ + n.putTag(OSMTagKey.ADDR_STREET.getValue(),str); + } else { + n.removeTag(OSMTagKey.ADDR_STREET.getValue()); + } + String hno = hnoText.getText().toString(); + if (hno .length() > 0 ){ + n.putTag(OSMTagKey.ADDR_HOUSE_NUMBER.getValue(),hno); + } else { + n.removeTag(OSMTagKey.ADDR_HOUSE_NUMBER.getValue()); + } + commitNode(action, n, openstreetmapUtil.getEntityInfo(), commentText.getText().toString(), closeChange.isSelected(), + new Runnable() { + @Override + public void run() { + AccessibleToast.makeText(activity, MessageFormat.format(activity.getResources().getString(R.string.poi_action_succeded_template), msg), + Toast.LENGTH_LONG).show(); + if (activity instanceof MapActivity) { + ((MapActivity) activity).getMapView().refreshMap(true); + } + activity.removeDialog(dialogID); + } + }); + } + }); + preparePOIDialog(view, args); + attachListeners(view, a, n); return dlg; } - private void attachListeners(final int dialogID, final Dialog dlg, final Amenity a, final Node n) { + private void attachListeners(final View dlg, final Amenity a, final Node n) { // DO NOT show on focus with empty text predefined list of subcategories - problems when rotating typeText.setOnClickListener(new View.OnClickListener() { @Override @@ -451,77 +525,6 @@ public class EditingPOIActivity implements DialogProvider { } }); - ((Button)dlg.findViewById(R.id.Cancel)).setOnClickListener(new View.OnClickListener(){ - @Override - public void onClick(View v) { - //we must do remove, because there are two dialogs EDIT,CREATE using same variables!! - activity.removeDialog(dialogID); - } - }); - ((Button)dlg.findViewById(R.id.Commit)).setOnClickListener(new View.OnClickListener(){ - @Override - public void onClick(View v) { - Resources resources = v.getResources(); - final String msg = n.getId() == -1 ? resources.getString(R.string.poi_action_add) : resources - .getString(R.string.poi_action_change); - OsmPoint.Action action = n.getId() == -1 ? OsmPoint.Action.CREATE : OsmPoint.Action.MODIFY; - String subType = typeText.getText().toString(); - if(allTranslatedSubTypes.get(subType.trim()) != null) { - PoiType pt = allTranslatedSubTypes.get(subType); - n.putTag(pt.getOsmTag() , pt.getOsmValue()); - if(pt.getOsmTag2() != null) { - n.putTag(pt.getOsmTag2(), pt.getOsmValue2()); - } - } else { - n.putTag(a.getType().getDefaultTag(), subType); - } - String name = nameText.getText().toString(); - if(name.length() > 0) { - n.putTag(OSMTagKey.NAME.getValue(), name); - } - if (openingHours.getText().toString().length() == 0) { - n.removeTag(OSMTagKey.OPENING_HOURS.getValue()); - } else { - n.putTag(OSMTagKey.OPENING_HOURS.getValue(), openingHours.getText().toString()); - } - String website = websiteText.getText().toString(); - if (website.length() > 0 ){ - n.putTag(OSMTagKey.WEBSITE.getValue(),website); - } else { - n.removeTag(OSMTagKey.WEBSITE.getValue()); - } - String phone = phoneText.getText().toString(); - if (phone.length() > 0 ){ - n.putTag(OSMTagKey.PHONE.getValue(),phone); - } else { - n.removeTag(OSMTagKey.PHONE.getValue()); - } - String str = streetNameText.getText().toString(); - if (str .length() > 0 ){ - n.putTag(OSMTagKey.ADDR_STREET.getValue(),str); - } else { - n.removeTag(OSMTagKey.ADDR_STREET.getValue()); - } - String hno = hnoText.getText().toString(); - if (hno .length() > 0 ){ - n.putTag(OSMTagKey.ADDR_HOUSE_NUMBER.getValue(),hno); - } else { - n.removeTag(OSMTagKey.ADDR_HOUSE_NUMBER.getValue()); - } - commitNode(action, n, openstreetmapUtil.getEntityInfo(), commentText.getText().toString(), closeChange.isSelected(), - new Runnable() { - @Override - public void run() { - AccessibleToast.makeText(activity, MessageFormat.format(activity.getResources().getString(R.string.poi_action_succeded_template), msg), - Toast.LENGTH_LONG).show(); - if (activity instanceof MapActivity) { - ((MapActivity) activity).getMapView().refreshMap(true); - } - activity.removeDialog(dialogID); - } - }); - } - }); } private void showSubCategory(Amenity a) { @@ -646,9 +649,6 @@ public class EditingPOIActivity implements DialogProvider { public Dialog onCreateDialog(int id) { Bundle args = dialogBundle; switch (id) { - case DIALOG_CREATE_POI: - case DIALOG_EDIT_POI: - return createPOIDialog(id, args); case DIALOG_DELETE_POI: return createDeleteDialog(args); case DIALOG_SUB_CATEGORIES: { @@ -712,12 +712,6 @@ public class EditingPOIActivity implements DialogProvider { public void onPrepareDialog(int id, Dialog dialog) { Bundle args = dialogBundle; switch (id) { - case DIALOG_CREATE_POI: - preparePOIDialog(id, dialog,args,R.string.poi_create_title); - break; - case DIALOG_EDIT_POI: - preparePOIDialog(id, dialog,args,R.string.poi_edit_title); - break; case DIALOG_DELETE_POI: prepareDeleteDialog(dialog,args); break; diff --git a/OsmAnd/src/net/osmand/plus/osmedit/LocalOpenstreetmapActivity.java b/OsmAnd/src/net/osmand/plus/osmedit/LocalOpenstreetmapActivity.java index ed21d8a3d1..656dd6ac09 100644 --- a/OsmAnd/src/net/osmand/plus/osmedit/LocalOpenstreetmapActivity.java +++ b/OsmAnd/src/net/osmand/plus/osmedit/LocalOpenstreetmapActivity.java @@ -1,460 +1,32 @@ package net.osmand.plus.osmedit; -import java.io.File; -import java.io.FileOutputStream; -import java.io.IOException; -import java.text.MessageFormat; -import java.util.ArrayList; -import java.util.Iterator; -import java.util.List; - -import android.support.v4.view.MenuItemCompat; -import android.view.*; -import android.widget.AdapterView; -import net.osmand.access.AccessibleToast; -import net.osmand.osm.edit.EntityInfo; -import net.osmand.osm.edit.Node; -import net.osmand.plus.OsmandApplication; -import net.osmand.plus.OsmandSettings; -import net.osmand.plus.ProgressImplementation; -import net.osmand.plus.R; -import net.osmand.plus.activities.MapActivity; -import net.osmand.plus.activities.OsmandListActivity; -import net.osmand.plus.osmedit.OsmPoint.Action; - -import org.xmlpull.v1.XmlSerializer; - -import android.app.AlertDialog; -import android.app.AlertDialog.Builder; -import android.app.Dialog; -import android.app.ProgressDialog; -import android.content.DialogInterface; -import android.os.AsyncTask; import android.os.Bundle; -import android.util.Xml; -import android.view.ContextMenu.ContextMenuInfo; -import android.widget.ArrayAdapter; -import android.widget.TextView; -import android.widget.Toast; +import android.view.MenuItem; + +import net.osmand.plus.OsmandApplication; +import net.osmand.plus.R; +import net.osmand.plus.activities.ActionBarProgressActivity; -public class LocalOpenstreetmapActivity extends OsmandListActivity { +public class LocalOpenstreetmapActivity extends ActionBarProgressActivity { - /** dialogs **/ - protected static final int DIALOG_PROGRESS_UPLOAD = 0; - protected static final int MENU_GROUP = 0; - private static final int UPLOAD_ID = 1; - private static final int BACKUP_ID = 2; - private static final int DELETE_ID = 3; - - private LocalOpenstreetmapAdapter listAdapter; - - private OpenstreetmapsDbHelper dbpoi; - private OsmBugsDbHelper dbbug; - - private OpenstreetmapRemoteUtil remotepoi; - private OsmBugsRemoteUtil remotebug; - - protected OsmPoint[] toUpload = new OsmPoint[0]; - private ArrayList dataPoints; - - - @Override protected void onCreate(Bundle savedInstanceState) { + ((OsmandApplication) getApplication()).applyTheme(this); super.onCreate(savedInstanceState); setContentView(R.layout.local_openstreetmap); - getSupportActionBar().setTitle(R.string.shared_string_download); - setSupportProgressBarIndeterminateVisibility(false); - listAdapter = new LocalOpenstreetmapAdapter(); - - getListView().setOnCreateContextMenuListener(new View.OnCreateContextMenuListener() { - @Override - public void onCreateContextMenu(ContextMenu menu, View v, ContextMenuInfo menuInfo) { - MenuInflater inflater = getMenuInflater(); - inflater.inflate(R.menu.localosm_child, menu); - } - }); - setListAdapter(listAdapter); - - dbpoi = new OpenstreetmapsDbHelper(this); - dbbug = new OsmBugsDbHelper(this); - - remotepoi = new OpenstreetmapRemoteUtil(this); - remotebug = new OsmBugsRemoteUtil(getMyApplication()); - } - - @Override - public boolean onCreateOptionsMenu(Menu menu) { - createMenuItem(menu, UPLOAD_ID, R.string.local_openstreetmap_uploadall, R.drawable.ic_action_gup_dark, R.drawable.ic_action_gup_dark, - MenuItemCompat.SHOW_AS_ACTION_IF_ROOM | MenuItemCompat.SHOW_AS_ACTION_WITH_TEXT); - createMenuItem(menu, BACKUP_ID, R.string.local_osm_changes_backup, R.drawable.ic_action_gsave_dark, R.drawable.ic_action_gsave_dark, - MenuItemCompat.SHOW_AS_ACTION_IF_ROOM | MenuItemCompat.SHOW_AS_ACTION_WITH_TEXT); - createMenuItem(menu, DELETE_ID, R.string.shared_string_delete_all, R.drawable.ic_action_gdiscard_dark, R.drawable.ic_action_gdiscard_dark, - MenuItemCompat.SHOW_AS_ACTION_IF_ROOM | MenuItemCompat.SHOW_AS_ACTION_WITH_TEXT); - return super.onCreateOptionsMenu(menu); - } - + @Override public boolean onOptionsItemSelected(MenuItem item) { - if (item.getItemId() == UPLOAD_ID) { - toUpload = dataPoints.toArray(new OsmPoint[0]); - showDialog(DIALOG_PROGRESS_UPLOAD); - return true; - } else if (item.getItemId() == BACKUP_ID) { - new BackupOpenstreetmapPointAsyncTask().execute(dataPoints.toArray(new OsmPoint[0])); - return true; - } else if (item.getItemId() == DELETE_ID) { - Builder b = new AlertDialog.Builder(this); - b.setMessage(getString(R.string.local_osm_changes_delete_all_confirm, dataPoints.size())); - b.setPositiveButton(R.string.shared_string_delete, new DialogInterface.OnClickListener() { - @Override - public void onClick(DialogInterface dialog, int which) { - Iterator it = dataPoints.iterator(); - while(it.hasNext()) { - OsmPoint info = it.next(); - if (info.getGroup() == OsmPoint.Group.POI) { - dbpoi.deletePOI((OpenstreetmapPoint) info); - } else if (info.getGroup() == OsmPoint.Group.BUG) { - dbbug.deleteAllBugModifications((OsmNotesPoint) info); - } - it.remove(); - listAdapter.delete(info); - } - listAdapter.notifyDataSetChanged(); - } - }); - b.setNegativeButton(R.string.shared_string_cancel, null); - b.show(); - return true; - } - return super.onOptionsItemSelected(item); - } - @Override - protected void onResume() { - super.onResume(); - - dataPoints = new ArrayList(); - List l1 = dbpoi.getOpenstreetmapPoints(); - List l2 = dbbug.getOsmbugsPoints(); - dataPoints.addAll(l1); - dataPoints.addAll(l2); - listAdapter.clear(); - for (OpenstreetmapPoint p : l1) { - listAdapter.add(p); - } - for (OsmNotesPoint p : l2) { - listAdapter.add(p); - } - listAdapter.notifyDataSetChanged(); - } - - @Override - public boolean onContextItemSelected(MenuItem item) { - int pos = ((android.widget.AdapterView.AdapterContextMenuInfo)item.getMenuInfo()).position; int itemId = item.getItemId(); - if(itemId == R.id.showmod) { - OsmandSettings settings = getMyApplication().getSettings(); - OsmPoint info = listAdapter.getItem(pos); - settings.setMapLocationToShow(info.getLatitude(), info.getLongitude(), settings.getLastKnownMapZoom()); - MapActivity.launchMapActivityMoveToTop(LocalOpenstreetmapActivity.this); - return true; - } else if(itemId == R.id.deletemod) { - OsmPoint info = listAdapter.getItem(pos); - if (info.getGroup() == OsmPoint.Group.POI) { - dbpoi.deletePOI((OpenstreetmapPoint) info); - } else if (info.getGroup() == OsmPoint.Group.BUG) { - dbbug.deleteAllBugModifications((OsmNotesPoint) info); - } - listAdapter.delete(info); - return true; - } else if (itemId == R.id.uploadmods) { - toUpload = new OsmPoint[]{ listAdapter.getItem(pos)}; - showDialog(DIALOG_PROGRESS_UPLOAD); - return true; + switch (itemId) { + case android.R.id.home: + finish(); + return true; + } - - return super.onContextItemSelected(item); - } - - @Override - protected void onDestroy() { - super.onDestroy(); - if (dbpoi != null) { - dbpoi.close(); - } - if (dbbug != null) { - dbbug.close(); - } - } - - @Override - protected Dialog onCreateDialog(int id) { - switch (id) { - case DIALOG_PROGRESS_UPLOAD: - return ProgressImplementation.createProgressDialog( - LocalOpenstreetmapActivity.this, - getString(R.string.uploading), - getString(R.string.local_openstreetmap_uploading), - ProgressDialog.STYLE_HORIZONTAL).getDialog(); - } - return null; - } - - @Override - protected void onPrepareDialog(int id, Dialog dialog, Bundle args) { - switch (id) { - case DIALOG_PROGRESS_UPLOAD: - UploadOpenstreetmapPointAsyncTask uploadTask = new UploadOpenstreetmapPointAsyncTask((ProgressDialog) dialog, remotepoi, - remotebug, toUpload.length); - uploadTask.execute(toUpload); - break; - } - } - - @Override - public void onItemClick(AdapterView parent, View view, int position, long id) { - - } - - public class BackupOpenstreetmapPointAsyncTask extends AsyncTask { - - - private File osmchange; - - public BackupOpenstreetmapPointAsyncTask() { - OsmandApplication app = LocalOpenstreetmapActivity.this.getMyApplication(); - osmchange = app.getAppPath("poi_modification.osc"); - } - - - @Override - protected String doInBackground(OsmPoint... points) { - FileOutputStream out = null; - try { - out = new FileOutputStream(osmchange); - XmlSerializer sz = Xml.newSerializer(); - - sz.setOutput(out, "UTF-8"); - sz.startDocument("UTF-8", true); - sz.startTag("", "osmChange"); - sz.attribute("", "generator", "OsmAnd"); - sz.attribute("", "version", "0.6"); - sz.startTag("", "create"); - writeContent(sz, points, OsmPoint.Action.CREATE); - sz.endTag("", "create"); - sz.startTag("", "modify"); - writeContent(sz, points, OsmPoint.Action.MODIFY); - sz.endTag("", "modify"); - sz.startTag("", "delete"); - writeContent(sz, points, OsmPoint.Action.DELETE); - sz.endTag("", "delete"); - sz.endTag("", "osmChange"); - sz.endDocument(); - } catch (Exception e) { - return e.getMessage(); - } finally { - try { - if(out!= null) out.close(); - } catch (IOException e) { - } - } - - return null; - } - - private void writeContent(XmlSerializer sz, OsmPoint[] points, Action a) throws IllegalArgumentException, IllegalStateException, IOException { - for (OsmPoint point : points) { - if (point.getGroup() == OsmPoint.Group.POI) { - OpenstreetmapPoint p = (OpenstreetmapPoint) point; - if (p.getAction() == a) { - sz.startTag("", "node"); - sz.attribute("", "lat", p.getLatitude() + ""); - sz.attribute("", "lon", p.getLongitude() + ""); - sz.attribute("", "id", p.getId() + ""); - sz.attribute("", "version", "1"); - for (String tag : p.getEntity().getTagKeySet()) { - String val = p.getEntity().getTag(tag); - sz.startTag("", "tag"); - sz.attribute("", "k", tag); - sz.attribute("", "v", val); - sz.endTag("", "tag"); - } - sz.endTag("", "node"); - } - } else if (point.getGroup() == OsmPoint.Group.BUG) { - OsmNotesPoint p = (OsmNotesPoint) point; - if (p.getAction() == a) { - sz.startTag("", "note"); - sz.attribute("", "lat", p.getLatitude() + ""); - sz.attribute("", "lon", p.getLongitude() + ""); - sz.attribute("", "id", p.getId() + ""); - sz.startTag("", "comment"); - sz.attribute("", "text", p.getText() +""); - sz.endTag("", "comment"); - sz.endTag("", "note"); - } - } - } - } - - - @Override - protected void onPreExecute() { - LocalOpenstreetmapActivity.this.setProgressBarIndeterminateVisibility(true); - } - - @Override - protected void onPostExecute(String result) { - LocalOpenstreetmapActivity.this.setProgressBarIndeterminateVisibility(false); - if (result != null) { - AccessibleToast.makeText(LocalOpenstreetmapActivity.this, getString(R.string.local_osm_changes_backup_failed) + " " + result, Toast.LENGTH_LONG).show(); - } else { - AccessibleToast.makeText(LocalOpenstreetmapActivity.this, getString(R.string.local_osm_changes_backup_successful, osmchange.getAbsolutePath()), Toast.LENGTH_LONG).show(); - } - } - } - - public class UploadOpenstreetmapPointAsyncTask extends AsyncTask { - - private ProgressDialog progress; - - private OpenstreetmapRemoteUtil remotepoi; - - private OsmBugsRemoteUtil remotebug; - - private int listSize = 0; - - private boolean interruptUploading = false; - - public UploadOpenstreetmapPointAsyncTask(ProgressDialog progress, OpenstreetmapRemoteUtil remotepoi, OsmBugsRemoteUtil remotebug, - int listSize) { - this.progress = progress; - this.remotepoi = remotepoi; - this.remotebug = remotebug; - this.listSize = listSize; - } - - @Override - protected Integer doInBackground(OsmPoint... points) { - int uploaded = 0; - - for (OsmPoint point : points) { - if (interruptUploading) - break; - - if (point.getGroup() == OsmPoint.Group.POI) { - OpenstreetmapPoint p = (OpenstreetmapPoint) point; - EntityInfo entityInfo = null; - if (OsmPoint.Action.CREATE != p.getAction()) { - entityInfo = remotepoi.loadNode(p.getEntity()); - } - Node n = remotepoi.commitNodeImpl(p.getAction(), p.getEntity(), entityInfo, p.getComment(), false); - if (n != null) { - dbpoi.deletePOI(p); - publishProgress(p); - uploaded++; - } - } else if (point.getGroup() == OsmPoint.Group.BUG) { - OsmNotesPoint p = (OsmNotesPoint) point; - boolean success = false; - if (p.getAction() == OsmPoint.Action.CREATE) { - success = remotebug.createNewBug(p.getLatitude(), p.getLongitude(), p.getText()) == null; - } else if (p.getAction() == OsmPoint.Action.MODIFY) { - success = remotebug.addingComment(p.getId(), p.getText()) == null; - } else if (p.getAction() == OsmPoint.Action.DELETE) { - success = remotebug.closingBug(p.getId(), p.getText()) == null; - } - if (success) { - dbbug.deleteAllBugModifications(p); - uploaded++; - publishProgress(p); - } - - } - } - - return uploaded; - } - - @Override - protected void onPreExecute() { - interruptUploading = false; - - progress.setOnCancelListener(new DialogInterface.OnCancelListener() { - @Override - public void onCancel(DialogInterface dialog) { - UploadOpenstreetmapPointAsyncTask.this.setInterruptUploading(true); - } - }); - progress.setIndeterminate(false); - progress.setMax(listSize); - progress.setProgress(0); - } - - @Override - protected void onPostExecute(Integer result) { - listAdapter.notifyDataSetChanged(); - if (result != null) { - AccessibleToast.makeText(LocalOpenstreetmapActivity.this, - MessageFormat.format(getString(R.string.local_openstreetmap_were_uploaded), result), Toast.LENGTH_LONG) - .show(); - } - removeDialog(DIALOG_PROGRESS_UPLOAD); - } - - public void setInterruptUploading(boolean b) { - interruptUploading = b; - } - - @Override - protected void onProgressUpdate(OsmPoint... points) { - for(OsmPoint p : points) { - listAdapter.delete(p); - progress.incrementProgressBy(1); - } - } - - } - - protected class LocalOpenstreetmapAdapter extends ArrayAdapter { - - public LocalOpenstreetmapAdapter() { - super(LocalOpenstreetmapActivity.this, net.osmand.plus.R.layout.local_openstreetmap_list_item); - } - - public void delete(OsmPoint i) { - dataPoints.remove(i); - remove(i); - listAdapter.notifyDataSetChanged(); - } - - @Override - public View getView(int position, View convertView, ViewGroup parent) { - View v = convertView; - final OsmPoint child = getItem(position); - if (v == null ) { - LayoutInflater inflater = getLayoutInflater(); - v = inflater.inflate(net.osmand.plus.R.layout.local_openstreetmap_list_item, parent, false); - } - TextView viewName = ((TextView) v.findViewById(R.id.local_openstreetmap_name)); - String idPrefix = (child.getGroup() == OsmPoint.Group.POI ? "POI " : "Bug ") + " id: " + child.getId(); - if (child.getGroup() == OsmPoint.Group.POI) - viewName.setText(idPrefix + " (" + ((OpenstreetmapPoint) child).getSubtype() + ") " + ((OpenstreetmapPoint) child).getName()); - else if (child.getGroup() == OsmPoint.Group.BUG) - viewName.setText(idPrefix + " (" + ((OsmNotesPoint) child).getAuthor() + ") " + ((OsmNotesPoint) child).getText()); - if (child.getAction() == OsmPoint.Action.CREATE) { - viewName.setTextColor(getResources().getColor(R.color.color_ok)); - } else if (child.getAction() == OsmPoint.Action.MODIFY) { - viewName.setTextColor(getResources().getColor(R.color.color_update)); - } else if (child.getAction() == OsmPoint.Action.DELETE) { - viewName.setTextColor(getResources().getColor(R.color.color_warning)); - } - - return v; - } - + return false; } } diff --git a/OsmAnd/src/net/osmand/plus/osmedit/OsmBugsLayer.java b/OsmAnd/src/net/osmand/plus/osmedit/OsmBugsLayer.java index 56d9917a0d..1f09f58946 100644 --- a/OsmAnd/src/net/osmand/plus/osmedit/OsmBugsLayer.java +++ b/OsmAnd/src/net/osmand/plus/osmedit/OsmBugsLayer.java @@ -67,7 +67,6 @@ public class OsmBugsLayer extends OsmandMapLayer implements IContextMenuProvider protected static final String KEY_LATITUDE = "latitude"; protected static final String KEY_LONGITUDE = "longitude"; protected static final String KEY_BUG = "bug"; - private static final int DIALOG_OPEN_BUG = 300; private static final int DIALOG_COMMENT_BUG = 301; private static final int DIALOG_CLOSE_BUG = 302; private static Bundle dialogBundle = new Bundle(); @@ -328,7 +327,7 @@ public class OsmBugsLayer extends OsmandMapLayer implements IContextMenuProvider dialogBundle.putString(KEY_MESSAGE, message); OsmandSettings settings = activity.getMyApplication().getSettings(); dialogBundle.putString(KEY_AUTHOR, settings.USER_NAME.get()); - activity.showDialog(DIALOG_OPEN_BUG); + createOpenBugDialog(dialogBundle).show(); } private void prepareOpenBugDialog(Dialog dlg, Bundle args) { @@ -548,8 +547,6 @@ public class OsmBugsLayer extends OsmandMapLayer implements IContextMenuProvider public Dialog onCreateDialog(int id) { Bundle args = dialogBundle; switch (id) { - case DIALOG_OPEN_BUG: - return createOpenBugDialog(args); case DIALOG_COMMENT_BUG: return createCommentBugDialog(args); case DIALOG_CLOSE_BUG: @@ -560,12 +557,8 @@ public class OsmBugsLayer extends OsmandMapLayer implements IContextMenuProvider @Override public void onPrepareDialog(int id, Dialog dialog) { - Bundle args = dialogBundle; switch (id) { - case DIALOG_OPEN_BUG: - prepareOpenBugDialog(dialog, args); - break; - case DIALOG_COMMENT_BUG: + case DIALOG_COMMENT_BUG: ((EditText)dialog.findViewById(R.id.BugMessage)).setText(""); break; } diff --git a/OsmAnd/src/net/osmand/plus/osmedit/OsmEditsFragment.java b/OsmAnd/src/net/osmand/plus/osmedit/OsmEditsFragment.java index 1bf2b4bf61..d00c1f1fc6 100644 --- a/OsmAnd/src/net/osmand/plus/osmedit/OsmEditsFragment.java +++ b/OsmAnd/src/net/osmand/plus/osmedit/OsmEditsFragment.java @@ -3,10 +3,14 @@ package net.osmand.plus.osmedit; import android.app.AlertDialog; import android.app.ProgressDialog; import android.content.DialogInterface; +import android.content.Intent; +import android.net.Uri; import android.os.AsyncTask; import android.os.Bundle; import android.support.v4.app.ListFragment; import android.support.v4.view.MenuItemCompat; +import android.support.v7.app.ActionBarActivity; +import android.support.v7.view.ActionMode; import android.support.v7.widget.PopupMenu; import android.util.Xml; import android.view.LayoutInflater; @@ -18,16 +22,19 @@ import android.view.ViewGroup; import android.widget.AdapterView; import android.widget.AdapterView.OnItemClickListener; import android.widget.ArrayAdapter; +import android.widget.CheckBox; import android.widget.ImageView; import android.widget.TextView; import android.widget.Toast; import net.osmand.access.AccessibleToast; +import net.osmand.data.PointDescription; import net.osmand.plus.OsmandApplication; import net.osmand.plus.OsmandPlugin; import net.osmand.plus.OsmandSettings; import net.osmand.plus.ProgressImplementation; import net.osmand.plus.R; +import net.osmand.plus.activities.ActionBarProgressActivity; import net.osmand.plus.activities.MapActivity; import net.osmand.plus.dialogs.DirectionsDialogs; import net.osmand.plus.helpers.ScreenOrientationHelper; @@ -52,14 +59,19 @@ public class OsmEditsFragment extends ListFragment implements OsmEditsUploadList private ArrayList dataPoints; private OsmEditsAdapter listAdapter; + private boolean selectionMode = false; + private OpenstreetmapsDbHelper dbpoi; private OsmBugsDbHelper dbbug; private OpenstreetmapRemoteUtil remotepoi; private OsmBugsRemoteUtil remotebug; + private ActionMode actionMode; protected OsmPoint[] toUpload = new OsmPoint[0]; + private ArrayList osmEditsSelected = new ArrayList<>(); + ProgressDialog dialog; @Override @@ -83,24 +95,23 @@ public class OsmEditsFragment extends ListFragment implements OsmEditsUploadList menu.clear(); if (ScreenOrientationHelper.isOrientationPortrait(getActivity())) { - menu = ((FavoritesActivity) getActivity()).getClearToolbar(true).getMenu(); + menu = ((ActionBarProgressActivity) getActivity()).getClearToolbar(true).getMenu(); } else { - ((FavoritesActivity) getActivity()).getClearToolbar(false); + ((ActionBarProgressActivity) getActivity()).getClearToolbar(false); } MenuItem item = menu.add(R.string.local_openstreetmap_uploadall). setIcon(R.drawable.ic_action_export); item.setOnMenuItemClickListener(new MenuItem.OnMenuItemClickListener() { @Override public boolean onMenuItemClick(MenuItem item) { - toUpload = dataPoints.toArray(new OsmPoint[0]); - showUploadItemsDialog(); + enterUploadMode(); return true; } }); MenuItemCompat.setShowAsAction(item, MenuItemCompat.SHOW_AS_ACTION_ALWAYS); item = menu.add(R.string.local_osm_changes_backup). - setIcon(R.drawable.ic_action_gsave_dark); + setIcon(R.drawable.ic_action_gshare_dark); MenuItemCompat.setShowAsAction(item, MenuItemCompat.SHOW_AS_ACTION_ALWAYS); item.setOnMenuItemClickListener(new MenuItem.OnMenuItemClickListener() { @Override @@ -115,32 +126,139 @@ public class OsmEditsFragment extends ListFragment implements OsmEditsUploadList item.setOnMenuItemClickListener(new MenuItem.OnMenuItemClickListener() { @Override public boolean onMenuItemClick(MenuItem item) { - AlertDialog.Builder b = new AlertDialog.Builder(getActivity()); - b.setMessage(getString(R.string.local_osm_changes_delete_all_confirm, dataPoints.size())); - b.setPositiveButton(R.string.shared_string_delete, new DialogInterface.OnClickListener() { - @Override - public void onClick(DialogInterface dialog, int which) { - Iterator it = dataPoints.iterator(); - while(it.hasNext()) { - OsmPoint info = it.next(); - if (info.getGroup() == OsmPoint.Group.POI) { - dbpoi.deletePOI((OpenstreetmapPoint) info); - } else if (info.getGroup() == OsmPoint.Group.BUG) { - dbbug.deleteAllBugModifications((OsmNotesPoint) info); - } - it.remove(); - listAdapter.delete(info); - } - listAdapter.notifyDataSetChanged(); - } - }); - b.setNegativeButton(R.string.shared_string_cancel, null); - b.show(); + enterDeleteMode(); return true; } }); } + private void enterUploadMode() { + actionMode = getActionBarActivity().startSupportActionMode(new ActionMode.Callback() { + + @Override + public boolean onCreateActionMode(final ActionMode mode, Menu menu) { + enableSelectionMode(true); + MenuItem item = menu.add(R.string.local_openstreetmap_uploadall). + setIcon(R.drawable.ic_action_export); + item.setOnMenuItemClickListener(new MenuItem.OnMenuItemClickListener() { + @Override + public boolean onMenuItemClick(MenuItem item) { + uploadItems(osmEditsSelected.toArray(new OsmPoint[0])); + mode.finish(); + return true; + } + }); + MenuItemCompat.setShowAsAction(item, MenuItemCompat.SHOW_AS_ACTION_IF_ROOM); + osmEditsSelected.clear(); + listAdapter.notifyDataSetInvalidated(); + updateSelectionMode(mode); + return true; + } + + @Override + public boolean onPrepareActionMode(ActionMode mode, Menu menu) { + return false; + } + + @Override + public boolean onActionItemClicked(ActionMode actionMode, MenuItem menuItem) { + return false; + } + + @Override + public void onDestroyActionMode(ActionMode mode) { + enableSelectionMode(false); + listAdapter.notifyDataSetInvalidated(); + } + + }); + } + + private void enterDeleteMode() { + actionMode = getActionBarActivity().startSupportActionMode(new ActionMode.Callback() { + + @Override + public boolean onCreateActionMode(final ActionMode mode, Menu menu) { + enableSelectionMode(true); + MenuItem item = menu.add(R.string.shared_string_delete_all).setIcon(R.drawable.ic_action_delete_dark); + item.setOnMenuItemClickListener(new MenuItem.OnMenuItemClickListener() { + @Override + public boolean onMenuItemClick(MenuItem item) { + deleteItems(osmEditsSelected); + mode.finish(); + return true; + } + }); + MenuItemCompat.setShowAsAction(item, MenuItemCompat.SHOW_AS_ACTION_IF_ROOM); + osmEditsSelected.clear(); + listAdapter.notifyDataSetInvalidated(); + updateSelectionMode(mode); + return true; + } + + @Override + public boolean onPrepareActionMode(ActionMode mode, Menu menu) { + return false; + } + + @Override + public boolean onActionItemClicked(ActionMode actionMode, MenuItem menuItem) { + return false; + } + + @Override + public void onDestroyActionMode(ActionMode mode) { + enableSelectionMode(false); + listAdapter.notifyDataSetInvalidated(); + } + + }); + } + + private void updateSelectionMode(ActionMode m) { + if(osmEditsSelected.size() > 0) { + m.setTitle(osmEditsSelected.size() + " " + getMyApplication().getString(R.string.shared_string_selected_lowercase)); + } else{ + m.setTitle(""); + } + } + + private void enableSelectionMode(boolean selectionMode) { + this.selectionMode = selectionMode; + ((FavoritesActivity)getActivity()).setToolbarVisibility(!selectionMode); + } + + public ActionBarActivity getActionBarActivity() { + if (getActivity() instanceof ActionBarActivity) { + return (ActionBarActivity) getActivity(); + } + return null; + } + + private void deleteItems(final ArrayList points) { + AlertDialog.Builder b = new AlertDialog.Builder(getActivity()); + b.setMessage(getString(R.string.local_osm_changes_delete_all_confirm, points.size())); + b.setPositiveButton(R.string.shared_string_delete, new DialogInterface.OnClickListener() { + @Override + public void onClick(DialogInterface dialog, int which) { + Iterator it = points.iterator(); + while (it.hasNext()) { + OsmPoint info = it.next(); + if (info.getGroup() == OsmPoint.Group.POI) { + dbpoi.deletePOI((OpenstreetmapPoint) info); + } else if (info.getGroup() == OsmPoint.Group.BUG) { + dbbug.deleteAllBugModifications((OsmNotesPoint) info); + } + it.remove(); + listAdapter.delete(info); + } + listAdapter.notifyDataSetChanged(); + } + }); + b.setNegativeButton(R.string.shared_string_cancel, null); + b.show(); + } + @Override public void onResume() { super.onResume(); @@ -163,10 +281,10 @@ public class OsmEditsFragment extends ListFragment implements OsmEditsUploadList } - public static void getOsmEditView(View v, OsmPoint child, OsmandApplication app){ + public static void getOsmEditView(View v, OsmPoint child, OsmandApplication app) { TextView viewName = ((TextView) v.findViewById(R.id.name)); ImageView icon = (ImageView) v.findViewById(R.id.icon); - String idPrefix = (child.getGroup() == OsmPoint.Group.POI ? "POI " : "Bug ") + " id: " + child.getId(); + String idPrefix = getPrefix(child); if (child.getGroup() == OsmPoint.Group.POI) { viewName.setText(idPrefix + " (" + ((OpenstreetmapPoint) child).getSubtype() + ") " + ((OpenstreetmapPoint) child).getName()); icon.setImageDrawable(app.getIconsCache(). @@ -211,15 +329,55 @@ public class OsmEditsFragment extends ListFragment implements OsmEditsUploadList v.findViewById(R.id.play).setVisibility(View.GONE); + final CheckBox ch = (CheckBox) v.findViewById(R.id.check_local_index); + View options = v.findViewById(R.id.options); + if(selectionMode) { + options.setVisibility(View.GONE); + ch.setVisibility(View.VISIBLE); + ch.setChecked(osmEditsSelected.contains(child)); + v.findViewById(R.id.icon).setVisibility(View.GONE); + ch.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View v) { + onItemSelect(ch, child); + } + }); + } else { + v.findViewById(R.id.icon).setVisibility(View.VISIBLE); + options.setVisibility(View.VISIBLE); + ch.setVisibility(View.GONE); + } + v.findViewById(R.id.options).setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { openPopUpMenu(v, child); } }); + v.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View v) { + if (selectionMode) { + ch.setChecked(!ch.isChecked()); + onItemSelect(ch, child); + } else { + showOnMap(child); + } + + } + }); return v; } + public void onItemSelect(CheckBox ch, OsmPoint child) { + if (ch.isChecked()) { + osmEditsSelected.add(child); + } else { + osmEditsSelected.remove(child); + } + updateSelectionMode(actionMode); + } + } private void openPopUpMenu(View v, final OsmPoint info) { @@ -242,13 +400,11 @@ public class OsmEditsFragment extends ListFragment implements OsmEditsUploadList item.setOnMenuItemClickListener(new MenuItem.OnMenuItemClickListener() { @Override public boolean onMenuItemClick(MenuItem item) { - if (info.getGroup() == OsmPoint.Group.POI) { - dbpoi.deletePOI((OpenstreetmapPoint) info); - } else if (info.getGroup() == OsmPoint.Group.BUG) { - dbbug.deleteAllBugModifications((OsmNotesPoint) info); - } - listAdapter.delete(info); + ArrayList points = new ArrayList(); + points.add(info); + deleteItems(new ArrayList(points)); return true; + } }); item = optionsMenu.getMenu().add(R.string.local_openstreetmap_upload). @@ -256,8 +412,7 @@ public class OsmEditsFragment extends ListFragment implements OsmEditsUploadList item.setOnMenuItemClickListener(new MenuItem.OnMenuItemClickListener() { @Override public boolean onMenuItemClick(MenuItem item) { - toUpload = new OsmPoint[]{info}; - showUploadItemsDialog(); + uploadItems(new OsmPoint[]{info}); return true; } }); @@ -268,7 +423,21 @@ public class OsmEditsFragment extends ListFragment implements OsmEditsUploadList return (OsmandApplication) getActivity().getApplication(); } - private void showUploadItemsDialog(){ + private void uploadItems(final OsmPoint[] items){ + AlertDialog.Builder b = new AlertDialog.Builder(getActivity()); + b.setMessage(getString(R.string.local_osm_changes_upload_all_confirm, items.length)); + b.setPositiveButton(R.string.shared_string_yes, new DialogInterface.OnClickListener() { + @Override + public void onClick(DialogInterface dialog, int which) { + toUpload = items; + showUploadItemsProgressDialog(); + } + }); + b.setNegativeButton(R.string.shared_string_cancel, null); + b.show(); + } + + private void showUploadItemsProgressDialog() { dialog = ProgressImplementation.createProgressDialog( getActivity(), getString(R.string.uploading), @@ -320,7 +489,7 @@ public class OsmEditsFragment extends ListFragment implements OsmEditsUploadList return e.getMessage(); } finally { try { - if(out!= null) out.close(); + if (out != null) out.close(); } catch (IOException e) { e.printStackTrace(); } @@ -356,7 +525,7 @@ public class OsmEditsFragment extends ListFragment implements OsmEditsUploadList sz.attribute("", "lon", p.getLongitude() + ""); sz.attribute("", "id", p.getId() + ""); sz.startTag("", "comment"); - sz.attribute("", "text", p.getText() +""); + sz.attribute("", "text", p.getText() + ""); sz.endTag("", "comment"); sz.endTag("", "note"); } @@ -376,18 +545,23 @@ public class OsmEditsFragment extends ListFragment implements OsmEditsUploadList if (result != null) { AccessibleToast.makeText(getActivity(), getString(R.string.local_osm_changes_backup_failed) + " " + result, Toast.LENGTH_LONG).show(); } else { - AccessibleToast.makeText(getActivity(), getString(R.string.local_osm_changes_backup_successful, osmchange.getAbsolutePath()), Toast.LENGTH_LONG).show(); + final Intent sendIntent = new Intent(); + sendIntent.setAction(Intent.ACTION_SEND); + sendIntent.putExtra(Intent.EXTRA_SUBJECT, getString(R.string.share_fav_subject)); + sendIntent.putExtra(Intent.EXTRA_STREAM, Uri.fromFile(osmchange)); + sendIntent.setType("text/plain"); + startActivity(sendIntent); } } } @Override - public void uploadUpdated(OsmPoint point){ + public void uploadUpdated(OsmPoint point) { listAdapter.delete(point); } @Override - public void uploadEnded(Integer result){ + public void uploadEnded(Integer result) { listAdapter.notifyDataSetChanged(); if (result != null) { AccessibleToast.makeText(getActivity(), @@ -397,4 +571,16 @@ public class OsmEditsFragment extends ListFragment implements OsmEditsUploadList dialog.dismiss(); } + private void showOnMap(OsmPoint osmPoint) { + boolean isOsmPoint = osmPoint instanceof OpenstreetmapPoint; + String type = osmPoint.getGroup() == OsmPoint.Group.POI ? PointDescription.POINT_TYPE_POI : PointDescription.POINT_TYPE_OSM_BUG; + String name = (isOsmPoint ? ((OpenstreetmapPoint) osmPoint).getName() : ((OsmNotesPoint) osmPoint).getText()); + getMyApplication().getSettings().setMapLocationToShow(osmPoint.getLatitude(), osmPoint.getLongitude(), 15, + new PointDescription(type, name), true, osmPoint); //$NON-NLS-1$ + MapActivity.launchMapActivityMoveToTop(getActivity()); + } + + public static String getPrefix(OsmPoint osmPoint) { + return (osmPoint.getGroup() == OsmPoint.Group.POI ? "POI " : "Bug ") + " id: " + osmPoint.getId(); + } } diff --git a/OsmAnd/src/net/osmand/plus/osmo/DashOsmoFragment.java b/OsmAnd/src/net/osmand/plus/osmo/DashOsmoFragment.java index 4251132be0..5223e9bf64 100644 --- a/OsmAnd/src/net/osmand/plus/osmo/DashOsmoFragment.java +++ b/OsmAnd/src/net/osmand/plus/osmo/DashOsmoFragment.java @@ -2,6 +2,7 @@ package net.osmand.plus.osmo; import android.content.Intent; import android.graphics.Typeface; +import android.graphics.drawable.Drawable; import android.os.Bundle; import android.view.LayoutInflater; import android.view.View; @@ -11,14 +12,20 @@ import android.widget.ImageButton; import android.widget.LinearLayout; import android.widget.TextView; +import net.osmand.Location; +import net.osmand.data.PointDescription; import net.osmand.plus.IconsCache; import net.osmand.plus.NavigationService; import net.osmand.plus.OsmandApplication; import net.osmand.plus.OsmandPlugin; import net.osmand.plus.R; +import net.osmand.plus.activities.MapActivity; import net.osmand.plus.dashboard.DashBaseFragment; import net.osmand.plus.helpers.FontCache; +import java.util.ArrayList; +import java.util.List; + /** * Created by Denis * on 20.01.2015. @@ -79,19 +86,19 @@ public class DashOsmoFragment extends DashBaseFragment { @Override public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) { - if(isChecked) { - if (plugin != null && plugin.getTracker() != null){ + if (isChecked) { + if (plugin != null && plugin.getTracker() != null) { plugin.getTracker().enableTracker(); } app.startNavigationService(NavigationService.USED_BY_LIVE); //interval setting not needed here, handled centrally in app.startNavigationService //app.getSettings().SERVICE_OFF_INTERVAL.set(0); } else { - if (plugin != null && plugin.getTracker() != null){ + if (plugin != null && plugin.getTracker() != null) { plugin.getTracker().disableTracker(); } if (app.getNavigationService() != null) { - app.getNavigationService().stopIfNeeded(app,NavigationService.USED_BY_LIVE); + app.getNavigationService().stopIfNeeded(app, NavigationService.USED_BY_LIVE); } } updateStatus(); @@ -109,32 +116,66 @@ public class DashOsmoFragment extends DashBaseFragment { updateStatus(); } - private void updateStatus(){ + private void updateStatus() { View header = getView(); - if(getView() == null) { + if (getView() == null) { return; } CompoundButton trackr = (CompoundButton) header.findViewById(R.id.check_item); - if(plugin != null && plugin.getTracker() != null){ + if (plugin != null && plugin.getTracker() != null) { trackr.setChecked(plugin.getTracker().isEnabledTracker()); } + updateConnectedDevices(header); } - private void synchronizeGroups(boolean clear){ - View mainView = getView(); - - LinearLayout items = (LinearLayout) mainView.findViewById(R.id.items); - items.removeAllViews(); - if (clear) { + private void updateConnectedDevices(View mainView) { + OsMoGroups grps = plugin.getGroups(); + OsMoGroupsStorage.OsMoGroup mainGroup = null; + for (OsMoGroupsStorage.OsMoGroup grp : grps.getGroups()) { + if (grp.getGroupId() == null) { + mainGroup = grp; + break; + } + } + LinearLayout contentList = (LinearLayout) mainView.findViewById(R.id.items); + contentList.removeAllViews(); + if (mainGroup == null) { return; } - } - private void showProgress(boolean show) { - if (getView() != null){ - getView().findViewById(R.id.progress).setVisibility(show ? View.VISIBLE : View.GONE); + List devices = + new ArrayList<>(mainGroup.getVisibleGroupUsers(plugin.getService().getMyGroupTrackerId())); + + while (devices.size() > 3){ + devices.remove(devices.size() - 1); + } + + + Drawable markerIcon = getMyApplication().getIconsCache().getContentIcon(R.drawable.ic_action_marker_dark); + LayoutInflater inflater = getActivity().getLayoutInflater(); + for (final OsMoGroupsStorage.OsMoDevice device : devices) { + View v = inflater.inflate(R.layout.dash_osmo_item, null, false); + ImageButton showOnMap = (ImageButton)v.findViewById(R.id.show_on_map); + showOnMap.setImageDrawable(markerIcon); + final String name = device.getVisibleName(); + showOnMap.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View v) { + Location loc = device.getLastLocation(); + getMyApplication().getSettings().setMapLocationToShow(loc.getLatitude(), + loc.getLongitude(), 15, + new PointDescription(PointDescription.POINT_TYPE_MARKER, name), + false, device); //$NON-NLS-1$ + MapActivity.launchMapActivityMoveToTop(getActivity()); + } + }); + + ((TextView)v.findViewById(R.id.name)).setText(name); + contentList.addView(v); } } + + } diff --git a/OsmAnd/src/net/osmand/plus/parkingpoint/DashParkingFragment.java b/OsmAnd/src/net/osmand/plus/parkingpoint/DashParkingFragment.java index 0a72c1d71f..a835fd4b3f 100644 --- a/OsmAnd/src/net/osmand/plus/parkingpoint/DashParkingFragment.java +++ b/OsmAnd/src/net/osmand/plus/parkingpoint/DashParkingFragment.java @@ -54,7 +54,7 @@ public class DashParkingFragment extends DashLocationFragment { public void onClick(View v) { LatLon point = plugin.getParkingPosition(); getMyApplication().getSettings().setMapLocationToShow(point.getLatitude(), point.getLongitude(), - 15, new PointDescription(PointDescription.POINT_TYPE_FAVORITE, plugin.getParkingDescription(getActivity())), true, + 15, new PointDescription(PointDescription.POINT_TYPE_FAVORITE, plugin.getParkingDescription(getActivity())), false, point); //$NON-NLS-1$ MapActivity.launchMapActivityMoveToTop(getActivity()); } @@ -83,31 +83,33 @@ public class DashParkingFragment extends DashLocationFragment { LatLon loc = getDefaultLocation(); LatLon position = plugin.getParkingPosition(); boolean limited = plugin.getParkingType(); - String parking_name = limited ? - getString(R.string.parking_place_limited) : getString(R.string.parking_place); + String descr; + + TextView timeLeft = (TextView) mainView.findViewById(R.id.time_left); if (limited) { + descr = getString(R.string.parking_place_limited) + " " + plugin.getFormattedTime( plugin.getParkingTime(), getActivity()); long endtime = plugin.getParkingTime(); long currTime = Calendar.getInstance().getTimeInMillis(); long timeDiff = endtime - currTime; - String time = getFormattedTime(timeDiff); - TextView timeLeft = (TextView) mainView.findViewById(R.id.time_left); - TextView leftLabel = (TextView) mainView.findViewById(R.id.left_lbl); + String time = getFormattedTime(timeDiff) + " "; + TextView leftLbl = (TextView) mainView.findViewById(R.id.left_lbl); timeLeft.setText(time); if (timeDiff < 0) { - timeLeft.setTextColor(Color.RED); - leftLabel.setTextColor(Color.RED); - leftLabel.setText(R.string.osmand_parking_outdated); + timeLeft.setText(time); + leftLbl.setTextColor(getResources().getColor(R.color.parking_outdated_color)); + leftLbl.setText(getString(R.string.osmand_parking_overdue)); } else { - timeLeft.setTextColor(Color.WHITE); - leftLabel.setTextColor(Color.WHITE); - leftLabel.setText(R.string.osmand_parking_time_left); + timeLeft.setText(time); + leftLbl.setTextColor(Color.WHITE); + leftLbl.setText(getString(R.string.osmand_parking_time_left)); } - mainView.findViewById(R.id.left_lbl).setVisibility(View.VISIBLE); + timeLeft.setVisibility(View.VISIBLE); } else { - ((TextView) mainView.findViewById(R.id.time_left)).setText(""); - mainView.findViewById(R.id.left_lbl).setVisibility(View.GONE); + descr = getString(R.string.parking_place); + timeLeft.setText(""); + timeLeft.setVisibility(View.GONE); } - ((TextView) mainView.findViewById(R.id.name)).setText(parking_name); + ((TextView) mainView.findViewById(R.id.name)).setText(descr); ImageView direction = (ImageView) mainView.findViewById(R.id.direction_icon); if (loc != null) { DashLocationView dv = new DashLocationView(direction, (TextView) mainView.findViewById(R.id.distance), position);