Merge branch 'fix-267/nfc-swap' into 'master'

NFC swap now goes to confirm swap, not manage repos activity.

The NFC message now is handled by the FDroid activity, so it is treated
the same way as every other incoming repo URL. Because FDroid handles
incoming intents correctly, the NFC one just magically works when
the <intent-filter> is moved from ManageReposAcivity to FDroid without
further code changes.

The other change is that the two way swap only happens when both are
actually swapping. Otherwise, we will send a request for someone to
swap with us, when we are incapable of swapping with them.

Fixes #267.

See merge request !91
This commit is contained in:
Peter Serwylo 2015-06-15 09:28:24 +00:00
commit 435fc27e31
2 changed files with 18 additions and 14 deletions

View File

@ -207,6 +207,20 @@
<data android:path="/store/search" />
</intent-filter>
<!-- Handle NFC tags detected from outside our application -->
<intent-filter>
<action android:name="android.nfc.action.NDEF_DISCOVERED" />
<category android:name="android.intent.category.DEFAULT" />
<!--
URIs that come in via NFC have scheme/host normalized to all lower case
https://developer.android.com/reference/android/nfc/NfcAdapter.html#ACTION_NDEF_DISCOVERED
-->
<data android:scheme="fdroidrepo" />
<data android:scheme="fdroidrepos" />
</intent-filter>
<!-- Repo URLs -->
<!--
@ -308,19 +322,6 @@
<meta-data
android:name="android.support.PARENT_ACTIVITY"
android:value=".FDroid" />
<!-- Handle NFC tags detected from outside our application -->
<intent-filter>
<action android:name="android.nfc.action.NDEF_DISCOVERED" />
<category android:name="android.intent.category.DEFAULT" />
<!--
URIs that come in via NFC have scheme/host normalized to all lower case
https://developer.android.com/reference/android/nfc/NfcAdapter.html#ACTION_NDEF_DISCOVERED
-->
<data android:scheme="fdroidrepo" />
<data android:scheme="fdroidrepos" />
</intent-filter>
<intent-filter>
<action android:name="android.intent.action.VIEW" />

View File

@ -156,7 +156,10 @@ public class ConnectSwapActivity extends ActionBarActivity implements ProgressLi
RepoProvider.Helper.update(this, repo, values);
}
if (!newRepoConfig.preventFurtherSwaps()) {
// Only ask server to swap with us, if we are actually running a local repo service.
// It is possible to have a swap initiated without first starting a swap, in which
// case swapping back is pointless.
if (!newRepoConfig.preventFurtherSwaps() && FDroidApp.isLocalRepoServiceRunning()) {
askServerToSwapWithUs();
}