From 0d6c6a1d52c45e8c1e99fcfe3c381c1a74a3351b Mon Sep 17 00:00:00 2001 From: Pranshul Date: Thu, 21 Nov 2024 18:51:08 +0530 Subject: [PATCH] updated v1.8.5 fixed #148, #146, #143, #141, #142 --- app/build.gradle | 4 +- app/release/output-metadata.json | 4 +- app/src/main/AndroidManifest.xml | 12 + app/src/main/assets/app/apiKeysRotation.js | 2 +- app/src/main/assets/app/app.js | 38 +- app/src/main/assets/app/fetch.js | 34 +- app/src/main/assets/app/renderWeather.js | 26 +- app/src/main/assets/icons/mat_shape_1.svg | 62 +++ app/src/main/assets/index.html | 35 +- .../assets/modules/GenerateClothingReco.js | 280 ++++++++++++++ app/src/main/assets/pages/AboutPage.html | 4 +- .../assets/pages/ClothingRecommendation.html | 212 ++++++++++ app/src/main/assets/pages/Homelocations.html | 362 ++++++++++++++++++ app/src/main/assets/pages/settings.html | 196 ++++++---- app/src/main/assets/providers/accuweather.js | 31 +- app/src/main/assets/providers/met-norway.js | 8 +- app/src/main/assets/ui-files/ui.css | 97 ++--- app/src/main/assets/ui-files/variables.css | 44 +++ .../weathermaster/ClothingRecommendation.java | 214 +++++++++++ .../example/weathermaster/Homelocations.java | 214 +++++++++++ .../example/weathermaster/MainActivity.java | 9 + .../weathermaster/SettingsActivity.java | 8 + app/src/main/res/values/themes.xml | 6 + 23 files changed, 1705 insertions(+), 197 deletions(-) create mode 100644 app/src/main/assets/icons/mat_shape_1.svg create mode 100644 app/src/main/assets/modules/GenerateClothingReco.js create mode 100644 app/src/main/assets/pages/ClothingRecommendation.html create mode 100644 app/src/main/assets/pages/Homelocations.html create mode 100644 app/src/main/java/com/example/weathermaster/ClothingRecommendation.java create mode 100644 app/src/main/java/com/example/weathermaster/Homelocations.java diff --git a/app/build.gradle b/app/build.gradle index 453198e8..010b3639 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -10,8 +10,8 @@ android { applicationId "com.example.weathermaster" minSdk 22 targetSdk 33 - versionCode 76 - versionName "1.8.4 (W)" + versionCode 77 + versionName "1.8.5 (W)" testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" } diff --git a/app/release/output-metadata.json b/app/release/output-metadata.json index 711ac08d..dcb829cf 100644 --- a/app/release/output-metadata.json +++ b/app/release/output-metadata.json @@ -11,8 +11,8 @@ "type": "SINGLE", "filters": [], "attributes": [], - "versionCode": 76, - "versionName": "1.8.4 (W)", + "versionCode": 77, + "versionName": "1.8.5 (W)", "outputFile": "app-release.apk" } ], diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index dec1a1e9..01f92ab6 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -115,6 +115,18 @@ android:exported="true" android:theme="@style/ScreensAll" /> + + { scrollView.addEventListener('touchend', () => { setTimeout(() => { - sendThemeToAndroid("EnableSwipeRefresh"); + checkTopScroll() isSwipeDisabledHori = false; }, 400); }); +let isSwipeDisabledHoriForecast = false; + +document.getElementById('forecast').addEventListener('touchstart', () => { + if (!isSwipeDisabledHoriForecast) { + sendThemeToAndroid("DisableSwipeRefresh"); + isSwipeDisabledHoriForecast = true; + } +}); + +document.getElementById('forecast').addEventListener('touchend', () => { + setTimeout(() => { + checkTopScroll() + isSwipeDisabledHoriForecast = false; + }, 400); +}); + + + scrollView.addEventListener('scroll', debounce(saveScrollPosition, 200)); scrollView.addEventListener('scroll', updateActiveIndicator); @@ -1752,4 +1776,12 @@ showLoader(); hideLoader() } +} + +function checkTopScroll(){ + if(document.getElementById('weather_wrap').scrollTop === 0){ + sendThemeToAndroid('EnableSwipeRefresh') + } else{ + sendThemeToAndroid('DisableSwipeRefresh') + } } \ No newline at end of file diff --git a/app/src/main/assets/app/fetch.js b/app/src/main/assets/app/fetch.js index ec092f4b..c2411e10 100644 --- a/app/src/main/assets/app/fetch.js +++ b/app/src/main/assets/app/fetch.js @@ -5,7 +5,7 @@ function getCountryName(code) { async function DecodeWeather(lat, lon, suggestionText, refreshValue){ - const apiKey = 'Garbage'; + const apiKey = 'API'; const url = `https://api.timezonedb.com/v2.1/get-time-zone?key=${apiKey}&format=json&by=position&lat=${lat}&lng=${lon}`; try { @@ -16,12 +16,16 @@ async function DecodeWeather(lat, lon, suggestionText, refreshValue){ FetchWeather(lat, lon, data.zoneName, suggestionText, refreshValue) } else { console.error('Error fetching timezone:', data); - DecodeWeather(lat, lon, suggestionText, refreshValue) + setTimeout(() =>{ + DecodeWeather(lat, lon, suggestionText, refreshValue) + }, 2500) return null; } } catch (error) { console.error('Error:', error); + setTimeout(() =>{ DecodeWeather(lat, lon, suggestionText, refreshValue) + }, 2500) return null; } } @@ -72,7 +76,7 @@ document.querySelector('.data_provider_name_import').innerHTML = 'Data by Met no function MoreDetails(latSum, lonSum, suggestionText) { - fetch(`https://api.weatherapi.com/v1/forecast.json?key=Garbage&q=${latSum},${lonSum}`) + fetch(`https://api.weatherapi.com/v1/forecast.json?key=API&q=${latSum},${lonSum}`) .then(response => response.json()) .then(data => { @@ -88,7 +92,7 @@ document.querySelector('.data_provider_name_import').innerHTML = 'Data by Met no function astronomyData(latSum, lonSum, suggestionText) { - fetch(`https://api.weatherapi.com/v1/astronomy.json?key=Garbage&q=${latSum},${lonSum}`) + fetch(`https://api.weatherapi.com/v1/astronomy.json?key=API&q=${latSum},${lonSum}`) .then(response => response.json()) .then(data => { @@ -101,7 +105,7 @@ document.querySelector('.data_provider_name_import').innerHTML = 'Data by Met no FetchAlert(lat, lon, suggestionText) function FetchAlert(lat, lon, suggestionText){ - fetch(`https://api.weatherapi.com/v1/alerts.json?key=Garbage&q=${lat},${lon}`) + fetch(`https://api.weatherapi.com/v1/alerts.json?key=API&q=${lat},${lon}`) .then(response => response.json()) .then(data => { @@ -119,11 +123,14 @@ IFSavedLocation(lat, lon,suggestionText) const currentLocationName = localStorage.getItem('CurrentLocationName') if(suggestionText === SavedLocation.name || suggestionText === 'CurrentDeviceLocation' && suggestionText === currentLocationName || !refreshValue){ - ReturnHomeLocation() + setTimeout(()=>{ + ReturnHomeLocation() + }, 1000); } else if (refreshValue){ setTimeout(() =>{ LoadLocationOnRequest(lat, lon, suggestionText) document.getElementById('last_updated').innerHTML = `Updated, just now`; + ShowSnackMessage.ShowSnack("Latest data fetched", "short"); }, 1000) setTimeout(() =>{ document.getElementById('last_updated').innerHTML = `Updated, just now`; @@ -136,12 +143,17 @@ document.querySelector('savedLocationsHolder').innerHTML = '' setTimeout(() => { loadSavedLocations() -}, 200) +}, 1000) hideLoader() }).catch(error =>{ - ShowError() +document.querySelector('savedLocationsHolder').innerHTML = '' + +setTimeout(() => { + loadSavedLocations() + ReturnHomeLocation() +}, 1000) document.getElementById('error_text_content').innerHTML = error }) @@ -229,7 +241,7 @@ function saveCache(lat, lon, timezone, suggestionText) { setTimeout(() => { loadSavedLocations() - }, 200) + }, 1000) }); } @@ -272,7 +284,7 @@ document.querySelector('savedLocationsHolder').innerHTML = '' setTimeout(() => { loadSavedLocations() -}, 200) +}, 1000) }) .catch(error => { @@ -304,7 +316,7 @@ document.querySelector('savedLocationsHolder').innerHTML = '' setTimeout(() => { loadSavedLocations() -}, 200) +}, 1000) }) .catch(error => { diff --git a/app/src/main/assets/app/renderWeather.js b/app/src/main/assets/app/renderWeather.js index c98f62a1..f5e0e05a 100644 --- a/app/src/main/assets/app/renderWeather.js +++ b/app/src/main/assets/app/renderWeather.js @@ -50,9 +50,9 @@ function HourlyWeather(data) { let PrecAmount; if (SelectedPrecipitationUnit === 'in') { - PrecAmount = mmToInches(data.hourly.precipitation[index]).toFixed(2) + ' in'; + PrecAmount = mmToInches(data.hourly.precipitation[index]).toFixed(2) + ''; } else { - PrecAmount = data.hourly.precipitation[index].toFixed(1) + ' mm'; + PrecAmount = data.hourly.precipitation[index].toFixed(1) + ''; } const PrecProb = data.hourly.precipitation_probability[index] @@ -72,18 +72,18 @@ function HourlyWeather(data) { } const maxRain = 2; - const rainAmountPercent = (data.hourly.precipitation[index] / maxRain) * 100; - - + const rainAmountPercent = data.hourly.precipitation[index] + ? (data.hourly.precipitation[index] / maxRain) * 100 + : 0; let barColor; if (data.hourly.precipitation[index] < 0.5) { - barColor = '#4c8df6' + barColor = 'var(--Primary-Container)'; } else if (data.hourly.precipitation[index] > 0.5 && data.hourly.precipitation[index] <= 1) { - barColor = 'orange' + barColor = 'var(--Primary-Container)'; } else if (data.hourly.precipitation[index] > 1) { - barColor = 'red' + barColor = 'var(--Primary)'; } @@ -128,9 +128,9 @@ function HourlyWeather(data) { +

${PrecAmount}

+

${data.hourly.precipitation_probability[index]}%

-

${PrecAmount}

-

${data.hourly.precipitation_probability[index]}%

${hours}${period} @@ -695,9 +695,9 @@ const percentageOfDaylight = Math.round(calculateDaylightPercentage(sunrise, sun - const recommendation = getClothingRecommendation(temperatureCLoths) +// const recommendation = getClothingRecommendation(temperatureCLoths) - document.getElementById('cloth_recommended').textContent = getTranslationByLang(localStorage.getItem('AppLanguageCode'), recommendation) +// document.getElementById('cloth_recommended').textContent = getTranslationByLang(localStorage.getItem('AppLanguageCode'), recommendation) } @@ -1216,13 +1216,11 @@ function FetchAlertRender(data){ if(data.alerts.alert && data.alerts.alert.length > 0){ - document.querySelector('.weatherCommentsDiv').classList.add('alertOpened'); document.querySelector('.excessiveHeat').hidden = false; localStorage.setItem('AlertCache', JSON.stringify(data.alerts.alert)); } else { console.log('No alerts'); - document.querySelector('.weatherCommentsDiv').classList.remove('alertOpened'); document.querySelector('.excessiveHeat').hidden = true; localStorage.removeItem('AlertCache', JSON.stringify(data.alerts.alert)); diff --git a/app/src/main/assets/icons/mat_shape_1.svg b/app/src/main/assets/icons/mat_shape_1.svg new file mode 100644 index 00000000..51edb811 --- /dev/null +++ b/app/src/main/assets/icons/mat_shape_1.svg @@ -0,0 +1,62 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/app/src/main/assets/index.html b/app/src/main/assets/index.html index 335a59b2..c1268a5a 100644 --- a/app/src/main/assets/index.html +++ b/app/src/main/assets/index.html @@ -24,7 +24,7 @@
@@ -112,8 +112,8 @@

-
-
+
+

@@ -131,9 +131,9 @@

-