Merge remote-tracking branch 'origin/master'
Before Width: | Height: | Size: 642 B After Width: | Height: | Size: 1.3 KiB |
Before Width: | Height: | Size: 720 B After Width: | Height: | Size: 1.3 KiB |
BIN
OsmAnd/res/drawable-hdpi/ic_download_disabled.png
Normal file
After Width: | Height: | Size: 1.2 KiB |
Before Width: | Height: | Size: 406 B After Width: | Height: | Size: 1.2 KiB |
Before Width: | Height: | Size: 452 B After Width: | Height: | Size: 1.2 KiB |
BIN
OsmAnd/res/drawable-mdpi/ic_download_disabled.png
Normal file
After Width: | Height: | Size: 1.1 KiB |
Before Width: | Height: | Size: 777 B After Width: | Height: | Size: 1.4 KiB |
Before Width: | Height: | Size: 838 B After Width: | Height: | Size: 1.4 KiB |
BIN
OsmAnd/res/drawable-xhdpi/ic_download_disabled.png
Normal file
After Width: | Height: | Size: 1.3 KiB |
BIN
OsmAnd/res/drawable-xxhdpi/ic_action_gdirections_dark.png
Normal file
After Width: | Height: | Size: 1.6 KiB |
BIN
OsmAnd/res/drawable-xxhdpi/ic_action_gdirections_light.png
Normal file
After Width: | Height: | Size: 1.5 KiB |
BIN
OsmAnd/res/drawable-xxhdpi/ic_download_disabled.png
Normal file
After Width: | Height: | Size: 1.5 KiB |
5
OsmAnd/res/drawable/download_disabled.xml
Normal file
|
@ -0,0 +1,5 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
|
||||
<selector xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<item android:drawable="@drawable/ic_download_cancel_tap" />
|
||||
</selector>
|
|
@ -19,8 +19,9 @@
|
|||
android:layout_height="28dp"/>
|
||||
|
||||
<LinearLayout android:orientation="vertical"
|
||||
android:layout_weight="1"
|
||||
android:layout_gravity="center_vertical"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content">
|
||||
<TextView android:id="@+id/name"
|
||||
android:textSize="16sp"
|
||||
|
@ -33,6 +34,13 @@
|
|||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"/>
|
||||
</LinearLayout>
|
||||
|
||||
<ImageButton android:id="@+id/navigate_to"
|
||||
android:src="@drawable/ic_action_gdirections_light"
|
||||
android:background="@drawable/dashboard_button"
|
||||
android:layout_marginLeft="12dp"
|
||||
android:layout_width="50dp"
|
||||
android:layout_height="50dp"/>
|
||||
</LinearLayout>
|
||||
|
||||
|
||||
|
|
|
@ -12,6 +12,7 @@
|
|||
android:layout_width="match_parent"
|
||||
android:layout_height="40dp">
|
||||
<TextView android:text="@string/map_update"
|
||||
android:id="@+id/header"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="fill_parent"
|
||||
android:paddingTop="2dp"
|
||||
|
@ -19,11 +20,6 @@
|
|||
android:layout_marginLeft="15dp"
|
||||
android:textSize="14sp"
|
||||
android:textColor="@color/dashboard_black"/>
|
||||
<TextView android:id="@+id/update_count"
|
||||
android:layout_marginLeft="2dp"
|
||||
android:layout_width="wrap_content"
|
||||
android:textColor="@color/dashboard_blue"
|
||||
android:layout_height="wrap_content"/>
|
||||
<ProgressBar android:id="@+id/main_progress"
|
||||
android:visibility="visible"
|
||||
android:layout_marginLeft="2dp"
|
||||
|
|
|
@ -32,7 +32,7 @@
|
|||
<string name="osmo_use_https_descr">Use secure connection with server</string>
|
||||
<string name="osmo_use_https">Use HTTPS</string>
|
||||
<string name="advanced_settings">Advanced</string>
|
||||
<string name="map_update">Maps</string>
|
||||
<string name="map_update">You have %1$s maps to update</string>
|
||||
<string name="search_for">Search for</string>
|
||||
<string name="show_map">SHOW MAP</string>
|
||||
<string name="show_all">SHOW ALL</string>
|
||||
|
|
|
@ -443,6 +443,10 @@ public class MainMenuActivity extends BaseDownloadActivity {
|
|||
Fragment f = ref.get();
|
||||
if(f instanceof DashUpdatesFragment) {
|
||||
if(!f.isDetached()) {
|
||||
if (downloadQueue.size() > 0){
|
||||
startDownload(downloadQueue.get(0));
|
||||
downloadQueue.remove(0);
|
||||
}
|
||||
((DashUpdatesFragment) f).updatedDownloadsList(list);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -21,6 +21,7 @@ import net.osmand.plus.OsmAndFormatter;
|
|||
import net.osmand.plus.R;
|
||||
import net.osmand.plus.activities.MapActivity;
|
||||
import net.osmand.plus.base.FavoriteImageDrawable;
|
||||
import net.osmand.plus.dialogs.DirectionsDialogs;
|
||||
import net.osmand.plus.helpers.FontCache;
|
||||
import net.osmand.util.MapUtils;
|
||||
|
||||
|
@ -101,6 +102,12 @@ public class DashFavoritesFragment extends DashBaseFragment {
|
|||
int dist = (int) (MapUtils.getDistance(point.getLatitude(), point.getLongitude(),
|
||||
lastKnownMapLocation.getLatitude(), lastKnownMapLocation.getLongitude()));
|
||||
String distance = OsmAndFormatter.getFormattedDistance(dist, getMyApplication()) + " ";
|
||||
view.findViewById(R.id.navigate_to).setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
DirectionsDialogs.directionsToDialogAndLaunchMap(getActivity(), point.getLatitude(), point.getLongitude(), point.getName());
|
||||
}
|
||||
});
|
||||
label.setText(distance, TextView.BufferType.SPANNABLE);
|
||||
label.setTypeface(Typeface.DEFAULT, point.isVisible() ? Typeface.NORMAL : Typeface.ITALIC);
|
||||
view.setOnClickListener(new View.OnClickListener() {
|
||||
|
|
|
@ -1,8 +1,11 @@
|
|||
package net.osmand.plus.dashboard;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.Comparator;
|
||||
import java.util.List;
|
||||
|
||||
import android.widget.*;
|
||||
import net.osmand.plus.R;
|
||||
import net.osmand.plus.base.BasicProgressAsyncTask;
|
||||
import net.osmand.plus.download.BaseDownloadActivity;
|
||||
|
@ -15,10 +18,6 @@ import android.support.annotation.Nullable;
|
|||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.ImageButton;
|
||||
import android.widget.LinearLayout;
|
||||
import android.widget.ProgressBar;
|
||||
import android.widget.TextView;
|
||||
|
||||
/**
|
||||
* Created by Denis on 21.11.2014.
|
||||
|
@ -31,6 +30,7 @@ public class DashUpdatesFragment extends DashBaseFragment {
|
|||
private List<ProgressBar> progressBars = new ArrayList<ProgressBar>();
|
||||
private List<String> baseNames = new ArrayList<String>();
|
||||
private List<ImageButton> downloadButtons = new ArrayList<ImageButton>();
|
||||
private List<IndexItem> downloadQueue = new ArrayList<IndexItem>();
|
||||
private ImageButton cancelButton;
|
||||
|
||||
@Override
|
||||
|
@ -56,6 +56,7 @@ public class DashUpdatesFragment extends DashBaseFragment {
|
|||
@Override
|
||||
public void onResume() {
|
||||
super.onResume();
|
||||
downloadQueue.clear();
|
||||
if (BaseDownloadActivity.downloadListIndexThread != null) {
|
||||
currentProgress = null;
|
||||
cancelButton = null;
|
||||
|
@ -64,6 +65,13 @@ public class DashUpdatesFragment extends DashBaseFragment {
|
|||
}
|
||||
|
||||
public void updatedDownloadsList(List<IndexItem> list) {
|
||||
List<IndexItem> itemList = new ArrayList<IndexItem>(list);
|
||||
Collections.sort(itemList, new Comparator<IndexItem>() {
|
||||
@Override
|
||||
public int compare(IndexItem indexItem, IndexItem t1) {
|
||||
return (int)(t1.getTimestamp() - indexItem.getTimestamp());
|
||||
}
|
||||
});
|
||||
View mainView = getView();
|
||||
//it may be null because download index thread is async
|
||||
if (mainView == null) {
|
||||
|
@ -73,20 +81,20 @@ public class DashUpdatesFragment extends DashBaseFragment {
|
|||
baseNames.clear();
|
||||
downloadButtons.clear();
|
||||
mainView.findViewById(R.id.main_progress).setVisibility(View.GONE);
|
||||
((TextView) mainView.findViewById(R.id.update_count)).setText(String.valueOf(list.size()));
|
||||
((TextView) mainView.findViewById(R.id.header)).setText(getString(R.string.map_update ,String.valueOf(list.size())));
|
||||
|
||||
LinearLayout updates = (LinearLayout) mainView.findViewById(R.id.updates_items);
|
||||
updates.removeAllViews();
|
||||
|
||||
if (list.size() < 1) {
|
||||
if (itemList.size() < 1) {
|
||||
mainView.findViewById(R.id.maps).setVisibility(View.GONE);
|
||||
return;
|
||||
} else {
|
||||
mainView.findViewById(R.id.maps).setVisibility(View.VISIBLE);
|
||||
}
|
||||
|
||||
for (int i = 0; i < list.size(); i++) {
|
||||
final IndexItem item = list.get(i);
|
||||
for (int i = 0; i < itemList.size(); i++) {
|
||||
final IndexItem item = itemList.get(i);
|
||||
if (i > 2) {
|
||||
break;
|
||||
}
|
||||
|
@ -103,8 +111,6 @@ public class DashUpdatesFragment extends DashBaseFragment {
|
|||
@Override
|
||||
public void onClick(View view) {
|
||||
getDownloadActivity().startDownload(item);
|
||||
currentProgress = progressBar;
|
||||
cancelButton = (ImageButton) view;
|
||||
}
|
||||
});
|
||||
downloadButtons.add((ImageButton) downloadButton);
|
||||
|
@ -124,7 +130,7 @@ public class DashUpdatesFragment extends DashBaseFragment {
|
|||
return;
|
||||
}
|
||||
//needed when rotation is performed and progress can be null
|
||||
if (currentProgress == null) {
|
||||
if (!updateOnlyProgress) {
|
||||
getProgressIfPossible(basicProgressAsyncTask.getDescription());
|
||||
if (currentProgress == null) {
|
||||
return;
|
||||
|
@ -140,7 +146,6 @@ public class DashUpdatesFragment extends DashBaseFragment {
|
|||
if (!visible) {
|
||||
return;
|
||||
}
|
||||
|
||||
cancelButton.setImageResource(R.drawable.cancel_button);
|
||||
cancelButton.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
|
|
|
@ -41,6 +41,7 @@ public class BaseDownloadActivity extends SherlockFragmentActivity {
|
|||
protected OsmandSettings settings;
|
||||
public static DownloadIndexesThread downloadListIndexThread;
|
||||
protected List<WeakReference<Fragment>> fragList = new ArrayList<WeakReference<Fragment>>();
|
||||
protected List<IndexItem> downloadQueue = new ArrayList<IndexItem>();
|
||||
|
||||
public static final int MAXIMUM_AVAILABLE_FREE_DOWNLOADS = 10;
|
||||
|
||||
|
@ -113,13 +114,18 @@ public class BaseDownloadActivity extends SherlockFragmentActivity {
|
|||
}
|
||||
|
||||
public void startDownload(IndexItem item) {
|
||||
if (downloadListIndexThread.getCurrentRunningTask() != null) {
|
||||
Toast.makeText(this, "Please wait before previous download is finished", Toast.LENGTH_SHORT).show();
|
||||
if (downloadListIndexThread.getCurrentRunningTask() != null && getEntriesToDownload().get(item) == null) {
|
||||
downloadQueue.add(item);
|
||||
Toast.makeText(this, "Added to download queue", Toast.LENGTH_SHORT).show();
|
||||
return;
|
||||
}
|
||||
addToDownload(item);
|
||||
downloadFilesCheckFreeVersion();
|
||||
}
|
||||
|
||||
private void addToDownload(IndexItem item) {
|
||||
List<DownloadEntry> download = item.createDownloadEntry(getMyApplication(), item.getType(), new ArrayList<DownloadEntry>());
|
||||
getEntriesToDownload().put(item, download);
|
||||
downloadFilesCheckFreeVersion();
|
||||
}
|
||||
|
||||
public void downloadFilesPreCheckSpace() {
|
||||
|
|
|
@ -163,7 +163,10 @@ public class DownloadIndexesThread {
|
|||
uiActivity.updateDownloadButton(false);
|
||||
}
|
||||
} else if (o instanceof String) {
|
||||
AccessibleToast.makeText(ctx, (String) o, Toast.LENGTH_LONG).show();
|
||||
String message = (String) o;
|
||||
if(!message.equals("I/O error occurred : Interrupted")){
|
||||
AccessibleToast.makeText(ctx, message, Toast.LENGTH_LONG).show();
|
||||
}
|
||||
}
|
||||
}
|
||||
super.onProgressUpdate(values);
|
||||
|
|