-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
80d217f
commit 147b89b
Showing
35 changed files
with
149 additions
and
50 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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; | ||
|
@@ -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"; | ||
|
@@ -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) { | ||
|
@@ -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); | ||
} | ||
|
||
|
@@ -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) { | ||
|
@@ -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"); | ||
|
@@ -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(); | ||
|
@@ -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(); | ||
} | ||
|
||
|
@@ -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() { | ||
|
@@ -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; | ||
} | ||
} |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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> |
This file was deleted.
Oops, something went wrong.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters