Merge pull request #938 from Bars107/master

Fixed issue with wrong tab opened when loading downloads from map. Fixed...
This commit is contained in:
vshcherb 2014-10-31 16:37:54 +01:00
commit 0595382a19
4 changed files with 22 additions and 5 deletions

View file

@ -81,7 +81,6 @@ public class OsmAndAppCustomization {
}
public Class<? extends Activity> getDownloadActivity() {
//return DownloadActivity.class;
return DownloadActivity.class;
}

View file

@ -54,10 +54,14 @@ public class DownloadActivity extends SherlockFragmentActivity {
private List<LocalIndexInfo> localIndexInfos = new ArrayList<LocalIndexInfo>();
List<WeakReference<Fragment>> fragList = new ArrayList<WeakReference<Fragment>>();
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();

View file

@ -84,7 +84,8 @@ public class DownloadIndexFragment extends OsmandExpandableListFragment {
};
filterText.addTextChangedListener(textWatcher);
String filter = ((DownloadActivity)getActivity()).getInitialFilter();
filterText.setText(filter);
return view;
}

View file

@ -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);
}
});