Updated parking card
This commit is contained in:
parent
e8b434c53c
commit
3f5123c191
12 changed files with 140 additions and 75 deletions
7
OsmAnd/res/drawable/dash_parking_dark.xml
Normal file
7
OsmAnd/res/drawable/dash_parking_dark.xml
Normal file
|
@ -0,0 +1,7 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<selector xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<item android:drawable="@color/dashboard_parking_dark_selected" android:state_enabled="false"/>
|
||||
<item android:drawable="@color/dashboard_parking_dark_selected" android:state_pressed="true"/>
|
||||
<item android:drawable="@color/dashboard_parking_dark_selected" android:state_focused="true"/>
|
||||
<item android:drawable="@color/dashboard_parking_dark_color"/>
|
||||
</selector>
|
7
OsmAnd/res/drawable/dash_parking_light.xml
Normal file
7
OsmAnd/res/drawable/dash_parking_light.xml
Normal file
|
@ -0,0 +1,7 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<selector xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<item android:state_enabled="false" android:drawable="@color/parking_card_selected" />
|
||||
<item android:state_pressed="true" android:drawable="@color/parking_card_selected" />
|
||||
<item android:state_focused="true" android:drawable="@color/parking_card_selected" />
|
||||
<item android:drawable="@color/dashboard_blue" />
|
||||
</selector>
|
|
@ -7,6 +7,7 @@
|
|||
android:orientation="vertical">
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/parking_header"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="@dimen/dash_parking_height"
|
||||
android:background="?attr/dash_parking_bg"
|
||||
|
|
|
@ -36,7 +36,7 @@
|
|||
<attr name="expandable_list_background" format="color"/>
|
||||
<attr name="list_settings_icon" format="reference"/>
|
||||
<attr name="size_progress_bar" format="reference"/>
|
||||
<attr name="dash_parking_bg" format="color"/>
|
||||
<attr name="dash_parking_bg" format="reference"/>
|
||||
</declare-styleable>
|
||||
|
||||
<declare-styleable name="PagerSlidingTabStrip">
|
||||
|
|
|
@ -1,6 +1,10 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<resources>
|
||||
|
||||
<color name="parking_card_selected">#234DDE</color>
|
||||
<color name="dashboard_parking_dark_color">#54778c</color>
|
||||
<color name="dashboard_parking_dark_selected">#446072</color>
|
||||
|
||||
<color name="list_divider_dark">#1f2326</color>
|
||||
<color name="list_divider_light">@color/color_white</color>
|
||||
<color name="list_background_dark">#292f33</color>
|
||||
|
@ -33,7 +37,7 @@
|
|||
<color name="dashboard_subheader_text_light">#212121</color>
|
||||
<color name="dashboard_general_button_text_dark">#ff8f00</color>
|
||||
<color name="dashboard_general_button_text_light">#536DFE</color>
|
||||
<color name="dashboard_parking_dark">#54778c</color>
|
||||
|
||||
|
||||
<color name="color_transparent">#00000000</color>
|
||||
<color name="widgettext_night">#ffC8C8C8</color>
|
||||
|
|
|
@ -165,7 +165,7 @@
|
|||
<item name="expandable_list_background">@color/color_white</item>
|
||||
<item name="list_settings_icon">@drawable/ic_overflow_menu_light</item>
|
||||
<item name="size_progress_bar">@drawable/size_progressbar_light</item>
|
||||
<item name="dash_parking_bg">@color/dashboard_blue</item>
|
||||
<item name="dash_parking_bg">@drawable/dash_parking_light</item>
|
||||
</style>
|
||||
|
||||
<style name="OsmandDarkTheme" parent="Theme.AppCompat">
|
||||
|
@ -209,7 +209,7 @@
|
|||
<item name="expandable_list_background">@color/list_background_dark</item>
|
||||
<item name="list_settings_icon">@drawable/ic_overflow_menu_dark</item>
|
||||
<item name="size_progress_bar">@drawable/size_progressbar_dark</item>
|
||||
<item name="dash_parking_bg">@color/dashboard_parking_dark</item>
|
||||
<item name="dash_parking_bg">@drawable/dash_parking_dark</item>
|
||||
</style>
|
||||
|
||||
<style name="Widget.Styled.ActionBarDark" parent="Widget.AppCompat.Light.ActionBar.Solid.Inverse">
|
||||
|
|
|
@ -40,6 +40,7 @@ public class IconsCache {
|
|||
return getDrawable(id, colorId);
|
||||
}
|
||||
|
||||
|
||||
public Drawable getContentIcon(int id) {
|
||||
return getDrawable(id, app.getSettings().isLightContent() ? R.color.icon_color_light : 0);
|
||||
}
|
||||
|
|
|
@ -9,6 +9,7 @@ import net.osmand.plus.OsmAndFormatter;
|
|||
import net.osmand.plus.OsmandApplication;
|
||||
import net.osmand.plus.R;
|
||||
import net.osmand.plus.views.DirectionDrawable;
|
||||
|
||||
import android.annotation.SuppressLint;
|
||||
import android.app.Activity;
|
||||
import android.content.Context;
|
||||
|
@ -37,6 +38,7 @@ public abstract class DashLocationFragment extends DashBaseFragment {
|
|||
public TextView txt;
|
||||
public LatLon loc;
|
||||
public int arrowResId;
|
||||
public boolean paint = true;
|
||||
|
||||
public DashLocationView(ImageView arrow, TextView txt, LatLon loc) {
|
||||
super();
|
||||
|
@ -57,8 +59,7 @@ public abstract class DashLocationFragment extends DashBaseFragment {
|
|||
|
||||
public static int getScreenOrientation(Activity a) {
|
||||
int screenOrientation = ((WindowManager) a.getSystemService(Context.WINDOW_SERVICE)).getDefaultDisplay().getRotation();
|
||||
switch (screenOrientation)
|
||||
{
|
||||
switch (screenOrientation) {
|
||||
case ORIENTATION_0: // Device default (normally portrait)
|
||||
screenOrientation = 0;
|
||||
break;
|
||||
|
@ -104,18 +105,19 @@ public abstract class DashLocationFragment extends DashBaseFragment {
|
|||
float h = useCenter ? -mapRotation : head;
|
||||
for (DashLocationView lv : distances) {
|
||||
updateLocationView(useCenter, loc, h, lv.arrow, lv.arrowResId, lv.txt, lv.loc.getLatitude(), lv.loc.getLongitude(),
|
||||
screenOrientation, getMyApplication(), getActivity());
|
||||
screenOrientation, getMyApplication(), getActivity(), lv.paint);
|
||||
}
|
||||
}
|
||||
|
||||
public static void updateLocationView(boolean useCenter, LatLon fromLoc, Float h,
|
||||
ImageView arrow, TextView txt, double toLat, double toLon,
|
||||
int screenOrientation, OsmandApplication app, Context ctx) {
|
||||
updateLocationView(useCenter, fromLoc, h, arrow, 0, txt, toLat, toLon, screenOrientation, app, ctx);
|
||||
updateLocationView(useCenter, fromLoc, h, arrow, 0, txt, toLat, toLon, screenOrientation, app, ctx, true);
|
||||
}
|
||||
|
||||
public static void updateLocationView(boolean useCenter, LatLon fromLoc, Float h,
|
||||
ImageView arrow, int arrowResId, TextView txt, double toLat, double toLon,
|
||||
int screenOrientation, OsmandApplication app, Context ctx) {
|
||||
int screenOrientation, OsmandApplication app, Context ctx, boolean paint) {
|
||||
float[] mes = new float[2];
|
||||
if (fromLoc != null) {
|
||||
Location.distanceBetween(toLat, toLon, fromLoc.getLatitude(), fromLoc.getLongitude(), mes);
|
||||
|
@ -129,7 +131,11 @@ public abstract class DashLocationFragment extends DashBaseFragment {
|
|||
arrowResId = R.drawable.ic_destination_arrow_white;
|
||||
}
|
||||
DirectionDrawable dd = (DirectionDrawable) arrow.getDrawable();
|
||||
if (paint) {
|
||||
dd.setImage(arrowResId, useCenter ? R.color.color_distance : R.color.color_myloc_distance);
|
||||
} else {
|
||||
dd.setImage(arrowResId);
|
||||
}
|
||||
if (fromLoc == null || h == null) {
|
||||
dd.setAngle(0);
|
||||
} else {
|
||||
|
@ -139,8 +145,10 @@ public abstract class DashLocationFragment extends DashBaseFragment {
|
|||
}
|
||||
if (txt != null) {
|
||||
if (fromLoc != null) {
|
||||
if (paint) {
|
||||
txt.setTextColor(app.getResources().getColor(
|
||||
useCenter ? R.color.color_distance : R.color.color_myloc_distance));
|
||||
}
|
||||
txt.setText(OsmAndFormatter.getFormattedDistance(mes[0], app));
|
||||
} else {
|
||||
txt.setText("");
|
||||
|
|
|
@ -2,6 +2,7 @@ package net.osmand.plus.parkingpoint;
|
|||
|
||||
import android.app.AlertDialog;
|
||||
import android.content.DialogInterface;
|
||||
import android.graphics.Color;
|
||||
import android.graphics.Typeface;
|
||||
import android.os.Bundle;
|
||||
import android.support.v4.util.TimeUtils;
|
||||
|
@ -14,11 +15,14 @@ import android.view.ViewGroup;
|
|||
import android.widget.Button;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.TextView;
|
||||
|
||||
import net.osmand.Location;
|
||||
import net.osmand.data.LatLon;
|
||||
import net.osmand.data.PointDescription;
|
||||
import net.osmand.plus.OsmAndFormatter;
|
||||
import net.osmand.plus.OsmandPlugin;
|
||||
import net.osmand.plus.R;
|
||||
import net.osmand.plus.activities.MapActivity;
|
||||
import net.osmand.plus.dashboard.DashLocationFragment;
|
||||
import net.osmand.plus.helpers.FontCache;
|
||||
import net.osmand.util.MapUtils;
|
||||
|
@ -52,6 +56,16 @@ public class DashParkingFragment extends DashLocationFragment {
|
|||
});
|
||||
remove.setTypeface(typeface);
|
||||
|
||||
view.findViewById(R.id.parking_header).setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
LatLon point = plugin.getParkingPosition();
|
||||
getMyApplication().getSettings().setMapLocationToShow(point.getLatitude(), point.getLongitude(),
|
||||
15, new PointDescription(PointDescription.POINT_TYPE_FAVORITE, plugin.getParkingDescription(getActivity())), true,
|
||||
point); //$NON-NLS-1$
|
||||
MapActivity.launchMapActivityMoveToTop(getActivity());
|
||||
}
|
||||
});
|
||||
return view;
|
||||
}
|
||||
|
||||
|
@ -81,8 +95,15 @@ public class DashParkingFragment extends DashLocationFragment {
|
|||
if (limited) {
|
||||
long endtime = plugin.getParkingTime();
|
||||
long currTime = Calendar.getInstance().getTimeInMillis();
|
||||
String time = getFormattedTime(endtime - currTime);
|
||||
((TextView)mainView.findViewById(R.id.time_left)).setText(time);
|
||||
long timeDiff = endtime - currTime;
|
||||
String time = getFormattedTime(timeDiff);
|
||||
TextView time_left = ((TextView) mainView.findViewById(R.id.time_left));
|
||||
time_left.setText(time);
|
||||
if (timeDiff < 0) {
|
||||
time_left.setTextColor(Color.RED);
|
||||
} else {
|
||||
time_left.setTextColor(Color.WHITE);
|
||||
}
|
||||
mainView.findViewById(R.id.left_lbl).setVisibility(View.VISIBLE);
|
||||
} else {
|
||||
((TextView) mainView.findViewById(R.id.time_left)).setText("");
|
||||
|
@ -92,12 +113,12 @@ public class DashParkingFragment extends DashLocationFragment {
|
|||
ImageView direction = (ImageView) mainView.findViewById(R.id.direction_icon);
|
||||
if (loc != null) {
|
||||
DashLocationView dv = new DashLocationView(direction, (TextView) mainView.findViewById(R.id.distance), position);
|
||||
dv.paint = false;
|
||||
dv.arrowResId = R.drawable.ic_parking_postion_arrow;
|
||||
distances.add(dv);
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
String getFormattedTime(long timeInMillis) {
|
||||
|
@ -106,16 +127,19 @@ public class DashParkingFragment extends DashLocationFragment {
|
|||
}
|
||||
StringBuilder timeStringBuilder = new StringBuilder();
|
||||
int hours = (int) timeInMillis / (1000 * 60 * 60);
|
||||
int miutes = (int) timeInMillis / (1000 * 60 * 60 * 60);
|
||||
int minutes = (int) timeInMillis / (1000 * 60);
|
||||
if (hours > 0) {
|
||||
timeStringBuilder.append(hours);
|
||||
timeStringBuilder.append(" ");
|
||||
timeStringBuilder.append(getResources().getString(R.string.osmand_parking_hour));
|
||||
}
|
||||
|
||||
timeStringBuilder.append(" ");
|
||||
timeStringBuilder.append(miutes);
|
||||
timeStringBuilder.append(minutes);
|
||||
timeStringBuilder.append(" ");
|
||||
timeStringBuilder.append(getResources().getString(R.string.osmand_parking_minute));
|
||||
|
||||
|
||||
return timeStringBuilder.toString();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -136,45 +136,12 @@ public class ParkingPositionLayer extends OsmandMapLayer implements ContextMenuL
|
|||
|
||||
@Override
|
||||
public String getObjectDescription(Object o) {
|
||||
if (o instanceof LatLon) {
|
||||
StringBuilder timeLimitDesc = new StringBuilder();
|
||||
timeLimitDesc.append(map.getString(R.string.osmand_parking_position_description_add_time) + " ");
|
||||
timeLimitDesc.append(getFormattedTime(plugin.getStartParkingTime()) + ".");
|
||||
if (plugin.getParkingType()) {
|
||||
// long parkingTime = settings.getParkingTime();
|
||||
// long parkingStartTime = settings.getStartParkingTime();
|
||||
// Time time = new Time();
|
||||
// time.set(parkingTime);
|
||||
// timeLimitDesc.append(map.getString(R.string.osmand_parking_position_description_add) + " ");
|
||||
// timeLimitDesc.append(time.hour);
|
||||
// timeLimitDesc.append(":");
|
||||
// int minute = time.minute;
|
||||
// timeLimitDesc.append(minute<10 ? "0" + minute : minute);
|
||||
// if (!DateFormat.is24HourFormat(map.getApplicationContext())) {
|
||||
// timeLimitDesc.append(time.hour >= 12 ? map.getString(R.string.osmand_parking_pm) :
|
||||
// map.getString(R.string.osmand_parking_am));
|
||||
// }
|
||||
timeLimitDesc.append(map.getString(R.string.osmand_parking_position_description_add) + " ");
|
||||
timeLimitDesc.append(getFormattedTime(plugin.getParkingTime()));
|
||||
}
|
||||
return map.getString(R.string.osmand_parking_position_description, timeLimitDesc.toString());
|
||||
}
|
||||
return null;
|
||||
return plugin.getParkingDescription(map);
|
||||
|
||||
}
|
||||
|
||||
String getFormattedTime(long timeInMillis) {
|
||||
StringBuilder timeStringBuilder = new StringBuilder();
|
||||
Time time = new Time();
|
||||
time.set(timeInMillis);
|
||||
timeStringBuilder.append(time.hour);
|
||||
timeStringBuilder.append(":");
|
||||
int minute = time.minute;
|
||||
timeStringBuilder.append(minute < 10 ? "0" + minute : minute);
|
||||
if (!DateFormat.is24HourFormat(map)) {
|
||||
timeStringBuilder.append(time.hour >= 12 ? map.getString(R.string.osmand_parking_pm) : map
|
||||
.getString(R.string.osmand_parking_am));
|
||||
}
|
||||
return timeStringBuilder.toString();
|
||||
public String getFormattedTime(long time){
|
||||
return plugin.getFormattedTime(time, map);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -27,6 +27,8 @@ import android.app.Dialog;
|
|||
import android.content.DialogInterface;
|
||||
import android.content.Intent;
|
||||
import android.graphics.Paint;
|
||||
import android.text.format.DateFormat;
|
||||
import android.text.format.Time;
|
||||
import android.view.View;
|
||||
import android.widget.ArrayAdapter;
|
||||
import android.widget.CheckBox;
|
||||
|
@ -524,4 +526,43 @@ public class ParkingPositionPlugin extends OsmandPlugin {
|
|||
public int getLogoResourceId() {
|
||||
return R.drawable.ic_action_parking_dark;
|
||||
}
|
||||
|
||||
String getFormattedTime(long timeInMillis, Activity ctx) {
|
||||
StringBuilder timeStringBuilder = new StringBuilder();
|
||||
Time time = new Time();
|
||||
time.set(timeInMillis);
|
||||
timeStringBuilder.append(time.hour);
|
||||
timeStringBuilder.append(":");
|
||||
int minute = time.minute;
|
||||
timeStringBuilder.append(minute < 10 ? "0" + minute : minute);
|
||||
if (!DateFormat.is24HourFormat(ctx)) {
|
||||
timeStringBuilder.append(time.hour >= 12 ? ctx.getString(R.string.osmand_parking_pm) : ctx
|
||||
.getString(R.string.osmand_parking_am));
|
||||
}
|
||||
return timeStringBuilder.toString();
|
||||
}
|
||||
|
||||
public String getParkingDescription(Activity ctx) {
|
||||
StringBuilder timeLimitDesc = new StringBuilder();
|
||||
timeLimitDesc.append(ctx.getString(R.string.osmand_parking_position_description_add_time) + " ");
|
||||
timeLimitDesc.append(getFormattedTime(getStartParkingTime(), ctx) + ".");
|
||||
if (getParkingType()) {
|
||||
// long parkingTime = settings.getParkingTime();
|
||||
// long parkingStartTime = settings.getStartParkingTime();
|
||||
// Time time = new Time();
|
||||
// time.set(parkingTime);
|
||||
// timeLimitDesc.append(map.getString(R.string.osmand_parking_position_description_add) + " ");
|
||||
// timeLimitDesc.append(time.hour);
|
||||
// timeLimitDesc.append(":");
|
||||
// int minute = time.minute;
|
||||
// timeLimitDesc.append(minute<10 ? "0" + minute : minute);
|
||||
// if (!DateFormat.is24HourFormat(map.getApplicationContext())) {
|
||||
// timeLimitDesc.append(time.hour >= 12 ? map.getString(R.string.osmand_parking_pm) :
|
||||
// map.getString(R.string.osmand_parking_am));
|
||||
// }
|
||||
timeLimitDesc.append(ctx.getString(R.string.osmand_parking_position_description_add) + " ");
|
||||
timeLimitDesc.append(getFormattedTime(getParkingTime(),ctx));
|
||||
}
|
||||
return ctx.getString(R.string.osmand_parking_position_description, timeLimitDesc.toString());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -33,6 +33,11 @@ public class DirectionDrawable extends Drawable {
|
|||
arrowImage = iconsCache.getIcon(resourceId, clrId);
|
||||
}
|
||||
|
||||
public void setImage(int resourceId){
|
||||
IconsCache iconsCache = ((OsmandApplication) ctx.getApplicationContext()).getIconsCache();
|
||||
arrowImage = iconsCache.getIcon(resourceId, 0);
|
||||
}
|
||||
|
||||
|
||||
public DirectionDrawable(Context ctx, float width, float height) {
|
||||
this.ctx = ctx;
|
||||
|
|
Loading…
Reference in a new issue