Added air quality page, removed aqi tips, option to change from us aqi to eu aqi

This commit is contained in:
Pranshul committed 2025-01-01 22:13:04 +05:30
1 parent 328bdb88ca
commit d62e8a62d0
10 files changed
+821 -34

No files matched your search

@@ -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 = `
<div class="top-details">
<p>${weekdayLang}, ${formattedDate}</p>
<p>${weekdayLang}</p>
<div>
<tempLarge><p>${TemperatureMax}° </p> <span>/${TemperatureMin}°</span></tempLarge>
<img src="${GetWeatherIcon(DailyWeatherCode, 1)}">
@@ -592,7 +598,7 @@ async function displayDailyForecast(forecast, forecastDaily) {
<div class="currentConditionItem sunRISESET ripple_btn_low" data-id="1"
>
<div class="currentConditionItemTitle"><i icon-filled>wb_twilight</i><span
data-translate="sun">Sun</span></div>
data-translate="sun_tile_page">Sun</span></div>
<div class="current_condition_icon">
<svg height="110.0dip" width="176.0dip" viewBox="0 0 176.0 110.0"
+25 -6
View File
@@ -1015,24 +1015,43 @@ if(percentageOfDaylight < 100){
function AirQuaility(data) {
const aqi = data.current.us_aqi;
// const
const aqiEU = data.current.european_aqi || 'N/A';
let aqiCategory;
if (aqi <= 50) {
aqiCategory = 1;
} else if (aqi <= 100) {
if(localStorage.getItem('selectedAQItype') === 'eu_aqi'){
if (aqiEU <= 25) {
aqiCategory = 1;
} else if (aqiEU <= 50) {
aqiCategory = 2;
} else if (aqi <= 150) {
} else if (aqiEU <= 75) {
aqiCategory = 3;
} else if (aqi <= 200) {
} else if (aqiEU <= 100) {
aqiCategory = 4;
} else {
aqiCategory = 5;
}
document.getElementById("aqi-level-value").innerHTML = aqiEU;
} else{
if (aqi <= 50) {
aqiCategory = 1;
} else if (aqi <= 100) {
aqiCategory = 2;
} else if (aqi <= 150) {
aqiCategory = 3;
} else if (aqi <= 200) {
aqiCategory = 4;
} else {
aqiCategory = 5;
}
document.getElementById("aqi-level-value").innerHTML = aqi;
}
document.getElementById("pm25_air").innerHTML = Math.round(
data.current.pm2_5
);
+1 -1
View File
@@ -623,7 +623,7 @@
<div class="all_air_quality air_selector" data-id="5"
<div class="all_air_quality air_selector ripple_btn_low" data-id="5" onclick="sendThemeToAndroid('OpenAirQualityCondition')"
style="border-radius: 10px; margin-bottom: 0px; overflow: hidden; box-shadow: 0px 6px 6px rgba(0, 0, 0, 0.2);"
id="ifPollenIsThere">
<div class="sun_text">
@@ -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 =
+20 -15
View File
@@ -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`
);
}
});
});
// 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;
}
@@ -0,0 +1,362 @@
<!DOCTYPE html>
<html lang="en" Theme="clothing" data-theme="dark">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=0">
<title>Air quality Forecast</title>
<script src="../../database/MainDataBase.js"></script>
<link rel="stylesheet" href="../../ui-files/font-usage.css">
<link rel="stylesheet" href="../../ui-files/variables.css">
<link rel="stylesheet" href="../../components/components.css">
<link rel="stylesheet" href="../../ripple-files/ripple.css">
<link rel="stylesheet" href="../../components/modal-ver.css">
<link rel="stylesheet" href="condition_pageUI.css">
<script src="../../langs/langs.js"></script>
<style>
.condition_info_content::before {
position: fixed;
bottom: 0;
content: '';
width: 100%;
background: linear-gradient(0deg, var(--Surface) 10%, rgba(255, 0, 0, 0));
height: 30px;
z-index: 1;
}
.top_aqi_holder_main{
display: flex;
justify-content: space-between;
background-color: var(--Surface-Container);
margin: 10px;
border-radius: 20px;
padding: 20px;
padding-left: 15px;
padding-right: 15px;
}
.svg_mat_icon_aqi svg{
width: 100px;
height: 100px;
}
.aqi_data_info{
display: flex;
flex-direction: column;
justify-content: space-between;
align-items: flex-start;
}
.aqi_data_info p{
color: var(--Primary);
font-family: var(--google-mid);
font-size: 18px;
}
.aqi_data_info{
color: var(--On-Surface-Variant);
font-family: var(--google-normal);
}
.aqi_full{
display: flex;
flex-direction: column;
justify-content: space-between;
align-items: flex-start;
gap: 3px;
}
#aqi_value_point{
position: absolute;
color: white;
font-family: var(--google-mid);
font-size: 40px;
}
.svg_mat_icon_aqi{
display: flex;
align-items: center;
justify-content: center;
}
.aqi_hidden_divs{
animation: aqi_hidden_divs 0.5s cubic-bezier(1,0,0,1);
}
@keyframes aqi_hidden_divs{
0%{
opacity: 0;
transform: translateY(100%);
}
100%{
transform: translateY(0%);
opacity: 1;
}
}
</style>
</head>
<body>
<div class="top_conditions_for_header">
<md-icon-button onclick="sendThemeToAndroid('GoBack')">
<md-icon icon-outlined>arrow_back</md-icon>
</md-icon-button>
</div>
<div class="condition_info_content">
<div class="condition_label_forecast">
<md-icon icon-outlined>airwave</md-icon>
<p data-translate="air_quality">Air quality</p>
</div>
<div class="top_aqi_holder_main">
<div class="aqi_data_info">
<p id="aqi_name">Good</p>
<div class="aqi_full">
<span id="us_aqi_value">US AQI: </span>
<span id="eu_aqi_value">EU AQI:</span>
</div>
</div>
<div class="svg_mat_icon_aqi">
<svg viewBox="0 0 161 161" fill="none" xmlns="http://www.w3.org/2000/svg">
<path id="aqi-level-color" d="M117.643 14.7482C124.891 15.2419 131.714 18.3443 136.85 23.4812C141.987 28.6182 145.088 35.4419 145.581 42.6895C146.027 49.2393 148.606 55.4628 152.923 60.4082C157.7 65.8818 160.331 72.9005 160.331 80.1651C160.331 87.4297 157.7 94.4483 152.923 99.922C148.606 104.869 146.029 111.094 145.584 117.644C145.091 124.892 141.988 131.715 136.851 136.851C131.714 141.988 124.891 145.089 117.643 145.582C111.092 146.027 104.867 148.606 99.9207 152.924C94.4475 157.702 87.4287 160.334 80.1639 160.334C72.899 160.334 65.8802 157.702 60.407 152.924C55.461 148.608 49.2376 146.031 42.6882 145.586C35.4407 145.092 28.6175 141.99 23.4812 136.853C18.3449 131.716 15.2434 124.892 14.7507 117.644C14.3056 111.093 11.7266 104.868 7.40823 99.922C2.63178 94.4483 0 87.4297 0 80.1651C0 72.9005 2.63178 65.8818 7.40823 60.4082C11.7242 55.4621 14.3018 49.2388 14.747 42.6895C15.2406 35.442 18.343 28.6187 23.48 23.4824C28.617 18.3461 35.4407 15.2446 42.6882 14.752C49.2393 14.3065 55.4641 11.7276 60.4107 7.40945C65.884 2.63227 72.9028 0 80.1676 0C87.4324 0 94.4512 2.63227 99.9245 7.40945C104.871 11.7254 111.094 14.303 117.643 14.7482Z" fill=""/>
</svg>
<p id="aqi_value_point">2</p>
</div>
</div>
<div class="eq_us_Switcher" style="padding-bottom: 20px;">
<md-tabs id="change_aqi_type_tabs">
<md-primary-tab>United States</md-primary-tab>
<md-primary-tab>European</md-primary-tab>
</md-tabs>
<div class="aqi_info_us aqi_hidden_divs">
<div class="info__forecast">
<span >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.</span>
<span >An AQI of 0–50 is considered "Good." Air quality is satisfactory, and air pollution poses little or no risk.</span>
<span >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.</span>
<span >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.</span>
<span >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.</span>
<span >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.</span>
<span >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.</span>
</div>
</div>
<div class="aqi_info_eu aqi_hidden_divs" hidden>
<div class="info__forecast">
<span>The EU AQI (Air Quality Index) is a measurement used to communicate the level of air pollution in the European Union. It is divided into five levels, from "Good" to "Very Poor," based on the concentration of key pollutants.</span>
<span>An AQI of 0–25 is considered "Good." Air quality is excellent, and pollution poses no risk to health.</span>
<span>An AQI of 26–50 is considered "Fair." Air quality is generally acceptable, though a small number of particularly sensitive individuals may experience minor discomfort.</span>
<span>An AQI of 51–75 is considered "Moderate." Air quality is acceptable, but some pollutants could cause a health risk for sensitive individuals, particularly during prolonged exposure.</span>
<span>An AQI of 76–100 is considered "Poor." Air quality may affect health, particularly for sensitive groups, such as individuals with respiratory or cardiovascular conditions.</span>
<span>An AQI above 100 is considered "Very Poor." Air quality poses a significant health risk to the general population. It is advised to reduce outdoor activities and take precautions.</span>
</div>
</div>
</div>
</div>
<script>
function hexToRgb(hex) {
const bigint = parseInt(hex.slice(1), 16);
return {
r: (bigint >> 16) & 255,
g: (bigint >> 8) & 255,
b: bigint & 255
};
}
function rgbToHsl({ r, g, b }) {
r /= 255;
g /= 255;
b /= 255;
const max = Math.max(r, g, b);
const min = Math.min(r, g, b);
let h, s, l = (max + min) / 2;
if (max === min) {
h = s = 0; // Achromatic
} else {
const d = max - min;
s = l > 0.5 ? d / (2 - max - min) : d / (max + min);
switch (max) {
case r: h = (g - b) / d + (g < b ? 6 : 0); break;
case g: h = (b - r) / d + 2; break;
case b: h = (r - g) / d + 4; break;
}
h /= 6;
}
return { h: h * 360, s: s * 100, l: l * 100 };
}
async function CreateMaterialYouTheme(hex) {
const colors = {
orange_material: "#FFA500",
red_material: "#FF0000",
pink_material: "#FFC0CB",
purple_material: "#800080",
blue_material: "#0000FF",
yellow_material: "#FFFF00",
green_material: "#008000"
};
const targetHsl = rgbToHsl(hexToRgb(hex));
let closestColor = null;
let smallestHueDifference = Infinity;
for (const [color, colorHex] of Object.entries(colors)) {
const colorHsl = rgbToHsl(hexToRgb(colorHex));
const hueDifference = Math.abs(targetHsl.h - colorHsl.h);
if (hueDifference < smallestHueDifference) {
smallestHueDifference = hueDifference;
closestColor = color;
}
}
if(localStorage.getItem("useDynamicColors") && localStorage.getItem("useDynamicColors") === "false"){
if (await customStorage.getItem("customTheme")) {
document.documentElement.setAttribute(
"Theme",
await customStorage.getItem("customTheme")
);
sendThemeToAndroid(
`${document.documentElement.getAttribute("Theme")}_ScrollFalse`
);
}
} else{
document.documentElement.setAttribute('Theme', closestColor);
sendThemeToAndroid(`${closestColor}_ScrollFalse`);
}
}
function sendThemeToAndroid(theme) {
AndroidInterface.updateStatusBarColor(theme);
};
// main
function renderAqiData(data){
const aqi = data.current.us_aqi;
let aqiCategory;
if (aqi <= 50) {
aqiCategory = 1;
} else if (aqi <= 100) {
aqiCategory = 2;
} else if (aqi <= 150) {
aqiCategory = 3;
} else if (aqi <= 200) {
aqiCategory = 4;
} else {
aqiCategory = 5;
}
const aqiEU = data.current.european_aqi || 'No data';
let aqiCategoryEU;
if (aqiEU <= 25) {
aqiCategoryEU = 1;
} else if (aqiEU <= 50) {
aqiCategoryEU = 2; // Fair
} else if (aqiEU <= 75) {
aqiCategoryEU = 3; // Moderate
} else if (aqiEU <= 100) {
aqiCategoryEU = 4; // Poor
} else {
aqiCategoryEU = 5; // Very Poor
}
const backgroundColor = {
1: "#43b710",
2: "#eaaf10",
3: "#eb8a11",
4: "#e83f0f",
5: "#8e3acf",
};
if(localStorage.getItem('selectedAQItype') === 'eu_aqi'){
document.getElementById('aqi_value_point').innerHTML = aqiCategoryEU;
document.getElementById("aqi-level-color").style.fill = backgroundColor[aqiCategoryEU];
} else{
document.getElementById('aqi_value_point').innerHTML = aqiCategory;
document.getElementById("aqi-level-color").style.fill = backgroundColor[aqiCategory];
}
document.getElementById('us_aqi_value').innerHTML = `United States AQI: ${aqi}`
document.getElementById('eu_aqi_value').innerHTML = `European AQI: ${aqiEU}`
}
document.getElementById('change_aqi_type_tabs').addEventListener('change', () => {
if (event.target.activeTabIndex === 0) {
document.querySelector('.aqi_info_us').hidden = false;
document.querySelector('.aqi_info_eu').hidden = true;
} else{
document.querySelector('.aqi_info_us').hidden = true;
document.querySelector('.aqi_info_eu').hidden = false;
}
});
renderAqiData(JSON.parse(localStorage.getItem(`AirQuality_${localStorage.getItem('CurrentLocationName')}`)))
</script>
<script src="../../app/navigate.js"></script>
<script src="../../components-script.js/components.js"></script>
<script src="../../ripple-files/icon-ripple.js"></script>
<script src="../../modules/scroll.js"></script>
<script src="../../bundle.js"></script>
<script type="module" src="../../index.js"></script>
<script src="../../modules/ripple_acc.js"></script>
</body>
</html>
+13 -7
View File
@@ -174,13 +174,6 @@
</div>
</md-list-item>
<md-list-item>
<md-icon icon-filled slot="start">rounded_corner</md-icon>
<div slot="headline" data-translate="rounded_ui">Rounded UI</div>
<div slot="supporting-text" data-translate="use_the_default_material_corner_radius">Use the default Material corner radius</div>
<md-switch slot="end" id="useRoundedUI" ></md-switch>
</md-list-item>
<md-list-item>
<md-icon icon-filled slot="start">thermometer_add</md-icon>
<div slot="headline" data-translate="temperature_animation">Temperature animation</div>
@@ -329,6 +322,19 @@
</md-list-item>
<md-list-item margin>
<md-icon icon-filled slot="start">air</md-icon>
<div slot="headline">AQI type</div>
<md-outlined-select id="selectAQItype" slot="end" style="min-width: max-content; --md-outlined-field-bottom-space: 10px;--md-outlined-field-top-space: 10px;">
<md-select-option value="us_aqi" menu-type>
<div slot="headline">United States</div>
</md-select-option>
<md-select-option value="eu_aqi" menu-type>
<div slot="headline">European</div>
</md-select-option>
</md-outlined-select>
</md-list-item>
<md-list-item margin>
<md-icon icon-filled slot="start">device_thermostat</md-icon>
<div slot="headline" data-translate="temperature_unit">Temperature Unit</div>
@@ -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/");
}
}
}
@@ -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() {
-1
View File
@@ -40,7 +40,6 @@
<item name="android:statusBarColor">#0c1822</item>
<item name="colorAccent">#afc6ff</item>
</style>
<style name="ScreensAll" parent="Theme.AppCompat.NoActionBar">