Skip to content

Commit

Permalink
updated
Browse files Browse the repository at this point in the history
  • Loading branch information
FlutterCrypto committed Apr 7, 2023
1 parent 80d217f commit 147b89b
Show file tree
Hide file tree
Showing 35 changed files with 149 additions and 50 deletions.
3 changes: 3 additions & 0 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -44,4 +44,7 @@ dependencies {
// pretty printing of card's responses
// source: https://github.com/devnied/EMV-NFC-Paycard-Enrollment
implementation 'com.github.devnied.emvnfccard:library:3.0.1'

// implementing an about page
implementation 'io.github.medyo:android-about-page:2.0.0'
}
35 changes: 35 additions & 0 deletions app/src/main/assets/open_source_licenses.html
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,41 @@ <h3>
limitations under the License.
</pre>

<h3>
MIT License
</h3>
<ul>
<li>
<b>android-about-page</b>
<br/>
Copyright © 2016 Mehdi Sakout (medyo)<br/>
Source code <a href="https://github.com/medyo/android-about-page">https://github.com/medyo/android-about-page</a>
</li>
</ul>
<pre>
MIT License

Copyright (c) 2016 Mehdi Sakout

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
</pre>

<h3>
Creative Commons
<br/>
Expand Down
Binary file added app/src/main/ic_launcher-playstore.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
import android.provider.Settings;
import android.text.TextUtils;
import android.util.Log;
import android.view.Gravity;
import android.view.LayoutInflater;
import android.view.Menu;
import android.view.MenuItem;
Expand Down Expand Up @@ -51,8 +52,12 @@
import java.nio.charset.StandardCharsets;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Calendar;
import java.util.List;

import mehdi.sakout.aboutpage.AboutPage;
import mehdi.sakout.aboutpage.Element;

public class MainActivity extends AppCompatActivity implements NfcAdapter.ReaderCallback {

private final String TAG = "MainAct";
Expand All @@ -65,6 +70,7 @@ public class MainActivity extends AppCompatActivity implements NfcAdapter.Reader
private String exportStringFileName = "emv.html";
private final String stepSeparatorString = "*********************************";
private final String lineSeparatorString = "---------------------------------";
Context context;

@Override
protected void onCreate(Bundle savedInstanceState) {
Expand All @@ -77,6 +83,8 @@ protected void onCreate(Bundle savedInstanceState) {
etLog = findViewById(R.id.etLog);
loadingLayout = findViewById(R.id.loading_layout);

context = getApplicationContext();

mNfcAdapter = NfcAdapter.getDefaultAdapter(this);
}

Expand All @@ -97,16 +105,16 @@ public void onTagDiscovered(Tag tag) {
clearData();
Log.d(TAG, "NFC tag discovered");
writeToUiAppend("NFC tag discovered");
playPing();
playSinglePing();
setLoadingLayoutVisibility(true);
byte[] tagId = tag.getId();
writeToUiAppend("TagId: " + bytesToHexNpe(tagId));
String[] techList = tag.getTechList();
writeToUiAppend("TechList found with these entries:");
boolean isoDepInTechList = false;
for (int i = 0; i < techList.length; i++) {
writeToUiAppend(techList[i]);
if (techList[i].equals("android.nfc.tech.IsoDep")) isoDepInTechList = true;
for (String s : techList) {
writeToUiAppend(s);
if (s.equals("android.nfc.tech.IsoDep")) isoDepInTechList = true;
}
// proceed only if tag has IsoDep in the techList
if (isoDepInTechList) {
Expand All @@ -122,7 +130,7 @@ public void onTagDiscovered(Tag tag) {
printStepHeader(0, "our journey begins");
writeToUiAppend(etData, "00 reading of the card started");

writeToUiAppend("increase IsoDep timeout for long reading");
writeToUiAppend("increase IsoDep timeout for long lasting reading");
writeToUiAppend("timeout old: " + nfc.getTimeout() + " ms");
nfc.setTimeout(10000);
writeToUiAppend("timeout new: " + nfc.getTimeout() + " ms");
Expand Down Expand Up @@ -585,13 +593,13 @@ public void onTagDiscovered(Tag tag) {
writeToUiAppend("The discovered NFC tag does not have an IsoDep interface.");
}
// final cleanup
playPing();
playDoublePing();
writeToUiFinal(etLog);
setLoadingLayoutVisibility(false);
}

private void startEndSequence(IsoDep nfc) {
playPing();
playDoublePing();
writeToUiFinal(etLog);
setLoadingLayoutVisibility(false);
vibrate();
Expand Down Expand Up @@ -1284,10 +1292,10 @@ private void playPing() {
Downloads: 366
Licence: Intended exclusively for private use
*/
//MediaPlayer mp = MediaPlayer.create(this, R.raw.ping_ringtone);
MediaPlayer mp = MediaPlayer.create(this, R.raw.ping_ringtone);


MediaPlayer mp = MediaPlayer.create(this, R.raw.notification_decorative_01);
//MediaPlayer mp = MediaPlayer.create(this, R.raw.notification_decorative_01);
mp.start();
}

Expand Down Expand Up @@ -1466,6 +1474,10 @@ private void writeTextToUri(Uri uri, String data) throws IOException {
}
}

/**
* options menu show licenses
*/

// run: displayLicensesAlertDialog();
// display licenses dialog see: https://bignerdranch.com/blog/open-source-licenses-and-android/
private void displayLicensesAlertDialog() {
Expand Down Expand Up @@ -1516,12 +1528,53 @@ public boolean onMenuItemClick(MenuItem item) {
mLicenses.setOnMenuItemClickListener(new MenuItem.OnMenuItemClickListener() {
@Override
public boolean onMenuItemClick(MenuItem item) {
Log.i(TAG, "mELicenses");
Log.i(TAG, "mLicenses");
displayLicensesAlertDialog();
return false;
}
});

MenuItem mAbout = menu.findItem(R.id.action_about);
mAbout.setOnMenuItemClickListener(new MenuItem.OnMenuItemClickListener() {
@Override
public boolean onMenuItemClick(MenuItem item) {
Log.i(TAG, "mLicenses");
CharSequence description = "This is the basic app for the Talk to your Credit Card application";
View aboutPage = new AboutPage(context)
.isRTL(false)
.setDescription(getString(R.string.app_description))
//.setCustomFont(String) // or Typeface
.setImage(R.drawable.ic_launcher_playstore)
.addItem(new Element().setTitle("Version 1.0"))
.addGroup("Connect with us")
.addEmail("[email protected]")
.addWebsite("https://medium.com/@androidcrypto")
.addGitHub("androidcrypto")
.addItem(getCopyRightsElement())
.create();
setContentView(aboutPage);
return false;
}
});

return super.onCreateOptionsMenu(menu);
}

Element getCopyRightsElement() {
Element copyRightsElement = new Element();
final String copyrights = String.format(getString(R.string.copy_right), Calendar.getInstance().get(Calendar.YEAR));
copyRightsElement.setTitle(copyrights);
copyRightsElement.setIconDrawable(R.drawable.about_icon_copy_right);
copyRightsElement.setAutoApplyIconTint(true);
copyRightsElement.setIconTint(mehdi.sakout.aboutpage.R.color.about_item_icon_color);
copyRightsElement.setIconNightTint(android.R.color.white);
copyRightsElement.setGravity(Gravity.CENTER);
copyRightsElement.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Toast.makeText(MainActivity.this, copyrights, Toast.LENGTH_SHORT).show();
}
});
return copyRightsElement;
}
}
30 changes: 0 additions & 30 deletions app/src/main/res/drawable-v24/ic_launcher_foreground.xml

This file was deleted.

9 changes: 9 additions & 0 deletions app/src/main/res/drawable/about_icon_copy_right.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:viewportHeight="24.0"
android:viewportWidth="24.0">
<path
android:fillColor="#000000"
android:pathData="M10.08,10.86c0.05,-0.33 0.16,-0.62 0.3,-0.87s0.34,-0.46 0.59,-0.62c0.24,-0.15 0.54,-0.22 0.91,-0.23 0.23,0.01 0.44,0.05 0.63,0.13 0.2,0.09 0.38,0.21 0.52,0.36s0.25,0.33 0.34,0.53 0.13,0.42 0.14,0.64h1.79c-0.02,-0.47 -0.11,-0.9 -0.28,-1.29s-0.4,-0.73 -0.7,-1.01 -0.66,-0.5 -1.08,-0.66 -0.88,-0.23 -1.39,-0.23c-0.65,0 -1.22,0.11 -1.7,0.34s-0.88,0.53 -1.2,0.92 -0.56,0.84 -0.71,1.36S8,11.29 8,11.87v0.27c0,0.58 0.08,1.12 0.23,1.64s0.39,0.97 0.71,1.35 0.72,0.69 1.2,0.91 1.05,0.34 1.7,0.34c0.47,0 0.91,-0.08 1.32,-0.23s0.77,-0.36 1.08,-0.63 0.56,-0.58 0.74,-0.94 0.29,-0.74 0.3,-1.15h-1.79c-0.01,0.21 -0.06,0.4 -0.15,0.58s-0.21,0.33 -0.36,0.46 -0.32,0.23 -0.52,0.3c-0.19,0.07 -0.39,0.09 -0.6,0.1 -0.36,-0.01 -0.66,-0.08 -0.89,-0.23 -0.25,-0.16 -0.45,-0.37 -0.59,-0.62s-0.25,-0.55 -0.3,-0.88 -0.08,-0.67 -0.08,-1v-0.27c0,-0.35 0.03,-0.68 0.08,-1.01zM12,2C6.48,2 2,6.48 2,12s4.48,10 10,10 10,-4.48 10,-10S17.52,2 12,2zM12,20c-4.41,0 -8,-3.59 -8,-8s3.59,-8 8,-8 8,3.59 8,8 -3.59,8 -8,8z" />
</vector>
15 changes: 15 additions & 0 deletions app/src/main/res/drawable/ic_launcher_foreground.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="108dp"
android:height="108dp"
android:viewportWidth="24"
android:viewportHeight="24"
android:tint="#FFFFFF">
<group android:scaleX="0.435"
android:scaleY="0.435"
android:translateX="6.78"
android:translateY="6.78">
<path
android:fillColor="@android:color/white"
android:pathData="M7,7.07L8.43,8.5c0.91,-0.91 2.18,-1.48 3.57,-1.48s2.66,0.57 3.57,1.48L17,7.07C15.72,5.79 13.95,5 12,5s-3.72,0.79 -5,2.07zM12,1C8.98,1 6.24,2.23 4.25,4.21l1.41,1.41C7.28,4 9.53,3 12,3s4.72,1 6.34,2.62l1.41,-1.41C17.76,2.23 15.02,1 12,1zM14.86,10.01L9.14,10C8.51,10 8,10.51 8,11.14v9.71c0,0.63 0.51,1.14 1.14,1.14h5.71c0.63,0 1.14,-0.51 1.14,-1.14v-9.71c0.01,-0.63 -0.5,-1.13 -1.13,-1.13zM15,20L9,20v-8h6v8z"/>
</group>
</vector>
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
5 changes: 5 additions & 0 deletions app/src/main/res/menu/menu_activity_main.xml
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,9 @@
android:title="Licenses"
app:showAsAction="never"/>

<item
android:id="@+id/action_about"
android:title="About the app"
app:showAsAction="never"/>

</menu>
4 changes: 2 additions & 2 deletions app/src/main/res/mipmap-anydpi-v26/ic_launcher.xml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<adaptive-icon xmlns:android="http://schemas.android.com/apk/res/android">
<background android:drawable="@drawable/ic_launcher_background" />
<foreground android:drawable="@drawable/ic_launcher_foreground" />
<background android:drawable="@color/ic_launcher_background"/>
<foreground android:drawable="@drawable/ic_launcher_foreground"/>
</adaptive-icon>
4 changes: 2 additions & 2 deletions app/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<adaptive-icon xmlns:android="http://schemas.android.com/apk/res/android">
<background android:drawable="@drawable/ic_launcher_background" />
<foreground android:drawable="@drawable/ic_launcher_foreground" />
<background android:drawable="@color/ic_launcher_background"/>
<foreground android:drawable="@drawable/ic_launcher_foreground"/>
</adaptive-icon>
6 changes: 0 additions & 6 deletions app/src/main/res/mipmap-anydpi-v33/ic_launcher.xml

This file was deleted.

Binary file added app/src/main/res/mipmap-hdpi/ic_launcher.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file removed app/src/main/res/mipmap-hdpi/ic_launcher.webp
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file removed app/src/main/res/mipmap-hdpi/ic_launcher_round.webp
Binary file not shown.
Binary file added app/src/main/res/mipmap-mdpi/ic_launcher.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file removed app/src/main/res/mipmap-mdpi/ic_launcher.webp
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file removed app/src/main/res/mipmap-mdpi/ic_launcher_round.webp
Binary file not shown.
Binary file added app/src/main/res/mipmap-xhdpi/ic_launcher.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file removed app/src/main/res/mipmap-xhdpi/ic_launcher.webp
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file removed app/src/main/res/mipmap-xhdpi/ic_launcher_round.webp
Binary file not shown.
Binary file added app/src/main/res/mipmap-xxhdpi/ic_launcher.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file removed app/src/main/res/mipmap-xxhdpi/ic_launcher.webp
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
Binary file added app/src/main/res/mipmap-xxxhdpi/ic_launcher.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file removed app/src/main/res/mipmap-xxxhdpi/ic_launcher.webp
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
4 changes: 4 additions & 0 deletions app/src/main/res/values/ic_launcher_background.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<color name="ic_launcher_background">#2196F3</color>
</resources>
2 changes: 2 additions & 0 deletions app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
<resources>
<string name="app_name">TalkToYourCreditCard</string>
<string name="action_licenses">Used libraries and their licenses</string>
<string name="copy_right" translatable="false">Copyrights © %1$d</string>
<string name="app_description">This is the basic app (part 0) for the \"Talk to your Credit Card\" application.\n\nThe full app reads your Credit Card and retrieves the card number and expiration date.</string>
</resources>
9 changes: 9 additions & 0 deletions readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,9 @@ build.gradle:
// pretty printing of card's responses
// source: https://github.com/devnied/EMV-NFC-Paycard-Enrollment
implementation 'com.github.devnied.emvnfccard:library:3.0.1'
// implementing an about page
implementation 'io.github.medyo:android-about-page:2.0.0'
```

These are the steps to read a payment card, it is a kind of "question & answer" workflow:
Expand Down Expand Up @@ -62,6 +65,12 @@ Source code: https://github.com/devnied/EMV-NFC-Paycard-Enrollment

License: Apache-2.0 license

## Library: Android About Page

Source code: https://github.com/medyo/android-about-page

License: The MIT License (MIT)


```plaintext
You are free to:
Expand Down

0 comments on commit 147b89b

Please sign in to comment.