use of net.osmand.plus.OsmandApplication in project Osmand by osmandapp.
the class DirectionDrawable method setImage.
public void setImage(int resourceId) {
IconsCache iconsCache = ((OsmandApplication) ctx.getApplicationContext()).getIconsCache();
arrowImage = iconsCache.getIcon(resourceId, 0);
this.resourceId = resourceId;
onBoundsChange(getBounds());
}
use of net.osmand.plus.OsmandApplication in project Osmand by osmandapp.
the class DirectionDrawable method setColorId.
public void setColorId(int clrId) {
// R.color.color_ok, R.color.color_unknown, R.color.color_warning
if (arrowImage != null) {
IconsCache iconsCache = ((OsmandApplication) ctx.getApplicationContext()).getIconsCache();
arrowImage = iconsCache.getIcon(resourceId, clrId);
} else {
paintRouteDirection.setColor(ctx.getResources().getColor(clrId));
}
}
use of net.osmand.plus.OsmandApplication in project Osmand by osmandapp.
the class RouteInfoWidgetsFactory method createPlainTimeControl.
public TextInfoWidget createPlainTimeControl(final MapActivity map) {
final OsmandApplication ctx = map.getMyApplication();
final TextInfoWidget plainTimeControl = new TextInfoWidget(map) {
private long cachedLeftTime = 0;
@Override
public boolean updateInfo(DrawSettings drawSettings) {
long time = System.currentTimeMillis();
if (time - cachedLeftTime > 5000) {
cachedLeftTime = time;
if (DateFormat.is24HourFormat(ctx)) {
// $NON-NLS-1$
setText(DateFormat.format("k:mm", time).toString(), null);
} else {
setText(DateFormat.format("h:mm", time).toString(), // $NON-NLS-1$
DateFormat.format("aa", time).toString());
}
}
return false;
}
};
plainTimeControl.setText(null, null);
plainTimeControl.setIcons(R.drawable.widget_time_day, R.drawable.widget_time_night);
return plainTimeControl;
}
use of net.osmand.plus.OsmandApplication in project Osmand by osmandapp.
the class RouteInfoWidgetsFactory method createBatteryControl.
public TextInfoWidget createBatteryControl(final MapActivity map) {
final int battery = R.drawable.widget_battery_day;
final int batteryN = R.drawable.widget_battery_night;
final int batteryCharging = R.drawable.widget_battery_charging_day;
final int batteryChargingN = R.drawable.widget_battery_charging_night;
final OsmandApplication ctx = map.getMyApplication();
final TextInfoWidget batteryControl = new TextInfoWidget(map) {
private long cachedLeftTime = 0;
@Override
public boolean updateInfo(DrawSettings drawSettings) {
long time = System.currentTimeMillis();
if (time - cachedLeftTime > 1000) {
cachedLeftTime = time;
Intent batteryIntent = ctx.registerReceiver(null, new IntentFilter(Intent.ACTION_BATTERY_CHANGED));
int level = batteryIntent.getIntExtra(BatteryManager.EXTRA_LEVEL, -1);
int scale = batteryIntent.getIntExtra(BatteryManager.EXTRA_SCALE, -1);
int status = batteryIntent.getIntExtra(BatteryManager.EXTRA_STATUS, -1);
if (level == -1 || scale == -1 || status == -1) {
setText("?", null);
setIcons(battery, batteryN);
} else {
boolean charging = ((status == BatteryManager.BATTERY_STATUS_CHARGING) || (status == BatteryManager.BATTERY_STATUS_FULL));
setText(String.format("%d%%", (level * 100) / scale), null);
setIcons(charging ? batteryCharging : battery, charging ? batteryChargingN : batteryN);
}
}
return false;
}
};
batteryControl.setText(null, null);
batteryControl.setIcons(battery, batteryN);
return batteryControl;
}
use of net.osmand.plus.OsmandApplication in project Osmand by osmandapp.
the class MapContextMenuFragment method buildHeader.
private void buildHeader() {
OsmandApplication app = getMyApplication();
if (app != null && view != null) {
final ImageView iconView = (ImageView) view.findViewById(R.id.context_menu_icon_view);
Drawable icon = menu.getRightIcon();
int iconId = menu.getRightIconId();
if (icon != null) {
iconView.setImageDrawable(icon);
iconView.setVisibility(View.VISIBLE);
} else if (iconId != 0) {
iconView.setImageDrawable(getIcon(iconId, !nightMode ? R.color.osmand_orange : R.color.osmand_orange_dark));
iconView.setVisibility(View.VISIBLE);
} else {
iconView.setVisibility(View.GONE);
}
setAddressLocation();
}
}
Aggregations