Add enable/disable buttons and remove not used files

This commit is contained in:
vshcherb 2014-03-12 18:01:36 +01:00
parent 2355433947
commit 1568ab8288
16 changed files with 266 additions and 184 deletions

View file

@ -5,7 +5,6 @@ import java.io.File;
import net.osmand.Location;
import net.osmand.plus.api.ExternalServiceAPI;
import net.osmand.plus.api.InternalOsmAndAPI;
import net.osmand.plus.api.InternalToDoAPI;
import net.osmand.plus.api.SQLiteAPI;
import net.osmand.plus.api.SettingsAPI;
import net.osmand.plus.render.RendererRegistry;
@ -35,8 +34,6 @@ public interface ClientContext {
public ExternalServiceAPI getExternalServiceAPI();
public InternalToDoAPI getTodoAPI();
public InternalOsmAndAPI getInternalAPI();
public SQLiteAPI getSQLiteAPI();

View file

@ -17,14 +17,14 @@ public class CurrentPositionHelper {
private Location lastAskedLocation = null;
private Thread calculatingThread = null;
private RoutingContext ctx;
private ClientContext app;
private OsmandApplication app;
private ApplicationMode am;
public CurrentPositionHelper(ClientContext app) {
public CurrentPositionHelper(OsmandApplication app) {
this.app = app;
}
private void initCtx(ClientContext app) {
private void initCtx(OsmandApplication app) {
am = app.getSettings().getApplicationMode();
GeneralRouterProfile p ;
if (am.isDerivedRoutingFrom(ApplicationMode.BICYCLE)) {
@ -37,7 +37,7 @@ public class CurrentPositionHelper {
return;
}
RoutingConfiguration cfg = RoutingConfiguration.getDefault().build(p.name().toLowerCase(), 10);
ctx = new RoutePlannerFrontEnd(false).buildRoutingContext(cfg, null, app.getTodoAPI().getRoutingMapFiles());
ctx = new RoutePlannerFrontEnd(false).buildRoutingContext(cfg, null, app.getResourceManager().getRoutingMapFiles());
}
private RouteDataObject runUpdateInThread(Location loc) {

View file

@ -28,7 +28,6 @@ import net.osmand.plus.activities.SavingTrackHelper;
import net.osmand.plus.activities.SettingsActivity;
import net.osmand.plus.api.ExternalServiceAPI;
import net.osmand.plus.api.InternalOsmAndAPI;
import net.osmand.plus.api.InternalToDoAPI;
import net.osmand.plus.api.SQLiteAPI;
import net.osmand.plus.api.SQLiteAPIImpl;
import net.osmand.plus.api.SettingsAPI;
@ -107,7 +106,6 @@ public class OsmandApplication extends Application implements ClientContext {
SettingsAPI settingsAPI;
ExternalServiceAPI externalServiceAPI;
InternalToDoAPI internalToDoAPI;
InternalOsmAndAPI internalOsmAndAPI;
SQLiteAPI sqliteAPI;
BRouterServiceConnection bRouterServiceConnection;
@ -128,7 +126,6 @@ public class OsmandApplication extends Application implements ClientContext {
settingsAPI = new net.osmand.plus.api.SettingsAPIImpl(this);
externalServiceAPI = new net.osmand.plus.api.ExternalServiceAPIImpl(this);
internalToDoAPI = new net.osmand.plus.api.InternalToDoAPIImpl(this);
internalOsmAndAPI = new net.osmand.plus.api.InternalOsmAndAPIImpl(this);
sqliteAPI = new SQLiteAPIImpl(this);
@ -696,11 +693,6 @@ public class OsmandApplication extends Application implements ClientContext {
return externalServiceAPI;
}
@Override
public InternalToDoAPI getTodoAPI() {
return internalToDoAPI;
}
@Override
public InternalOsmAndAPI getInternalAPI() {
return internalOsmAndAPI;

View file

@ -916,7 +916,7 @@ public class OsmandSettings {
if (!dir.exists()) {
return checkAmongAvailableTileSources(dir, knownTemplates);
} else if (tileName.endsWith(IndexConstants.SQLITE_EXT)) {
return ctx.getTodoAPI().newSqliteTileSource(dir, knownTemplates);
return new SQLiteTileSource(ctx, dir, knownTemplates);
} else if (dir.isDirectory() && !dir.getName().startsWith(".")) {
TileSourceTemplate t = TileSourceManager.createTileSourceTemplate(dir);
if (warnWhenSelected && !t.isRuleAcceptable()) {

View file

@ -1,17 +0,0 @@
package net.osmand.plus.api;
import java.io.File;
import java.util.List;
import net.osmand.binary.BinaryMapIndexReader;
import net.osmand.map.ITileSource;
import net.osmand.map.TileSourceManager.TileSourceTemplate;
public interface InternalToDoAPI {
public BinaryMapIndexReader[] getRoutingMapFiles();
public ITileSource newSqliteTileSource(File dir, List<TileSourceTemplate> knownTemplates);
}

View file

@ -1,30 +0,0 @@
package net.osmand.plus.api;
import java.io.File;
import java.util.List;
import net.osmand.binary.BinaryMapIndexReader;
import net.osmand.map.ITileSource;
import net.osmand.map.TileSourceManager.TileSourceTemplate;
import net.osmand.plus.OsmandApplication;
import net.osmand.plus.SQLiteTileSource;
public class InternalToDoAPIImpl implements InternalToDoAPI {
private OsmandApplication app;
public InternalToDoAPIImpl(OsmandApplication app) {
this.app = app;
}
@Override
public BinaryMapIndexReader[] getRoutingMapFiles() {
return app.getResourceManager().getRoutingMapFiles();
}
@Override
public ITileSource newSqliteTileSource(File dir, List<TileSourceTemplate> knownTemplates) {
return new SQLiteTileSource(app, dir, knownTemplates);
}
}

View file

@ -1,9 +0,0 @@
package net.osmand.plus.api;
import net.osmand.plus.api.render.Paint;
public interface RendererAPI {
public Paint newPaint();
}

View file

@ -1,5 +0,0 @@
package net.osmand.plus.api.render;
public interface Canvas {
}

View file

@ -1,24 +0,0 @@
package net.osmand.plus.api.render;
public class Color {
public static final int BLACK = 0xFF000000;
public static final int DKGRAY = 0xFF444444;
public static final int GRAY = 0xFF888888;
public static final int LTGRAY = 0xFFCCCCCC;
public static final int WHITE = 0xFFFFFFFF;
public static final int RED = 0xFFFF0000;
public static final int GREEN = 0xFF00FF00;
public static final int BLUE = 0xFF0000FF;
public static final int YELLOW = 0xFFFFFF00;
public static final int CYAN = 0xFF00FFFF;
public static final int MAGENTA = 0xFFFF00FF;
public static final int TRANSPARENT = 0;
public static int rgb(int red, int green, int blue) {
return (0xFF << 24) | (red << 16) | (green << 8) | blue;
}
public static int argb(int alpha, int red, int green, int blue) {
return (alpha << 24) | (red << 16) | (green << 8) | blue;
}
}

View file

@ -5,7 +5,7 @@ import java.util.List;
import net.osmand.Location;
import net.osmand.data.LatLon;
import net.osmand.plus.ApplicationMode;
import net.osmand.plus.ClientContext;
import net.osmand.plus.OsmandApplication;
import net.osmand.plus.routing.RouteProvider.GPXRouteParams;
import net.osmand.plus.routing.RouteProvider.RouteService;
import net.osmand.router.RouteCalculationProgress;
@ -16,7 +16,7 @@ public class RouteCalculationParams {
public LatLon end;
public List<LatLon> intermediates;
public ClientContext ctx;
public OsmandApplication ctx;
public ApplicationMode mode;
public RouteService type;
public GPXRouteParams gpxRoute;

View file

@ -431,7 +431,7 @@ public class RouteProvider {
}
protected RouteCalculationResult findVectorMapsRoute(final RouteCalculationParams params, boolean calcGPXRoute) throws IOException {
BinaryMapIndexReader[] files = params.ctx.getTodoAPI().getRoutingMapFiles();
BinaryMapIndexReader[] files = params.ctx.getResourceManager().getRoutingMapFiles();
RoutePlannerFrontEnd router = new RoutePlannerFrontEnd(false);
OsmandSettings settings = params.ctx.getSettings();

View file

@ -5,6 +5,7 @@ import net.osmand.plus.OsmAndFormatter;
import net.osmand.plus.OsmandSettings.CommonPreference;
import net.osmand.plus.R;
import net.osmand.plus.activities.MapActivity;
import net.osmand.plus.views.controls.MapControls;
import net.osmand.plus.views.controls.MapMenuControls;
import net.osmand.plus.views.controls.MapZoomControls;
import android.graphics.Canvas;
@ -26,14 +27,13 @@ import android.widget.SeekBar;
public class MapControlsLayer extends OsmandMapLayer {
private static final int HOVER_COLOR = 0xffC8C8C8;
private static final int TIMEOUT_TO_SHOW_BUTTONS = 5000;
private final MapActivity mapActivity;
private int shadowColor = Color.WHITE;
private int shadowColor;
private MapZoomControls zoomControls;
private MapMenuControls mapMenuControls;
private RulerControl rulerControl;
private float scaleCoefficient;
@ -41,16 +41,13 @@ public class MapControlsLayer extends OsmandMapLayer {
private LinearLayout transparencyBarLayout;
private static CommonPreference<Integer> settingsToTransparency;
private Drawable rulerDrawable;
private TextPaint rulerTextPaint;
private final static double screenRulerPercent = 0.25;
public MapControlsLayer(MapActivity activity){
this.mapActivity = activity;
}
@Override
public boolean drawInScreenPixels() {
return true;
@ -65,10 +62,9 @@ public class MapControlsLayer extends OsmandMapLayer {
zoomControls.init(parent);
mapMenuControls = new MapMenuControls(mapActivity, showUIHandler, scaleCoefficient);
mapMenuControls.init(parent);
mapMenuControls.show(parent);
initRuler(view, parent);
rulerControl = new RulerControl(zoomControls, mapActivity, showUIHandler, scaleCoefficient);
rulerControl.init(parent);
initTransparencyBar(view, parent);
}
@Override
@ -84,34 +80,47 @@ public class MapControlsLayer extends OsmandMapLayer {
if(shadowColor != sh) {
shadowColor = sh;
int textColor = sh == Color.WHITE ? Color.BLACK : HOVER_COLOR;
rulerTextPaint.setColor(textColor);
rulerControl.setShadowColor(textColor, sh);
zoomControls.setShadowColor(textColor, sh);
mapMenuControls.setShadowColor(textColor, sh);
}
boolean showZooms = !mapActivity.getRoutingHelper().isRouteCalculated();
if(showZooms != zoomControls.isVisible()){
if(showZooms) {
zoomControls.show((FrameLayout) mapActivity.getMapView().getParent());
} else {
zoomControls.hide((FrameLayout) mapActivity.getMapView().getParent());
}
}
if(showZooms) {
zoomControls.onDraw(canvas, tileBox, nightMode);
}
mapMenuControls.onDraw(canvas, tileBox, nightMode);
drawRuler(canvas, tileBox, nightMode);
boolean showZooms = false; //!mapActivity.getRoutingHelper().isRouteCalculated() && !mapActivity.getRoutingHelper().isFollowingMode();
checkVisibilityAndDraw(showZooms, zoomControls, canvas, tileBox, nightMode);
boolean showMenu = false;// !mapActivity.getRoutingHelper().isFollowingMode();
checkVisibilityAndDraw(showMenu, mapMenuControls, canvas, tileBox, nightMode);
checkVisibilityAndDraw(true, rulerControl, canvas, tileBox, nightMode);
}
private void checkVisibilityAndDraw(boolean visibility, MapControls controls, Canvas canvas,
RotatedTileBox tileBox, DrawSettings nightMode) {
if(visibility != controls.isVisible()){
if(visibility) {
controls.show((FrameLayout) mapActivity.getMapView().getParent());
} else {
controls.hide((FrameLayout) mapActivity.getMapView().getParent());
}
}
if(controls.isVisible()) {
controls.onDraw(canvas, tileBox, nightMode);
}
}
@Override
public boolean onSingleTap(PointF point, RotatedTileBox tileBox) {
if(mapMenuControls.onSingleTap(point, tileBox)) {
return true;
}
if(zoomControls.isVisible() && zoomControls.onSingleTap(point, tileBox)) {
zoomControls.showWithDelay((FrameLayout) mapActivity.getMapView().getParent(), TIMEOUT_TO_SHOW_BUTTONS);
mapMenuControls.showWithDelay((FrameLayout) mapActivity.getMapView().getParent(), TIMEOUT_TO_SHOW_BUTTONS);
if(mapMenuControls.isVisible() && mapMenuControls.onSingleTap(point, tileBox)) {
return true;
}
if(zoomControls.isVisible() ) {
if(zoomControls.onSingleTap(point, tileBox)) {
return true;
}
}
return false;
}
@ -183,54 +192,89 @@ public class MapControlsLayer extends OsmandMapLayer {
/////////////////////// Ruler ///////////////////
// cache values for ruler
ShadowText cacheRulerText = null;
float cacheRulerZoom = 0;
double cacheRulerTileX = 0;
double cacheRulerTileY = 0;
float cacheRulerTextLen = 0;
public static class RulerControl extends MapControls {
private void initRuler(OsmandMapTileView view, FrameLayout parent) {
rulerTextPaint = new TextPaint();
rulerTextPaint.setTextSize(20 * scaleCoefficient);
rulerTextPaint.setAntiAlias(true);
rulerDrawable = view.getResources().getDrawable(R.drawable.ruler);
}
private void drawRuler(Canvas canvas, RotatedTileBox tb, DrawSettings nightMode) {
if( (zoomControls.isVisible() && zoomControls.isShowZoomLevel()) || !mapActivity.getMyApplication().getSettings().SHOW_RULER.get()){
return;
ShadowText cacheRulerText = null;
float cacheRulerZoom = 0;
double cacheRulerTileX = 0;
double cacheRulerTileY = 0;
float cacheRulerTextLen = 0;
MapZoomControls zoomControls;
Drawable rulerDrawable;
TextPaint rulerTextPaint;
final static double screenRulerPercent = 0.25;
public RulerControl(MapZoomControls zoomControls, MapActivity mapActivity, Handler showUIHandler, float scaleCoefficient) {
super(mapActivity, showUIHandler, scaleCoefficient);
this.zoomControls = zoomControls;
}
OsmandMapTileView view = mapActivity.getMapView();
// update cache
if (view.isZooming()) {
cacheRulerText = null;
} else if((tb.getZoom() + tb.getZoomScale()) != cacheRulerZoom ||
Math.abs(tb.getCenterTileX() - cacheRulerTileX) + Math.abs(tb.getCenterTileY() - cacheRulerTileY) > 1){
cacheRulerZoom = (tb.getZoom() + tb.getZoomScale());
cacheRulerTileX = tb.getCenterTileX();
cacheRulerTileY = tb.getCenterTileY();
final double dist = tb.getDistance(0, tb.getPixHeight() / 2, tb.getPixWidth(), tb.getPixHeight() / 2);
double pixDensity = tb.getPixWidth() / dist;
@Override
public int getWidth() {
return 0;
}
@Override
protected void hideControls(FrameLayout layout) {
}
@Override
public void setShadowColor(int textColor, int shadowColor) {
super.setShadowColor(textColor, shadowColor);
rulerTextPaint.setColor(textColor);
}
@Override
protected void showControls(FrameLayout layout) {
rulerTextPaint = new TextPaint();
rulerTextPaint.setTextSize(20 * scaleCoefficient);
rulerTextPaint.setAntiAlias(true);
rulerDrawable = mapActivity.getResources().getDrawable(R.drawable.ruler);
}
@Override
public void onDraw(Canvas canvas, RotatedTileBox tb, DrawSettings nightMode) {
if( (zoomControls.isVisible() && zoomControls.isShowZoomLevel()) || !mapActivity.getMyApplication().getSettings().SHOW_RULER.get()){
return;
}
OsmandMapTileView view = mapActivity.getMapView();
// update cache
if (view.isZooming()) {
cacheRulerText = null;
} else if((tb.getZoom() + tb.getZoomScale()) != cacheRulerZoom ||
Math.abs(tb.getCenterTileX() - cacheRulerTileX) + Math.abs(tb.getCenterTileY() - cacheRulerTileY) > 1){
cacheRulerZoom = (tb.getZoom() + tb.getZoomScale());
cacheRulerTileX = tb.getCenterTileX();
cacheRulerTileY = tb.getCenterTileY();
final double dist = tb.getDistance(0, tb.getPixHeight() / 2, tb.getPixWidth(), tb.getPixHeight() / 2);
double pixDensity = tb.getPixWidth() / dist;
double roundedDist = OsmAndFormatter.calculateRoundedDist(dist * screenRulerPercent, view.getApplication());
int cacheRulerDistPix = (int) (pixDensity * roundedDist);
cacheRulerText = ShadowText.create(OsmAndFormatter.getFormattedDistance((float) roundedDist, view.getApplication()));
cacheRulerTextLen = rulerTextPaint.measureText(cacheRulerText.getText());
Rect bounds = rulerDrawable.getBounds();
bounds.right = (int) (view.getWidth() - 7 * scaleCoefficient);
bounds.bottom = (int) (view.getHeight() - (!zoomControls.isVisible() ? 0 : zoomControls.getHeight()));
bounds.top = bounds.bottom - rulerDrawable.getMinimumHeight();
bounds.left = bounds.right - cacheRulerDistPix;
rulerDrawable.setBounds(bounds);
}
double roundedDist = OsmAndFormatter.calculateRoundedDist(dist * screenRulerPercent, view.getApplication());
int cacheRulerDistPix = (int) (pixDensity * roundedDist);
cacheRulerText = ShadowText.create(OsmAndFormatter.getFormattedDistance((float) roundedDist, view.getApplication()));
cacheRulerTextLen = rulerTextPaint.measureText(cacheRulerText.getText());
Rect bounds = rulerDrawable.getBounds();
bounds.right = (int) (view.getWidth() - 7 * scaleCoefficient);
bounds.bottom = (int) (view.getHeight() - (!zoomControls.isVisible() ? 0 : zoomControls.getHeight()));
bounds.top = bounds.bottom - rulerDrawable.getMinimumHeight();
bounds.left = bounds.right - cacheRulerDistPix;
rulerDrawable.setBounds(bounds);
}
if (cacheRulerText != null) {
rulerDrawable.draw(canvas);
Rect bounds = rulerDrawable.getBounds();
cacheRulerText.draw(canvas, bounds.left + (bounds.width() - cacheRulerTextLen) / 2, bounds.bottom - 8 * scaleCoefficient,
rulerTextPaint, shadowColor);
if (cacheRulerText != null) {
Rect bounds = rulerDrawable.getBounds();
int bottom = (int) (view.getHeight() - (!zoomControls.isVisible() ? 0 : zoomControls.getHeight()));
if(bounds.bottom != bottom) {
bounds.bottom = bottom;
rulerDrawable.setBounds(bounds);
}
rulerDrawable.draw(canvas);
cacheRulerText.draw(canvas, bounds.left + (bounds.width() - cacheRulerTextLen) / 2, bounds.bottom - 8 * scaleCoefficient,
rulerTextPaint, shadowColor);
}
}
}

View file

@ -16,6 +16,7 @@ public abstract class MapControls {
protected Handler showUIHandler;
protected int shadowColor;
private boolean visible;
private long delayTime;
public MapControls(MapActivity mapActivity, Handler showUIHandler, float scaleCoefficient) {
this.mapActivity = mapActivity;
@ -36,9 +37,38 @@ public abstract class MapControls {
showControls(layout);
}
public final void showWithDelay(final FrameLayout layout, final long delay) {
this.delayTime = System.currentTimeMillis() + delay;
if(!visible) {
visible = true;
showControls(layout);
runWithDelay(layout, delay);
mapActivity.getMapView().refreshMap();
}
}
private void runWithDelay(final FrameLayout layout, final long delay) {
showUIHandler.postDelayed(new Runnable() {
@Override
public void run() {
long ctime = System.currentTimeMillis();
if(MapControls.this.delayTime <= ctime) {
MapControls.this.delayTime = 0;
visible = false;
hideControls(layout);
mapActivity.getMapView().refreshMap();
} else {
runWithDelay(layout, MapControls.this.delayTime - ctime);
}
}
}, delay);
}
public final void hide(FrameLayout layout) {
visible = false;
hideControls(layout);
if(this.delayTime == 0) {
visible = false;
hideControls(layout);
}
}
public boolean isVisible() {

View file

@ -73,6 +73,7 @@ public class MapMenuControls extends MapControls {
@Override
public void hideControls(FrameLayout layout) {
layout.removeView(backToMenuButton);
mapActivity.accessibleContent.remove(backToMenuButton);
}

View file

@ -116,15 +116,12 @@ public class MapZoomControls extends MapControls {
}
@Override
public int getWidth() {
return 0; // TODO
}
@Override
public void hideControls(FrameLayout layout) {
mapActivity.accessibleContent.remove(zoomInButton);
mapActivity.accessibleContent.remove(zoomOutButton);
layout.removeView(zoomInButton);
layout.removeView(zoomOutButton);
}
private void drawZoomLevel(Canvas canvas, RotatedTileBox tb, boolean drawZoomLevel) {
@ -234,5 +231,11 @@ public class MapZoomControls extends MapControls {
Drawable buttonDrawable = view.getResources().getDrawable(R.drawable.map_zoom_in);
return buttonDrawable.getMinimumHeight();
}
@Override
public int getWidth() {
Drawable buttonDrawable = view.getResources().getDrawable(R.drawable.map_zoom_in);
return buttonDrawable.getMinimumWidth() + buttonDrawable.getMinimumWidth();
}
}

View file

@ -0,0 +1,100 @@
package net.osmand.plus.views.controls;
import net.osmand.data.RotatedTileBox;
import net.osmand.plus.OsmAndFormatter;
import net.osmand.plus.R;
import net.osmand.plus.activities.MapActivity;
import net.osmand.plus.views.OsmandMapLayer.DrawSettings;
import net.osmand.plus.views.OsmandMapTileView;
import net.osmand.plus.views.ShadowText;
import android.graphics.Canvas;
import android.graphics.Rect;
import android.graphics.drawable.Drawable;
import android.os.Handler;
import android.text.TextPaint;
import android.widget.FrameLayout;
public class RulerControl extends MapControls {
ShadowText cacheRulerText = null;
float cacheRulerZoom = 0;
double cacheRulerTileX = 0;
double cacheRulerTileY = 0;
float cacheRulerTextLen = 0;
MapZoomControls zoomControls;
Drawable rulerDrawable;
TextPaint rulerTextPaint;
final static double screenRulerPercent = 0.25;
public RulerControl(MapZoomControls zoomControls, MapActivity mapActivity, Handler showUIHandler, float scaleCoefficient) {
super(mapActivity, showUIHandler, scaleCoefficient);
this.zoomControls = zoomControls;
}
@Override
public int getWidth() {
return 0;
}
@Override
protected void hideControls(FrameLayout layout) {
}
@Override
public void setShadowColor(int textColor, int shadowColor) {
super.setShadowColor(textColor, shadowColor);
rulerTextPaint.setColor(textColor);
}
@Override
protected void showControls(FrameLayout layout) {
rulerTextPaint = new TextPaint();
rulerTextPaint.setTextSize(20 * scaleCoefficient);
rulerTextPaint.setAntiAlias(true);
rulerDrawable = mapActivity.getResources().getDrawable(R.drawable.ruler);
}
@Override
public void onDraw(Canvas canvas, RotatedTileBox tb, DrawSettings nightMode) {
if( (zoomControls.isVisible() && zoomControls.isShowZoomLevel()) || !mapActivity.getMyApplication().getSettings().SHOW_RULER.get()){
return;
}
OsmandMapTileView view = mapActivity.getMapView();
// update cache
if (view.isZooming()) {
cacheRulerText = null;
} else if((tb.getZoom() + tb.getZoomScale()) != cacheRulerZoom ||
Math.abs(tb.getCenterTileX() - cacheRulerTileX) + Math.abs(tb.getCenterTileY() - cacheRulerTileY) > 1){
cacheRulerZoom = (tb.getZoom() + tb.getZoomScale());
cacheRulerTileX = tb.getCenterTileX();
cacheRulerTileY = tb.getCenterTileY();
final double dist = tb.getDistance(0, tb.getPixHeight() / 2, tb.getPixWidth(), tb.getPixHeight() / 2);
double pixDensity = tb.getPixWidth() / dist;
double roundedDist = OsmAndFormatter.calculateRoundedDist(dist * screenRulerPercent, view.getApplication());
int cacheRulerDistPix = (int) (pixDensity * roundedDist);
cacheRulerText = ShadowText.create(OsmAndFormatter.getFormattedDistance((float) roundedDist, view.getApplication()));
cacheRulerTextLen = rulerTextPaint.measureText(cacheRulerText.getText());
Rect bounds = rulerDrawable.getBounds();
bounds.right = (int) (view.getWidth() - 7 * scaleCoefficient);
bounds.bottom = (int) (view.getHeight() - (!zoomControls.isVisible() ? 0 : zoomControls.getHeight()));
bounds.top = bounds.bottom - rulerDrawable.getMinimumHeight();
bounds.left = bounds.right - cacheRulerDistPix;
rulerDrawable.setBounds(bounds);
}
if (cacheRulerText != null) {
Rect bounds = rulerDrawable.getBounds();
int bottom = (int) (view.getHeight() - (!zoomControls.isVisible() ? 0 : zoomControls.getHeight()));
if(bounds.bottom != bottom) {
bounds.bottom = bottom;
rulerDrawable.setBounds(bounds);
}
rulerDrawable.draw(canvas);
cacheRulerText.draw(canvas, bounds.left + (bounds.width() - cacheRulerTextLen) / 2, bounds.bottom - 8 * scaleCoefficient,
rulerTextPaint, shadowColor);
}
}
}