diff --git a/res/values/strings.xml b/res/values/strings.xml index b6a5210b..e05b8a82 100644 --- a/res/values/strings.xml +++ b/res/values/strings.xml @@ -52,7 +52,7 @@ Processing options Solution options Caster options - + Rover Base @@ -130,7 +130,7 @@ b: height: - + Single DGPS/DGNSS @@ -168,7 +168,7 @@ PPP Dead reckoning Internal - + Lat/Long/Height X/Y/Z — ECEF @@ -261,7 +261,7 @@ Rinex header RTCM Antenna position - + Processing options 1 Solution options @@ -327,7 +327,7 @@ 35 40 - + GPS Integer ambiguity resolution GPS Integer ambiguity resolution @@ -532,11 +532,11 @@ 30 60 - + Output header Set whether the header is output or not - + Output GPS mock locations Set if solution is sent to other applications like the internal GPS @@ -553,7 +553,7 @@ OFF Solid Solid, ocean, pole - + ddd.dddddddd : Degree ddd mm ss.sss : Degree minute second @@ -627,7 +627,7 @@ +proj=longlat +ellps=WGS84 +datum=WGS84 +no_defs Enable test mode If this is enabled and Rover/Base/Correction are off, it runs in a special test mode with positions coming from internal GPS. Obviously no algorithm from RTKLIB can work - + Type Format @@ -644,10 +644,10 @@ Receiver option Transmit GPGGA to Base Station Latitude - Longitude + Longitude Antenna Antenna official IGS name (for phase center variation) - + OFF Latitude/Longitude @@ -658,8 +658,8 @@ 1 2 - - + + Enable Solution 1 Enable Solution 2 @@ -668,7 +668,7 @@ Solution 2 GPX Trace - + Log rover Log base @@ -676,7 +676,7 @@ Log Rover Log Base Log Correction - + NTRIP client settings Host @@ -684,6 +684,13 @@ NTRIP Mountpoint NTRIP user NTRIP password + + Individual fields + Single path + + NTRIP path... + Change all settings as a single string. + NTRIP server settings Filename can included %Y (year) %m (month) %d (day) %h (hour) %M (minutes) %S (seconds) for dynamic naming @@ -703,7 +710,7 @@ File settings - + Bluetooth receiver settings device not selected @@ -711,7 +718,7 @@ Bluetooth device Bluetooth system settings Display system Bluetooth settings screen - + Bluetooth connected Bluetooth connection lost @@ -744,10 +751,10 @@ - + USB connected USB connection lost - + USB receiver settings Baudrate @@ -794,7 +801,7 @@ 1 2 - + Send commands at startup Send commands at shutdown @@ -802,14 +809,14 @@ Commands at shutdown Load Select file - + Lat/Lon/Height (deg/m) Lat/Lon/Height (dms/m) X/Y/Z — ECEF For fixed mode For relative mode - + SNR Rover/Base SNR Rover/Base L1 @@ -817,7 +824,7 @@ SNR Rover/Base L5 Skyplot Rover L1 Skyplot Rover L2 - Skyplot Rover L5 + Skyplot Rover L5 Skyplot Base L1 Skyplot Base L2 Skyplot Base L5 @@ -830,12 +837,12 @@ Install EGM 2008 2.5\' Geoid (135MB) Install EGM 2008 1.0\' Geoid (825MB) Install EGM 96 15\' Geoid (2MB) - + Change Log What\'s New OK more… - + Enable experimental NTRIP Caster NTRIP Caster Ending NTRIP Caster will also shutown RTKGPS+, it is safer for being sure all connections are closed. diff --git a/res/xml/stream_ntrip_client_settings.xml b/res/xml/stream_ntrip_client_settings.xml index 8853be18..f809e132 100644 --- a/res/xml/stream_ntrip_client_settings.xml +++ b/res/xml/stream_ntrip_client_settings.xml @@ -1,28 +1,45 @@ - - - - - - - - - - - - \ No newline at end of file + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/gpsplus/rtkgps/settings/NtripPathEditTextPreference.java b/src/gpsplus/rtkgps/settings/NtripPathEditTextPreference.java new file mode 100644 index 00000000..3afa3c92 --- /dev/null +++ b/src/gpsplus/rtkgps/settings/NtripPathEditTextPreference.java @@ -0,0 +1,61 @@ +package gpsplus.rtkgps.settings; + +import android.content.Context; +import android.os.Bundle; +import android.preference.EditTextPreference; + +import android.util.AttributeSet; +import android.text.Editable; +import android.text.TextWatcher; +import android.app.AlertDialog; +import android.app.Dialog; +import android.widget.Button; + +public class NtripPathEditTextPreference extends EditTextPreference { + + public NtripPathEditTextPreference(Context ctx, AttributeSet attrs, int defStyle) { + super(ctx, attrs, defStyle); + } + + public NtripPathEditTextPreference(Context ctx, AttributeSet attrs) { + super(ctx, attrs); + } + + private class EditTextWatcher implements TextWatcher { + @Override + public void onTextChanged(CharSequence s, int start, int before, int count) {} + + @Override + public void beforeTextChanged(CharSequence s, int start, int before, int count) {} + + @Override + public void afterTextChanged(Editable s) { + onEditTextChanged(); + } + } + + EditTextWatcher m_watcher = new EditTextWatcher(); + + protected boolean onCheckValue(String value) { + return null != SettingsHelper.decodeNtripTcpPath(value); + } + + protected void onEditTextChanged() { + boolean enable = onCheckValue(getEditText().getText().toString()); + Dialog dlg = getDialog(); + if (dlg instanceof AlertDialog) { + AlertDialog alertDlg = (AlertDialog) dlg; + Button btn = alertDlg.getButton(AlertDialog.BUTTON_POSITIVE); + btn.setEnabled(enable); + } + } + + @Override + protected void showDialog(Bundle state) { + super.showDialog(state); + + getEditText().removeTextChangedListener(m_watcher); + getEditText().addTextChangedListener(m_watcher); + onEditTextChanged(); + } +} diff --git a/src/gpsplus/rtkgps/settings/SettingsHelper.java b/src/gpsplus/rtkgps/settings/SettingsHelper.java index eb7d2da8..077e788c 100644 --- a/src/gpsplus/rtkgps/settings/SettingsHelper.java +++ b/src/gpsplus/rtkgps/settings/SettingsHelper.java @@ -16,11 +16,21 @@ import gpsplus.rtklib.constants.StreamFormat; import gpsplus.rtklib.constants.StreamType; +import java.util.regex.Matcher; +import java.util.regex.Pattern; + import javax.annotation.Nonnull; import javax.annotation.Nullable; public class SettingsHelper { + static final String NTRIP_REGEX = "^ntrip://(?:([^:]+)(?::([^@]+))?@)?([^:]+)(?::([0-9]+))?/(.+)$"; + + static final int USER = 1; + static final int PASSWORD = 2; + static final int HOST = 3; + static final int PORT = 4; + static final int MOUNTPOINT = 5; static class StreamDefaultsBase { @@ -471,5 +481,28 @@ static String encodeNtripTcpPath( return path.toString(); } + static StreamNtripClientFragment.Value decodeNtripTcpPath(String path) { + StreamNtripClientFragment.Value value = new StreamNtripClientFragment.Value(); + Pattern pattern = Pattern.compile(NTRIP_REGEX); + Matcher matcher = pattern.matcher(path); + if (!matcher.find()) { + return null; + } + value + .setUser(fixEmpty(matcher.group(USER))) + .setPassword(fixEmpty(matcher.group(PASSWORD))) + .setHost(matcher.group(HOST)) + .setPort( + matcher.group(PORT) == null + ? StreamNtripClientFragment.Value.DEFAULT_PORT + : Integer.parseInt(matcher.group(PORT)) + ) + .setMountpoint(matcher.group(MOUNTPOINT)); + return value; + } + + static String fixEmpty(String value) { + return value == null ? "" : value; + } } diff --git a/src/gpsplus/rtkgps/settings/StreamNtripClientFragment.java b/src/gpsplus/rtkgps/settings/StreamNtripClientFragment.java index 26f824f6..a35439fe 100644 --- a/src/gpsplus/rtkgps/settings/StreamNtripClientFragment.java +++ b/src/gpsplus/rtkgps/settings/StreamNtripClientFragment.java @@ -23,6 +23,7 @@ public class StreamNtripClientFragment extends PreferenceFragment { private static final String KEY_MOUNTPOINT = "stream_ntrip_client_mountpoint"; private static final String KEY_USER = "stream_ntrip_client_user"; private static final String KEY_PASSWORD = "stream_ntrip_client_password"; + private static final String KEY_PATH = "stream_ntrip_path"; private final PreferenceChangeListener mPreferenceChangeListener; @@ -155,6 +156,7 @@ public static void setDefaultValue(Context ctx, String sharedPrefsName, Value va .putString(KEY_MOUNTPOINT, value.mountpoint) .putString(KEY_USER, value.user) .putString(KEY_PASSWORD, value.password) + .putString(KEY_PATH, "") .apply(); } @@ -190,17 +192,34 @@ void reloadSummaries() { etp = (EditTextPreference) findPreference(KEY_PASSWORD); etp.setSummary(etp.getText()); + + etp = (EditTextPreference) findPreference(KEY_PATH); + etp.setSummary(etp.getText()); } private class PreferenceChangeListener implements SharedPreferences.OnSharedPreferenceChangeListener { @Override public void onSharedPreferenceChanged( SharedPreferences sharedPreferences, String key) { + if (key.equals(KEY_PATH)) { + String path = ((EditTextPreference) findPreference(KEY_PATH)).getText(); + Value value = SettingsHelper.decodeNtripTcpPath(path); + if (value != null) { + ((EditTextPreference) findPreference(KEY_HOST)).setText(value.host); + ((EditTextPreference) findPreference(KEY_PORT)).setText(String.valueOf(value.port)); + ((EditTextPreference) findPreference(KEY_MOUNTPOINT)).setText(value.mountpoint); + ((EditTextPreference) findPreference(KEY_USER)).setText(value.user); + ((EditTextPreference) findPreference(KEY_PASSWORD)).setText(value.password); + } else { + ((EditTextPreference) findPreference(KEY_PATH)).setText(readSummary(sharedPreferences)); + } + } else { + ((EditTextPreference) findPreference(KEY_PATH)).setText(readSummary(sharedPreferences)); + } reloadSummaries(); } }; - public static Value readSettings(SharedPreferences prefs) { return new Value() .setUser(prefs.getString(KEY_USER, ""))