From 27f4874ec0dddb937ee7417426bb00b0dda79428 Mon Sep 17 00:00:00 2001 From: Denis Date: Fri, 12 Sep 2014 11:16:11 +0300 Subject: [PATCH 1/4] Added < icon in action bar --- OsmAnd/src/net/osmand/plus/download/DownloadActivity.java | 1 + 1 file changed, 1 insertion(+) diff --git a/OsmAnd/src/net/osmand/plus/download/DownloadActivity.java b/OsmAnd/src/net/osmand/plus/download/DownloadActivity.java index 10252e8ceb..a49ec13b88 100644 --- a/OsmAnd/src/net/osmand/plus/download/DownloadActivity.java +++ b/OsmAnd/src/net/osmand/plus/download/DownloadActivity.java @@ -124,6 +124,7 @@ public class DownloadActivity extends SherlockFragmentActivity { } getSupportActionBar().setHomeButtonEnabled(true); + getSupportActionBar().setDisplayHomeAsUpEnabled(true); } @Override From 93cd84b75179b89cc3ddc85e2eda367911c09a03 Mon Sep 17 00:00:00 2001 From: Denis Date: Fri, 12 Sep 2014 11:44:53 +0300 Subject: [PATCH 2/4] Fixed description for local index --- OsmAnd/res/values/strings.xml | 2 +- .../plus/download/LocalIndexesFragment.java | 33 +++++++------------ 2 files changed, 13 insertions(+), 22 deletions(-) diff --git a/OsmAnd/res/values/strings.xml b/OsmAnd/res/values/strings.xml index 2c974783cb..43779b7c83 100644 --- a/OsmAnd/res/values/strings.xml +++ b/OsmAnd/res/values/strings.xml @@ -1100,7 +1100,7 @@ Afghanistan, Albania, Algeria, Andorra, Angola, Anguilla, Antigua and Barbuda, A OsmAnd offline navigation is temporarily not available. Left-hand driving Select for countries with left-hand traffic - Click here to download or update offline map files. \nClick any existing item to see more details, press and hold to deactivate or delete. Current data on device (%1$s free): + Click any existing item to see more details, press and hold to deactivate or delete. Current data on device (%1$s free): Starting point is not yet determined Position not yet known Modify transparency (0 - transparent, 255 - opaque) diff --git a/OsmAnd/src/net/osmand/plus/download/LocalIndexesFragment.java b/OsmAnd/src/net/osmand/plus/download/LocalIndexesFragment.java index 8582e7f5cc..7b0cbf54dd 100644 --- a/OsmAnd/src/net/osmand/plus/download/LocalIndexesFragment.java +++ b/OsmAnd/src/net/osmand/plus/download/LocalIndexesFragment.java @@ -10,6 +10,8 @@ import java.util.Locale; import java.util.Map; import java.util.Set; +import android.graphics.Color; +import android.text.method.LinkMovementMethod; import com.actionbarsherlock.app.ActionBar; import com.actionbarsherlock.view.*; import net.osmand.IProgress; @@ -71,6 +73,8 @@ public class LocalIndexesFragment extends OsmandExpandableListFragment { private ContextMenuAdapter optionsMenuAdapter; private ActionMode actionMode; + private TextView descriptionText; + @Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View view = inflater.inflate(R.layout.local_index, container, false); @@ -83,6 +87,8 @@ public class LocalIndexesFragment extends OsmandExpandableListFragment { listView.setAdapter(listAdapter); setListView(listView); //getDownloadActivity().getSupportActionBar().setLogo(R.drawable.tab_download_screen_icon); + descriptionText = (TextView) view.findViewById(R.id.DescriptionText); + updateDescriptionTextWithSize(); return view; } @@ -93,7 +99,6 @@ public class LocalIndexesFragment extends OsmandExpandableListFragment { descriptionLoader = new LoadLocalIndexDescriptionTask(); - updateDescriptionTextWithSize(); if (asyncLoader == null || asyncLoader.getResult() == null) { // getLastNonConfigurationInstance method should be in onCreate() method // (onResume() doesn't work) @@ -606,8 +611,8 @@ public class LocalIndexesFragment extends OsmandExpandableListFragment { @Override public void onDestroyActionMode(ActionMode mode) { selectionMode = false; - //findViewById(R.id.DescriptionText).setVisibility(View.VISIBLE); - //updateDescriptionTextWithSize(); + descriptionText.setVisibility(View.VISIBLE); + updateDescriptionTextWithSize(); listAdapter.cancelFilter(); collapseAllGroups(); listAdapter.notifyDataSetChanged(); @@ -625,28 +630,14 @@ public class LocalIndexesFragment extends OsmandExpandableListFragment { StatFs fs = new StatFs(dir.getAbsolutePath()); size = formatGb.format(new Object[]{(float) (fs.getAvailableBlocks()) * fs.getBlockSize() / (1 << 30) }); } - //TextView ds = (TextView) findViewById(R.id.DescriptionText); - String text = getString(R.string.download_link_and_local_description, size); + + String text = getString(R.string.local_index_description, size); int l = text.indexOf('.'); if(l == -1) { l = text.length(); } - SpannableString content = new SpannableString(text); - content.setSpan(new ClickableSpan() { - @Override - public void onClick(View widget) { - asyncLoader.setResult(null); - startActivity(new Intent(getDownloadActivity(), DownloadIndexFragment.class)); - } - - @Override - public void updateDrawState(TextPaint ds) { - super.updateDrawState(ds); -// ds.setColor(Color.GREEN); - } - }, 0, l, 0); - //ds.setText(content); - //ds.setMovementMethod(LinkMovementMethod.getInstance()); + descriptionText.setText(text); + descriptionText.setMovementMethod(LinkMovementMethod.getInstance()); } From 400b3263cae26159a8518c3f0eddae6762d371e3 Mon Sep 17 00:00:00 2001 From: Denis Date: Fri, 12 Sep 2014 12:35:12 +0300 Subject: [PATCH 3/4] Fixed bug when pressing on item in downloads doesnt trigger download button functionality --- .../plus/download/DownloadIndexAdapter.java | 6 ++++++ .../plus/download/DownloadIndexFragment.java | 5 +++-- .../plus/download/DownloadIndexesThread.java | 15 ++++++++++++-- .../plus/download/LocalIndexesFragment.java | 20 ++++++++----------- 4 files changed, 30 insertions(+), 16 deletions(-) diff --git a/OsmAnd/src/net/osmand/plus/download/DownloadIndexAdapter.java b/OsmAnd/src/net/osmand/plus/download/DownloadIndexAdapter.java index ae7ef61480..8f07ba3130 100644 --- a/OsmAnd/src/net/osmand/plus/download/DownloadIndexAdapter.java +++ b/OsmAnd/src/net/osmand/plus/download/DownloadIndexAdapter.java @@ -236,6 +236,12 @@ public class DownloadIndexAdapter extends OsmandBaseExpandableListAdapter implem v = inflater.inflate(net.osmand.plus.R.layout.download_index_list_item, parent, false); } final View row = v; + row.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View view) { + downloadFragment.onChildClick(downloadFragment.getExpandableListView(), row, groupPosition, childPosition, getChildId(groupPosition, childPosition)); + } + }); TextView item = (TextView) row.findViewById(R.id.download_item); TextView description = (TextView) row.findViewById(R.id.download_descr); IndexItem e = (IndexItem) getChild(groupPosition, childPosition); diff --git a/OsmAnd/src/net/osmand/plus/download/DownloadIndexFragment.java b/OsmAnd/src/net/osmand/plus/download/DownloadIndexFragment.java index ae7adc9adf..cf74483124 100644 --- a/OsmAnd/src/net/osmand/plus/download/DownloadIndexFragment.java +++ b/OsmAnd/src/net/osmand/plus/download/DownloadIndexFragment.java @@ -67,7 +67,8 @@ public class DownloadIndexFragment extends OsmandExpandableListFragment { listView.setAdapter(listAdapter); setListView(listView); - //getSupportActionBar().setTitle(R.string.local_index_download); + + getDownloadActivity().getSupportActionBar().setTitle(R.string.local_index_download); // recreation upon rotation is pgetaprevented in manifest file filterText = (EditText) view.findViewById(R.id.search_box); @@ -331,7 +332,7 @@ public class DownloadIndexFragment extends OsmandExpandableListFragment { @Override public boolean onChildClick(ExpandableListView parent, View v, int groupPosition, int childPosition, long id) { - final IndexItem e = (IndexItem) listAdapter.getChild(groupPosition, childPosition); + final IndexItem e = listAdapter.getChild(groupPosition, childPosition); final CheckBox ch = (CheckBox) v.findViewById(R.id.check_download_item); if(ch.isChecked()){ diff --git a/OsmAnd/src/net/osmand/plus/download/DownloadIndexesThread.java b/OsmAnd/src/net/osmand/plus/download/DownloadIndexesThread.java index bd846a6a03..e00bc8b0ec 100644 --- a/OsmAnd/src/net/osmand/plus/download/DownloadIndexesThread.java +++ b/OsmAnd/src/net/osmand/plus/download/DownloadIndexesThread.java @@ -103,6 +103,7 @@ public class DownloadIndexesThread { app.getResourceManager().getBackupIndexes(indexFileNames); this.indexFileNames = indexFileNames; this.indexActivatedFileNames = indexActivatedFileNames; + //updateFilesToDownload(); } public Map getDownloadedIndexFileNames() { @@ -504,7 +505,7 @@ public class DownloadIndexesThread { DownloadIndexAdapter a = ((DownloadIndexAdapter) uiFragment.getExpandableListAdapter()); a.setLoadedFiles(indexActivatedFileNames, indexFileNames); a.setIndexFiles(filtered, cats); - prepareFilesToDownload(filtered); + prepareFilesToUpdate(filtered); a.notifyDataSetChanged(); a.getFilter().filter(uiFragment.getFilterText()); if ((type == DownloadActivityType.SRTM_COUNTRY_FILE || type == DownloadActivityType.HILLSHADE_FILE) @@ -545,7 +546,17 @@ public class DownloadIndexesThread { execute(inst, new Void[0]); } - private void prepareFilesToDownload(List filtered) { + private void updateFilesToDownload(){ + for (IndexItem item : itemsToUpdate){ + for (String key : indexFileNames.keySet()){ + if (item.getFileName().equals(indexFileNames.get(key))){ + itemsToUpdate.remove(item); + } + } + } + } + + private void prepareFilesToUpdate(List filtered) { itemsToUpdate.clear(); for (IndexItem item : filtered) { String sfName = item.getTargetFileName(); diff --git a/OsmAnd/src/net/osmand/plus/download/LocalIndexesFragment.java b/OsmAnd/src/net/osmand/plus/download/LocalIndexesFragment.java index 7b0cbf54dd..c06114bb6f 100644 --- a/OsmAnd/src/net/osmand/plus/download/LocalIndexesFragment.java +++ b/OsmAnd/src/net/osmand/plus/download/LocalIndexesFragment.java @@ -461,6 +461,7 @@ public class LocalIndexesFragment extends OsmandExpandableListFragment { @Override public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) { + ActionBar actionBar = getDownloadActivity().getSupportActionBar(); //hide action bar from downloadindexfragment actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_STANDARD); @@ -508,17 +509,14 @@ public class LocalIndexesFragment extends OsmandExpandableListFragment { } } + + if(operationTask == null || operationTask.getStatus() == AsyncTask.Status.FINISHED){ + menu.setGroupVisible(0, true); + } else { + menu.setGroupVisible(0, false); + } } -// @Override -// public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) { -// if(operationTask == null || operationTask.getStatus() == Status.FINISHED){ -// menu.setGroupVisible(0, true); -// } else { -// menu.setGroupVisible(0, false); -// } -// } - @Override public boolean onOptionsItemSelected(MenuItem item) { int itemId = item.getItemId(); @@ -639,9 +637,7 @@ public class LocalIndexesFragment extends OsmandExpandableListFragment { descriptionText.setText(text); descriptionText.setMovementMethod(LinkMovementMethod.getInstance()); } - - - + public void localOptionsMenu(final int itemId) { if (itemId == R.string.local_index_download) { asyncLoader.setResult(null); From c76d5a021b9b8071e33b0794fedadb6d48a3c7b7 Mon Sep 17 00:00:00 2001 From: Denis Date: Fri, 12 Sep 2014 16:56:40 +0300 Subject: [PATCH 4/4] Fixed bug with not showing items in local index, also fixed issue when progress bar doesnt show --- OsmAnd/res/layout/download_index_list_item.xml | 4 ++-- OsmAnd/src/net/osmand/plus/download/DownloadActivity.java | 4 +++- OsmAnd/src/net/osmand/plus/download/LocalIndexesFragment.java | 3 ++- OsmAnd/src/net/osmand/plus/download/UpdatesIndexFragment.java | 2 +- 4 files changed, 8 insertions(+), 5 deletions(-) diff --git a/OsmAnd/res/layout/download_index_list_item.xml b/OsmAnd/res/layout/download_index_list_item.xml index eeaeea55f0..fb6485a6f9 100644 --- a/OsmAnd/res/layout/download_index_list_item.xml +++ b/OsmAnd/res/layout/download_index_list_item.xml @@ -7,9 +7,9 @@ android:gravity="center_vertical" android:focusable="false" /> + android:maxLines="7" android:layout_weight="1" style="@style/ListText.Small"/> + android:layout_height="wrap_content" style="@style/ListText.Small"/> diff --git a/OsmAnd/src/net/osmand/plus/download/DownloadActivity.java b/OsmAnd/src/net/osmand/plus/download/DownloadActivity.java index a49ec13b88..75057bf4d7 100644 --- a/OsmAnd/src/net/osmand/plus/download/DownloadActivity.java +++ b/OsmAnd/src/net/osmand/plus/download/DownloadActivity.java @@ -13,6 +13,7 @@ import android.view.View; import android.widget.*; import com.actionbarsherlock.app.ActionBar; import com.actionbarsherlock.app.SherlockFragmentActivity; +import com.actionbarsherlock.view.Window; import net.osmand.plus.*; import net.osmand.plus.activities.FavouritesActivity; import net.osmand.plus.base.BasicProgressAsyncTask; @@ -52,7 +53,8 @@ public class DownloadActivity extends SherlockFragmentActivity { protected void onCreate(Bundle savedInstanceState) { getMyApplication().applyTheme(this); super.onCreate(savedInstanceState); - + requestWindowFeature(Window.FEATURE_INDETERMINATE_PROGRESS); + setProgressBarIndeterminateVisibility(false); setContentView(R.layout.tab_content); OsmandSettings settings = ((OsmandApplication) getApplication()).getSettings(); diff --git a/OsmAnd/src/net/osmand/plus/download/LocalIndexesFragment.java b/OsmAnd/src/net/osmand/plus/download/LocalIndexesFragment.java index c06114bb6f..070deed646 100644 --- a/OsmAnd/src/net/osmand/plus/download/LocalIndexesFragment.java +++ b/OsmAnd/src/net/osmand/plus/download/LocalIndexesFragment.java @@ -461,7 +461,8 @@ public class LocalIndexesFragment extends OsmandExpandableListFragment { @Override public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) { - + //fixes issue when local files not shown after switching tabs + reloadIndexes(); ActionBar actionBar = getDownloadActivity().getSupportActionBar(); //hide action bar from downloadindexfragment actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_STANDARD); diff --git a/OsmAnd/src/net/osmand/plus/download/UpdatesIndexFragment.java b/OsmAnd/src/net/osmand/plus/download/UpdatesIndexFragment.java index 8a0f0189d9..ff5781ac80 100644 --- a/OsmAnd/src/net/osmand/plus/download/UpdatesIndexFragment.java +++ b/OsmAnd/src/net/osmand/plus/download/UpdatesIndexFragment.java @@ -82,7 +82,7 @@ public class UpdatesIndexFragment extends SherlockListFragment { TextView name = (TextView) v.findViewById(R.id.download_item); TextView description = (TextView) v.findViewById(R.id.download_descr); IndexItem e = items.get(position); - String eName = e.getVisibleDescription(getMyApplication()) + "\n" + e.getVisibleName(getMyApplication(), osmandRegions); + String eName = e.getVisibleName(getMyApplication(), osmandRegions); name.setText(eName.trim()); //$NON-NLS-1$ String d = e.getDate(format) + "\n" + e.getSizeDescription(getMyApplication()); description.setText(d);