diff --git a/F-Droid/res/drawable-hdpi/ic_network_wifi_white.png b/F-Droid/res/drawable-hdpi/ic_network_wifi_white.png
new file mode 100644
index 000000000..75469cd85
Binary files /dev/null and b/F-Droid/res/drawable-hdpi/ic_network_wifi_white.png differ
diff --git a/F-Droid/res/drawable-mdpi/ic_network_wifi_white.png b/F-Droid/res/drawable-mdpi/ic_network_wifi_white.png
new file mode 100644
index 000000000..ca927f3de
Binary files /dev/null and b/F-Droid/res/drawable-mdpi/ic_network_wifi_white.png differ
diff --git a/F-Droid/res/drawable-xhdpi/ic_network_wifi_white.png b/F-Droid/res/drawable-xhdpi/ic_network_wifi_white.png
new file mode 100644
index 000000000..eb284e383
Binary files /dev/null and b/F-Droid/res/drawable-xhdpi/ic_network_wifi_white.png differ
diff --git a/F-Droid/res/drawable-xxhdpi/ic_network_wifi_white.png b/F-Droid/res/drawable-xxhdpi/ic_network_wifi_white.png
new file mode 100644
index 000000000..fb9821e49
Binary files /dev/null and b/F-Droid/res/drawable-xxhdpi/ic_network_wifi_white.png differ
diff --git a/F-Droid/res/drawable-xxxhdpi/ic_network_wifi_white.png b/F-Droid/res/drawable-xxxhdpi/ic_network_wifi_white.png
new file mode 100644
index 000000000..57f4dcc9b
Binary files /dev/null and b/F-Droid/res/drawable-xxxhdpi/ic_network_wifi_white.png differ
diff --git a/F-Droid/res/drawable/ic_network_wifi_white.png b/F-Droid/res/drawable/ic_network_wifi_white.png
new file mode 100644
index 000000000..ca927f3de
Binary files /dev/null and b/F-Droid/res/drawable/ic_network_wifi_white.png differ
diff --git a/F-Droid/res/layout/swap_blank.xml b/F-Droid/res/layout/swap_blank.xml
index 6c846d00b..5113fbf6b 100644
--- a/F-Droid/res/layout/swap_blank.xml
+++ b/F-Droid/res/layout/swap_blank.xml
@@ -1,23 +1,174 @@
+
+
+ android:layout_height="120dp">
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ tools:text="Can't find who you're looking for?" />
-
\ No newline at end of file
diff --git a/F-Droid/res/values/strings.xml b/F-Droid/res/values/strings.xml
index c7bb99b45..6cbf676e7 100644
--- a/F-Droid/res/values/strings.xml
+++ b/F-Droid/res/values/strings.xml
@@ -317,8 +317,6 @@
Open QR Scanner
Welcome to F-Droid!
Do you want to get apps from %1$s now?
- Your mobile device becomes an app store with Swap!
- START A SWAP
An error occurred while attempting to swap with another device. We will still try to get apps from them, but they may not be able to get apps from us.
Tap to select the apps you want to swap.
Don\'t show this again
@@ -333,4 +331,5 @@
Best bet
Choose Apps
Scan QR Code
+ Nearby Swap
diff --git a/F-Droid/src/org/fdroid/fdroid/localrepo/SwapManager.java b/F-Droid/src/org/fdroid/fdroid/localrepo/SwapManager.java
index 90803d306..cf4067415 100644
--- a/F-Droid/src/org/fdroid/fdroid/localrepo/SwapManager.java
+++ b/F-Droid/src/org/fdroid/fdroid/localrepo/SwapManager.java
@@ -1,5 +1,6 @@
package org.fdroid.fdroid.localrepo;
+import android.bluetooth.BluetoothAdapter;
import android.content.ComponentName;
import android.content.Context;
import android.content.Intent;
@@ -222,4 +223,37 @@ public class SwapManager {
public boolean isEnabled() {
return service != null && service.isEnabled();
}
+
+ // ==========================================
+ // Interacting with Bluetooth adapter
+ // ==========================================
+
+ @Nullable /* Emulators tend not to have bluetooth adapters. */
+ private final BluetoothAdapter bluetooth = BluetoothAdapter.getDefaultAdapter();
+
+ public boolean isBluetoothDiscoverable() {
+ return bluetooth != null &&
+ bluetooth.getScanMode() == BluetoothAdapter.SCAN_MODE_CONNECTABLE_DISCOVERABLE;
+ }
+
+ public void ensureBluetoothDiscoverable() {
+
+ if (bluetooth == null) {
+ return;
+ }
+
+ if (!bluetooth.isEnabled()) {
+ if (!bluetooth.enable()) {
+
+ }
+ }
+
+ if (bluetooth.isEnabled()) {
+ Intent discoverableIntent = new Intent(BluetoothAdapter.ACTION_REQUEST_DISCOVERABLE);
+ discoverableIntent.putExtra(BluetoothAdapter.EXTRA_DISCOVERABLE_DURATION, 0);
+ context.startActivity(discoverableIntent);
+ }
+
+ }
+
}
diff --git a/F-Droid/src/org/fdroid/fdroid/views/swap/StartSwapView.java b/F-Droid/src/org/fdroid/fdroid/views/swap/StartSwapView.java
index 13d240358..f9f9c50aa 100644
--- a/F-Droid/src/org/fdroid/fdroid/views/swap/StartSwapView.java
+++ b/F-Droid/src/org/fdroid/fdroid/views/swap/StartSwapView.java
@@ -1,17 +1,24 @@
package org.fdroid.fdroid.views.swap;
import android.annotation.TargetApi;
+import android.bluetooth.BluetoothAdapter;
import android.content.Context;
+import android.content.Intent;
import android.os.Build;
import android.support.annotation.ColorRes;
import android.support.annotation.NonNull;
+import android.support.annotation.Nullable;
import android.util.AttributeSet;
import android.view.Menu;
import android.view.MenuInflater;
import android.view.View;
+import android.widget.CompoundButton;
import android.widget.LinearLayout;
+import android.widget.Switch;
+import android.widget.TextView;
import org.fdroid.fdroid.R;
+import org.fdroid.fdroid.compat.SwitchCompat;
import org.fdroid.fdroid.localrepo.SwapManager;
public class StartSwapView extends LinearLayout implements SwapWorkflowActivity.InnerView {
@@ -45,17 +52,52 @@ public class StartSwapView extends LinearLayout implements SwapWorkflowActivity.
return (SwapWorkflowActivity)getContext();
}
+ private SwapManager getManager() {
+ return getActivity().getState();
+ }
+
+ @Nullable /* Emulators typically don't have bluetooth adapters */
+ private final BluetoothAdapter bluetooth = BluetoothAdapter.getDefaultAdapter();
+
+ private TextView viewBluetoothId;
+
@Override
protected void onFinishInflate() {
super.onFinishInflate();
- findViewById(R.id.button_start_swap).setOnClickListener(new View.OnClickListener() {
+ if (bluetooth != null) {
+
+ viewBluetoothId = (TextView)findViewById(R.id.device_id_bluetooth);
+ viewBluetoothId.setText(bluetooth.getName());
+
+ Switch bluetoothSwitch = ((Switch) findViewById(R.id.switch_bluetooth));
+ bluetoothSwitch.setChecked(getManager().isBluetoothDiscoverable());
+ bluetoothSwitch.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
+ @Override
+ public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
+ if (isChecked) {
+ getManager().ensureBluetoothDiscoverable();
+ } else {
+ // disableBluetooth();
+ }
+ }
+ });
+ } else {
+ findViewById(R.id.bluetooth_info).setVisibility(View.GONE);
+ }
+
+ ((Switch)findViewById(R.id.switch_wifi)).setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
@Override
- public void onClick(View v) {
- getActivity().showSelectApps();
+ public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
+ if (isChecked) {
+ enableWifi();
+ } else {
+ disableWifi();
+ }
}
});
+
}
@Override
@@ -85,6 +127,19 @@ public class StartSwapView extends LinearLayout implements SwapWorkflowActivity.
@Override
public String getToolbarTitle() {
- return getResources().getString(R.string.swap_start);
+ return getResources().getString(R.string.swap_nearby);
+ }
+
+
+ // ========================================================================
+ // Wifi stuff
+ // ========================================================================
+
+ private void enableWifi() {
+
+ }
+
+ private void disableWifi() {
+
}
}