added support for configuration URIs
http://frankmorgner.github.io/vsmartcard/remote-reader/README.html?host=1.1.1.1&port=123 https://frankmorgner.github.io/vsmartcard/remote-reader/README.html?host=1.1.1.1&port=123 vpcd://1.1.1.1:123
This commit is contained in:
10
remote-reader/.idea/libraries/appcompat_v7_19_1_0.xml
generated
Normal file
10
remote-reader/.idea/libraries/appcompat_v7_19_1_0.xml
generated
Normal file
@@ -0,0 +1,10 @@
|
|||||||
|
<component name="libraryTable">
|
||||||
|
<library name="appcompat-v7-19.1.0">
|
||||||
|
<CLASSES>
|
||||||
|
<root url="file://$PROJECT_DIR$/build/intermediates/exploded-aar/com.android.support/appcompat-v7/19.1.0/res" />
|
||||||
|
<root url="jar://$PROJECT_DIR$/build/intermediates/exploded-aar/com.android.support/appcompat-v7/19.1.0/classes.jar!/" />
|
||||||
|
</CLASSES>
|
||||||
|
<JAVADOC />
|
||||||
|
<SOURCES />
|
||||||
|
</library>
|
||||||
|
</component>
|
||||||
11
remote-reader/.idea/libraries/support_v4_19_1_0.xml
generated
Normal file
11
remote-reader/.idea/libraries/support_v4_19_1_0.xml
generated
Normal file
@@ -0,0 +1,11 @@
|
|||||||
|
<component name="libraryTable">
|
||||||
|
<library name="support-v4-19.1.0">
|
||||||
|
<CLASSES>
|
||||||
|
<root url="jar://$APPLICATION_HOME_DIR$/sdk/extras/android/m2repository/com/android/support/support-v4/19.1.0/support-v4-19.1.0.jar!/" />
|
||||||
|
</CLASSES>
|
||||||
|
<JAVADOC />
|
||||||
|
<SOURCES>
|
||||||
|
<root url="jar://$APPLICATION_HOME_DIR$/sdk/extras/android/m2repository/com/android/support/support-v4/19.1.0/support-v4-19.1.0-sources.jar!/" />
|
||||||
|
</SOURCES>
|
||||||
|
</library>
|
||||||
|
</component>
|
||||||
@@ -14,7 +14,10 @@
|
|||||||
android:theme="@style/AppTheme" >
|
android:theme="@style/AppTheme" >
|
||||||
<activity
|
<activity
|
||||||
android:name="com.vsmartcard.remotesmartcardreader.app.MainActivity"
|
android:name="com.vsmartcard.remotesmartcardreader.app.MainActivity"
|
||||||
android:label="@string/app_name" >
|
android:label="@string/app_name"
|
||||||
|
android:exported="true"
|
||||||
|
android:launchMode="singleTask" >
|
||||||
|
|
||||||
<intent-filter>
|
<intent-filter>
|
||||||
<action android:name="android.intent.action.MAIN" />
|
<action android:name="android.intent.action.MAIN" />
|
||||||
|
|
||||||
@@ -28,6 +31,29 @@
|
|||||||
android:name="android.nfc.action.TECH_DISCOVERED"
|
android:name="android.nfc.action.TECH_DISCOVERED"
|
||||||
android:resource="@xml/nfc_tech_filter" />
|
android:resource="@xml/nfc_tech_filter" />
|
||||||
|
|
||||||
|
<intent-filter>
|
||||||
|
<action android:name="android.intent.action.VIEW" />
|
||||||
|
<category android:name="android.intent.category.BROWSABLE" />
|
||||||
|
<category android:name="android.intent.category.DEFAULT" />
|
||||||
|
<data android:scheme="@string/scheme_vpcd" />
|
||||||
|
</intent-filter>
|
||||||
|
<intent-filter>
|
||||||
|
<action android:name="android.intent.action.VIEW" />
|
||||||
|
<category android:name="android.intent.category.DEFAULT" />
|
||||||
|
<category android:name="android.intent.category.BROWSABLE" />
|
||||||
|
<data android:scheme="@string/scheme_http"
|
||||||
|
android:host="frankmorgner.github.io"
|
||||||
|
android:pathPattern="/vsmartcard/remote-reader/README.html" />
|
||||||
|
</intent-filter>
|
||||||
|
<intent-filter>
|
||||||
|
<action android:name="android.intent.action.VIEW" />
|
||||||
|
<category android:name="android.intent.category.DEFAULT" />
|
||||||
|
<category android:name="android.intent.category.BROWSABLE" />
|
||||||
|
<data android:scheme="@string/scheme_https"
|
||||||
|
android:host="frankmorgner.github.io"
|
||||||
|
android:pathPattern="/vsmartcard/remote-reader/README.html" />
|
||||||
|
</intent-filter>
|
||||||
|
|
||||||
</activity>
|
</activity>
|
||||||
</application>
|
</application>
|
||||||
|
|
||||||
|
|||||||
@@ -22,20 +22,19 @@ package com.vsmartcard.remotesmartcardreader.app;
|
|||||||
import android.app.Activity;
|
import android.app.Activity;
|
||||||
import android.app.PendingIntent;
|
import android.app.PendingIntent;
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
|
import android.net.Uri;
|
||||||
import android.nfc.NfcAdapter;
|
import android.nfc.NfcAdapter;
|
||||||
|
import android.os.Bundle;
|
||||||
import android.os.Handler;
|
import android.os.Handler;
|
||||||
import android.os.Looper;
|
import android.os.Looper;
|
||||||
import android.os.Message;
|
import android.os.Message;
|
||||||
import android.os.Bundle;
|
|
||||||
import android.text.Editable;
|
import android.text.Editable;
|
||||||
import android.text.Layout;
|
import android.text.Layout;
|
||||||
import android.text.method.LinkMovementMethod;
|
|
||||||
import android.text.method.ScrollingMovementMethod;
|
import android.text.method.ScrollingMovementMethod;
|
||||||
import android.view.KeyEvent;
|
import android.view.KeyEvent;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.view.inputmethod.EditorInfo;
|
import android.view.inputmethod.EditorInfo;
|
||||||
import android.widget.Button;
|
import android.widget.Button;
|
||||||
import android.widget.CheckBox;
|
|
||||||
import android.widget.EditText;
|
import android.widget.EditText;
|
||||||
import android.widget.ProgressBar;
|
import android.widget.ProgressBar;
|
||||||
import android.widget.TextView;
|
import android.widget.TextView;
|
||||||
@@ -43,7 +42,6 @@ import android.widget.TextView;
|
|||||||
import com.vsmartcard.remotesmartcardreader.app.screaders.DummyReader;
|
import com.vsmartcard.remotesmartcardreader.app.screaders.DummyReader;
|
||||||
import com.vsmartcard.remotesmartcardreader.app.screaders.NFCReader;
|
import com.vsmartcard.remotesmartcardreader.app.screaders.NFCReader;
|
||||||
import com.vsmartcard.remotesmartcardreader.app.screaders.SCReader;
|
import com.vsmartcard.remotesmartcardreader.app.screaders.SCReader;
|
||||||
import android.text.ClipboardManager;
|
|
||||||
|
|
||||||
public class MainActivity extends Activity {
|
public class MainActivity extends Activity {
|
||||||
|
|
||||||
@@ -115,7 +113,6 @@ public class MainActivity extends Activity {
|
|||||||
private boolean testing;
|
private boolean testing;
|
||||||
private String hostname;
|
private String hostname;
|
||||||
private String port;
|
private String port;
|
||||||
private String savedLog;
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onCreate(Bundle savedInstanceState) {
|
protected void onCreate(Bundle savedInstanceState) {
|
||||||
@@ -193,7 +190,13 @@ public class MainActivity extends Activity {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void vpcdConnect(SCReader scReader) {
|
private void vpcdConnect(SCReader scReader) {
|
||||||
vpcdTest = new VPCDWorker(hostname, Integer.parseInt(port), scReader, handler);
|
int p = VPCDWorker.DEFAULT_PORT;
|
||||||
|
try {
|
||||||
|
p = Integer.parseInt(port);
|
||||||
|
} catch (NumberFormatException e) {
|
||||||
|
textViewVPCDStatus.append(getResources().getString(R.string.status_default_port)+"\n");
|
||||||
|
}
|
||||||
|
vpcdTest = new VPCDWorker(hostname, p, scReader, handler);
|
||||||
new Thread(vpcdTest).start();
|
new Thread(vpcdTest).start();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -249,14 +252,37 @@ public class MainActivity extends Activity {
|
|||||||
@Override
|
@Override
|
||||||
public void onResume() {
|
public void onResume() {
|
||||||
super.onResume();
|
super.onResume();
|
||||||
|
Intent intent = getIntent();
|
||||||
// Check to see that the Activity started due to a discovered tag
|
// Check to see that the Activity started due to a discovered tag
|
||||||
if (NfcAdapter.ACTION_TECH_DISCOVERED.equals(getIntent().getAction())) {
|
if (NfcAdapter.ACTION_TECH_DISCOVERED.equals(intent.getAction())) {
|
||||||
NFCReader nfcReader = NFCReader.processIntent(getIntent());
|
NFCReader nfcReader = NFCReader.processIntent(intent);
|
||||||
if (nfcReader != null) {
|
if (nfcReader != null) {
|
||||||
textViewVPCDStatus.append(getResources().getString(R.string.status_tag_discovered)+"\n");
|
textViewVPCDStatus.append(getResources().getString(R.string.status_tag_discovered)+"\n");
|
||||||
forceConnect(nfcReader);
|
forceConnect(nfcReader);
|
||||||
} else {
|
} else {
|
||||||
super.onNewIntent(getIntent());
|
super.onNewIntent(intent);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
// Check to see that the Activity started due to a configuration URI
|
||||||
|
if (Intent.ACTION_VIEW.equals(intent.getAction())) {
|
||||||
|
testing = false;
|
||||||
|
vpcdDisconnect();
|
||||||
|
Uri uri = intent.getData();
|
||||||
|
String h = "";
|
||||||
|
String p = "";
|
||||||
|
if (uri.getScheme().equals(getResources().getString(R.string.scheme_vpcd))) {
|
||||||
|
h = uri.getHost();
|
||||||
|
int _p = uri.getPort();
|
||||||
|
if (_p > 0) {
|
||||||
|
p = Integer.toString(_p);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
h = uri.getQueryParameter("host");
|
||||||
|
p = uri.getQueryParameter("port");
|
||||||
|
}
|
||||||
|
editTextVPCDHost.setText(h);
|
||||||
|
editTextVPCDPort.setText(p);
|
||||||
|
super.onNewIntent(intent);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -31,6 +31,7 @@ import java.net.InetAddress;
|
|||||||
import java.net.Socket;
|
import java.net.Socket;
|
||||||
|
|
||||||
public class VPCDWorker implements Runnable, Closeable {
|
public class VPCDWorker implements Runnable, Closeable {
|
||||||
|
public static int DEFAULT_PORT = 35963;
|
||||||
private int port;
|
private int port;
|
||||||
private String hostname;
|
private String hostname;
|
||||||
private SCReader reader;
|
private SCReader reader;
|
||||||
|
|||||||
@@ -23,6 +23,7 @@
|
|||||||
<string name="status_unknown">Unknown Event</string>
|
<string name="status_unknown">Unknown Event</string>
|
||||||
<string name="status_tag_discovered">Contact-less card discovered.</string>
|
<string name="status_tag_discovered">Contact-less card discovered.</string>
|
||||||
<string name="status_dummy_start">Using a dummy card to test the connection.</string>
|
<string name="status_dummy_start">Using a dummy card to test the connection.</string>
|
||||||
|
<string name="status_default_port">Using default port.</string>
|
||||||
|
|
||||||
<string name="menu_copy_to_clipboard">Copy</string>
|
<string name="menu_copy_to_clipboard">Copy</string>
|
||||||
|
|
||||||
@@ -30,4 +31,8 @@
|
|||||||
<string name="verbose">Verbose logging</string>
|
<string name="verbose">Verbose logging</string>
|
||||||
<string name="error_tag_lost">Data transmission failed. Is the card still present?</string>
|
<string name="error_tag_lost">Data transmission failed. Is the card still present?</string>
|
||||||
|
|
||||||
|
<string name="scheme_http">http</string>
|
||||||
|
<string name="scheme_https">https</string>
|
||||||
|
<string name="scheme_vpcd">vpcd</string>
|
||||||
|
|
||||||
</resources>
|
</resources>
|
||||||
|
|||||||
Reference in New Issue
Block a user