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

@ -38,6 +38,7 @@ dependencies {
implementation 'org.jsoup:jsoup:1.13.1'
implementation 'com.squareup.picasso:picasso:2.71828'
implementation 'androidx.preference:preference:1.1.1'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'androidx.test.ext:junit:1.1.2'

View File

@ -11,8 +11,22 @@
android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="@style/AppTheme">
<activity android:name=".AboutActivity"></activity>
<activity android:name=".HelpActivity"></activity>
<activity android:name=".SettingsActivity">
<meta-data
android:name="android.support.PARENT_ACTIVITY"
android:value=".MainActivity"/>
</activity>
<activity android:name=".HelpActivity">
<meta-data
android:name="android.support.PARENT_ACTIVITY"
android:value=".MainActivity"/>
</activity>
<activity android:name=".AboutActivity">
<meta-data
android:name="android.support.PARENT_ACTIVITY"
android:value=".MainActivity"/>
</activity>
<activity
android:name=".MainActivity"
android:label="@string/app_name"

View File

@ -0,0 +1,9 @@
<!doctype html>
<h3>Description</h3>
<p>This application was developed to be used without a facebook account. Therefore it does not use the facebook API. Instead it opens the facebook event URI and downloads the website source code. This source contains the information which is used to create a calendar entry.</p>
<h3>Open Source</h3>
<p>The source code for this application is available at <a href=" https://github.com/akaessens/NoFbEventScraper">GitHub</a>.<strong><br /></strong></p>
<p>If you encounter an issue, please report it to me anonymously at the <a href="https://gitreports.com/issue/akaessens/NoFbEventScraper">Bugtracker</a> or directly at <a href="https://github.com/akaessens/NoFbEventScraper/issues">GitHub</a>.</p>
<h3>Donations</h3>
<p>I develop this application in my free time. If you like it, you can donate at <a href="https://www.paypal.me/andreaskaessens">PayPal</a>.</p>
<p><a title="PayPal" href="https://www.paypal.me/andreaskaessens"><img src="https://www.paypalobjects.com/webstatic/de_DE/i/de-pp-logo-100px.png" /></a></p>

View File

@ -0,0 +1,15 @@
<!doctype html>
<h1>Help</h1>
<h3>What links can be used with this app?</h3>
<p>All facebook subdomains are supported, whether mobile (m.facebook.com) or language-specific (de-de.facebook.com). The link must contain an event ID.</p>
<h3>How to use this application?</h3>
<ul>
<li><strong>Paste button</strong>: paste a copied link from the clipboard into the URL bar.</li>
<li><strong>Share to</strong>: Android's built-in share-function, e.g. from a browser.</li>
<li><strong>Open with</strong>: Android's built-in open-with-function, e.g. when clicking on a link in a messenger.</li>
</ul>
<h3>Why does event X not work?</h3>
<p>This app relies on event information that is publicy available. If the event does not offer for example the location without a login, it will not be available in this application. Events with multiple instances are problematic because they do not provide the correct start and end date when scraping from m.facebook.com.</p>
<p>If you encounter issues with a specific event, please let me know via the <a href="https://gitreports.com/issue/akaessens/NoFbEventScraper">anonymous bugtracker</a> or at the <a href="https://github.com/akaessens/NoFbEventScraper/issues/">GitHub issue page</a>.</p>
<h3>Is this compatible with my calendar app?</h3>
<p>Yes. This application makes use of application independent calendar functions, which makes it compatible to every calendar app. However, i recommend <a href="https://play.google.com/store/apps/details?id=ws.xsoh.etar&amp;hl=de">Etar Calendar</a> because it is Open Source.</p>

View File

@ -1,5 +1,6 @@
package com.akdev.nofbeventscraper;
import androidx.appcompat.app.ActionBar;
import androidx.appcompat.app.AppCompatActivity;
import androidx.appcompat.widget.Toolbar;
@ -7,6 +8,7 @@ import android.content.Intent;
import android.net.Uri;
import android.os.Bundle;
import android.view.View;
import android.webkit.WebView;
import android.widget.ImageView;
public class AboutActivity extends AppCompatActivity {
@ -15,19 +17,14 @@ public class AboutActivity extends AppCompatActivity {
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_about);
this.getSupportActionBar().hide();
ActionBar action_bar = getSupportActionBar();
if (action_bar != null) {
action_bar.setDisplayHomeAsUpEnabled(true);
}
ImageView img = (ImageView)findViewById(R.id.paypal_image);
WebView webview_about = findViewById(R.id.webview_about);
img.setOnClickListener(new View.OnClickListener(){
public void onClick(View v){
Intent intent = new Intent();
intent.setAction(Intent.ACTION_VIEW);
intent.addCategory(Intent.CATEGORY_BROWSABLE);
intent.setData(Uri.parse("https://www.paypal.me/andreaskaessens"));
startActivity(intent);
}
});
webview_about.loadUrl("file:////android_asset/about.html");
}

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.");
}

View File

@ -1,7 +1,9 @@
package com.akdev.nofbeventscraper;
import android.os.Bundle;
import android.webkit.WebView;
import androidx.appcompat.app.ActionBar;
import androidx.appcompat.app.AppCompatActivity;
public class HelpActivity extends AppCompatActivity {
@ -10,6 +12,14 @@ public class HelpActivity extends AppCompatActivity {
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_help);
this.getSupportActionBar().hide();
ActionBar action_bar = getSupportActionBar();
if (action_bar != null) {
action_bar.setDisplayHomeAsUpEnabled(true);
}
WebView webview_help = findViewById(R.id.webview_help);
webview_help.loadUrl("file:////android_asset/help.html");
}
}

View File

@ -14,6 +14,7 @@ import android.widget.Button;
import android.widget.ImageView;
import androidx.appcompat.app.AppCompatActivity;
import androidx.appcompat.view.menu.MenuBuilder;
import androidx.appcompat.widget.Toolbar;
import com.google.android.material.appbar.AppBarLayout;
@ -320,6 +321,12 @@ public class MainActivity extends AppCompatActivity {
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.menu_main, menu);
if(menu instanceof MenuBuilder){
MenuBuilder m = (MenuBuilder) menu;
//noinspection RestrictedApi
m.setOptionalIconsVisible(true);
}
return true;
}
@ -339,6 +346,10 @@ public class MainActivity extends AppCompatActivity {
startActivity(new Intent(this, HelpActivity.class));
return true;
}
if (id == R.id.action_settings) {
startActivity(new Intent(this, SettingsActivity.class));
return true;
}
return super.onOptionsItemSelected(item);
}

View File

@ -0,0 +1,31 @@
package com.akdev.nofbeventscraper;
import android.os.Bundle;
import androidx.appcompat.app.ActionBar;
import androidx.appcompat.app.AppCompatActivity;
import androidx.preference.PreferenceFragmentCompat;
public class SettingsActivity extends AppCompatActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.settings_activity);
getSupportFragmentManager()
.beginTransaction()
.replace(R.id.settings, new SettingsFragment())
.commit();
ActionBar action_bar = getSupportActionBar();
if (action_bar != null) {
action_bar.setDisplayHomeAsUpEnabled(true);
}
}
public static class SettingsFragment extends PreferenceFragmentCompat {
@Override
public void onCreatePreferences(Bundle savedInstanceState, String rootKey) {
setPreferencesFromResource(R.xml.root_preferences, rootKey);
}
}
}

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="M12,2C6.48,2 2,6.48 2,12s4.48,10 10,10 10,-4.48 10,-10S17.52,2 12,2zM13,19h-2v-2h2v2zM15.07,11.25l-0.9,0.92C13.45,12.9 13,13.5 13,15h-2v-0.5c0,-1.1 0.45,-2.1 1.17,-2.83l1.24,-1.26c0.37,-0.36 0.59,-0.86 0.59,-1.41 0,-1.1 -0.9,-2 -2,-2s-2,0.9 -2,2L8,9c0,-2.21 1.79,-4 4,-4s4,1.79 4,4c0,0.88 -0.36,1.68 -0.93,2.25z"
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="M12,2C6.48,2 2,6.48 2,12s4.48,10 10,10 10,-4.48 10,-10S17.52,2 12,2zM13,17h-2v-6h2v6zM13,9h-2L11,7h2v2z"
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="M19.14,12.94c0.04,-0.3 0.06,-0.61 0.06,-0.94c0,-0.32 -0.02,-0.64 -0.07,-0.94l2.03,-1.58c0.18,-0.14 0.23,-0.41 0.12,-0.61l-1.92,-3.32c-0.12,-0.22 -0.37,-0.29 -0.59,-0.22l-2.39,0.96c-0.5,-0.38 -1.03,-0.7 -1.62,-0.94L14.4,2.81c-0.04,-0.24 -0.24,-0.41 -0.48,-0.41h-3.84c-0.24,0 -0.43,0.17 -0.47,0.41L9.25,5.35C8.66,5.59 8.12,5.92 7.63,6.29L5.24,5.33c-0.22,-0.08 -0.47,0 -0.59,0.22L2.74,8.87C2.62,9.08 2.66,9.34 2.86,9.48l2.03,1.58C4.84,11.36 4.8,11.69 4.8,12s0.02,0.64 0.07,0.94l-2.03,1.58c-0.18,0.14 -0.23,0.41 -0.12,0.61l1.92,3.32c0.12,0.22 0.37,0.29 0.59,0.22l2.39,-0.96c0.5,0.38 1.03,0.7 1.62,0.94l0.36,2.54c0.05,0.24 0.24,0.41 0.48,0.41h3.84c0.24,0 0.44,-0.17 0.47,-0.41l0.36,-2.54c0.59,-0.24 1.13,-0.56 1.62,-0.94l2.39,0.96c0.22,0.08 0.47,0 0.59,-0.22l1.92,-3.32c0.12,-0.22 0.07,-0.47 -0.12,-0.61L19.14,12.94zM12,15.6c-1.98,0 -3.6,-1.62 -3.6,-3.6s1.62,-3.6 3.6,-3.6s3.6,1.62 3.6,3.6S13.98,15.6 12,15.6z"
android:fillColor="#000000"/>
</vector>

Binary file not shown.

Before

Width:  |  Height:  |  Size: 13 KiB

View File

@ -1,97 +1,15 @@
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
<androidx.constraintlayout.widget.ConstraintLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fitsSystemWindows="true"
tools:context=".AboutActivity">
<ScrollView
<WebView
android:id="@+id/webview_about"
android:layout_width="match_parent"
android:layout_height="match_parent">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:layout_margin="16dp">
<TextView
android:id="@+id/description_heading"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="8dp"
android:text="@string/description_heading"
android:textAppearance="@style/TextAppearance.AppCompat.Large" />
<TextView
android:id="@+id/description_text"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@string/description_text"
android:textAppearance="@style/TextAppearance.AppCompat.Medium" />
<TextView
android:id="@+id/open_source_heading"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="16dp"
android:layout_marginBottom="8dp"
android:text="@string/open_source_heading"
android:textAppearance="@style/TextAppearance.AppCompat.Large" />
<TextView
android:id="@+id/open_source_text"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:autoLink="web"
android:text="@string/open_source_text"
android:textAppearance="@style/TextAppearance.AppCompat.Medium" />
<TextView
android:id="@+id/issues_heading"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="16dp"
android:layout_marginBottom="8dp"
android:text="@string/issues_heading"
android:textAppearance="@style/TextAppearance.AppCompat.Large" />
<TextView
android:id="@+id/issues_text"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:autoLink="web"
android:text="@string/issues_text"
android:textAppearance="@style/TextAppearance.AppCompat.Medium" />
<TextView
android:id="@+id/donate_heading"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="16dp"
android:layout_marginBottom="8dp"
android:text="@string/donate_heading"
android:textAppearance="@style/TextAppearance.AppCompat.Large" />
<TextView
android:id="@+id/changelog_text"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:autoLink="web"
android:text="@string/donate_text"
android:textAppearance="@style/TextAppearance.AppCompat.Medium" />
<ImageView
android:id="@+id/paypal_image"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:contentDescription="PayPal Donate"
android:scaleType="fitStart"
android:src="@drawable/paypal" />
</LinearLayout>
</ScrollView>
android:layout_height="match_parent" />
</androidx.constraintlayout.widget.ConstraintLayout>

View File

@ -1,76 +1,15 @@
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
<androidx.constraintlayout.widget.ConstraintLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".HelpActivity">
<ScrollView
<WebView
android:id="@+id/webview_help"
android:layout_width="match_parent"
android:layout_height="match_parent">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:layout_margin="16dp">
<TextView
android:id="@+id/faq_heading"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="8dp"
android:text="@string/faq_heading"
android:textAppearance="@style/TextAppearance.AppCompat.Large" />
<TextView
android:id="@+id/faq_0q"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="0dp"
android:layout_marginBottom="4dp"
android:text="@string/faq_0q"
android:textAppearance="@style/TextAppearance.AppCompat.Medium" />
<TextView
android:id="@+id/faq_0a"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@string/faq_0a"
android:textAppearance="@style/TextAppearance.AppCompat.Small" />
<TextView
android:id="@+id/faq_1q"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="8dp"
android:layout_marginBottom="4dp"
android:text="@string/faq_1q"
android:textAppearance="@style/TextAppearance.AppCompat.Medium" />
<TextView
android:id="@+id/faq_1a"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@string/faq_1a"
android:textAppearance="@style/TextAppearance.AppCompat.Small" />
<TextView
android:id="@+id/faq_2q"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="8dp"
android:layout_marginBottom="4dp"
android:text="@string/faq_2q"
android:textAppearance="@style/TextAppearance.AppCompat.Medium" />
<TextView
android:id="@+id/faq_2a"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@string/faq_2a"
android:textAppearance="@style/TextAppearance.AppCompat.Small" />
</LinearLayout>
</ScrollView>
android:layout_height="match_parent" />
</androidx.constraintlayout.widget.ConstraintLayout>

View File

@ -0,0 +1,9 @@
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent">
<FrameLayout
android:id="@+id/settings"
android:layout_width="match_parent"
android:layout_height="match_parent" />
</LinearLayout>

View File

@ -4,12 +4,17 @@
tools:context="com.akdev.nofbeventscraper.MainActivity">
<item
android:id="@+id/action_about"
android:icon="@android:drawable/ic_menu_info_details"
android:icon="@drawable/ic_info"
android:orderInCategory="100"
android:title="@string/action_about" />
<item
android:id="@+id/action_help"
android:icon="@android:drawable/ic_menu_info_details"
android:icon="@drawable/ic_help"
android:orderInCategory="100"
android:title="@string/action_help" />
<item
android:id="@+id/action_settings"
android:icon="@drawable/ic_settings"
android:orderInCategory="100"
android:title="@string/action_settings" />
</menu>

View File

@ -0,0 +1,13 @@
<resources>
<!-- Reply Preference -->
<string-array name="url_to_scrape">
<item>m.facebook.com</item>
<item>www.facebook.com</item>
</string-array>
<string-array name="url_prefix">
<item>https://m.</item>
<item>https://www.</item>
</string-array>
</resources>

View File

@ -2,34 +2,18 @@
<string name="app_name">NoFb Event Scraper</string>
<string name="action_about">About</string>
<string name="action_help">Help</string>
<string name="action_settings">Settings</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="paste_button">Paste from clipboard</string>
<string name="description_heading">Description</string>
<string name="description_text">This application was developed to be used without a facebook account.
\nTherefore it does not use the facebook API.
Instead it opens the facebook event URI and downloads the website source code.
This source contains the information which is used to create a calendar entry.
<!-- Preference Titles -->
<string name="scraper_header">Scraper</string>
<string name="url_setting">Which URL to scrape</string>
<string name="url_setting_summary">
Using m.facebook.com is more stable and faster. Using www.facebook.com gives high-res images and works better with mutiple instance events but will eventually break when facebook disables the classic design.
</string>
<string name="open_source_heading"> Open Source </string>
<string name="open_source_text"> The source code for this application can be found at https://github.com/akaessens/NoFbEventScraper .</string>
<string name="issues_heading" > Report a bug</string>
<string name="issues_text" >If you encounter a bug please report it to me anonymously at https://gitreports.com/issue/akaessens/NoFbEventScraper or directly at Github with the link above.</string>
<string name="faq_heading"> FAQ </string>
<string name="faq_0q"> What links can be used with this app? </string>
<string name="faq_0a"> All facebook subdomains are supported, whether mobile (m.facebook.com) or language-specific (de-de.facebook.com). The link must contain an event ID.</string>
<string name="faq_1q"> How to use this application? </string>
<string name="faq_1a"> You can use the paste button to paste a previously copied link into the URL bar.
Alternatively you can use the "share" function e.g. from the Android browser.
A third option is to click on a facebook link and use the "open with"-dialog. </string>
<string name="faq_2q"> Why does event X not work? </string>
<string name="faq_2a"> Current limitations are events in the past or events with multiple instances. If you find some other event that does not work, please let me know.</string>
<string name="donate_heading"> Donations </string>
<string name="donate_text">Click on the PayPal image to send me a coffee if you like :) </string>
</resources>

View File

@ -0,0 +1,21 @@
<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto">
<PreferenceCategory app:title="@string/scraper_header">
<ListPreference
app:defaultValue="m.facebook.com"
app:entries="@array/url_to_scrape"
app:entryValues="@array/url_prefix"
app:key="url_preference"
app:title="@string/url_setting"
android:summary="@string/url_setting_summary"/>
</PreferenceCategory>
</PreferenceScreen>