Downdload map design in progress. Working sorting. Downloading is now trigger by onItemClick(no visual feedback yet). Hillshades are now grouped correctly.

This commit is contained in:
GaidamakUA 2015-09-28 19:11:18 +03:00
parent f13f84a850
commit 9d0ee20906
38 changed files with 131 additions and 112 deletions

View file

@ -110,7 +110,7 @@
android:gravity="center"/>
<Button
android:id="@+id/DownloadButton"
android:id="@+id/downloadButton"
android:layout_width="0dp"
android:layout_height="@dimen/list_item_height"
android:layout_weight="1"
@ -120,7 +120,7 @@
android:textColor="?attr/pstsTextColor"/>
<ImageView
android:id="@+id/WikiButton"
android:id="@+id/wikiButton"
android:layout_width="@dimen/list_item_height"
android:layout_height="@dimen/list_item_height"
android:scaleType="centerInside"

View file

@ -15,7 +15,7 @@
android:paddingLeft="@dimen/list_content_padding">
<ImageView
android:id="@+id/leftIcon"
android:id="@+id/leftImageView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
@ -52,7 +52,7 @@
</LinearLayout>
<ImageButton
android:id="@+id/rightIcon"
android:id="@+id/rightImageButton"
android:layout_width="@dimen/list_item_height"
android:layout_height="@dimen/list_item_height"
android:layout_gravity="center_vertical"

View file

@ -736,7 +736,7 @@
<string name="favorite_home_category">Дом</string>
<string name="favorite_friends_category">Сябры</string>
<string name="favorite_places_category">Месцы</string>
<string name="favorite_default_category">Іншае</string>
<string name="shared_string_others">Іншае</string>
<string name="favourites_edit_dialog_name">Назва</string>
<string name="favourites_edit_dialog_category">Катэгорыя</string>
<string name="shared_string_no_thanks">Не, дзякуй</string>

View file

@ -947,7 +947,7 @@ OsmAnd е с отворен код и активно да се развива.
<string name="favorite_home_category">Дом</string>
<string name="favorite_friends_category">Приятели</string>
<string name="favorite_places_category">Места</string>
<string name="favorite_default_category">Други</string>
<string name="shared_string_others">Други</string>
<string name="favourites_edit_dialog_name">Име</string>
<string name="favourites_edit_dialog_category">Категория</string>
<string name="shared_string_no_thanks">Не, благодаря</string>

View file

@ -302,7 +302,7 @@
<string name="favourites_delete_multiple_succesful">S\'ha suprimit amb èxit el(s) punt(s) preferit(s).</string>
<string name="favorite_friends_category">Amics</string>
<string name="favorite_places_category">Llocs</string>
<string name="favorite_default_category">Altres</string>
<string name="shared_string_others">Altres</string>
<string name="favourites_edit_dialog_name">Nom</string>
<string name="favourites_edit_dialog_category">Categoria</string>

View file

@ -253,7 +253,7 @@
<string name="favorite_home_category">Doma</string>
<string name="favorite_friends_category">Přátelé</string>
<string name="favorite_places_category">Místa</string>
<string name="favorite_default_category">Ostatní</string>
<string name="shared_string_others">Ostatní</string>
<string name="shared_string_no_thanks">Není potřeba</string>
<string name="basemap_missing">Chybí základní mapa světa. Prosím stáhněte ji pro správnou funkci programu.</string>
<string name="vector_data_missing">Na SD kartě nejsou uložena žádná offline data. Prosím stáhněte je pro použití map v offline módu.</string>

View file

@ -554,7 +554,7 @@
<string name="favorite_home_category">Hjem</string>
<string name="favorite_friends_category">Venner</string>
<string name="favorite_places_category">Steder</string>
<string name="favorite_default_category">Andre</string>
<string name="shared_string_others">Andre</string>
<string name="favourites_edit_dialog_name">Navn</string>
<string name="favourites_edit_dialog_category">Kategori</string>
<string name="shared_string_no_thanks">Nej tak</string>

View file

@ -619,7 +619,7 @@
<string name="favorite_home_category">Zu Hause</string>
<string name="favorite_friends_category">Freunde</string>
<string name="favorite_places_category">Sehenswertes</string>
<string name="favorite_default_category">Andere</string>
<string name="shared_string_others">Andere</string>
<string name="favourites_edit_dialog_name">Name</string>
<string name="favourites_edit_dialog_category">Kategorie</string>
<string name="shared_string_no_thanks">Nicht verwendet</string>

View file

@ -1434,7 +1434,7 @@
<string name="favorite_home_category">Inicio</string>
<string name="favorite_friends_category">Amigos</string>
<string name="favorite_places_category">Lugares</string>
<string name="favorite_default_category">Otros</string>
<string name="shared_string_others">Otros</string>
<string name="favourites_edit_dialog_name">Nombre</string>
<string name="favourites_edit_dialog_category">Categoría</string>
<string name="shared_string_no_thanks">No, gracias</string>

View file

@ -183,7 +183,7 @@
<string name="favorite_home_category">Inicio</string>
<string name="favorite_friends_category">Amigos</string>
<string name="favorite_places_category">Lugares</string>
<string name="favorite_default_category">Otros</string>
<string name="shared_string_others">Otros</string>
<string name="favourites_edit_dialog_name">Nombre</string>
<string name="favourites_edit_dialog_category">Categoría</string>
<string name="shared_string_no_thanks">No, gracias</string>

View file

@ -217,7 +217,7 @@
<string name="favorite_home_category">Koti</string>
<string name="favorite_friends_category">Ystävät</string>
<string name="favorite_places_category">Paikat</string>
<string name="favorite_default_category">Muut</string>
<string name="shared_string_others">Muut</string>
<string name="favourites_edit_dialog_name">Nimi</string>
<string name="favourites_edit_dialog_category">Kategoria</string>
<string name="shared_string_no_thanks">Ei kiitos</string>

View file

@ -178,7 +178,7 @@
<string name="favorite_home_category">Domicile</string>
<string name="favorite_friends_category">Amis</string>
<string name="favorite_places_category">Lieux</string>
<string name="favorite_default_category">Autres</string>
<string name="shared_string_others">Autres</string>
<string name="shared_string_no_thanks">Pas nécessaire</string>
<string name="basemap_missing">La carte mondiale de base est absente (couvrant le monde entier à faible zoom). Pensez à télécharger World_basemap_x.obf pour avoir un environnement complet.</string>
<string name="vector_data_missing">Il n\'y a pas de cartes (\'hors-ligne\') sur la carte SD. Pensez à en télécharger pour utiliser OsmAnd hors-ligne.</string>

View file

@ -232,7 +232,7 @@
<string name="favorite_home_category">Család</string>
<string name="favorite_friends_category">Barátok</string>
<string name="favorite_places_category">Helyek</string>
<string name="favorite_default_category">Egyéb</string>
<string name="shared_string_others">Egyéb</string>
<string name="favourites_edit_dialog_name">Név</string>
<string name="favourites_edit_dialog_category">Kategória</string>
<string name="shared_string_no_thanks">Nem szükséges</string>

View file

@ -168,7 +168,7 @@
<string name="favorite_home_category">Casa</string>
<string name="favorite_friends_category">Amici</string>
<string name="favorite_places_category">Luoghi</string>
<string name="favorite_default_category">Altro</string>
<string name="shared_string_others">Altro</string>
<string name="shared_string_no_thanks">No, grazie</string>
<string name="basemap_missing">La mappa di base del mondo (ricopre l\'intero mondo per zoom bassi) è mancante. Puoi scaricare World_basemap_x.obf per un sistema completo.</string>
<string name="vector_data_missing">Mancano i dati (\'offline\') nella scheda SD. Ti consigliamo di scaricarli per poter usare le mappe offline.</string>

View file

@ -1236,7 +1236,7 @@ POIの更新は利用できません</string>
<string name="favorite_home_category">自宅</string>
<string name="favorite_friends_category">友人宅</string>
<string name="favorite_places_category">場所</string>
<string name="favorite_default_category">その他</string>
<string name="shared_string_others">その他</string>
<string name="favourites_edit_dialog_name">名前</string>
<string name="favourites_edit_dialog_category">カテゴリー</string>
<string name="shared_string_no_thanks">必要ありません</string>

View file

@ -262,7 +262,7 @@
<string name="favorite_home_category"></string>
<string name="favorite_friends_category">친구</string>
<string name="favorite_places_category">장소</string>
<string name="favorite_default_category">기타</string>
<string name="shared_string_others">기타</string>
<string name="favourites_edit_dialog_name">이름</string>
<string name="favourites_edit_dialog_category">카테고리</string>

View file

@ -369,7 +369,7 @@
<string name="favorite_home_category">Namai</string>
<string name="favorite_friends_category">Draugai</string>
<string name="favorite_places_category">Vietos</string>
<string name="favorite_default_category">Kitos</string>
<string name="shared_string_others">Kitos</string>
<string name="favourites_edit_dialog_name">Pavadinimas</string>
<string name="favourites_edit_dialog_category">Kategorija</string>
<string name="shared_string_no_thanks">Ačiū, ne</string>

View file

@ -239,7 +239,7 @@
<string name="favorite_home_category">Mājas</string>
<string name="favorite_friends_category">Draugi</string>
<string name="favorite_places_category">Vietas</string>
<string name="favorite_default_category">Pārējais</string>
<string name="shared_string_others">Pārējais</string>
<string name="favourites_edit_dialog_name">Nosaukums</string>
<string name="favourites_edit_dialog_category">Kategorija</string>
<string name="shared_string_no_thanks">Nē, paldies</string>

View file

@ -125,7 +125,7 @@
<string name="favorite_home_category">घर</string>
<string name="favorite_friends_category">मित्र</string>
<string name="favorite_places_category">ठिकाणे</string>
<string name="favorite_default_category">इतर</string>
<string name="shared_string_others">इतर</string>
<string name="favourites_edit_dialog_name">नाव</string>
<string name="favourites_edit_dialog_category">वर्गीकरण</string>
<string name="shared_string_no_thanks">नाही, धन्यवाद</string>

View file

@ -72,7 +72,7 @@
<string name="favorite_home_category">Dom</string>
<string name="favorite_friends_category">Znajomi</string>
<string name="favorite_places_category">Miejsca</string>
<string name="favorite_default_category">Inne</string>
<string name="shared_string_others">Inne</string>
<string name="shared_string_no_thanks">Niepotrzebne</string>
<string name="basemap_missing">Podstawowa mapa świata jest niezainstalowana. Pobierz plik World_basemap_x.obf.</string>
<string name="vector_data_missing">Brak danych (\'offline\') w urządzeniu na karcie SD. Musisz je najpierw pobrać, by używać map offline.</string>

View file

@ -1263,7 +1263,7 @@
<string name="favorite_delete_multiple">Você apagará %1$d favorito(s) e %2$d grupo(s) favorito(s). Continuar?</string>
<string name="favorite_friends_category">Amigos</string>
<string name="favorite_places_category">Lugares</string>
<string name="favorite_default_category">Outros</string>
<string name="shared_string_others">Outros</string>
<string name="favourites_edit_dialog_name">Nome</string>
<string name="favourites_edit_dialog_category">Categori­a</string>
<string name="shared_string_no_thanks">Não, obrigado</string>

View file

@ -301,7 +301,7 @@
<string name="favorite_home_category">Дом</string>
<string name="favorite_friends_category">Друзья</string>
<string name="favorite_places_category">Места</string>
<string name="favorite_default_category">Другое</string>
<string name="shared_string_others">Другое</string>
<string name="shared_string_no_thanks">Не нужно</string>
<string name="basemap_missing">Отсутствует базовая карта, покрывающая весь мир на мелком масштабе. Пожалуйста загрузите World_basemap_x.obf для полноценный работы приложения.</string>
<string name="vector_data_missing">Локальные данные отсутствуют на SD-карте. Пожалуйста, загрузите их для того, чтобы использовать приложение без Интернета.</string>

View file

@ -1151,7 +1151,7 @@
<string name="favorite_home_category">Domo</string>
<string name="favorite_friends_category">Amigos</string>
<string name="favorite_places_category">Logos</string>
<string name="favorite_default_category">Àteru</string>
<string name="shared_string_others">Àteru</string>
<string name="favourites_edit_dialog_name">Nùmene</string>
<string name="favourites_edit_dialog_category">Categoria</string>
<string name="shared_string_no_thanks">No, gràtzias</string>

View file

@ -347,7 +347,7 @@
<string name="favorite_home_category">Doma</string>
<string name="favorite_friends_category">Priatelia</string>
<string name="favorite_places_category">Miesta</string>
<string name="favorite_default_category">Iné</string>
<string name="shared_string_others">Iné</string>
<string name="shared_string_no_thanks">Netreba</string>
<string name="basemap_missing">Chýba základná mapa sveta(World Basemap). Prosím, zvážte jej stiahnutie pre správnu funkčnosť.</string>
<string name="vector_data_missing">Na SD karte chýbajú offline údaje. Prosím, zvážte ich stiahnutie pre použitie máp bez internetu.</string>

View file

@ -508,7 +508,7 @@
<string name="favorite_friends_category">Naslovi prijateljev</string>
<string name="favourites_edit_dialog_name">Naziv</string>
<string name="favourites_edit_dialog_category">Skupina</string>
<string name="favorite_default_category">Druge točke</string>
<string name="shared_string_others">Druge točke</string>
<string name="favorite_home_category">Domači naslovi</string>
<string name="favorite_places_category">Priljubljeni kraji</string>
<string name="favorite_delete_multiple">Izbrisane bodo priljubljene točke (%1$d) in skupine (%2$d). Ali ste prepričani, da želite nadaljevati?</string>

View file

@ -273,7 +273,7 @@
<string name="favourites_delete_multiple_succesful">Омиљена тачка(е) је успешно избрисана.</string>
<string name="favorite_friends_category">Пријатељи</string>
<string name="favorite_places_category">Места</string>
<string name="favorite_default_category">Остало</string>
<string name="shared_string_others">Остало</string>
<string name="favourites_edit_dialog_name">Име</string>
<string name="favourites_edit_dialog_category">Врста</string>
<string name="shared_string_no_thanks">Не, хвала</string>

View file

@ -434,7 +434,7 @@
<string name="favorite_home_category">Hem</string>
<string name="favorite_friends_category">Vänner</string>
<string name="favorite_places_category">Platser</string>
<string name="favorite_default_category">Annat</string>
<string name="shared_string_others">Annat</string>
<string name="favourites_edit_dialog_name">Namn</string>
<string name="favourites_edit_dialog_category">Kategori</string>
<string name="shared_string_no_thanks">Nej, tack</string>

View file

@ -66,7 +66,7 @@ Translator: Le Viet Thanh; email: lethanhx2k@gmail.com --><resources>
<string name="favorite_home_category">Nhà</string>
<string name="favorite_friends_category">Bạn bè</string>
<string name="favorite_places_category">Địa điểm</string>
<string name="favorite_default_category">Khác</string>
<string name="shared_string_others">Khác</string>
<string name="shared_string_no_thanks">Không cần</string>
<string name="basemap_missing">Bản đồ nền (bao phủ toàn bộ thế giới ở tỉ lệ xem nhỏ) bị thiếu. Hãy tải về tập tin World_basemap_x.obf để bổ sung đầy đủ.</string>

View file

@ -427,7 +427,7 @@
<string name="favorite_home_category">住家</string>
<string name="favorite_friends_category">朋友</string>
<string name="favorite_places_category">地點</string>
<string name="favorite_default_category">其它</string>
<string name="shared_string_others">其它</string>
<string name="favourites_edit_dialog_name">名稱</string>
<string name="favourites_edit_dialog_category">類別</string>
<string name="shared_string_no_thanks">不需要,謝謝</string>

View file

@ -1468,7 +1468,7 @@ Afghanistan, Albania, Algeria, Andorra, Angola, Anguilla, Antigua and Barbuda, A
<string name="favorite_home_category">Home</string>
<string name="favorite_friends_category">Friends</string>
<string name="favorite_places_category">Places</string>
<string name="favorite_default_category">Others</string>
<string name="shared_string_others">Others</string>
<string name="favourites_edit_dialog_name">Name</string>
<string name="favourites_edit_dialog_category">Category</string>
<string name="shared_string_no_thanks">No, thanks</string>

View file

@ -559,7 +559,7 @@ public class FavouritesDbHelper {
addEmptyCategory(context.getString(R.string.favorite_home_category));
addEmptyCategory(context.getString(R.string.favorite_friends_category));
addEmptyCategory(context.getString(R.string.favorite_places_category));
addEmptyCategory(context.getString(R.string.favorite_default_category));
addEmptyCategory(context.getString(R.string.shared_string_others));
}
private FavoriteGroup getOrCreateGroup(FavouritePoint p, int defColor) {

View file

@ -142,7 +142,7 @@ public class DownloadActivity extends BaseDownloadActivity {
}
});
findViewById(R.id.DownloadButton).setOnClickListener(new View.OnClickListener() {
findViewById(R.id.downloadButton).setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
@ -150,7 +150,7 @@ public class DownloadActivity extends BaseDownloadActivity {
}
});
findViewById(R.id.WikiButton).setOnClickListener(new View.OnClickListener() {
findViewById(R.id.wikiButton).setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
@ -423,7 +423,7 @@ public class DownloadActivity extends BaseDownloadActivity {
} else {
BasicProgressAsyncTask<?, ?, ?> task = DownloadActivity.downloadListIndexThread.getCurrentRunningTask();
boolean running = task instanceof DownloadIndexesThread.DownloadIndexesAsyncTask;
((Button) findViewById(R.id.DownloadButton)).setEnabled(!running);
((Button) findViewById(R.id.downloadButton)).setEnabled(!running);
String text;
int downloads = DownloadActivity.downloadListIndexThread.getDownloads();
if (!running) {
@ -441,9 +441,9 @@ public class DownloadActivity extends BaseDownloadActivity {
text += " (" + (excessLimit ? "! " : "") + getString(R.string.files_limit, left).toLowerCase() + ")";
}
}
((Button) findViewById(R.id.DownloadButton)).setText(text);
((Button) findViewById(R.id.downloadButton)).setText(text);
List<IndexItem> wikipediaItems = getWikipediaItems();
findViewById(R.id.WikiButton).setVisibility(wikipediaItems.size() == 0 ? View.GONE : View.VISIBLE);
findViewById(R.id.wikiButton).setVisibility(wikipediaItems.size() == 0 ? View.GONE : View.VISIBLE);
}
for (WeakReference<Fragment> ref : fragList) {

View file

@ -251,9 +251,8 @@ public class DownloadActivityType implements Parcelable {
}
public String getVisibleName(IndexItem indexItem, Context ctx, OsmandRegions osmandRegions) {
String fileName = indexItem.fileName;
if (this == VOICE_FILE) {
String fileName = indexItem.fileName;
if (fileName.endsWith(IndexConstants.VOICE_INDEX_EXT_ZIP)) {
return FileNameTranslationHelper.getVoiceName(ctx, getBasename(indexItem));
} else if (fileName.endsWith(IndexConstants.TTSVOICE_INDEX_EXT_ZIP)) {
@ -265,9 +264,9 @@ public class DownloadActivityType implements Parcelable {
if (bn.endsWith(FileNameTranslationHelper.WIKI_NAME)){
return FileNameTranslationHelper.getWikiName(ctx,bn);
}
if (bn.startsWith(FileNameTranslationHelper.HILL_SHADE)){
return FileNameTranslationHelper.getHillShadeName(ctx, osmandRegions, bn);
}
// if (this == HILLSHADE_FILE){
// return FileNameTranslationHelper.getHillShadeName(ctx, osmandRegions, bn);
// }
final String lc = bn.toLowerCase();
String std = FileNameTranslationHelper.getStandardMapName(ctx, lc);
if (std != null) {
@ -334,8 +333,12 @@ public class DownloadActivityType implements Parcelable {
if (fileName.endsWith(IndexConstants.EXTRA_ZIP_EXT)) {
return fileName.substring(0, fileName.length() - IndexConstants.EXTRA_ZIP_EXT.length());
}
if (this == HILLSHADE_FILE) {
return fileName.substring(0, fileName.length() - IndexConstants.SQLITE_EXT.length())
.replace(FileNameTranslationHelper.HILL_SHADE, "");
}
if (fileName.endsWith(IndexConstants.SQLITE_EXT)) {
return fileName.substring(0, fileName.length() - IndexConstants.SQLITE_EXT.length()).replace('_', ' ');
return fileName.substring(0, fileName.length() - IndexConstants.SQLITE_EXT.length());
}
if (this == VOICE_FILE) {
int l = fileName.lastIndexOf('_');
@ -359,7 +362,6 @@ public class DownloadActivityType implements Parcelable {
return fileName;
}
@Override
public int describeContents() {
return 0;

View file

@ -132,10 +132,7 @@ public class IndexItemCategoryWithSubcat implements Comparable<IndexItemCategory
}
}
if (i.getType() == DownloadActivityType.VOICE_FILE){
// TODO remove
final String visibleName = i.getVisibleName(ctx, ctx.getRegions());
i.setName(visibleName);
if (i.getType() == DownloadActivityType.VOICE_FILE) {
category.items.add(i);
} else {
IndexItemCategoryWithSubcat region;
@ -155,25 +152,44 @@ public class IndexItemCategoryWithSubcat implements Comparable<IndexItemCategory
|| i.getType() == DownloadActivityType.WIKIPEDIA_FILE
|| i.getType() == DownloadActivityType.SRTM_COUNTRY_FILE
|| i.getType() == DownloadActivityType.HILLSHADE_FILE) {
category.types.add(i.getType().getStringResource());
region.types.add(i.getType().getStringResource());
}
}
}
final Collator collator = OsmAndCollator.primaryCollator();
for (IndexItemCategoryWithSubcat ct : mainList) {
for (IndexItemCategoryWithSubcat category : mainList) {
final OsmandRegions osmandRegions = ctx.getResourceManager().getOsmandRegions();
Collections.sort(ct.items, new Comparator<IndexItem>() {
@Override
public int compare(IndexItem lhs, IndexItem rhs) {
return collator.compare(lhs.getVisibleName(ctx, osmandRegions),
rhs.getVisibleName(ctx, osmandRegions));
}
});
sortIndexItemCategoryWithSybcat(category, ctx, osmandRegions, collator);
}
Collections.sort(mainList);
return mainList;
}
private static void sortIndexItemCategoryWithSybcat(final IndexItemCategoryWithSubcat category,
final OsmandApplication context,
final OsmandRegions osmandRegions,
final Collator collator) {
if (category.subcats.size() > 0) {
Collections.sort(category.subcats, new Comparator<IndexItemCategoryWithSubcat>() {
@Override
public int compare(IndexItemCategoryWithSubcat lhs, IndexItemCategoryWithSubcat rhs) {
return collator.compare(lhs.getName(), rhs.getName());
}
});
for (IndexItemCategoryWithSubcat subcat : category.subcats) {
sortIndexItemCategoryWithSybcat(subcat, context, osmandRegions, collator);
}
}
Collections.sort(category.items, new Comparator<IndexItem>() {
@Override
public int compare(IndexItem lhs, IndexItem rhs) {
return collator.compare(lhs.getVisibleName(context, osmandRegions),
rhs.getVisibleName(context, osmandRegions));
}
});
}
@Override
public String getName() {
return categoryStaticData.getName();

View file

@ -12,6 +12,7 @@ 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 net.osmand.plus.download.IndexItem;
import net.osmand.plus.helpers.HasName;
@ -62,6 +63,7 @@ public class MapsInCategoryFragment extends DialogFragment {
public void onIndexItemSelected(@NonNull IndexItem indexItem) {
LOG.debug("onIndexItemSelected()");
((DownloadActivity) getActivity()).startDownload(indexItem);
}
public static MapsInCategoryFragment createInstance(

View file

@ -16,18 +16,16 @@ import android.widget.ListView;
import android.widget.TextView;
import net.osmand.PlatformUtil;
import net.osmand.plus.IconsCache;
import net.osmand.plus.OsmandApplication;
import net.osmand.plus.OsmandSettings;
import net.osmand.plus.R;
import net.osmand.plus.download.DownloadActivity;
import net.osmand.plus.download.DownloadActivityType;
import net.osmand.plus.download.IndexItem;
import net.osmand.plus.helpers.HasName;
import org.apache.commons.logging.Log;
import java.util.Comparator;
public class SubcategoriesFragment extends Fragment {
private static final Log LOG = PlatformUtil.getLog(SubcategoriesFragment.class);
private static final String CATEGORY = "category";
@ -40,17 +38,10 @@ public class SubcategoriesFragment extends Fragment {
ListView listView = new ListView(getActivity());
final OsmandApplication application = (OsmandApplication) getActivity().getApplication();
final MapFilesAdapter mAdapter = new MapFilesAdapter(getActivity(),
application.getIconsCache(), application);
final MapFilesAdapter mAdapter = new MapFilesAdapter(getActivity());
listView.setAdapter(mAdapter);
mAdapter.addAll(category.items);
mAdapter.addAll(category.subcats);
mAdapter.sort(new Comparator<HasName>() {
@Override
public int compare(HasName lhs, HasName rhs) {
return lhs.getName().compareTo(rhs.getName());
}
});
View freeVersionBanner = inflater.inflate(R.layout.free_version_banner, listView, false);
final OsmandSettings settings = application.getSettings();
@ -84,14 +75,8 @@ public class SubcategoriesFragment extends Fragment {
private static class MapFilesAdapter extends ArrayAdapter<HasName> {
private final IconsCache iconsCache;
private final OsmandApplication application;
public MapFilesAdapter(Context context, IconsCache iconsCache, OsmandApplication application) {
public MapFilesAdapter(Context context) {
super(context, R.layout.two_line_with_images_list_item);
this.iconsCache = iconsCache;
this.application = application;
}
@Override
@ -100,44 +85,17 @@ public class SubcategoriesFragment extends Fragment {
if (convertView == null) {
convertView = LayoutInflater.from(parent.getContext())
.inflate(R.layout.two_line_with_images_list_item, parent, false);
viewHolder = new ViewHolder();
viewHolder.nameTextView = (TextView) convertView.findViewById(R.id.name);
viewHolder.descrTextView = (TextView) convertView.findViewById(R.id.description);
viewHolder.leftImageView = (ImageView) convertView.findViewById(R.id.leftIcon);
viewHolder.rightImageView = (ImageView) convertView.findViewById(R.id.rightIcon);
viewHolder = new ViewHolder(convertView);
convertView.setTag(viewHolder);
} else {
viewHolder = (ViewHolder) convertView.getTag();
}
HasName item = getItem(position);
if (item instanceof IndexItemCategoryWithSubcat) {
IndexItemCategoryWithSubcat category = (IndexItemCategoryWithSubcat) item;
viewHolder.nameTextView.setText(category.getName());
if (category.types.size() > 0) {
StringBuilder stringBuilder = new StringBuilder();
Resources resources = getContext().getResources();
for (Integer mapType : category.types) {
stringBuilder.append(resources.getString(mapType));
stringBuilder.append(", ");
}
stringBuilder.delete(stringBuilder.length() - 2, stringBuilder.capacity());
viewHolder.descrTextView.setText(stringBuilder.toString());
} else {
// TODO replace with string constant
viewHolder.descrTextView.setText("Others");
}
viewHolder.leftImageView.setImageDrawable(iconsCache.getContentIcon(R.drawable.ic_map));
LOG.debug("category.types=" + category.types);
viewHolder.bindCategory((IndexItemCategoryWithSubcat) item,
(DownloadActivity)getContext());
} else if (item instanceof IndexItem) {
IndexItem indexItem = (IndexItem) item;
if (indexItem.getType() == DownloadActivityType.VOICE_FILE) {
viewHolder.nameTextView.setText(indexItem.getVisibleName(getContext(),
application.getRegions()));
} else {
viewHolder.nameTextView.setText(indexItem.getType().getString(getContext()));
}
viewHolder.descrTextView.setText(indexItem.getSizeDescription(getContext()));
viewHolder.leftImageView.setImageResource(indexItem.getType().getIconResource());
viewHolder.bindIndexItem((IndexItem) item, (DownloadActivity) getContext());
} else {
throw new IllegalArgumentException("Item must be of type IndexItem or " +
"IndexItemCategory but is of type:" + item.getClass());
@ -149,7 +107,45 @@ public class SubcategoriesFragment extends Fragment {
TextView nameTextView;
TextView descrTextView;
ImageView leftImageView;
ImageView rightImageView;
ImageView rightImageButton;
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);
}
public void bindIndexItem(IndexItem indexItem, DownloadActivity context) {
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(context.getMyApplication()
.getIconsCache().getContentIcon(indexItem.getType().getIconResource()));
}
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(context.getMyApplication()
.getIconsCache().getContentIcon(R.drawable.ic_map));
}
}
}
}

View file

@ -1,10 +1,14 @@
package net.osmand.plus.helpers;
import android.content.Context;
import net.osmand.IndexConstants;
import net.osmand.PlatformUtil;
import net.osmand.map.OsmandRegions;
import net.osmand.plus.R;
import org.apache.commons.logging.Log;
import java.lang.reflect.Field;
/**
@ -12,9 +16,9 @@ import java.lang.reflect.Field;
* on 07.07.2014.
*/
public class FileNameTranslationHelper {
private static final Log LOG = PlatformUtil.getLog(FileNameTranslationHelper.class);
public static final String WIKI_NAME = "_wiki";
public static final String HILL_SHADE = "Hillshade";
public static final String HILL_SHADE = "Hillshade_";
public static String getFileName(Context ctx, OsmandRegions regions, String fileName) {
String basename = getBasename(fileName);
@ -51,10 +55,8 @@ public class FileNameTranslationHelper {
}
public static String getHillShadeName(Context ctx, OsmandRegions regions, String basename) {
String intermName = basename.replace(HILL_SHADE,"");
String hillsh = ctx.getString(R.string.download_hillshade_item) + " ";
String locName = regions.getLocaleName(intermName.trim().replace(" ", "_"));
String locName = regions.getLocaleName(basename.trim());
return hillsh + locName;
}

View file

@ -1,5 +1,6 @@
package net.osmand.plus.helpers;
public interface HasName {
@Deprecated
String getName();
}