Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,27 @@ private void configureForceRelayConnectionSwitch(@NonNull ComponentSwitchBinding
});
}

private void configureEnableLazyConnectionSwitch(@NonNull ComponentSwitchBinding binding, @NonNull Preferences preferences) {
binding.switchTitle.setText(R.string.advanced_enable_lazy_conn);
binding.switchDescription.setText(R.string.advanced_enable_lazy_conn_desc);

binding.switchControl.setChecked(preferences.isLazyConnectionEnabled());
binding.switchControl.setOnCheckedChangeListener((buttonView, isChecked) -> {
if (isChecked) {
preferences.enableLazyConnection();
} else {
preferences.disableLazyConnection();
}

showReconnectionNeededWarningDialog();
});

// Make parent layout clickable to toggle switch (for TV remote)
binding.getRoot().setOnClickListener(v -> {
binding.switchControl.toggle();
});
}

public View onCreateView(@NonNull LayoutInflater inflater,
ViewGroup container, Bundle savedInstanceState) {

Expand Down Expand Up @@ -182,6 +203,7 @@ public View onCreateView(@NonNull LayoutInflater inflater,
});

configureForceRelayConnectionSwitch(binding.layoutForceRelayConnection, preferences);
configureEnableLazyConnectionSwitch(binding.layoutEnableLazyConnection, preferences);

// Initialize engine config switches (your settings)
initializeEngineConfigSwitches();
Expand Down
13 changes: 12 additions & 1 deletion app/src/main/res/layout/fragment_advanced.xml
Original file line number Diff line number Diff line change
Expand Up @@ -530,6 +530,17 @@
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/layout_disable_firewall" />

<include
android:id="@+id/layout_enable_lazy_connection"
layout="@layout/component_switch"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginTop="16dp"
android:orientation="vertical"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/layout_force_relay_connection" />

<LinearLayout
android:id="@+id/layout_theme"
android:layout_width="0dp"
Expand All @@ -538,7 +549,7 @@
android:orientation="vertical"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/layout_force_relay_connection">
app:layout_constraintTop_toBottomOf="@id/layout_enable_lazy_connection">

<TextView
android:layout_width="wrap_content"
Expand Down
2 changes: 2 additions & 0 deletions app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -141,4 +141,6 @@
<string name="profiles_success_switched">Switched to profile \'%s\'</string>
<string name="profiles_success_logged_out">Logged out from profile \'%s\'</string>
<string name="profiles_success_removed">Profile \'%s\' removed successfully</string>
<string name="advanced_enable_lazy_conn">Enable lazy connection</string>
<string name="advanced_enable_lazy_conn_desc">Enables lazy connection for this peer</string>
</resources>
2 changes: 1 addition & 1 deletion netbird
Submodule netbird updated 396 files
2 changes: 2 additions & 0 deletions tool/src/main/java/io/netbird/client/tool/EnvVarPackager.java
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ public static EnvList getEnvironmentVariables(Preferences preferences) {
var envList = new EnvList();

envList.put(Android.getEnvKeyNBForceRelay(), String.valueOf(preferences.isConnectionForceRelayed()));
envList.put(Android.getEnvKeyNBLazyConn(), String.valueOf(preferences.isLazyConnectionEnabled()));
envList.put(Android.getEnvKeyNBInactivityThreshold(), String.valueOf(preferences.getInactivityThreshold()));

return envList;
}
Expand Down
21 changes: 21 additions & 0 deletions tool/src/main/java/io/netbird/client/tool/Preferences.java
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ public class Preferences {
private final String keyTraceLog = "tracelog";

private final String keyForceRelayConnection = "isConnectionForceRelayed";
private final String keyLazyConnectionEnabled = "isLazyConnectionEnabled";
private final String keyInactivityThreshold = "inactivityThreshold";

private final SharedPreferences sharedPref;

Expand Down Expand Up @@ -38,6 +40,25 @@ public void disableForcedRelayConnection() {
sharedPref.edit().putBoolean(keyForceRelayConnection, false).apply();
}

public boolean isLazyConnectionEnabled() {
return sharedPref.getBoolean(keyLazyConnectionEnabled, true);
}

public void enableLazyConnection() {
sharedPref.edit().putBoolean(keyLazyConnectionEnabled, true).apply();
}

public void disableLazyConnection() {
sharedPref.edit().putBoolean(keyLazyConnectionEnabled, false).apply();
}

// This value represents for how long, in minutes, it will take for a lazy connection to be considered inactive so
// it won't attempt reconnection anymore. Currently, the user cannot change this so it's hardcoded to five minutes
// (its default value in the SDK is 15 minutes, and accepts a minimum of 1 minute).
public int getInactivityThreshold() {
return sharedPref.getInt(keyInactivityThreshold, 5);
}

public static String defaultServer() {
return "https://api.netbird.io";
}
Expand Down
Loading