Search in sources :

Example 1 with SavingTrackHelper

use of net.osmand.plus.activities.SavingTrackHelper in project Osmand by osmandapp.

the class SettingsMonitoringActivity method createLoggingSection.

private void createLoggingSection(PreferenceScreen grp) {
    PreferenceCategory cat = new PreferenceCategory(this);
    cat.setTitle(R.string.save_track_to_gpx_globally);
    grp.addPreference(cat);
    Preference globalrecord = new Preference(this);
    globalrecord.setTitle(R.string.save_track_to_gpx_globally_headline);
    globalrecord.setSummary(R.string.save_track_to_gpx_globally_descr);
    globalrecord.setSelectable(false);
    // setEnabled(false) creates bad readability on some devices
    // globalrecord.setEnabled(false);
    cat.addPreference(globalrecord);
    if (settings.SAVE_GLOBAL_TRACK_REMEMBER.get()) {
        cat.addPreference(createTimeListPreference(settings.SAVE_GLOBAL_TRACK_INTERVAL, SECONDS, MINUTES, 1000, settings.SAVE_GLOBAL_TRACK_REMEMBER, R.string.save_global_track_interval, R.string.save_global_track_interval_descr));
    }
    Preference pref = new Preference(this);
    pref.setTitle(R.string.save_current_track);
    pref.setSummary(getMyApplication().getString(R.string.save_current_track_descr) + " (" + OsmAndFormatter.getFormattedDistance(getMyApplication().getSavingTrackHelper().getDistance(), getMyApplication()) + ")");
    pref.setOnPreferenceClickListener(new OnPreferenceClickListener() {

        @Override
        public boolean onPreferenceClick(Preference preference) {
            SavingTrackHelper helper = getMyApplication().getSavingTrackHelper();
            if (helper.hasDataToSave()) {
                saveCurrentTracks(helper);
            } else {
                helper.close();
            }
            return true;
        }
    });
    cat.addPreference(pref);
    cat.addPreference(createCheckBoxPreference(settings.SAVE_TRACK_TO_GPX, R.string.save_track_to_gpx, R.string.save_track_to_gpx_descrp));
    cat.addPreference(createTimeListPreference(settings.SAVE_TRACK_INTERVAL, SECONDS, MINUTES, 1000, R.string.save_track_interval, R.string.save_track_interval_descr));
    String[] names;
    Float[] floatValues;
    floatValues = new Float[] { 0.f, 2.0f, 5.0f, 10.0f, 20.0f, 30.0f, 50.0f };
    names = new String[floatValues.length];
    names[0] = getString(R.string.shared_string_not_selected);
    for (int i = 1; i < floatValues.length; i++) {
        names[i] = floatValues[i].intValue() + " " + getString(R.string.m);
    }
    cat.addPreference(createListPreference(settings.SAVE_TRACK_MIN_DISTANCE, names, floatValues, R.string.save_track_min_distance, R.string.save_track_min_distance_descr));
    floatValues = new Float[] { 0.f, 1.0f, 2.0f, 5.0f, 10.0f, 15.0f, 20.0f, 50.0f, 100.0f };
    names = new String[floatValues.length];
    names[0] = getString(R.string.shared_string_not_selected);
    for (int i = 1; i < floatValues.length; i++) {
        names[i] = floatValues[i].intValue() + " " + getString(R.string.m) + "  (" + Math.round(floatValues[i] / 0.3048f) + " " + getString(R.string.foot) + ")";
    }
    cat.addPreference(createListPreference(settings.SAVE_TRACK_PRECISION, names, floatValues, R.string.save_track_precision, R.string.save_track_precision_descr));
    floatValues = new Float[] { 0.f, 0.000001f, 1.0f, 2.0f, 3.0f, 4.0f, 5.0f, 6.0f, 7.0f };
    names = new String[floatValues.length];
    names[0] = getString(R.string.shared_string_not_selected);
    // This option for the GPS chipset motion detection
    names[1] = "> 0";
    for (int i = 2; i < floatValues.length; i++) {
        names[i] = floatValues[i].intValue() + " " + getString(R.string.km_h);
        floatValues[i] = floatValues[i] / 3.6f;
    }
    cat.addPreference(createListPreference(settings.SAVE_TRACK_MIN_SPEED, names, floatValues, R.string.save_track_min_speed, R.string.save_track_min_speed_descr));
    cat.addPreference(createCheckBoxPreference(settings.AUTO_SPLIT_RECORDING, R.string.auto_split_recording_title, R.string.auto_split_recording_descr));
    cat.addPreference(createCheckBoxPreference(settings.DISABLE_RECORDING_ONCE_APP_KILLED, R.string.disable_recording_once_app_killed, R.string.disable_recording_once_app_killed_descrp));
    cat.addPreference(createCheckBoxPreference(settings.STORE_TRACKS_IN_MONTHLY_DIRECTORIES, R.string.store_tracks_in_monthly_directories, R.string.store_tracks_in_monthly_directories_descrp));
}
Also used : OnPreferenceClickListener(android.preference.Preference.OnPreferenceClickListener) PreferenceCategory(android.preference.PreferenceCategory) CheckBoxPreference(android.preference.CheckBoxPreference) Preference(android.preference.Preference) SavingTrackHelper(net.osmand.plus.activities.SavingTrackHelper)

Example 2 with SavingTrackHelper

use of net.osmand.plus.activities.SavingTrackHelper in project Osmand by osmandapp.

the class DashTrackFragment method updateCurrentTrack.

public static void updateCurrentTrack(View v, final Activity ctx, final OsmandApplication app) {
    final OsmandMonitoringPlugin plugin = OsmandPlugin.getEnabledPlugin(OsmandMonitoringPlugin.class);
    if (v == null || ctx == null || app == null || plugin == null) {
        return;
    }
    final boolean isRecording = app.getSettings().SAVE_GLOBAL_TRACK_TO_GPX.get();
    ImageButton stop = ((ImageButton) v.findViewById(R.id.stop));
    if (isRecording) {
        stop.setImageDrawable(app.getIconsCache().getThemedIcon(R.drawable.ic_action_rec_stop));
        stop.setContentDescription(app.getString(R.string.gpx_monitoring_stop));
    } else {
        stop.setImageDrawable(app.getIconsCache().getThemedIcon(R.drawable.ic_action_rec_start));
        stop.setContentDescription(app.getString(R.string.gpx_monitoring_start));
    }
    stop.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            if (isRecording) {
                plugin.stopRecording();
            } else if (app.getLocationProvider().checkGPSEnabled(ctx)) {
                plugin.startGPXMonitoring(ctx);
            }
        }
    });
    SavingTrackHelper sth = app.getSavingTrackHelper();
    ImageButton save = ((ImageButton) v.findViewById(R.id.show_on_map));
    save.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            plugin.saveCurrentTrack();
        }
    });
    if (sth.getPoints() > 0 || sth.getDistance() > 0) {
        save.setVisibility(View.VISIBLE);
    } else {
        save.setVisibility(View.GONE);
    }
    save.setImageDrawable(app.getIconsCache().getThemedIcon(R.drawable.ic_action_gsave_dark));
    save.setContentDescription(app.getString(R.string.save_current_track));
    ((TextView) v.findViewById(R.id.points_count)).setText(String.valueOf(sth.getPoints()));
    ((TextView) v.findViewById(R.id.distance)).setText(OsmAndFormatter.getFormattedDistance(sth.getDistance(), app));
    v.findViewById(R.id.points_icon).setVisibility(View.VISIBLE);
    ImageView distance = (ImageView) v.findViewById(R.id.distance_icon);
    distance.setVisibility(View.VISIBLE);
    distance.setImageDrawable(app.getIconsCache().getThemedIcon(R.drawable.ic_small_distance));
    ImageView pointsCount = (ImageView) v.findViewById(R.id.points_icon);
    pointsCount.setVisibility(View.VISIBLE);
    pointsCount.setImageDrawable(app.getIconsCache().getThemedIcon(R.drawable.ic_small_point));
}
Also used : ImageButton(android.widget.ImageButton) TextView(android.widget.TextView) SavingTrackHelper(net.osmand.plus.activities.SavingTrackHelper) ImageView(android.widget.ImageView) ImageView(android.widget.ImageView) View(android.view.View) TextView(android.widget.TextView)

Example 3 with SavingTrackHelper

use of net.osmand.plus.activities.SavingTrackHelper in project Osmand by osmandapp.

the class AvailableGPXFragment method updateCurrentTrack.

public void updateCurrentTrack() {
    final OsmandMonitoringPlugin plugin = OsmandPlugin.getEnabledPlugin(OsmandMonitoringPlugin.class);
    if (currentGpxView == null || plugin == null) {
        return;
    }
    final boolean isRecording = app.getSettings().SAVE_GLOBAL_TRACK_TO_GPX.get();
    ImageView icon = (ImageView) currentGpxView.findViewById(R.id.icon);
    icon.setImageDrawable(app.getIconsCache().getIcon(R.drawable.monitoring_rec_big));
    icon.setVisibility(selectionMode && showOnMapMode ? View.GONE : View.VISIBLE);
    final boolean light = app.getSettings().isLightContent();
    SavingTrackHelper sth = app.getSavingTrackHelper();
    Button stop = (Button) currentGpxView.findViewById(R.id.action_button);
    if (isRecording) {
        currentGpxView.findViewById(R.id.segment_time_div).setVisibility(View.VISIBLE);
        TextView segmentTime = (TextView) currentGpxView.findViewById(R.id.segment_time);
        segmentTime.setText(OsmAndFormatter.getFormattedDurationShort((int) (sth.getDuration() / 1000)));
        segmentTime.setVisibility(View.VISIBLE);
        stop.setCompoundDrawablesWithIntrinsicBounds(app.getIconsCache().getIcon(R.drawable.ic_action_rec_stop, light ? R.color.color_dialog_buttons_light : R.color.color_dialog_buttons_dark), null, null, null);
        stop.setText(app.getString(R.string.shared_string_control_stop));
        stop.setContentDescription(app.getString(R.string.gpx_monitoring_stop));
    } else {
        currentGpxView.findViewById(R.id.segment_time_div).setVisibility(View.GONE);
        currentGpxView.findViewById(R.id.segment_time).setVisibility(View.GONE);
        stop.setCompoundDrawablesWithIntrinsicBounds(app.getIconsCache().getIcon(R.drawable.ic_action_rec_start, light ? R.color.color_dialog_buttons_light : R.color.color_dialog_buttons_dark), null, null, null);
        stop.setText(app.getString(R.string.shared_string_record));
        stop.setContentDescription(app.getString(R.string.gpx_monitoring_start));
    }
    stop.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            if (isRecording) {
                plugin.stopRecording();
                updateCurrentTrack();
            } else if (app.getLocationProvider().checkGPSEnabled(getActivity())) {
                plugin.startGPXMonitoring(getActivity());
                updateCurrentTrack();
            }
        }
    });
    Button save = (Button) currentGpxView.findViewById(R.id.save_button);
    save.setCompoundDrawablesWithIntrinsicBounds(app.getIconsCache().getIcon(R.drawable.ic_action_gsave_dark, light ? R.color.color_dialog_buttons_light : R.color.color_dialog_buttons_dark), null, null, null);
    save.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            plugin.saveCurrentTrack();
            updateCurrentTrack();
        }
    });
    if (sth.getPoints() > 0 || sth.getDistance() > 0) {
        save.setVisibility(View.VISIBLE);
    } else {
        save.setVisibility(View.GONE);
    }
    save.setContentDescription(app.getString(R.string.save_current_track));
    ((TextView) currentGpxView.findViewById(R.id.points_count)).setText(String.valueOf(sth.getPoints()));
    ((TextView) currentGpxView.findViewById(R.id.distance)).setText(OsmAndFormatter.getFormattedDistance(sth.getDistance(), app));
    @SuppressWarnings("ConstantConditions") final CheckBox checkbox = (CheckBox) currentGpxView.findViewById(R.id.check_local_index);
    checkbox.setVisibility(selectionMode && showOnMapMode ? View.VISIBLE : View.GONE);
    if (selectionMode && showOnMapMode) {
        checkbox.setChecked(selectedItems.contains(currentRecording));
        checkbox.setOnClickListener(new View.OnClickListener() {

            @Override
            public void onClick(View v) {
                if (checkbox.isChecked()) {
                    selectedItems.add(currentRecording);
                } else {
                    selectedItems.remove(currentRecording);
                }
                updateSelectionMode(actionMode);
            }
        });
    }
}
Also used : ImageButton(android.widget.ImageButton) Button(android.widget.Button) CompoundButton(android.widget.CompoundButton) CheckBox(android.widget.CheckBox) TextView(android.widget.TextView) ImageView(android.widget.ImageView) SavingTrackHelper(net.osmand.plus.activities.SavingTrackHelper) SearchView(android.support.v7.widget.SearchView) ImageView(android.widget.ImageView) View(android.view.View) TextView(android.widget.TextView) AbsListView(android.widget.AbsListView) ExpandableListView(android.widget.ExpandableListView) OsmandMonitoringPlugin(net.osmand.plus.monitoring.OsmandMonitoringPlugin)

Example 4 with SavingTrackHelper

use of net.osmand.plus.activities.SavingTrackHelper in project Osmand by osmandapp.

the class AudioVideoNotesPlugin method indexFile.

private void indexFile(boolean registerInGPX, File f) {
    if (f.getName().endsWith(THREEGP_EXTENSION) || f.getName().endsWith(MPEG4_EXTENSION) || f.getName().endsWith(IMG_EXTENSION)) {
        boolean newFileIndexed = indexSingleFile(f);
        if (newFileIndexed && registerInGPX) {
            Recording rec = recordingByFileName.get(f.getName());
            if (rec != null && (app.getSettings().SAVE_TRACK_TO_GPX.get() || app.getSettings().SAVE_GLOBAL_TRACK_TO_GPX.get()) && OsmandPlugin.getEnabledPlugin(OsmandMonitoringPlugin.class) != null) {
                String name = f.getName();
                SavingTrackHelper savingTrackHelper = app.getSavingTrackHelper();
                savingTrackHelper.insertPointData(rec.lat, rec.lon, System.currentTimeMillis(), null, name, null, 0);
            }
        }
    }
}
Also used : SavingTrackHelper(net.osmand.plus.activities.SavingTrackHelper)

Aggregations

SavingTrackHelper (net.osmand.plus.activities.SavingTrackHelper)4 View (android.view.View)2 ImageButton (android.widget.ImageButton)2 ImageView (android.widget.ImageView)2 TextView (android.widget.TextView)2 CheckBoxPreference (android.preference.CheckBoxPreference)1 Preference (android.preference.Preference)1 OnPreferenceClickListener (android.preference.Preference.OnPreferenceClickListener)1 PreferenceCategory (android.preference.PreferenceCategory)1 SearchView (android.support.v7.widget.SearchView)1 AbsListView (android.widget.AbsListView)1 Button (android.widget.Button)1 CheckBox (android.widget.CheckBox)1 CompoundButton (android.widget.CompoundButton)1 ExpandableListView (android.widget.ExpandableListView)1 OsmandMonitoringPlugin (net.osmand.plus.monitoring.OsmandMonitoringPlugin)1