use of net.osmand.plus.utils.UiUtilities in project Osmand by osmandapp.
the class DashWaypointsFragment method selectTargetModel.
private void selectTargetModel(final TargetPoint point, final View view) {
final OsmandApplication app = getMyApplication();
if (app == null) {
return;
}
final UiUtilities iconsCache = app.getUIUtilities();
final PopupMenu optionsMenu = new PopupMenu(requireActivity(), view);
DirectionsDialogs.setupPopUpMenuIcon(optionsMenu);
MenuItem item;
final boolean target = point == app.getTargetPointsHelper().getPointToNavigate();
if (SHOW_ALL && app.getTargetPointsHelper().getIntermediatePoints().size() > 0) {
final List<TargetPoint> allTargets = app.getTargetPointsHelper().getIntermediatePointsWithTarget();
if (point.index > 0 || target) {
final int ind = target ? allTargets.size() - 1 : point.index;
item = optionsMenu.getMenu().add(R.string.waypoint_visit_before).setIcon(iconsCache.getThemedIcon(R.drawable.ic_action_up_dark));
item.setOnMenuItemClickListener(menuItem -> {
TargetPoint remove = allTargets.remove(ind - 1);
allTargets.add(ind, remove);
app.getTargetPointsHelper().reorderAllTargetPoints(allTargets, true);
setupView();
return true;
});
}
if (!target) {
item = optionsMenu.getMenu().add(R.string.waypoint_visit_after).setIcon(iconsCache.getThemedIcon(R.drawable.ic_action_down_dark));
item.setOnMenuItemClickListener(menuItem -> {
TargetPoint remove = allTargets.remove(point.index + 1);
allTargets.add(point.index, remove);
app.getTargetPointsHelper().reorderAllTargetPoints(allTargets, true);
setupView();
return true;
});
}
}
item = optionsMenu.getMenu().add(R.string.shared_string_remove).setIcon(iconsCache.getThemedIcon(R.drawable.ic_action_remove_dark));
item.setOnMenuItemClickListener(menuItem -> {
deletePointConfirm(point, view);
return true;
});
optionsMenu.show();
}
use of net.osmand.plus.utils.UiUtilities in project Osmand by osmandapp.
the class NoImagesCard method update.
@Override
public void update() {
if (view != null) {
UiUtilities ic = getMyApplication().getUIUtilities();
boolean night = getMyApplication().getDaynightHelper().isNightModeForMapControls();
MapActivity ctx = getMapActivity();
AndroidUtils.setBackgroundColor(ctx, view, ColorUtilities.getListBgColorId(night));
((ImageView) view.findViewById(R.id.icon_sadface)).setImageDrawable(ic.getIcon(R.drawable.ic_action_sadface, night ? R.color.color_white : R.color.icon_color_default_light));
AndroidUtils.setTextPrimaryColor(ctx, (TextView) view.findViewById(R.id.title), night);
AndroidUtils.setBackgroundColor(ctx, view.findViewById(R.id.button_background), night, R.color.inactive_buttons_and_links_bg_light, R.color.inactive_buttons_and_links_bg_dark);
((ImageView) view.findViewById(R.id.icon_add_photos)).setImageDrawable(ic.getIcon(R.drawable.ic_action_add_photos, ColorUtilities.getActiveColorId(night)));
((TextView) view.findViewById(R.id.app_photos_text_view)).setTextColor(ColorUtilities.getActiveColor(ctx, night));
AndroidUtils.setBackground(ctx, view.findViewById(R.id.card_background), night, R.drawable.context_menu_card_light, R.drawable.context_menu_card_dark);
view.findViewById(R.id.button).setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
MapillaryPlugin.openMapillary(getMapActivity(), null);
}
});
}
}
use of net.osmand.plus.utils.UiUtilities in project Osmand by osmandapp.
the class DirectionDrawable method setColorId.
public void setColorId(int clrId) {
// R.color.color_ok, R.color.color_unknown, R.color.color_warning
if (arrowImage != null) {
UiUtilities iconsCache = app.getUIUtilities();
arrowImage = iconsCache.getIcon(resourceId, clrId);
} else {
paintRouteDirection.setColor(app.getResources().getColor(clrId));
}
}
use of net.osmand.plus.utils.UiUtilities in project Osmand by osmandapp.
the class DirectionDrawable method setImage.
public void setImage(int resourceId, int clrId) {
UiUtilities iconsCache = app.getUIUtilities();
arrowImage = iconsCache.getIcon(resourceId, clrId);
this.resourceId = resourceId;
onBoundsChange(getBounds());
}
use of net.osmand.plus.utils.UiUtilities in project Osmand by osmandapp.
the class QuickSearchCoordinatesFragment method onCreateView.
@Override
@SuppressLint("PrivateResource")
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
final OsmandApplication app = getMyApplication();
view = inflater.inflate(R.layout.search_advanced_coords, container, false);
Toolbar toolbar = (Toolbar) view.findViewById(R.id.toolbar);
int color = ColorUtilities.getActiveButtonsAndLinksTextColorId(!isLightTheme);
Drawable icBack = app.getUIUtilities().getIcon(AndroidUtils.getNavigationIconResId(app), color);
toolbar.setNavigationIcon(icBack);
toolbar.setNavigationContentDescription(R.string.access_shared_string_navigate_up);
toolbar.setNavigationOnClickListener(v -> dismiss());
toolbar.setBackgroundColor(ColorUtilities.getAppBarColor(app, !isLightTheme));
toolbar.setTitleTextColor(ContextCompat.getColor(app, isLightTheme ? R.color.color_white : R.color.text_color_primary_dark));
updateLocationViewCache = app.getUIUtilities().getUpdateLocationViewCache();
myLocation = app.getLocationProvider().getLastKnownLocation();
currentFormat = app.getSettings().COORDINATES_FORMAT.get();
latEdit = ((EditText) view.findViewById(R.id.latitudeEditText));
lonEdit = ((EditText) view.findViewById(R.id.longitudeEditText));
northingEdit = ((EditText) view.findViewById(R.id.northingEditText));
eastingEdit = ((EditText) view.findViewById(R.id.eastingEditText));
zoneEdit = ((EditText) view.findViewById(R.id.zoneEditText));
mgrsEdit = ((EditText) view.findViewById(R.id.mgrsEditText));
olcEdit = ((EditText) view.findViewById(R.id.olcEditText));
olcInfo = ((TextView) view.findViewById(R.id.olcInfoTextView));
swissGridEastEdit = ((EditText) view.findViewById(R.id.swissGridEastEditText));
swissGridNorthEdit = ((EditText) view.findViewById(R.id.swissGridNorthEditText));
formatEdit = ((EditText) view.findViewById(R.id.formatEditText));
searchProgressBar = ((ProgressBar) view.findViewById(R.id.searchProgressBar));
String defaultLat = "";
String defaultZone = "";
String defaultMgrs = "";
String defaultOlc = "";
String defaultSwissGridEast = "";
String defaultSwissGridNorth = "";
boolean coordinatesApplied = false;
if (getArguments() != null) {
String text = getArguments().getString(QUICK_SEARCH_COORDS_TEXT_KEY);
if (!Algorithms.isEmpty(text)) {
if (currentFormat == PointDescription.UTM_FORMAT) {
defaultZone = text.trim();
} else if (currentFormat == PointDescription.MGRS_FORMAT) {
defaultMgrs = text.trim();
} else if (currentFormat == PointDescription.OLC_FORMAT) {
defaultOlc = text.trim();
} else if (currentFormat == PointDescription.SWISS_GRID_FORMAT || currentFormat == PointDescription.SWISS_GRID_PLUS_FORMAT) {
defaultSwissGridEast = text.trim();
} else {
defaultLat = text.trim();
}
} else {
double latitude = getArguments().getDouble(QUICK_SEARCH_COORDS_LATITUDE_KEY, Double.NaN);
double longitude = getArguments().getDouble(QUICK_SEARCH_COORDS_LONGITUDE_KEY, Double.NaN);
if (!Double.isNaN(latitude) && !Double.isNaN(longitude)) {
currentLatLon = new LatLon(latitude, longitude);
applyFormat(currentFormat, true);
coordinatesApplied = true;
}
}
}
String latStr = getStringValue(savedInstanceState, QUICK_SEARCH_COORDS_LAT_KEY, defaultLat);
String lonStr = getStringValue(savedInstanceState, QUICK_SEARCH_COORDS_LON_KEY, "");
String northingStr = getStringValue(savedInstanceState, QUICK_SEARCH_COORDS_NORTH_KEY, "");
String eastingStr = getStringValue(savedInstanceState, QUICK_SEARCH_COORDS_EAST_KEY, "");
String zoneStr = getStringValue(savedInstanceState, QUICK_SEARCH_COORDS_ZONE_KEY, defaultZone);
String mgrsStr = getStringValue(savedInstanceState, QUICK_SEARCH_COORDS_MGRS_KEY, defaultMgrs);
String olcStr = getStringValue(savedInstanceState, QUICK_SEARCH_COORDS_OLC_KEY, defaultOlc);
String olcInfoStr = getStringValue(savedInstanceState, QUICK_SEARCH_COORDS_OLC_INFO_KEY, defaultOlc);
String swissGridEastStr = getStringValue(savedInstanceState, QUICK_SEARCH_COORDS_SWISS_GRID_EAST_KEY, defaultSwissGridEast);
String swissGridNorthStr = getStringValue(savedInstanceState, QUICK_SEARCH_COORDS_SWISS_GRID_NORTH_KEY, defaultSwissGridNorth);
if (savedInstanceState != null)
currentFormat = savedInstanceState.getInt(QUICK_SEARCH_COORDS_FORMAT_KEY, -1);
if (currentFormat == -1)
currentFormat = getArguments().getInt(QUICK_SEARCH_COORDS_FORMAT_KEY, -1);
if (currentFormat == -1)
currentFormat = app.getSettings().COORDINATES_FORMAT.get();
if (!coordinatesApplied) {
latEdit.setText(latStr);
latEdit.setSelection(latStr.length());
lonEdit.setText(lonStr);
lonEdit.setSelection(lonStr.length());
northingEdit.setText(northingStr);
northingEdit.setSelection(northingStr.length());
eastingEdit.setText(eastingStr);
eastingEdit.setSelection(eastingStr.length());
zoneEdit.setText(zoneStr);
zoneEdit.setSelection(zoneStr.length());
mgrsEdit.setText(mgrsStr);
mgrsEdit.setSelection(mgrsStr.length());
olcEdit.setText(olcStr);
olcEdit.setSelection(olcStr.length());
olcInfo.setText(olcInfoStr);
swissGridEastEdit.setText(swissGridEastStr);
swissGridEastEdit.setSelection(swissGridEastStr.length());
swissGridNorthEdit.setText(swissGridNorthStr);
swissGridNorthEdit.setSelection(swissGridNorthStr.length());
}
formatEdit.setText(PointDescription.formatToHumanString(app, currentFormat));
formatEdit.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
new ChooseCoordsFormatDialogFragment().show(getChildFragmentManager(), "ChooseCoordinatesFormatFragment");
}
});
TextWatcher textWatcher = new TextWatcher() {
@Override
public void onTextChanged(CharSequence s, int start, int before, int count) {
}
@Override
public void beforeTextChanged(CharSequence s, int start, int count, int after) {
}
@Override
public void afterTextChanged(Editable s) {
parseLocation();
}
};
latEdit.addTextChangedListener(textWatcher);
lonEdit.addTextChangedListener(textWatcher);
northingEdit.addTextChangedListener(textWatcher);
eastingEdit.addTextChangedListener(textWatcher);
zoneEdit.addTextChangedListener(textWatcher);
mgrsEdit.addTextChangedListener(textWatcher);
olcEdit.addTextChangedListener(textWatcher);
swissGridEastEdit.addTextChangedListener(textWatcher);
swissGridNorthEdit.addTextChangedListener(textWatcher);
OnEditorActionListener doneListener = (v, actionId, event) -> {
if (actionId == EditorInfo.IME_ACTION_DONE) {
if (currentLatLon != null && additionalUtmLatLon != null) {
Activity activity = getActivity();
if (activity != null) {
AndroidUtils.hideSoftKeyboard(activity, eastingEdit);
}
} else {
showOnMap(currentLatLon != null ? currentLatLon : additionalUtmLatLon);
}
return true;
} else {
return false;
}
};
lonEdit.setOnEditorActionListener(doneListener);
eastingEdit.setOnEditorActionListener(doneListener);
mgrsEdit.setOnEditorActionListener(doneListener);
olcEdit.setOnEditorActionListener(doneListener);
swissGridEastEdit.setOnEditorActionListener(doneListener);
swissGridNorthEdit.setOnEditorActionListener(doneListener);
UiUtilities ic = app.getUIUtilities();
((ImageView) view.findViewById(R.id.latitudeImage)).setImageDrawable(ic.getThemedIcon(R.drawable.ic_action_coordinates_latitude));
((ImageView) view.findViewById(R.id.longitudeImage)).setImageDrawable(ic.getThemedIcon(R.drawable.ic_action_coordinates_longitude));
((ImageView) view.findViewById(R.id.northingImage)).setImageDrawable(ic.getThemedIcon(R.drawable.ic_action_coordinates_latitude));
((ImageView) view.findViewById(R.id.eastingImage)).setImageDrawable(ic.getThemedIcon(R.drawable.ic_action_coordinates_longitude));
ImageButton latitudeClearButton = (ImageButton) view.findViewById(R.id.latitudeClearButton);
latitudeClearButton.setImageDrawable(ic.getThemedIcon(R.drawable.ic_action_remove_dark));
latitudeClearButton.setOnClickListener(v -> latEdit.setText(""));
ImageButton longitudeClearButton = (ImageButton) view.findViewById(R.id.longitudeClearButton);
longitudeClearButton.setImageDrawable(ic.getThemedIcon(R.drawable.ic_action_remove_dark));
longitudeClearButton.setOnClickListener(v -> lonEdit.setText(""));
ImageButton northingClearButton = (ImageButton) view.findViewById(R.id.northingClearButton);
northingClearButton.setImageDrawable(ic.getThemedIcon(R.drawable.ic_action_remove_dark));
northingClearButton.setOnClickListener(v -> northingEdit.setText(""));
ImageButton eastingClearButton = (ImageButton) view.findViewById(R.id.eastingClearButton);
eastingClearButton.setImageDrawable(ic.getThemedIcon(R.drawable.ic_action_remove_dark));
eastingClearButton.setOnClickListener(v -> eastingEdit.setText(""));
ImageButton zoneClearButton = (ImageButton) view.findViewById(R.id.zoneClearButton);
zoneClearButton.setImageDrawable(ic.getThemedIcon(R.drawable.ic_action_remove_dark));
zoneClearButton.setOnClickListener(v -> zoneEdit.setText(""));
ImageButton olcClearButton = (ImageButton) view.findViewById(R.id.olcClearButton);
olcClearButton.setImageDrawable(ic.getThemedIcon(R.drawable.ic_action_remove_dark));
olcClearButton.setOnClickListener(v -> olcEdit.setText(""));
ImageButton mgrsClearButton = (ImageButton) view.findViewById(R.id.mgrsClearButton);
mgrsClearButton.setImageDrawable(ic.getThemedIcon(R.drawable.ic_action_remove_dark));
mgrsClearButton.setOnClickListener(v -> mgrsEdit.setText(""));
ImageButton swissGridEastClearButton = (ImageButton) view.findViewById(R.id.swissGridEastClearButton);
swissGridEastClearButton.setImageDrawable(ic.getThemedIcon(R.drawable.ic_action_remove_dark));
swissGridEastClearButton.setOnClickListener(v -> swissGridEastEdit.setText(""));
ImageButton swissGridNorthClearButton = (ImageButton) view.findViewById(R.id.swissGridNorthClearButton);
swissGridNorthClearButton.setImageDrawable(ic.getThemedIcon(R.drawable.ic_action_remove_dark));
swissGridNorthClearButton.setOnClickListener(v -> swissGridNorthEdit.setText(""));
ImageButton formatSelectButton = (ImageButton) view.findViewById(R.id.formatSelectButton);
formatSelectButton.setImageDrawable(ic.getThemedIcon(R.drawable.ic_action_arrow_drop_down));
formatSelectButton.setOnClickListener(v -> new ChooseCoordsFormatDialogFragment().show(getChildFragmentManager(), "ChooseCoordinatesFormatFragment"));
View coordinatesViewContainer = view.findViewById(R.id.found_location);
coordsView = setupCoordinatesView(coordinatesViewContainer);
coordsView.setOnClickListener(v -> showOnMap(currentLatLon));
View additionalCoordinatesViewContainer = view.findViewById(R.id.additional_found_location);
additionalCoordsView = setupCoordinatesView(additionalCoordinatesViewContainer);
additionalCoordsView.setOnClickListener(v -> showOnMap(additionalUtmLatLon));
errorView = view.findViewById(R.id.error_item);
parseLocation();
updateControlsVisibility();
return view;
}
Aggregations