implement progress indicator
git-svn-id: https://osmand.googlecode.com/svn/trunk@535 e29c36b1-1cfa-d876-8d93-3434fc2bb7b8
|
@ -8,24 +8,26 @@ package net.osmand;
|
|||
public class ToDoConstants {
|
||||
|
||||
|
||||
// TODO max 96
|
||||
|
||||
// TODO max 97
|
||||
// FOR 0.4 beta RELEASE
|
||||
// ! 89. Transport redesign UI (enable run from context menu, switch go to goal/not) !
|
||||
// ! 95. Show progress while map rendered and loaded (Issue)
|
||||
|
||||
// +!_1 . VELCOM animation
|
||||
// !_25. Add all attributes needed for routing (highway attributes, turn_restrictions)
|
||||
// !_22. Verify all POI has a point_type (in order to search them)
|
||||
// !_22. Verify all POI has a point_type (in order to search them) and fix POI issues (!)
|
||||
|
||||
// !_28. Rotate crash (progress dialog)
|
||||
// !_29. Fix memory for netherlands map creator
|
||||
// _30. About screen (Issue)
|
||||
// _18. Fix loading map data in rotated mode (check properly boundaries) +/-
|
||||
|
||||
|
||||
/// PROFILE AND REVIEW Rendering !!!
|
||||
// - Review Ref on the road on low zooms
|
||||
|
||||
// - Fix broken multipolygon
|
||||
|
||||
//+-!_28. Rotate crash (progress dialog) [not reproducible]
|
||||
//+- _18. Fix loading map data in rotated mode (check properly boundaries)
|
||||
//+ !_1 . VELCOM animation
|
||||
//+ _30. About screen (Issue)
|
||||
//+ _30. Bug with landscape (?)
|
||||
|
||||
// not required
|
||||
// ! 81. Add some objects to POI category (1) to add them into OSM 2) to help navigation)
|
||||
// highway (?), traffic_calming (?), barrier(?), military(?-), landuse (?), office(?), man_made(?), power(?),
|
||||
|
@ -61,8 +63,10 @@ public class ToDoConstants {
|
|||
// 93. Implement multitype vector objects - building with fence, road & tram ...
|
||||
// 90. Use Junidecode library on the client for english translation for map rendering
|
||||
// 96. Download voice data through UI interface (Issue)
|
||||
// 95. Show progress while map rendered and loaded (Issue)
|
||||
|
||||
// DONE SWING
|
||||
// 12. Reinvent UI of swing app (remove Region object and clear other MapObject)
|
||||
// 12. Reinvent UI of swing app (remove Region object and clear other MapObject)
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -5,7 +5,7 @@ public class Version {
|
|||
public static final String APP_VERSION = "0.4"; //$NON-NLS-1$
|
||||
public static final String APP_NAME = "OsmAnd"; //$NON-NLS-1$
|
||||
public static final String APP_DESCRIPTION = "alpha (b2)"; //$NON-NLS-1$
|
||||
public static final boolean VELCOM_EDITION = false;
|
||||
public static final boolean VELCOM_EDITION = true;
|
||||
|
||||
public static final String APP_NAME_VERSION = APP_NAME + " " + APP_VERSION; //$NON-NLS-1$
|
||||
public static final String APP_FULL_NAME = APP_NAME + " " + APP_VERSION + " " +APP_DESCRIPTION; //$NON-NLS-1$ //$NON-NLS-2$
|
||||
|
|
Before Width: | Height: | Size: 23 KiB After Width: | Height: | Size: 16 KiB |
BIN
OsmAnd/res/drawable/spinner_black_76.png
Normal file
After Width: | Height: | Size: 2.6 KiB |
BIN
OsmAnd/res/drawable/spinner_blue_76.png
Normal file
After Width: | Height: | Size: 53 KiB |
BIN
OsmAnd/res/drawable/spinner_green_76.png
Normal file
After Width: | Height: | Size: 1.5 KiB |
Before Width: | Height: | Size: 30 KiB After Width: | Height: | Size: 14 KiB |
|
@ -4,6 +4,9 @@
|
|||
android:layout_width="fill_parent"
|
||||
android:layout_height="fill_parent">
|
||||
<net.osmand.views.OsmandMapTileView android:id="@+id/MapView" android:layout_width="fill_parent" android:layout_height="fill_parent"/>
|
||||
<View android:id="@+id/ProgressBar"
|
||||
android:layout_width="40dp" android:layout_height="40dp" android:layout_marginRight="25dp" android:layout_marginTop="5dp" android:layout_gravity="top|right"/>
|
||||
|
||||
<net.osmand.views.OsmZoomControls android:id="@+id/ZoomControls"
|
||||
android:layout_marginRight="3dp" android:layout_marginBottom="2dp"
|
||||
android:layout_width="100dp" android:layout_height="wrap_content" android:layout_gravity="bottom|right"/>
|
||||
|
|
89
OsmAnd/src/net/osmand/BusyIndicator.java
Normal file
|
@ -0,0 +1,89 @@
|
|||
package net.osmand;
|
||||
|
||||
import android.content.Context;
|
||||
import android.graphics.drawable.Drawable;
|
||||
import android.os.Handler;
|
||||
import android.view.View;
|
||||
import android.view.animation.Animation;
|
||||
import android.view.animation.LinearInterpolator;
|
||||
import android.view.animation.RotateAnimation;
|
||||
|
||||
public class BusyIndicator {
|
||||
|
||||
private View bar;
|
||||
private Handler uiHandler;
|
||||
private int status;
|
||||
private final Context ctx;
|
||||
|
||||
public static final int STATUS_INVISIBLE = 0;
|
||||
public static final int STATUS_GREEN = 1;
|
||||
public static final int STATUS_BLUE = 2;
|
||||
public static final int STATUS_BLACK = 3;
|
||||
|
||||
public BusyIndicator(Context ctx, View bar){
|
||||
this.ctx = ctx;
|
||||
this.bar = bar;
|
||||
bar.setVisibility(View.INVISIBLE);
|
||||
uiHandler = new Handler();
|
||||
}
|
||||
|
||||
public boolean isVisible(){
|
||||
return status != 0;
|
||||
}
|
||||
|
||||
public int getStatus(){
|
||||
return status;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* @param status - 0 invisible
|
||||
* 1
|
||||
*/
|
||||
public void updateStatus(int status){
|
||||
if(this.status != status){
|
||||
this.status = status;
|
||||
final Drawable drawable;
|
||||
if(this.status == STATUS_BLACK){
|
||||
drawable = ctx.getResources().getDrawable(R.drawable.spinner_black_76);
|
||||
} else if(this.status == STATUS_BLUE){
|
||||
drawable = ctx.getResources().getDrawable(R.drawable.spinner_blue_76);
|
||||
} else if(this.status == STATUS_GREEN){
|
||||
drawable = ctx.getResources().getDrawable(R.drawable.spinner_green_76);
|
||||
} else {
|
||||
drawable = null;
|
||||
}
|
||||
final RotateAnimation animation;
|
||||
if(drawable != null){
|
||||
animation = new RotateAnimation(0, 360, RotateAnimation.RELATIVE_TO_SELF, 0.5f, RotateAnimation.RELATIVE_TO_SELF, 0.5f);
|
||||
animation.setRepeatCount(Animation.INFINITE);
|
||||
animation.setInterpolator(new LinearInterpolator());
|
||||
animation.setDuration(850);
|
||||
animation.setStartTime(RotateAnimation.START_ON_FIRST_FRAME);
|
||||
animation.setStartOffset(0);
|
||||
} else {
|
||||
animation = null;
|
||||
}
|
||||
uiHandler.post(new Runnable(){
|
||||
@Override
|
||||
public void run() {
|
||||
bar.setVisibility(drawable != null ? View.VISIBLE : View.INVISIBLE);
|
||||
if(bar.getAnimation() != null){
|
||||
bar.clearAnimation();
|
||||
}
|
||||
if(drawable != null){
|
||||
bar.setBackgroundDrawable(drawable);
|
||||
bar.startAnimation(animation);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
|
@ -12,6 +12,7 @@ import java.util.Map;
|
|||
import java.util.Stack;
|
||||
import java.util.TreeMap;
|
||||
|
||||
import net.osmand.activities.OsmandApplication;
|
||||
import net.osmand.data.Amenity;
|
||||
import net.osmand.data.TransportStop;
|
||||
import net.osmand.data.index.IndexConstants;
|
||||
|
@ -26,7 +27,6 @@ import net.osmand.views.POIMapLayer;
|
|||
|
||||
import org.apache.commons.logging.Log;
|
||||
|
||||
import android.content.Context;
|
||||
import android.database.sqlite.SQLiteException;
|
||||
import android.graphics.Bitmap;
|
||||
import android.graphics.BitmapFactory;
|
||||
|
@ -75,7 +75,9 @@ public class ResourceManager {
|
|||
|
||||
protected File dirWithTiles ;
|
||||
|
||||
private final Context context;
|
||||
private final OsmandApplication context;
|
||||
|
||||
private BusyIndicator busyIndicator;
|
||||
|
||||
private final MapTileDownloader downloader = MapTileDownloader.getInstance();
|
||||
// Indexes
|
||||
|
@ -85,12 +87,12 @@ public class ResourceManager {
|
|||
|
||||
protected final Map<String, TransportIndexRepository> transportRepositories = new LinkedHashMap<String, TransportIndexRepository>();
|
||||
|
||||
protected final MapRenderRepositories renderer ;
|
||||
protected final MapRenderRepositories renderer;
|
||||
|
||||
public final AsyncLoadingThread asyncLoadingTiles = new AsyncLoadingThread();
|
||||
|
||||
|
||||
public ResourceManager(Context context) {
|
||||
public ResourceManager(OsmandApplication context) {
|
||||
this.context = context;
|
||||
this.renderer = new MapRenderRepositories(context);
|
||||
// TODO start/stop this thread when needed?
|
||||
|
@ -102,7 +104,7 @@ public class ResourceManager {
|
|||
|
||||
}
|
||||
|
||||
public Context getContext() {
|
||||
public OsmandApplication getContext() {
|
||||
return context;
|
||||
}
|
||||
|
||||
|
@ -564,6 +566,14 @@ public class ResourceManager {
|
|||
}
|
||||
transportRepositories.clear();
|
||||
}
|
||||
|
||||
public BusyIndicator getBusyIndicator() {
|
||||
return busyIndicator;
|
||||
}
|
||||
|
||||
public synchronized void setBusyIndicator(BusyIndicator busyIndicator) {
|
||||
this.busyIndicator = busyIndicator;
|
||||
}
|
||||
|
||||
public synchronized void close(){
|
||||
imagesOnFS.clear();
|
||||
|
@ -710,6 +720,20 @@ public class ResourceManager {
|
|||
boolean amenityLoaded = false;
|
||||
boolean transportLoaded = false;
|
||||
boolean mapLoaded = false;
|
||||
int progress = 0;
|
||||
if(downloader.isSomethingBeingDownloaded()){
|
||||
progress = BusyIndicator.STATUS_GREEN;
|
||||
}
|
||||
synchronized(ResourceManager.this){
|
||||
if(busyIndicator != null){
|
||||
if(context.getRoutingHelper().isRouteBeingCalculated()){
|
||||
progress = BusyIndicator.STATUS_BLUE;
|
||||
} else if(!requests.isEmpty()){
|
||||
progress = BusyIndicator.STATUS_BLACK;;
|
||||
}
|
||||
busyIndicator.updateStatus(progress);
|
||||
}
|
||||
}
|
||||
while(!requests.isEmpty()){
|
||||
Object req = requests.pop();
|
||||
if (req instanceof TileLoadDownloadRequest) {
|
||||
|
@ -745,6 +769,21 @@ public class ResourceManager {
|
|||
c.tileDownloaded(null);
|
||||
}
|
||||
}
|
||||
boolean routeBeingCalculated = context.getRoutingHelper().isRouteBeingCalculated();
|
||||
if (progress != 0 || routeBeingCalculated || downloader.isSomethingBeingDownloaded()) {
|
||||
synchronized (ResourceManager.this) {
|
||||
if (busyIndicator != null) {
|
||||
if(routeBeingCalculated){
|
||||
progress = BusyIndicator.STATUS_BLUE;
|
||||
} else if(downloader.isSomethingBeingDownloaded()){
|
||||
progress = BusyIndicator.STATUS_GREEN;
|
||||
} else {
|
||||
progress = 0;
|
||||
}
|
||||
busyIndicator.updateStatus(progress);
|
||||
}
|
||||
}
|
||||
}
|
||||
sleep(750);
|
||||
} catch (InterruptedException e) {
|
||||
log.error(e, e);
|
||||
|
|
|
@ -101,7 +101,7 @@ public class MainMenuActivity extends Activity {
|
|||
if(Version.VELCOM_EDITION){
|
||||
final ImageView imgView = (ImageView) findViewById(R.id.VelcomMini);
|
||||
final Camera camera = new Camera();
|
||||
final float firstRotate = 0.3f;
|
||||
final float firstRotate = 0.25f;
|
||||
final float invisibleText = 0.7f;
|
||||
final int animationTime = 3600;
|
||||
Animation ra = new Animation(){
|
||||
|
@ -112,9 +112,9 @@ public class MainMenuActivity extends Activity {
|
|||
int centerX = imgView.getWidth() / 2;
|
||||
camera.save();
|
||||
if (interpolatedTime < firstRotate) {
|
||||
camera.rotateY(360 * (firstRotate - interpolatedTime) / firstRotate);
|
||||
camera.rotateY(360 * interpolatedTime / firstRotate);
|
||||
} else if (interpolatedTime < 2 * firstRotate) {
|
||||
camera.rotateY(360 * (2 * firstRotate - interpolatedTime) / firstRotate);
|
||||
camera.rotateY(360 * (interpolatedTime - firstRotate) / firstRotate);
|
||||
} else {
|
||||
camera.rotateY(360 * (interpolatedTime - 2 * firstRotate) / (1 - 2 * firstRotate));
|
||||
}
|
||||
|
@ -125,6 +125,8 @@ public class MainMenuActivity extends Activity {
|
|||
camera.restore();
|
||||
}
|
||||
};
|
||||
// let accelerate animation
|
||||
// ra.setInterpolator(new LinearInterpolator());
|
||||
ra.setDuration(animationTime);
|
||||
imgView.startAnimation(ra);
|
||||
|
||||
|
|
|
@ -11,6 +11,7 @@ import java.util.Map;
|
|||
|
||||
import net.osmand.Algoritms;
|
||||
import net.osmand.AmenityIndexRepository;
|
||||
import net.osmand.BusyIndicator;
|
||||
import net.osmand.GPXUtilities;
|
||||
import net.osmand.LogUtil;
|
||||
import net.osmand.OsmandSettings;
|
||||
|
@ -670,6 +671,7 @@ public class MapActivity extends Activity implements IMapLocationListener, Senso
|
|||
wakeLock = null;
|
||||
}
|
||||
OsmandSettings.setMapActivityEnabled(this, false);
|
||||
((OsmandApplication)getApplication()).getResourceManager().setBusyIndicator(null);
|
||||
}
|
||||
|
||||
private void updateApplicationModeSettings(){
|
||||
|
@ -807,6 +809,9 @@ public class MapActivity extends Activity implements IMapLocationListener, Senso
|
|||
OsmandSettings.setMapActivityEnabled(this, true);
|
||||
checkExternalStorage();
|
||||
showAndHideMapPosition();
|
||||
|
||||
((OsmandApplication)getApplication()).getResourceManager().setBusyIndicator(
|
||||
new BusyIndicator(this, findViewById(R.id.ProgressBar)));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -484,6 +484,10 @@ public class RoutingHelper {
|
|||
}
|
||||
}
|
||||
|
||||
public boolean isRouteBeingCalculated(){
|
||||
return currentRunningJob != null;
|
||||
}
|
||||
|
||||
private void showMessage(final String msg){
|
||||
if (uiActivity != null) {
|
||||
uiActivity.runOnUiThread(new Runnable() {
|
||||
|
|