Improve pad sharing

This commit is contained in:
skylarmt 2015-04-16 18:07:50 -06:00
parent 49c7c1cf61
commit 372c8d9c24
2 changed files with 5 additions and 2 deletions

View File

@ -138,7 +138,7 @@ public class FileUtils {
public static String getUrl(String url) throws MalformedURLException, IOException {
String out;
try (Scanner sc = new Scanner(new URL("http://www.google.com").openStream(), "UTF-8")) {
try (Scanner sc = new Scanner(new URL(url).openStream(), "UTF-8")) {
out = sc.useDelimiter("\\A").next();
}
return out;

View File

@ -210,11 +210,13 @@ public class SharePad extends javax.swing.JPanel {
String f = FileUtils.getUrl(
Main.API_URL + "sendpad.php?email="
+ email + "&padid=" + pad);
Debug.println(f);
if (f.contains("OK")) {
SwingUtilities.invokeLater(new Runnable() {
@Override
public void run() {
emailBtn.setText("Link Sent!");
emailBox.setText("");
}
});
} else {
@ -226,6 +228,7 @@ public class SharePad extends javax.swing.JPanel {
});
}
} catch (Exception ex) {
Debug.stacktrace(ex);
SwingUtilities.invokeLater(new Runnable() {
@Override
public void run() {
@ -241,7 +244,7 @@ public class SharePad extends javax.swing.JPanel {
SwingUtilities.invokeLater(new Runnable() {
@Override
public void run() {
emailBtn.setEnabled(true);
emailBtn.setEnabled(License.checkEmail(emailBox.getText()));
emailBtn.setText("Send Email");
}
});