Skip to content

Commit 77bc67f

Browse files
MichaelUrayclaude
andcommitted
android: remove Force-Relay switch (replaced by Connection-Mode picker)
Phase 3.7h finalisation. The standalone "Force relay connection" toggle in Advanced Settings is removed because the new Connection-Mode picker (landed earlier on this branch) supersedes it. Preferences key and EnvVarPackager NB_FORCE_RELAY plumbing are removed too so the setting no longer leaks into NetBird via env vars. Bumps netbird submodule to include the matching ServerPushed-getter commits from the netbird repo. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
1 parent 4f2c2f8 commit 77bc67f

6 files changed

Lines changed: 3 additions & 71 deletions

File tree

app/src/main/java/io/netbird/client/ui/advanced/AdvancedFragment.java

Lines changed: 0 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -17,12 +17,10 @@
1717
import android.widget.Toast;
1818

1919
import androidx.annotation.NonNull;
20-
import androidx.appcompat.app.AlertDialog;
2120
import androidx.appcompat.app.AppCompatDelegate;
2221
import androidx.fragment.app.Fragment;
2322

2423
import io.netbird.client.R;
25-
import io.netbird.client.databinding.ComponentSwitchBinding;
2624
import io.netbird.client.databinding.FragmentAdvancedBinding;
2725
import io.netbird.client.tool.Preferences;
2826
import io.netbird.client.tool.ProfileManagerWrapper;
@@ -36,38 +34,6 @@ public class AdvancedFragment extends Fragment {
3634
private FragmentAdvancedBinding binding;
3735
private io.netbird.gomobile.android.Preferences goPreferences;
3836

39-
private void showReconnectionNeededWarningDialog() {
40-
final View dialogView = getLayoutInflater().inflate(R.layout.dialog_simple_alert_message, null);
41-
final AlertDialog alertDialog = new AlertDialog.Builder(requireContext(), R.style.AlertDialogTheme)
42-
.setView(dialogView)
43-
.create();
44-
45-
((TextView)dialogView.findViewById(R.id.txt_dialog)).setText(R.string.reconnectionNeededWarningMessage);
46-
dialogView.findViewById(R.id.btn_ok_dialog).setOnClickListener(v -> alertDialog.dismiss());
47-
alertDialog.show();
48-
}
49-
50-
private void configureForceRelayConnectionSwitch(@NonNull ComponentSwitchBinding binding, @NonNull Preferences preferences) {
51-
binding.switchTitle.setText(R.string.advanced_force_relay_conn);
52-
binding.switchDescription.setText(R.string.advanced_force_relay_conn_desc);
53-
54-
binding.switchControl.setChecked(preferences.isConnectionForceRelayed());
55-
binding.switchControl.setOnCheckedChangeListener((buttonView, isChecked) -> {
56-
if (isChecked) {
57-
preferences.enableForcedRelayConnection();
58-
} else {
59-
preferences.disableForcedRelayConnection();
60-
}
61-
62-
showReconnectionNeededWarningDialog();
63-
});
64-
65-
// Make parent layout clickable to toggle switch (for TV remote)
66-
binding.getRoot().setOnClickListener(v -> {
67-
binding.switchControl.toggle();
68-
});
69-
}
70-
7137
public View onCreateView(@NonNull LayoutInflater inflater,
7238
ViewGroup container, Bundle savedInstanceState) {
7339

@@ -163,8 +129,6 @@ public View onCreateView(@NonNull LayoutInflater inflater,
163129
binding.switchRosenpassPermissive.toggle();
164130
});
165131

166-
configureForceRelayConnectionSwitch(binding.layoutForceRelayConnection, preferences);
167-
168132
// Initialize engine config switches (your settings)
169133
initializeEngineConfigSwitches();
170134

app/src/main/res/layout/fragment_advanced.xml

Lines changed: 1 addition & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -567,17 +567,6 @@
567567

568568
</LinearLayout>
569569

570-
<include
571-
android:id="@+id/layout_force_relay_connection"
572-
layout="@layout/component_switch"
573-
android:layout_width="0dp"
574-
android:layout_height="wrap_content"
575-
android:layout_marginTop="16dp"
576-
android:orientation="vertical"
577-
app:layout_constraintEnd_toEndOf="parent"
578-
app:layout_constraintStart_toStartOf="parent"
579-
app:layout_constraintTop_toBottomOf="@id/layout_disable_firewall" />
580-
581570
<LinearLayout
582571
android:id="@+id/layout_theme"
583572
android:layout_width="0dp"
@@ -586,7 +575,7 @@
586575
android:orientation="vertical"
587576
app:layout_constraintEnd_toEndOf="parent"
588577
app:layout_constraintStart_toStartOf="parent"
589-
app:layout_constraintTop_toBottomOf="@id/layout_force_relay_connection">
578+
app:layout_constraintTop_toBottomOf="@id/layout_disable_firewall">
590579

591580
<TextView
592581
android:layout_width="wrap_content"

app/src/main/res/values/strings.xml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -117,8 +117,6 @@
117117
<string name="advanced_theme_dark">Dark</string>
118118
<string name="advanced_theme_light">Light</string>
119119
<string name="advanced_theme_desc">Choose the app appearance mode.</string>
120-
<string name="advanced_force_relay_conn">Force relay connection</string>
121-
<string name="advanced_force_relay_conn_desc">Forces usage of relay when connecting to peers</string>
122120
<string name="exclamation_mark">exclamation mark</string>
123121
<string name="reconnectionNeededWarningMessage">To apply the setting, you will need to reconnect.</string>
124122
<string name="change_server_setup_key_warning">Using setup keys for user devices is not recommended. SSO with MFA provides stronger security, proper user-device association, and periodic re-authentication.</string>
Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,9 @@
11
package io.netbird.client.tool;
22

3-
import io.netbird.gomobile.android.Android;
43
import io.netbird.gomobile.android.EnvList;
54

65
public class EnvVarPackager {
76
public static EnvList getEnvironmentVariables(Preferences preferences) {
8-
var envList = new EnvList();
9-
10-
envList.put(Android.getEnvKeyNBForceRelay(), String.valueOf(preferences.isConnectionForceRelayed()));
11-
12-
return envList;
7+
return new EnvList();
138
}
149
}

tool/src/main/java/io/netbird/client/tool/Preferences.java

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,6 @@ public class Preferences {
77

88
private final String keyTraceLog = "tracelog";
99

10-
private final String keyForceRelayConnection = "isConnectionForceRelayed";
11-
1210
private final SharedPreferences sharedPref;
1311

1412
public Preferences(Context context) {
@@ -26,18 +24,6 @@ public void disableTraceLog() {
2624
sharedPref.edit().putBoolean(keyTraceLog, false).apply();
2725
}
2826

29-
public boolean isConnectionForceRelayed() {
30-
return sharedPref.getBoolean(keyForceRelayConnection, true);
31-
}
32-
33-
public void enableForcedRelayConnection() {
34-
sharedPref.edit().putBoolean(keyForceRelayConnection, true).apply();
35-
}
36-
37-
public void disableForcedRelayConnection() {
38-
sharedPref.edit().putBoolean(keyForceRelayConnection, false).apply();
39-
}
40-
4127
public static String defaultServer() {
4228
return "https://api.netbird.io";
4329
}

0 commit comments

Comments
 (0)