Merge remote-tracking branch 'origin/master'
This commit is contained in:
commit
f5d109fd81
8 changed files with 89 additions and 34 deletions
31
OsmAnd/res/layout/update_index_list_item.xml
Normal file
31
OsmAnd/res/layout/update_index_list_item.xml
Normal file
|
@ -0,0 +1,31 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
|
||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:paddingTop="1dp"
|
||||
android:paddingBottom="1dp"
|
||||
android:paddingRight="8dp">
|
||||
|
||||
<CheckBox android:id="@+id/check_download_item"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="match_parent"
|
||||
android:gravity="center_vertical"
|
||||
android:focusable="false"/>
|
||||
|
||||
<TextView android:layout_width="0dp"
|
||||
android:layout_height="match_parent"
|
||||
android:id="@+id/download_item"
|
||||
android:gravity="center_vertical"
|
||||
android:maxLines="7"
|
||||
android:layout_weight="1"
|
||||
style="@style/ListText.Small"/>
|
||||
|
||||
<TextView android:layout_width="wrap_content"
|
||||
android:layout_height="match_parent"
|
||||
android:id="@+id/download_descr"
|
||||
android:layout_marginLeft="3dp"
|
||||
android:gravity="right|center_vertical"
|
||||
style="@style/ListText.Small"/>
|
||||
|
||||
</LinearLayout>
|
|
@ -11,6 +11,7 @@ import net.osmand.plus.OsmandApplication;
|
|||
import net.osmand.plus.R;
|
||||
import net.osmand.plus.Version;
|
||||
import net.osmand.plus.activities.search.SearchActivity;
|
||||
import net.osmand.plus.download.DownloadActivity;
|
||||
import net.osmand.plus.download.DownloadIndexFragment;
|
||||
import net.osmand.plus.render.MapRenderRepositories;
|
||||
import net.osmand.plus.sherpafy.TourViewActivity;
|
||||
|
@ -376,7 +377,7 @@ public class MainMenuActivity extends Activity {
|
|||
|
||||
@Override
|
||||
public void onClick(DialogInterface dialog, int which) {
|
||||
startActivity(new Intent(MainMenuActivity.this, DownloadIndexFragment.class));
|
||||
startActivity(new Intent(MainMenuActivity.this, DownloadActivity.class));
|
||||
}
|
||||
|
||||
});
|
||||
|
|
|
@ -374,7 +374,7 @@ public class SettingsGeneralActivity extends SettingsBaseActivity {
|
|||
if (id.equals(settings.VOICE_PROVIDER.getId())) {
|
||||
if (MORE_VALUE.equals(newValue)) {
|
||||
// listPref.set(oldValue); // revert the change..
|
||||
final Intent intent = new Intent(this, DownloadIndexFragment.class);
|
||||
final Intent intent = new Intent(this, DownloadActivity.class);
|
||||
intent.putExtra(DownloadActivity.FILTER_CAT, DownloadActivityType.VOICE_FILE.getTag());
|
||||
startActivity(intent);
|
||||
} else {
|
||||
|
|
|
@ -44,6 +44,8 @@ public class DownloadActivity extends SherlockFragmentActivity {
|
|||
private TextView progressMessage;
|
||||
private TextView progressPercent;
|
||||
private ImageView cancel;
|
||||
private UpdatesIndexFragment updatesIndexFragment;
|
||||
|
||||
|
||||
public static final String FILTER_KEY = "filter";
|
||||
public static final String FILTER_CAT = "filter_cat";
|
||||
|
@ -129,6 +131,10 @@ public class DownloadActivity extends SherlockFragmentActivity {
|
|||
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
|
||||
}
|
||||
|
||||
public void setUpdatesIndexFragment(UpdatesIndexFragment fragment){
|
||||
this.updatesIndexFragment = fragment;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onResume() {
|
||||
super.onResume();
|
||||
|
@ -320,9 +326,10 @@ public class DownloadActivity extends SherlockFragmentActivity {
|
|||
}
|
||||
|
||||
public void updateDownloadList(List<IndexItem> list){
|
||||
Fragment fragment = mTabsAdapter.getItem(2);
|
||||
//will fall if change tab order
|
||||
((UpdatesIndexFragment) fragment).updateItemsList(list);
|
||||
if(updatesIndexFragment == null){
|
||||
return;
|
||||
}
|
||||
updatesIndexFragment.updateItemsList(list);
|
||||
}
|
||||
|
||||
public void updateDownloadButton(boolean scroll) {
|
||||
|
|
|
@ -182,6 +182,7 @@ public class DownloadIndexesThread {
|
|||
DownloadIndexAdapter adapter = ((DownloadIndexAdapter) uiFragment.getExpandableListAdapter());
|
||||
if (adapter != null) {
|
||||
adapter.setLoadedFiles(indexActivatedFileNames, indexFileNames);
|
||||
updateFilesToUpdate();
|
||||
}
|
||||
}
|
||||
currentRunningTask.remove(this);
|
||||
|
@ -546,16 +547,6 @@ public class DownloadIndexesThread {
|
|||
execute(inst, new Void[0]);
|
||||
}
|
||||
|
||||
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<IndexItem> filtered) {
|
||||
itemsToUpdate.clear();
|
||||
for (IndexItem item : filtered) {
|
||||
|
@ -571,7 +562,25 @@ public class DownloadIndexesThread {
|
|||
itemsToUpdate.add(item);
|
||||
}
|
||||
}
|
||||
itemsToUpdate.size();
|
||||
uiFragment.getDownloadActivity().updateDownloadList(itemsToUpdate);
|
||||
}
|
||||
|
||||
private void updateFilesToUpdate(){
|
||||
List<IndexItem> stillUpdate = new ArrayList<IndexItem>();
|
||||
for (IndexItem item : itemsToUpdate) {
|
||||
String sfName = item.getTargetFileName();
|
||||
java.text.DateFormat format = uiFragment.getDownloadActivity().getMyApplication().getResourceManager().getDateFormat();
|
||||
String date = item.getDate(format);
|
||||
String indexactivateddate = indexActivatedFileNames.get(sfName);
|
||||
String indexfilesdate = indexFileNames.get(sfName);
|
||||
if (date != null &&
|
||||
!date.equals(indexactivateddate) &&
|
||||
!date.equals(indexfilesdate) &&
|
||||
indexActivatedFileNames.containsKey(sfName)) {
|
||||
stillUpdate.add(item);
|
||||
}
|
||||
}
|
||||
itemsToUpdate = stillUpdate;
|
||||
uiFragment.getDownloadActivity().updateDownloadList(itemsToUpdate);
|
||||
}
|
||||
|
||||
|
|
|
@ -640,10 +640,7 @@ public class LocalIndexesFragment extends OsmandExpandableListFragment {
|
|||
}
|
||||
|
||||
public void localOptionsMenu(final int itemId) {
|
||||
if (itemId == R.string.local_index_download) {
|
||||
asyncLoader.setResult(null);
|
||||
startActivity(new Intent(getDownloadActivity(), DownloadIndexFragment.class));
|
||||
} else if (itemId == R.string.local_index_mi_reload) {
|
||||
if (itemId == R.string.local_index_mi_reload) {
|
||||
reloadIndexes();
|
||||
} else if (itemId == R.string.local_index_mi_delete) {
|
||||
openSelectionMode(itemId, R.drawable.ic_action_delete_dark, R.drawable.ic_action_delete_light,
|
||||
|
|
|
@ -20,6 +20,7 @@ import net.osmand.plus.activities.OsmandExpandableListFragment;
|
|||
|
||||
import java.text.MessageFormat;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Comparator;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
|
@ -32,33 +33,34 @@ public class UpdatesIndexFragment extends SherlockListFragment {
|
|||
private java.text.DateFormat format;
|
||||
private UpdateIndexAdapter listAdapter;
|
||||
|
||||
|
||||
@Override
|
||||
public void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
format = getMyApplication().getResourceManager().getDateFormat();
|
||||
osmandRegions = getMyApplication().getResourceManager().getOsmandRegions();
|
||||
listAdapter = new UpdateIndexAdapter(getDownloadActivity(), R.layout.download_index_list_item, DownloadActivity.downloadListIndexThread.getItemsToUpdate());
|
||||
listAdapter.sort(new Comparator<IndexItem>() {
|
||||
@Override
|
||||
public int compare(IndexItem indexItem, IndexItem indexItem2) {
|
||||
return indexItem.getVisibleName(getMyApplication(), osmandRegions).compareTo(indexItem2.getVisibleName(getMyApplication(), osmandRegions));
|
||||
}
|
||||
});
|
||||
setListAdapter(listAdapter);
|
||||
setHasOptionsMenu(true);
|
||||
getDownloadActivity().setUpdatesIndexFragment(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onResume() {
|
||||
super.onResume();
|
||||
|
||||
Map<IndexItem, List<DownloadEntry>> map = getDownloadActivity().getEntriesToDownload();
|
||||
|
||||
}
|
||||
|
||||
public void updateItemsList(List<IndexItem> items) {
|
||||
UpdateIndexAdapter adapter = (UpdateIndexAdapter) getListAdapter();
|
||||
if (adapter == null) {
|
||||
if(listAdapter == null){
|
||||
return;
|
||||
}
|
||||
adapter.clear();
|
||||
for (IndexItem item : items) {
|
||||
adapter.add(item);
|
||||
}
|
||||
listAdapter.setIndexFiles(items);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -170,7 +172,7 @@ public class UpdatesIndexFragment extends SherlockListFragment {
|
|||
|
||||
if (v == null) {
|
||||
LayoutInflater inflater = (LayoutInflater) getDownloadActivity().getSystemService(Context.LAYOUT_INFLATER_SERVICE);
|
||||
v = inflater.inflate(R.layout.download_index_list_item, null);
|
||||
v = inflater.inflate(R.layout.update_index_list_item, null);
|
||||
}
|
||||
|
||||
TextView name = (TextView) v.findViewById(R.id.download_item);
|
||||
|
@ -209,9 +211,16 @@ public class UpdatesIndexFragment extends SherlockListFragment {
|
|||
}
|
||||
|
||||
public void setIndexFiles(List<IndexItem> filtered) {
|
||||
this.items.clear();
|
||||
this.items.addAll(filtered);
|
||||
notifyDataSetChanged();
|
||||
clear();
|
||||
for (IndexItem item : filtered){
|
||||
add(item);
|
||||
}
|
||||
sort(new Comparator<IndexItem>() {
|
||||
@Override
|
||||
public int compare(IndexItem indexItem, IndexItem indexItem2) {
|
||||
return indexItem.getVisibleName(getMyApplication(), osmandRegions).compareTo(indexItem2.getVisibleName(getMyApplication(), osmandRegions));
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -5,6 +5,7 @@ import java.util.WeakHashMap;
|
|||
import net.osmand.data.LatLon;
|
||||
import net.osmand.plus.OsmandApplication;
|
||||
import net.osmand.plus.R;
|
||||
import net.osmand.plus.download.DownloadActivity;
|
||||
import net.osmand.plus.download.DownloadIndexFragment;
|
||||
import net.osmand.plus.sherpafy.TourInformation.StageFavorite;
|
||||
import net.osmand.plus.sherpafy.TourInformation.StageInformation;
|
||||
|
@ -376,7 +377,7 @@ public class TourViewActivity extends SherlockFragmentActivity {
|
|||
|
||||
|
||||
public void startDownloadActivity() {
|
||||
final Intent download = new Intent(this, DownloadIndexFragment.class);
|
||||
final Intent download = new Intent(this, DownloadActivity.class);
|
||||
download.setFlags(Intent.FLAG_ACTIVITY_REORDER_TO_FRONT);
|
||||
refreshListAfterDownload = true;
|
||||
startActivity(download);
|
||||
|
|
Loading…
Reference in a new issue