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"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:background="?attr/card_bg"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent">
android:layout_height="match_parent"
android:background="?attr/card_bg"
android:orientation="vertical">
<LinearLayout android:orientation="horizontal"
android:layout_width="match_parent"
android:background="@color/dashboard_blue"
android:layout_height="@dimen/dash_parking_height">
<ImageView android:id="@+id/direction_icon"
android:layout_gravity="center_vertical"
android:layout_marginLeft="@dimen/dashFavIconMargin"
android:layout_marginRight="@dimen/dashFavIconMargin"
android:layout_width="wrap_content"
android:layout_height="wrap_content"/>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="@dimen/dash_parking_height"
android:background="?attr/dash_parking_bg"
android:orientation="horizontal">
<LinearLayout android:orientation="vertical"
android:layout_gravity="center_vertical"
android:layout_width="0dp"
android:layout_weight="1"
android:layout_height="wrap_content">
<TextView android:id="@+id/distance"
android:layout_width="match_parent"
android:layout_height="wrap_content"/>
<TextView android:id="@+id/name"
android:layout_width="wrap_content"
android:layout_height="wrap_content"/>
<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_marginLeft="@dimen/dashboard_parking_left_margin"
android:layout_marginRight="@dimen/dashFavIconMargin"
android:src="@drawable/ic_parking_postion_arrow"/>
<LinearLayout
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:layout_weight="1"
android:orientation="vertical">
<TextView
android:id="@+id/distance"
android:layout_width="match_parent"
android:layout_height="wrap_content"/>
<TextView
android:id="@+id/name"
android:layout_width="wrap_content"
android:layout_height="wrap_content"/>
</LinearLayout>
<LinearLayout android:orientation="vertical"
android:layout_width="wrap_content"
android:layout_gravity="center_vertical"
android:layout_marginRight="@dimen/dashFavIconMargin"
android:layout_height="wrap_content">
<TextView android:id="@+id/next_turn_distance"
android:layout_width="match_parent"
android:layout_height="wrap_content"/>
<TextView android:id="@+id/next_turn"
android:layout_width="wrap_content"
android:layout_height="wrap_content"/>
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:layout_marginRight="@dimen/dashFavIconMargin"
android:orientation="vertical">
<TextView
android:id="@+id/time_left"
android:layout_width="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>
<Button android:id="@+id/remove_tag"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@string/remove_the_tag"
style="?attr/dashboardGeneralButtonStyle"/>
<Button
android:id="@+id/remove_tag"
style="?attr/dashboardGeneralButtonStyle"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@string/remove_the_tag"/>
</LinearLayout>

View file

@ -36,6 +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"/>
</declare-styleable>
<declare-styleable name="PagerSlidingTabStrip">

View file

@ -32,6 +32,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>

View file

@ -21,7 +21,7 @@
<dimen name="dashCardMargin">4dp</dimen>
<dimen name="abp__shadow_height">4dp</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_header_padding">8dp</dimen>
<dimen name="tab_height">48dp</dimen>
@ -46,6 +46,8 @@
<dimen name="dashboard_map_width">360dp</dimen>
<dimen name="dashboard_map_top_padding">@dimen/dashMapHeight</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 -->
<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).
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="track_segments">Track segments</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="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>
</style>
<style name="OsmandDarkTheme" parent="Theme.AppCompat">
@ -209,6 +210,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>
</style>
<style name="Widget.Styled.ActionBarDark" parent="Widget.AppCompat.Light.ActionBar.Solid.Inverse">

View file

@ -108,6 +108,11 @@ public class DashPluginsFragment extends DashBaseFragment {
@Override
public void onResume() {
super.onResume();
refreshCard();
}
@Override
public void refreshCard() {
View contentView = getView();
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.graphics.Typeface;
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.View;
import android.view.ViewGroup;
@ -19,6 +23,8 @@ import net.osmand.plus.dashboard.DashLocationFragment;
import net.osmand.plus.helpers.FontCache;
import net.osmand.util.MapUtils;
import java.util.Calendar;
/**
* Created by Denis on
* 26.01.2015.
@ -80,13 +86,24 @@ public class DashParkingFragment extends DashLocationFragment {
String distance = OsmAndFormatter.getFormattedDistance(dist, getMyApplication());
((TextView) mainView.findViewById(R.id.distance)).setText(distance);
//TODO add parking time
String parking_name = plugin.getParkingType() ?
getString(R.string.parking_place) : getString(R.string.parking_place);
boolean limited = plugin.getParkingType();
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);
ImageView direction = (ImageView) mainView.findViewById(R.id.direction_icon);
if (loc != null){
direction.setVisibility(View.VISIBLE);
updateArrow(getActivity(), loc, position, direction, 10, R.drawable.ic_destination_arrow, heading);
updateArrow(getActivity(), loc, position, direction,
(int)getResources().getDimension(R.dimen.dashboard_parking_icon_size), R.drawable.ic_parking_postion_arrow, heading);
}
}
@ -110,4 +127,23 @@ public class DashParkingFragment extends DashLocationFragment {
}
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();
}