diff --git a/app/build.gradle b/app/build.gradle index 717c552e..decb1360 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -11,7 +11,7 @@ android { minSdk 22 targetSdk 33 versionCode 2 - versionName "1.2.0 (W)" + versionName "1.2.1 (W)" testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" } diff --git a/app/release/output-metadata.json b/app/release/output-metadata.json index a0f823b4..a5e1eeff 100644 --- a/app/release/output-metadata.json +++ b/app/release/output-metadata.json @@ -12,7 +12,7 @@ "filters": [], "attributes": [], "versionCode": 2, - "versionName": "1.1.8 (W)", + "versionName": "1.2.0 (W)", "outputFile": "app-release.apk" } ], diff --git a/app/src/main/assets/app/app.js b/app/src/main/assets/app/app.js index 6be84d32..6cd910d6 100644 --- a/app/src/main/assets/app/app.js +++ b/app/src/main/assets/app/app.js @@ -162,7 +162,7 @@ window.addEventListener('popstate', function (event) { document.getElementById('search-container').style.display = 'none' document.getElementById('search-container').style.opacity = '1' - }, 200); + }, 250); }); @@ -223,9 +223,8 @@ function getWeather(city, latitude, longitude) { const apiUrl = `https://api.openweathermap.org/data/2.5/weather?lat=${latitude}&lon=${longitude}&appid=${apiKey}&units=metric`; setTimeout(() => { - updateMoonTrackProgress(latitude, longitude) updateSunTrackProgress(latitude, longitude); - + Fetchmoonphases(latitude, longitude) }, 500); @@ -587,7 +586,7 @@ function getWeatherByCoordinates(latitude, longitude) { setTimeout(() => { - updateMoonTrackProgress(latitude, longitude) + Fetchmoonphases(latitude, longitude) updateSunTrackProgress(latitude, longitude); }, 500); @@ -1195,68 +1194,6 @@ document.getElementById('forecast').addEventListener('scroll', function () { - -function updateMoonTrackProgress(lat, long) { - fetch(`https://api.ipgeolocation.io/astronomy?apiKey=f22c81e7a0b5448e812ad5e0e1c25242&lat=${lat}&long=${long}`) - .then(response => response.json()) - .then(data => { - const moonriseTime = parseTime(data.moonrise); - const moonsetTime = parseTime(data.moonset); - const currentTime = new Date(); - - const totalMoonlight = moonsetTime - moonriseTime; - - let timeSinceMoonrise = currentTime - moonriseTime; - - if (currentTime > moonsetTime && currentTime < new Date(currentTime.getFullYear(), currentTime.getMonth(), currentTime.getDate(), 23, 59, 59)) { - timeSinceMoonrise = totalMoonlight; - } - - const percentageOfMoonlight = (timeSinceMoonrise / totalMoonlight) * 100; - - const moonProgressWidth = Math.min(Math.max(percentageOfMoonlight, 0), 100); - - document.querySelector('moontrackprogress').style.width = `${moonProgressWidth}%`; - - const moonrise = formatTimeMoonRiseMoonSet(data.moonrise); - const moonset = data.moonset === "-:-" ? "Not available" : formatTimeMoonRiseMoonSet(data.moonset); - document.getElementById('moonrise').textContent = `${moonrise}`; - document.getElementById('moonset').textContent = `${moonset}`; - - }) - .catch(error => { - console.error('Error fetching moonrise/moonset data:', error); - }); -} - - -function parseTime(time24) { - const [hours, minutes] = time24.split(':').map(Number); - const currentDate = new Date(); - const time = new Date(currentDate.getFullYear(), currentDate.getMonth(), currentDate.getDate(), hours, minutes); - return time; -} - -function formatTimeMoonRiseMoonSet(time24) { - let [hours, minutes] = time24.split(':').map(Number); - - minutes = Math.round(minutes); - - if (minutes === 60) { - minutes = 0; - hours += 1; - } - - const period = hours >= 12 ? 'PM' : 'AM'; - - hours = hours % 12 || 12; - - minutes = minutes.toString().padStart(2, '0'); - - return `${hours}:${minutes} ${period}`; -} - - function refreshWeather(){ const latSend = localStorage.getItem('currentLat') const longSend = localStorage.getItem('currentLong') @@ -1389,6 +1326,12 @@ function toggleMapTypeChips(element) { function openLivemap(){ document.querySelector('.liveMapScreen').hidden = false; window.history.pushState({ LiveMapOpen: true }, ""); + + var passChips = document.getElementsByName('MapType'); + passChips.forEach((passChip) => { + passChip.selected = false; + }); + document.querySelector('[label="Temperature"]').selected = true; } function closeLiveMap(){ @@ -1429,4 +1372,74 @@ if(document.querySelector('[label="Rain"]').selected){ } +} + + +function Fetchmoonphases(lat, long){ + fetch(`https://weather.visualcrossing.com/VisualCrossingWebServices/rest/services/timeline/${lat},${long}?unitGroup=metric&include=days&key=4KMES28T2K3PXBCXTNYZCZFW8&contentType=json`) + .then(response => response.json()) + .then(data => { + + const moon_phase_img = document.getElementById('moon_phase_img'); + + if(data.days[0].moonphase === 0 && data.days[0].moonphase <= 0){ + document.getElementById('moonPhaseText').innerHTML = 'New Moon'; + moon_phase_img.src = 'moon_phases/moon_new.svg'; + } else if(data.days[0].moonphase > 0 && data.days[0].moonphase <= 0.25){ + document.getElementById('moonPhaseText').innerHTML = 'Waxing Crescent'; + moon_phase_img.src = 'moon_phases/moon_waxing_crescent.svg'; + } else if(data.days[0].moonphase === 0.25 && data.days[0].moonphase <= 0.25){ + document.getElementById('moonPhaseText').innerHTML = 'First Quarter'; + moon_phase_img.src = 'moon_phases/moon_first_quarter.svg'; + } else if(data.days[0].moonphase > 0.25 && data.days[0].moonphase <= 0.5){ + document.getElementById('moonPhaseText').innerHTML = 'Waxing Gibbous'; + moon_phase_img.src = 'moon_phases/moon_waxing_gibbous.svg'; + } else if(data.days[0].moonphase === 0.5 && data.days[0].moonphase <= 0.5){ + document.getElementById('moonPhaseText').innerHTML = 'Full Moon'; + moon_phase_img.src = 'moon_phases/moon_full.svg'; + } else if(data.days[0].moonphase > 0.5 && data.days[0].moonphase <= 0.75){ + document.getElementById('moonPhaseText').innerHTML = 'Waning Gibbous'; + moon_phase_img.src = 'moon_phases/moon_waning_gibbous.svg'; + } else if(data.days[0].moonphase === 0.75 && data.days[0].moonphase <= 0.75){ + document.getElementById('moonPhaseText').innerHTML = 'Last Quarter'; + moon_phase_img.src = 'moon_phases/moon_last_quarter.svg'; + } else if(data.days[0].moonphase > 0.75 && data.days[0].moonphase <= 1){ + document.getElementById('moonPhaseText').innerHTML = 'Waning Crescent'; + moon_phase_img.src = 'moon_phases/moon_waning_crescent.svg'; + } + + console.log(data) + + }) + .catch(error => console.error(error)); + + + + fetch(`https://api.ipgeolocation.io/astronomy?apiKey=63a7210d2b104646a1099d5ba223d221&lat=${lat}8&long=${long}`) +.then(response => response.json()) +.then(data => { + const moonRise = data.moonrise; + const moonSet = data.moonset; + + const moonRiseAmPm = convertToAmPm(moonRise); + const moonSetAmPm = convertToAmPm(moonSet); + + + document.getElementById('moonriseText').innerHTML = moonRiseAmPm; + document.getElementById('moonsetText').innerHTML = moonSetAmPm; + + +}) +.catch(error => console.error(error)); + + +} + +function convertToAmPm(time) { + let [hour, minute] = time.split(':'); + hour = parseInt(hour); + const ampm = hour >= 12 ? 'PM' : 'AM'; + hour = hour % 12; + hour = hour ? hour : 12; + return `${hour}:${minute} ${ampm}`; } \ No newline at end of file diff --git a/app/src/main/assets/icons/moon.png b/app/src/main/assets/icons/moon.png deleted file mode 100644 index f9534b60..00000000 Binary files a/app/src/main/assets/icons/moon.png and /dev/null differ diff --git a/app/src/main/assets/index.html b/app/src/main/assets/index.html index 2e14d001..7cc553d3 100644 --- a/app/src/main/assets/index.html +++ b/app/src/main/assets/index.html @@ -201,32 +201,28 @@

-

Moonrise & Moonset

+

Moon phase

-
-
- Moonrise -
-

+
+
+ +
+

-
-
- Moonset -
-

+
+

Moonrise:

+

Moonset:

-
-
+
- - - - - +
+ +
+

diff --git a/app/src/main/assets/moon_phases/moon_first_quarter.svg b/app/src/main/assets/moon_phases/moon_first_quarter.svg new file mode 100644 index 00000000..f15467b6 --- /dev/null +++ b/app/src/main/assets/moon_phases/moon_first_quarter.svg @@ -0,0 +1,11 @@ + + + + + + + + + + + diff --git a/app/src/main/assets/moon_phases/moon_full.svg b/app/src/main/assets/moon_phases/moon_full.svg new file mode 100644 index 00000000..c0c67d10 --- /dev/null +++ b/app/src/main/assets/moon_phases/moon_full.svg @@ -0,0 +1,10 @@ + + + + + + + + + + diff --git a/app/src/main/assets/moon_phases/moon_last_quarter.svg b/app/src/main/assets/moon_phases/moon_last_quarter.svg new file mode 100644 index 00000000..5263f436 --- /dev/null +++ b/app/src/main/assets/moon_phases/moon_last_quarter.svg @@ -0,0 +1,11 @@ + + + + + + + + + + + diff --git a/app/src/main/assets/moon_phases/moon_new.svg b/app/src/main/assets/moon_phases/moon_new.svg new file mode 100644 index 00000000..38ae6ddc --- /dev/null +++ b/app/src/main/assets/moon_phases/moon_new.svg @@ -0,0 +1,3 @@ + + + diff --git a/app/src/main/assets/moon_phases/moon_waning_crescent.svg b/app/src/main/assets/moon_phases/moon_waning_crescent.svg new file mode 100644 index 00000000..93fcba41 --- /dev/null +++ b/app/src/main/assets/moon_phases/moon_waning_crescent.svg @@ -0,0 +1,11 @@ + + + + + + + + + + + diff --git a/app/src/main/assets/moon_phases/moon_waning_gibbous.svg b/app/src/main/assets/moon_phases/moon_waning_gibbous.svg new file mode 100644 index 00000000..a055dbb2 --- /dev/null +++ b/app/src/main/assets/moon_phases/moon_waning_gibbous.svg @@ -0,0 +1,11 @@ + + + + + + + + + + + diff --git a/app/src/main/assets/moon_phases/moon_waxing_crescent.svg b/app/src/main/assets/moon_phases/moon_waxing_crescent.svg new file mode 100644 index 00000000..a5cc7cfc --- /dev/null +++ b/app/src/main/assets/moon_phases/moon_waxing_crescent.svg @@ -0,0 +1,11 @@ + + + + + + + + + + + diff --git a/app/src/main/assets/moon_phases/moon_waxing_gibbous.svg b/app/src/main/assets/moon_phases/moon_waxing_gibbous.svg new file mode 100644 index 00000000..11502cc0 --- /dev/null +++ b/app/src/main/assets/moon_phases/moon_waxing_gibbous.svg @@ -0,0 +1,11 @@ + + + + + + + + + + + diff --git a/app/src/main/assets/pages/AboutPage.html b/app/src/main/assets/pages/AboutPage.html index 9d6ab414..119c2f92 100644 --- a/app/src/main/assets/pages/AboutPage.html +++ b/app/src/main/assets/pages/AboutPage.html @@ -61,7 +61,7 @@ info
Version
-
1.2.0 (W)
+
1.2.1 (W)
diff --git a/app/src/main/assets/ui-files/ui.css b/app/src/main/assets/ui-files/ui.css index f556ffab..b806e2ff 100644 --- a/app/src/main/assets/ui-files/ui.css +++ b/app/src/main/assets/ui-files/ui.css @@ -1038,7 +1038,7 @@ suntrackprogress, moontrackprogress{ height: 100%; background-color: orange; position: relative; - transition: width 2s ease-in; + transition: width 2s ease-out; border-radius: inherit; } @@ -1058,17 +1058,6 @@ sun{ transform: translateY(-50%); } -moon{ - width: 50px; - height: 50px; - position: absolute; - background: url('../icons/moon.png'); - right: -30px; - background-size: cover; - top: 50%; - transform: translateY(-50%); -} - /* timings */ @@ -1269,7 +1258,7 @@ rainMeterBar rainmeterbaritem rainperbar rainperbarProgress{ min-height: 10%; background: #4c8df6; border: 1px solid #4c8df6; - border-radius: 10px; + border-radius: 5px; bottom: 0; left: 0; } @@ -1316,6 +1305,10 @@ rainMeterBar{ z-index: -1; } +.LiveMapWrap #livemapPreview{ + height: 100px; +} + .LiveMapWrap{ margin: 10px; padding: 10px; @@ -1408,3 +1401,37 @@ rainMeterBar{ padding: 10px; padding-bottom: 20px; } + +.moonSideWrap{ + display: flex; + justify-content: space-between; +} + +.moonSideWrap .rightWrapMoon img{ + width: 150px; +} + +.moonSideWrap .leftWrapMoon .moonPhaseNameWrap{ + padding-left: 20px; + font-family: var(--google-mid); + font-size: 20px; + color: var(--On-Surface); + padding-top: 10px; +} + +.moonSideWrap .leftWrapMoon .moonPhaseNameWrap p{ + margin: 0; +} + +.moonSideWrap .leftWrapMoon .moonrise-Set{ + padding-left: 20px; + padding-top: 20px; +} + +.moonSideWrap .leftWrapMoon .moonrise-Set p{ + color: var(--On-Surface-Variant); +} + +.moonSideWrap .leftWrapMoon .moonrise-Set span{ + color: var(--On-Surface); +} \ No newline at end of file