@Nonnull static String readStreamSummary(Resources resources, StreamType type, SharedPreferences prefs) { String summary; switch (type) { case FILE: summary = StreamFileClientFragment.readSummary(prefs); break; case NTRIPCLI: summary = StreamNtripClientFragment.readSummary(prefs); break; case TCPCLI: summary = StreamTcpClientFragment.readSummary(prefs); break; case BLUETOOTH: summary = StreamBluetoothFragment.readSummary(resources, prefs); break; case USB: summary = StreamUsbFragment.readSummary(resources, prefs); break; case NONE: summary = ""; break; default: throw new IllegalArgumentException(); } return summary; }
@Nonnull static TransportSettings readTransportSettings( Context context, StreamType type, SharedPreferences prefs, String stream) { TransportSettings settings; switch (type) { case FILE: settings = StreamFileClientFragment.readSettings(prefs); break; case NTRIPCLI: settings = StreamNtripClientFragment.readSettings(prefs); break; case TCPCLI: settings = StreamTcpClientFragment.readSettings(prefs); break; case BLUETOOTH: settings = StreamBluetoothFragment.readSettings(context, prefs, stream); break; case USB: settings = StreamUsbFragment.readSettings(context, prefs, stream); break; case NONE: settings = RtkServerSettings.TRANSPORT_DUMMY; break; default: throw new IllegalArgumentException(); } return settings; }
static void setInputStreamDefaultValues( Context ctx, String sharedPrefsName, boolean force, InputStreamDefaults defaults) { final SharedPreferences prefs; prefs = ctx.getSharedPreferences(sharedPrefsName, Context.MODE_PRIVATE); final boolean needUpdate = force || !prefs.contains(InputRoverFragment.KEY_ENABLE); if (needUpdate) { SharedPreferences.Editor e = prefs.edit(); e.putBoolean(InputRoverFragment.KEY_ENABLE, defaults.enable) .putString(InputRoverFragment.KEY_TYPE, defaults.type.name()) .putString(InputRoverFragment.KEY_FORMAT, defaults.format.name()) .putString(InputRoverFragment.KEY_RECEIVER_OPTION, defaults.receiverOption) .commit(); StartupShutdownSettingsActivity.setDefaultValue(ctx, sharedPrefsName); StationPositionActivity.setDefaultValue(ctx, sharedPrefsName, defaults.positionDefaults); StreamFileClientFragment.setDefaultValue(ctx, sharedPrefsName, defaults.fileClientDefaults); StreamNtripClientFragment.setDefaultValue(ctx, sharedPrefsName, defaults.ntripClientDefaults); StreamTcpClientFragment.setDefaultValue(ctx, sharedPrefsName, defaults.tcpClientDefaults); StreamBluetoothFragment.setDefaultValue(ctx, sharedPrefsName, defaults.bluetoothDefaults); StreamUsbFragment.setDefaultValue(ctx, sharedPrefsName, defaults.usbDefaults); } }
static void setLogStreamDefaultValues( Context ctx, String sharedPrefsName, boolean force, LogStreamDefaults defaults) { final SharedPreferences prefs; prefs = ctx.getSharedPreferences(sharedPrefsName, Context.MODE_PRIVATE); final boolean needUpdate = force || !prefs.contains(LogRoverFragment.KEY_ENABLE); if (needUpdate) { SharedPreferences.Editor e = prefs.edit(); e.putBoolean(LogRoverFragment.KEY_ENABLE, defaults.enable) .putString(LogRoverFragment.KEY_TYPE, defaults.type.name()); e.commit(); StreamFileClientFragment.setDefaultValue(ctx, sharedPrefsName, defaults.fileClientDefaults); StreamNtripClientFragment.setDefaultValue(ctx, sharedPrefsName, defaults.ntripClientDefaults); StreamTcpClientFragment.setDefaultValue(ctx, sharedPrefsName, defaults.tcpClientDefaults); } }