Update compass

This commit is contained in:
Victor Shcherb 2013-04-14 23:53:00 +02:00
parent 983f6f36ab
commit 7dedfe6bec
3 changed files with 27 additions and 9 deletions

View file

@ -21,8 +21,8 @@
<string name="layer_hillshade">Hillshade layer</string>
<string name="map_widget_gps_info">GPS info</string>
<string name="tip_recent_changes_1_1_4_t">Changes in 1.1.4:
\n\t* UI redesign
\n\t* Bug fixes
\n\t* Small UI redesign
</string>
<string name="access_arrival_time">Arrival time</string>
<string name="item_checked">checked</string>

View file

@ -723,22 +723,34 @@ public class MapInfoLayer extends OsmandMapLayer {
return progressBar;
}
private class ConfigLayout extends FrameLayout implements MapControlUpdateable {
private ImageViewWidget config;
private ConfigLayout(Context c, ImageViewWidget config) {
super(c);
this.config = config;
}
@Override
public boolean updateInfo(DrawSettings drawSettings) {
return config.updateInfo(drawSettings);
}
}
private View createConfiguration(){
final OsmandMapTileView view = map.getMapView();
FrameLayout fl = new FrameLayout(view.getContext());
FrameLayout.LayoutParams fparams = new FrameLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
final Drawable config = view.getResources().getDrawable(R.drawable.list_activities_config);
final Drawable configWhite = view.getResources().getDrawable(R.drawable.list_activities_config_white);
ImageViewWidget configuration = new ImageViewWidget(map) {
private boolean nightMode;
private boolean nm;
@Override
public boolean updateInfo(DrawSettings drawSettings) {
boolean nightMode = drawSettings == null ? false : drawSettings.isNightMode();
if(nightMode != this.nightMode) {
this.nightMode = nightMode;
boolean nightMode = drawSettings != null && drawSettings.isNightMode();
if(nightMode != this.nm) {
this.nm = nightMode;
setImageDrawable(nightMode ? configWhite : config);
return true;
}
@ -746,6 +758,7 @@ public class MapInfoLayer extends OsmandMapLayer {
}
};
configuration.setBackgroundDrawable(config);
FrameLayout fl = new ConfigLayout(view.getContext(), configuration) ;
fl.addView(configuration, fparams);
fparams = new FrameLayout.LayoutParams(config.getMinimumWidth(), config.getMinimumHeight());
progressBar = new View(view.getContext());

View file

@ -229,19 +229,24 @@ public class MapInfoWidgetsFactory {
final int mw = (int) compass.getMinimumWidth() ;
final int mh = (int) compass.getMinimumHeight() ;
ImageViewWidget compassView = new ImageViewWidget(map) {
Drawable d = compass;
private float cachedRotate = 0;
private boolean nm;
@Override
protected void onDraw(Canvas canvas) {
canvas.save();
canvas.rotate(view.getRotate(), mw / 2, mh / 2);
d.draw(canvas);
getDrawable().draw(canvas);
canvas.restore();
}
@Override
public boolean updateInfo(DrawSettings drawSettings) {
d = drawSettings != null && drawSettings.isNightMode() ? compassWhite : compass;
boolean nightMode = drawSettings != null && drawSettings.isNightMode();
if(nightMode != this.nm) {
this.nm = nightMode;
setImageDrawable(nightMode ? compassWhite : compass);
return true;
}
if(view.getRotate() != cachedRotate) {
cachedRotate = view.getRotate();
invalidate();