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

9 Commits

Author SHA1 Message Date
fc9fb169ef prepare v0.2.1 2020-08-15 19:29:56 +02:00
a1c7720836 links in text color for better visibility 2020-08-15 16:38:12 +02:00
9ab18b496f update jsoup 2020-08-15 15:31:05 +02:00
40a2c7d18f cancel scraping if clear is pressed to prevent inconsitent cleared state
disable add button to prevent creating empty events
2020-08-15 13:51:12 +02:00
fd874d7cb0 fix calendar icon color for dark layout 2020-08-15 13:27:17 +02:00
eafa1bfc1b Merge branch 'master' of github.com:akaessens/NoFbEventScraper 2020-08-15 13:15:50 +02:00
bc9cf04f10 use helper error instead of toast
move clear fuction to text input
more concise add button
remove autocorrect o textfields
closes #10
2020-08-15 13:15:01 +02:00
ac98a4a43c fix tests,
minor design fixes
2020-08-15 11:42:56 +02:00
b9f9038f6e Update README.md 2020-08-15 01:00:03 +02:00
16 changed files with 120 additions and 76 deletions

View File

@ -11,10 +11,8 @@ This source contains the information which is used to create a calendar entry.
# Download
Currently this application is in the submitting process to FDroid. see also [#2](/../../issues/2).
Until it is published at FDroid, use [release v0.1.1](https://github.com/akaessens/NoFbEventScraper/releases/download/v0.2.0/app-release.apk).
Until it is published at FDroid, use [release v0.2.0](https://github.com/akaessens/NoFbEventScraper/releases/download/v0.2.0/app-release.apk).
# Screenshot
<img src="https://github.com/akaessens/NoFbEventScraper/raw/master/fastlane/metadata/android/en-US/images/phoneScreenshots/1.png" alt="Screenshot 1" width="250">
<img src="https://github.com/akaessens/NoFbEventScraper/raw/master/fastlane/metadata/android/en-US/images/phoneScreenshots/2.png" alt="Screenshot 2" width="250">
<img src="https://github.com/akaessens/NoFbEventScraper/raw/master/fastlane/metadata/android/en-US/images/phoneScreenshots/3.png" alt="Screenshot 3" width="250">
<img src="https://github.com/akaessens/NoFbEventScraper/raw/master/fastlane/metadata/android/en-US/images/phoneScreenshots/1.png" alt="Screenshot 1" width="250"> <img src="https://github.com/akaessens/NoFbEventScraper/raw/master/fastlane/metadata/android/en-US/images/phoneScreenshots/2.png" alt="Screenshot 2" width="250"> <img src="https://github.com/akaessens/NoFbEventScraper/raw/master/fastlane/metadata/android/en-US/images/phoneScreenshots/3.png" alt="Screenshot 3" width="250">

View File

@ -8,8 +8,8 @@ android {
applicationId "com.akdev.nofbeventscraper"
minSdkVersion 26
targetSdkVersion 29
versionCode 3
versionName "0.2.0"
versionCode 4
versionName "0.2.1"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}
@ -35,7 +35,7 @@ dependencies {
implementation 'androidx.navigation:navigation-ui:2.3.0'
// jsoup HTML parser library @ https://jsoup.org/
implementation 'org.jsoup:jsoup:1.11.1'
implementation 'org.jsoup:jsoup:1.13.1'
implementation 'com.squareup.picasso:picasso:2.71828'

View File

@ -36,7 +36,7 @@ public class MainActivityUnitTest {
mInstrumentation.removeMonitor(monitor);
final String exp = "https://m.facebook.com/events/261145401687844";
final String exp = "https://www.facebook.com/events/261145401687844";
String url = "https://www.facebook.com/events/261145401687844";
String act = mainActivity.checkURI(url);

View File

@ -55,12 +55,12 @@ public class ScraperUnitTest {
FbScraper scraper = new FbScraper(null, "");
String in = "foo @[152580919265:274:MagentaMusik 360] bar";
String exp = "foo m.facebook.com/152580919265 (MagentaMusik 360) bar";
String exp = "foo MagentaMusik 360 [m.facebook.com/152580919265] bar";
String act = scraper.fixLinks(in);
assertEquals(exp, act);
in = "foo @[152580919265:274:MagentaMusik 360] bar @[666666666666:274:NoOfTheBeast]";
exp = "foo m.facebook.com/152580919265 (MagentaMusik 360) bar m.facebook.com/666666666666 (NoOfTheBeast)";
exp = "foo MagentaMusik 360 [m.facebook.com/152580919265] bar NoOfTheBeast [m.facebook.com/666666666666]";
act = scraper.fixLinks(in);
assertEquals(exp, act);

View File

@ -1,15 +1,9 @@
package com.akdev.nofbeventscraper;
import android.app.Activity;
import android.content.Context;
import android.os.AsyncTask;
import android.text.Editable;
import android.text.SpannableStringBuilder;
import android.util.Log;
import android.view.View;
import android.widget.Toast;
import com.google.android.material.textfield.TextInputEditText;
import org.json.JSONException;
import org.json.JSONObject;
@ -80,7 +74,8 @@ public class FbScraper extends AsyncTask<Void, Void, Void> {
protected String fixLinks(String description_in) {
try {
// @[152580919265:274:MagentaMusik 360] -> m.facebook.com/152580919265
return description_in.replaceAll("@\\[([0-9]{10,}):[0-9]{3}:([^\\]]*)\\]", "m.facebook.com/$1 ($2)");
return description_in.replaceAll("@\\[([0-9]{10,}):[0-9]{3}:([^\\]]*)\\]",
"$2 [m.facebook.com/$1]");
} catch (Exception e) {
e.printStackTrace();
@ -103,7 +98,7 @@ public class FbScraper extends AsyncTask<Void, Void, Void> {
Document document = null;
try {
document = Jsoup.connect(url).get();
document = Jsoup.connect(url).userAgent("Mozilla").get();
try {
String json = document.select("script[type = application/ld+json]").first().data();
@ -141,7 +136,7 @@ public class FbScraper extends AsyncTask<Void, Void, Void> {
e.printStackTrace();
this.error = "Error: Scraping event data failed";
}
} catch (IOException e) {
} catch (Exception e) {
e.printStackTrace();
this.error = "Error: URL not available";
}
@ -160,7 +155,7 @@ public class FbScraper extends AsyncTask<Void, Void, Void> {
this.main.update(event);
}
else {
main.toast(error);
main.error(error);
this.main.clear(false);
}
}

View File

@ -19,15 +19,12 @@ import android.widget.Button;
import android.widget.ImageView;
import android.widget.Toast;
import com.google.android.material.textfield.TextInputLayout;
import com.squareup.picasso.Picasso;
import java.net.URI;
import java.net.URL;
import java.time.LocalDateTime;
import java.time.ZoneId;
import java.time.ZonedDateTime;
import java.time.format.DateTimeFormatter;
import java.util.TimeZone;
public class MainActivity extends AppCompatActivity {
@ -44,6 +41,9 @@ public class MainActivity extends AppCompatActivity {
private TextInputEditText field_event_description;
private ImageView toolbar_image_view;
private CollapsingToolbarLayout toolbar_layout;
private TextInputLayout input_layout;
private FbScraper scraper;
@Override
protected void onCreate(Bundle savedInstanceState) {
@ -52,11 +52,11 @@ public class MainActivity extends AppCompatActivity {
Toolbar toolbar = findViewById(R.id.toolbar);
setSupportActionBar(toolbar);
cancel_button = (Button) findViewById(R.id.cancel_button);
ok_button = (Button) findViewById(R.id.ok_button);
paste_button = (Button) findViewById(R.id.paste_button);
field_uri_input = (TextInputEditText) findViewById(R.id.field_uri_input);
input_layout = (TextInputLayout) findViewById(R.id.textInputLayout);
field_event_name = (TextInputEditText) findViewById(R.id.field_event_name);
field_event_start = (TextInputEditText) findViewById(R.id.field_event_start);
field_event_end = (TextInputEditText) findViewById(R.id.field_event_end);
@ -65,6 +65,9 @@ public class MainActivity extends AppCompatActivity {
toolbar_image_view = (ImageView) findViewById(R.id.image_view);
toolbar_layout = (CollapsingToolbarLayout) findViewById(R.id.toolbar_layout);
ok_button.setEnabled(false);
paste_button.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
@ -78,13 +81,20 @@ public class MainActivity extends AppCompatActivity {
}
catch (NullPointerException e) {
e.printStackTrace();
toast("Error: Clipboard empty");
error("Error: Clipboard empty");
}
startScraping();
}
});
cancel_button.setOnClickListener(new View.OnClickListener() {
input_layout.setEndIconOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
clear(true);
}
});
input_layout.setErrorIconOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
clear(true);
@ -110,13 +120,12 @@ public class MainActivity extends AppCompatActivity {
intent.putExtra(CalendarContract.EXTRA_EVENT_BEGIN_TIME, start_epoch);
intent.putExtra(CalendarContract.EXTRA_EVENT_END_TIME, end_epoch);
intent.putExtra(CalendarContract.Events.EVENT_LOCATION, location);
intent.putExtra(CalendarContract.Events.DESCRIPTION, uri + "\n" + description);
intent.putExtra(CalendarContract.Events.DESCRIPTION, uri + "\n\n" + description);
startActivity(intent);
}
catch (Exception e )
{
e.printStackTrace();
toast("Error: Invalid fields");
}
}
@ -217,8 +226,8 @@ public class MainActivity extends AppCompatActivity {
}
catch (Exception e) {
e.printStackTrace();
clear(true);
toast("Invalid URL");
clear(false);
error("Error: Invalid URL");
str = "";
}
return str;
@ -226,23 +235,31 @@ public class MainActivity extends AppCompatActivity {
public void startScraping() {
String str = checkURI(field_uri_input.getText().toString());
field_uri_input.setText(str);
error(null);
try {
FbScraper scraper = new FbScraper(this, field_uri_input.getText().toString());
scraper.execute();
String str = checkURI(field_uri_input.getText().toString());
if (!str.equals(""))
{
field_uri_input.setText(str);
scraper = new FbScraper(this, field_uri_input.getText().toString());
scraper.execute();
}
}
catch (Exception e) {
e.printStackTrace();
clear(true);
toast("Invalid URL");
clear(false);
error("Error: Invalid URL");
}
}
public void toast(String str) {
Toast.makeText(this, str, Toast.LENGTH_SHORT).show();
public void error(String str) {
//Toast.makeText(this, str, Toast.LENGTH_SHORT).show();
input_layout.setError(str);
}
public void clear(boolean clearUri) {
if (clearUri) {
@ -261,10 +278,18 @@ public class MainActivity extends AppCompatActivity {
toolbar_image_view.setImageDrawable(null);
toolbar_layout.setTitle(getString(R.string.app_name));
if (scraper!=null)
{
scraper.cancel(true);
scraper = null;
}
ok_button.setEnabled(false);
}
public void update(FbEvent event) {
field_event_name.setText(event.name);
input_layout.setError(null);
if (event.name.equals(""))
{
@ -304,6 +329,8 @@ public class MainActivity extends AppCompatActivity {
{
e.printStackTrace();
}
ok_button.setEnabled(true);
}

View File

@ -0,0 +1,9 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:viewportWidth="24"
android:viewportHeight="24">
<path
android:pathData="M22,3L7,3c-0.69,0 -1.23,0.35 -1.59,0.88L0.37,11.45c-0.22,0.34 -0.22,0.77 0,1.11l5.04,7.56c0.36,0.52 0.9,0.88 1.59,0.88h15c1.1,0 2,-0.9 2,-2L24,5c0,-1.1 -0.9,-2 -2,-2zM18.3,16.3c-0.39,0.39 -1.02,0.39 -1.41,0L14,13.41l-2.89,2.89c-0.39,0.39 -1.02,0.39 -1.41,0 -0.39,-0.39 -0.39,-1.02 0,-1.41L12.59,12 9.7,9.11c-0.39,-0.39 -0.39,-1.02 0,-1.41 0.39,-0.39 1.02,-0.39 1.41,0L14,10.59l2.89,-2.89c0.39,-0.39 1.02,-0.39 1.41,0 0.39,0.39 0.39,1.02 0,1.41L15.41,12l2.89,2.89c0.38,0.38 0.38,1.02 0,1.41z"
android:fillColor="#000000"/>
</vector>

View File

@ -0,0 +1,9 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:viewportWidth="24"
android:viewportHeight="24">
<path
android:pathData="M16.53,11.06L15.47,10l-4.88,4.88 -2.12,-2.12 -1.06,1.06L10.59,17l5.94,-5.94zM19,3h-1L18,1h-2v2L8,3L8,1L6,1v2L5,3c-1.11,0 -1.99,0.9 -1.99,2L3,19c0,1.1 0.89,2 2,2h14c1.1,0 2,-0.9 2,-2L21,5c0,-1.1 -0.9,-2 -2,-2zM19,19L5,19L5,8h14v11z"
android:fillColor="#000000"/>
</vector>

View File

@ -70,36 +70,22 @@
android:layout_margin="0dp"
app:contentInsetStart="0dp">
<LinearLayout
android:id="@+id/groupbutton"
<Button
android:id="@+id/ok_button"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="bottom"
android:orientation="horizontal"
android:weightSum="2">
<Button
android:id="@+id/cancel_button"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="16dp"
android:layout_marginRight="8dp"
android:layout_weight="1"
android:padding="12dp"
android:text="@android:string/cancel"
app:cornerRadius="12dp" />
<Button
android:id="@+id/ok_button"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="8dp"
android:layout_marginRight="16dp"
android:layout_weight="1"
android:padding="12dp"
android:text="@android:string/ok"
app:cornerRadius="12dp" />
</LinearLayout>
android:layout_marginStart="16dp"
android:layout_marginEnd="16dp"
android:layout_weight="1"
android:padding="12dp"
android:text="@string/add_to_calendar"
android:textColor="#FFFFFF"
app:cornerRadius="24dp"
app:icon="@drawable/ic_event_available"
app:iconGravity="textStart"
app:iconPadding="16dp"
app:iconTint="#FFFFFF" />
</com.google.android.material.bottomappbar.BottomAppBar>

View File

@ -31,16 +31,22 @@
<com.google.android.material.textfield.TextInputLayout
android:id="@+id/textInputLayout"
style="@style/Widget.MaterialComponents.TextInputLayout.OutlinedBox"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginStart="16dp"
android:layout_marginTop="16dp"
android:layout_marginEnd="16dp"
android:layout_marginEnd="16dp"
app:endIconCheckable="false"
app:endIconDrawable="@drawable/ic_backspace_black"
app:endIconMode="custom"
app:errorIconDrawable="@drawable/ic_backspace_black"
app:helperText="@string/add_link_helper"
app:helperTextEnabled="true"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/linearLayout4"
style="@style/Widget.MaterialComponents.TextInputLayout.OutlinedBox" >
app:layout_constraintTop_toBottomOf="@+id/linearLayout4">
<com.google.android.material.textfield.TextInputEditText
android:id="@+id/field_uri_input"
@ -50,7 +56,9 @@
android:clickable="true"
android:cursorVisible="true"
android:hint="@string/add_link_hint"
android:singleLine="true" />
android:inputType="textNoSuggestions"
android:singleLine="true"
android:textColorLink="@color/material_on_background_emphasis_high_type" />
</com.google.android.material.textfield.TextInputLayout>
<LinearLayout
@ -85,7 +93,9 @@
android:clickable="true"
android:cursorVisible="true"
android:hint="Event name"
android:singleLine="true" />
android:inputType="textNoSuggestions"
android:singleLine="true"
android:textColorLink="@color/material_on_background_emphasis_high_type" />
</com.google.android.material.textfield.TextInputLayout>
<com.google.android.material.textfield.TextInputLayout
@ -99,6 +109,7 @@
android:layout_height="wrap_content"
android:clickable="true"
android:cursorVisible="true"
android:inputType="textNoSuggestions"
android:hint="Event start"
android:singleLine="true" />
</com.google.android.material.textfield.TextInputLayout>
@ -114,6 +125,7 @@
android:layout_height="wrap_content"
android:clickable="true"
android:cursorVisible="true"
android:inputType="textNoSuggestions"
android:hint="Event end"
android:singleLine="true" />
</com.google.android.material.textfield.TextInputLayout>
@ -130,6 +142,7 @@
android:autoLink="map"
android:clickable="true"
android:cursorVisible="true"
android:inputType="textNoSuggestions"
android:hint="Event location"
android:singleLine="true" />
</com.google.android.material.textfield.TextInputLayout>
@ -147,7 +160,9 @@
android:clickable="true"
android:cursorVisible="true"
android:hint="Event description"
android:singleLine="false" />
android:inputType="textNoSuggestions|textMultiLine"
android:singleLine="false"
android:textColorLink="@color/material_on_background_emphasis_high_type" />
</com.google.android.material.textfield.TextInputLayout>
</LinearLayout>

View File

@ -2,5 +2,5 @@
<resources>
<color name="colorPrimary">#297DA6</color>
<color name="colorPrimaryDark">#23607E</color>
<color name="colorAccent">#23607E</color>
<color name="colorAccent">#297DA6</color>
</resources>

View File

@ -2,7 +2,9 @@
<string name="app_name">NoFb Event Scraper</string>
<string name="action_about">About</string>
<string name="action_help">Help</string>
<string name="add_link_hint">Paste facebook link to the event.</string>
<string name="add_link_hint">Event link</string>
<string name="add_link_helper">Paste facebook link to the event.</string>
<string name="add_to_calendar">Add to calendar</string>
<string name="description_heading">Description</string>
<string name="description_text">This application was developed to be used without a facebook account.

View File

@ -0,0 +1,3 @@
Fixes for new design.
Mew button layout.
Improve input error display.

Binary file not shown.

Before

Width:  |  Height:  |  Size: 91 KiB

After

Width:  |  Height:  |  Size: 90 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 93 KiB

After

Width:  |  Height:  |  Size: 686 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 687 KiB

After

Width:  |  Height:  |  Size: 135 KiB