Opening hours fixed, number of rows in progress
This commit is contained in:
parent
759e169586
commit
a1cbb76207
13 changed files with 203 additions and 111 deletions
45
OsmAnd/res/layout/dashboard_settings_dialog_item_1.xml
Normal file
45
OsmAnd/res/layout/dashboard_settings_dialog_item_1.xml
Normal file
|
@ -0,0 +1,45 @@
|
|||
<?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="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="vertical"
|
||||
android:paddingLeft="@dimen/dialog_content_margin"
|
||||
android:paddingRight="@dimen/dialog_content_margin">
|
||||
|
||||
<include layout="@layout/dashboard_settings_dialog_item"/>
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/numberOfRowsTextView"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
tools:text="Number of rows %s"/>
|
||||
|
||||
<Space
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="1"/>
|
||||
|
||||
<Button
|
||||
android:id="@+id/decrementButton"
|
||||
style="@style/Widget.AppCompat.Button.Borderless"
|
||||
android:layout_width="48dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:padding="0dp"
|
||||
android:text="-" />
|
||||
|
||||
<Button
|
||||
android:id="@+id/incrementButton"
|
||||
style="@style/Widget.AppCompat.Button.Borderless"
|
||||
android:layout_width="48dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:padding="0dp"
|
||||
android:text="+" />
|
||||
|
||||
</LinearLayout>
|
||||
</LinearLayout>
|
|
@ -1,6 +1,7 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<android.support.v4.widget.NestedScrollView
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:osmand="http://schemas.android.com/apk/res-auto"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:theme="@style/OsmandLightTheme.NewAppTheme">
|
||||
|
@ -11,72 +12,79 @@
|
|||
android:layout_height="match_parent"
|
||||
android:orientation="vertical">
|
||||
|
||||
<FrameLayout
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginLeft="16dp"
|
||||
android:layout_marginRight="16dp"
|
||||
android:layout_marginTop="16dp"
|
||||
android:background="@drawable/bg_card_shadow">
|
||||
android:background="?attr/bg_card"
|
||||
android:orientation="vertical">
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="vertical">
|
||||
android:layout_height="37dp"
|
||||
android:gravity="center">
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
<net.osmand.plus.widgets.TextViewEx
|
||||
android:layout_width="120dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:gravity="center">
|
||||
|
||||
<TextView
|
||||
android:layout_width="120dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_margin="16dp"
|
||||
android:text="name"/>
|
||||
|
||||
<View
|
||||
android:layout_width="1dp"
|
||||
android:layout_height="match_parent"
|
||||
android:background="@color/divider_color"/>
|
||||
|
||||
<TextView
|
||||
android:id="@+id/nameTextView"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_margin="16dp"/>
|
||||
</LinearLayout>
|
||||
android:layout_marginLeft="16dp"
|
||||
android:layout_marginRight="16dp"
|
||||
android:text="name"
|
||||
android:textSize="14sp"
|
||||
osmand:typeface="@string/font_roboto_regular"/>
|
||||
|
||||
<View
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="1dp"
|
||||
android:layout_width="1dp"
|
||||
android:layout_height="match_parent"
|
||||
android:background="@color/divider_color"/>
|
||||
|
||||
<LinearLayout
|
||||
<net.osmand.plus.widgets.TextViewEx
|
||||
android:id="@+id/nameTextView"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:gravity="center">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/amenityTagTextView"
|
||||
android:layout_width="120dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_margin="16dp"
|
||||
android:text="amenity"/>
|
||||
|
||||
<View
|
||||
android:layout_width="1dp"
|
||||
android:layout_height="match_parent"
|
||||
android:background="@color/divider_color"/>
|
||||
|
||||
<TextView
|
||||
android:id="@+id/amenityTextView"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_margin="16dp"/>
|
||||
</LinearLayout>
|
||||
android:layout_marginLeft="16dp"
|
||||
android:layout_marginRight="16dp"
|
||||
android:textSize="14sp"
|
||||
osmand:typeface="@string/font_roboto_medium"/>
|
||||
</LinearLayout>
|
||||
</FrameLayout>
|
||||
|
||||
<View
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="1dp"
|
||||
android:background="@color/divider_color"/>
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="37dp"
|
||||
android:gravity="center">
|
||||
|
||||
<net.osmand.plus.widgets.TextViewEx
|
||||
android:id="@+id/amenityTagTextView"
|
||||
android:layout_width="120dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginLeft="16dp"
|
||||
android:layout_marginRight="16dp"
|
||||
android:text="amenity"
|
||||
android:textSize="14sp"
|
||||
osmand:typeface="@string/font_roboto_regular"/>
|
||||
|
||||
<View
|
||||
android:layout_width="1dp"
|
||||
android:layout_height="match_parent"
|
||||
android:background="@color/divider_color"/>
|
||||
|
||||
<net.osmand.plus.widgets.TextViewEx
|
||||
android:id="@+id/amenityTextView"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginLeft="16dp"
|
||||
android:layout_marginRight="16dp"
|
||||
android:textSize="14sp"
|
||||
osmand:typeface="@string/font_roboto_medium"/>
|
||||
</LinearLayout>
|
||||
</LinearLayout>
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/editTagsList"
|
||||
|
@ -87,11 +95,13 @@
|
|||
|
||||
<include layout="@layout/poi_tag_list_item"/>
|
||||
|
||||
<Button
|
||||
<net.osmand.plus.widgets.ButtonEx
|
||||
android:id="@+id/addTagButton"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="Add tag"/>
|
||||
android:text="Add tag"
|
||||
android:textSize="12sp"
|
||||
osmand:typeface="@string/font_roboto_medium"/>
|
||||
|
||||
<!--XXX due to bug in NestedScroolView-->
|
||||
<Space
|
||||
|
|
|
@ -104,13 +104,15 @@
|
|||
android:layout_below="@id/openHoursTextView"
|
||||
android:orientation="vertical"/>
|
||||
|
||||
<Button
|
||||
<net.osmand.plus.widgets.ButtonEx
|
||||
android:id="@+id/addOpeningHoursButton"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_below="@id/openHoursContainer"
|
||||
android:layout_marginLeft="72dp"
|
||||
android:text="Add opening hours"/>
|
||||
android:text="Add opening hours"
|
||||
android:textSize="12sp"
|
||||
osmand:typeface="@string/font_roboto_medium"/>
|
||||
|
||||
<!--XXX due to bug in NestedScroolView-->
|
||||
<Space
|
||||
|
|
|
@ -14,7 +14,9 @@
|
|||
<android.support.design.widget.TextInputLayout
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="1">
|
||||
android:layout_weight="1"
|
||||
android:layout_marginLeft="16dp"
|
||||
android:layout_marginRight="16dp">
|
||||
|
||||
<EditText
|
||||
android:id="@+id/tagEditText"
|
||||
|
|
|
@ -123,16 +123,6 @@
|
|||
<item name="android:textColorSecondary">@color/divider_color</item>
|
||||
</style>
|
||||
|
||||
<style name="OsmandLightDialogTheme" parent="Theme.AppCompat.Light.Dialog.Alert">
|
||||
<item name="colorAccent">@color/osmand_orange</item>
|
||||
<item name="buttonBarButtonStyle">@style/DialogButtonLight</item>
|
||||
</style>
|
||||
|
||||
<style name="DialogButtonLight" parent="Base.Widget.AppCompat.Button.Borderless">
|
||||
<item name="android:textColor">@color/color_dialog_buttons</item>
|
||||
<item name="android:textColorPrimary">@color/color_black</item>
|
||||
</style>
|
||||
|
||||
<style name="OsmandDarkTheme" parent="Theme.AppCompat">
|
||||
<item name="list_divider">@color/list_divider_light</item>
|
||||
<item name="expandable_category_color">?android:attr/colorBackground</item>
|
||||
|
|
|
@ -34,6 +34,8 @@ public class DashFavoritesFragment extends DashLocationFragment {
|
|||
public static final String TAG = "DASH_FAVORITES_FRAGMENT";
|
||||
List<FavouritePoint> points = new ArrayList<FavouritePoint>();
|
||||
|
||||
public static final String ROW_NUMBER_TAG = TAG + "_row_number";
|
||||
|
||||
@Override
|
||||
public View initView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
|
||||
View view = getActivity().getLayoutInflater().inflate(R.layout.dash_common_fragment, container, false);
|
||||
|
@ -78,9 +80,11 @@ public class DashFavoritesFragment extends DashLocationFragment {
|
|||
}
|
||||
LinearLayout favorites = (LinearLayout) mainView.findViewById(R.id.items);
|
||||
favorites.removeAllViews();
|
||||
if (points.size() > 3) {
|
||||
while (points.size() != 3) {
|
||||
points.remove(3);
|
||||
int numberOfRows =
|
||||
getMyApplication().getSettings().registerIntPreference(ROW_NUMBER_TAG, 3).get();
|
||||
if (points.size() > numberOfRows) {
|
||||
while (points.size() != numberOfRows) {
|
||||
points.remove(numberOfRows);
|
||||
}
|
||||
}
|
||||
List<DashLocationView> distances = new ArrayList<DashLocationFragment.DashLocationView>();
|
||||
|
@ -134,6 +138,4 @@ public class DashFavoritesFragment extends DashLocationFragment {
|
|||
}
|
||||
this.distances = distances;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -11,7 +11,6 @@ import android.support.v7.widget.Toolbar;
|
|||
import android.util.Log;
|
||||
import android.view.Gravity;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.view.animation.Animation;
|
||||
import android.view.animation.Animation.AnimationListener;
|
||||
import android.view.animation.TranslateAnimation;
|
||||
|
@ -95,7 +94,7 @@ public class DashboardOnMap implements ObservableScrollViewCallbacks {
|
|||
new DashFragmentData(DashRecentsFragment.TAG, DashRecentsFragment.class,
|
||||
"Recent places", 8),
|
||||
new DashFragmentData(DashFavoritesFragment.TAG, DashFavoritesFragment.class,
|
||||
"Favourites", 9),
|
||||
"Favourites", defaultShouldShow, false, 9, DashFavoritesFragment.ROW_NUMBER_TAG),
|
||||
new DashFragmentData(DashPluginsFragment.TAG, DashPluginsFragment.class,
|
||||
"Plugins", 14)
|
||||
};
|
||||
|
|
|
@ -14,26 +14,35 @@ public final class DashFragmentData implements Comparable<DashFragmentData> {
|
|||
public final ShouldShowFunction shouldShowFunction;
|
||||
public final boolean customDeletionLogic;
|
||||
public final int position;
|
||||
public final String rowNumberTag;
|
||||
|
||||
public DashFragmentData(String tag, Class<? extends DashBaseFragment> fragmentClass,
|
||||
String title, ShouldShowFunction shouldShowFunction,
|
||||
boolean customDeletionLogic, int position) {
|
||||
boolean customDeletionLogic, int position, String rowNumberTag) {
|
||||
this.tag = tag;
|
||||
this.fragmentClass = fragmentClass;
|
||||
this.title = title;
|
||||
this.shouldShowFunction = shouldShowFunction;
|
||||
this.customDeletionLogic = customDeletionLogic;
|
||||
this.position = position;
|
||||
this.rowNumberTag = rowNumberTag;
|
||||
}
|
||||
|
||||
public DashFragmentData(String tag, Class<? extends DashBaseFragment> fragmentClass,
|
||||
String title, ShouldShowFunction shouldShowFunction,
|
||||
boolean customDeletionLogic, int position) {
|
||||
this(tag, fragmentClass, title, shouldShowFunction, customDeletionLogic, position, null);
|
||||
}
|
||||
|
||||
public DashFragmentData(String tag, Class<? extends DashBaseFragment> fragmentClass,
|
||||
String title, ShouldShowFunction shouldShowFunction, int position) {
|
||||
this(tag, fragmentClass, title, shouldShowFunction, false, position);
|
||||
this(tag, fragmentClass, title, shouldShowFunction, false, position, null);
|
||||
}
|
||||
|
||||
public DashFragmentData(String tag, Class<? extends DashBaseFragment> fragmentClass,
|
||||
String title, int position) {
|
||||
this(tag, fragmentClass, title, new DashboardOnMap.DefaultShouldShow(), false, position);
|
||||
this(tag, fragmentClass, title, new DashboardOnMap.DefaultShouldShow(), false, position,
|
||||
null);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -12,6 +12,7 @@ import android.view.LayoutInflater;
|
|||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.ArrayAdapter;
|
||||
import android.widget.Button;
|
||||
import android.widget.CompoundButton;
|
||||
import android.widget.ListView;
|
||||
import android.widget.TextView;
|
||||
|
@ -69,7 +70,8 @@ public class DashboardSettingsDialogFragment extends DialogFragment {
|
|||
AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());
|
||||
if (savedInstanceState != null && savedInstanceState.containsKey(CHECKED_ITEMS)) {
|
||||
mAdapter = new DashFragmentAdapter(getActivity(), mFragmentsData,
|
||||
savedInstanceState.getBooleanArray(CHECKED_ITEMS));
|
||||
savedInstanceState.getBooleanArray(CHECKED_ITEMS),
|
||||
new int[mFragmentsData.size()]);
|
||||
} else {
|
||||
mAdapter = new DashFragmentAdapter(getActivity(), mFragmentsData,
|
||||
settings);
|
||||
|
@ -87,7 +89,6 @@ public class DashboardSettingsDialogFragment extends DialogFragment {
|
|||
}
|
||||
mapActivity.getDashboard().refreshDashboardFragments();
|
||||
shouldShowDashboardOnStart.set(compoundButton.isChecked());
|
||||
// TODO save as preference
|
||||
}
|
||||
})
|
||||
.setNegativeButton(R.string.shared_string_cancel, null);
|
||||
|
@ -106,16 +107,19 @@ public class DashboardSettingsDialogFragment extends DialogFragment {
|
|||
|
||||
private static class DashFragmentAdapter extends ArrayAdapter<DashFragmentData> {
|
||||
private final boolean[] checkedItems;
|
||||
private final int[] numbersOfRows;
|
||||
|
||||
public DashFragmentAdapter(Context context, List<DashFragmentData> objects,
|
||||
boolean[] checkedItems) {
|
||||
boolean[] checkedItems, int[] numbersOfRows) {
|
||||
super(context, 0, objects);
|
||||
this.checkedItems = checkedItems;
|
||||
this.numbersOfRows = numbersOfRows;
|
||||
}
|
||||
|
||||
public DashFragmentAdapter(Context context, List<DashFragmentData> objects,
|
||||
OsmandSettings settings) {
|
||||
super(context, 0, objects);
|
||||
numbersOfRows = new int[objects.size()];
|
||||
checkedItems = new boolean[objects.size()];
|
||||
for (int i = 0; i < objects.size(); i++) {
|
||||
checkedItems[i] = settings.registerBooleanPreference(
|
||||
|
@ -123,14 +127,34 @@ public class DashboardSettingsDialogFragment extends DialogFragment {
|
|||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getViewTypeCount() {
|
||||
return 2;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getItemViewType(int position) {
|
||||
return getItem(position).rowNumberTag == null ? 0 : 1;
|
||||
}
|
||||
|
||||
@Override
|
||||
public View getView(final int position, View convertView, ViewGroup parent) {
|
||||
DashFragmentData dashFragmentData = getItem(position);
|
||||
DashViewHolder viewHolder;
|
||||
boolean hasRows = getItemViewType(position) == 1;
|
||||
if (convertView == null) {
|
||||
viewHolder = new DashViewHolder();
|
||||
convertView = LayoutInflater.from(getContext()).inflate(
|
||||
R.layout.dashboard_settings_dialog_item, parent, false);
|
||||
if (hasRows) {
|
||||
convertView = LayoutInflater.from(getContext()).inflate(
|
||||
R.layout.dashboard_settings_dialog_item_1, parent, false);
|
||||
|
||||
viewHolder.numberOfRowsTextView = (TextView) convertView.findViewById(R.id.numberOfRowsTextView);
|
||||
viewHolder.decrementButton = (Button) convertView.findViewById(R.id.decrementButton);
|
||||
viewHolder.incrementButton = (Button) convertView.findViewById(R.id.incrementButton);
|
||||
} else {
|
||||
convertView = LayoutInflater.from(getContext()).inflate(
|
||||
R.layout.dashboard_settings_dialog_item, parent, false);
|
||||
}
|
||||
viewHolder.textView = (TextView) convertView.findViewById(R.id.text);
|
||||
viewHolder.compoundButton = (CompoundButton) convertView.findViewById(R.id.check_item);
|
||||
viewHolder.compoundButton.setOnCheckedChangeListener(
|
||||
|
@ -164,6 +188,9 @@ public class DashboardSettingsDialogFragment extends DialogFragment {
|
|||
TextView textView;
|
||||
CompoundButton compoundButton;
|
||||
int position;
|
||||
TextView numberOfRowsTextView;
|
||||
Button decrementButton;
|
||||
Button incrementButton;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -33,9 +33,9 @@ import org.apache.commons.logging.Log;
|
|||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
public class NormalDataFragment extends Fragment {
|
||||
private static final String TAG = "NormalDataFragment";
|
||||
private static final Log LOG = PlatformUtil.getLog(NormalDataFragment.class);
|
||||
public class BasicDataFragment extends Fragment {
|
||||
private static final String TAG = "BasicDataFragment";
|
||||
private static final Log LOG = PlatformUtil.getLog(BasicDataFragment.class);
|
||||
private static final String OPENING_HOURS = "opening_hours";
|
||||
private EditText streetEditText;
|
||||
private EditText houseNumberEditText;
|
|
@ -460,7 +460,7 @@ public class EditPoiFragment extends Fragment {
|
|||
public Fragment getItem(int position) {
|
||||
switch (position) {
|
||||
case 0:
|
||||
return new NormalDataFragment();
|
||||
return new BasicDataFragment();
|
||||
case 1:
|
||||
return new AdvancedDataFragment();
|
||||
}
|
||||
|
|
|
@ -28,8 +28,7 @@ public class OpeningHoursDaysDialogFragment extends DialogFragment {
|
|||
(OpeningHoursParser.BasicOpeningHourRule) getArguments().getSerializable(ITEM);
|
||||
final int positionToAdd = getArguments().getInt(POSITION_TO_ADD);
|
||||
|
||||
AlertDialog.Builder builder = new AlertDialog.Builder(getActivity(),
|
||||
R.style.OsmandLightDialogTheme);
|
||||
AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());
|
||||
|
||||
boolean add = positionToAdd > -1;
|
||||
Calendar inst = Calendar.getInstance();
|
||||
|
@ -85,6 +84,7 @@ public class OpeningHoursDaysDialogFragment extends DialogFragment {
|
|||
|
||||
public static OpeningHoursDaysDialogFragment createInstance(final OpeningHoursParser.BasicOpeningHourRule item,
|
||||
final int positionToAdd) {
|
||||
LOG.debug("createInstance(" + "item=" + item + ", positionToAdd=" + positionToAdd + ")");
|
||||
OpeningHoursDaysDialogFragment daysDialogFragment = new OpeningHoursDaysDialogFragment();
|
||||
Bundle bundle = new Bundle();
|
||||
bundle.putSerializable(ITEM, item);
|
||||
|
|
|
@ -1,21 +1,20 @@
|
|||
package net.osmand.plus.osmedit.dialogs;
|
||||
|
||||
import android.app.Dialog;
|
||||
import android.app.TimePickerDialog;
|
||||
import android.graphics.Color;
|
||||
import android.content.DialogInterface;
|
||||
import android.graphics.Typeface;
|
||||
import android.os.Bundle;
|
||||
import android.support.annotation.NonNull;
|
||||
import android.support.v4.app.DialogFragment;
|
||||
import android.support.v7.app.AlertDialog;
|
||||
import android.text.format.DateFormat;
|
||||
import android.util.TypedValue;
|
||||
import android.view.Gravity;
|
||||
import android.view.View;
|
||||
import android.widget.TextView;
|
||||
import android.widget.TimePicker;
|
||||
|
||||
import net.osmand.plus.R;
|
||||
import net.osmand.plus.osmedit.NormalDataFragment;
|
||||
import net.osmand.plus.osmedit.BasicDataFragment;
|
||||
import net.osmand.util.OpeningHoursParser;
|
||||
|
||||
import java.util.Calendar;
|
||||
|
@ -32,32 +31,39 @@ public class OpeningHoursHoursDialogFragment extends DialogFragment {
|
|||
final boolean isStart = args.getBoolean(IS_START);
|
||||
final OpeningHoursParser.BasicOpeningHourRule item = (OpeningHoursParser.BasicOpeningHourRule)
|
||||
args.getSerializable(BASIC_OPENING_HOUR_RULE);
|
||||
TimePickerDialog.OnTimeSetListener callback = new TimePickerDialog.OnTimeSetListener() {
|
||||
@Override
|
||||
public void onTimeSet(TimePicker view, int hourOfDay, int minute) {
|
||||
int time = minute + hourOfDay * 60;
|
||||
if (isStart) {
|
||||
item.setStartTime(time);
|
||||
OpeningHoursHoursDialogFragment.createInstance(item, null, false)
|
||||
.show(getFragmentManager(), "TimePickerDialogFragment");
|
||||
} else {
|
||||
item.setEndTime(time);
|
||||
((NormalDataFragment) getParentFragment()).addBasicOpeningHoursRule(item);
|
||||
}
|
||||
}
|
||||
};
|
||||
AlertDialog.Builder builder =
|
||||
new AlertDialog.Builder(getActivity());
|
||||
|
||||
Calendar initialState = (Calendar) args.getSerializable(INITIAL_TIME);
|
||||
if (initialState == null) {
|
||||
initialState = Calendar.getInstance();
|
||||
initialState.set(Calendar.HOUR_OF_DAY, isStart? 8 : 20);
|
||||
initialState.set(Calendar.MINUTE, 0);
|
||||
}
|
||||
TimePickerDialog timePickerDialog = new TimePickerDialog(getActivity(),
|
||||
R.style.OsmandLightDialogTheme,
|
||||
callback,
|
||||
initialState.get(Calendar.HOUR_OF_DAY),
|
||||
initialState.get(Calendar.MINUTE),
|
||||
DateFormat.is24HourFormat(getActivity()));
|
||||
|
||||
final TimePicker timePicker = new TimePicker(getActivity());
|
||||
timePicker.setIs24HourView(DateFormat.is24HourFormat(getActivity()));
|
||||
timePicker.setCurrentHour(initialState.get(Calendar.HOUR_OF_DAY));
|
||||
timePicker.setCurrentMinute(initialState.get(Calendar.MINUTE));
|
||||
|
||||
builder.setView(timePicker)
|
||||
.setPositiveButton(R.string.next_proceed, new DialogInterface.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(DialogInterface dialog, int which) {
|
||||
int minute = timePicker.getCurrentMinute();
|
||||
int hourOfDay = timePicker.getCurrentHour();
|
||||
int time = minute + hourOfDay * 60;
|
||||
if (isStart) {
|
||||
item.setStartTime(time);
|
||||
OpeningHoursHoursDialogFragment.createInstance(item, null, false)
|
||||
.show(getFragmentManager(), "TimePickerDialogFragment");
|
||||
} else {
|
||||
item.setEndTime(time);
|
||||
((BasicDataFragment) getParentFragment()).addBasicOpeningHoursRule(item);
|
||||
}
|
||||
}
|
||||
})
|
||||
.setNegativeButton(R.string.shared_string_cancel, null);
|
||||
|
||||
int paddingInDp = 18;
|
||||
float density = getActivity().getResources().getDisplayMetrics().density;
|
||||
|
@ -72,8 +78,8 @@ public class OpeningHoursHoursDialogFragment extends DialogFragment {
|
|||
titleTextView.setTextColor(getActivity().getResources().getColor(R.color.color_black));
|
||||
Typeface typeface = titleTextView.getTypeface();
|
||||
titleTextView.setTypeface(typeface, Typeface.BOLD);
|
||||
timePickerDialog.setCustomTitle(titleTextView);
|
||||
return timePickerDialog;
|
||||
builder.setCustomTitle(titleTextView);
|
||||
return builder.create();
|
||||
}
|
||||
|
||||
public static OpeningHoursHoursDialogFragment createInstance(OpeningHoursParser.BasicOpeningHourRule item,
|
||||
|
|
Loading…
Reference in a new issue