diff --git a/OsmAnd/res/layout/dash_download_maps_fragment.xml b/OsmAnd/res/layout/dash_download_maps_fragment.xml
new file mode 100644
index 0000000000..ffd74770ee
--- /dev/null
+++ b/OsmAnd/res/layout/dash_download_maps_fragment.xml
@@ -0,0 +1,37 @@
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/OsmAnd/res/layout/tab_content.xml b/OsmAnd/res/layout/tab_content.xml
index 55549c7832..2bf57d264c 100644
--- a/OsmAnd/res/layout/tab_content.xml
+++ b/OsmAnd/res/layout/tab_content.xml
@@ -89,6 +89,13 @@
android:layout_weight="0" />
+
+
+ Do you want to download any offline map?
+ You have %1$s maps downloaded
+ Download New Map
+ Manage
Map language
Transport Stops
Do you want OsmAnd to also copy its data files to the new destination? Select \'No\' for OsmAnd to just create and use the new folder.
diff --git a/OsmAnd/src/net/osmand/plus/activities/MainMenuActivity.java b/OsmAnd/src/net/osmand/plus/activities/MainMenuActivity.java
index 590031da9b..d37db427e4 100644
--- a/OsmAnd/src/net/osmand/plus/activities/MainMenuActivity.java
+++ b/OsmAnd/src/net/osmand/plus/activities/MainMenuActivity.java
@@ -13,6 +13,7 @@ import net.osmand.plus.OsmandApplication;
import net.osmand.plus.R;
import net.osmand.plus.Version;
import net.osmand.plus.base.BasicProgressAsyncTask;
+import net.osmand.plus.dashboard.DashDownloadMapsFragment;
import net.osmand.plus.dashboard.DashErrorFragment;
import net.osmand.plus.dashboard.DashFavoritesFragment;
import net.osmand.plus.dashboard.DashMapFragment;
@@ -169,6 +170,10 @@ public class MainMenuActivity extends BaseDownloadActivity {
DashUpdatesFragment updatesFragment = new DashUpdatesFragment();
fragmentTransaction.add(R.id.content, updatesFragment, DashUpdatesFragment.TAG);
}
+ if (manager.findFragmentByTag(DashDownloadMapsFragment.TAG) == null){
+ DashDownloadMapsFragment fragment = new DashDownloadMapsFragment();
+ fragmentTransaction.add(R.id.content, fragment, DashDownloadMapsFragment.TAG);
+ }
if (manager.findFragmentByTag(DashPluginsFragment.TAG) == null){
DashPluginsFragment pluginsFragment = new DashPluginsFragment();
fragmentTransaction.add(R.id.content, pluginsFragment, DashPluginsFragment.TAG).commit();
diff --git a/OsmAnd/src/net/osmand/plus/dashboard/DashDownloadMapsFragment.java b/OsmAnd/src/net/osmand/plus/dashboard/DashDownloadMapsFragment.java
new file mode 100644
index 0000000000..b71f840632
--- /dev/null
+++ b/OsmAnd/src/net/osmand/plus/dashboard/DashDownloadMapsFragment.java
@@ -0,0 +1,109 @@
+package net.osmand.plus.dashboard;
+
+import java.io.File;
+import java.text.MessageFormat;
+import java.util.Locale;
+
+import net.osmand.IndexConstants;
+import net.osmand.plus.R;
+import net.osmand.plus.download.DownloadActivity;
+import net.osmand.plus.helpers.FontCache;
+import android.content.Intent;
+import android.graphics.Typeface;
+import android.os.AsyncTask;
+import android.os.Bundle;
+import android.view.LayoutInflater;
+import android.view.View;
+import android.view.ViewGroup;
+import android.widget.Button;
+import android.widget.TextView;
+
+/**
+ * Created by dummy on 02.12.14.
+ */
+public class DashDownloadMapsFragment extends DashBaseFragment {
+
+ public static final String TAG = "DASH_DOWNLOAD_MAPS_FRAGMENT";
+ MessageFormat formatMb = new MessageFormat("{0, number,##.#} MB", Locale.US);
+ MessageFormat formatGb = new MessageFormat("{0, number,#.##} GB", Locale.US);
+
+ @Override
+ public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
+ final View view = getActivity().getLayoutInflater().inflate(R.layout.dash_download_maps_fragment, container, false);
+ Typeface typeface = FontCache.getRobotoMedium(getActivity());
+ final TextView message =((TextView) view.findViewById(R.id.message));
+ final Button local = ((Button) view.findViewById(R.id.local_downloads));
+ message.setTypeface(typeface);
+ new AsyncTask() {
+ int countMaps = 0;
+ long size = 0;
+ @Override
+ protected Void doInBackground(Void... params) {
+ updateCount(IndexConstants.MAPS_PATH);
+ updateCount(IndexConstants.SRTM_INDEX_DIR);
+ return null;
+ }
+
+ protected void updateCount(String s) {
+ File ms = getMyApplication().getAppPath(s);
+ if (ms.exists()) {
+ File[] lf = ms.listFiles();
+ if (lf != null) {
+ for (File f : ms.listFiles()) {
+ if (f.getName().endsWith(IndexConstants.BINARY_MAP_INDEX_EXT)) {
+ size += f.length();
+ countMaps++;
+ }
+ }
+ }
+ }
+ }
+
+ @Override
+ protected void onPostExecute(Void result) {
+ super.onPostExecute(result);
+ if(countMaps > 0) {
+ long mb = 1 << 20;
+ long gb = 1 << 30;
+ String sz = size > gb ?
+ formatGb.format(new Object[] { (float) size / (gb) }) :
+ formatMb.format(new Object[] { (float) size / mb }) ;
+ message.setText(getString(R.string.dash_download_msg, countMaps+"") + " (" + sz +")");
+ local.setVisibility(View.VISIBLE);
+ } else {
+ message.setText(getString(R.string.dash_download_msg_none));
+ local.setVisibility(View.GONE);
+ }
+
+ }
+ };
+
+
+
+
+ local.setTypeface(typeface);
+ local.setOnClickListener(new View.OnClickListener() {
+
+ @Override
+ public void onClick(View v) {
+ final Intent intent = new Intent(view.getContext(), getMyApplication().getAppCustomization().getDownloadIndexActivity());
+ intent.putExtra(DownloadActivity.TAB_TO_OPEN, DownloadActivity.LOCAL_TAB);
+ intent.putExtra(DownloadActivity.SINGLE_TAB, true);
+ getActivity().startActivity(intent);
+ }
+ });
+
+ Button cancelBtn = ((Button) view.findViewById(R.id.download_new_map));
+ cancelBtn.setTypeface(typeface);
+ cancelBtn.setOnClickListener(new View.OnClickListener() {
+ @Override
+ public void onClick(View view) {
+ final Intent intent = new Intent(view.getContext(), getMyApplication().getAppCustomization().getDownloadIndexActivity());
+ intent.putExtra(DownloadActivity.TAB_TO_OPEN, DownloadActivity.DOWNLOAD_TAB);
+ intent.putExtra(DownloadActivity.SINGLE_TAB, true);
+ getActivity().startActivity(intent);
+ }
+ });
+ return view;
+ }
+}
diff --git a/OsmAnd/src/net/osmand/plus/dashboard/DashUpdatesFragment.java b/OsmAnd/src/net/osmand/plus/dashboard/DashUpdatesFragment.java
index e9ed8de377..02846629d9 100644
--- a/OsmAnd/src/net/osmand/plus/dashboard/DashUpdatesFragment.java
+++ b/OsmAnd/src/net/osmand/plus/dashboard/DashUpdatesFragment.java
@@ -41,6 +41,7 @@ public class DashUpdatesFragment extends DashBaseFragment {
public void onClick(View view) {
final Intent intent = new Intent(view.getContext(), getMyApplication().getAppCustomization().getDownloadIndexActivity());
intent.putExtra(DownloadActivity.TAB_TO_OPEN, DownloadActivity.UPDATES_TAB);
+ intent.putExtra(DownloadActivity.SINGLE_TAB, true);
getActivity().startActivity(intent);
}
});
diff --git a/OsmAnd/src/net/osmand/plus/download/DownloadActivity.java b/OsmAnd/src/net/osmand/plus/download/DownloadActivity.java
index 66252f0192..692f74c8e6 100644
--- a/OsmAnd/src/net/osmand/plus/download/DownloadActivity.java
+++ b/OsmAnd/src/net/osmand/plus/download/DownloadActivity.java
@@ -48,13 +48,16 @@ public class DownloadActivity extends BaseDownloadActivity {
private List localIndexInfos = new ArrayList();
private String initialFilter = "";
+ private boolean singleTab;
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 LOCAL_TAB = "local";
public static final String DOWNLOAD_TAB = "download";
public static final String UPDATES_TAB = "updates";
+ public static final String SINGLE_TAB = "SINGLE_TAB";
@Override
@@ -72,24 +75,45 @@ public class DownloadActivity extends BaseDownloadActivity {
setProgressBarIndeterminateVisibility(false);
setContentView(R.layout.tab_content);
-
- tabHost = (TabHost) findViewById(android.R.id.tabhost);
- tabHost.setup();
- ViewPager viewPager = (ViewPager) findViewById(R.id.pager);
- mTabsAdapter = new FavouritesActivity.TabsAdapter(this, tabHost, viewPager, settings, false);
- if (getMyApplication().getAppCustomization().onlyTourDownload()){
- mTabsAdapter.addTab(tabHost.newTabSpec("DOWNLOADS").setIndicator(getString(R.string.download_tab_downloads)),
- DownloadIndexFragment.class, null);
- } else {
- mTabsAdapter.addTab(tabHost.newTabSpec("LOCAL_INDEX").setIndicator(getString(R.string.download_tab_local)),
- LocalIndexesFragment.class, null);
- mTabsAdapter.addTab(tabHost.newTabSpec("DOWNLOADS").setIndicator(getString(R.string.download_tab_downloads)),
- DownloadIndexFragment.class, null);
- mTabsAdapter.addTab(tabHost.newTabSpec("UPDATES").setIndicator(getString(R.string.download_tab_updates)),
- UpdatesIndexFragment.class, null);
+ singleTab = getIntent() != null && getIntent().getBooleanExtra(SINGLE_TAB, false);
+ int currentTab = 0;
+ String tab = getIntent() == null ? null : getIntent().getExtras().getString(TAB_TO_OPEN);
+ if (tab != null) {
+ if (tab.equals(DOWNLOAD_TAB)){
+ currentTab = 1;
+ } else if (tab.equals(UPDATES_TAB)){
+ currentTab = 2;
+ }
}
+ if (singleTab) {
+ ViewPager viewPager = (ViewPager) findViewById(R.id.pager);
+ viewPager.setVisibility(View.GONE);
+ Fragment f = currentTab == 0 ? new LocalIndexesFragment() :
+ (currentTab == 1? new DownloadIndexFragment() : new UpdatesIndexFragment());
+ findViewById(R.id.layout).setVisibility(View.VISIBLE);
+ getSupportFragmentManager().beginTransaction().add(R.id.layout, f).commit();
+ } else {
+ tabHost = (TabHost) findViewById(android.R.id.tabhost);
+ tabHost.setup();
+ ViewPager viewPager = (ViewPager) findViewById(R.id.pager);
+ mTabsAdapter = new FavouritesActivity.TabsAdapter(this, tabHost, viewPager, settings, false);
+ if (getMyApplication().getAppCustomization().onlyTourDownload()) {
+ mTabsAdapter.addTab(
+ tabHost.newTabSpec("DOWNLOADS").setIndicator(getString(R.string.download_tab_downloads)),
+ DownloadIndexFragment.class, null);
+ } else {
+ mTabsAdapter.addTab(
+ tabHost.newTabSpec("LOCAL_INDEX").setIndicator(getString(R.string.download_tab_local)),
+ LocalIndexesFragment.class, null);
+ mTabsAdapter.addTab(
+ tabHost.newTabSpec("DOWNLOADS").setIndicator(getString(R.string.download_tab_downloads)),
+ DownloadIndexFragment.class, null);
+ mTabsAdapter.addTab(tabHost.newTabSpec("UPDATES")
+ .setIndicator(getString(R.string.download_tab_updates)), UpdatesIndexFragment.class, null);
+ }
- tabHost.setCurrentTab(0);
+ tabHost.setCurrentTab(currentTab);
+ }
settings = ((OsmandApplication)getApplication()).getSettings();
@@ -136,15 +160,6 @@ public class DownloadActivity extends BaseDownloadActivity {
downloadTypes.add(0, type);
}
}
-
- String tab = intent.getExtras().getString(TAB_TO_OPEN);
- if (tab != null) {
- if (tab.equals(DOWNLOAD_TAB)){
- tabHost.setCurrentTab(1);
- } else if (tab.equals(UPDATES_TAB)){
- tabHost.setCurrentTab(2);
- }
- }
}
getSupportActionBar().setHomeButtonEnabled(true);
@@ -165,7 +180,6 @@ public class DownloadActivity extends BaseDownloadActivity {
protected void onResume() {
super.onResume();
getMyApplication().setDownloadActivity(this);
- BasicProgressAsyncTask, ?, ?> t = downloadListIndexThread.getCurrentRunningTask();
}
diff --git a/OsmAnd/src/net/osmand/plus/download/LocalIndexesFragment.java b/OsmAnd/src/net/osmand/plus/download/LocalIndexesFragment.java
index 2921f99cc9..2583245ddb 100644
--- a/OsmAnd/src/net/osmand/plus/download/LocalIndexesFragment.java
+++ b/OsmAnd/src/net/osmand/plus/download/LocalIndexesFragment.java
@@ -13,9 +13,6 @@ import java.util.Locale;
import java.util.Map;
import java.util.Set;
-import android.text.method.LinkMovementMethod;
-import com.actionbarsherlock.app.ActionBar;
-import com.actionbarsherlock.view.*;
import net.osmand.IProgress;
import net.osmand.IndexConstants;
import net.osmand.access.AccessibleToast;
@@ -24,8 +21,11 @@ import net.osmand.plus.ContextMenuAdapter.OnContextMenuClick;
import net.osmand.plus.OsmandApplication;
import net.osmand.plus.OsmandPlugin;
import net.osmand.plus.R;
-import net.osmand.plus.activities.*;
+import net.osmand.plus.activities.LocalIndexHelper;
import net.osmand.plus.activities.LocalIndexHelper.LocalIndexType;
+import net.osmand.plus.activities.LocalIndexInfo;
+import net.osmand.plus.activities.OsmandBaseExpandableListAdapter;
+import net.osmand.plus.activities.OsmandExpandableListFragment;
import net.osmand.plus.helpers.FileNameTranslationHelper;
import net.osmand.util.Algorithms;
import android.app.Activity;
@@ -38,6 +38,7 @@ import android.graphics.Typeface;
import android.os.AsyncTask;
import android.os.Bundle;
import android.os.StatFs;
+import android.text.method.LinkMovementMethod;
import android.view.ContextMenu;
import android.view.ContextMenu.ContextMenuInfo;
import android.view.LayoutInflater;
@@ -51,7 +52,13 @@ import android.widget.ExpandableListView.ExpandableListContextMenuInfo;
import android.widget.TextView;
import android.widget.Toast;
+import com.actionbarsherlock.app.ActionBar;
+import com.actionbarsherlock.view.ActionMode;
import com.actionbarsherlock.view.ActionMode.Callback;
+import com.actionbarsherlock.view.Menu;
+import com.actionbarsherlock.view.MenuInflater;
+import com.actionbarsherlock.view.MenuItem;
+import com.actionbarsherlock.view.SubMenu;
public class LocalIndexesFragment extends OsmandExpandableListFragment {