Search in sources :

Example 6 with IconsCache

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();
}
Also used : MenuItem(android.view.MenuItem) IconsCache(net.osmand.plus.IconsCache) PopupMenu(android.support.v7.widget.PopupMenu) PoiUIFilter(net.osmand.plus.poi.PoiUIFilter)

Example 7 with IconsCache

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();
}
Also used : CurrentRecording(net.osmand.plus.audionotes.AudioVideoNotesPlugin.CurrentRecording) TextView(android.widget.TextView) IconsCache(net.osmand.plus.IconsCache) ImageView(android.widget.ImageView) SurfaceView(android.view.SurfaceView) ImageView(android.widget.ImageView) TextView(android.widget.TextView) View(android.view.View)

Example 8 with IconsCache

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());
}
Also used : OsmandApplication(net.osmand.plus.OsmandApplication) IconsCache(net.osmand.plus.IconsCache)

Example 9 with IconsCache

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));
    }
}
Also used : OsmandApplication(net.osmand.plus.OsmandApplication) IconsCache(net.osmand.plus.IconsCache)

Example 10 with IconsCache

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;
}
Also used : AlertDialog(android.support.v7.app.AlertDialog) OsmandApplication(net.osmand.plus.OsmandApplication) ContextMenuItem(net.osmand.plus.ContextMenuItem) DialogInterface(android.content.DialogInterface) ViewGroup(android.view.ViewGroup) Drawable(android.graphics.drawable.Drawable) SpannableString(android.text.SpannableString) ImageView(android.widget.ImageView) View(android.view.View) AdapterView(android.widget.AdapterView) MarkerView(com.github.mikephil.charting.components.MarkerView) TextView(android.widget.TextView) SuppressLint(android.annotation.SuppressLint) SelectedGpxFile(net.osmand.plus.GpxSelectionHelper.SelectedGpxFile) OnClickListener(android.content.DialogInterface.OnClickListener) TextView(android.widget.TextView) IconsCache(net.osmand.plus.IconsCache) SelectedGpxFile(net.osmand.plus.GpxSelectionHelper.SelectedGpxFile) File(java.io.File) GPXFile(net.osmand.plus.GPXUtilities.GPXFile) ArrayAdapter(android.widget.ArrayAdapter)

Aggregations

IconsCache (net.osmand.plus.IconsCache)25 View (android.view.View)16 ImageView (android.widget.ImageView)13 TextView (android.widget.TextView)12 MenuItem (android.view.MenuItem)9 OsmandApplication (net.osmand.plus.OsmandApplication)8 PopupMenu (android.support.v7.widget.PopupMenu)6 RecyclerView (android.support.v7.widget.RecyclerView)5 LatLon (net.osmand.data.LatLon)5 ContextMenuItem (net.osmand.plus.ContextMenuItem)5 MotionEvent (android.view.MotionEvent)4 AdapterView (android.widget.AdapterView)4 ImageButton (android.widget.ImageButton)4 GPXFile (net.osmand.plus.GPXUtilities.GPXFile)4 Intent (android.content.Intent)3 Toolbar (android.support.v7.widget.Toolbar)3 ListView (android.widget.ListView)3 File (java.io.File)3 SimpleDateFormat (java.text.SimpleDateFormat)3 Date (java.util.Date)3