Add icons for application mode, fix small issues

This commit is contained in:
Victor Shcherb 2011-06-26 22:01:22 +02:00
parent 9ba23e599b
commit 2c0f87d3b3
17 changed files with 795 additions and 632 deletions

View file

@ -91,10 +91,10 @@ public class Algoritms {
}
public static boolean removeAllFiles(File f){
if(f.isDirectory()){
boolean deleted = true;
for(File c : f.listFiles()){
public static boolean removeAllFiles(File f) {
if (f.isDirectory()) {
boolean deleted = true;
for (File c : f.listFiles()) {
deleted &= removeAllFiles(c);
}
return f.delete();

View file

@ -1,5 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<assets>
<asset name="basemap.obf.jpg" destination="basemap.obf"/>
<asset name="voice/en-tts/_ttsconfig.p" destination="voice/en-tts/_ttsconfig.p"/>
<asset name="voice/en-tts/ttsconfig.p.jpg" destination="voice/en-tts/_ttsconfig.p"/>
</assets>

View file

@ -0,0 +1,120 @@
:- op('==', xfy, 500).
version(100).
language(en).
% before each announcement (beep)
preamble - [].
%% TURNS
turn('left', ['turn left ']).
turn('left_sh', ['sharp left ']).
turn('left_sl', ['turn slightly left ']).
turn('right', ['turn right ']).
turn('right_sh', ['sharp right ']).
turn('right_sl', ['turn slightly right ']).
prepare_turn(Turn, Dist) == ['Prepare to ', M, ' after ', D] :-
distance(Dist) == D, turn(Turn, M).
turn(Turn, Dist) == ['After ', D, M] :-
distance(Dist) == D, turn(Turn, M).
turn(Turn) == M :- turn(Turn, M).
prepare_make_ut(Dist) == ['Prepare after ', D, ' to turn back'] :-
distance(Dist) == D.
prepare_roundabout(Dist) == ['Prepare to enter roundabout after ', D] :-
distance(Dist) == D.
make_ut(Dist) == ['After ', D, ' turn back '] :-
distance(Dist) == D.
make_ut == ['Make U turn '].
roundabout(Dist, _Angle, Exit) == ['After ', D, ' enter the roundabout, and take the ', E, 'exit'] :- distance(Dist) == D, nth(Exit, E).
roundabout(_Angle, Exit) == ['taking the ', E, 'exit'] :- nth(Exit, E).
and_arrive_destination == ['and arrive at your destination ']. % Miss and?
then == ['then '].
reached_destination == ['you have reached your destination '].
bear_right == ['keep right '].
bear_left == ['keep left '].
route_recalc(_Dist) == []. % ['recalculating route ']. %nothing to said possibly beep?
route_new_calc(Dist) == ['The trip is ', D] :- distance(Dist) == D. % nothing to said possibly beep?
go_ahead(Dist) == ['Drive for ', D]:- distance(Dist) == D.
go_ahead == ['Continue straight ahead '].
%%
nth(1, 'first ').
nth(2, 'second ').
nth(3, 'third ').
nth(4, 'fourth ').
nth(5, 'fifth ').
nth(6, 'sixth ').
nth(7, 'seventh ').
nth(8, 'eight ').
nth(9, 'nineth ').
nth(10, 'tenth ').
nth(11, 'eleventh ').
nth(12, 'twelfth ').
nth(13, 'thirteenth ').
nth(14, 'fourteenth ').
nth(15, 'fifteenth ').
nth(16, 'sixteenth ').
nth(17, 'seventeenth ').
%%% distance measure
distance(Dist) == T :- Dist < 1000, dist(Dist, F), append(F, ' meters',T).
dist(D, ['10 ']) :- D < 20, !.
dist(D, ['20 ']) :- D < 30, !.
dist(D, ['30 ']) :- D < 40, !.
dist(D, ['40 ']) :- D < 50, !.
dist(D, ['50 ']) :- D < 60, !.
dist(D, ['60 ']) :- D < 70, !.
dist(D, ['70 ']) :- D < 80, !.
dist(D, ['80 ']) :- D < 90, !.
dist(D, ['90 ']) :- D < 100, !.
dist(D, ['100 ']) :- D < 150, !.
dist(D, ['150 ']) :- D < 200, !.
dist(D, ['200 ']) :- D < 250, !.
dist(D, ['250 ']) :- D < 300, !.
dist(D, ['300 ']) :- D < 350, !.
dist(D, ['350 ']) :- D < 400, !.
dist(D, ['400 ']) :- D < 450, !.
dist(D, ['450 ']) :- D < 500, !.
dist(D, ['500 ']) :- D < 550, !.
dist(D, ['550 ']) :- D < 600, !.
dist(D, ['600 ']) :- D < 650, !.
dist(D, ['650 ']) :- D < 700, !.
dist(D, ['700 ']) :- D < 750, !.
dist(D, ['750 ']) :- D < 800, !.
dist(D, ['800 ']) :- D < 850, !.
dist(D, ['850 ']) :- D < 900, !.
dist(D, ['900 ']) :- D < 950, !.
dist(D, ['950 ']) :- !.
distance(Dist) == ['more than 1 kilometer '] :- Dist < 1500.
distance(Dist) == ['more than 2 kilometers '] :- Dist < 3000.
distance(Dist) == ['more than 3 kilometers '] :- Dist < 4000.
distance(Dist) == ['more than 4 kilometers '] :- Dist < 5000.
distance(Dist) == ['more than 5 kilometers '] :- Dist < 6000.
distance(Dist) == ['more than 6 kilometers '] :- Dist < 7000.
distance(Dist) == ['more than 7 kilometers '] :- Dist < 8000.
distance(Dist) == ['more than 8 kilometers '] :- Dist < 9000.
distance(Dist) == ['more than 9 kilometers '] :- Dist < 10000.
distance(Dist) == ['more than ', X, ' kilometers '] :- D is Dist/1000, dist(D, X).
%% resolve command main method
%% if you are familar with Prolog you can input specific to the whole mechanism,
%% by adding exception cases.
flatten(X, Y) :- flatten(X, [], Y), !.
flatten([], Acc, Acc).
flatten([X|Y], Acc, Res):-
flatten(Y, Acc, R), flatten(X, R, Res).
flatten(X, Acc, [X|Acc]).
resolve(X, Y) :- resolve_impl(X,Z), flatten(Z, Y).
resolve_impl([],[]).
resolve_impl([X|Rest], List) :- resolve_impl(Rest, Tail), ((X == L) -> append(L, Tail, List); List = Tail).

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 122 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.7 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 5.6 KiB

After

Width:  |  Height:  |  Size: 5.6 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 6 KiB

After

Width:  |  Height:  |  Size: 5.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 122 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.6 KiB

File diff suppressed because it is too large Load diff

View file

@ -406,7 +406,10 @@ public class ResourceManager {
for (String asset : resourcesToCopy.keySet()) {
String destination = resourcesToCopy.get(asset);
File file = new File(dir, destination);
file.mkdirs();
if(file.exists()){
Algoritms.removeAllFiles(file);
}
file.getParentFile().mkdirs();
InputStream is = assetManager.open(asset, AssetManager.ACCESS_STREAMING);
FileOutputStream out = new FileOutputStream(file);
Algoritms.streamCopy(is, out);

View file

@ -4,6 +4,7 @@ import net.osmand.OsmAndFormatter;
import net.osmand.osm.MapUtils;
import net.osmand.plus.R;
import net.osmand.plus.OsmandSettings.CommonPreference;
import net.osmand.plus.activities.ApplicationMode;
import net.osmand.plus.activities.MapActivity;
import android.content.Context;
import android.graphics.Canvas;
@ -21,6 +22,7 @@ import android.view.WindowManager;
import android.view.ViewGroup.LayoutParams;
import android.widget.Button;
import android.widget.FrameLayout;
import android.widget.ImageView;
import android.widget.SeekBar;
public class MapControlsLayer implements OsmandMapLayer {
@ -48,6 +50,7 @@ public class MapControlsLayer implements OsmandMapLayer {
private Drawable zoomShadow;
private Button backToMenuButton;
private Drawable modeShadow;
private Drawable rulerDrawable;
private TextPaint rulerTextPaint;
@ -83,6 +86,7 @@ public class MapControlsLayer implements OsmandMapLayer {
initRuler(view, parent);
initTransparencyBar(view, parent);
}
@Override
@ -101,6 +105,8 @@ public class MapControlsLayer implements OsmandMapLayer {
zoomOutButton.setEnabled(zoomOutEnabled);
}
drawApplicationMode(canvas);
if(view.isZooming()){
showZoomLevel = true;
showUIHandler.removeMessages(SHOW_ZOOM_LEVEL_MSG_ID);
@ -117,6 +123,31 @@ public class MapControlsLayer implements OsmandMapLayer {
}
private ApplicationMode cacheApplicationMode = null;
private Drawable cacheAppModeIcon = null;
private void drawApplicationMode(Canvas canvas) {
ApplicationMode appMode = view.getSettings().getApplicationMode();
if(appMode != cacheApplicationMode){
modeShadow.setBounds(backToMenuButton.getLeft() + (int) (2 * dm.density), backToMenuButton.getTop() - (int) (20 * dm.density),
backToMenuButton.getRight() - (int) (4 * dm.density), backToMenuButton.getBottom());
if(appMode == ApplicationMode.BICYCLE){
cacheAppModeIcon = view.getResources().getDrawable(R.drawable.bicycle_small);
} else if(appMode == ApplicationMode.CAR){
cacheAppModeIcon = view.getResources().getDrawable(R.drawable.car_small);
} else {
cacheAppModeIcon = view.getResources().getDrawable(R.drawable.pedestrian_small);
}
int l = modeShadow.getBounds().left + (modeShadow.getBounds().width() - cacheAppModeIcon.getMinimumWidth()) / 2;
int t = (int) (modeShadow.getBounds().top + 5 * dm.density);
cacheAppModeIcon.setBounds(l, t, l + cacheAppModeIcon.getMinimumWidth(), t + cacheAppModeIcon.getMinimumHeight());
}
modeShadow.draw(canvas);
if(cacheAppModeIcon != null){
cacheAppModeIcon.draw(canvas);
}
}
private void drawZoomLevel(Canvas canvas) {
String zoomText = view.getZoom() + "";
@ -166,6 +197,8 @@ public class MapControlsLayer implements OsmandMapLayer {
parent.addView(backToMenuButton, params);
backToMenuButton.setEnabled(true);
modeShadow = view.getResources().getDrawable(R.drawable.zoom_background);
backToMenuButton.setOnClickListener(new View.OnClickListener() {
@Override
@ -187,6 +220,13 @@ public class MapControlsLayer implements OsmandMapLayer {
private void initZoomButtons(final OsmandMapTileView view, FrameLayout parent) {
int minimumWidth = view.getResources().getDrawable(R.drawable.map_zoom_in).getMinimumWidth();
ImageView bottomShadow = new ImageView(view.getContext());
bottomShadow.setBackgroundResource(R.drawable.bottom_shadow);
android.widget.FrameLayout.LayoutParams params = new FrameLayout.LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.WRAP_CONTENT,
Gravity.BOTTOM);
params.setMargins(0, 0, 0, 0);
parent.addView(bottomShadow, params);
zoomTextPaint = new TextPaint();
zoomTextPaint.setTextSize(18 * dm.density);
zoomTextPaint.setAntiAlias(true);
@ -196,7 +236,7 @@ public class MapControlsLayer implements OsmandMapLayer {
zoomInButton = new Button(view.getContext());
zoomInButton.setBackgroundResource(R.drawable.map_zoom_in);
android.widget.FrameLayout.LayoutParams params = new FrameLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT,
params = new FrameLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT,
Gravity.BOTTOM | Gravity.RIGHT);
params.setMargins(0, 0, 0, 0);
parent.addView(zoomInButton, params);