use of net.osmand.plus.widgets.FlowLayout in project Osmand by osmandapp.
the class PublicTransportCard method createRouteBadges.
private void createRouteBadges(List<TransportRouteResultSegment> segments, boolean badgesRowClickable) {
int itemsSpacing = AndroidUtils.dpToPx(app, 6);
FlowLayout routesBadges = (FlowLayout) view.findViewById(R.id.routes_badges);
routesBadges.removeAllViews();
TransportRoutingHelper transportRoutingHelper = app.getTransportRoutingHelper();
Iterator<TransportRouteResultSegment> iterator = segments.iterator();
TransportRouteResultSegment prevSegment = null;
while (iterator.hasNext()) {
TransportRouteResultSegment s = iterator.next();
RouteCalculationResult walkingSegment = transportRoutingHelper.getWalkingRouteSegment(prevSegment, s);
if (walkingSegment != null) {
double walkTime = walkingSegment.getRoutingTime();
if (walkTime > MIN_WALK_TIME) {
routesBadges.addView(createWalkRouteBadge(walkingSegment, badgesRowClickable), new FlowLayout.LayoutParams(itemsSpacing, itemsSpacing));
routesBadges.addView(createArrow(), new FlowLayout.LayoutParams(itemsSpacing, itemsSpacing));
}
} else if (s.walkDist > 0) {
double walkTime = getWalkTime(s.walkDist, routeResult.getWalkSpeed());
if (walkTime > MIN_WALK_TIME) {
LatLon start;
LatLon end = s.getStart().getLocation();
if (prevSegment != null) {
start = prevSegment.getEnd().getLocation();
} else {
start = this.startLocation;
}
routesBadges.addView(createWalkRouteBadge(walkTime, start, end, badgesRowClickable), new FlowLayout.LayoutParams(itemsSpacing, itemsSpacing));
routesBadges.addView(createArrow(), new FlowLayout.LayoutParams(itemsSpacing, itemsSpacing));
}
}
routesBadges.addView(createRouteBadge(s, badgesRowClickable), new FlowLayout.LayoutParams(itemsSpacing, itemsSpacing));
if (iterator.hasNext()) {
routesBadges.addView(createArrow(), new FlowLayout.LayoutParams(itemsSpacing, itemsSpacing));
} else {
walkingSegment = transportRoutingHelper.getWalkingRouteSegment(s, null);
if (walkingSegment != null) {
double walkTime = walkingSegment.getRoutingTime();
if (walkTime > MIN_WALK_TIME) {
routesBadges.addView(createArrow(), new FlowLayout.LayoutParams(itemsSpacing, itemsSpacing));
routesBadges.addView(createWalkRouteBadge(walkingSegment, badgesRowClickable), new FlowLayout.LayoutParams(itemsSpacing, itemsSpacing));
}
} else {
double finishWalkDist = routeResult.getFinishWalkDist();
if (finishWalkDist > 0) {
double walkTime = getWalkTime(finishWalkDist, routeResult.getWalkSpeed());
if (walkTime > MIN_WALK_TIME) {
LatLon start = s.getEnd().getLocation();
LatLon end = this.endLocation;
routesBadges.addView(createArrow(), new FlowLayout.LayoutParams(itemsSpacing, itemsSpacing));
routesBadges.addView(createWalkRouteBadge(walkTime, start, end, badgesRowClickable));
}
}
}
}
prevSegment = s;
}
}
use of net.osmand.plus.widgets.FlowLayout in project Osmand by osmandapp.
the class ShapesCard method updateContent.
@Override
protected void updateContent() {
FlowLayout flowLayout = ((FlowLayout) view);
flowLayout.setHorizontalAutoSpacing(true);
LayoutInflater inflater = UiUtilities.getInflater(view.getContext(), nightMode);
int width = getDimen(R.dimen.favorites_select_icon_button_right_padding);
for (BackgroundType shape : BackgroundType.values()) {
if (shape.isSelected()) {
FlowLayout.LayoutParams layoutParams = new FlowLayout.LayoutParams(width, 0);
flowLayout.addView(createShapeItemView(inflater, shape), layoutParams);
}
}
}
use of net.osmand.plus.widgets.FlowLayout in project Osmand by osmandapp.
the class ProfileAppearanceFragment method createColorsCard.
private void createColorsCard(PreferenceViewHolder holder) {
MapActivity mapActivity = getMapActivity();
if (mapActivity == null) {
return;
}
FlowLayout colorsCardContainer = (FlowLayout) holder.findViewById(R.id.color_items);
colorsCardContainer.removeAllViews();
int selectedColor = changedProfile.getActualColor();
List<Integer> colors = new ArrayList<>();
for (ProfileIconColors color : ProfileIconColors.values()) {
colors.add(ContextCompat.getColor(app, color.getColor(isNightMode())));
}
colorsCard = new ColorsCard(mapActivity, getSelectedAppMode(), this, selectedColor, colors, app.getSettings().CUSTOM_ICON_COLORS, false);
colorsCard.setListener(this);
colorsCardContainer.addView(colorsCard.build(app));
updateColorName();
}
use of net.osmand.plus.widgets.FlowLayout in project Osmand by osmandapp.
the class ProfileAppearanceFragment method onBindPreferenceViewHolder.
@Override
protected void onBindPreferenceViewHolder(Preference preference, PreferenceViewHolder holder) {
super.onBindPreferenceViewHolder(preference, holder);
if (PROFILE_NAME.equals(preference.getKey())) {
profileName = (EditText) holder.findViewById(R.id.profile_name_et);
profileName.setImeOptions(EditorInfo.IME_ACTION_DONE);
profileName.setRawInputType(InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_FLAG_CAP_SENTENCES);
profileName.setText(changedProfile.name);
profileName.addTextChangedListener(new TextWatcher() {
@Override
public void beforeTextChanged(CharSequence s, int start, int count, int after) {
}
@Override
public void onTextChanged(CharSequence s, int start, int before, int count) {
}
@Override
public void afterTextChanged(Editable s) {
changedProfile.name = s.toString();
if (nameIsEmpty()) {
disableSaveButtonWithErrorMessage(app.getString(R.string.please_provide_profile_name_message));
} else if (hasNameDuplicate()) {
disableSaveButtonWithErrorMessage(app.getString(R.string.profile_alert_duplicate_name_msg));
} else {
saveButton.setEnabled(true);
}
}
});
profileName.setOnFocusChangeListener(new View.OnFocusChangeListener() {
@Override
public void onFocusChange(View v, boolean hasFocus) {
if (hasFocus) {
profileName.setSelection(profileName.getText().length());
AndroidUtils.showSoftKeyboard(getMyActivity(), profileName);
}
}
});
if (getSelectedAppMode().equals(ApplicationMode.DEFAULT) && !isNewProfile) {
profileName.setFocusableInTouchMode(false);
profileName.setFocusable(false);
}
profileNameOtfb = (OsmandTextFieldBoxes) holder.findViewById(R.id.profile_name_otfb);
updateProfileNameAppearance();
} else if (MASTER_PROFILE.equals(preference.getKey())) {
baseProfileName = (EditText) holder.findViewById(R.id.master_profile_et);
baseProfileName.setFocusable(false);
baseProfileName.setText(changedProfile.parent != null ? changedProfile.parent.toHumanString() : getSelectedAppMode().toHumanString());
OsmandTextFieldBoxes baseProfileNameHint = (OsmandTextFieldBoxes) holder.findViewById(R.id.master_profile_otfb);
baseProfileNameHint.setLabelText(getString(R.string.profile_type_osmand_string));
FrameLayout selectNavTypeBtn = (FrameLayout) holder.findViewById(R.id.select_nav_type_btn);
selectNavTypeBtn.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
if (isNewProfile) {
hideKeyboard();
if (getActivity() != null) {
String selected = changedProfile.parent != null ? changedProfile.parent.getStringKey() : null;
SelectBaseProfileBottomSheet.showInstance(getActivity(), ProfileAppearanceFragment.this, getSelectedAppMode(), selected, false);
}
}
}
});
} else if (SELECT_COLOR.equals(preference.getKey())) {
colorName = holder.itemView.findViewById(R.id.summary);
colorName.setTextColor(ContextCompat.getColor(app, R.color.preference_category_title));
} else if (COLOR_ITEMS.equals(preference.getKey())) {
createColorsCard(holder);
} else if (ICON_ITEMS.equals(preference.getKey())) {
iconItems = (FlowLayout) holder.findViewById(R.id.color_items);
iconItems.removeAllViews();
ArrayList<Integer> icons = ProfileIcons.getIcons();
for (int iconRes : icons) {
View iconItem = createIconItemView(iconRes, iconItems);
int minimalPaddingBetweenIcon = app.getResources().getDimensionPixelSize(R.dimen.favorites_select_icon_button_right_padding);
iconItems.addView(iconItem, new FlowLayout.LayoutParams(minimalPaddingBetweenIcon, 0));
iconItems.setHorizontalAutoSpacing(true);
}
setIconColor(changedProfile.iconRes);
} else if (LOCATION_ICON_ITEMS.equals(preference.getKey())) {
locationIconItems = (FlowLayout) holder.findViewById(R.id.color_items);
locationIconItems.removeAllViews();
for (LocationIcon locationIcon : LocationIcon.values()) {
View iconItemView = createLocationIconView(locationIcon, locationIconItems);
locationIconItems.addView(iconItemView, new FlowLayout.LayoutParams(0, 0));
}
updateLocationIconSelector(changedProfile.locationIcon);
} else if (NAV_ICON_ITEMS.equals(preference.getKey())) {
navIconItems = (FlowLayout) holder.findViewById(R.id.color_items);
navIconItems.removeAllViews();
for (NavigationIcon navigationIcon : NavigationIcon.values()) {
View iconItemView = createNavigationIconView(navigationIcon, navIconItems);
navIconItems.addView(iconItemView, new FlowLayout.LayoutParams(0, 0));
}
updateNavigationIconSelector(changedProfile.navigationIcon);
}
}
use of net.osmand.plus.widgets.FlowLayout in project Osmand by osmandapp.
the class ColorsCard method createColorSelector.
private void createColorSelector() {
FlowLayout selectCustomColor = view.findViewById(R.id.select_custom_color);
selectCustomColor.removeAllViews();
selectCustomColor.setHorizontalAutoSpacing(true);
int minimalPaddingBetweenIcon = getDimen(R.dimen.favorites_select_icon_button_right_padding);
for (int color : customColors) {
selectCustomColor.addView(createColorItemView(color, selectCustomColor, true), new LayoutParams(minimalPaddingBetweenIcon, 0));
}
if (customColors.size() < 6) {
selectCustomColor.addView(createAddCustomColorItemView(selectCustomColor), new LayoutParams(minimalPaddingBetweenIcon, 0));
}
FlowLayout selectDefaultColor = view.findViewById(R.id.select_default_color);
selectDefaultColor.removeAllViews();
selectDefaultColor.setHorizontalAutoSpacing(true);
for (int color : colors) {
selectDefaultColor.addView(createColorItemView(color, selectDefaultColor, false), new LayoutParams(minimalPaddingBetweenIcon, 0));
}
updateColorSelector(selectedColor);
}
Aggregations