From 4a8d2b7b820e056a0916d001636b9ebf33d7ce10 Mon Sep 17 00:00:00 2001 From: Alexey Kulish Date: Wed, 21 Oct 2015 18:20:43 +0300 Subject: [PATCH 1/3] Fix intent filter and filterCat params --- .../search/SearchByNameAbstractActivity.java | 2 +- .../osmand/plus/dashboard/DashboardOnMap.java | 4 +- .../plus/download/DownloadActivity.java | 20 ++++++-- .../plus/download/DownloadResourceGroup.java | 3 ++ .../plus/download/DownloadResources.java | 12 +++-- .../ui/DownloadResourceGroupFragment.java | 50 ++++++++++++------- .../download/ui/SearchDialogFragment.java | 4 ++ .../openseamapsplugin/NauticalMapsPlugin.java | 1 - 8 files changed, 65 insertions(+), 31 deletions(-) diff --git a/OsmAnd/src/net/osmand/plus/activities/search/SearchByNameAbstractActivity.java b/OsmAnd/src/net/osmand/plus/activities/search/SearchByNameAbstractActivity.java index 8b3d2189b8..d1d2752d6d 100644 --- a/OsmAnd/src/net/osmand/plus/activities/search/SearchByNameAbstractActivity.java +++ b/OsmAnd/src/net/osmand/plus/activities/search/SearchByNameAbstractActivity.java @@ -141,7 +141,7 @@ public abstract class SearchByNameAbstractActivity extends OsmandListActivity } }); // Not perfect -// searchText.setOnClickListener(new OnClickListener() { +// filter.setOnClickListener(new OnClickListener() { // } // }); searchText.setImeOptions(EditorInfo.IME_ACTION_DONE); diff --git a/OsmAnd/src/net/osmand/plus/dashboard/DashboardOnMap.java b/OsmAnd/src/net/osmand/plus/dashboard/DashboardOnMap.java index 9399bb5284..87e83f3fba 100644 --- a/OsmAnd/src/net/osmand/plus/dashboard/DashboardOnMap.java +++ b/OsmAnd/src/net/osmand/plus/dashboard/DashboardOnMap.java @@ -577,7 +577,9 @@ public class DashboardOnMap implements ObservableScrollViewCallbacks { hideDashboard(false); final Intent intent = new Intent(mapActivity, mapActivity.getMyApplication().getAppCustomization() .getDownloadIndexActivity()); - intent.putExtra(DownloadActivity.FILTER_KEY, f); + if (f != null && !f.equals("basemap")) { + intent.putExtra(DownloadActivity.FILTER_KEY, f); + } intent.putExtra(DownloadActivity.TAB_TO_OPEN, DownloadActivity.DOWNLOAD_TAB); mapActivity.startActivity(intent); } diff --git a/OsmAnd/src/net/osmand/plus/download/DownloadActivity.java b/OsmAnd/src/net/osmand/plus/download/DownloadActivity.java index dca576dd53..33ebff637c 100644 --- a/OsmAnd/src/net/osmand/plus/download/DownloadActivity.java +++ b/OsmAnd/src/net/osmand/plus/download/DownloadActivity.java @@ -60,6 +60,8 @@ public class DownloadActivity extends BaseDownloadActivity { private BannerAndDownloadFreeVersion visibleBanner; private ViewPager viewPager; + private String filter; + private String filterCat; @Override protected void onCreate(Bundle savedInstanceState) { @@ -74,7 +76,7 @@ public class DownloadActivity extends BaseDownloadActivity { final View downloadProgressLayout = findViewById(R.id.downloadProgressLayout); downloadProgressLayout.setVisibility(View.VISIBLE); updateDescriptionTextWithSize(this, downloadProgressLayout); - int currentTab = 0; + int currentTab = DOWNLOAD_TAB_NUMBER; String tab = getIntent() == null || getIntent().getExtras() == null ? null : getIntent().getExtras().getString(TAB_TO_OPEN); if (tab != null) { if (tab.equals(DOWNLOAD_TAB)) { @@ -124,10 +126,9 @@ public class DownloadActivity extends BaseDownloadActivity { visibleBanner = new BannerAndDownloadFreeVersion(findViewById(R.id.mainLayout), this); final Intent intent = getIntent(); - // FIXME INITIAL FILTER & INITIAL KEY if (intent != null && intent.getExtras() != null) { - final String filter = intent.getExtras().getString(FILTER_KEY); - final String filterCat = intent.getExtras().getString(FILTER_CAT); + filter = intent.getExtras().getString(FILTER_KEY); + filterCat = intent.getExtras().getString(FILTER_CAT); } } @@ -443,6 +444,17 @@ public class DownloadActivity extends BaseDownloadActivity { } + public String getFilterAndClear() { + String res = filter; + filter = null; + return res; + } + + public String getFilterCatAndClear() { + String res = filterCat; + filterCat = null; + return res; + } @SuppressWarnings("deprecation") public static void updateDescriptionTextWithSize(DownloadActivity activity, View view) { diff --git a/OsmAnd/src/net/osmand/plus/download/DownloadResourceGroup.java b/OsmAnd/src/net/osmand/plus/download/DownloadResourceGroup.java index e7c8d74ece..8c568fea50 100644 --- a/OsmAnd/src/net/osmand/plus/download/DownloadResourceGroup.java +++ b/OsmAnd/src/net/osmand/plus/download/DownloadResourceGroup.java @@ -78,6 +78,9 @@ public class DownloadResourceGroup { || this == OTHER_MAPS_HEADER || this == OTHER_MAPS_GROUP; } + public static String getVoiceTTSId() { + return "#" + VOICE_GROUP.name().toLowerCase() + "#" + VOICE_TTS.name().toLowerCase(); + } } public DownloadResourceGroup(DownloadResourceGroup parentGroup, DownloadResourceGroupType type) { diff --git a/OsmAnd/src/net/osmand/plus/download/DownloadResources.java b/OsmAnd/src/net/osmand/plus/download/DownloadResources.java index 9140e2b517..ee88aeec4d 100644 --- a/OsmAnd/src/net/osmand/plus/download/DownloadResources.java +++ b/OsmAnd/src/net/osmand/plus/download/DownloadResources.java @@ -202,11 +202,7 @@ public class DownloadResources extends DownloadResourceGroup { DownloadResourceGroup voiceScreenTTS = new DownloadResourceGroup(voiceGroup, DownloadResourceGroupType.VOICE_TTS); DownloadResourceGroup voiceRec = new DownloadResourceGroup(voiceGroup, DownloadResourceGroupType.VOICE_HEADER_REC); DownloadResourceGroup voiceTTS = new DownloadResourceGroup(voiceGroup, DownloadResourceGroupType.VOICE_HEADER_TTS); - voiceScreenTTS.addGroup(voiceTTS); - voiceScreenRec.addGroup(voiceRec); - voiceGroup.addGroup(voiceScreenRec); - voiceGroup.addGroup(voiceScreenTTS); - + DownloadResourceGroup worldMaps = new DownloadResourceGroup(this, DownloadResourceGroupType.WORLD_MAPS); Map > groupByRegion = new LinkedHashMap>(); @@ -279,7 +275,13 @@ public class DownloadResources extends DownloadResourceGroup { if (otherMaps.size() > 0) { addGroup(otherMapsGroup); } + + voiceScreenTTS.addGroup(voiceTTS); + voiceScreenRec.addGroup(voiceRec); + voiceGroup.addGroup(voiceScreenRec); + voiceGroup.addGroup(voiceScreenTTS); addGroup(voiceGroup); + createHillshadeSRTMGroups(); trimEmptyGroups(); initAlreadyLoadedFiles(); diff --git a/OsmAnd/src/net/osmand/plus/download/ui/DownloadResourceGroupFragment.java b/OsmAnd/src/net/osmand/plus/download/ui/DownloadResourceGroupFragment.java index aa93afc180..ab1c55074e 100644 --- a/OsmAnd/src/net/osmand/plus/download/ui/DownloadResourceGroupFragment.java +++ b/OsmAnd/src/net/osmand/plus/download/ui/DownloadResourceGroupFragment.java @@ -1,24 +1,5 @@ package net.osmand.plus.download.ui; -import java.util.ArrayList; -import java.util.List; - -import net.osmand.plus.IconsCache; -import net.osmand.plus.OsmandApplication; -import net.osmand.plus.OsmandSettings; -import net.osmand.plus.R; -import net.osmand.plus.activities.OsmandBaseExpandableListAdapter; -import net.osmand.plus.download.DownloadActivity; -import net.osmand.plus.download.DownloadActivity.BannerAndDownloadFreeVersion; -import net.osmand.plus.download.DownloadActivityType; -import net.osmand.plus.download.DownloadIndexesThread.DownloadEvents; -import net.osmand.plus.download.DownloadResourceGroup; -import net.osmand.plus.download.DownloadResourceGroup.DownloadResourceGroupType; -import net.osmand.plus.download.DownloadResources; -import net.osmand.plus.download.IndexItem; -import net.osmand.util.Algorithms; -import android.content.Context; -import android.content.DialogInterface; import android.content.res.Resources; import android.content.res.TypedArray; import android.graphics.drawable.Drawable; @@ -38,6 +19,24 @@ import android.widget.ExpandableListView; import android.widget.ExpandableListView.OnChildClickListener; import android.widget.TextView; +import net.osmand.plus.IconsCache; +import net.osmand.plus.OsmandApplication; +import net.osmand.plus.OsmandSettings; +import net.osmand.plus.R; +import net.osmand.plus.activities.OsmandBaseExpandableListAdapter; +import net.osmand.plus.download.DownloadActivity; +import net.osmand.plus.download.DownloadActivity.BannerAndDownloadFreeVersion; +import net.osmand.plus.download.DownloadActivityType; +import net.osmand.plus.download.DownloadIndexesThread.DownloadEvents; +import net.osmand.plus.download.DownloadResourceGroup; +import net.osmand.plus.download.DownloadResourceGroup.DownloadResourceGroupType; +import net.osmand.plus.download.DownloadResources; +import net.osmand.plus.download.IndexItem; +import net.osmand.util.Algorithms; + +import java.util.ArrayList; +import java.util.List; + public class DownloadResourceGroupFragment extends DialogFragment implements DownloadEvents, OnChildClickListener { public static final int RELOAD_ID = 0; public static final int SEARCH_ID = 1; @@ -112,6 +111,19 @@ public class DownloadResourceGroupFragment extends DialogFragment implements Dow public void onResume() { super.onResume(); reloadData(); + String filter = getDownloadActivity().getFilterAndClear(); + String filterCat = getDownloadActivity().getFilterCatAndClear(); + if (filter != null) { + getDownloadActivity().showDialog(getActivity(), + SearchDialogFragment.createInstance(filter)); + } else if (filterCat != null) { + if (filterCat.equals(DownloadActivityType.VOICE_FILE.getTag())) { + String uniqueId = DownloadResourceGroup.DownloadResourceGroupType.getVoiceTTSId(); + final DownloadResourceGroupFragment regionDialogFragment = DownloadResourceGroupFragment + .createInstance(uniqueId); + ((DownloadActivity) getActivity()).showDialog(getActivity(), regionDialogFragment); + } + } } private void reloadData() { diff --git a/OsmAnd/src/net/osmand/plus/download/ui/SearchDialogFragment.java b/OsmAnd/src/net/osmand/plus/download/ui/SearchDialogFragment.java index 430bac41f0..1ac724d768 100644 --- a/OsmAnd/src/net/osmand/plus/download/ui/SearchDialogFragment.java +++ b/OsmAnd/src/net/osmand/plus/download/ui/SearchDialogFragment.java @@ -33,6 +33,7 @@ import net.osmand.plus.download.DownloadResourceGroup; import net.osmand.plus.download.DownloadResourceGroup.DownloadResourceGroupType; import net.osmand.plus.download.DownloadResources; import net.osmand.plus.download.IndexItem; +import net.osmand.util.Algorithms; import java.util.ArrayList; import java.util.Collections; @@ -181,6 +182,9 @@ public class SearchDialogFragment extends DialogFragment implements DownloadEven public void onResume() { super.onResume(); search.setIconified(false); + if (!Algorithms.isEmpty(searchText)) { + search.setQuery(searchText, true); + } } public void updateSearchText(String searchText) { diff --git a/OsmAnd/src/net/osmand/plus/openseamapsplugin/NauticalMapsPlugin.java b/OsmAnd/src/net/osmand/plus/openseamapsplugin/NauticalMapsPlugin.java index bccf333eb6..7523826568 100644 --- a/OsmAnd/src/net/osmand/plus/openseamapsplugin/NauticalMapsPlugin.java +++ b/OsmAnd/src/net/osmand/plus/openseamapsplugin/NauticalMapsPlugin.java @@ -60,7 +60,6 @@ public class NauticalMapsPlugin extends OsmandPlugin { @Override public void onClick(DialogInterface dialog, int which) { final Intent intent = new Intent(activity, app.getAppCustomization().getDownloadIndexActivity()); - intent.putExtra(DownloadActivity.FILTER_KEY, app.getString(net.osmand.plus.R.string.index_item_world_seamarks)); intent.putExtra(DownloadActivity.TAB_TO_OPEN, DownloadActivity.DOWNLOAD_TAB); activity.startActivity(intent); } From bf329e3577ff4cefede2a980005c457ac15e3223 Mon Sep 17 00:00:00 2001 From: ezjerry liao Date: Wed, 21 Oct 2015 17:14:48 +0200 Subject: [PATCH 2/3] Translated using Weblate (Chinese (Taiwan)) Currently translated at 89.7% (1847 of 2057 strings) --- OsmAnd/res/values-zh-rTW/phrases.xml | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/OsmAnd/res/values-zh-rTW/phrases.xml b/OsmAnd/res/values-zh-rTW/phrases.xml index 86c60c0e62..901f5a73f7 100644 --- a/OsmAnd/res/values-zh-rTW/phrases.xml +++ b/OsmAnd/res/values-zh-rTW/phrases.xml @@ -1998,4 +1998,10 @@ 注釋 有水的地方 + 動物寄宿 + 寄宿類型:狗 + 寄宿類型:貓 + 寄宿類型:狗、貓 + 寄宿類型:馬 + From 4866cd483dccf8412563e1a409760152355e47a2 Mon Sep 17 00:00:00 2001 From: Alexey Kulish Date: Wed, 21 Oct 2015 18:48:10 +0300 Subject: [PATCH 3/3] Fix --- .../osmand/plus/download/DownloadActivity.java | 17 ++++++----------- 1 file changed, 6 insertions(+), 11 deletions(-) diff --git a/OsmAnd/src/net/osmand/plus/download/DownloadActivity.java b/OsmAnd/src/net/osmand/plus/download/DownloadActivity.java index 10ac527a71..33ebff637c 100644 --- a/OsmAnd/src/net/osmand/plus/download/DownloadActivity.java +++ b/OsmAnd/src/net/osmand/plus/download/DownloadActivity.java @@ -78,18 +78,13 @@ public class DownloadActivity extends BaseDownloadActivity { updateDescriptionTextWithSize(this, downloadProgressLayout); int currentTab = DOWNLOAD_TAB_NUMBER; String tab = getIntent() == null || getIntent().getExtras() == null ? null : getIntent().getExtras().getString(TAB_TO_OPEN); - if (tab != null) { - switch (tab) { - case DOWNLOAD_TAB: - currentTab = DOWNLOAD_TAB_NUMBER; - break; - case LOCAL_TAB: - currentTab = LOCAL_TAB_NUMBER; - break; - case UPDATES_TAB: - currentTab = UPDATES_TAB_NUMBER; - break; + if (tab.equals(DOWNLOAD_TAB)) { + currentTab = DOWNLOAD_TAB_NUMBER; + } else if (tab.equals(LOCAL_TAB)) { + currentTab = LOCAL_TAB_NUMBER; + } else if (tab.equals(UPDATES_TAB)) { + currentTab = UPDATES_TAB_NUMBER; } }