Show message when touching the QRCode button, but swap isn't enabled.

Also cleaned up a doc comment in the swap activity, and minor
formatting of swap related strings in strings.xml.
This commit is contained in:
Peter Serwylo 2015-08-17 08:19:30 +10:00
parent 930c906460
commit 99ebc84a91
4 changed files with 33 additions and 11 deletions

View File

@ -372,6 +372,8 @@
<string name="loading">Loading…</string>
<string name="swap_attempt_install">TRY TO INSTALL</string>
<string name="swap_connection_misc_error">An error occurred while connecting to device, we can\'t seem to swap with it :(</string>
<string name="swap_not_enabled">Swapping not enabled</string>
<string name="swap_not_enabled_description">Before swapping, your device must be made visible.</string>
<string name="install_confirm">Do you want to install this application?
It will get access to:</string>

View File

@ -58,8 +58,7 @@ import java.util.TimerTask;
/**
* Central service which manages all of the different moving parts of swap which are required
* to enable p2p swapping of apps. Currently manages WiFi and NFC. Will manage Bluetooth in
* the future.
* to enable p2p swapping of apps.
*
* TODO: Show "Waiting for other device to finish setting up swap" when only F-Droid shown in swap
* TODO: Handle "not connected to wifi" more gracefully. For example, Bonjour discovery falls over.
@ -68,6 +67,7 @@ import java.util.TimerTask;
* TODO: Feedback for "Setting up (wifi|bluetooth)" in start swap view is not as immediate as I had hoped.
* TODO: Turn off bluetooth after cancelling/timing out if we turned it on.
* TODO: Disable the Scan QR button unless visible via something. Could equally show relevant feedback.
* TODO: Implement "Send F-Droid" on the main page.
*
* TODO: Starting wifi after cancelling swap and beginning again doesn't work properly
* TODO: Scan QR hangs when updating repoo. Swapper was 2.3.3 and Swappee was 5.0

View File

@ -141,7 +141,7 @@ public class StartSwapView extends ScrollView implements SwapWorkflowActivity.In
findViewById(R.id.btn_qr_scanner).setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
getActivity().showSelectApps();
getActivity().startQrWorkflow();
}
});
}

View File

@ -5,6 +5,7 @@ import android.app.ProgressDialog;
import android.content.ComponentName;
import android.bluetooth.BluetoothAdapter;
import android.content.Context;
import android.content.DialogInterface;
import android.content.Intent;
import android.content.ServiceConnection;
import android.net.Uri;
@ -17,6 +18,7 @@ import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import android.support.v4.app.NavUtils;
import android.support.v4.content.LocalBroadcastManager;
import android.support.v7.app.AlertDialog;
import android.support.v7.app.AppCompatActivity;
import android.support.v7.widget.Toolbar;
import android.util.Log;
@ -332,6 +334,24 @@ public class SwapWorkflowActivity extends AppCompatActivity {
((ConfirmReceive)inflateInnerView(R.layout.swap_confirm_receive)).setup(config);
}
public void startQrWorkflow() {
if (!getService().isEnabled()) {
new AlertDialog.Builder(this)
.setTitle(R.string.swap_not_enabled)
.setMessage(R.string.swap_not_enabled_description)
.setCancelable(true)
.setPositiveButton(android.R.string.ok, new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
// Do nothing. The dialog will get dismissed anyway, which is all we ever wanted...
}
})
.create().show();
} else {
showSelectApps();
}
}
public void showSelectApps() {
inflateInnerView(R.layout.swap_select_apps);
}