From 6d5db2438a1f5af448bad8ce8f5fbb0dd9a0aece Mon Sep 17 00:00:00 2001 From: Matthew Sibigtroth Date: Sat, 1 Nov 2014 10:50:57 -0700 Subject: [PATCH 1/2] reinstated lengthened url in the edit urls card --- .../physical_web/physicalweb/BeaconConfigFragment.java | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/android/PhysicalWeb/app/src/main/java/org/physical_web/physicalweb/BeaconConfigFragment.java b/android/PhysicalWeb/app/src/main/java/org/physical_web/physicalweb/BeaconConfigFragment.java index 39b53918..fa1ce273 100644 --- a/android/PhysicalWeb/app/src/main/java/org/physical_web/physicalweb/BeaconConfigFragment.java +++ b/android/PhysicalWeb/app/src/main/java/org/physical_web/physicalweb/BeaconConfigFragment.java @@ -202,13 +202,17 @@ public void onBeaconConfigReadUrlComplete(byte[] scanRecord, int status) { Log.e(TAG, "onUriBeaconRead - error " + status); } else { UriBeacon uriBeacon = UriBeacon.parseFromBytes(scanRecord); - final String url = (uriBeacon != null) ? uriBeacon.getUriString() : ""; + String url = (uriBeacon != null) ? uriBeacon.getUriString() : ""; Log.d(TAG, "onReadUrlComplete" + " url: " + url); + if (UrlShortener.isShortUrl(url)) { + url = UrlShortener.lengthenShortUrl(url); + } + final String urlToDisplay = url; getActivity().runOnUiThread(new Runnable() { @Override public void run() { // Update the url edit text field with the given url - mEditCardUrl.setText(url); + mEditCardUrl.setText(urlToDisplay); // Show the beacon configuration card showConfigurableBeaconCard(); } From 88938dea561facdb569c9760da2e597a14564fa7 Mon Sep 17 00:00:00 2001 From: Matthew Sibigtroth Date: Sat, 1 Nov 2014 11:34:11 -0700 Subject: [PATCH 2/2] add todos for ensuring network op is off ui thread --- .../main/java/org/physical_web/physicalweb/UrlShortener.java | 2 ++ 1 file changed, 2 insertions(+) diff --git a/android/PhysicalWeb/app/src/main/java/org/physical_web/physicalweb/UrlShortener.java b/android/PhysicalWeb/app/src/main/java/org/physical_web/physicalweb/UrlShortener.java index 905a5453..e44d95b5 100644 --- a/android/PhysicalWeb/app/src/main/java/org/physical_web/physicalweb/UrlShortener.java +++ b/android/PhysicalWeb/app/src/main/java/org/physical_web/physicalweb/UrlShortener.java @@ -47,6 +47,7 @@ class UrlShortener { * @param longUrl The url that will be shortened * @return The short url for the given longUrl */ + // TODO: make sure this network operation is off the ui thread public static String shortenUrl(String longUrl) { String shortUrl = null; try { @@ -112,6 +113,7 @@ public static boolean isShortUrl(String url) { * @param shortUrl The short url that will be lengthened * @return The lengthened url for the given short url */ + // TODO: make sure this network operation is off the ui thread public static String lengthenShortUrl(String shortUrl) { String longUrl = null; try {