Merge remote-tracking branch 'origin/master'

This commit is contained in:
Weblate 2015-12-02 16:51:41 +01:00
commit 71c95fef0d
5 changed files with 131 additions and 79 deletions

View file

@ -8,6 +8,8 @@ import java.util.ArrayList;
import java.util.Arrays;
import java.util.Calendar;
import gnu.trove.list.array.TIntArrayList;
/**
* Class used to parse opening hours
*
@ -288,7 +290,22 @@ public class OpeningHoursParser {
}
return endTimes[0];
}
/**
* get all start times as independent list
* @return all start times
*/
public TIntArrayList getStartTimes() {
return new TIntArrayList(startTimes);
}
/**
* get all end times as independent list
* @return all end times
*/
public TIntArrayList getEndTimes() {
return new TIntArrayList(endTimes);
}
/**
* Check if the weekday of time "cal" is part of this rule
@ -925,5 +942,14 @@ public class OpeningHoursParser {
testOpened("05.10.2013 15:00", hours, true);
testOpened("05.10.2013 20:00", hours, false);
// Test time with breaks
hours = parseOpenedHours("Mo-Fr: 9:00-13:00, 14:00-18:00");
System.out.println(hours);
testOpened("02.12.2015 12:00", hours, true);
testOpened("02.12.2015 13:30", hours, false);
testOpened("02.12.2015 16:00", hours, true);
testOpened("05.12.2015 16:00", hours, false);
}
}

View file

@ -4,20 +4,20 @@
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center_vertical"
android:orientation="horizontal">
<ImageView
android:id="@+id/clockIconImageView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="16dp"
android:layout_margin="16dp"
android:src="@drawable/ic_action_time"/>
<LinearLayout
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginLeft="32dp"
android:layout_marginLeft="16dp"
android:layout_marginTop="16dp"
android:layout_weight="1"
android:orientation="vertical">
@ -36,56 +36,12 @@
</LinearLayout>
<LinearLayout
android:id="@+id/timeContainer"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="center_vertical">
android:orientation="vertical"
android:id="@+id/timeListContainer">
<!--<include layout="@layout/time_from_to_layout"/>-->
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="16dp"
android:layout_marginRight="16dp"
android:orientation="vertical">
<TextView
android:id="@+id/openingTextView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textColor="?android:textColorPrimary"
android:textSize="@dimen/default_list_text_size"
tools:text="08:00"/>
<View
android:layout_width="match_parent"
android:layout_height="1dp"
android:background="?android:textColorSecondary"/>
</LinearLayout>
<View
android:layout_width="16dp"
android:layout_height="1dp"
android:background="?android:textColorSecondary"/>
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="16dp"
android:orientation="vertical">
<TextView
android:id="@+id/closingTextView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textColor="?android:textColorPrimary"
android:textSize="@dimen/default_list_text_size"
tools:text="20:00"/>
<View
android:layout_width="match_parent"
android:layout_height="1dp"
android:background="?android:textColorSecondary"/>
</LinearLayout>
</LinearLayout>
<ImageButton
@ -93,7 +49,7 @@
style="@style/Widget.AppCompat.Button.Borderless"
android:layout_width="48dp"
android:layout_height="48dp"
android:layout_gravity="bottom"
android:layout_gravity="top"
android:src="@drawable/ic_action_remove_dark"/>
</LinearLayout>

View file

@ -0,0 +1,60 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="center_vertical"
tools:showIn="@layout/open_time_list_item"
android:layout_marginTop="16dp">
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="16dp"
android:layout_marginRight="16dp"
android:orientation="vertical">
<TextView
android:id="@+id/openingTextView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textColor="?android:textColorPrimary"
android:textSize="@dimen/default_list_text_size"
tools:text="08:00"/>
<View
android:layout_width="match_parent"
android:layout_height="1dp"
android:background="?android:textColorSecondary"/>
</LinearLayout>
<View
android:layout_width="16dp"
android:layout_height="1dp"
android:background="?android:textColorSecondary"/>
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="16dp"
android:orientation="vertical">
<TextView
android:id="@+id/closingTextView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textColor="?android:textColorPrimary"
android:textSize="@dimen/default_list_text_size"
tools:text="20:00"/>
<View
android:layout_width="match_parent"
android:layout_height="1dp"
android:background="?android:textColorSecondary"/>
</LinearLayout>
</LinearLayout>

View file

@ -34,6 +34,8 @@ import net.osmand.util.OpeningHoursParser.BasicOpeningHourRule;
import org.apache.commons.logging.Log;
import gnu.trove.list.array.TIntArrayList;
public class BasicEditPoiFragment extends Fragment
implements EditPoiDialogFragment.OnFragmentActivatedListener {
private static final Log LOG = PlatformUtil.getLog(BasicEditPoiFragment.class);
@ -248,7 +250,7 @@ public class BasicEditPoiFragment extends Fragment
clockIconImageView.setImageDrawable(clockDrawable);
TextView daysTextView = (TextView) view.findViewById(R.id.daysTextView);
View timeContainer = view.findViewById(R.id.timeContainer);
LinearLayout timeListContainer = (LinearLayout) view.findViewById(R.id.timeListContainer);
if (openingHours.getRules().get(position) instanceof BasicOpeningHourRule) {
final OpeningHoursParser.BasicOpeningHourRule rule =
@ -257,14 +259,6 @@ public class BasicEditPoiFragment extends Fragment
rule.appendDaysString(stringBuilder);
daysTextView.setText(stringBuilder.toString());
TextView openingTextView = (TextView) view.findViewById(R.id.openingTextView);
openingTextView.setText(Algorithms.formatMinutesDuration(rule.getStartTime()));
TextView closingTextView = (TextView) view.findViewById(R.id.closingTextView);
closingTextView.setText(Algorithms.formatMinutesDuration(rule.getEndTime()));
timeContainer.setVisibility(View.VISIBLE);
daysTextView.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
@ -273,25 +267,41 @@ public class BasicEditPoiFragment extends Fragment
fragment.show(getChildFragmentManager(), "OpenTimeDialogFragment");
}
});
openingTextView.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
OpeningHoursHoursDialogFragment fragment =
OpeningHoursHoursDialogFragment.createInstance(rule, position, true);
fragment.show(getChildFragmentManager(), "OpeningHoursHoursDialogFragment");
}
});
closingTextView.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
OpeningHoursHoursDialogFragment fragment =
OpeningHoursHoursDialogFragment.createInstance(rule, position, false);
fragment.show(getChildFragmentManager(), "OpeningHoursHoursDialogFragment");
}
});
TIntArrayList startTimes = rule.getStartTimes();
TIntArrayList endTimes = rule.getEndTimes();
for (int i = 0; i < startTimes.size(); i++) {
View timeFromToLayout = LayoutInflater.from(linearLayout.getContext())
.inflate(R.layout.time_from_to_layout, timeListContainer, false);
TextView openingTextView =
(TextView) timeFromToLayout.findViewById(R.id.openingTextView);
openingTextView.setText(Algorithms.formatMinutesDuration(startTimes.get(i)));
TextView closingTextView =
(TextView) timeFromToLayout.findViewById(R.id.closingTextView);
closingTextView.setText(Algorithms.formatMinutesDuration(endTimes.get(i)));
openingTextView.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
OpeningHoursHoursDialogFragment fragment =
OpeningHoursHoursDialogFragment.createInstance(rule, position, true);
fragment.show(getChildFragmentManager(), "OpeningHoursHoursDialogFragment");
}
});
closingTextView.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
OpeningHoursHoursDialogFragment fragment =
OpeningHoursHoursDialogFragment.createInstance(rule, position, false);
fragment.show(getChildFragmentManager(), "OpeningHoursHoursDialogFragment");
}
});
timeListContainer.addView(timeFromToLayout);
}
} else if (openingHours.getRules().get(position) instanceof OpeningHoursParser.UnparseableRule) {
daysTextView.setText(openingHours.getRules().get(position).toRuleString(false));
timeContainer.setVisibility(View.GONE);
timeListContainer.removeAllViews();
}
ImageButton deleteItemImageButton = (ImageButton) view.findViewById(R.id.deleteItemImageButton);

View file

@ -41,7 +41,7 @@ public class PointLocationLayer extends OsmandMapLayer implements ContextMenuLay
private Bitmap locationIcon;
private OsmAndLocationProvider locationProvider;
private MapViewTrackingUtilities mapViewTrackingUtilities;
private boolean nm = false;
private boolean nm;
public PointLocationLayer(MapViewTrackingUtilities mv) {
this.mapViewTrackingUtilities = mv;