Added card for parking plugin

Conflicts:
	OsmAnd/src/net/osmand/plus/parkingpoint/DashParkingFragment.java
This commit is contained in:
Denis 2015-03-06 17:09:50 +02:00
parent 056226bda3
commit ae34831ef9
9 changed files with 155 additions and 45 deletions

View file

@ -1,53 +1,72 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical" xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="?attr/card_bg" android:background="?attr/card_bg"
android:layout_width="match_parent" android:orientation="vertical">
android:layout_height="match_parent">
<LinearLayout android:orientation="horizontal" <LinearLayout
android:layout_width="match_parent" android:layout_width="match_parent"
android:background="@color/dashboard_blue" android:layout_height="@dimen/dash_parking_height"
android:layout_height="@dimen/dash_parking_height"> android:background="?attr/dash_parking_bg"
<ImageView android:id="@+id/direction_icon" android:orientation="horizontal">
<ImageView
android:id="@+id/direction_icon"
android:layout_width="@dimen/dashboard_parking_icon_size"
android:layout_height="@dimen/dashboard_parking_icon_size"
android:layout_gravity="center_vertical" android:layout_gravity="center_vertical"
android:layout_marginLeft="@dimen/dashFavIconMargin" android:layout_marginLeft="@dimen/dashboard_parking_left_margin"
android:layout_marginRight="@dimen/dashFavIconMargin" android:layout_marginRight="@dimen/dashFavIconMargin"
android:layout_width="wrap_content" android:src="@drawable/ic_parking_postion_arrow"/>
android:layout_height="wrap_content"/>
<LinearLayout android:orientation="vertical" <LinearLayout
android:layout_gravity="center_vertical"
android:layout_width="0dp" android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:layout_weight="1" android:layout_weight="1"
android:layout_height="wrap_content"> android:orientation="vertical">
<TextView android:id="@+id/distance"
<TextView
android:id="@+id/distance"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content"/> android:layout_height="wrap_content"/>
<TextView android:id="@+id/name"
<TextView
android:id="@+id/name"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content"/> android:layout_height="wrap_content"/>
</LinearLayout> </LinearLayout>
<LinearLayout android:orientation="vertical" <LinearLayout
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical" android:layout_gravity="center_vertical"
android:layout_marginRight="@dimen/dashFavIconMargin" android:layout_marginRight="@dimen/dashFavIconMargin"
android:layout_height="wrap_content"> android:orientation="vertical">
<TextView android:id="@+id/next_turn_distance"
android:layout_width="match_parent" <TextView
android:layout_height="wrap_content"/> android:id="@+id/time_left"
<TextView android:id="@+id/next_turn"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content"/> android:layout_height="wrap_content"
tools:text="@string/app_mode_aircraft"/>
<TextView
android:id="@+id/left_lbl"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/osmand_parking_time_left"
tools:text="@string/app_version"/>
</LinearLayout> </LinearLayout>
</LinearLayout> </LinearLayout>
<Button android:id="@+id/remove_tag" <Button
android:id="@+id/remove_tag"
style="?attr/dashboardGeneralButtonStyle"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:text="@string/remove_the_tag" android:text="@string/remove_the_tag"/>
style="?attr/dashboardGeneralButtonStyle"/>
</LinearLayout> </LinearLayout>

View file

@ -36,6 +36,7 @@
<attr name="expandable_list_background" format="color"/> <attr name="expandable_list_background" format="color"/>
<attr name="list_settings_icon" format="reference"/> <attr name="list_settings_icon" format="reference"/>
<attr name="size_progress_bar" format="reference"/> <attr name="size_progress_bar" format="reference"/>
<attr name="dash_parking_bg" format="color"/>
</declare-styleable> </declare-styleable>
<declare-styleable name="PagerSlidingTabStrip"> <declare-styleable name="PagerSlidingTabStrip">

View file

@ -32,6 +32,7 @@
<color name="dashboard_subheader_text_light">#212121</color> <color name="dashboard_subheader_text_light">#212121</color>
<color name="dashboard_general_button_text_dark">#ff8f00</color> <color name="dashboard_general_button_text_dark">#ff8f00</color>
<color name="dashboard_general_button_text_light">#536DFE</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="color_transparent">#00000000</color>
<color name="widgettext_night">#ffC8C8C8</color> <color name="widgettext_night">#ffC8C8C8</color>

View file

@ -21,7 +21,7 @@
<dimen name="dashCardMargin">4dp</dimen> <dimen name="dashCardMargin">4dp</dimen>
<dimen name="abp__shadow_height">4dp</dimen> <dimen name="abp__shadow_height">4dp</dimen>
<dimen name="dashFABMargin">0dp</dimen> <dimen name="dashFABMargin">0dp</dimen>
<dimen name="dash_parking_height">100dp</dimen> <dimen name="dash_parking_height">78dp</dimen>
<dimen name="list_content_padding">16dp</dimen> <dimen name="list_content_padding">16dp</dimen>
<dimen name="list_header_padding">8dp</dimen> <dimen name="list_header_padding">8dp</dimen>
<dimen name="tab_height">48dp</dimen> <dimen name="tab_height">48dp</dimen>
@ -46,6 +46,8 @@
<dimen name="dashboard_map_width">360dp</dimen> <dimen name="dashboard_map_width">360dp</dimen>
<dimen name="dashboard_map_top_padding">@dimen/dashMapHeight</dimen> <dimen name="dashboard_map_top_padding">@dimen/dashMapHeight</dimen>
<dimen name="dashboard_map_bottom_padding">90dp</dimen> <dimen name="dashboard_map_bottom_padding">90dp</dimen>
<dimen name="dashboard_parking_left_margin">16dp</dimen>
<dimen name="dashboard_parking_icon_size">48dp</dimen>
<!-- TextSizes --> <!-- TextSizes -->
<dimen name="list_header_text_size">14sp</dimen> <dimen name="list_header_text_size">14sp</dimen>

View file

@ -9,6 +9,11 @@
3. All your modified/created strings are in the top of the file (to make easier find what\'s translated). 3. All your modified/created strings are in the top of the file (to make easier find what\'s translated).
PLEASE: Have a look at http://code.google.com/p/osmand/wiki/UIConsistency, it may really improve your and our work :-) Thx - Hardy PLEASE: Have a look at http://code.google.com/p/osmand/wiki/UIConsistency, it may really improve your and our work :-) Thx - Hardy
--> -->
<string name="osmand_parking_hour">h</string><!-- means first letter of word *hour*-->
<string name="osmand_parking_minute">m</string><!-- means first letter of word *minute*-->
<string name="osmand_parking_time_left">Left</string> <!-- used to describe time left, not left direction -->
<string name="parking_place_limited">Parking place time limited</string>
<string name="your_edits">Your Edits</string>
<string name="route_points">Route points</string> <string name="route_points">Route points</string>
<string name="track_segments">Track segments</string> <string name="track_segments">Track segments</string>
<string name="track_points">Track points</string> <string name="track_points">Track points</string>

View file

@ -166,6 +166,7 @@
<item name="expandable_list_background">@color/color_white</item> <item name="expandable_list_background">@color/color_white</item>
<item name="list_settings_icon">@drawable/ic_overflow_menu_light</item> <item name="list_settings_icon">@drawable/ic_overflow_menu_light</item>
<item name="size_progress_bar">@drawable/size_progressbar_light</item> <item name="size_progress_bar">@drawable/size_progressbar_light</item>
<item name="dash_parking_bg">@color/dashboard_blue</item>
</style> </style>
<style name="OsmandDarkTheme" parent="Theme.AppCompat"> <style name="OsmandDarkTheme" parent="Theme.AppCompat">
@ -209,6 +210,7 @@
<item name="expandable_list_background">@color/list_background_dark</item> <item name="expandable_list_background">@color/list_background_dark</item>
<item name="list_settings_icon">@drawable/ic_overflow_menu_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="size_progress_bar">@drawable/size_progressbar_dark</item>
<item name="dash_parking_bg">@color/dashboard_parking_dark</item>
</style> </style>
<style name="Widget.Styled.ActionBarDark" parent="Widget.AppCompat.Light.ActionBar.Solid.Inverse"> <style name="Widget.Styled.ActionBarDark" parent="Widget.AppCompat.Light.ActionBar.Solid.Inverse">

View file

@ -108,6 +108,11 @@ public class DashPluginsFragment extends DashBaseFragment {
@Override @Override
public void onResume() { public void onResume() {
super.onResume(); super.onResume();
refreshCard();
}
@Override
public void refreshCard() {
View contentView = getView(); View contentView = getView();
if (contentView == null) { if (contentView == null) {

View file

@ -0,0 +1,39 @@
package net.osmand.plus.osmedit;
import android.os.Bundle;
import android.support.v4.app.ListFragment;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import android.widget.TextView;
import net.osmand.plus.OsmandPlugin;
import net.osmand.plus.R;
import net.osmand.plus.audionotes.AudioVideoNotesPlugin;
/**
* Created by Denis
* on 06.03.2015.
*/
public class OsmEditsFragment extends ListFragment {
OsmEditingPlugin plugin;
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
setHasOptionsMenu(true);
plugin = OsmandPlugin.getEnabledPlugin(OsmEditingPlugin.class);
View view = getActivity().getLayoutInflater().inflate(R.layout.update_index, container, false);
view.findViewById(R.id.select_all).setVisibility(View.GONE);
((TextView) view.findViewById(R.id.header)).setText(R.string.your_edits);
return view;
}
@Override
public void onResume() {
super.onResume();
}
}

View file

@ -4,6 +4,10 @@ import android.app.AlertDialog;
import android.content.DialogInterface; import android.content.DialogInterface;
import android.graphics.Typeface; import android.graphics.Typeface;
import android.os.Bundle; import android.os.Bundle;
import android.support.v4.util.TimeUtils;
import android.text.format.DateFormat;
import android.text.format.DateUtils;
import android.text.format.Time;
import android.view.LayoutInflater; import android.view.LayoutInflater;
import android.view.View; import android.view.View;
import android.view.ViewGroup; import android.view.ViewGroup;
@ -19,6 +23,8 @@ import net.osmand.plus.dashboard.DashLocationFragment;
import net.osmand.plus.helpers.FontCache; import net.osmand.plus.helpers.FontCache;
import net.osmand.util.MapUtils; import net.osmand.util.MapUtils;
import java.util.Calendar;
/** /**
* Created by Denis on * Created by Denis on
* 26.01.2015. * 26.01.2015.
@ -80,13 +86,24 @@ public class DashParkingFragment extends DashLocationFragment {
String distance = OsmAndFormatter.getFormattedDistance(dist, getMyApplication()); String distance = OsmAndFormatter.getFormattedDistance(dist, getMyApplication());
((TextView) mainView.findViewById(R.id.distance)).setText(distance); ((TextView) mainView.findViewById(R.id.distance)).setText(distance);
//TODO add parking time //TODO add parking time
String parking_name = plugin.getParkingType() ? boolean limited = plugin.getParkingType();
getString(R.string.parking_place) : getString(R.string.parking_place); String parking_name = limited ?
getString(R.string.parking_place_limited) : getString(R.string.parking_place);
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);
mainView.findViewById(R.id.left_lbl).setVisibility(View.VISIBLE);
} else {
((TextView)mainView.findViewById(R.id.time_left)).setText("");
mainView.findViewById(R.id.left_lbl).setVisibility(View.GONE);
}
((TextView) mainView.findViewById(R.id.name)).setText(parking_name); ((TextView) mainView.findViewById(R.id.name)).setText(parking_name);
ImageView direction = (ImageView) mainView.findViewById(R.id.direction_icon); ImageView direction = (ImageView) mainView.findViewById(R.id.direction_icon);
if (loc != null){ if (loc != null){
direction.setVisibility(View.VISIBLE); updateArrow(getActivity(), loc, position, direction,
updateArrow(getActivity(), loc, position, direction, 10, R.drawable.ic_destination_arrow, heading); (int)getResources().getDimension(R.dimen.dashboard_parking_icon_size), R.drawable.ic_parking_postion_arrow, heading);
} }
} }
@ -111,3 +128,22 @@ public class DashParkingFragment extends DashLocationFragment {
updateParkingPosition(); updateParkingPosition();
} }
} }
String getFormattedTime(long timeInMillis) {
if (timeInMillis < 0){
timeInMillis *= -1;
}
StringBuilder timeStringBuilder = new StringBuilder();
int hours = (int)timeInMillis / (1000*60*60);
int miutes = (int)timeInMillis / (1000*60*60*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(" ");
timeStringBuilder.append(getResources().getString(R.string.osmand_parking_minute));
return timeStringBuilder.toString();
}