Frank Morgner
2014-08-31 22:32:28 +02:00
parent 90892cb40f
commit 2f8ff4a29b
6 changed files with 89 additions and 10 deletions

View 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>

View 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>

View File

@@ -14,7 +14,10 @@
android:theme="@style/AppTheme" >
<activity
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>
<action android:name="android.intent.action.MAIN" />
@@ -28,6 +31,29 @@
android:name="android.nfc.action.TECH_DISCOVERED"
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>
</application>

View File

@@ -22,20 +22,19 @@ package com.vsmartcard.remotesmartcardreader.app;
import android.app.Activity;
import android.app.PendingIntent;
import android.content.Intent;
import android.net.Uri;
import android.nfc.NfcAdapter;
import android.os.Bundle;
import android.os.Handler;
import android.os.Looper;
import android.os.Message;
import android.os.Bundle;
import android.text.Editable;
import android.text.Layout;
import android.text.method.LinkMovementMethod;
import android.text.method.ScrollingMovementMethod;
import android.view.KeyEvent;
import android.view.View;
import android.view.inputmethod.EditorInfo;
import android.widget.Button;
import android.widget.CheckBox;
import android.widget.EditText;
import android.widget.ProgressBar;
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.NFCReader;
import com.vsmartcard.remotesmartcardreader.app.screaders.SCReader;
import android.text.ClipboardManager;
public class MainActivity extends Activity {
@@ -115,7 +113,6 @@ public class MainActivity extends Activity {
private boolean testing;
private String hostname;
private String port;
private String savedLog;
@Override
protected void onCreate(Bundle savedInstanceState) {
@@ -193,7 +190,13 @@ public class MainActivity extends Activity {
}
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();
}
@@ -249,14 +252,37 @@ public class MainActivity extends Activity {
@Override
public void onResume() {
super.onResume();
Intent intent = getIntent();
// Check to see that the Activity started due to a discovered tag
if (NfcAdapter.ACTION_TECH_DISCOVERED.equals(getIntent().getAction())) {
NFCReader nfcReader = NFCReader.processIntent(getIntent());
if (NfcAdapter.ACTION_TECH_DISCOVERED.equals(intent.getAction())) {
NFCReader nfcReader = NFCReader.processIntent(intent);
if (nfcReader != null) {
textViewVPCDStatus.append(getResources().getString(R.string.status_tag_discovered)+"\n");
forceConnect(nfcReader);
} 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);
}
}
}

View File

@@ -31,6 +31,7 @@ import java.net.InetAddress;
import java.net.Socket;
public class VPCDWorker implements Runnable, Closeable {
public static int DEFAULT_PORT = 35963;
private int port;
private String hostname;
private SCReader reader;

View File

@@ -23,6 +23,7 @@
<string name="status_unknown">Unknown Event</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_default_port">Using default port.</string>
<string name="menu_copy_to_clipboard">Copy</string>
@@ -30,4 +31,8 @@
<string name="verbose">Verbose logging</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>