diff --git a/OsmAnd/res/values-ca/phrases.xml b/OsmAnd/res/values-ca/phrases.xml
index 4fe07fdc6c..c075db1d73 100644
--- a/OsmAnd/res/values-ca/phrases.xml
+++ b/OsmAnd/res/values-ca/phrases.xml
@@ -915,7 +915,7 @@
Operador
Marca
- Control de tràfic: obeir el semàfor
+ Control de tràfic: semàfor
Control de trànsit: velocitat màxima
Control de trànsit: alçada màxima
Control de trànsit: distància mínima
@@ -1017,8 +1017,8 @@
Bicicletes
Dutxa
- Aigua potable
- Aigua no potable
+ Aigua potable: sí
+ Aigua potable: no
De temporada
Tot l\'any
Estació seca
@@ -1093,7 +1093,7 @@
Pentecostal
Mormó
Testimonis de Jehovà
- Ortodox grec
+ Ortodoxa grega
Calvinisme
Adventisme del setè dia
Nova apostòlica
@@ -1221,4 +1221,11 @@
Cafè
Venda de tiquets
Venda d\'aigua
+ Sitja búnquer
+ DVD
+ Espelmes
+ Joguines
+ Gelat
+ Targes SIM
+
diff --git a/OsmAnd/res/values-ca/strings.xml b/OsmAnd/res/values-ca/strings.xml
index 7d42584fc2..d0ff403bea 100644
--- a/OsmAnd/res/values-ca/strings.xml
+++ b/OsmAnd/res/values-ca/strings.xml
@@ -2152,4 +2152,7 @@ Per retornar a l\'estil habitual dels mapes d\'OsmAnd, només cal desactivar aqu
m/s
Baixada - %1$d fitxer
+Corbes de nivell desactivades
+ Mostra bàner de la versió gratuïta
+ Encara que tinguéssiu una versió de pagament també podríeu veure el bàner de la versió gratuïta
diff --git a/OsmAnd/res/values-da/strings.xml b/OsmAnd/res/values-da/strings.xml
index 5ec6469ab5..52f13d7483 100644
--- a/OsmAnd/res/values-da/strings.xml
+++ b/OsmAnd/res/values-da/strings.xml
@@ -2162,4 +2162,6 @@
Vælg kategori
Henter - %1$d fil
Højdekurver er deaktiveret
-
+ Vis banner for gratis version
+ "Selvom du har en betalt version kan du stadig se banner for den gratis version"
+
diff --git a/OsmAnd/res/values-es-rAR/phrases.xml b/OsmAnd/res/values-es-rAR/phrases.xml
index 33a7f95cd1..1516f704b1 100644
--- a/OsmAnd/res/values-es-rAR/phrases.xml
+++ b/OsmAnd/res/values-es-rAR/phrases.xml
@@ -1437,8 +1437,8 @@
No acepta billetes
Acepta monederos electrónicos
No acepta monederos electrónicos
- Acepta efectivo
- No acepta efectivo
+ Acepta dinero
+ No acepta dinero
Acepta tarjetas de débito
No acepta tarjetas de débito
Acepta Bitcoin
@@ -1644,7 +1644,7 @@
Prohibido para hombres
Femenino
Prohibido para mujeres
- Cubierto (puertas adentro)
+ Cubierto (interior)
Al aire libre
Con baños
Sin baños
@@ -1671,7 +1671,7 @@
Dulces
Condones
Sellos
- Tubos de bicicleta
+ Válvulas de bicicleta
Comida
Bebidas y comidas
Surtidor de combustible
@@ -1709,4 +1709,12 @@
Inscripción
-
+Con cepillo giratorio
+ Sin cepillo giratorio
+ Estación de paquetes y correos
+ Estación de paquetería
+ Estación de correos
+ Moneda elongada
+ Koshinto
+ Jizo
+
diff --git a/OsmAnd/res/values-es-rAR/strings.xml b/OsmAnd/res/values-es-rAR/strings.xml
index 93ba90c8c5..37e117061c 100644
--- a/OsmAnd/res/values-es-rAR/strings.xml
+++ b/OsmAnd/res/values-es-rAR/strings.xml
@@ -2083,4 +2083,8 @@
Añadir nuevo
Elegir categoría
-
+ Curvas de nivel desactivadas
+ Descargando - %1$s archivo/s
+ Mostrar banner de versión gratuita
+ Aunque tenga la versión paga, podrá ver el banner de la versión gratuita
+
diff --git a/OsmAnd/res/values-it/strings.xml b/OsmAnd/res/values-it/strings.xml
index 4da4acf899..023eeb9431 100644
--- a/OsmAnd/res/values-it/strings.xml
+++ b/OsmAnd/res/values-it/strings.xml
@@ -2206,4 +2206,6 @@ Si consiglia di aggiungere uno o più punti intermedi per migliorarne le prestaz
Scegli la categoria
In download - %1$d file
Linee isocline disattivate
-
+ Mostra il banner della versione gratuita
+ Anche se hai la versione a pagamento puoi comunque vedere il banner della versione gratuita
+
diff --git a/OsmAnd/res/values-sc/strings.xml b/OsmAnd/res/values-sc/strings.xml
index 15727fdad4..08f961a7cf 100644
--- a/OsmAnd/res/values-sc/strings.xml
+++ b/OsmAnd/res/values-sc/strings.xml
@@ -384,7 +384,7 @@
Stop
Avia/Inghitza
Notas àudio/vìdeo
- Plugin OsmAndfor pro sas lìnias de livellu sena lìnia
+ Plugin OsmAnd pro sas lìnias de livellu sena lìnia
"Custu plugin frunidi sas lìnias de livellu e sas umbraduras de sos rilievos, chi podent èssere visualizadas in supra de sas mapas non in lìnia de OsmAnd. Custa funtzionalidade at a èssere appretziada meda dae sos atletas, sos escursionistas, e totu sos chi sunt interessados in s\'orografia e su paesàggiu.
\n\nSos datos globales (intre sos 70 grados nord e sos 70 grados sud) sunt basados in supra de sas medidas de su SRTM (Shuttle Radar Topography Mission) e de s’ASTER (Advanced Spaceborne Thermal Emission and Reflection Radiometer), un’aina medidora a bordu de Terra, su satellite de su sistema di osservatzione de sa terra de sa NASA. ASTER est un’isfortzu de coperassione intre NASA, su Ministeru de s’Economia Cummèrtziu e Industria (METI) de su Giappone, e su sistema ispatziale giapponesu (J-spacesystems). "
Medidura de sa distantzia
@@ -2116,4 +2116,7 @@
m/s
Iscarrigande - %1$d documentu
+Lìnias de livellu disativadas
+ Ammustra s’insigna de sa versione a indonu (gratùita)
+ Fintzas si tenes sa versione a pagamentu podes bìere s’insigna de sa versione a indonu (gratùita)
diff --git a/OsmAnd/res/values-sv/strings.xml b/OsmAnd/res/values-sv/strings.xml
index 15663748c6..8dfc2c87b9 100644
--- a/OsmAnd/res/values-sv/strings.xml
+++ b/OsmAnd/res/values-sv/strings.xml
@@ -2027,4 +2027,5 @@
min/km
m/s
+ Konturlinjer inaktiverade
diff --git a/OsmAnd/res/values-zh-rTW/strings.xml b/OsmAnd/res/values-zh-rTW/strings.xml
index 15a9d17347..285cd93feb 100644
--- a/OsmAnd/res/values-zh-rTW/strings.xml
+++ b/OsmAnd/res/values-zh-rTW/strings.xml
@@ -2140,4 +2140,5 @@
增加新的
選擇類別
正在下載 - %1$d 檔案
-
+等高線已停用
+
diff --git a/OsmAnd/res/values/phrases.xml b/OsmAnd/res/values/phrases.xml
index c1b17dfad8..e3caa0492e 100644
--- a/OsmAnd/res/values/phrases.xml
+++ b/OsmAnd/res/values/phrases.xml
@@ -1058,14 +1058,14 @@
Highway crossing
- International cycling network route
- National cycling network route
- Regional cycling network route
- Local cycling network route
- International hiking network route
- National hiking network route
- Regional hiking network route
- Local hiking network route
+ International cycling network node
+ National cycling network node
+ Regional cycling network node
+ Local cycling network node
+ International hiking network node
+ National hiking network node
+ Regional hiking network node
+ Local hiking network node
International hiking route
National hiking route
diff --git a/OsmAnd/res/values/strings.xml b/OsmAnd/res/values/strings.xml
index cb7e809d85..cc9387ac66 100644
--- a/OsmAnd/res/values/strings.xml
+++ b/OsmAnd/res/values/strings.xml
@@ -1998,4 +1998,6 @@ Afghanistan, Albania, Algeria, Andorra, Angola, Anguilla, Antigua and Barbuda, A
%1$s downloads left
Roads
Downloding - %1$d file
+ Show free version banner
+ Even if you have paid version you still can see free version banner
diff --git a/OsmAnd/src/net/osmand/plus/OsmandSettings.java b/OsmAnd/src/net/osmand/plus/OsmandSettings.java
index d8f6d57849..ef8dbc1a63 100644
--- a/OsmAnd/src/net/osmand/plus/OsmandSettings.java
+++ b/OsmAnd/src/net/osmand/plus/OsmandSettings.java
@@ -1,21 +1,15 @@
package net.osmand.plus;
-import java.io.File;
-import java.io.IOException;
-import java.lang.ref.WeakReference;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.Comparator;
-import java.util.Iterator;
-import java.util.LinkedHashMap;
-import java.util.LinkedHashSet;
-import java.util.LinkedList;
-import java.util.List;
-import java.util.Locale;
-import java.util.Map;
-import java.util.Set;
-import java.util.StringTokenizer;
+import android.annotation.TargetApi;
+import android.content.Context;
+import android.content.res.Configuration;
+import android.hardware.Sensor;
+import android.hardware.SensorManager;
+import android.net.ConnectivityManager;
+import android.net.NetworkInfo;
+import android.os.Build;
+import android.os.Environment;
import net.osmand.IndexConstants;
import net.osmand.StateChangedListener;
@@ -34,15 +28,22 @@ import net.osmand.plus.helpers.SearchHistoryHelper;
import net.osmand.plus.render.RendererRegistry;
import net.osmand.plus.routing.RouteProvider.RouteService;
import net.osmand.render.RenderingRulesStorage;
-import android.annotation.TargetApi;
-import android.content.Context;
-import android.content.res.Configuration;
-import android.hardware.Sensor;
-import android.hardware.SensorManager;
-import android.net.ConnectivityManager;
-import android.net.NetworkInfo;
-import android.os.Build;
-import android.os.Environment;
+
+import java.io.File;
+import java.io.IOException;
+import java.lang.ref.WeakReference;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Comparator;
+import java.util.Iterator;
+import java.util.LinkedHashMap;
+import java.util.LinkedHashSet;
+import java.util.LinkedList;
+import java.util.List;
+import java.util.Locale;
+import java.util.Map;
+import java.util.Set;
+import java.util.StringTokenizer;
public class OsmandSettings {
@@ -1072,6 +1073,8 @@ public class OsmandSettings {
public CommonPreference PREVIOUS_INSTALLED_VERSION = new StringPreference("previous_installed_version", "").makeGlobal();
+ public final OsmandPreference SHOULD_SHOW_FREE_VERSION_BANNER = new BooleanPreference("should_show_free_version_banner", false).makeGlobal().cache();
+
public ITileSource getMapTileSource(boolean warnWhenSelected) {
String tileName = MAP_TILE_SOURCES.get();
if (tileName != null) {
diff --git a/OsmAnd/src/net/osmand/plus/development/SettingsDevelopmentActivity.java b/OsmAnd/src/net/osmand/plus/development/SettingsDevelopmentActivity.java
index 81f49586b1..8c69d7e40c 100644
--- a/OsmAnd/src/net/osmand/plus/development/SettingsDevelopmentActivity.java
+++ b/OsmAnd/src/net/osmand/plus/development/SettingsDevelopmentActivity.java
@@ -1,6 +1,7 @@
package net.osmand.plus.development;
+import android.annotation.SuppressLint;
import android.app.AlertDialog;
import android.app.AlertDialog.Builder;
import android.content.Intent;
@@ -142,6 +143,7 @@ public class SettingsDevelopmentActivity extends SettingsBaseActivity {
final Preference agpspref = new Preference(this);
agpspref.setTitle(R.string.agps_info);
if (settings.AGPS_DATA_LAST_TIME_DOWNLOADED.get() != 0L) {
+ @SuppressLint("SimpleDateFormat")
SimpleDateFormat prt = new SimpleDateFormat("yyyy-MM-dd HH:mm");
agpspref.setSummary(getString(R.string.agps_data_last_downloaded, prt.format(settings.AGPS_DATA_LAST_TIME_DOWNLOADED.get())));
} else {
@@ -155,6 +157,7 @@ public class SettingsDevelopmentActivity extends SettingsBaseActivity {
public boolean onPreferenceClick(Preference preference) {
if(getMyApplication().getSettings().isInternetConnectionAvailable(true)) {
getMyApplication().getLocationProvider().redownloadAGPS();
+ @SuppressLint("SimpleDateFormat")
SimpleDateFormat prt = new SimpleDateFormat("yyyy-MM-dd HH:mm");
agpspref.setSummary(getString(R.string.agps_data_last_downloaded, prt.format(settings.AGPS_DATA_LAST_TIME_DOWNLOADED.get())));
}
@@ -167,6 +170,7 @@ public class SettingsDevelopmentActivity extends SettingsBaseActivity {
pref = new Preference(this);
pref.setTitle(R.string.day_night_info);
if (sunriseSunset != null) {
+ @SuppressLint("SimpleDateFormat")
SimpleDateFormat prt = new SimpleDateFormat("yyyy-MM-dd HH:mm");
pref.setSummary(getString(R.string.day_night_info_description, prt.format(sunriseSunset.getSunrise()),
prt.format(sunriseSunset.getSunset())));
@@ -176,7 +180,11 @@ public class SettingsDevelopmentActivity extends SettingsBaseActivity {
pref.setSelectable(false);
//setEnabled(false) creates bad readability on some devices
//pref.setEnabled(false);
- cat.addPreference(pref);
+ cat.addPreference(pref);
+
+ cat.addPreference(createCheckBoxPreference(settings.SHOULD_SHOW_FREE_VERSION_BANNER,
+ R.string.show_free_version_banner,
+ R.string.show_free_version_banner_description));
}
protected void availableProfileDialog() {
@@ -193,7 +201,7 @@ public class SettingsDevelopmentActivity extends SettingsBaseActivity {
StringBuilder vls = new StringBuilder(ApplicationMode.DEFAULT.getStringKey()+",");
for(ApplicationMode mode : modes) {
if(selected.contains(mode)) {
- vls.append(mode.getStringKey()+",");
+ vls.append(mode.getStringKey()).append(",");
}
}
settings.AVAILABLE_APP_MODES.set(vls.toString());
diff --git a/OsmAnd/src/net/osmand/plus/download/DownloadActivity.java b/OsmAnd/src/net/osmand/plus/download/DownloadActivity.java
index e54ab24e60..4979d31660 100644
--- a/OsmAnd/src/net/osmand/plus/download/DownloadActivity.java
+++ b/OsmAnd/src/net/osmand/plus/download/DownloadActivity.java
@@ -34,7 +34,6 @@ import net.osmand.plus.activities.TabActivity;
import net.osmand.plus.base.BasicProgressAsyncTask;
import net.osmand.plus.download.items.WorldItemsFragment;
import net.osmand.plus.download.newimplementation.IndexItemCategoryWithSubcat;
-import net.osmand.plus.download.newimplementation.NewLocalIndexesFragment;
import net.osmand.plus.srtmplugin.SRTMPlugin;
import net.osmand.plus.views.controls.PagerSlidingTabStrip;
@@ -321,24 +320,6 @@ public class DownloadActivity extends BaseDownloadActivity {
}
}
- @Override
- public void onCategorizationFinished(List filtered,
- List cats) {
- boolean isPushed = false;
- for (WeakReference ref : fragSet) {
- Fragment f = ref.get();
- if (f instanceof NewLocalIndexesFragment) {
- if (f.isAdded()) {
- isPushed = true;
- ((NewLocalIndexesFragment) f).onCategorizationFinished(filtered, cats);
- }
- }
- }
- if (!isPushed) {
- this.cats = cats;
- }
- }
-
@Override
public void onCategorizationFinished() {
for (WeakReference ref : fragSet) {
diff --git a/OsmAnd/src/net/osmand/plus/download/items/RegionDialogFragment.java b/OsmAnd/src/net/osmand/plus/download/items/RegionDialogFragment.java
index 46d6757edb..99808eaba8 100644
--- a/OsmAnd/src/net/osmand/plus/download/items/RegionDialogFragment.java
+++ b/OsmAnd/src/net/osmand/plus/download/items/RegionDialogFragment.java
@@ -72,14 +72,12 @@ public class RegionDialogFragment extends DialogFragment {
}
toolbar.setTitle(this.region.getName());
}
- DownloadsUiHelper.initFreeVersionBanner(view, getMyApplication().getSettings(),
+ DownloadsUiHelper.initFreeVersionBanner(view, getMyApplication(),
getResources());
- final WorldRegion finalRegion = region;
mProgressListener = new DownloadsUiHelper.MapDownloadListener(view, getResources()){
@Override
public void onProgressUpdate(int progressPercentage, int activeTasks) {
- LOG.debug(finalRegion.getName() + " onProgressUpdate()");
super.onProgressUpdate(progressPercentage, activeTasks);
}
@@ -87,7 +85,7 @@ public class RegionDialogFragment extends DialogFragment {
public void onFinished() {
super.onFinished();
DownloadsUiHelper.initFreeVersionBanner(view,
- getMyApplication().getSettings(), getResources());
+ getMyApplication(), getResources());
}
};
diff --git a/OsmAnd/src/net/osmand/plus/download/items/WorldItemsFragment.java b/OsmAnd/src/net/osmand/plus/download/items/WorldItemsFragment.java
index 00c1958e3a..4b86cc141b 100644
--- a/OsmAnd/src/net/osmand/plus/download/items/WorldItemsFragment.java
+++ b/OsmAnd/src/net/osmand/plus/download/items/WorldItemsFragment.java
@@ -61,7 +61,7 @@ public class WorldItemsFragment extends OsmandExpandableListFragment {
onCategorizationFinished();
DownloadsUiHelper.initFreeVersionBanner(view,
- getMyApplication().getSettings(), getResources());
+ getMyApplication(), getResources());
return view;
}
diff --git a/OsmAnd/src/net/osmand/plus/download/newimplementation/DownloadsUiHelper.java b/OsmAnd/src/net/osmand/plus/download/newimplementation/DownloadsUiHelper.java
index 21a18b3362..431f0b6e84 100644
--- a/OsmAnd/src/net/osmand/plus/download/newimplementation/DownloadsUiHelper.java
+++ b/OsmAnd/src/net/osmand/plus/download/newimplementation/DownloadsUiHelper.java
@@ -12,6 +12,7 @@ import android.view.View;
import android.widget.ProgressBar;
import android.widget.TextView;
+import net.osmand.plus.OsmandApplication;
import net.osmand.plus.OsmandSettings;
import net.osmand.plus.R;
import net.osmand.plus.Version;
@@ -22,8 +23,15 @@ public final class DownloadsUiHelper {
private DownloadsUiHelper() {
}
- public static void initFreeVersionBanner(View header, OsmandSettings settings,
+ public static void initFreeVersionBanner(View header, OsmandApplication application,
Resources resources) {
+ final View freeVersionBanner = header.findViewById(R.id.freeVersionBanner);
+ OsmandSettings settings = application.getSettings();
+ if(!Version.isFreeVersion(application) && !settings.SHOULD_SHOW_FREE_VERSION_BANNER.get()) {
+ freeVersionBanner.setVisibility(View.GONE);
+ return;
+ }
+
TextView downloadsLeftTextView = (TextView) header.findViewById(R.id.downloadsLeftTextView);
final int downloadsLeft = BaseDownloadActivity.MAXIMUM_AVAILABLE_FREE_DOWNLOADS
- settings.NUMBER_OF_FREE_DOWNLOADS.get();
@@ -35,8 +43,7 @@ public final class DownloadsUiHelper {
BaseDownloadActivity.MAXIMUM_AVAILABLE_FREE_DOWNLOADS));
final View buttonsLinearLayout = header.findViewById(R.id.buttonsLinearLayout);
-
- header.findViewById(R.id.freeVersionBanner).setOnClickListener(
+ freeVersionBanner.setOnClickListener(
new ToggleCollapseFreeVersionBanner(freeVersionDescriptionTextView,
buttonsLinearLayout));
diff --git a/OsmAnd/src/net/osmand/plus/download/newimplementation/MapsInCategoryFragment.java b/OsmAnd/src/net/osmand/plus/download/newimplementation/MapsInCategoryFragment.java
deleted file mode 100644
index 742ad022b8..0000000000
--- a/OsmAnd/src/net/osmand/plus/download/newimplementation/MapsInCategoryFragment.java
+++ /dev/null
@@ -1,104 +0,0 @@
-package net.osmand.plus.download.newimplementation;
-
-import android.os.Bundle;
-import android.support.annotation.NonNull;
-import android.support.v4.app.DialogFragment;
-import android.support.v7.widget.Toolbar;
-import android.view.LayoutInflater;
-import android.view.View;
-import android.view.ViewGroup;
-
-import net.osmand.PlatformUtil;
-import net.osmand.plus.OsmandApplication;
-import net.osmand.plus.OsmandSettings;
-import net.osmand.plus.R;
-import net.osmand.plus.download.DownloadActivity;
-
-import org.apache.commons.logging.Log;
-
-public class MapsInCategoryFragment extends DialogFragment {
- private static final Log LOG = PlatformUtil.getLog(IndexItemCategoryWithSubcat.class);
- public static final String TAG = "MapsInCategoryFragment";
- private static final String CATEGORY = "category";
- private DownloadsUiHelper.MapDownloadListener mProgressListener;
-
- @Override
- public void onCreate(Bundle savedInstanceState) {
- super.onCreate(savedInstanceState);
- boolean isLightTheme = ((OsmandApplication) getActivity().getApplication())
- .getSettings().OSMAND_THEME.get() == OsmandSettings.OSMAND_LIGHT_THEME;
- int themeId = isLightTheme ? R.style.OsmandLightTheme : R.style.OsmandDarkTheme;
- setStyle(STYLE_NO_FRAME, themeId);
- }
-
- @Override
- public View onCreateView(LayoutInflater inflater, ViewGroup container,
- Bundle savedInstanceState) {
- final View view = inflater.inflate(R.layout.maps_in_category_fragment, container, false);
-
- IndexItemCategoryWithSubcat category = getArguments().getParcelable(CATEGORY);
- assert category != null;
- getChildFragmentManager().beginTransaction().add(R.id.fragmentContainer,
- SubcategoriesFragment.createInstance(category)).commit();
-
- Toolbar toolbar = (Toolbar) view.findViewById(R.id.toolbar);
- toolbar.setTitle(category.getName());
- toolbar.setNavigationIcon(R.drawable.abc_ic_ab_back_mtrl_am_alpha);
- toolbar.setNavigationOnClickListener(new View.OnClickListener() {
- @Override
- public void onClick(View v) {
- dismiss();
- }
- });
-
- DownloadsUiHelper.initFreeVersionBanner(view,
- getMyActivity().getMyApplication().getSettings(), getResources());
- mProgressListener = new DownloadsUiHelper.MapDownloadListener(view, getResources()){
- @Override
- public void onFinished() {
- super.onFinished();
- DownloadsUiHelper.initFreeVersionBanner(view,
- getMyActivity().getMyApplication().getSettings(), getResources());
- }
- };
- view.findViewById(R.id.downloadProgressLayout).setOnClickListener(new View.OnClickListener() {
- @Override
- public void onClick(View v) {
-
- }
- });
- return view;
- }
-
- @Override
- public void onResume() {
- super.onResume();
- getMyActivity().setOnProgressUpdateListener(mProgressListener);
- }
-
- @Override
- public void onPause() {
- super.onPause();
- getMyActivity().setOnProgressUpdateListener(null);
- }
-
- private DownloadActivity getMyActivity() {
- return (DownloadActivity) getActivity();
- }
-
- public void onCategorySelected(@NonNull IndexItemCategoryWithSubcat category) {
- LOG.debug("onCategorySelected()");
- createInstance(category).show(getChildFragmentManager(), TAG);
- }
-
- public static MapsInCategoryFragment createInstance(
- @NonNull IndexItemCategoryWithSubcat category) {
- Bundle bundle = new Bundle();
- bundle.putParcelable(CATEGORY, category);
- MapsInCategoryFragment fragment = new MapsInCategoryFragment();
- fragment.setArguments(bundle);
- return fragment;
- }
-
-
-}
diff --git a/OsmAnd/src/net/osmand/plus/download/newimplementation/NewLocalIndexesFragment.java b/OsmAnd/src/net/osmand/plus/download/newimplementation/NewLocalIndexesFragment.java
deleted file mode 100644
index a5cad2f7fa..0000000000
--- a/OsmAnd/src/net/osmand/plus/download/newimplementation/NewLocalIndexesFragment.java
+++ /dev/null
@@ -1,180 +0,0 @@
-package net.osmand.plus.download.newimplementation;
-
-import android.content.Context;
-import android.graphics.drawable.Drawable;
-import android.os.Bundle;
-import android.os.StatFs;
-import android.support.v4.app.FragmentTransaction;
-import android.support.v4.view.MenuItemCompat;
-import android.text.Html;
-import android.text.method.LinkMovementMethod;
-import android.view.LayoutInflater;
-import android.view.Menu;
-import android.view.MenuInflater;
-import android.view.MenuItem;
-import android.view.View;
-import android.view.ViewGroup;
-import android.widget.ArrayAdapter;
-import android.widget.ListView;
-import android.widget.ProgressBar;
-import android.widget.TextView;
-
-import net.osmand.PlatformUtil;
-import net.osmand.plus.OsmandApplication;
-import net.osmand.plus.R;
-import net.osmand.plus.activities.OsmAndListFragment;
-import net.osmand.plus.download.DownloadActivity;
-import net.osmand.plus.download.IndexItem;
-
-import org.apache.commons.logging.Log;
-
-import java.io.File;
-import java.text.MessageFormat;
-import java.util.ArrayList;
-import java.util.List;
-import java.util.Locale;
-
-
-public class NewLocalIndexesFragment extends OsmAndListFragment {
- private static final Log LOG = PlatformUtil.getLog(NewLocalIndexesFragment.class);
- public static final String CATEGORIES = "categories";
- private static final MessageFormat formatGb = new MessageFormat("{0, number,#.##} GB", Locale.US);
-
- public static final int RELOAD_ID = 0;
- private CategoriesAdapter mAdapter;
-
- @Override
- public void onCreate(Bundle savedInstanceState) {
- super.onCreate(savedInstanceState);
- setHasOptionsMenu(true);
- }
-
- @Override
- public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
- View view = inflater.inflate(R.layout.local_index_fragment, container, false);
-
- ListView listView = (ListView) view.findViewById(android.R.id.list);
- mAdapter = new CategoriesAdapter(getActivity(), getMyApplication());
- listView.setAdapter(mAdapter);
-
- List cats = ((DownloadActivity) getActivity()).getCats();
- if (cats != null) {
- onCategorizationFinished(null, cats);
- }
- if (savedInstanceState != null) {
- List savedCats =
- savedInstanceState.getParcelableArrayList(CATEGORIES);
- onCategorizationFinished(null, savedCats);
- }
-
- View header = inflater.inflate(R.layout.local_index_fragment_header, listView, false);
- initMemoryConsumedCard(header);
- DownloadsUiHelper.initFreeVersionBanner(header, getMyApplication().getSettings(),
- getResources());
- listView.addHeaderView(header);
-
- getDownloadActivity().setSupportProgressBarIndeterminateVisibility(false);
- return view;
- }
-
- private void initMemoryConsumedCard(View header) {
- ProgressBar sizeProgress = (ProgressBar) header.findViewById(R.id.progressBar);
- File dir = getMyApplication().getAppPath("").getParentFile();
- String size = formatGb.format(new Object[]{0});
- int percent = 0;
- if (dir.canRead()) {
- StatFs statFs = new StatFs(dir.getAbsolutePath());
- //noinspection deprecation
- size = formatGb.format(new Object[]{(float) (statFs.getAvailableBlocks()) * statFs.getBlockSize() / (1 << 30)});
- //noinspection deprecation
- percent = statFs.getAvailableBlocks() * 100 / statFs.getBlockCount();
- }
- sizeProgress.setProgress(percent);
- String text = getString(R.string.free, size);
-
- TextView descriptionText = (TextView) header.findViewById(R.id.rightTextView);
- descriptionText.setText(Html.fromHtml(text));
- descriptionText.setMovementMethod(LinkMovementMethod.getInstance());
-
- ((TextView) header.findViewById(R.id.leftTextView)).setText(R.string.device_memory);
- }
-
- @Override
- public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
- MenuItem item = menu.add(0, RELOAD_ID, 0, R.string.shared_string_refresh);
- item.setIcon(R.drawable.ic_action_refresh_dark);
- MenuItemCompat.setShowAsAction(item, MenuItemCompat.SHOW_AS_ACTION_ALWAYS);
- }
-
- @Override
- public boolean onOptionsItemSelected(MenuItem item) {
- if (item.getItemId() == RELOAD_ID) {
- // re-create the thread
- DownloadActivity.downloadListIndexThread.runReloadIndexFiles();
- return true;
- }
- return super.onOptionsItemSelected(item);
- }
-
- @Override
- public void onSaveInstanceState(Bundle outState) {
- LOG.debug("onSaveInstanceState()");
- ArrayList items = new ArrayList<>(mAdapter.getCount());
- for (int i = 0; i < mAdapter.getCount(); i++) {
- items.add(mAdapter.getItem(i));
- }
- outState.putParcelableArrayList(CATEGORIES, items);
- super.onSaveInstanceState(outState);
- }
-
- @Override
- public void onListItemClick(ListView l, View v, int position, long id) {
- FragmentTransaction fragmentTransaction = getChildFragmentManager().beginTransaction();
- fragmentTransaction.addToBackStack(null);
- MapsInCategoryFragment.createInstance(mAdapter.getItem(position - 1))
- .show(fragmentTransaction, MapsInCategoryFragment.TAG);
- }
-
- private DownloadActivity getDownloadActivity() {
- return (DownloadActivity) getActivity();
- }
-
- public void onCategorizationFinished(List filtered, List cats) {
- if (mAdapter != null) {
- mAdapter.clear();
- mAdapter.addAll(cats);
- }
- }
-
- private static class CategoriesAdapter extends ArrayAdapter {
- private final OsmandApplication osmandApplication;
-
- public CategoriesAdapter(Context context, OsmandApplication osmandApplication) {
- super(context, R.layout.simple_list_menu_item);
- this.osmandApplication = osmandApplication;
- }
-
- @Override
- public View getView(int position, View convertView, ViewGroup parent) {
- ViewHolder viewHolder;
- if (convertView == null) {
- convertView = LayoutInflater.from(parent.getContext())
- .inflate(R.layout.simple_list_menu_item, parent, false);
- viewHolder = new ViewHolder();
- viewHolder.textView = (TextView) convertView.findViewById(R.id.title);
- convertView.setTag(viewHolder);
- } else {
- viewHolder = (ViewHolder) convertView.getTag();
- }
- Drawable iconLeft = osmandApplication.getIconsCache()
- .getContentIcon(R.drawable.ic_world_globe_dark);
- viewHolder.textView.setCompoundDrawablesWithIntrinsicBounds(iconLeft, null, null, null);
- viewHolder.textView.setText(getItem(position).categoryStaticData.getName());
- return convertView;
- }
-
- private static class ViewHolder {
- TextView textView;
- }
- }
-}
diff --git a/OsmAnd/src/net/osmand/plus/download/newimplementation/SubcategoriesFragment.java b/OsmAnd/src/net/osmand/plus/download/newimplementation/SubcategoriesFragment.java
deleted file mode 100644
index fcdd1ca970..0000000000
--- a/OsmAnd/src/net/osmand/plus/download/newimplementation/SubcategoriesFragment.java
+++ /dev/null
@@ -1,167 +0,0 @@
-package net.osmand.plus.download.newimplementation;
-
-import android.content.Context;
-import android.content.res.Resources;
-import android.graphics.drawable.Drawable;
-import android.os.Bundle;
-import android.support.annotation.NonNull;
-import android.support.annotation.Nullable;
-import android.support.v4.app.Fragment;
-import android.view.LayoutInflater;
-import android.view.View;
-import android.view.ViewGroup;
-import android.widget.AdapterView;
-import android.widget.ArrayAdapter;
-import android.widget.ImageView;
-import android.widget.ListView;
-import android.widget.ProgressBar;
-import android.widget.TextView;
-
-import net.osmand.plus.OsmandApplication;
-import net.osmand.plus.R;
-import net.osmand.plus.download.BaseDownloadActivity;
-import net.osmand.plus.download.DownloadActivity;
-import net.osmand.plus.download.DownloadActivityType;
-import net.osmand.plus.download.IndexItem;
-import net.osmand.plus.helpers.HasName;
-
-public class SubcategoriesFragment extends Fragment {
- private static final String CATEGORY = "category";
-
- @Nullable
- @Override
- public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
- IndexItemCategoryWithSubcat category = getArguments().getParcelable(CATEGORY);
- assert category != null;
-
- ListView listView = new ListView(getActivity());
- final OsmandApplication application = (OsmandApplication) getActivity().getApplication();
- final MapFilesAdapter mAdapter = new MapFilesAdapter(getActivity(),
- (MapsInCategoryFragment) getParentFragment());
- listView.setAdapter(mAdapter);
- mAdapter.addAll(category.items);
- mAdapter.addAll(category.subcats);
-
- listView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
- @Override
- public void onItemClick(AdapterView> parent, View view, int position, long id) {
- final HasName item = mAdapter.getItem(position);
- if (item instanceof IndexItemCategoryWithSubcat) {
- ((MapsInCategoryFragment) getParentFragment())
- .onCategorySelected((IndexItemCategoryWithSubcat) item);
- }
- }
- });
-
- return listView;
- }
-
- public static SubcategoriesFragment createInstance(
- @NonNull IndexItemCategoryWithSubcat category) {
- Bundle bundle = new Bundle();
- bundle.putParcelable(CATEGORY, category);
- SubcategoriesFragment fragment = new SubcategoriesFragment();
- fragment.setArguments(bundle);
- return fragment;
- }
-
-
- private static class MapFilesAdapter extends ArrayAdapter {
- final MapsInCategoryFragment fragment;
-
- public MapFilesAdapter(Context context, MapsInCategoryFragment fragment) {
- super(context, R.layout.two_line_with_images_list_item);
- this.fragment = fragment;
- }
-
- @Override
- public View getView(int position, View convertView, ViewGroup parent) {
- ViewHolder viewHolder;
- if (convertView == null) {
- convertView = LayoutInflater.from(parent.getContext())
- .inflate(R.layout.two_line_with_images_list_item, parent, false);
- viewHolder = new ViewHolder(convertView);
- convertView.setTag(viewHolder);
- } else {
- viewHolder = (ViewHolder) convertView.getTag();
- }
- HasName item = getItem(position);
- if (item instanceof IndexItemCategoryWithSubcat) {
- viewHolder.bindCategory((IndexItemCategoryWithSubcat) item,
- (DownloadActivity) getContext());
- } else if (item instanceof IndexItem) {
- viewHolder.bindIndexItem((IndexItem) item, (DownloadActivity) getContext(),
- fragment);
- } else {
- throw new IllegalArgumentException("Item must be of type IndexItem or " +
- "IndexItemCategory but is of type:" + item.getClass());
- }
- return convertView;
- }
-
- private static class ViewHolder {
- private final TextView nameTextView;
- private final TextView descrTextView;
- private final ImageView leftImageView;
- private final ImageView rightImageButton;
- private final ProgressBar progressBar;
-
- public ViewHolder(View convertView) {
- nameTextView = (TextView) convertView.findViewById(R.id.name);
- descrTextView = (TextView) convertView.findViewById(R.id.description);
- leftImageView = (ImageView) convertView.findViewById(R.id.leftImageView);
- rightImageButton = (ImageView) convertView.findViewById(R.id.rightImageButton);
- progressBar = (ProgressBar) convertView.findViewById(R.id.progressBar);
- }
-
- public void bindIndexItem(final IndexItem indexItem, final DownloadActivity context,
- MapsInCategoryFragment fragment) {
- if (indexItem.getType() == DownloadActivityType.VOICE_FILE) {
- nameTextView.setText(indexItem.getVisibleName(context,
- context.getMyApplication().getRegions()));
- } else {
- nameTextView.setText(indexItem.getType().getString(context));
- }
- descrTextView.setText(indexItem.getSizeDescription(context));
- leftImageView.setImageDrawable(getContextIcon(context,
- indexItem.getType().getIconResource()));
- rightImageButton.setVisibility(View.VISIBLE);
- rightImageButton.setImageDrawable(getContextIcon(context,
- R.drawable.ic_action_import));
- rightImageButton.setTag(R.id.index_item, indexItem);
- rightImageButton.setOnClickListener(new View.OnClickListener() {
- @Override
- public void onClick(View v) {
- ((BaseDownloadActivity) v.getContext())
- .startDownload((IndexItem) v.getTag(R.id.index_item));
- }
- });
- progressBar.setVisibility(View.GONE);
- }
-
- public void bindCategory(IndexItemCategoryWithSubcat category,
- DownloadActivity context) {
- nameTextView.setText(category.getName());
- if (category.types.size() > 0) {
- StringBuilder stringBuilder = new StringBuilder();
- Resources resources = context.getResources();
- for (Integer mapType : category.types) {
- stringBuilder.append(resources.getString(mapType));
- stringBuilder.append(", ");
- }
- stringBuilder.delete(stringBuilder.length() - 2, stringBuilder.capacity());
- descrTextView.setText(stringBuilder.toString());
- } else {
- descrTextView.setText(R.string.shared_string_others);
- }
- leftImageView.setImageDrawable(getContextIcon(context, R.drawable.ic_map));
- rightImageButton.setVisibility(View.GONE);
- progressBar.setVisibility(View.GONE);
- }
-
- private Drawable getContextIcon(DownloadActivity context, int resourceId) {
- return context.getMyApplication().getIconsCache().getContentIcon(resourceId);
- }
- }
- }
-}