use a material design
allows resetting the emulator
This commit is contained in:
@@ -13,8 +13,10 @@
|
|||||||
android:label="@string/app_name"
|
android:label="@string/app_name"
|
||||||
android:theme="@style/AppTheme" >
|
android:theme="@style/AppTheme" >
|
||||||
<activity
|
<activity
|
||||||
android:name=".MainActivity"
|
android:name="com.vsmartcard.acardemulator.MainActivity"
|
||||||
android:label="@string/app_name" >
|
android:label="@string/app_name"
|
||||||
|
android:theme="@style/AppTheme.NoActionBar"
|
||||||
|
>
|
||||||
<intent-filter>
|
<intent-filter>
|
||||||
<action android:name="android.intent.action.MAIN" />
|
<action android:name="android.intent.action.MAIN" />
|
||||||
|
|
||||||
@@ -25,10 +27,9 @@
|
|||||||
<activity
|
<activity
|
||||||
android:name="com.vsmartcard.acardemulator.SettingsActivity"
|
android:name="com.vsmartcard.acardemulator.SettingsActivity"
|
||||||
android:label="@string/action_settings" >
|
android:label="@string/action_settings" >
|
||||||
>
|
|
||||||
</activity>
|
</activity>
|
||||||
|
|
||||||
<service android:name=".SimulatorService"
|
<service android:name="com.vsmartcard.acardemulator.SimulatorService"
|
||||||
android:exported="true"
|
android:exported="true"
|
||||||
android:permission="android.permission.BIND_NFC_SERVICE">
|
android:permission="android.permission.BIND_NFC_SERVICE">
|
||||||
<intent-filter>
|
<intent-filter>
|
||||||
|
|||||||
@@ -29,20 +29,21 @@ import android.content.Intent;
|
|||||||
import android.content.IntentFilter;
|
import android.content.IntentFilter;
|
||||||
import android.content.SharedPreferences;
|
import android.content.SharedPreferences;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
|
import android.support.design.widget.FloatingActionButton;
|
||||||
|
import android.support.design.widget.Snackbar;
|
||||||
import android.support.v4.content.LocalBroadcastManager;
|
import android.support.v4.content.LocalBroadcastManager;
|
||||||
import android.support.v7.app.ActionBarActivity;
|
import android.support.v7.app.AppCompatActivity;
|
||||||
|
import android.support.v7.widget.Toolbar;
|
||||||
import android.view.Menu;
|
import android.view.Menu;
|
||||||
import android.view.MenuItem;
|
import android.view.MenuItem;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.widget.ScrollView;
|
|
||||||
import android.widget.TextView;
|
import android.widget.TextView;
|
||||||
import android.widget.Toast;
|
import android.widget.Toast;
|
||||||
|
|
||||||
|
|
||||||
public class MainActivity extends ActionBarActivity {
|
public class MainActivity extends AppCompatActivity {
|
||||||
|
|
||||||
private TextView textViewVPCDStatus;
|
private TextView textViewVPCDStatus;
|
||||||
private ScrollView scrollView;
|
|
||||||
private BroadcastReceiver bReceiver = new BroadcastReceiver() {
|
private BroadcastReceiver bReceiver = new BroadcastReceiver() {
|
||||||
@Override
|
@Override
|
||||||
public void onReceive(Context context, Intent intent) {
|
public void onReceive(Context context, Intent intent) {
|
||||||
@@ -60,7 +61,6 @@ public class MainActivity extends ActionBarActivity {
|
|||||||
textViewVPCDStatus.append(getResources().getString(R.string.status_error) + ": " + error + "\n");
|
textViewVPCDStatus.append(getResources().getString(R.string.status_error) + ": " + error + "\n");
|
||||||
if (rapdu != null) {
|
if (rapdu != null) {
|
||||||
textViewVPCDStatus.append(getResources().getString(R.string.status_rapdu) + ": " + rapdu + "\n");
|
textViewVPCDStatus.append(getResources().getString(R.string.status_rapdu) + ": " + rapdu + "\n");
|
||||||
scrollView.fullScroll(View.FOCUS_DOWN);
|
|
||||||
}
|
}
|
||||||
if (deselect != null)
|
if (deselect != null)
|
||||||
textViewVPCDStatus.append(getResources().getString(R.string.status_disconnected) + ": " + deselect + "\n");
|
textViewVPCDStatus.append(getResources().getString(R.string.status_disconnected) + ": " + deselect + "\n");
|
||||||
@@ -88,9 +88,21 @@ public class MainActivity extends ActionBarActivity {
|
|||||||
protected void onCreate(Bundle savedInstanceState) {
|
protected void onCreate(Bundle savedInstanceState) {
|
||||||
super.onCreate(savedInstanceState);
|
super.onCreate(savedInstanceState);
|
||||||
setContentView(R.layout.activity_main);
|
setContentView(R.layout.activity_main);
|
||||||
|
Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
|
||||||
|
setSupportActionBar(toolbar);
|
||||||
|
|
||||||
|
FloatingActionButton fab = (FloatingActionButton) findViewById(R.id.fab);
|
||||||
|
assert fab != null;
|
||||||
|
fab.setOnClickListener(new View.OnClickListener() {
|
||||||
|
@Override
|
||||||
|
public void onClick(View view) {
|
||||||
|
Snackbar.make(view, "Scheduled re-installation of all applets...", Snackbar.LENGTH_LONG)
|
||||||
|
.setAction("Action", null).show();
|
||||||
|
SimulatorService.destroySimulator(getApplicationContext());
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
textViewVPCDStatus = (TextView) findViewById(R.id.textViewLog);
|
textViewVPCDStatus = (TextView) findViewById(R.id.textViewLog);
|
||||||
scrollView = (ScrollView) findViewById(R.id.scrollView);
|
|
||||||
SharedPreferences settings = getSharedPreferences(PREFS, 0);
|
SharedPreferences settings = getSharedPreferences(PREFS, 0);
|
||||||
if (settings.getInt(PREF_LASTVERSION, 0) != BuildConfig.VERSION_CODE) {
|
if (settings.getInt(PREF_LASTVERSION, 0) != BuildConfig.VERSION_CODE) {
|
||||||
showStartupMessage();
|
showStartupMessage();
|
||||||
|
|||||||
@@ -120,7 +120,7 @@ public class SettingsActivity extends AppCompatPreferenceActivity {
|
|||||||
CharSequence aid = switchPreference.getSwitchTextOn();
|
CharSequence aid = switchPreference.getSwitchTextOn();
|
||||||
preference.setSummary("Selectable with AID " + aid);
|
preference.setSummary("Selectable with AID " + aid);
|
||||||
} else {
|
} else {
|
||||||
preference.setSummary("Deactivated");
|
preference.setSummary("Will not be installed");
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// For all other preferences, set the summary to the value's
|
// For all other preferences, set the summary to the value's
|
||||||
|
|||||||
@@ -19,6 +19,7 @@
|
|||||||
|
|
||||||
package com.vsmartcard.acardemulator;
|
package com.vsmartcard.acardemulator;
|
||||||
|
|
||||||
|
import android.content.Context;
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
import android.content.SharedPreferences;
|
import android.content.SharedPreferences;
|
||||||
import android.nfc.cardemulation.HostApduService;
|
import android.nfc.cardemulation.HostApduService;
|
||||||
@@ -63,6 +64,7 @@ public class SimulatorService extends HostApduService {
|
|||||||
public static final String EXTRA_INSTALL = "MSG_INSTALL";
|
public static final String EXTRA_INSTALL = "MSG_INSTALL";
|
||||||
|
|
||||||
private static Simulator simulator = null;
|
private static Simulator simulator = null;
|
||||||
|
private static boolean do_destroy = false;
|
||||||
|
|
||||||
private void createSimulator() {
|
private void createSimulator() {
|
||||||
String aid, name, extra_install = "", extra_error = "";
|
String aid, name, extra_install = "", extra_error = "";
|
||||||
@@ -148,6 +150,8 @@ public class SimulatorService extends HostApduService {
|
|||||||
@Override
|
@Override
|
||||||
public void onCreate () {
|
public void onCreate () {
|
||||||
super.onCreate();
|
super.onCreate();
|
||||||
|
// force reloading applets if requested
|
||||||
|
do_destroy();
|
||||||
|
|
||||||
Log.d("", "Begin transaction");
|
Log.d("", "Begin transaction");
|
||||||
if (useVPCD) {
|
if (useVPCD) {
|
||||||
@@ -170,6 +174,26 @@ public class SimulatorService extends HostApduService {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static void destroySimulator(Context context) {
|
||||||
|
do_destroy = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void do_destroy() {
|
||||||
|
if (do_destroy) {
|
||||||
|
simulator = null;
|
||||||
|
do_destroy = false;
|
||||||
|
Intent i = new Intent(TAG);
|
||||||
|
i.putExtra(EXTRA_DESELECT, "Uninstalled all applets.");
|
||||||
|
LocalBroadcastManager.getInstance(this).sendBroadcast(i);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onDestroy() {
|
||||||
|
do_destroy();
|
||||||
|
super.onDestroy();
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public byte[] processCommandApdu(byte[] capdu, Bundle extras) {
|
public byte[] processCommandApdu(byte[] capdu, Bundle extras) {
|
||||||
Intent i = new Intent(TAG);
|
Intent i = new Intent(TAG);
|
||||||
|
|||||||
@@ -1,21 +1,58 @@
|
|||||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
<android.support.design.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||||
xmlns:tools="http://schemas.android.com/tools"
|
xmlns:tools="http://schemas.android.com/tools"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent"
|
||||||
android:keepScreenOn="true"
|
android:fitsSystemWindows="true"
|
||||||
android:orientation="vertical"
|
tools:context="com.vsmartcard.smartcardemulator.MainActivity">
|
||||||
tools:context="com.vsmartcard.remotesmartcardreader.app.MainActivity">
|
|
||||||
|
|
||||||
<ScrollView
|
<android.support.design.widget.AppBarLayout
|
||||||
|
android:id="@+id/app_bar"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="@dimen/app_bar_height"
|
||||||
|
android:fitsSystemWindows="true"
|
||||||
|
android:theme="@style/AppTheme.AppBarOverlay">
|
||||||
|
|
||||||
|
<android.support.design.widget.CollapsingToolbarLayout
|
||||||
|
android:id="@+id/toolbar_layout"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent"
|
||||||
android:id="@+id/scrollView">
|
android:fitsSystemWindows="true"
|
||||||
|
app:contentScrim="?attr/colorPrimary"
|
||||||
|
app:layout_scrollFlags="scroll|exitUntilCollapsed">
|
||||||
|
|
||||||
|
<android.support.v7.widget.Toolbar
|
||||||
|
android:id="@+id/toolbar"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="?attr/actionBarSize"
|
||||||
|
app:layout_collapseMode="pin"
|
||||||
|
app:popupTheme="@style/AppTheme.PopupOverlay" />
|
||||||
|
|
||||||
|
</android.support.design.widget.CollapsingToolbarLayout>
|
||||||
|
</android.support.design.widget.AppBarLayout>
|
||||||
|
|
||||||
|
<android.support.v4.widget.NestedScrollView xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||||
|
xmlns:tools="http://schemas.android.com/tools"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
app:layout_behavior="@string/appbar_scrolling_view_behavior"
|
||||||
|
tools:context="com.vsmartcard.remotesmartcardreader.app.MainActivity"
|
||||||
|
tools:showIn="@layout/activity_main">
|
||||||
<TextView
|
<TextView
|
||||||
|
android:layout_margin="@dimen/text_margin"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent"
|
||||||
android:textAppearance="?android:attr/textAppearanceSmall"
|
android:id="@+id/textViewLog" />
|
||||||
android:id="@+id/textViewLog"
|
</android.support.v4.widget.NestedScrollView>
|
||||||
android:typeface="monospace" />
|
|
||||||
</ScrollView>
|
|
||||||
|
|
||||||
</LinearLayout>
|
<android.support.design.widget.FloatingActionButton
|
||||||
|
android:id="@+id/fab"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_margin="@dimen/fab_margin"
|
||||||
|
android:src="@mipmap/ic_reset"
|
||||||
|
app:layout_anchor="@id/app_bar"
|
||||||
|
app:layout_anchorGravity="bottom|end" />
|
||||||
|
|
||||||
|
</android.support.design.widget.CoordinatorLayout>
|
||||||
BIN
ACardEmulator/app/src/main/res/mipmap-hdpi/ic_reset.png
Normal file
BIN
ACardEmulator/app/src/main/res/mipmap-hdpi/ic_reset.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 598 B |
BIN
ACardEmulator/app/src/main/res/mipmap-mdpi/ic_reset.png
Normal file
BIN
ACardEmulator/app/src/main/res/mipmap-mdpi/ic_reset.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 390 B |
BIN
ACardEmulator/app/src/main/res/mipmap-xhdpi/ic_reset.png
Normal file
BIN
ACardEmulator/app/src/main/res/mipmap-xhdpi/ic_reset.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 842 B |
BIN
ACardEmulator/app/src/main/res/mipmap-xxhdpi/ic_reset.png
Normal file
BIN
ACardEmulator/app/src/main/res/mipmap-xxhdpi/ic_reset.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 1.5 KiB |
BIN
ACardEmulator/app/src/main/res/mipmap-xxxhdpi/ic_reset.png
Normal file
BIN
ACardEmulator/app/src/main/res/mipmap-xxxhdpi/ic_reset.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 2.3 KiB |
6
ACardEmulator/app/src/main/res/values/colors.xml
Normal file
6
ACardEmulator/app/src/main/res/values/colors.xml
Normal file
@@ -0,0 +1,6 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<resources>
|
||||||
|
<color name="colorPrimary">#3F51B5</color>
|
||||||
|
<color name="colorPrimaryDark">#303F9F</color>
|
||||||
|
<color name="colorAccent">#fdd017</color>
|
||||||
|
</resources>
|
||||||
@@ -1,6 +1,5 @@
|
|||||||
<resources>
|
<resources>
|
||||||
<!-- Default screen margins, per the Android Design guidelines. -->
|
<dimen name="app_bar_height">180dp</dimen>
|
||||||
<dimen name="activity_horizontal_margin">16dp</dimen>
|
<dimen name="fab_margin">16dp</dimen>
|
||||||
<dimen name="activity_vertical_margin">16dp</dimen>
|
<dimen name="text_margin">16dp</dimen>
|
||||||
|
|
||||||
</resources>
|
</resources>
|
||||||
|
|||||||
@@ -3,6 +3,18 @@
|
|||||||
<!-- Base application theme. -->
|
<!-- Base application theme. -->
|
||||||
<style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
|
<style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
|
||||||
<!-- Customize your theme here. -->
|
<!-- Customize your theme here. -->
|
||||||
|
<item name="colorPrimary">@color/colorPrimary</item>
|
||||||
|
<item name="colorPrimaryDark">@color/colorPrimaryDark</item>
|
||||||
|
<item name="colorAccent">@color/colorAccent</item>
|
||||||
</style>
|
</style>
|
||||||
|
|
||||||
|
<style name="AppTheme.NoActionBar">
|
||||||
|
<item name="windowActionBar">false</item>
|
||||||
|
<item name="windowNoTitle">true</item>
|
||||||
|
</style>
|
||||||
|
|
||||||
|
<style name="AppTheme.AppBarOverlay" parent="ThemeOverlay.AppCompat.Dark.ActionBar" />
|
||||||
|
|
||||||
|
<style name="AppTheme.PopupOverlay" parent="ThemeOverlay.AppCompat.Light" />
|
||||||
|
|
||||||
</resources>
|
</resources>
|
||||||
|
|||||||
Reference in New Issue
Block a user