diff --git a/app/src/main/assets/app/renderForecastPage.js b/app/src/main/assets/app/renderForecastPage.js index f93b7a5c6..708f64bb2 100644 --- a/app/src/main/assets/app/renderForecastPage.js +++ b/app/src/main/assets/app/renderForecastPage.js @@ -315,7 +315,13 @@ async function displayDailyForecast(forecast, forecastDaily) { const dailyData = forecastDaily[date]; - const formattedDate = new Intl.DateTimeFormat('en-US', { day: 'numeric', month: 'short' }).format(dateObj); + const months = ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec']; + + + const day = dateObj.getDate(); + const month = months[dateObj.getMonth()]; + + const formattedDate = `${day} ${month}`; const rainPercentage = Math.round(forecast.precipitation_probability_max[index]) || '--'; @@ -571,7 +577,7 @@ async function displayDailyForecast(forecast, forecastDaily) { forecastTempConditionMainContent.innerHTML = `
-

${weekdayLang}, ${formattedDate}

+

${weekdayLang}

${TemperatureMax}°

/${TemperatureMin}°
@@ -592,7 +598,7 @@ async function displayDailyForecast(forecast, forecastDaily) {
wb_twilightSun
+ data-translate="sun_tile_page">Sun
diff --git a/app/src/main/assets/modules/GenerateClothingReco.js b/app/src/main/assets/modules/GenerateClothingReco.js index a4876cc34..055d73978 100644 --- a/app/src/main/assets/modules/GenerateClothingReco.js +++ b/app/src/main/assets/modules/GenerateClothingReco.js @@ -55,7 +55,6 @@ function GenerateRecommendation() { // Air quality details const { carbon_monoxide, nitrogen_dioxide, ozone, pm2_5, pm10, sulphur_dioxide } = airQualityData.current || {}; - generateAirQualityDetail(carbon_monoxide, nitrogen_dioxide, ozone, pm2_5, pm10, sulphur_dioxide); // Day Tip dayTipContainer.innerHTML = diff --git a/app/src/main/assets/modules/settingsModule.js b/app/src/main/assets/modules/settingsModule.js index 790e66583..f0fd3b5a8 100644 --- a/app/src/main/assets/modules/settingsModule.js +++ b/app/src/main/assets/modules/settingsModule.js @@ -245,20 +245,6 @@ if (HideNewUpdateToast === "true") { } // ------------------------------------- -const useRoundedUISwitch = document.getElementById("useRoundedUI"); - -useRoundedUISwitch.addEventListener("change", () => { - localStorage.setItem("UseRoundedUI", useRoundedUISwitch.selected); -}); - -const UseRoundedUI = localStorage.getItem("UseRoundedUI"); - -if (UseRoundedUI && UseRoundedUI === "true") { - useRoundedUISwitch.selected = true; -} else { - useRoundedUISwitch.selected = false; -} - document.getElementById("toggle_noti").addEventListener("change", () => { if (document.getElementById("toggle_noti").selected) { setTimeout(() => { @@ -888,4 +874,23 @@ document `${document.documentElement.getAttribute("Theme")}_ScrollFalse` ); } - }); \ No newline at end of file + }); + + + // aqi type + + const selectAQItype = document.getElementById("selectAQItype"); + + selectAQItype.addEventListener("input", () => { + localStorage.setItem("selectedAQItype", selectAQItype.value); + }); + + if (!localStorage.getItem("selectedAQItype")) { + document.querySelector(`[value="us_aqi"]`).selected = true; + } + + const getSelectedAQItype = localStorage.getItem("selectedAQItype"); + + if (localStorage.getItem("selectedAQItype")) { + document.querySelector(`[value="${getSelectedAQItype}"]`).selected = true; + } \ No newline at end of file diff --git a/app/src/main/assets/pages/conditions_pages/airQuality_forecast.html b/app/src/main/assets/pages/conditions_pages/airQuality_forecast.html new file mode 100644 index 000000000..0650973f4 --- /dev/null +++ b/app/src/main/assets/pages/conditions_pages/airQuality_forecast.html @@ -0,0 +1,362 @@ + + + + + + + Air quality Forecast + + + + + + + + + + + + + +
+ + arrow_back + +
+ +
+
+ airwave +

Air quality

+
+ + +
+ +
+

Good

+ +
+ US AQI: + EU AQI: +
+
+ +
+ + + + + +

2

+ +
+ +
+ + +
+ + + United States + European + + + +
+
+ The US AQI (Air Quality Index) is a measurement used to communicate the level of air pollution. It ranges from 0 to 500, with higher values indicating worse air quality. + + An AQI of 0–50 is considered "Good." Air quality is satisfactory, and air pollution poses little or no risk. + + An AQI of 51–100 is considered "Moderate." Air quality is acceptable; however, some pollutants may be a concern for a small number of sensitive individuals. + + An AQI of 101–150 is considered "Unhealthy for Sensitive Groups." Members of sensitive groups, such as children, the elderly, and individuals with respiratory or heart conditions, may experience health effects. The general public is not likely to be affected. + + An AQI of 151–200 is considered "Unhealthy." Everyone may begin to experience health effects, and members of sensitive groups may experience more serious effects. + + An AQI of 201–300 is considered "Very Unhealthy." Health alert: everyone may experience more serious health effects. It is advised to reduce outdoor activity. + + An AQI of 301–500 is considered "Hazardous." Health warning of emergency conditions: the entire population is more likely to be affected. Avoid outdoor activity and stay indoors with windows closed. +
+ +
+ + + + +
+ + +
+ + + + + + + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/assets/pages/settings.html b/app/src/main/assets/pages/settings.html index 7085c330b..eadb77040 100644 --- a/app/src/main/assets/pages/settings.html +++ b/app/src/main/assets/pages/settings.html @@ -174,13 +174,6 @@
- - rounded_corner -
Rounded UI
-
Use the default Material corner radius
- -
- thermometer_add
Temperature animation
@@ -329,6 +322,19 @@
+ + air +
AQI type
+ + +
United States
+
+ +
European
+
+
+
+ device_thermostat
Temperature Unit
diff --git a/app/src/main/java/com/example/weathermaster/AirQualityConditions.java b/app/src/main/java/com/example/weathermaster/AirQualityConditions.java new file mode 100644 index 000000000..667d14802 --- /dev/null +++ b/app/src/main/java/com/example/weathermaster/AirQualityConditions.java @@ -0,0 +1,384 @@ +package com.example.weathermaster; + + +import android.animation.ArgbEvaluator; +import android.animation.ObjectAnimator; +import android.annotation.SuppressLint; +import android.content.Intent; +import android.graphics.Color; +import android.net.Uri; +import android.os.Build; +import android.os.Bundle; +import android.os.Handler; +import android.view.ContextThemeWrapper; +import android.view.View; +import android.view.WindowManager; +import android.webkit.JavascriptInterface; +import android.webkit.WebSettings; +import android.webkit.WebView; +import android.webkit.WebViewClient; +import android.widget.ProgressBar; +import android.widget.Toast; + + +import androidx.annotation.RequiresApi; +import androidx.appcompat.app.AppCompatActivity; + +public class AirQualityConditions extends AppCompatActivity { + + private WebView webview; + private boolean isFirstLoad = true; + + public void onBackPressed() { + super.onBackPressed(); + } + + @Override + protected void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + + + + + setContentView(R.layout.activity_main); + + + + // Webview stuff + webview = findViewById(R.id.webView); + WebSettings webSettings = webview.getSettings(); + webSettings.setJavaScriptEnabled(true); + webSettings.setDomStorageEnabled(true); + webSettings.setAllowFileAccessFromFileURLs(true); + webSettings.setAllowUniversalAccessFromFileURLs(true); + webSettings.setAllowContentAccess(true); + webview.setVerticalScrollBarEnabled(true); + webview.setHorizontalScrollBarEnabled(false); + webview.setOverScrollMode(WebView.OVER_SCROLL_NEVER); + webview.setWebViewClient(new WebViewClientDemo()); + AndroidInterface androidInterface = new AndroidInterface(this); + webview.addJavascriptInterface(androidInterface, "AndroidInterface"); + webview.setBackgroundColor(getResources().getColor(R.color.yellowBg)); + webSettings.setTextZoom(100); + webSettings.setAllowFileAccess(true); + webview.loadUrl("file:///android_asset/pages/conditions_pages/airQuality_forecast.html"); + + webview.setWebViewClient(new WebViewClient() { + @Override + public boolean shouldOverrideUrlLoading(WebView view, String url) { + Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse(url)); + view.getContext().startActivity(intent); + return true; + } + + @Override + public void onPageFinished(WebView view, String url) { + super.onPageFinished(view, url); + + if (isFirstLoad) { + isFirstLoad = false; + + int primaryColor = new ContextThemeWrapper(AirQualityConditions.this, R.style.Base_Theme_WeatherMaster) + .getTheme() + .obtainStyledAttributes(new int[]{com.google.android.material.R.attr.colorPrimary}) + .getColor(0, 0); + + String hexColor = String.format("#%06X", (0xFFFFFF & primaryColor)); + String jsCodePrimaryColor = "CreateMaterialYouTheme('" + hexColor + "');"; + + webview.evaluateJavascript(jsCodePrimaryColor, null); + } + } + }); + } + + + + + public class AndroidInterface { + private AirQualityConditions aActivity; + + AndroidInterface(AirQualityConditions activity) { + aActivity = activity; + } + + @JavascriptInterface + public void updateStatusBarColor(final String color) { + aActivity.runOnUiThread(new Runnable() { + @SuppressLint("ResourceType") + @RequiresApi(api = Build.VERSION_CODES.O) + @Override + public void run() { + int statusBarColor; + int navigationBarColor; + int systemUiVisibilityFlags = View.SYSTEM_UI_FLAG_LIGHT_STATUS_BAR | View.SYSTEM_UI_FLAG_LIGHT_NAVIGATION_BAR; + + + if(color.equals("Scrolled")){ + statusBarColor = 0xFF1d2024; + navigationBarColor = 0xFF111318; + systemUiVisibilityFlags = 0; + + } else if (color.equals("ScrollFalse")) { + statusBarColor = 0xFF111318; + navigationBarColor = 0xFF111318; + systemUiVisibilityFlags = 0; + + } else if(color.equals("orange_material_Scrolled")){ + statusBarColor = 0xFF251e17; + navigationBarColor = 0xFF18120c; + systemUiVisibilityFlags = 0; + + } else if (color.equals("orange_material_ScrollFalse")) { + statusBarColor = 0xFF18120c; + navigationBarColor = 0xFF18120c; + systemUiVisibilityFlags = 0; + + } else if(color.equals("red_material_Scrolled")){ + statusBarColor = 0xFF271d1b; + navigationBarColor = 0xFF1a110f; + systemUiVisibilityFlags = 0; + + } else if (color.equals("red_material_ScrollFalse")) { + statusBarColor = 0xFF1a110f; + navigationBarColor = 0xFF1a110f; + systemUiVisibilityFlags = 0; + + } else if(color.equals("pink_material_Scrolled")){ + statusBarColor = 0xFF261d1f; + navigationBarColor = 0xFF191113; + systemUiVisibilityFlags = 0; + + } else if (color.equals("pink_material_ScrollFalse")) { + statusBarColor = 0xFF191113; + navigationBarColor = 0xFF191113; + systemUiVisibilityFlags = 0; + + } else if(color.equals("purple_material_Scrolled")){ + statusBarColor = 0xFF241e22; + navigationBarColor = 0xFF171216; + systemUiVisibilityFlags = 0; + + } else if (color.equals("purple_material_ScrollFalse")) { + statusBarColor = 0xFF171216; + navigationBarColor = 0xFF171216; + systemUiVisibilityFlags = 0; + + } else if(color.equals("blue_material_Scrolled")){ + statusBarColor = 0xFF1d2024; + navigationBarColor = 0xFF111318; + systemUiVisibilityFlags = 0; + + } else if (color.equals("blue_material_ScrollFalse")) { + statusBarColor = 0xFF111318; + navigationBarColor = 0xFF111318; + systemUiVisibilityFlags = 0; + + } else if(color.equals("yellow_material_Scrolled")){ + statusBarColor = 0xFF222017; + navigationBarColor = 0xFF15130b; + systemUiVisibilityFlags = 0; + + } else if (color.equals("yellow_material_ScrollFalse")) { + statusBarColor = 0xFF15130b; + navigationBarColor = 0xFF15130b; + systemUiVisibilityFlags = 0; + + } else if(color.equals("green_material_Scrolled")){ + statusBarColor = 0xFF1e201a; + navigationBarColor = 0xFF12140e; + systemUiVisibilityFlags = 0; + + } else if (color.equals("green_material_ScrollFalse")) { + statusBarColor = 0xFF12140e; + navigationBarColor = 0xFF12140e; + systemUiVisibilityFlags = 0; + + } else if (color.equals("orange_material_DialogNotScrolled")){ + statusBarColor = 0xFF0a0705; + navigationBarColor = 0xFF0a0705; + systemUiVisibilityFlags = 0; + + } else if (color.equals("orange_material_DialogScrolled")) { + statusBarColor = 0xFF0f0c09; + navigationBarColor = 0xFF0a0705; + systemUiVisibilityFlags = 0; + + } else if(color.equals("red_material_DialogNotScrolled")){ + statusBarColor = 0xFF0b0706; + navigationBarColor = 0xFF0b0706; + systemUiVisibilityFlags = 0; + + } else if (color.equals("red_material_DialogScrolled")) { + statusBarColor = 0xFF100c0b; + navigationBarColor = 0xFF0b0706; + systemUiVisibilityFlags = 0; + + } else if(color.equals("pink_material_DialogNotScrolled")){ + statusBarColor = 0xFF090708; + navigationBarColor = 0xFF090708; + systemUiVisibilityFlags = 0; + + } else if (color.equals("pink_material_DialogScrolled")) { + statusBarColor = 0xFF0e0d0b; + navigationBarColor = 0xFF090708; + systemUiVisibilityFlags = 0; + + } else if(color.equals("purple_material_DialogNotScrolled")){ + statusBarColor = 0xFF090709; + navigationBarColor = 0xFF090709; + systemUiVisibilityFlags = 0; + + } else if (color.equals("purple_material_DialogScrolled")) { + statusBarColor = 0xFF0e0c0e; + navigationBarColor = 0xFF090709; + systemUiVisibilityFlags = 0; + + } else if(color.equals("blue_material_DialogNotScrolled")){ + statusBarColor = 0xFF07080a; + navigationBarColor = 0xFF07080a; + systemUiVisibilityFlags = 0; + + } else if (color.equals("blue_material_DialogScrolled")) { + statusBarColor = 0xFF0c0d0e; + navigationBarColor = 0xFF07080a; + systemUiVisibilityFlags = 0; + + } else if(color.equals("yellow_material_DialogNotScrolled")){ + statusBarColor = 0xFF080804; + navigationBarColor = 0xFF080804; + systemUiVisibilityFlags = 0; + + } else if (color.equals("yellow_material_DialogScrolled")) { + statusBarColor = 0xFF0e0d09; + navigationBarColor = 0xFF080804; + systemUiVisibilityFlags = 0; + + } else if(color.equals("green_material_DialogNotScrolled")){ + statusBarColor = 0xFF070806; + navigationBarColor = 0xFF070806; + systemUiVisibilityFlags = 0; + + } else if (color.equals("green_material_DialogScrolled")) { + statusBarColor = 0xFF0c0d0a; + navigationBarColor = 0xFF070806; + systemUiVisibilityFlags = 0; + + + } else if (color.equals("GoBack")){ + back(); + return; + } else if (color.equals("OpenTermsConditions")){ + + return; + } else if (color.equals("OpenPrivacyPolicy")){ + + return; + } else if (color.equals("OpenLicenses")){ + + return; + + } else if (color.equals("bluesetDef")) { + + return; + } else if (color.equals("keepiton")) { + getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON); + return; + } else if (color.equals("keepitoff")) { + getWindow().clearFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON); + return; + } else if (color.equals("itsOn")) { + Toast.makeText(aActivity, "Your device will stay awake", Toast.LENGTH_SHORT).show(); + return; + } else if (color.equals("ItsOff")) { + Toast.makeText(aActivity, "Your device will go to sleep at the default time", Toast.LENGTH_SHORT).show(); + return; + + + } else { + Toast.makeText(aActivity, "not found", Toast.LENGTH_SHORT).show(); + return; + } + + + int currentStatusBarColor = aActivity.getWindow().getStatusBarColor(); + int currentNavigationBarColor = aActivity.getWindow().getNavigationBarColor(); + + ObjectAnimator statusBarAnimator = ObjectAnimator.ofObject( + aActivity.getWindow(), + "statusBarColor", + new ArgbEvaluator(), + currentStatusBarColor, + statusBarColor + ); + + statusBarAnimator.setDuration(200); + statusBarAnimator.start(); + + ObjectAnimator navBarAnimator = ObjectAnimator.ofObject( + aActivity.getWindow(), + "navigationBarColor", + new ArgbEvaluator(), + currentNavigationBarColor, + navigationBarColor + ); + + navBarAnimator.setDuration(200); + navBarAnimator.start(); + + aActivity.getWindow().setNavigationBarColor(navigationBarColor); + + View decorView = aActivity.getWindow().getDecorView(); + decorView.setSystemUiVisibility(systemUiVisibilityFlags); + + + } + }); + } + + + + } + + public void back() { + onBackPressed(); + } + + + + private static class WebViewClientDemo extends WebViewClient { + + @Override + public boolean shouldOverrideUrlLoading(WebView view, String url) { + if (shouldOpenInBrowser(url)) { + Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse(url)); + view.getContext().startActivity(intent); + return true; + + } else { + view.loadUrl(url); + return true; + + + } + + + } + + private boolean shouldOpenInBrowser(String url) { + return url.startsWith("https://fonts.google.com/specimen/Outfit?query=outfit") || + url.startsWith("https://openweathermap.org/") || + url.startsWith("https://fonts.google.com/specimen/Poppins?query=poppins") || + url.startsWith("https://github.com/material-components/material-web") || + url.startsWith("https://app-privacy-policy-generator.nisrulz.com/") || + url.startsWith("https://github.com/PranshulGG/WeatherMaster") || + url.startsWith("mailto:pranshul.devmain@gmail.com")|| + url.startsWith("https://github.com/PranshulGG/WeatherMaster/releases")|| + url.startsWith("https://leafletjs.com/"); + + + } + + + } +} \ No newline at end of file diff --git a/app/src/main/java/com/example/weathermaster/MainActivity.java b/app/src/main/java/com/example/weathermaster/MainActivity.java index c3789ca4d..974bb25e5 100644 --- a/app/src/main/java/com/example/weathermaster/MainActivity.java +++ b/app/src/main/java/com/example/weathermaster/MainActivity.java @@ -488,6 +488,9 @@ public class MainActivity extends AppCompatActivity { } else if (color.equals("OpenClothingPage")){ OpenClothingPage(); return; + } else if (color.equals("OpenAirQualityCondition")){ + openAirQualityCondition(); + return; } else if (color.equals("OpenGithubReleaseLatest")){ openGithubReleases(); return; @@ -637,6 +640,10 @@ public class MainActivity extends AppCompatActivity { Intent intent = new Intent(mActivity, MoonPhases.class); mActivity.startActivity(intent); } + public void openAirQualityCondition() { + Intent intent = new Intent(mActivity, AirQualityConditions.class); + mActivity.startActivity(intent); + } } private void openGithubReleases() { diff --git a/app/src/main/res/values/themes.xml b/app/src/main/res/values/themes.xml index 98163ddd0..0050cfd38 100644 --- a/app/src/main/res/values/themes.xml +++ b/app/src/main/res/values/themes.xml @@ -40,7 +40,6 @@ #0c1822 #afc6ff -