From a8967574ed7f87b48978d12df0b15568f9dd20ed Mon Sep 17 00:00:00 2001 From: Denis Date: Fri, 31 Oct 2014 17:28:51 +0200 Subject: [PATCH] Fixed issue with wrong tab opened when loading downloads from map. Fixed issue with initial filter not being set --- .../osmand/plus/OsmAndAppCustomization.java | 1 - .../plus/download/DownloadActivity.java | 22 ++++++++++++++++--- .../plus/download/DownloadIndexFragment.java | 3 ++- .../plus/views/DownloadedRegionsLayer.java | 1 + 4 files changed, 22 insertions(+), 5 deletions(-) diff --git a/OsmAnd/src/net/osmand/plus/OsmAndAppCustomization.java b/OsmAnd/src/net/osmand/plus/OsmAndAppCustomization.java index fb0827d0a9..fcfef74bf8 100644 --- a/OsmAnd/src/net/osmand/plus/OsmAndAppCustomization.java +++ b/OsmAnd/src/net/osmand/plus/OsmAndAppCustomization.java @@ -81,7 +81,6 @@ public class OsmAndAppCustomization { } public Class getDownloadActivity() { - //return DownloadActivity.class; return DownloadActivity.class; } diff --git a/OsmAnd/src/net/osmand/plus/download/DownloadActivity.java b/OsmAnd/src/net/osmand/plus/download/DownloadActivity.java index 012092e48d..1f4e152c22 100644 --- a/OsmAnd/src/net/osmand/plus/download/DownloadActivity.java +++ b/OsmAnd/src/net/osmand/plus/download/DownloadActivity.java @@ -54,10 +54,14 @@ public class DownloadActivity extends SherlockFragmentActivity { private List localIndexInfos = new ArrayList(); List> fragList = new ArrayList>(); + private String initialFilter = ""; public static final String FILTER_KEY = "filter"; public static final String FILTER_CAT = "filter_cat"; + public static final String TAB_TO_OPEN = "Tab_to_open"; + public static final String DOWNLOAD_TAB = "download"; + @Override protected void onCreate(Bundle savedInstanceState) { @@ -128,9 +132,10 @@ public class DownloadActivity extends SherlockFragmentActivity { setType(downloadTypes.get(0)); if (intent != null && intent.getExtras() != null) { final String filter = intent.getExtras().getString(FILTER_KEY); -// if (filter != null) { -// filterText.setText(filter); -// } + if (filter != null) { + initialFilter = filter; + } + final String filterCat = intent.getExtras().getString(FILTER_CAT); if (filterCat != null) { DownloadActivityType type = DownloadActivityType.getIndexType(filterCat.toLowerCase()); @@ -140,6 +145,13 @@ public class DownloadActivity extends SherlockFragmentActivity { downloadTypes.add(0, type); } } + + String tab = intent.getExtras().get(TAB_TO_OPEN).toString(); + if (tab != null) { + if (tab.equals(DOWNLOAD_TAB)){ + tabHost.setCurrentTab(1); + } + } } if(getMyApplication().getResourceManager().getIndexFileNames().isEmpty()) { @@ -197,6 +209,10 @@ public class DownloadActivity extends SherlockFragmentActivity { return downloadListIndexThread != null ? downloadListIndexThread.getIndexActivatedFileNames() : null; } + public String getInitialFilter() { + return initialFilter; + } + @Override protected void onResume() { super.onResume(); diff --git a/OsmAnd/src/net/osmand/plus/download/DownloadIndexFragment.java b/OsmAnd/src/net/osmand/plus/download/DownloadIndexFragment.java index 404dd69629..63195d8e07 100644 --- a/OsmAnd/src/net/osmand/plus/download/DownloadIndexFragment.java +++ b/OsmAnd/src/net/osmand/plus/download/DownloadIndexFragment.java @@ -84,7 +84,8 @@ public class DownloadIndexFragment extends OsmandExpandableListFragment { }; filterText.addTextChangedListener(textWatcher); - + String filter = ((DownloadActivity)getActivity()).getInitialFilter(); + filterText.setText(filter); return view; } diff --git a/OsmAnd/src/net/osmand/plus/views/DownloadedRegionsLayer.java b/OsmAnd/src/net/osmand/plus/views/DownloadedRegionsLayer.java index af24a3f559..8fc0138455 100644 --- a/OsmAnd/src/net/osmand/plus/views/DownloadedRegionsLayer.java +++ b/OsmAnd/src/net/osmand/plus/views/DownloadedRegionsLayer.java @@ -89,6 +89,7 @@ public class DownloadedRegionsLayer extends OsmandMapLayer { public void onClick(View v) { final Intent intent = new Intent(view.getContext(), view.getApplication().getAppCustomization().getDownloadIndexActivity()); intent.putExtra(DownloadActivity.FILTER_KEY, filter.toString()); + intent.putExtra(DownloadActivity.TAB_TO_OPEN, DownloadActivity.DOWNLOAD_TAB); view.getContext().startActivity(intent); } });