1
0
mirror of https://github.com/akaessens/NoFbEventScraper synced 2025-06-05 23:29:13 +02:00

switch to webview display in help and about

add icons to overflow menu
add settings with scrape url prefix selection
rewrite help and about
This commit is contained in:
akaessens
2020-08-28 20:47:52 +02:00
parent 023b7f951a
commit ec62cb6347
20 changed files with 212 additions and 196 deletions

View File

@ -1,9 +1,12 @@
package com.akdev.nofbeventscraper;
import android.content.SharedPreferences;
import android.os.AsyncTask;
import android.text.Editable;
import android.text.SpannableStringBuilder;
import androidx.preference.PreferenceManager;
import org.json.JSONException;
import org.json.JSONObject;
import org.jsoup.Jsoup;
@ -54,12 +57,21 @@ public class FbScraper extends AsyncTask<Void, Void, Void> {
// check for url format
new URL(url).toURI();
Pattern pattern = Pattern.compile("(facebook.com/events/[0-9]*)");
String regex = "(facebook.com/events/[0-9]*)(/\\?event_time_id=[0-9]*)?";
Pattern pattern = Pattern.compile(regex);
Matcher matcher = pattern.matcher(url);
if (matcher.find()) {
SharedPreferences shared_prefs = PreferenceManager.getDefaultSharedPreferences(main.get());
String url_prefix = shared_prefs.getString("url_preference", "m.facebook.com");
// rewrite url to m.facebook and dismiss any query strings or referrals
return "https://m." + matcher.group(1);
String ret = url_prefix + matcher.group(1);
if (matcher.group(2) != null) {
ret += matcher.group(2);
}
return ret;
} else {
throw new URISyntaxException(url, "Does not contain event.");
}