use of net.osmand.plus.IconsCache in project Osmand by osmandapp.
the class SearchPoiFilterFragment method showOptionsMenu.
private void showOptionsMenu(View v) {
// Show menu with search all, name finder, name finder poi
IconsCache iconsCache = getMyApplication().getIconsCache();
final PopupMenu optionsMenu = new PopupMenu(getActivity(), v);
MenuItem item = optionsMenu.getMenu().add(R.string.poi_filter_custom_filter).setIcon(iconsCache.getThemedIcon(R.drawable.ic_action_filter_dark));
item.setOnMenuItemClickListener(new MenuItem.OnMenuItemClickListener() {
@Override
public boolean onMenuItemClick(MenuItem item) {
PoiUIFilter filter = getApp().getPoiFilters().getCustomPOIFilter();
filter.clearFilter();
showFilterActivity(filter.getFilterId());
return true;
}
});
optionsMenu.show();
}
use of net.osmand.plus.IconsCache in project Osmand by osmandapp.
the class AudioVideoNoteRecordingMenu method update.
public void update() {
CurrentRecording recording = plugin.getCurrentRecording();
IconsCache iconsCache = plugin.getMapActivity().getMyApplication().getIconsCache();
ImageView leftButtonIcon = (ImageView) view.findViewById(R.id.leftButtonIcon);
View leftButtonView = view.findViewById(R.id.leftButtonView);
if (recording.getType() != AVActionType.REC_AUDIO) {
leftButtonIcon.setImageDrawable(iconsCache.getThemedIcon(R.drawable.ic_action_minimize));
TextView showHideText = (TextView) view.findViewById(R.id.leftButtonText);
showHideText.setText(showViewfinder ? view.getResources().getString(R.string.shared_string_hide) : view.getResources().getString(R.string.shared_string_show));
leftButtonView.setVisibility(View.VISIBLE);
viewfinder.setVisibility(showViewfinder ? View.VISIBLE : View.GONE);
} else {
leftButtonView.setVisibility(View.INVISIBLE);
viewfinder.setVisibility(View.GONE);
}
leftButtonView.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
showHideViewfinder();
}
});
View centerButtonView = view.findViewById(R.id.centerButtonView);
ImageView recIcon = (ImageView) view.findViewById(R.id.centerButtonIcon);
TextView recText = (TextView) view.findViewById(R.id.centerButtonText);
View timeView = view.findViewById(R.id.timeView);
switch(recording.getType()) {
case REC_AUDIO:
case REC_VIDEO:
recIcon.setImageDrawable(iconsCache.getThemedIcon(R.drawable.ic_action_rec_stop));
recText.setText(view.getResources().getString(R.string.shared_string_control_stop));
recText.setVisibility(View.VISIBLE);
updateDuration();
timeView.setVisibility(View.VISIBLE);
break;
case REC_PHOTO:
recIcon.setImageDrawable(iconsCache.getThemedIcon(R.drawable.ic_action_photo_dark));
recText.setVisibility(View.GONE);
timeView.setVisibility(View.INVISIBLE);
break;
}
centerButtonView.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
rec(plugin.getMapActivity(), false);
}
});
applyViewfinderVisibility();
}
use of net.osmand.plus.IconsCache in project Osmand by osmandapp.
the class DirectionDrawable method setImage.
public void setImage(int resourceId) {
IconsCache iconsCache = ((OsmandApplication) ctx.getApplicationContext()).getIconsCache();
arrowImage = iconsCache.getIcon(resourceId, 0);
this.resourceId = resourceId;
onBoundsChange(getBounds());
}
use of net.osmand.plus.IconsCache 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) {
IconsCache iconsCache = ((OsmandApplication) ctx.getApplicationContext()).getIconsCache();
arrowImage = iconsCache.getIcon(resourceId, clrId);
} else {
paintRouteDirection.setColor(ctx.getResources().getColor(clrId));
}
}
use of net.osmand.plus.IconsCache in project Osmand by osmandapp.
the class GpxUiHelper method createSingleChoiceDialog.
private static AlertDialog createSingleChoiceDialog(final Activity activity, final boolean showCurrentGpx, final CallbackWithObject<GPXFile[]> callbackWithObject, final List<GPXInfo> list, final ContextMenuAdapter adapter) {
final OsmandApplication app = (OsmandApplication) activity.getApplication();
final IconsCache iconsCache = app.getIconsCache();
final File dir = app.getAppPath(IndexConstants.GPX_INDEX_DIR);
AlertDialog.Builder builder = new AlertDialog.Builder(activity);
final int layout = R.layout.list_menu_item_native_singlechoice;
final ArrayAdapter<String> listAdapter = new ArrayAdapter<String>(activity, layout, R.id.text1, adapter.getItemNames()) {
@Override
public View getView(final int position, View convertView, ViewGroup parent) {
// User super class to create the View
View v = convertView;
if (v == null) {
v = activity.getLayoutInflater().inflate(layout, null);
}
final ContextMenuItem item = adapter.getItem(position);
TextView tv = (TextView) v.findViewById(R.id.text1);
Drawable icon;
if (showCurrentGpx && position == 0) {
icon = null;
} else {
icon = iconsCache.getThemedIcon(item.getIcon());
}
tv.setCompoundDrawablePadding(AndroidUtils.dpToPx(activity, 10f));
tv.setCompoundDrawablesWithIntrinsicBounds(icon, null, null, null);
tv.setText(item.getTitle());
tv.setTextSize(TypedValue.COMPLEX_UNIT_SP, 16);
return v;
}
};
int selectedIndex = 0;
String prevSelectedGpx = app.getSettings().LAST_SELECTED_GPX_TRACK_FOR_NEW_POINT.get();
if (prevSelectedGpx != null) {
selectedIndex = list.indexOf(prevSelectedGpx);
}
if (selectedIndex == -1) {
selectedIndex = 0;
}
final int[] selectedPosition = { selectedIndex };
builder.setSingleChoiceItems(listAdapter, selectedIndex, new OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int position) {
selectedPosition[0] = position;
}
});
builder.setTitle(R.string.select_gpx).setPositiveButton(R.string.shared_string_ok, new OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
int position = selectedPosition[0];
if (position != -1) {
if (showCurrentGpx && position == 0) {
callbackWithObject.processResult(null);
app.getSettings().LAST_SELECTED_GPX_TRACK_FOR_NEW_POINT.set(null);
} else {
String fileName = list.get(position).getFileName();
app.getSettings().LAST_SELECTED_GPX_TRACK_FOR_NEW_POINT.set(fileName);
SelectedGpxFile selectedGpxFile = app.getSelectedGpxHelper().getSelectedFileByName(fileName);
if (selectedGpxFile != null) {
callbackWithObject.processResult(new GPXFile[] { selectedGpxFile.getGpxFile() });
} else {
loadGPXFileInDifferentThread(activity, callbackWithObject, dir, null, fileName);
}
}
}
}
}).setNegativeButton(R.string.shared_string_cancel, null);
final AlertDialog dlg = builder.create();
dlg.setCanceledOnTouchOutside(false);
dlg.show();
try {
dlg.getListView().setFastScrollEnabled(true);
} catch (Exception e) {
// java.lang.ClassCastException: com.android.internal.widget.RoundCornerListAdapter
// Unknown reason but on some devices fail
}
return dlg;
}
Aggregations