show hotspot-specific status messages when hotspot is active

This commit is contained in:
Hans-Christoph Steiner 2019-05-24 15:30:23 +02:00
parent b11ac7a64a
commit 9db9f32bf1
4 changed files with 15 additions and 3 deletions

View File

@ -223,6 +223,10 @@ public class StartSwapView extends SwapView {
WifiApControl wifiAp = WifiApControl.getInstance(getActivity());
if (wifiAp != null && wifiAp.isWifiApEnabled()) {
WifiConfiguration config = wifiAp.getConfiguration();
TextView textWifiVisible = findViewById(R.id.wifi_visible);
if (textWifiVisible != null) {
textWifiVisible.setText(R.string.swap_visible_hotspot);
}
viewWifiNetwork.setText(getContext().getString(R.string.swap_active_hotspot, config.SSID));
} else if (TextUtils.isEmpty(FDroidApp.ssid)) {
// not connected to or setup with any wifi network

View File

@ -117,6 +117,7 @@ public class SwapWorkflowActivity extends AppCompatActivity {
private NewRepoConfig confirmSwapConfig;
private LocalBroadcastManager localBroadcastManager;
private WifiManager wifiManager;
private WifiApControl wifiApControl;
private BluetoothAdapter bluetoothAdapter;
@LayoutRes
@ -227,6 +228,7 @@ public class SwapWorkflowActivity extends AppCompatActivity {
new IntentFilter(Downloader.ACTION_INTERRUPTED));
wifiManager = (WifiManager) getApplicationContext().getSystemService(Context.WIFI_SERVICE);
wifiApControl = WifiApControl.getInstance(this);
bluetoothAdapter = BluetoothAdapter.getDefaultAdapter();
@ -442,7 +444,6 @@ public class SwapWorkflowActivity extends AppCompatActivity {
}
private void setupWifiAP() {
WifiApControl wifiApControl = WifiApControl.getInstance(this);
if (wifiApControl == null) {
Log.e(TAG, "WiFi AP is null");
Toast.makeText(this, R.string.swap_toast_could_not_enable_hotspot, Toast.LENGTH_LONG).show();
@ -1052,7 +1053,11 @@ public class SwapWorkflowActivity extends AppCompatActivity {
peopleNearbyProgress.setVisibility(View.VISIBLE);
break;
case BonjourManager.STATUS_VISIBLE:
textWifiVisible.setText(R.string.swap_visible_wifi);
if (wifiApControl != null && wifiApControl.isEnabled()) {
textWifiVisible.setText(R.string.swap_visible_hotspot);
} else {
textWifiVisible.setText(R.string.swap_visible_wifi);
}
peopleNearbyText.setText(R.string.swap_scanning_for_peers);
peopleNearbyText.setVisibility(View.VISIBLE);
peopleNearbyProgress.setVisibility(View.VISIBLE);

View File

@ -39,7 +39,7 @@
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
tools:text="No network yet"
tools:text="@string/swap_no_wifi_network"
android:id="@+id/wifi_ssid"
style="@style/SwapTheme.Wizard.WifiSSID"
android:layout_below="@id/wifi_icon"

View File

@ -477,6 +477,9 @@ This often occurs with apps installed via Google Play or other sources, if they
<string name="swap_success">Swap success!</string>
<string name="swap_no_wifi_network">No network yet</string>
<string name="swap_active_hotspot">%1$s (your hotspot)</string>
<string name="swap_visible_hotspot">Visible via hotspot</string>
<string name="swap_setting_up_hotspot">Setting up hotspot…</string>
<string name="swap_stopping_hotspot">Stopping hotspot…</string>
<string name="swap_view_available_networks">Tap to open available networks</string>
<string name="swap_switch_to_wifi">Tap to switch to a Wi-Fi network</string>
<string name="open_qr_code_scanner">Open QR Scanner</string>