Skip to content

Commit

Permalink
Merge pull request #45 from Lee245/FixPluim
Browse files Browse the repository at this point in the history
Fixed broken KNMI pluim display
  • Loading branch information
CNugteren authored Feb 15, 2024
2 parents 6ab1edc + be07e8b commit 3b4523b
Showing 1 changed file with 9 additions and 1 deletion.
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
package foss.cnugteren.nlweer.ui.fragments

import android.graphics.Color
import android.os.Bundle
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import android.webkit.WebView
import android.webkit.WebViewClient
import androidx.fragment.app.Fragment
import androidx.preference.PreferenceManager
import androidx.swiperefreshlayout.widget.SwipeRefreshLayout
import foss.cnugteren.nlweer.MainActivity
import foss.cnugteren.nlweer.R
Expand All @@ -25,14 +27,20 @@ class WebClientKnmiPluim : WebViewClient() {
override fun onPageFinished(view: WebView, url: String) {
view.loadUrl("javascript:(function() {" +
"document.getElementsByClassName('breadcrumb')[0].style.display='none';" +
"document.getElementsByClassName('weather-small')[0].style.display='none';" +
"document.getElementsByClassName('site-header')[0].style.display='none';" +
"document.getElementsByClassName('site-footer')[0].style.display='none';" +
"document.getElementsByClassName('morelinks')[0].style.display='none';" +
"document.getElementsByClassName('columns')[0].style.display='none';" +
"document.getElementsByClassName('columns')[1].style.display='none';" +
"document.getElementsByClassName('columns')[2].style.display='none';" +
"document.getElementsByClassName('columns')[3].style.display='none';" +
"document.getElementsByClassName('chart-legend__wrp')[0].style.display='none';" +
"}\n)()")
val sharedPreferences = PreferenceManager.getDefaultSharedPreferences(view.context)
val darkMode = sharedPreferences.getString("dark_mode", "dark_mode_no")
if (darkMode == "dark_mode_yes") {
view.setBackgroundColor(Color.parseColor("#2e2e2e")); // matches Android's dark mode colours
}
}
}

Expand Down

0 comments on commit 3b4523b

Please sign in to comment.