Skip to content

Commit

Permalink
updated v1.8.5 fixed #148, #146, #143, #141, #142
Browse files Browse the repository at this point in the history
  • Loading branch information
PranshulGG committed Nov 21, 2024
1 parent 29a160c commit 0d6c6a1
Show file tree
Hide file tree
Showing 23 changed files with 1,705 additions and 197 deletions.
4 changes: 2 additions & 2 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -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"
}

Expand Down
4 changes: 2 additions & 2 deletions app/release/output-metadata.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
}
],
Expand Down
12 changes: 12 additions & 0 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,18 @@
android:exported="true"
android:theme="@style/ScreensAll"
/>
<activity
android:name=".Homelocations"
android:screenOrientation="portrait"
android:exported="true"
android:theme="@style/ScreensAll"
/>
<activity
android:name=".ClothingRecommendation"
android:screenOrientation="portrait"
android:exported="true"
android:theme="@style/clothingMainPage"
/>
<activity
android:name=".MainActivity"
android:theme="@style/app_theme"
Expand Down
2 changes: 1 addition & 1 deletion app/src/main/assets/app/apiKeysRotation.js
Original file line number Diff line number Diff line change
@@ -1 +1 @@
// Garbage file
// Not needed anymore
38 changes: 35 additions & 3 deletions app/src/main/assets/app/app.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@

//E:\MYAPPS\WeatherMaster\app\release

const DefaultLocation = JSON.parse(localStorage.getItem('DefaultLocation'));

let currentApiKeyIndex = 0;
Expand All @@ -11,6 +13,8 @@ ShowSnackMessage.ShowSnack("Please wait before refreshing again.", "long");
}




function handleStorageChange(event) {
if (event.key === 'SelectedTempUnit' ||
event.key === 'SelectedWindUnit' ||
Expand Down Expand Up @@ -350,6 +354,8 @@ function GetSavedSearchLocation(){
saveLocationToContainer(searchedItem.LocationName, searchedItem.latitude, searchedItem.longitude)
}

ShowSnackMessage.ShowSnack("Loading location data", "short");

}

function handleStorageChangeSearch(event) {
Expand Down Expand Up @@ -850,7 +856,7 @@ window.addEventListener('popstate', function (event) {
document.getElementById('city-input').dispatchEvent(new Event('input'));
document.getElementById('search-container').style.display = 'none'
document.getElementById('search-container').style.opacity = '1'
sendThemeToAndroid("EnableSwipeRefresh")
checkTopScroll()
cityList.innerHTML = '';
cityInput.value = '';

Expand Down Expand Up @@ -1043,7 +1049,7 @@ checkNoInternet();

document.addEventListener('DOMContentLoaded', async function() {

const currentVersion = 'v1.8.4';
const currentVersion = 'v1.8.5';
const githubRepo = 'PranshulGG/WeatherMaster';
const releasesUrl = `https://api.github.com/repos/${githubRepo}/releases/latest`;

Expand Down Expand Up @@ -1150,11 +1156,29 @@ scrollView.addEventListener('touchstart', () => {

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);
Expand Down Expand Up @@ -1752,4 +1776,12 @@ showLoader();

hideLoader()
}
}

function checkTopScroll(){
if(document.getElementById('weather_wrap').scrollTop === 0){
sendThemeToAndroid('EnableSwipeRefresh')
} else{
sendThemeToAndroid('DisableSwipeRefresh')
}
}
34 changes: 23 additions & 11 deletions app/src/main/assets/app/fetch.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -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;
}
}
Expand Down Expand Up @@ -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 => {

Expand All @@ -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 => {

Expand All @@ -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 => {

Expand All @@ -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`;
Expand All @@ -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

})
Expand Down Expand Up @@ -229,7 +241,7 @@ function saveCache(lat, lon, timezone, suggestionText) {

setTimeout(() => {
loadSavedLocations()
}, 200)
}, 1000)

});
}
Expand Down Expand Up @@ -272,7 +284,7 @@ document.querySelector('savedLocationsHolder').innerHTML = ''

setTimeout(() => {
loadSavedLocations()
}, 200)
}, 1000)

})
.catch(error => {
Expand Down Expand Up @@ -304,7 +316,7 @@ document.querySelector('savedLocationsHolder').innerHTML = ''

setTimeout(() => {
loadSavedLocations()
}, 200)
}, 1000)

})
.catch(error => {
Expand Down
26 changes: 12 additions & 14 deletions app/src/main/assets/app/renderWeather.js
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand All @@ -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)';
}


Expand Down Expand Up @@ -128,9 +128,9 @@ function HourlyWeather(data) {
<rainPerBar>
<rainPerBarProgress style="height: ${Math.round(rainAmountPercent)}%; background-color: ${barColor};"">
</rainPerBarProgress>
<p class="prec_amount_bar">${PrecAmount}</p>
<p>${data.hourly.precipitation_probability[index]}%</p>
</rainPerBar>
<p>${PrecAmount}</p>
<p>${data.hourly.precipitation_probability[index]}%</p>
<span>${hours}${period}</span>
Expand Down Expand Up @@ -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)

}

Expand Down Expand Up @@ -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));

Expand Down
Loading

0 comments on commit 0d6c6a1

Please sign in to comment.