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 @@ -197,6 +197,7 @@ private void initializeEngineConfigSwitches() {
binding.switchDisableFirewall.setChecked(goPreferences.getDisableFirewall());
binding.switchAllowSsh.setChecked(goPreferences.getServerSSHAllowed());
binding.switchBlockInbound.setChecked(goPreferences.getBlockInbound());
binding.switchLazyConnection.setChecked(goPreferences.getLazyConnectionEnabled());

// Set up change listeners
binding.switchDisableClientRoutes.setOnCheckedChangeListener((buttonView, isChecked) -> {
Expand Down Expand Up @@ -252,15 +253,28 @@ private void initializeEngineConfigSwitches() {
Log.e(LOGTAG, "Failed to set block inbound", e);
}
});


binding.switchLazyConnection.setOnCheckedChangeListener((buttonView, isChecked) -> {
try {
goPreferences.setLazyConnectionEnabled(isChecked);
goPreferences.commit();
} catch (Exception e) {
Log.e(LOGTAG, "Failed to set lazy connection", e);
}
});

// Make parent layouts clickable to toggle switches (for TV remote)
binding.layoutAllowSsh.setOnClickListener(v -> {
binding.switchAllowSsh.toggle();
});

binding.layoutBlockInbound.setOnClickListener(v -> {
binding.switchBlockInbound.toggle();
});

binding.layoutLazyConnection.setOnClickListener(v -> {
binding.switchLazyConnection.toggle();
});

binding.layoutDisableClientRoutes.setOnClickListener(v -> {
binding.switchDisableClientRoutes.toggle();
Expand Down
51 changes: 50 additions & 1 deletion app/src/main/res/layout/fragment_advanced.xml
Original file line number Diff line number Diff line change
Expand Up @@ -268,7 +268,7 @@
</LinearLayout>

<LinearLayout
android:id="@+id/layout_disable_client_routes"
android:id="@+id/layout_lazy_connection"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginTop="16dp"
Expand All @@ -282,6 +282,55 @@
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/layout_block_inbound">

<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center_vertical"
android:orientation="horizontal">

<TextView
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="@string/advanced_lazy_connection"
android:textColor="@color/nb_txt_light" />

<com.google.android.material.switchmaterial.SwitchMaterial
android:id="@+id/switch_lazy_connection"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:clickable="false"
android:focusable="false" />

</LinearLayout>

<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginStart="0dp"
android:layout_marginTop="2dp"
android:layout_marginEnd="48dp"
android:text="@string/advanced_lazy_connection_desc"
android:textColor="@color/nb_txt_light"
android:textSize="12sp" />

</LinearLayout>

<LinearLayout
android:id="@+id/layout_disable_client_routes"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginTop="16dp"
android:background="@drawable/focus_highlight"
android:clickable="true"
android:focusable="true"
android:focusableInTouchMode="false"
android:orientation="vertical"
android:padding="12dp"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/layout_lazy_connection">

<LinearLayout
android:layout_width="match_parent"
android:layout_height="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 @@ -96,6 +96,8 @@
<string name="advanced_allow_ssh_desc">Allows SSH connections to this device</string>
<string name="advanced_block_inbound">Block inbound connections</string>
<string name="advanced_block_inbound_desc">Blocks all inbound connections to this device and routed networks. This overrides any policies received from the management service</string>
<string name="advanced_lazy_connection">Lazy connection</string>
<string name="advanced_lazy_connection_desc">Defer per-peer connection setup until first actual traffic. Reduces background load but adds latency to the first packet to a peer</string>


<string name="desc_logo">NetBird logo</string>
Expand Down