use of net.osmand.plus.utils.UiUtilities in project Osmand by osmandapp.
the class DashLocationFragment method updateAllWidgets.
public void updateAllWidgets() {
OsmandApplication app = getMyApplication();
if (app == null || dashboard == null) {
return;
}
UiUtilities ic = app.getUIUtilities();
UpdateLocationViewCache cache = ic.getUpdateLocationViewCache();
for (DashLocationView lv : distances) {
cache.arrowResId = lv.arrowResId;
cache.paintTxt = lv.paint;
ic.updateLocationView(cache, lv.arrow, lv.txt, lv.loc);
}
}
use of net.osmand.plus.utils.UiUtilities in project Osmand by osmandapp.
the class MapContextMenuFragment method getActionView.
private View getActionView(ContextMenuItem contextMenuItem, final int position, final ContextMenuAdapter mainAdapter, final ContextMenuAdapter additionalAdapter, final ContextMenuItemClickListener mainListener, final ContextMenuItemClickListener additionalListener) {
UiUtilities uiUtilities = requireMyApplication().getUIUtilities();
LayoutInflater inflater = UiUtilities.getInflater(getMyApplication(), nightMode);
View view = inflater.inflate(R.layout.context_menu_action_item, null);
LinearLayout item = view.findViewById(R.id.item);
ImageView icon = view.findViewById(R.id.icon);
TextView title = view.findViewById(R.id.text);
icon.setImageDrawable(uiUtilities.getIcon(contextMenuItem.getIcon(), nightMode));
title.setText(contextMenuItem.getTitle());
String id = contextMenuItem.getId();
if (MAP_CONTEXT_MENU_MORE_ID.equals(id)) {
item.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
menu.showAdditionalActionsFragment(additionalAdapter, additionalListener);
}
});
} else {
item.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
mainListener.onItemClick(position);
}
});
}
return view;
}
use of net.osmand.plus.utils.UiUtilities in project Osmand by osmandapp.
the class AvailableGPXFragment method openPopUpMenu.
private void openPopUpMenu(View v, final GpxInfo gpxInfo) {
UiUtilities iconsCache = app.getUIUtilities();
final List<PopUpMenuItem> items = new ArrayList<>();
items.add(new PopUpMenuItem.Builder(app).setTitleId(R.string.shared_string_show_on_map).setIcon(iconsCache.getThemedIcon(R.drawable.ic_show_on_map)).setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
showGpxOnMap(gpxInfo);
}
}).create());
GPXTrackAnalysis analysis;
if ((analysis = getGpxTrackAnalysis(gpxInfo, app, null)) != null) {
if (analysis.totalDistance != 0 && !gpxInfo.currentlyRecordingTrack) {
items.add(new PopUpMenuItem.Builder(app).setTitleId(R.string.analyze_on_map).setIcon(iconsCache.getThemedIcon(R.drawable.ic_action_info_dark)).setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
new OpenGpxDetailsTask(gpxInfo).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
}
}).create());
}
}
items.add(new PopUpMenuItem.Builder(app).setTitleId(R.string.shared_string_move).setIcon(iconsCache.getThemedIcon(R.drawable.ic_action_folder_stroke)).setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
moveGpx(gpxInfo);
}
}).create());
items.add(new PopUpMenuItem.Builder(app).setTitleId(R.string.shared_string_rename).setIcon(iconsCache.getThemedIcon(R.drawable.ic_action_edit_dark)).setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
FragmentActivity activity = getActivity();
if (activity != null) {
FileUtils.renameFile(activity, gpxInfo.file, AvailableGPXFragment.this, false);
}
}
}).create());
Drawable shareIcon = iconsCache.getThemedIcon((R.drawable.ic_action_gshare_dark));
items.add(new PopUpMenuItem.Builder(app).setTitleId(R.string.shared_string_share).setIcon(AndroidUtils.getDrawableForDirection(app, shareIcon)).setOnClickListener(v1 -> {
Activity activity = getActivity();
if (activity != null) {
Uri fileUri = AndroidUtils.getUriForFile(activity, gpxInfo.file);
Intent sendIntent = new Intent(Intent.ACTION_SEND).putExtra(Intent.EXTRA_STREAM, fileUri).setType("text/plain").addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION);
AndroidUtils.startActivityIfSafe(activity, sendIntent);
}
}).create());
final OsmEditingPlugin osmEditingPlugin = OsmandPlugin.getActivePlugin(OsmEditingPlugin.class);
if (osmEditingPlugin != null) {
items.add(new PopUpMenuItem.Builder(app).setTitleId(R.string.shared_string_export).setIcon(iconsCache.getThemedIcon(R.drawable.ic_action_export)).setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
osmEditingPlugin.sendGPXFiles(getActivity(), AvailableGPXFragment.this, gpxInfo);
}
}).create());
}
items.add(new PopUpMenuItem.Builder(app).setTitleId(R.string.shared_string_delete).setIcon(iconsCache.getThemedIcon(R.drawable.ic_action_delete_dark)).setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());
builder.setMessage(R.string.recording_delete_confirm);
builder.setPositiveButton(R.string.shared_string_yes, new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
operationTask = new DeleteGpxTask();
operationTask.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR, gpxInfo);
}
});
builder.setNegativeButton(R.string.shared_string_cancel, null);
builder.show();
}
}).create());
new PopUpMenuHelper.Builder(v, items, nightMode).show();
}
use of net.osmand.plus.utils.UiUtilities in project Osmand by osmandapp.
the class MeasurementToolAdapter method onBindViewHolder.
@Override
public void onBindViewHolder(@NonNull final MeasureToolItemVH holder, int pos) {
OsmandApplication app = mapActivity.getMyApplication();
UiUtilities iconsCache = app.getUIUtilities();
holder.iconReorder.setImageDrawable(iconsCache.getThemedIcon(R.drawable.ic_action_item_move));
holder.iconReorder.setOnTouchListener((view, event) -> {
if (event.getActionMasked() == MotionEvent.ACTION_DOWN) {
listener.onDragStarted(holder);
}
return false;
});
holder.icon.setImageDrawable(iconsCache.getIcon(R.drawable.ic_action_measure_point, ColorUtilities.getDefaultIconColorId(nightMode)));
WptPt pt = points.get(pos);
String pointTitle = pt.name;
if (!TextUtils.isEmpty(pointTitle)) {
holder.title.setText(pointTitle);
} else {
holder.title.setText(mapActivity.getString(R.string.ltr_or_rtl_combine_via_dash, mapActivity.getString(R.string.plugin_distance_point), String.valueOf(pos + 1)));
}
String pointDesc = pt.desc;
if (!TextUtils.isEmpty(pointDesc)) {
holder.descr.setText(pointDesc);
} else {
String text = "";
Location l1;
Location l2;
if (pos < 1) {
text = mapActivity.getString(R.string.start_point);
if (app.getLocationProvider().getLastKnownLocation() != null) {
l1 = app.getLocationProvider().getLastKnownLocation();
l2 = getLocationFromLL(points.get(0).lat, points.get(0).lon);
text = text + BULLET + OsmAndFormatter.getFormattedDistance(l1.distanceTo(l2), app) + BULLET + OsmAndFormatter.getFormattedAzimuth(l1.bearingTo(l2), app);
}
} else {
float dist = 0;
for (int i = 1; i <= pos; i++) {
l1 = getLocationFromLL(points.get(i - 1).lat, points.get(i - 1).lon);
l2 = getLocationFromLL(points.get(i).lat, points.get(i).lon);
dist += l1.distanceTo(l2);
text = OsmAndFormatter.getFormattedDistance(dist, app) + BULLET + OsmAndFormatter.getFormattedAzimuth(l1.bearingTo(l2), app);
}
}
holder.descr.setText(text);
}
double elevation = pt.ele;
if (!Double.isNaN(elevation)) {
String eleStr = (mapActivity.getString(R.string.altitude)).substring(0, 1);
holder.elevation.setText(mapActivity.getString(R.string.ltr_or_rtl_combine_via_colon, eleStr, OsmAndFormatter.getFormattedAlt(elevation, app)));
} else {
holder.elevation.setText("");
}
float speed = (float) pt.speed;
if (speed != 0) {
String speedStr = (mapActivity.getString(R.string.map_widget_speed)).substring(0, 1);
holder.speed.setText(mapActivity.getString(R.string.ltr_or_rtl_combine_via_colon, speedStr, OsmAndFormatter.getFormattedSpeed(speed, app)));
} else {
holder.speed.setText("");
}
holder.deleteBtn.setImageDrawable(iconsCache.getIcon(R.drawable.ic_action_remove_dark, ColorUtilities.getDefaultIconColorId(nightMode)));
holder.deleteBtn.setOnClickListener(view -> listener.onRemoveClick(holder.getAdapterPosition()));
holder.itemView.setOnClickListener(view -> listener.onItemClick(holder.getAdapterPosition()));
}
use of net.osmand.plus.utils.UiUtilities in project Osmand by osmandapp.
the class MapInfoLayer method recreateControls.
public void recreateControls() {
if (leftStack != null) {
leftStack.removeAllViews();
if (mapInfoControls != null) {
mapInfoControls.populateStackControl(leftStack, settings.getApplicationMode(), true, WIDGETS_EXPANDED);
}
leftStack.requestLayout();
}
if (rightStack != null) {
rightStack.removeAllViews();
if (mapInfoControls != null) {
mapInfoControls.populateStackControl(rightStack, settings.getApplicationMode(), false, WIDGETS_EXPANDED);
}
rightStack.requestLayout();
}
if (expandButton != null) {
expandButton.setVisibility(mapInfoControls.hasCollapsibles(settings.getApplicationMode()) ? View.VISIBLE : View.GONE);
UiUtilities uiUtilities = getApplication().getUIUtilities();
int iconId = WIDGETS_EXPANDED ? R.drawable.ic_action_arrow_up : R.drawable.ic_action_arrow_down;
int colorId = ColorUtilities.getMapButtonIconColorId(false);
Drawable expandIcon = uiUtilities.getIcon(iconId, colorId);
setMapButtonIcon(expandButton, expandIcon);
expandButton.setContentDescription(getString(WIDGETS_EXPANDED ? R.string.shared_string_collapse : R.string.access_widget_expand));
expandButton.setOnClickListener(v -> {
WIDGETS_EXPANDED = !WIDGETS_EXPANDED;
recreateControls();
});
}
}
Aggregations