initial sketch of how to display hotspot mode on the swap wifi screen

This is really just a placeholder, there is lots of work to be done here.
Really, this screen should have the SSID of the hotspot, but we need to use
a private API to get that.  Coming soon...

The icon is free software from:
https://commons.wikimedia.org/wiki/File:Wifi.svg
This commit is contained in:
Hans-Christoph Steiner 2015-05-10 00:06:26 -04:00
parent 962a2fb3d6
commit 12b3a5af12
6 changed files with 29 additions and 4 deletions

Binary file not shown.

After

Width:  |  Height:  |  Size: 9.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 20 KiB

View File

@ -299,6 +299,7 @@
<string name="app_description">F-Droid is an installable catalogue of FOSS (Free and Open Source Software) applications for the Android platform. The client makes it easy to browse, install, and keep track of updates on your device.</string>
<string name="swap_nfc_description">If your friend has <b>F-Droid and NFC turned on</b> touch your phones together.</string>
<string name="swap_join_same_wifi">Join the same Wifi as your friend</string>
<string name="swap_join_this_hotspot">Help your friend join your hotspot</string>
<string name="swap_use_bluetooth">Use Bluetooth instead</string>
<string name="swap_wifi_help">Learn more about Wifi</string>
<string name="menu_swap">Swap apps</string>
@ -306,7 +307,9 @@
<string name="swap_repo_name">Swap</string>
<string name="swap_success">Swap success!</string>
<string name="swap_no_wifi_network">No network yet</string>
<string name="swap_active_hotspot">Your hotspot is active</string>
<string name="swap_view_available_networks">(Tap to open available networks)</string>
<string name="swap_switch_to_wifi">(Tap to switch to a WiFi network)</string>
<string name="swap_wifi_qr_not_working">It\'s not working</string>
<string name="open_qr_code_scanner">Open QR Code Scanner</string>
<string name="swap_welcome">Welcome to F-Droid!</string>

View File

@ -17,6 +17,7 @@ import android.view.MenuInflater;
import android.view.MenuItem;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.TextView;
import org.fdroid.fdroid.FDroidApp;
@ -74,10 +75,31 @@ public class JoinWifiFragment extends Fragment {
}
private void refreshWifiState() {
if (getView() != null) {
TextView ssidView = (TextView) getView().findViewById(R.id.wifi_ssid);
String text = TextUtils.isEmpty(FDroidApp.ssid) ? getString(R.string.swap_no_wifi_network) : FDroidApp.ssid;
ssidView.setText(text);
View view = getView();
if (view != null) {
TextView descriptionView = (TextView) view.findViewById(R.id.text_description);
ImageView wifiIcon = (ImageView) view.findViewById(R.id.wifi_icon);
TextView ssidView = (TextView) view.findViewById(R.id.wifi_ssid);
TextView tapView = (TextView) view.findViewById(R.id.wifi_available_networks_prompt);
if (TextUtils.isEmpty(FDroidApp.bssid) && !TextUtils.isEmpty(FDroidApp.ipAddressString)) {
// empty bssid with an ipAddress means hotspot mode
descriptionView.setText(R.string.swap_join_this_hotspot);
wifiIcon.setImageDrawable(getResources().getDrawable(R.drawable.hotspot));
ssidView.setText(R.string.swap_active_hotspot);
tapView.setText(R.string.swap_switch_to_wifi);
} else if (TextUtils.isEmpty(FDroidApp.ssid)) {
// not connected to or setup with any wifi network
descriptionView.setText(R.string.swap_join_same_wifi);
wifiIcon.setImageDrawable(getResources().getDrawable(R.drawable.wifi));
ssidView.setText(R.string.swap_no_wifi_network);
tapView.setText(R.string.swap_view_available_networks);
} else {
// connected to a regular wifi network
descriptionView.setText(R.string.swap_join_same_wifi);
wifiIcon.setImageDrawable(getResources().getDrawable(R.drawable.wifi));
ssidView.setText(FDroidApp.ssid);
tapView.setText(R.string.swap_view_available_networks);
}
}
}