Added support for multiple timespanes in UI.

This commit is contained in:
GaidamakUA 2015-12-02 17:50:46 +02:00
parent 18e8f5a6df
commit 4a226142ed
3 changed files with 103 additions and 77 deletions

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);