From d60717f0b73d597c4fb820f2a297b8667ec730d7 Mon Sep 17 00:00:00 2001 From: akaessens <24660231+akaessens@users.noreply.github.com> Date: Wed, 26 Aug 2020 16:45:33 +0200 Subject: [PATCH] switch to m.facebook scraping more descriptive toolbar button string update unit tests --- .../nofbeventscraper/MainActivityUnitTest.java | 6 +++++- .../com/akdev/nofbeventscraper/MainActivity.java | 14 +------------- app/src/main/res/layout/activity_main.xml | 4 ++-- app/src/main/res/values/strings.xml | 1 + 4 files changed, 9 insertions(+), 16 deletions(-) diff --git a/app/src/androidTest/java/com/akdev/nofbeventscraper/MainActivityUnitTest.java b/app/src/androidTest/java/com/akdev/nofbeventscraper/MainActivityUnitTest.java index 3b9844f..78bae73 100644 --- a/app/src/androidTest/java/com/akdev/nofbeventscraper/MainActivityUnitTest.java +++ b/app/src/androidTest/java/com/akdev/nofbeventscraper/MainActivityUnitTest.java @@ -36,7 +36,7 @@ public class MainActivityUnitTest { mInstrumentation.removeMonitor(monitor); - final String exp = "https://www.facebook.com/events/261145401687844"; + final String exp = "https://m.facebook.com/events/261145401687844"; String url = "https://www.facebook.com/events/261145401687844"; String act = mainActivity.checkURI(url); @@ -53,6 +53,10 @@ public class MainActivityUnitTest { url = "https://www.facebook.com/events/261145401687844/?active_tab=discussion"; act = mainActivity.checkURI(url); assertEquals(exp, act); + + url = "https://www.facebook.com/events/261145401687844?reflink_something"; + act = mainActivity.checkURI(url); + assertEquals(exp, act); } @Test diff --git a/app/src/main/java/com/akdev/nofbeventscraper/MainActivity.java b/app/src/main/java/com/akdev/nofbeventscraper/MainActivity.java index b540ac1..f546df7 100644 --- a/app/src/main/java/com/akdev/nofbeventscraper/MainActivity.java +++ b/app/src/main/java/com/akdev/nofbeventscraper/MainActivity.java @@ -202,18 +202,6 @@ public class MainActivity extends AppCompatActivity { return null; } - public static boolean isNumeric(String strNum) { - if (strNum == null) { - return false; - } - try { - double d = Double.parseDouble(strNum); - } catch (NumberFormatException e) { - //e.printStackTrace(); - return false; - } - return true; - } String checkURI(String str) { try { @@ -223,7 +211,7 @@ public class MainActivity extends AppCompatActivity { if (str.matches(".*(facebook.com/events/[0-9]*).*")) { return str.replaceAll(".*(facebook.com/events/[0-9]*).*", - "https://www.$1"); + "https://m.$1"); } else { error("Error: Invalid URL"); diff --git a/app/src/main/res/layout/activity_main.xml b/app/src/main/res/layout/activity_main.xml index 17d8797..668bbf2 100644 --- a/app/src/main/res/layout/activity_main.xml +++ b/app/src/main/res/layout/activity_main.xml @@ -11,7 +11,7 @@ @@ -58,7 +58,7 @@ app:layout_anchor="@id/app_bar" app:layout_anchorGravity="bottom|end" app:icon="@drawable/ic_content_paste" - android:text="@android:string/paste"/> + android:text="@string/paste_button"/> diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 767c420..976356c 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -5,6 +5,7 @@ Event link Paste facebook link to the event. Add to calendar + Paste from clipboard Description This application was developed to be used without a facebook account.