Search in sources :

Example 46 with OsmandApplication

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());
}
Also used : OsmandApplication(net.osmand.plus.OsmandApplication) IconsCache(net.osmand.plus.IconsCache)

Example 47 with OsmandApplication

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));
    }
}
Also used : OsmandApplication(net.osmand.plus.OsmandApplication) IconsCache(net.osmand.plus.IconsCache)

Example 48 with OsmandApplication

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;
}
Also used : OsmandApplication(net.osmand.plus.OsmandApplication) DrawSettings(net.osmand.plus.views.OsmandMapLayer.DrawSettings)

Example 49 with OsmandApplication

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;
}
Also used : IntentFilter(android.content.IntentFilter) OsmandApplication(net.osmand.plus.OsmandApplication) Intent(android.content.Intent) TargetPoint(net.osmand.plus.TargetPointsHelper.TargetPoint) Paint(android.graphics.Paint) DrawSettings(net.osmand.plus.views.OsmandMapLayer.DrawSettings)

Example 50 with OsmandApplication

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();
    }
}
Also used : OsmandApplication(net.osmand.plus.OsmandApplication) Drawable(android.graphics.drawable.Drawable) ImageView(android.widget.ImageView) QuadPoint(net.osmand.data.QuadPoint)

Aggregations

OsmandApplication (net.osmand.plus.OsmandApplication)181 View (android.view.View)46 TextView (android.widget.TextView)39 ArrayList (java.util.ArrayList)33 AlertDialog (android.support.v7.app.AlertDialog)32 ImageView (android.widget.ImageView)31 DialogInterface (android.content.DialogInterface)27 OsmandSettings (net.osmand.plus.OsmandSettings)27 LatLon (net.osmand.data.LatLon)25 Intent (android.content.Intent)21 AdapterView (android.widget.AdapterView)19 File (java.io.File)17 OsmandMapTileView (net.osmand.plus.views.OsmandMapTileView)15 Location (net.osmand.Location)13 EditText (android.widget.EditText)12 ContextMenuAdapter (net.osmand.plus.ContextMenuAdapter)12 ArrayAdapter (android.widget.ArrayAdapter)11 ListView (android.widget.ListView)11 ContextMenuItem (net.osmand.plus.ContextMenuItem)11 SelectedGpxFile (net.osmand.plus.GpxSelectionHelper.SelectedGpxFile)11