Commit dc1a81bb authored by Kirk Rader's avatar Kirk Rader

push logic for deciding what intents to filter for during foreground dispatch...

push logic for deciding what intents to filter for during foreground dispatch down to the derived classes
parent b7d17526
......@@ -2,8 +2,8 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
package="us.rader.wyfy"
android:versionCode="201"
android:versionName="2.1" >
android:versionCode="202"
android:versionName="2.2" >
<uses-sdk
android:minSdkVersion="10"
......
......@@ -15,15 +15,15 @@
<ul>
<li>Enter wi fi parameters in the UI (SSID, security protocol,
password etc.)</li>
<li><p>Enter wi fi parameters in the UI (SSID, security
protocol, password etc.)</p></li>
<li>Write those parameters to a NDEF-compatible NFC tag</li>
<li><p>Write those parameters to a NDEF-compatible NFC tag</p></li>
<li>Share those parameters as QR code image</li>
<li><p>Share those parameters as QR code image</p></li>
<li>Connect to a wi fi network automatically by tapping a NFC tag
created by this app</li>
<li><p>Connect to a wi fi network automatically by tapping a
NFC tag created by this app</p></li>
</ul>
......@@ -49,20 +49,20 @@
<ul>
<li>It is small and lightweight, focused exactly on its intended
purpose</li>
<li><p>It is small and lightweight, focused exactly on its
intended purpose</p></li>
<li>It requests no permissions beyond those it actually needs for
its user-visible functionality (NFC, wi fi settings)</li>
<li><p>It requests no permissions beyond those it actually
needs for its user-visible functionality (NFC, wi fi settings)</p></li>
<li>It is completely ad free, generates no notification-bar spam
or the like</li>
<li><p>It is completely ad free, generates no
notification-bar spam or the like</p></li>
<li>It is open-source, offering the opportunity not only to
verify that it does not contain any malware but also to use it as an
example of how to accomplish a number of Android app programming
tasks (app life-cycle, sharing via intents and content providers, NFC
etc.)</li>
<li><p>It is open-source, offering the opportunity not only
to verify that it does not contain any malware but also to use it as
an example of how to accomplish a number of Android app programming
tasks (app life-cycle, sharing via intents and content providers,
NFC etc.)</p></li>
</ul>
......
......@@ -258,6 +258,15 @@ public abstract class ForegroundDispatchActivity<ResultType extends Parcelable>
}
/**
* Create the {@link IntentFilter} array to use when foreground dispatch is
* enabled
*
* @return {@link IntentFilter} that includes filters(s) for the tags and
* technologies supported by the derived class
*/
protected abstract IntentFilter[] createIntentFilters();
/**
* Initialize the data structures used in conjunction with foreground
* dispatch
......@@ -275,11 +284,7 @@ public abstract class ForegroundDispatchActivity<ResultType extends Parcelable>
Intent intent = new Intent(this, getClass());
intent.addFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP);
pendingIntent = PendingIntent.getActivity(this, requestCode, intent, 0);
IntentFilter ndefFilter = new IntentFilter(
NfcAdapter.ACTION_NDEF_DISCOVERED);
IntentFilter tagFilter = new IntentFilter(
NfcAdapter.ACTION_TAG_DISCOVERED);
filters = new IntentFilter[] { ndefFilter, tagFilter };
filters = createIntentFilters();
}
......
......@@ -19,8 +19,10 @@ import java.io.UnsupportedEncodingException;
import java.util.Locale;
import us.rader.wyfy.R;
import android.content.IntentFilter;
import android.nfc.NdefMessage;
import android.nfc.NdefRecord;
import android.nfc.NfcAdapter;
import android.nfc.Tag;
import android.nfc.tech.Ndef;
import android.util.Log;
......@@ -254,6 +256,26 @@ public abstract class NdefReaderActivity extends
}
/**
* Create the {@link IntentFilter} array to use when foreground dispatch is
* enabled
*
* @return {@link IntentFilter} array that selects NDEF formatted and
* unformatted tag
*
* @see us.rader.wyfy.nfc.ForegroundDispatchActivity#createIntentFilters()
*/
@Override
protected final IntentFilter[] createIntentFilters() {
IntentFilter ndefFilter = new IntentFilter(
NfcAdapter.ACTION_NDEF_DISCOVERED);
IntentFilter tagFilter = new IntentFilter(
NfcAdapter.ACTION_TAG_DISCOVERED);
return new IntentFilter[] { ndefFilter, tagFilter };
}
/**
* Extract an {@link NdefMessage} from the given {@link Tag}
*
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment