From 76fba36aa59bf1e4d242c0ae74a5a35bcdb3dfcd Mon Sep 17 00:00:00 2001 From: Viktar Palstsiuk Date: Mon, 7 Sep 2015 21:53:07 +0200 Subject: [PATCH 01/14] Translated using Weblate (Belarusian) Currently translated at 100.0% (1768 of 1768 strings) --- OsmAnd/res/values-be/strings.xml | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/OsmAnd/res/values-be/strings.xml b/OsmAnd/res/values-be/strings.xml index 6438cb7eca..62dced4e42 100644 --- a/OsmAnd/res/values-be/strings.xml +++ b/OsmAnd/res/values-be/strings.xml @@ -2084,4 +2084,8 @@ Месцазнаходжаньні Колькасьць радкоў на галоўным экране %1$s грамадзкі аб\'ект - + выдаліць + Працоўныя дні + Нядаўнія месцы + Упадабанае + From c31bd9eea5ff016f4ec92e1539ae744ced1f7035 Mon Sep 17 00:00:00 2001 From: GaidamakUA Date: Tue, 8 Sep 2015 10:12:14 +0300 Subject: [PATCH 02/14] Notification for OsmandMonitoringPlugin --- .../net/osmand/plus/NavigationService.java | 32 ++++--------- .../monitoring/OsmandMonitoringPlugin.java | 46 ++++++++++++++++++- .../SettingsMonitoringActivity.java | 17 +++---- 3 files changed, 64 insertions(+), 31 deletions(-) diff --git a/OsmAnd/src/net/osmand/plus/NavigationService.java b/OsmAnd/src/net/osmand/plus/NavigationService.java index ad11896d9d..1a2740bd71 100644 --- a/OsmAnd/src/net/osmand/plus/NavigationService.java +++ b/OsmAnd/src/net/osmand/plus/NavigationService.java @@ -38,7 +38,6 @@ public class NavigationService extends Service implements LocationListener { // global id don't conflict with others private final static int NOTIFICATION_SERVICE_ID = 5; public final static String OSMAND_STOP_SERVICE_ACTION = "OSMAND_STOP_SERVICE_ACTION"; //$NON-NLS-1$ - public final static String OSMAND_SAVE_SERVICE_ACTION = "OSMAND_SAVE_SERVICE_ACTION"; public static int USED_BY_NAVIGATION = 1; public static int USED_BY_GPX = 2; public static int USED_BY_LIVE = 4; @@ -176,26 +175,23 @@ public class NavigationService extends Service implements LocationListener { if (settings.SAVE_GLOBAL_TRACK_TO_GPX.get()) { settings.SAVE_GLOBAL_TRACK_TO_GPX.set(false); } - OsMoPlugin plugin = OsmandPlugin.getEnabledPlugin(OsMoPlugin.class); - if (plugin != null) { - if (plugin.getTracker().isEnabledTracker()) { - plugin.getTracker().disableTracker(); + OsMoPlugin osmoPlugin = OsmandPlugin.getEnabledPlugin(OsMoPlugin.class); + if (osmoPlugin != null) { + if (osmoPlugin.getTracker().isEnabledTracker()) { + osmoPlugin.getTracker().disableTracker(); } } + OsmandMonitoringPlugin monitoringPlugin = + OsmandPlugin.getEnabledPlugin(OsmandMonitoringPlugin.class); + if (monitoringPlugin != null) { + monitoringPlugin.stopRecording(); + } NavigationService.this.stopSelf(); } }; registerReceiver(broadcastReceiver, new IntentFilter(OSMAND_STOP_SERVICE_ACTION)); - saveBroadcastReceiver = new BroadcastReceiver() { - @Override - public void onReceive(Context context, Intent intent) { - final OsmandMonitoringPlugin plugin = OsmandPlugin - .getEnabledPlugin(OsmandMonitoringPlugin.class); - plugin.saveCurrentTrack(); - } - }; - registerReceiver(saveBroadcastReceiver, new IntentFilter(OSMAND_SAVE_SERVICE_ACTION)); + //Show currently active wake-up interval int soi = settings.SERVICE_OFF_INTERVAL.get(); @@ -215,14 +211,6 @@ public class NavigationService extends Service implements LocationListener { // notification.flags = Notification.FLAG_NO_CLEAR; // startForeground(NOTIFICATION_SERVICE_ID, notification); - String stop = getResources().getString(R.string.shared_string_control_stop); - Intent stopIntent = new Intent(OSMAND_STOP_SERVICE_ACTION); - PendingIntent stopPendingIntent = PendingIntent.getBroadcast(this, 0, stopIntent, - PendingIntent.FLAG_UPDATE_CURRENT); - String pause = getResources().getString(R.string.shared_string_save); - Intent saveIntent = new Intent(OSMAND_SAVE_SERVICE_ACTION); - PendingIntent savePendingIntent = PendingIntent.getBroadcast(this, 0, saveIntent, - PendingIntent.FLAG_UPDATE_CURRENT); Intent contentIntent = new Intent(this, MapActivity.class); PendingIntent contentPendingIntent = PendingIntent.getActivity(this, 0, contentIntent, PendingIntent.FLAG_UPDATE_CURRENT); diff --git a/OsmAnd/src/net/osmand/plus/monitoring/OsmandMonitoringPlugin.java b/OsmAnd/src/net/osmand/plus/monitoring/OsmandMonitoringPlugin.java index 635fc44b49..1d0fb01550 100644 --- a/OsmAnd/src/net/osmand/plus/monitoring/OsmandMonitoringPlugin.java +++ b/OsmAnd/src/net/osmand/plus/monitoring/OsmandMonitoringPlugin.java @@ -3,9 +3,15 @@ package net.osmand.plus.monitoring; import android.app.Activity; import android.app.AlertDialog; import android.app.AlertDialog.Builder; +import android.app.NotificationManager; +import android.app.PendingIntent; +import android.content.BroadcastReceiver; import android.content.Context; import android.content.DialogInterface; import android.content.DialogInterface.OnClickListener; +import android.content.Intent; +import android.content.IntentFilter; +import android.support.v4.app.NotificationCompat; import android.util.DisplayMetrics; import android.view.View; import android.view.WindowManager; @@ -45,6 +51,8 @@ import gnu.trove.list.array.TIntArrayList; public class OsmandMonitoringPlugin extends OsmandPlugin { private static final String ID = "osmand.monitoring"; + private static final int notificationId = ID.hashCode(); + public final static String OSMAND_SAVE_SERVICE_ACTION = "OSMAND_SAVE_SERVICE_ACTION"; private OsmandSettings settings; private OsmandApplication app; private TextInfoWidget monitoringControl; @@ -329,6 +337,10 @@ public class OsmandMonitoringPlugin extends OsmandPlugin { public void stopRecording(){ settings.SAVE_GLOBAL_TRACK_TO_GPX.set(false); if (app.getNavigationService() != null) { + NotificationManager mNotificationManager = + (NotificationManager) app.getNavigationService() + .getSystemService(Context.NOTIFICATION_SERVICE); + mNotificationManager.cancel(notificationId); app.getNavigationService().stopIfNeeded(app, NavigationService.USED_BY_GPX); } } @@ -367,7 +379,39 @@ public class OsmandMonitoringPlugin extends OsmandPlugin { } }); } - + + String stop = map.getResources().getString(R.string.shared_string_control_stop); + Intent stopIntent = new Intent(NavigationService.OSMAND_STOP_SERVICE_ACTION); + PendingIntent stopPendingIntent = PendingIntent.getBroadcast(map, 0, stopIntent, + PendingIntent.FLAG_UPDATE_CURRENT); + String save = map.getResources().getString(R.string.shared_string_save); + Intent saveIntent = new Intent(OSMAND_SAVE_SERVICE_ACTION); + PendingIntent savePendingIntent = PendingIntent.getBroadcast(map, 0, saveIntent, + PendingIntent.FLAG_UPDATE_CURRENT); + + BroadcastReceiver saveBroadcastReceiver = new BroadcastReceiver() { + @Override + public void onReceive(Context context, Intent intent) { + final OsmandMonitoringPlugin plugin = OsmandPlugin + .getEnabledPlugin(OsmandMonitoringPlugin.class); + if (plugin != null) { + plugin.saveCurrentTrack(); + } + } + }; + map.registerReceiver(saveBroadcastReceiver, new IntentFilter(OSMAND_SAVE_SERVICE_ACTION)); + + final NotificationCompat.Builder notificationBuilder = + new android.support.v7.app.NotificationCompat.Builder(map) + .setContentTitle(map.getResources().getString(R.string.map_widget_monitoring)) + .setSmallIcon(R.drawable.ic_action_polygom_dark) +// .setLargeIcon(Helpers.getBitmap(R.drawable.mirakel, getBaseContext())) + .setOngoing(true) + .addAction(R.drawable.ic_action_rec_stop, stop, stopPendingIntent) + .addAction(R.drawable.ic_action_save, save, savePendingIntent); + NotificationManager mNotificationManager = + (NotificationManager) map.getSystemService(Context.NOTIFICATION_SERVICE); + mNotificationManager.notify(notificationId, notificationBuilder.build()); } public static void showIntervalChooseDialog(final Context uiCtx, final String patternMsg, diff --git a/OsmAnd/src/net/osmand/plus/monitoring/SettingsMonitoringActivity.java b/OsmAnd/src/net/osmand/plus/monitoring/SettingsMonitoringActivity.java index e81fd6651a..ac92f53f1a 100644 --- a/OsmAnd/src/net/osmand/plus/monitoring/SettingsMonitoringActivity.java +++ b/OsmAnd/src/net/osmand/plus/monitoring/SettingsMonitoringActivity.java @@ -1,14 +1,6 @@ package net.osmand.plus.monitoring; -import android.view.Window; -import net.osmand.plus.NavigationService; -import net.osmand.plus.OsmAndTaskManager.OsmAndTaskRunnable; -import net.osmand.plus.OsmandApplication; -import net.osmand.plus.OsmandSettings; -import net.osmand.plus.R; -import net.osmand.plus.activities.SavingTrackHelper; -import net.osmand.plus.activities.SettingsBaseActivity; import android.content.BroadcastReceiver; import android.content.ComponentName; import android.content.Context; @@ -21,6 +13,15 @@ import android.preference.Preference.OnPreferenceChangeListener; import android.preference.Preference.OnPreferenceClickListener; import android.preference.PreferenceCategory; import android.preference.PreferenceScreen; +import android.view.Window; + +import net.osmand.plus.NavigationService; +import net.osmand.plus.OsmAndTaskManager.OsmAndTaskRunnable; +import net.osmand.plus.OsmandApplication; +import net.osmand.plus.OsmandSettings; +import net.osmand.plus.R; +import net.osmand.plus.activities.SavingTrackHelper; +import net.osmand.plus.activities.SettingsBaseActivity; public class SettingsMonitoringActivity extends SettingsBaseActivity { From b1abe62db5f5b27f7280ea34a5e8210689299380 Mon Sep 17 00:00:00 2001 From: Ldm Public Date: Mon, 7 Sep 2015 22:17:06 +0200 Subject: [PATCH 03/14] Translated using Weblate (French) Currently translated at 99.6% (1762 of 1768 strings) --- OsmAnd/res/values-fr/strings.xml | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/OsmAnd/res/values-fr/strings.xml b/OsmAnd/res/values-fr/strings.xml index 136a916725..5f8a8e0e5e 100644 --- a/OsmAnd/res/values-fr/strings.xml +++ b/OsmAnd/res/values-fr/strings.xml @@ -2139,4 +2139,10 @@ Afghanistan, Albanie, Algérie, Allemagne, Andorre, Angola, Anguilla, Antigua-et Ajouter des heures d\'ouverture Type de PI Positions - + Supprimer + Contact + Merci d\'indiquer un type de PI. + Jours travaillés + Emplacements récents + Favoris + From 4b0ed9e23292a52deb26e97b2a147f08abc411cb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Xos=C3=A9=20Calvo?= Date: Mon, 7 Sep 2015 21:29:10 +0200 Subject: [PATCH 04/14] Translated using Weblate (Galician) Currently translated at 98.1% (1735 of 1768 strings) --- OsmAnd/res/values-gl/strings.xml | 38 ++++++++++++++++++++++++++++---- 1 file changed, 34 insertions(+), 4 deletions(-) diff --git a/OsmAnd/res/values-gl/strings.xml b/OsmAnd/res/values-gl/strings.xml index c76b303f30..224b07f96e 100644 --- a/OsmAnd/res/values-gl/strings.xml +++ b/OsmAnd/res/values-gl/strings.xml @@ -442,7 +442,7 @@ Indicacións desde "Mapa: " Lat %1$.3f, lon %2$.3f - Posición actaul + Posición actual Para: Pasando por: Desde: @@ -606,7 +606,7 @@ Comezar Notas de son/vídeo Engadido de OsmAnd para curvas de nivel sen conexión - Este engadido fornece curvas de nivel que poden ser mostradas nos mapas sen conexión de OsmAnd. Os datos globais (entre os 70 graos norte e os 70 graos sul) están baseados nas medicións de SRTM (Misión Topográfica con Radar da Lanzadeira Espacial) e ASTER (Radiómetro Espacial Avanzado de Emisión Térmica e Reflexión) e instrumentos de imaxes a bordo do Terra, o satélite máis importante do Sistema de Observación Terrestre da NASA. ASTER é un esforzo cooperativo entre a NASA, o Ministerio de Economía do Xapón, Comercio e Industria (METI) e Sistemas Espaciais Xaponeses (J-spaceystems). + "Este engadido fornece unha capa de sobreposición de curvas de nivel e unha capa de sombras de altitude (relevo) que poden ser mostradas nos mapas sen conexión de OsmAnd. Esta funcionalidade pode ser moi apreciada por atletas, camiñantes, sendeiristas e calqueira que teña interese pola estrutura de relevo da paisaxe.\n\nOs datos globais (entre os 70 graos norte e os 70 graos sul) están baseados nas medicións de SRTM (Misión Topográfica con Radar da Lanzadeira Espacial) e ASTER (Radiómetro Espacial Avanzado de Emisión Térmica e Reflexión) e instrumentos de imaxes a bordo do Terra, o satélite máis importante do Sistema de Observación Terrestre da NASA. ASTER é un esforzo cooperativo entre a NASA, o Ministerio de Economía do Xapón, Comercio e Industria (METI) e Sistemas Espaciais Xaponeses (J-spaceystems). " Medición de distancias A situación que asociar coa nota aínda non foi definida. Con «Empregar a situación...» pódeselle asignar unha nota á situación indicada @@ -615,7 +615,7 @@ Notas de son/vídeo partes Curvas de nivel - Facilita a descarga de curvas de nivel e sombreados sen conexión («Configuración» → «Xestionar os ficheiros de mapas» → «Descargar» → Seleccione o tipo de mapa que desexe). + "Este engadido fornece unha capa de sobreposición de curvas de nivel e unha capa de sombras de altitude (relevo) que poden ser mostradas nos mapas sen conexión de OsmAnd. Esta funcionalidade pode ser moi apreciada por atletas, camiñantes, sendeiristas e calqueira que teña interese pola estrutura de relevo da paisaxe.\n\nOs datos globais (entre os 70 graos norte e os 70 graos sul) están baseados nas medicións de SRTM (Misión Topográfica con Radar da Lanzadeira Espacial) e ASTER (Radiómetro Espacial Avanzado de Emisión Térmica e Reflexión) e instrumentos de imaxes a bordo do Terra, o satélite máis importante do Sistema de Observación Terrestre da NASA. ASTER é un esforzo cooperativo entre a NASA, o Ministerio de Economía do Xapón, Comercio e Industria (METI) e Sistemas Espaciais Xaponeses (J-spaceystems). " Curvas de nivel Outros mapas Só as estradas @@ -1015,7 +1015,7 @@ \n\t- Other small features " Esta versión gratuíta do OsmAnd está limitada a %1$s descargas e non admite artigos da Wikipedia sen conexión. Versión libre - Mostrar a descrición dos puntos de interese (PDI) + Mostrar a descrición do punto de interese (PDI) Norteamérica Norteamérica - Estados Unidos América Central @@ -1968,4 +1968,34 @@ Acción {0} Contraer Enderezo + Pechar a sesión + Non foi posíbel cambiar o nome + días de atraso + Coidado de pistas + Para poder mostrar mapas náuticos hai que descargar o mapa especial sen conexión + Editar o grupo + Lugar de aparcamento + Descargar versións nocturnas + Construcións (versións) + Indicacións con voz + eliminar + Recálculo automático da ruta + Non foi posíbel enviar + Abre ás + Pecha ás + Engadir as horas de apertura + Días laborábeis + Lugares recentes + Favoritos +Lugares + Bordo groso + Navaho + Detén o rexistro de GPX cando se mata o aplicativo (mediante apps recentes). A indicación do modo de durmir de OsmAnd desaparece da barra de notificacións de Android). + Información de A-GPS + Datos de A-GPS descargados por última vez: %1$s + Indicar o tempo de agarda durante o que ficar na pantalla de planificación de rutas + Iniciar a navegación paso a paso despois de… + Tempo de aparcamento limitado a + Vista de mapa náutico + Rexistro de pistas baixo petición From ac87d4ecc563765368ce126532cf6844c7067e92 Mon Sep 17 00:00:00 2001 From: Evgenii Martynenko Date: Mon, 7 Sep 2015 19:44:53 +0200 Subject: [PATCH 05/14] Translated using Weblate (Russian) Currently translated at 99.3% (1757 of 1768 strings) --- OsmAnd/res/values-ru/strings.xml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/OsmAnd/res/values-ru/strings.xml b/OsmAnd/res/values-ru/strings.xml index 3c3c97e3f9..a4483eff7e 100644 --- a/OsmAnd/res/values-ru/strings.xml +++ b/OsmAnd/res/values-ru/strings.xml @@ -2088,4 +2088,6 @@ Количество строк на странице %1$s Пожалуйста, укажите тип POI. Жирный контур - + Рабочие дни + Избранное + From 585ee1373128769bd9319494444f9a0a412f304f Mon Sep 17 00:00:00 2001 From: josep constanti Date: Mon, 7 Sep 2015 22:54:46 +0200 Subject: [PATCH 06/14] Translated using Weblate (Catalan) Currently translated at 98.3% (1073 of 1091 strings) --- OsmAnd/res/values-ca/phrases.xml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/OsmAnd/res/values-ca/phrases.xml b/OsmAnd/res/values-ca/phrases.xml index 49c0a90a6c..6b5c7650c6 100644 --- a/OsmAnd/res/values-ca/phrases.xml +++ b/OsmAnd/res/values-ca/phrases.xml @@ -1141,4 +1141,7 @@ Residus radioactius Camp per rehabilitar + Data d\'inici + Cadira de rodes + From aba2ebdfccb9ab2de17ca8dd593a6948f88ac0f5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Xos=C3=A9=20Calvo?= Date: Mon, 7 Sep 2015 21:22:02 +0200 Subject: [PATCH 07/14] Translated using Weblate (Galician) Currently translated at 67.8% (740 of 1091 strings) --- OsmAnd/res/values-gl/phrases.xml | 179 ++++++++++++++++++++++++++++++- 1 file changed, 178 insertions(+), 1 deletion(-) diff --git a/OsmAnd/res/values-gl/phrases.xml b/OsmAnd/res/values-gl/phrases.xml index b486be6aec..4cd1c36427 100644 --- a/OsmAnd/res/values-gl/phrases.xml +++ b/OsmAnd/res/values-gl/phrases.xml @@ -451,7 +451,7 @@ Parada de tranvía Estación de autobuses Estación ferroviaria - + Terminal de ferris Atalaia Campanario Centro @@ -600,4 +600,181 @@ Ortodoxa copta Wesleyana Maronita + Acceso á Internet: público + Acceso á Internet: con fíos + Acceso á Internet: servizo + + Acceso á Internet: terminal + Acceso á Internet: rede local sen fíos + Mahayana + + Miradoiro + Localidade + Área de descanso + + Deporte de motor + Marco + Atracción turística xeral + Atracción de feira + Aloxamento + Pensión + Zoroastriana + + Unida + Iglesia ni cristo + Santos dos Últimos Días + Igrexa Unida de Cristo + Tumba + Pista + Pista de esquí + Pista de esquí nórdico + Alugueiro de esquís + + Galería de arte + Club de striptease + Estación de esquí + Parque para cans + Porto + Banco + Motores agrícolas + Apicultor + Óptico + Ducha + Zona de fumadores + Pelouro notábel + Val + Auga + Bosque + Árbore + Baliza + Dique + Amarre + Zona militar + Lugar de explosión nuclear + + Wikipedia + Wiki en inglés + Wiki en árabe + Wiki en bielorruso + Wiki en búlgaro + Wiki en catalán + Wiki en cebuano + Wiki en checo + Wiki en dinamarqués + Wiki en alemán + Wiki en grego + Wiki en estoniano + Wiki en español + Wiki en finlandés + Wiki en francés + Wiki en galego + Wiki en hebreo + Wiki en hindi + Wiki en croata + Wiki en haitiano + Wiki en húngaro + Wiki en indonesio + Wiki en italiano + Wiki en xaponés + Wiki en coreano + Wiki en lituano + Wiki en letón + Wiki en malaio + Wiki en newar + Wiki en holandés + Wiki en noruegués nynorsk + Wiki en noruegués + Wiki en polaco + Wiki en portugués + Wiki en romanés + Wiki en ruso + Wiki en eslovaco + Wiki en esloveno + Wiki en serbio + Wiki en sueco + Wiki en suahili + Wiki en telugu + Wiki en tailandés + Wiki en turco + Wiki en ucraíno + Wiki en vietnamita + Wiki en volapük + Wiki en chinés + + Entrada + Entrada principal + Entrada + Saída + + Horario de apertura + Descrición + Teléfono + Sitio web + Correo electrónico + Fax + Facebook + Twitter + Skype + Youtube + Instagram + Vkontakte + Google+ + Móbil + Altura máxima + Peso máximo + Abandonado + Obxecto abandonado + En desuso + + Marca + Auga potábel + Auga non potábel + Vixiado + Non vixiado + Temporal + Non temporal + Estación seca + Estación húmida + Primavera + Verán + Outono + Inverno + Con sinais de tráfico + Sen control + Sen marcas + Data de inicio + Cadeira de rodas + + Acceso privado + Sen acceso + Acceso permisivo + Acceso para clientes + Acceso para entregas + Acceso agrícola + + Auga (contido) + Combustíbel (contido) + Viño (contido) + Biomasa (contido) + Colleita (contido) + Forraxe (contido) + Cervexa (contido) + Sal (contido) + Tenda de materiais de mergullo con botella + Taller de automoción + Lámpadas de baixo consumo + Club étnico + Club da natureza + Club de tiro + Club turista + Horario de recollida + Edificio + +Gran (contido) + + Canceira + Refuxio para gatos + Refuxio para cans e gatos + Refuxio para aves + From 7bc3a4e75e660b60d035cba515e980beb9173c70 Mon Sep 17 00:00:00 2001 From: GaidamakUA Date: Tue, 8 Sep 2015 11:38:10 +0300 Subject: [PATCH 08/14] Side sliders no longer owerlap with checkboxes #1657 --- .../plus/activities/MapActivityLayers.java | 25 ++++----- .../osmand/plus/dialogs/ConfigureMapMenu.java | 36 ++++++------ .../net/osmand/plus/helpers/GpxUiHelper.java | 56 +++++++++---------- .../plus/helpers/WaypointDialogHelper.java | 35 ++++++------ 4 files changed, 76 insertions(+), 76 deletions(-) diff --git a/OsmAnd/src/net/osmand/plus/activities/MapActivityLayers.java b/OsmAnd/src/net/osmand/plus/activities/MapActivityLayers.java index 160a3eb181..5115e14803 100644 --- a/OsmAnd/src/net/osmand/plus/activities/MapActivityLayers.java +++ b/OsmAnd/src/net/osmand/plus/activities/MapActivityLayers.java @@ -1,10 +1,11 @@ package net.osmand.plus.activities; -import java.util.ArrayList; -import java.util.LinkedHashMap; -import java.util.List; -import java.util.Map.Entry; +import android.content.DialogInterface; +import android.content.Intent; +import android.support.v7.app.AlertDialog; +import android.widget.ListAdapter; +import android.widget.Toast; import net.osmand.CallbackWithObject; import net.osmand.ResultMatcher; @@ -12,7 +13,6 @@ import net.osmand.StateChangedListener; import net.osmand.access.AccessibleToast; import net.osmand.map.ITileSource; import net.osmand.map.TileSourceManager.TileSourceTemplate; -import net.osmand.osm.PoiCategory; import net.osmand.plus.ContextMenuAdapter; import net.osmand.plus.ContextMenuAdapter.Item; import net.osmand.plus.GPXUtilities.GPXFile; @@ -47,12 +47,11 @@ import net.osmand.plus.views.RouteLayer; import net.osmand.plus.views.TransportInfoLayer; import net.osmand.plus.views.TransportStopsLayer; import net.osmand.plus.views.mapwidgets.MapWidgetRegistry; -import android.app.AlertDialog; -import android.app.AlertDialog.Builder; -import android.content.DialogInterface; -import android.content.Intent; -import android.widget.ListAdapter; -import android.widget.Toast; + +import java.util.ArrayList; +import java.util.LinkedHashMap; +import java.util.List; +import java.util.Map.Entry; /** * Object is responsible to maintain layers using by map activity @@ -259,7 +258,7 @@ public class MapActivityLayers { addFilterToList(adapter, list, f); } - Builder builder = new AlertDialog.Builder(activity); + AlertDialog.Builder builder = new AlertDialog.Builder(activity); ListAdapter listAdapter = adapter.createListAdapter(activity, app.getSettings().isLightContent()); builder.setAdapter(listAdapter, new DialogInterface.OnClickListener(){ @Override @@ -321,7 +320,7 @@ public class MapActivityLayers { final List> entriesMapList = new ArrayList>(entriesMap.entrySet()); - Builder builder = new AlertDialog.Builder(activity); + AlertDialog.Builder builder = new AlertDialog.Builder(activity); String selectedTileSourceKey = settings.MAP_TILE_SOURCES.get(); diff --git a/OsmAnd/src/net/osmand/plus/dialogs/ConfigureMapMenu.java b/OsmAnd/src/net/osmand/plus/dialogs/ConfigureMapMenu.java index f1598b2292..b4a5ede423 100644 --- a/OsmAnd/src/net/osmand/plus/dialogs/ConfigureMapMenu.java +++ b/OsmAnd/src/net/osmand/plus/dialogs/ConfigureMapMenu.java @@ -1,12 +1,16 @@ package net.osmand.plus.dialogs; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.Collection; -import java.util.Iterator; -import java.util.List; +import android.content.Context; +import android.content.DialogInterface; +import android.content.DialogInterface.OnMultiChoiceClickListener; +import android.content.Intent; +import android.support.v7.app.AlertDialog; +import android.view.View; +import android.widget.ArrayAdapter; +import android.widget.Toast; import net.osmand.access.AccessibleToast; +import net.osmand.core.android.MapRendererContext; import net.osmand.plus.ContextMenuAdapter; import net.osmand.plus.ContextMenuAdapter.OnContextMenuClick; import net.osmand.plus.ContextMenuAdapter.OnRowItemClick; @@ -20,7 +24,6 @@ import net.osmand.plus.activities.MapActivity; import net.osmand.plus.activities.PluginActivity; import net.osmand.plus.activities.SettingsActivity; import net.osmand.plus.activities.TransportRouteHelper; -import net.osmand.plus.dashboard.DashboardOnMap.DashboardType; import net.osmand.plus.poi.PoiUIFilter; import net.osmand.plus.rastermaps.OsmandRasterMapsPlugin; import net.osmand.plus.render.RendererRegistry; @@ -28,21 +31,18 @@ import net.osmand.plus.views.GPXLayer; import net.osmand.plus.views.OsmandMapTileView; import net.osmand.plus.views.RouteLayer; import net.osmand.plus.views.corenative.NativeCoreContext; -import gnu.trove.list.array.TIntArrayList; -import net.osmand.core.android.MapRendererContext; import net.osmand.render.RenderingRuleProperty; import net.osmand.render.RenderingRuleStorageProperties; import net.osmand.render.RenderingRulesStorage; import net.osmand.util.Algorithms; -import android.app.AlertDialog; -import android.app.AlertDialog.Builder; -import android.content.Context; -import android.content.DialogInterface; -import android.content.Intent; -import android.content.DialogInterface.OnMultiChoiceClickListener; -import android.view.View; -import android.widget.ArrayAdapter; -import android.widget.Toast; + +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Collection; +import java.util.Iterator; +import java.util.List; + +import gnu.trove.list.array.TIntArrayList; public class ConfigureMapMenu { @@ -473,7 +473,7 @@ public class ConfigureMapMenu { protected void showPreferencesDialog(final ContextMenuAdapter adapter, final ArrayAdapter a, final int pos, final MapActivity activity, String category, List ps, final List> prefs) { - Builder bld = new AlertDialog.Builder(activity); + AlertDialog.Builder bld = new AlertDialog.Builder(activity); boolean[] checkedItems = new boolean[prefs.size()]; for (int i = 0; i < prefs.size(); i++) { checkedItems[i] = prefs.get(i).get(); diff --git a/OsmAnd/src/net/osmand/plus/helpers/GpxUiHelper.java b/OsmAnd/src/net/osmand/plus/helpers/GpxUiHelper.java index 9eaf5f07d4..f00aab8541 100644 --- a/OsmAnd/src/net/osmand/plus/helpers/GpxUiHelper.java +++ b/OsmAnd/src/net/osmand/plus/helpers/GpxUiHelper.java @@ -1,12 +1,24 @@ package net.osmand.plus.helpers; -import java.io.File; -import java.util.ArrayList; -import java.util.Collections; -import java.util.Comparator; -import java.util.HashMap; -import java.util.List; -import java.util.Map; +import android.app.Activity; +import android.app.Application; +import android.app.ProgressDialog; +import android.content.DialogInterface; +import android.content.DialogInterface.OnClickListener; +import android.os.Build; +import android.support.v7.app.AlertDialog; +import android.util.TypedValue; +import android.view.View; +import android.view.ViewGroup; +import android.widget.AdapterView; +import android.widget.AdapterView.OnItemClickListener; +import android.widget.ArrayAdapter; +import android.widget.CheckBox; +import android.widget.CompoundButton; +import android.widget.CompoundButton.OnCheckedChangeListener; +import android.widget.ImageView; +import android.widget.TextView; +import android.widget.Toast; import net.osmand.CallbackWithObject; import net.osmand.IndexConstants; @@ -20,26 +32,14 @@ import net.osmand.plus.OsmAndFormatter; import net.osmand.plus.OsmandApplication; import net.osmand.plus.R; import net.osmand.util.Algorithms; -import android.app.Activity; -import android.app.AlertDialog; -import android.app.AlertDialog.Builder; -import android.app.Application; -import android.app.ProgressDialog; -import android.content.DialogInterface; -import android.content.DialogInterface.OnClickListener; -import android.os.Build; -import android.util.TypedValue; -import android.view.View; -import android.view.ViewGroup; -import android.widget.AdapterView; -import android.widget.AdapterView.OnItemClickListener; -import android.widget.ArrayAdapter; -import android.widget.CheckBox; -import android.widget.CompoundButton; -import android.widget.CompoundButton.OnCheckedChangeListener; -import android.widget.ImageView; -import android.widget.TextView; -import android.widget.Toast; + +import java.io.File; +import java.util.ArrayList; +import java.util.Collections; +import java.util.Comparator; +import java.util.HashMap; +import java.util.List; +import java.util.Map; public class GpxUiHelper { @@ -232,7 +232,7 @@ public class GpxUiHelper { final List list, final ContextMenuAdapter adapter) { final OsmandApplication app = (OsmandApplication) activity.getApplication(); final File dir = app.getAppPath(IndexConstants.GPX_INDEX_DIR); - Builder b = new AlertDialog.Builder(activity); + AlertDialog.Builder b = new AlertDialog.Builder(activity); // final int padding = (int) (12 * activity.getResources().getDisplayMetrics().density + 0.5f); final boolean light = app.getSettings().isLightContent(); final int layout; diff --git a/OsmAnd/src/net/osmand/plus/helpers/WaypointDialogHelper.java b/OsmAnd/src/net/osmand/plus/helpers/WaypointDialogHelper.java index c60a08aa20..31ba752b17 100644 --- a/OsmAnd/src/net/osmand/plus/helpers/WaypointDialogHelper.java +++ b/OsmAnd/src/net/osmand/plus/helpers/WaypointDialogHelper.java @@ -1,7 +1,20 @@ package net.osmand.plus.helpers; -import java.util.ArrayList; -import java.util.List; +import android.app.Activity; +import android.content.DialogInterface; +import android.content.DialogInterface.OnClickListener; +import android.content.DialogInterface.OnDismissListener; +import android.os.AsyncTask; +import android.support.v4.app.FragmentActivity; +import android.support.v7.app.AlertDialog; +import android.view.View; +import android.view.ViewGroup; +import android.widget.AdapterView; +import android.widget.ArrayAdapter; +import android.widget.CompoundButton; +import android.widget.ImageButton; +import android.widget.ImageView; +import android.widget.TextView; import net.osmand.data.LatLon; import net.osmand.data.LocationPoint; @@ -16,21 +29,9 @@ import net.osmand.plus.helpers.WaypointHelper.LocationPointWrapper; import net.osmand.plus.poi.PoiUIFilter; import net.osmand.plus.views.AnimateDraggingMapThread; import net.osmand.util.MapUtils; -import android.app.Activity; -import android.app.AlertDialog; -import android.content.DialogInterface; -import android.content.DialogInterface.OnClickListener; -import android.content.DialogInterface.OnDismissListener; -import android.os.AsyncTask; -import android.support.v4.app.FragmentActivity; -import android.view.View; -import android.view.ViewGroup; -import android.widget.AdapterView; -import android.widget.ArrayAdapter; -import android.widget.CompoundButton; -import android.widget.ImageButton; -import android.widget.ImageView; -import android.widget.TextView; + +import java.util.ArrayList; +import java.util.List; /** */ From 7c0a084ba90a5c56771936cd759762511d598ea9 Mon Sep 17 00:00:00 2001 From: GaidamakUA Date: Tue, 8 Sep 2015 13:24:02 +0300 Subject: [PATCH 09/14] Saving last comment and dark theme fix --- OsmAnd/res/layout/fragment_edit_poi_advanced.xml | 11 +++++++---- .../plus/osmedit/dialogs/SendPoiDialogFragment.java | 5 ++++- 2 files changed, 11 insertions(+), 5 deletions(-) diff --git a/OsmAnd/res/layout/fragment_edit_poi_advanced.xml b/OsmAnd/res/layout/fragment_edit_poi_advanced.xml index e906a3e08b..70cb7efce5 100644 --- a/OsmAnd/res/layout/fragment_edit_poi_advanced.xml +++ b/OsmAnd/res/layout/fragment_edit_poi_advanced.xml @@ -4,6 +4,7 @@ xmlns:osmand="http://schemas.android.com/apk/res-auto" android:layout_width="match_parent" android:layout_height="match_parent" + xmlns:tools="http://schemas.android.com/tools" android:theme="?attr/new_app_theme"> + osmand:typeface="@string/font_roboto_medium" + tools:text="poi name"/> + osmand:typeface="@string/font_roboto_medium" + tools:text="landmark"/> diff --git a/OsmAnd/src/net/osmand/plus/osmedit/dialogs/SendPoiDialogFragment.java b/OsmAnd/src/net/osmand/plus/osmedit/dialogs/SendPoiDialogFragment.java index e579e5fdf7..aa923c3103 100644 --- a/OsmAnd/src/net/osmand/plus/osmedit/dialogs/SendPoiDialogFragment.java +++ b/OsmAnd/src/net/osmand/plus/osmedit/dialogs/SendPoiDialogFragment.java @@ -19,6 +19,7 @@ import net.osmand.plus.osmedit.OsmPoint; public class SendPoiDialogFragment extends DialogFragment { public static final String TAG = "SendPoiDialogFragment"; public static final String OPENSTREETMAP_POINT = "openstreetmap_point"; + private static String comment; @NonNull @Override @@ -31,6 +32,7 @@ public class SendPoiDialogFragment extends DialogFragment { final EditText passwordEditText = (EditText) view.findViewById(R.id.passwordEditText); final CheckBox closeChangeSetCheckBox = (CheckBox) view.findViewById(R.id.closeChangeSetCheckBox); + messageEditText.setText(comment); final OsmandSettings settings = ((OsmandApplication) getActivity().getApplication()) .getSettings(); userNameEditText.setText(settings.USER_NAME.get()); @@ -44,12 +46,13 @@ public class SendPoiDialogFragment extends DialogFragment { .setPositiveButton(R.string.shared_string_ok, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { + comment = messageEditText.getText().toString(); settings.USER_NAME.set(userNameEditText.getText().toString()); settings.USER_PASSWORD.set(passwordEditText.getText().toString()); for (OsmPoint osmPoint : poi) { if (osmPoint.getGroup() == OsmPoint.Group.POI) { ((OpenstreetmapPoint) osmPoint) - .setComment(messageEditText.getText().toString()); + .setComment(comment); break; } } From 5d4e56690196a3e53090b3ccae80ee928c78729d Mon Sep 17 00:00:00 2001 From: Mirco Zorzo Date: Tue, 8 Sep 2015 13:18:29 +0200 Subject: [PATCH 10/14] Translated using Weblate (Italian) Currently translated at 100.0% (1768 of 1768 strings) --- OsmAnd/res/values-it/strings.xml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/OsmAnd/res/values-it/strings.xml b/OsmAnd/res/values-it/strings.xml index ee820a05aa..4e3b0857aa 100644 --- a/OsmAnd/res/values-it/strings.xml +++ b/OsmAnd/res/values-it/strings.xml @@ -2166,4 +2166,8 @@ Si consiglia di aggiungere uno o più punti intermedi per migliorarne le prestaz Tipo di PDI Numero di righe del cruscotto %1$s Per favore specifica il tipo si PDI. +Elimina + Giorni lavorativi + Luoghi recenti + Preferiti From 85f604e9c136b6b5fe622920122298ae655e7bd3 Mon Sep 17 00:00:00 2001 From: Matej U Date: Tue, 8 Sep 2015 14:07:17 +0200 Subject: [PATCH 11/14] Translated using Weblate (Slovenian) Currently translated at 100.0% (1768 of 1768 strings) --- OsmAnd/res/values-sl/strings.xml | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/OsmAnd/res/values-sl/strings.xml b/OsmAnd/res/values-sl/strings.xml index 1d1d180304..438994a08d 100644 --- a/OsmAnd/res/values-sl/strings.xml +++ b/OsmAnd/res/values-sl/strings.xml @@ -1962,4 +1962,20 @@ Izogni se vožnji z vlakom Izogni se vožnji z vlakom Zemljevidi za delo brez\npovezave in navigacijo + Priljubljene +Datoteka GPX z opombami + Mesta + izbriši + Osnovno + Napredno + ime + prednost + Podatki stika + Opis + Dodaj odpiralni čas + Vrsta točke POI + Število vrstic v %1$s + Določiti je treba vrsto točke POI. + Delovni dnevi + Nedavna mesta From 73c1664ff8f8cb749d851e0f56845a4721d8fe6c Mon Sep 17 00:00:00 2001 From: Alexey Kulish Date: Tue, 8 Sep 2015 15:32:42 +0300 Subject: [PATCH 12/14] Context menu in progress --- .../res/layout/map_context_menu_fragment.xml | 56 ++++-- .../mapcontextmenu/BottomSectionBuilder.java | 27 +++ .../mapcontextmenu/InfoSectionBuilder.java | 166 ++++++++++++++++++ .../plus/mapcontextmenu/MapContextMenu.java | 13 +- .../MapContextMenuFragment.java | 24 +++ .../osmand/plus/views/ContextMenuLayer.java | 88 ++++++---- 6 files changed, 325 insertions(+), 49 deletions(-) create mode 100644 OsmAnd/src/net/osmand/plus/mapcontextmenu/BottomSectionBuilder.java create mode 100644 OsmAnd/src/net/osmand/plus/mapcontextmenu/InfoSectionBuilder.java diff --git a/OsmAnd/res/layout/map_context_menu_fragment.xml b/OsmAnd/res/layout/map_context_menu_fragment.xml index ca495ba479..52c903bf34 100644 --- a/OsmAnd/res/layout/map_context_menu_fragment.xml +++ b/OsmAnd/res/layout/map_context_menu_fragment.xml @@ -53,8 +53,9 @@ @@ -79,25 +80,41 @@ android:layout_marginTop="3dp" android:text="@string/other_location" android:textColor="?android:textColorSecondary" - android:textSize="@dimen/default_list_text_size"/> + android:textSize="@dimen/default_desc_text_size"/> + + + + + + + android:layout_height="1dp" + android:background="?attr/dashboard_divider"/> + android:layout_gravity="bottom"> + android:layout_width="1dp" + android:background="?attr/dashboard_divider"/> + android:layout_width="1dp" + android:background="?attr/dashboard_divider"/> + android:layout_width="1dp" + android:background="?attr/dashboard_divider"/> + + + + + + + + \ No newline at end of file diff --git a/OsmAnd/src/net/osmand/plus/mapcontextmenu/BottomSectionBuilder.java b/OsmAnd/src/net/osmand/plus/mapcontextmenu/BottomSectionBuilder.java new file mode 100644 index 0000000000..bc393679d9 --- /dev/null +++ b/OsmAnd/src/net/osmand/plus/mapcontextmenu/BottomSectionBuilder.java @@ -0,0 +1,27 @@ +package net.osmand.plus.mapcontextmenu; + +import android.graphics.drawable.Drawable; +import android.view.View; + +import net.osmand.plus.IconsCache; +import net.osmand.plus.OsmandApplication; +import net.osmand.plus.R; + +public abstract class BottomSectionBuilder { + + protected OsmandApplication app; + + public BottomSectionBuilder(OsmandApplication app) { + this.app = app; + } + + public abstract void buildSection(View view); + + public Drawable getRowIcon(int iconId) { + IconsCache iconsCache = app.getIconsCache(); + boolean light = app.getSettings().isLightContent(); + return iconsCache.getIcon(iconId, + light ? R.color.icon_color : R.color.icon_color_light); + } + +} diff --git a/OsmAnd/src/net/osmand/plus/mapcontextmenu/InfoSectionBuilder.java b/OsmAnd/src/net/osmand/plus/mapcontextmenu/InfoSectionBuilder.java new file mode 100644 index 0000000000..1ffd848cc9 --- /dev/null +++ b/OsmAnd/src/net/osmand/plus/mapcontextmenu/InfoSectionBuilder.java @@ -0,0 +1,166 @@ +package net.osmand.plus.mapcontextmenu; + +import android.content.res.Resources; +import android.util.AttributeSet; +import android.util.TypedValue; +import android.view.Gravity; +import android.view.View; +import android.view.ViewGroup; +import android.widget.ImageView; +import android.widget.LinearLayout; +import android.widget.TextView; + +import net.osmand.data.Amenity; +import net.osmand.osm.AbstractPoiType; +import net.osmand.osm.MapPoiTypes; +import net.osmand.osm.PoiType; +import net.osmand.plus.OsmandApplication; +import net.osmand.plus.R; +import net.osmand.util.Algorithms; + +import java.util.Map; + +import static android.util.TypedValue.COMPLEX_UNIT_DIP; + +public class InfoSectionBuilder extends BottomSectionBuilder { + + private final Amenity amenity; + + public InfoSectionBuilder(OsmandApplication app, final Amenity amenity) { + super(app); + this.amenity = amenity; + } + + private void buildRow(View view, int iconId, String text) { + + /* + + + + + + + + + + + + + + + + + + */ + + + LinearLayout ll = new LinearLayout(view.getContext()); + ll.setOrientation(LinearLayout.HORIZONTAL); + ll.setLayoutParams(new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT)); + + // Icon + LinearLayout llIcon = new LinearLayout(view.getContext()); + llIcon.setOrientation(LinearLayout.HORIZONTAL); + llIcon.setLayoutParams(new LinearLayout.LayoutParams(dpToPx(42f), ViewGroup.LayoutParams.MATCH_PARENT)); + ll.addView(llIcon); + + ImageView icon = new ImageView(view.getContext()); + ViewGroup.MarginLayoutParams llIconParams = new ViewGroup.MarginLayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT); + llIconParams.setMargins(dpToPx(12f), 0, 0, 0); + //llIconParams.setGravity(Gravity.CENTER_VERTICAL); + icon.setLayoutParams(llIconParams); + icon.setScaleType(ImageView.ScaleType.CENTER); + icon.setImageDrawable(getRowIcon(iconId)); + llIcon.addView(icon); + + // Text + LinearLayout llText = new LinearLayout(view.getContext()); + llText.setOrientation(LinearLayout.VERTICAL); + ViewGroup.MarginLayoutParams llTextParams = new ViewGroup.MarginLayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT); + llTextParams.setMargins(0, dpToPx(4f), 0, dpToPx(4f)); + llText.setLayoutParams(llTextParams); + ll.addView(llText); + + TextView textView = new TextView(view.getContext()); + ViewGroup.MarginLayoutParams llTextViewParams = new ViewGroup.MarginLayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT); + llTextViewParams.setMargins(dpToPx(10f), 0, dpToPx(10f), 0); + llText.setLayoutParams(llTextViewParams); + } + + public int dpToPx(float dp) { + Resources r = app.getResources(); + return (int) TypedValue.applyDimension( + COMPLEX_UNIT_DIP, + dp, + r.getDisplayMetrics() + ); + } + + @Override + public void buildSection(View view) { + + MapPoiTypes poiTypes = app.getPoiTypes(); + for(Map.Entry e : amenity.getAdditionalInfo().entrySet()) { + int iconId = 0; + String key = e.getKey(); + String vl = e.getValue(); + if(key.startsWith("name:")) { + continue; + } else if(Amenity.OPENING_HOURS.equals(key)) { + iconId = R.drawable.mm_clock; // todo: change icon + } else if(Amenity.PHONE.equals(key)) { + iconId = R.drawable.mm_amenity_telephone; // todo: change icon + } else if(Amenity.WEBSITE.equals(key)) { + iconId = R.drawable.mm_internet_access; // todo: change icon + } else { + iconId = R.drawable.ic_type_info; // todo: change icon + AbstractPoiType pt = poiTypes.getAnyPoiAdditionalTypeByKey(e.getKey()); + if (pt != null) { + if(pt instanceof PoiType && !((PoiType) pt).isText()) { + vl = pt.getTranslation(); + } else { + vl = /*pt.getTranslation() + ": " + */amenity.unzipContent(e.getValue()); + } + } else { + vl = /*Algorithms.capitalizeFirstLetterAndLowercase(e.getKey()) + + ": " + */amenity.unzipContent(e.getValue()); + } + } + + buildRow(view, iconId, vl); + } + } +} diff --git a/OsmAnd/src/net/osmand/plus/mapcontextmenu/MapContextMenu.java b/OsmAnd/src/net/osmand/plus/mapcontextmenu/MapContextMenu.java index 2048005c63..4b0d13c2f1 100644 --- a/OsmAnd/src/net/osmand/plus/mapcontextmenu/MapContextMenu.java +++ b/OsmAnd/src/net/osmand/plus/mapcontextmenu/MapContextMenu.java @@ -134,7 +134,7 @@ public class MapContextMenu { res = typeName; } - return Algorithms.isEmpty(res) ? "Address is unknown yet" : res; + return Algorithms.isEmpty(res) ? "Address is unknown yet" : res; // todo: text constant } public String getLocationStr() { @@ -144,6 +144,17 @@ public class MapContextMenu { return foundStreetName; } + public BottomSectionBuilder getBottomSectionBuilder() { + + if (object != null) { + if (object instanceof Amenity) { + return new InfoSectionBuilder(app, (Amenity)object); + } + } + + return null; + } + public void buttonNavigatePressed() { mapActivity.getMapActions().showNavigationContextMenuPoint(pointDescription.getLat(), pointDescription.getLon()); } diff --git a/OsmAnd/src/net/osmand/plus/mapcontextmenu/MapContextMenuFragment.java b/OsmAnd/src/net/osmand/plus/mapcontextmenu/MapContextMenuFragment.java index a98de676c5..f1b0a35ca0 100644 --- a/OsmAnd/src/net/osmand/plus/mapcontextmenu/MapContextMenuFragment.java +++ b/OsmAnd/src/net/osmand/plus/mapcontextmenu/MapContextMenuFragment.java @@ -126,6 +126,7 @@ public class MapContextMenuFragment extends Fragment { } }); + // Left icon IconsCache iconsCache = getMyApplication().getIconsCache(); boolean light = getMyApplication().getSettings().isLightContent(); @@ -140,12 +141,27 @@ public class MapContextMenuFragment extends Fragment { light ? R.color.icon_color : R.color.icon_color_light)); } + // Text line 1 TextView line1 = (TextView) view.findViewById(R.id.context_menu_line1); line1.setText(MapContextMenu.getInstance().getAddressStr()); + // Text line 2 TextView line2 = (TextView) view.findViewById(R.id.context_menu_line2); line2.setText(MapContextMenu.getInstance().getLocationStr()); + // Close button + final ImageView closeButtonView = (ImageView)view.findViewById(R.id.context_menu_close_btn_view); + closeButtonView.setImageDrawable(iconsCache.getIcon(R.drawable.ic_action_remove_dark, + light ? R.color.actionbar_dark_color : R.color.actionbar_light_color)); + closeButtonView.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View v) { + ((MapActivity)getActivity()).getMapLayers().getContextMenuLayer().hideMapContextMenuMarker(); + dismissMenu(); + } + }); + + // Action buttons final ImageButton buttonNavigate = (ImageButton) view.findViewById(R.id.context_menu_route_button); buttonNavigate.setImageDrawable(iconsCache.getIcon(R.drawable.map_directions, light ? R.color.actionbar_dark_color : R.color.actionbar_light_color)); @@ -186,6 +202,14 @@ public class MapContextMenuFragment extends Fragment { } }); + // Bottom view + BottomSectionBuilder bottomSectionBuilder = MapContextMenu.getInstance().getBottomSectionBuilder(); + if (bottomSectionBuilder != null) { + View bottomView = view.findViewById(R.id.context_menu_bottom_view); + bottomSectionBuilder.buildSection(bottomView); + } + + /* Toolbar toolbar = (Toolbar) view.findViewById(R.id.toolbar); toolbar.setTitle(R.string.poi_create_title); diff --git a/OsmAnd/src/net/osmand/plus/views/ContextMenuLayer.java b/OsmAnd/src/net/osmand/plus/views/ContextMenuLayer.java index 0282f751cb..965f45c573 100644 --- a/OsmAnd/src/net/osmand/plus/views/ContextMenuLayer.java +++ b/OsmAnd/src/net/osmand/plus/views/ContextMenuLayer.java @@ -4,14 +4,9 @@ import android.app.AlertDialog; import android.app.AlertDialog.Builder; import android.content.DialogInterface; import android.content.DialogInterface.OnClickListener; -import android.graphics.Bitmap; -import android.graphics.BitmapFactory; import android.graphics.Canvas; import android.graphics.Color; -import android.graphics.Paint; import android.graphics.PointF; -import android.graphics.PorterDuff; -import android.graphics.PorterDuffColorFilter; import android.graphics.Rect; import android.os.Build; import android.text.Html; @@ -35,6 +30,7 @@ import java.util.Iterator; import java.util.List; import java.util.Map; import java.util.Map.Entry; +import java.util.Objects; import java.util.concurrent.ConcurrentHashMap; public class ContextMenuLayer extends OsmandMapLayer { @@ -68,6 +64,7 @@ public class ContextMenuLayer extends OsmandMapLayer { private LatLon latLon; private String description; private Map selectedObjects = new ConcurrentHashMap(); + private Object selectedObj; private TextView textView; private ImageView closeButton; @@ -78,10 +75,8 @@ public class ContextMenuLayer extends OsmandMapLayer { private float scaleCoefficient = 1; private CallbackWithObject selectOnMap = null; - private Bitmap mapContextMarker; - private boolean showMapContextMarker; - - private Paint mapMarkerPaintIcon; + private boolean showContextMarker; + private ImageView contextMarker; public ContextMenuLayer(MapActivity activity){ this.activity = activity; @@ -130,11 +125,14 @@ public class ContextMenuLayer extends OsmandMapLayer { closeButton.setImageDrawable(view.getResources().getDrawable(R.drawable.headliner_close)); closeButton.setClickable(true); - showMapContextMarker = false; - mapMarkerPaintIcon = new Paint(); - mapMarkerPaintIcon.setColorFilter(new PorterDuffColorFilter(activity.getResources().getColor(R.color.osmand_orange), PorterDuff.Mode.SRC_IN)); - mapContextMarker = BitmapFactory.decodeResource(view.getResources(), R.drawable.ic_action_marker2); - + showContextMarker = false; + contextMarker = new ImageView(view.getContext()); + contextMarker.setLayoutParams(new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT)); + contextMarker.setImageDrawable(view.getResources().getDrawable(R.drawable.map_pin_context_menu)); + contextMarker.setClickable(true); + int minw = contextMarker.getDrawable().getMinimumWidth(); + int minh = contextMarker.getDrawable().getMinimumHeight(); + contextMarker.layout(0, 0, minw, minh); if(latLon != null){ setLocation(latLon, description); @@ -153,8 +151,10 @@ public class ContextMenuLayer extends OsmandMapLayer { int x = (int) box.getPixXFromLatLon(latLon.getLatitude(), latLon.getLongitude()); int y = (int) box.getPixYFromLatLon(latLon.getLatitude(), latLon.getLongitude()); - if (showMapContextMarker) - canvas.drawBitmap(mapContextMarker, x - mapContextMarker.getWidth() / 2, y - mapContextMarker.getHeight(), mapMarkerPaintIcon); + if (showContextMarker) { + canvas.translate(x - contextMarker.getWidth() / 2, y - contextMarker.getHeight()); + contextMarker.draw(canvas); + } textView.setTextColor(nightMode != null && nightMode.isNightMode() ? Color.GRAY : Color.WHITE); if (textView.getText().length() > 0) { @@ -201,15 +201,15 @@ public class ContextMenuLayer extends OsmandMapLayer { } public void showMapContextMenuMarker() { - if (!showMapContextMarker) { - showMapContextMarker = true; + if (!showContextMarker) { + showContextMarker = true; view.refreshMap(); } } public void hideMapContextMenuMarker() { - if (showMapContextMarker) { - showMapContextMarker = false; + if (showContextMarker) { + showContextMarker = false; view.refreshMap(); } } @@ -273,11 +273,10 @@ public class ContextMenuLayer extends OsmandMapLayer { if (latLon != null) { if (selectedObjects.size() == 1) { setLocation(null, ""); - Object selectedObj = selectedObjects.keySet().iterator().next(); + selectedObj = selectedObjects.keySet().iterator().next(); showMapContextMenu(selectedObj, latLon); - } else { - String description = getSelectedObjectDescription(); - setLocation(latLon, description); + } else if (selectedObjects.size() > 1) { + showContextMenuForSelectedObjects(latLon); } } else { setLocation(null, ""); @@ -362,7 +361,19 @@ public class ContextMenuLayer extends OsmandMapLayer { } return 0; } - + + public boolean pressedContextMarker(RotatedTileBox tb, float px, float py) { + if (latLon != null && showContextMarker) { + Rect bs = contextMarker.getDrawable().getBounds(); + int dx = (int) (px - tb.getPixXFromLatLon(latLon.getLatitude(), latLon.getLongitude())); + int dy = (int) (py - tb.getPixYFromLatLon(latLon.getLatitude(), latLon.getLongitude())); + int bx = dx + bs.width() / 2; + int by = dy + bs.height(); + return (bs.contains(bx, by)); + } + return false; + } + public String getSelectedObjectName(){ return getSelectedObjectInfo(true); } @@ -412,6 +423,11 @@ public class ContextMenuLayer extends OsmandMapLayer { @Override public boolean onSingleTap(PointF point, RotatedTileBox tileBox) { + if (pressedContextMarker(tileBox, point.x, point.y)) { + showMapContextMenu(selectedObj, latLon); + return true; + } + boolean nativeMode = (Build.VERSION.SDK_INT >= 14) || view.getSettings().SCROLL_MAP_BY_GESTURES.get(); int val = pressedInTextView(tileBox, point.x, point.y); if(selectOnMap != null) { @@ -438,12 +454,10 @@ public class ContextMenuLayer extends OsmandMapLayer { if (latLon != null) { if (selectedObjects.size() == 1) { setLocation(null, ""); - Object selectedObj = selectedObjects.keySet().iterator().next(); + selectedObj = selectedObjects.keySet().iterator().next(); showMapContextMenu(selectedObj, latLon); - } else { - String description = getSelectedObjectDescription(); - setLocation(latLon, description); - view.refreshMap(); + } else if (selectedObjects.size() > 1) { + showContextMenuForSelectedObjects(latLon); return true; } } @@ -467,13 +481,13 @@ public class ContextMenuLayer extends OsmandMapLayer { builder.setItems(d, new OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { - Object selectedObj = s.get(which); + selectedObj = s.get(which); showMapContextMenu(selectedObj, l); } }); builder.show(); } else { - Object selectedObj = selectedObjects.keySet().iterator().next(); + selectedObj = selectedObjects.keySet().iterator().next(); showMapContextMenu(selectedObj, l); } } @@ -481,13 +495,15 @@ public class ContextMenuLayer extends OsmandMapLayer { private void showMapContextMenu(Object obj, LatLon latLon) { PointDescription pointDescription; if (obj != null) { - pointDescription = selectedObjects.get(obj).getObjectName(obj); - pointDescription.setLat(latLon.getLatitude()); - pointDescription.setLon(latLon.getLongitude()); + IContextMenuProvider typedObj = selectedObjects.get(obj); + pointDescription = typedObj.getObjectName(obj); + LatLon objLocation = typedObj.getObjectLocation(obj); + pointDescription.setLat(objLocation.getLatitude()); + pointDescription.setLon(objLocation.getLongitude()); } else { pointDescription = new PointDescription(latLon.getLatitude(), latLon.getLongitude()); } - this.latLon = latLon; + this.latLon = new LatLon(pointDescription.getLat(), pointDescription.getLon()); showMapContextMenuMarker(); MapContextMenu.getInstance().show(pointDescription, obj); From 748337ada667f32f98f793a8736aadc7ba8acc3d Mon Sep 17 00:00:00 2001 From: Alexey Kulish Date: Tue, 8 Sep 2015 17:53:57 +0300 Subject: [PATCH 13/14] Added POI info fields to the context menu --- .../res/layout/map_context_menu_fragment.xml | 2 +- .../mapcontextmenu/InfoSectionBuilder.java | 86 ++++++------------- .../MapContextMenuFragment.java | 10 ++- .../osmand/plus/views/ContextMenuLayer.java | 33 ++++--- 4 files changed, 51 insertions(+), 80 deletions(-) diff --git a/OsmAnd/res/layout/map_context_menu_fragment.xml b/OsmAnd/res/layout/map_context_menu_fragment.xml index 52c903bf34..cb2a9335a3 100644 --- a/OsmAnd/res/layout/map_context_menu_fragment.xml +++ b/OsmAnd/res/layout/map_context_menu_fragment.xml @@ -177,7 +177,7 @@ android:id="@+id/context_menu_bottom_view" android:layout_width="fill_parent" android:layout_height="wrap_content" - android:orientation="horizontal"> + android:orientation="vertical"> - - - - - - - - - - - - - - - - - */ - - LinearLayout ll = new LinearLayout(view.getContext()); ll.setOrientation(LinearLayout.HORIZONTAL); - ll.setLayoutParams(new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT)); + LinearLayout.LayoutParams llParams = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT) ; + llParams.setMargins(0, dpToPx(10f), 0, dpToPx(10f)); + ll.setLayoutParams(llParams); // Icon LinearLayout llIcon = new LinearLayout(view.getContext()); @@ -98,9 +44,9 @@ public class InfoSectionBuilder extends BottomSectionBuilder { ll.addView(llIcon); ImageView icon = new ImageView(view.getContext()); - ViewGroup.MarginLayoutParams llIconParams = new ViewGroup.MarginLayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT); + LinearLayout.LayoutParams llIconParams = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT) ; llIconParams.setMargins(dpToPx(12f), 0, 0, 0); - //llIconParams.setGravity(Gravity.CENTER_VERTICAL); + llIconParams.gravity = Gravity.CENTER_VERTICAL; icon.setLayoutParams(llIconParams); icon.setScaleType(ImageView.ScaleType.CENTER); icon.setImageDrawable(getRowIcon(iconId)); @@ -109,15 +55,33 @@ public class InfoSectionBuilder extends BottomSectionBuilder { // Text LinearLayout llText = new LinearLayout(view.getContext()); llText.setOrientation(LinearLayout.VERTICAL); - ViewGroup.MarginLayoutParams llTextParams = new ViewGroup.MarginLayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT); + LinearLayout.LayoutParams llTextParams = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT); llTextParams.setMargins(0, dpToPx(4f), 0, dpToPx(4f)); llText.setLayoutParams(llTextParams); ll.addView(llText); TextView textView = new TextView(view.getContext()); - ViewGroup.MarginLayoutParams llTextViewParams = new ViewGroup.MarginLayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT); + + LinearLayout.LayoutParams llTextViewParams = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT); llTextViewParams.setMargins(dpToPx(10f), 0, dpToPx(10f), 0); llText.setLayoutParams(llTextViewParams); + textView.setText(text); + //textView.setText("sdf dsaf fsdasdfg adsf asdsfd asdf sdf adsfg asdf sdfa sdf dsf agsfdgd fgsfd sdf asdf adg adf sdf asdf dfgdfsg sdfg adsf asdf asdf sdf SDF ASDF ADSF ASDF ASDF DAF SDAF dfg dsfg dfg sdfg rg rth sfghs dfgs dfgsdfg adfg dfg sdfg dfs "); + llText.addView(textView); + + ((LinearLayout)view).addView(ll); + + View horizontalLine = new View(view.getContext()); + LinearLayout.LayoutParams llHorLineParams = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, dpToPx(1f)); + llHorLineParams.gravity = Gravity.BOTTOM; + horizontalLine.setLayoutParams(llHorLineParams); + TypedValue typedValue = new TypedValue(); + Resources.Theme theme = view.getContext().getTheme(); + theme.resolveAttribute(R.attr.dashboard_divider, typedValue, true); + int color = typedValue.data; + horizontalLine.setBackgroundColor(color); + + ((LinearLayout)view).addView(horizontalLine); } public int dpToPx(float dp) { diff --git a/OsmAnd/src/net/osmand/plus/mapcontextmenu/MapContextMenuFragment.java b/OsmAnd/src/net/osmand/plus/mapcontextmenu/MapContextMenuFragment.java index f1b0a35ca0..716e9c9cfc 100644 --- a/OsmAnd/src/net/osmand/plus/mapcontextmenu/MapContextMenuFragment.java +++ b/OsmAnd/src/net/osmand/plus/mapcontextmenu/MapContextMenuFragment.java @@ -10,7 +10,6 @@ import android.view.MotionEvent; import android.view.View; import android.view.ViewGroup; import android.view.animation.DecelerateInterpolator; -import android.widget.Button; import android.widget.ImageButton; import android.widget.ImageView; import android.widget.LinearLayout; @@ -21,12 +20,9 @@ import net.osmand.plus.IconsCache; import net.osmand.plus.OsmandApplication; import net.osmand.plus.R; import net.osmand.plus.activities.MapActivity; -import net.osmand.plus.activities.search.SearchActivity; import org.apache.commons.logging.Log; -import java.util.Map; - public class MapContextMenuFragment extends Fragment { @@ -206,6 +202,12 @@ public class MapContextMenuFragment extends Fragment { BottomSectionBuilder bottomSectionBuilder = MapContextMenu.getInstance().getBottomSectionBuilder(); if (bottomSectionBuilder != null) { View bottomView = view.findViewById(R.id.context_menu_bottom_view); + bottomView.setOnTouchListener(new View.OnTouchListener() { + @Override + public boolean onTouch(View v, MotionEvent event) { + return true; + } + }); bottomSectionBuilder.buildSection(bottomView); } diff --git a/OsmAnd/src/net/osmand/plus/views/ContextMenuLayer.java b/OsmAnd/src/net/osmand/plus/views/ContextMenuLayer.java index 965f45c573..47998532d1 100644 --- a/OsmAnd/src/net/osmand/plus/views/ContextMenuLayer.java +++ b/OsmAnd/src/net/osmand/plus/views/ContextMenuLayer.java @@ -30,7 +30,6 @@ import java.util.Iterator; import java.util.List; import java.util.Map; import java.util.Map.Entry; -import java.util.Objects; import java.util.concurrent.ConcurrentHashMap; public class ContextMenuLayer extends OsmandMapLayer { @@ -65,7 +64,8 @@ public class ContextMenuLayer extends OsmandMapLayer { private String description; private Map selectedObjects = new ConcurrentHashMap(); private Object selectedObj; - + private IContextMenuProvider contextObject; + private TextView textView; private ImageView closeButton; private OsmandMapTileView view; @@ -274,7 +274,8 @@ public class ContextMenuLayer extends OsmandMapLayer { if (selectedObjects.size() == 1) { setLocation(null, ""); selectedObj = selectedObjects.keySet().iterator().next(); - showMapContextMenu(selectedObj, latLon); + contextObject = selectedObjects.get(selectedObj); + showMapContextMenu(latLon); } else if (selectedObjects.size() > 1) { showContextMenuForSelectedObjects(latLon); } @@ -282,7 +283,9 @@ public class ContextMenuLayer extends OsmandMapLayer { setLocation(null, ""); final double lat = tileBox.getLatFromPixel((int) point.x, (int) point.y); final double lon = tileBox.getLonFromPixel((int) point.x, (int) point.y); - showMapContextMenu(null, new LatLon(lat, lon)); + selectedObj = null; + contextObject = null; + showMapContextMenu(new LatLon(lat, lon)); //setLocation(new LatLon(lat, lon), null); } view.refreshMap(); @@ -424,7 +427,7 @@ public class ContextMenuLayer extends OsmandMapLayer { @Override public boolean onSingleTap(PointF point, RotatedTileBox tileBox) { if (pressedContextMarker(tileBox, point.x, point.y)) { - showMapContextMenu(selectedObj, latLon); + showMapContextMenu(latLon); return true; } @@ -455,7 +458,8 @@ public class ContextMenuLayer extends OsmandMapLayer { if (selectedObjects.size() == 1) { setLocation(null, ""); selectedObj = selectedObjects.keySet().iterator().next(); - showMapContextMenu(selectedObj, latLon); + contextObject = selectedObjects.get(selectedObj); + showMapContextMenu(latLon); } else if (selectedObjects.size() > 1) { showContextMenuForSelectedObjects(latLon); return true; @@ -482,22 +486,23 @@ public class ContextMenuLayer extends OsmandMapLayer { @Override public void onClick(DialogInterface dialog, int which) { selectedObj = s.get(which); - showMapContextMenu(selectedObj, l); + contextObject = selectedObjects.get(selectedObj); + showMapContextMenu(l); } }); builder.show(); } else { selectedObj = selectedObjects.keySet().iterator().next(); - showMapContextMenu(selectedObj, l); + contextObject = selectedObjects.get(selectedObj); + showMapContextMenu(l); } } - private void showMapContextMenu(Object obj, LatLon latLon) { + private void showMapContextMenu(LatLon latLon) { PointDescription pointDescription; - if (obj != null) { - IContextMenuProvider typedObj = selectedObjects.get(obj); - pointDescription = typedObj.getObjectName(obj); - LatLon objLocation = typedObj.getObjectLocation(obj); + if (selectedObj != null && contextObject != null) { + pointDescription = contextObject.getObjectName(selectedObj); + LatLon objLocation = contextObject.getObjectLocation(selectedObj); pointDescription.setLat(objLocation.getLatitude()); pointDescription.setLon(objLocation.getLongitude()); } else { @@ -506,7 +511,7 @@ public class ContextMenuLayer extends OsmandMapLayer { this.latLon = new LatLon(pointDescription.getLat(), pointDescription.getLon()); showMapContextMenuMarker(); - MapContextMenu.getInstance().show(pointDescription, obj); + MapContextMenu.getInstance().show(pointDescription, selectedObj); } From bb588f08164110e9411585883795010bfff532f2 Mon Sep 17 00:00:00 2001 From: Alexey Kulish Date: Tue, 8 Sep 2015 20:01:25 +0300 Subject: [PATCH 14/14] Context menu - few fixes --- OsmAnd/res/layout/map_context_menu_fragment.xml | 6 +++--- .../mapcontextmenu/MapContextMenuFragment.java | 14 +++++--------- 2 files changed, 8 insertions(+), 12 deletions(-) diff --git a/OsmAnd/res/layout/map_context_menu_fragment.xml b/OsmAnd/res/layout/map_context_menu_fragment.xml index cb2a9335a3..4e73daf26a 100644 --- a/OsmAnd/res/layout/map_context_menu_fragment.xml +++ b/OsmAnd/res/layout/map_context_menu_fragment.xml @@ -2,12 +2,12 @@ diff --git a/OsmAnd/src/net/osmand/plus/mapcontextmenu/MapContextMenuFragment.java b/OsmAnd/src/net/osmand/plus/mapcontextmenu/MapContextMenuFragment.java index 716e9c9cfc..60858352bc 100644 --- a/OsmAnd/src/net/osmand/plus/mapcontextmenu/MapContextMenuFragment.java +++ b/OsmAnd/src/net/osmand/plus/mapcontextmenu/MapContextMenuFragment.java @@ -12,7 +12,6 @@ import android.view.ViewGroup; import android.view.animation.DecelerateInterpolator; import android.widget.ImageButton; import android.widget.ImageView; -import android.widget.LinearLayout; import android.widget.TextView; import net.osmand.PlatformUtil; @@ -85,6 +84,8 @@ public class MapContextMenuFragment extends Fragment { View topView = view.findViewById(R.id.context_menu_top_view); mainView = view.findViewById(R.id.context_menu_main); + //LinearLayout.LayoutParams lp = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, dpToPx(400)); + //mainView.setLayoutParams(lp); topView.setOnTouchListener(new View.OnTouchListener() { @@ -100,21 +101,16 @@ public class MapContextMenuFragment extends Fragment { case MotionEvent.ACTION_MOVE: float y = event.getY(); - LinearLayout.LayoutParams lp = (LinearLayout.LayoutParams) mainView.getLayoutParams(); - float top = lp.topMargin + (y - dy); - if (top < 0) { - lp.topMargin = (int) top; - mainView.setLayoutParams(lp); - } + mainView.setY(mainView.getY() + (y - dy)); break; case MotionEvent.ACTION_UP: case MotionEvent.ACTION_CANCEL: float posY = view.getHeight() - mainViewHeight; - if (mainView.getY() != posY) { + if (mainView.getY() != posY) mainView.animate().y(posY).setDuration(200).setInterpolator(new DecelerateInterpolator()).start(); - } + break; }