Register monitoring plugin preferences

This commit is contained in:
Vitaliy 2020-01-20 18:40:05 +02:00
parent 1f9a94cea4
commit 7bc27022e5
5 changed files with 58 additions and 25 deletions

View file

@ -65,6 +65,13 @@
android:summaryOn="@string/shared_string_enabled"
android:title="@string/disable_recording_once_app_killed" />
<net.osmand.plus.settings.preferences.SwitchPreferenceEx
android:key="save_heading_to_gpx"
android:layout="@layout/preference_with_descr_dialog_and_switch"
android:summaryOff="@string/shared_string_disabled"
android:summaryOn="@string/shared_string_enabled"
android:title="@string/save_heading" />
<Preference
android:layout="@layout/simple_divider_item"
android:selectable="false" />
@ -76,6 +83,18 @@
tools:icon="@drawable/ic_action_folder"
tools:summary="Not selected" />
<net.osmand.plus.settings.preferences.SwitchPreferenceEx
android:key="show_trip_recording_notification"
android:layout="@layout/preference_with_descr_dialog_and_switch"
android:summaryOff="@string/shared_string_disabled"
android:summaryOn="@string/shared_string_enabled"
android:title="@string/trip_rec_notification_settings"
tools:icon="@drawable/ic_action_notification" />
<Preference
android:layout="@layout/simple_divider_item"
android:selectable="false" />
<net.osmand.plus.settings.preferences.SwitchPreferenceEx
android:key="live_monitoring"
android:layout="@layout/preference_with_descr_dialog_and_switch"

View file

@ -8,14 +8,11 @@ import android.support.annotation.NonNull;
import net.osmand.plus.OsmandApplication;
import net.osmand.plus.OsmandPlugin;
import net.osmand.plus.OsmandSettings;
import net.osmand.plus.OsmandSettings.OsmandPreference;
import net.osmand.plus.R;
import net.osmand.plus.settings.BaseSettingsFragment;
import java.io.IOException;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
public class AccessibilityPlugin extends OsmandPlugin {
@ -29,19 +26,18 @@ public class AccessibilityPlugin extends OsmandPlugin {
private SoundPool sounds;
private Map<Integer, Integer> soundIcons = new HashMap<Integer, Integer>();
private List<OsmandPreference> pluginPreferences = new ArrayList<>();
public AccessibilityPlugin(OsmandApplication app) {
this.app = app;
pluginPreferences.add(app.getSettings().ACCESSIBILITY_MODE);
pluginPreferences.add(app.getSettings().SPEECH_RATE);
pluginPreferences.add(app.getSettings().ACCESSIBILITY_SMART_AUTOANNOUNCE);
pluginPreferences.add(app.getSettings().ACCESSIBILITY_AUTOANNOUNCE_PERIOD);
pluginPreferences.add(app.getSettings().DISABLE_OFFROUTE_RECALC);
pluginPreferences.add(app.getSettings().DISABLE_WRONG_DIRECTION_RECALC);
pluginPreferences.add(app.getSettings().DIRECTION_STYLE);
pluginPreferences.add(app.getSettings().DIRECTION_AUDIO_FEEDBACK);
pluginPreferences.add(app.getSettings().DIRECTION_HAPTIC_FEEDBACK);
OsmandSettings settings = app.getSettings();
pluginPreferences.add(settings.ACCESSIBILITY_MODE);
pluginPreferences.add(settings.SPEECH_RATE);
pluginPreferences.add(settings.ACCESSIBILITY_SMART_AUTOANNOUNCE);
pluginPreferences.add(settings.ACCESSIBILITY_AUTOANNOUNCE_PERIOD);
pluginPreferences.add(settings.DISABLE_OFFROUTE_RECALC);
pluginPreferences.add(settings.DISABLE_WRONG_DIRECTION_RECALC);
pluginPreferences.add(settings.DIRECTION_STYLE);
pluginPreferences.add(settings.DIRECTION_AUDIO_FEEDBACK);
pluginPreferences.add(settings.DIRECTION_HAPTIC_FEEDBACK);
}
@Override
@ -80,11 +76,6 @@ public class AccessibilityPlugin extends OsmandPlugin {
return AccessibilitySettingsFragment.class;
}
@Override
public List<OsmandPreference> getPreferences() {
return pluginPreferences;
}
@Override
public String getPrefsDescription() {
return app.getString(R.string.accessibility_prefs_descr);
@ -108,12 +99,6 @@ public class AccessibilityPlugin extends OsmandPlugin {
return R.drawable.ic_plugin_accessibility;
}
private OsmandSettings.CommonPreference<Boolean> registerBooleanAccessibilityPreference(OsmandApplication app, String prefId, boolean defValue) {
OsmandSettings.CommonPreference<Boolean> preference = app.getSettings().registerBooleanAccessibilityPreference(prefId, defValue);
pluginPreferences.add(preference);
return preference;
}
public void playSoundIcon(int iconId) {
if ((sounds != null) && soundIcons.containsKey(iconId)) {
int sound = soundIcons.get(iconId);

View file

@ -641,6 +641,12 @@ public abstract class OsmandPlugin {
return preference;
}
private OsmandSettings.CommonPreference<Boolean> registerBooleanAccessibilityPreference(OsmandApplication app, String prefId, boolean defValue) {
OsmandSettings.CommonPreference<Boolean> preference = app.getSettings().registerBooleanAccessibilityPreference(prefId, defValue);
pluginPreferences.add(preference);
return preference;
}
protected OsmandSettings.CommonPreference<String> registerStringPreference(OsmandApplication app, String prefId, String defValue) {
OsmandSettings.CommonPreference<String> preference = app.getSettings().registerStringPreference(prefId, defValue);
pluginPreferences.add(preference);

View file

@ -43,8 +43,10 @@ public class MonitoringSettingsFragment extends BaseSettingsFragment implements
setupSaveTrackMinSpeedPref();
setupAutoSplitRecordingPref();
setupDisableRecordingOnceAppKilledPref();
setupSaveHeadingToGpxPref();
setupTrackStorageDirectoryPref();
setupShowTripRecNotificationPref();
setupLiveMonitoringPref();
setupOpenNotesDescrPref();
@ -136,6 +138,17 @@ public class MonitoringSettingsFragment extends BaseSettingsFragment implements
disableRecordingOnceAppKilled.setDescription(getString(R.string.disable_recording_once_app_killed_descrp));
}
private void setupSaveHeadingToGpxPref() {
SwitchPreferenceEx saveHeadingToGpx = (SwitchPreferenceEx) findPreference(settings.SAVE_HEADING_TO_GPX.getId());
saveHeadingToGpx.setDescription(getString(R.string.save_heading_descr));
}
private void setupShowTripRecNotificationPref() {
SwitchPreferenceEx showTripRecNotification = (SwitchPreferenceEx) findPreference(settings.SHOW_TRIP_REC_NOTIFICATION.getId());
showTripRecNotification.setDescription(getString(R.string.trip_rec_notification_settings));
showTripRecNotification.setIcon(getContentIcon(R.drawable.ic_action_notification));
}
private void setupTrackStorageDirectoryPref() {
Integer[] entryValues = new Integer[] {REC_DIRECTORY, MONTHLY_DIRECTORY, DAILY_DIRECTORY};
String[] entries = new String[entryValues.length];

View file

@ -63,6 +63,16 @@ public class OsmandMonitoringPlugin extends OsmandPlugin {
final List<ApplicationMode> am = ApplicationMode.allPossibleValues();
ApplicationMode.regWidgetVisibility("monitoring", am.toArray(new ApplicationMode[am.size()]));
settings = app.getSettings();
pluginPreferences.add(settings.SAVE_TRACK_TO_GPX);
pluginPreferences.add(settings.SAVE_TRACK_INTERVAL);
pluginPreferences.add(settings.SAVE_TRACK_MIN_DISTANCE);
pluginPreferences.add(settings.SAVE_TRACK_PRECISION);
pluginPreferences.add(settings.AUTO_SPLIT_RECORDING);
pluginPreferences.add(settings.DISABLE_RECORDING_ONCE_APP_KILLED);
pluginPreferences.add(settings.SAVE_HEADING_TO_GPX);
pluginPreferences.add(settings.SHOW_TRIP_REC_NOTIFICATION);
pluginPreferences.add(settings.TRACK_STORAGE_DIRECTORY);
pluginPreferences.add(settings.LIVE_MONITORING);
}
@Override