diff --git a/app/build.gradle b/app/build.gradle index e3cad74..7eeb37b 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -31,9 +31,9 @@ repositories { dependencies { compile fileTree(dir: 'libs', include: ['*.jar']) testCompile 'junit:junit:4.12' - compile files('libs/NautilusMessage.jar') compile 'com.android.support:appcompat-v7:21.0.3' compile 'net.tomp2p:tomp2p-android:5.0-Beta5' compile 'com.android.support:support-v4:21.0.3' compile 'com.google.android.gms:play-services-appindexing:8.1.0' + compile files('libs/NautilusMessage.jar') } diff --git a/app/src/main/java/com/github/luislorenzom/naudroid/FileNavigator.java b/app/src/main/java/com/github/luislorenzom/naudroid/FileNavigator.java index 0390cc6..c33c68c 100644 --- a/app/src/main/java/com/github/luislorenzom/naudroid/FileNavigator.java +++ b/app/src/main/java/com/github/luislorenzom/naudroid/FileNavigator.java @@ -180,7 +180,7 @@ public void onClick(View v) { final ProgressDialog progress = ProgressDialog.show(FileNavigator.this, "Retrieving file", "Conneting with the servers, wait a minute", true); - new Thread(new Runnable() { + Thread t = new Thread(new Runnable() { @Override public void run() { ClientConnection clientConnection = new ClientConnection(FileNavigator.this); @@ -194,6 +194,8 @@ public void run() { } }); + t.start(); + } else { Toast.makeText(getApplicationContext(), "Can't get the keys from this file", Toast.LENGTH_SHORT).show(); } diff --git a/app/src/main/java/com/github/luislorenzom/naudroid/PrepareFileToSend.java b/app/src/main/java/com/github/luislorenzom/naudroid/PrepareFileToSend.java index 13bf13c..f33e1a8 100644 --- a/app/src/main/java/com/github/luislorenzom/naudroid/PrepareFileToSend.java +++ b/app/src/main/java/com/github/luislorenzom/naudroid/PrepareFileToSend.java @@ -213,10 +213,10 @@ public boolean onOptionsItemSelected(MenuItem item) { publicKey = null; } - final ProgressDialog progress = ProgressDialog.show(PrepareFileToSend.this, "Retrieving file", + final ProgressDialog progress = ProgressDialog.show(PrepareFileToSend.this, "Saving file", "Conneting with the servers, wait a minute", true); - new Thread(new Runnable() { + Thread t = new Thread(new Runnable() { @Override public void run() { // Send the petition to clientConnection @@ -231,6 +231,10 @@ public void run() { }); } }); + + t.start(); + + } return super.onOptionsItemSelected(item); } diff --git a/app/src/main/java/com/github/luislorenzom/naudroid/connection/ClientConnection.java b/app/src/main/java/com/github/luislorenzom/naudroid/connection/ClientConnection.java index 8444fa1..06755b5 100644 --- a/app/src/main/java/com/github/luislorenzom/naudroid/connection/ClientConnection.java +++ b/app/src/main/java/com/github/luislorenzom/naudroid/connection/ClientConnection.java @@ -343,7 +343,7 @@ private int startClient(String ipAddress, NautilusMessage msgObject) { } // -------------------------------------------------------------- - if (msgObject.getType() == 1) { + if (msgObject.getType() == 3) { // Send and logic to process msg type one FutureDirect future = client.sendDirect(peerA).object(msg).start(); diff --git a/app/src/main/java/com/github/luislorenzom/naudroid/connection/ConnectionUtilities.java b/app/src/main/java/com/github/luislorenzom/naudroid/connection/ConnectionUtilities.java index c002009..1d1f1a2 100644 --- a/app/src/main/java/com/github/luislorenzom/naudroid/connection/ConnectionUtilities.java +++ b/app/src/main/java/com/github/luislorenzom/naudroid/connection/ConnectionUtilities.java @@ -13,6 +13,7 @@ import java.security.MessageDigest; import java.security.NoSuchAlgorithmException; import java.security.PublicKey; +import java.text.SimpleDateFormat; import java.util.ArrayList; import java.util.Calendar; import java.util.Collections; @@ -96,8 +97,20 @@ public List prepareFileToSend(String filePath, int downloadLimi keysList.add(nKey); // Generate a message - NautilusMessage msg = new NautilusMessage(1, hash, readContentIntoByteArray(encryptFile), - downloadLimit, dateLimit, releaseDate); + SimpleDateFormat sdf = new SimpleDateFormat("dd/MM/yyyy"); + String dateLimitString = null; + String releaseDateString = null; + + if (dateLimit != null) { + dateLimitString = sdf.format(dateLimit.getTime()); + } + + if (releaseDate != null) { + releaseDateString = sdf.format(releaseDate.getTime()); + } + + NautilusMessage msg = new NautilusMessage(dateLimitString, releaseDateString, 3, hash, + readContentIntoByteArray(encryptFile), downloadLimit); // Add the new message to the messageList msgs.add(msg);