From 81fd1f3ebb6588ea020c7e39d8289a8ad3219ece Mon Sep 17 00:00:00 2001 From: akaessens <24660231+akaessens@users.noreply.github.com> Date: Mon, 31 Aug 2020 11:32:22 +0200 Subject: [PATCH] enable dark mode for help and about webviews --- app/build.gradle | 3 ++- .../akdev/nofbeventscraper/AboutActivity.java | 21 ++++++++++++------- .../com/akdev/nofbeventscraper/FbScraper.java | 4 ---- .../akdev/nofbeventscraper/HelpActivity.java | 13 ++++++++++++ app/src/main/res/layout/activity_about.xml | 6 ++---- app/src/main/res/layout/activity_help.xml | 6 ++---- app/src/main/res/raw-de/help.html | 2 +- 7 files changed, 33 insertions(+), 22 deletions(-) diff --git a/app/build.gradle b/app/build.gradle index 2e84895..5a1ba10 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -30,7 +30,6 @@ dependencies { implementation 'androidx.appcompat:appcompat:1.2.0' implementation 'com.google.android.material:material:1.2.0' - implementation 'androidx.constraintlayout:constraintlayout:2.0.1' implementation 'androidx.navigation:navigation-fragment:2.3.0' implementation 'androidx.navigation:navigation-ui:2.3.0' @@ -40,6 +39,8 @@ dependencies { implementation 'com.squareup.picasso:picasso:2.71828' implementation 'androidx.preference:preference:1.1.1' + implementation "androidx.webkit:webkit:1.3.0" + testImplementation 'junit:junit:4.12' androidTestImplementation 'androidx.test.ext:junit:1.1.2' androidTestImplementation 'androidx.test.espresso:espresso-core:3.3.0' diff --git a/app/src/main/java/com/akdev/nofbeventscraper/AboutActivity.java b/app/src/main/java/com/akdev/nofbeventscraper/AboutActivity.java index 0175319..13d9f9c 100644 --- a/app/src/main/java/com/akdev/nofbeventscraper/AboutActivity.java +++ b/app/src/main/java/com/akdev/nofbeventscraper/AboutActivity.java @@ -1,15 +1,13 @@ package com.akdev.nofbeventscraper; +import android.content.res.Configuration; +import android.os.Bundle; +import android.webkit.WebView; + import androidx.appcompat.app.ActionBar; import androidx.appcompat.app.AppCompatActivity; -import androidx.appcompat.widget.Toolbar; - -import android.content.Intent; -import android.net.Uri; -import android.os.Bundle; -import android.view.View; -import android.webkit.WebView; -import android.widget.ImageView; +import androidx.webkit.WebSettingsCompat; +import androidx.webkit.WebViewFeature; public class AboutActivity extends AppCompatActivity { @@ -24,6 +22,13 @@ public class AboutActivity extends AppCompatActivity { WebView webview_about = findViewById(R.id.webview_about); + int night_mode_flags = getResources().getConfiguration().uiMode & Configuration.UI_MODE_NIGHT_MASK; + if (night_mode_flags == Configuration.UI_MODE_NIGHT_YES) { + if (WebViewFeature.isFeatureSupported(WebViewFeature.FORCE_DARK)) { + WebSettingsCompat.setForceDark(webview_about.getSettings(), + WebSettingsCompat.FORCE_DARK_ON); + } + } webview_about.loadUrl("file:///android_res/raw/about.html"); } diff --git a/app/src/main/java/com/akdev/nofbeventscraper/FbScraper.java b/app/src/main/java/com/akdev/nofbeventscraper/FbScraper.java index 312de53..dc2187c 100644 --- a/app/src/main/java/com/akdev/nofbeventscraper/FbScraper.java +++ b/app/src/main/java/com/akdev/nofbeventscraper/FbScraper.java @@ -129,10 +129,6 @@ public class FbScraper extends AsyncTask { protected Date parseToDate(String time_in) { try { - // time in is missing a : in the timezone offset - //Editable editable = new SpannableStringBuilder(time_in); - //String time_str = editable.insert(22, ":").toString(); - // parse e.g. 2011-12-03T10:15:30+0100 SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ssZ", Locale.getDefault()); diff --git a/app/src/main/java/com/akdev/nofbeventscraper/HelpActivity.java b/app/src/main/java/com/akdev/nofbeventscraper/HelpActivity.java index 6ece1a7..0c0066b 100644 --- a/app/src/main/java/com/akdev/nofbeventscraper/HelpActivity.java +++ b/app/src/main/java/com/akdev/nofbeventscraper/HelpActivity.java @@ -1,10 +1,13 @@ package com.akdev.nofbeventscraper; +import android.content.res.Configuration; import android.os.Bundle; import android.webkit.WebView; import androidx.appcompat.app.ActionBar; import androidx.appcompat.app.AppCompatActivity; +import androidx.webkit.WebSettingsCompat; +import androidx.webkit.WebViewFeature; public class HelpActivity extends AppCompatActivity { @@ -19,7 +22,17 @@ public class HelpActivity extends AppCompatActivity { WebView webview_help = findViewById(R.id.webview_help); + int night_mode_flags = getResources().getConfiguration().uiMode & Configuration.UI_MODE_NIGHT_MASK; + if (night_mode_flags == Configuration.UI_MODE_NIGHT_YES) { + if (WebViewFeature.isFeatureSupported(WebViewFeature.FORCE_DARK)) { + WebSettingsCompat.setForceDark(webview_help.getSettings(), + WebSettingsCompat.FORCE_DARK_ON); + } + } + webview_help.loadUrl("file:////android_res/raw/help.html"); + + } } diff --git a/app/src/main/res/layout/activity_about.xml b/app/src/main/res/layout/activity_about.xml index e25fb2e..6d02d1e 100644 --- a/app/src/main/res/layout/activity_about.xml +++ b/app/src/main/res/layout/activity_about.xml @@ -1,15 +1,13 @@ - - - \ No newline at end of file + \ No newline at end of file diff --git a/app/src/main/res/layout/activity_help.xml b/app/src/main/res/layout/activity_help.xml index 61743fa..f77ea28 100644 --- a/app/src/main/res/layout/activity_help.xml +++ b/app/src/main/res/layout/activity_help.xml @@ -1,15 +1,13 @@ - - - \ No newline at end of file + \ No newline at end of file diff --git a/app/src/main/res/raw-de/help.html b/app/src/main/res/raw-de/help.html index 295aa8b..24dbd5d 100644 --- a/app/src/main/res/raw-de/help.html +++ b/app/src/main/res/raw-de/help.html @@ -10,5 +10,5 @@

Warum funktioniert die Veranstaltung X nicht?

Diese Anwendung greift auf öffentlich zugängliche Ereignisinformationen zu. Wenn die Veranstaltung z.B. den Ort ohne Login nicht anbietet, ist dies in dieser Anwendung nicht verfügbar. Auch bieten einige Veranstaltungen die Informationen einfach nicht in einem maschinenlesbaren Format an. Veranstaltungen mit mehreren Instanzen sind problematisch, da sie beim Scraping von m.facebook.com nicht das korrekte Start- und Enddatum angeben.

Wenn Sie Probleme mit einem bestimmten Ereignis haben, lassen Sie es mich bitte über den anonymen Bugtracker oder auf der GitHub Problemseite.

-

Is this compatible with my calendar app?

+

Ist diese App kompatibel mit meinem Kalender?

Ja. Diese Anwendung verwendet anwendungsunabhängige Kalenderfunktionen, wodurch sie mit jeder Kalenderanwendung kompatibel ist. Ich empfehle jedoch den Etar Kalender, da er Open Source ist.

\ No newline at end of file