Closed peyronnx closed 10 years ago
There are helper columns for that:
sunrizeHour - the hour of sunrize
sunrizeMinute - the minute of sunrize
sunsetHour
sunsetMinute
So if sunrise time is 6:17am: sunrizeHour = 6 sunrizeMinute = 17 You just need to compare current time with hour and minute of sunrize (the same is for sunset). Night time is time when current hour and minute has bigger values sunsetHour and sunsetMinute but smaller than sunrizeHour and sunrizeMinute. How this conditions should be written in manifest.xml you can read in xda thread describing MIUI lockscreen manifest.
Thanks for your fast answer. I know how to handle sunrise and sunset in the manifest.xml I modded my weather dynamic icon. I just do not know how to call sunrise and sunset in the application in case of multi-cities? Sunrise and Sunset could be different regarding the city displayed. weather_id (variable used in manifest.xml) seems to be a hardcoded variable who grab the data for the current city displayed, could it be done for sunrise and sunset? I hope my questions are clear....
You do not understand - sunrize and sunset time in content provider of Weather BZ are different for different cities. So I see no problems to work with sun Hour and Minute variables in manifest.
OK understood, I know to request data for home city or GPS one (see below). I do not know how to detect the current city displayed when multicies are used. I guess I have to deal with : whereFormat="station='%s'" I just need to know which variable I have to use to point on current city displayed (in case of multicities): Regards
<ContentProviderBinder
name="city_binder"
uri="content://pro.burgerz.weather/cities"
columns="location,isHome"
where="isHome=1 OR isGPS=1"
order="isHome DESC, isGPS DESC"
countName="hasmaincity">
<Variable name="cities_location" type="string" column="location" row="0"/>
<Variable name="cities_ishome" type="int" column="isHome" row="0"/>
</ContentProviderBinder>
<ContentProviderBinder
name="weather_binder"
dependency="city_binder"
uri="content://pro.burgerz.weather/weather"
columns="station,temp,weatherID,sunrizeHour,sunrizeMinute,sunsetHour,sunsetMinute"
whereFormat="station='%s'"
whereParas="@cities_location"
countName="hasweather">
<Variable name="weather_temperature" type="int" column="temp" row="0"/>
<Variable name="weather_temperature_str" type="string" column="temp" row="0"/>
<Variable name="weather_id" type="int" column="weatherID" row="0"/>
<Variable name="sunrize_hour" type="int" column="sunrizeHour" row="0"/>
<Variable name="sunrize_minute" type="int" column="sunrizeMinute" row="0"/>
<Variable name="sunset_hour" type="int" column="sunsetHour" row="0"/>
<Variable name="sunset_minute" type="int" column="sunsetMinute" row="0"/>
</ContentProviderBinder>
You use this theme only for ONE city:
where="isHome=1 OR isGPS=1"
So if you want your theme to show another city just drag&drop it in WeatherBZ to the top position. For example I use more simple scheme (look for earlier commits for this file) for manifest of my dynamic icon: https://github.com/BurgerZ/MIUI-v5-Translation/blob/master/Russian/extras/icons/fancy_icons/pro.burgerz.weather/manifest.xml
I did not succeed in making sunrise / sunset variables works in the weather_ani.zip. In the manifest.xml, I put:
My wish is to make 6_60+30 be linked to the sunrize and 20_60+30 be linked to sunset.
I tried with
Perhaps, sunrize and sunset must be hardcoded in the application lines code.
My dynamic icon works, so I guess handling weather_ani.zip is a little bit different.
<?xml version="1.0" encoding="utf-8"?>
Regards
<Var name="is_night" expression="lt(#hour24*60+#minute,#day_start)+ge(#hour24*60+#minute,#day_end)"/>
->
<Var name="is_night" expression="lt(#hour24*60+#minute,#day_start)*ge(#hour24*60+#minute,#day_end)"/>
Try to change + to *. In real night time #is_night variable will be 1
this is my declaration and working fine to automatic weathericon change (sunrise and sunset)
<Var name="sunrize_Time" expression="le(#hour24,#sunrizeH)*lt(#minute,#sunrizeM)+lt(#hour24,#sunrizeH)*(ge(#minute,#sunrizeM)+le(#minute,#sunrizeM))"/>
<Var name="sunset_Time" expression="ge(#hour24,#sunsetH)*ge(#minute,#sunsetM)+gt(#hour24,#sunsetH)*(ge(#minute,#sunsetM)+le(#minute,#sunsetM))"/>
<Var name="night_flag" expression="#sunrize_Time+#sunset_Time"/>
<Var name="day_night_icon" expression="eq(#weather_id,0)+eq(#weather_id,1)+eq(#weather_id,7)+eq(#weather_id,8)+eq(#weather_id,14)"/>
<Var name="icon_suffix" expression="ifelse(#night_flag*#day_night_icon,'1','0')" type="string"/>
<Var name="weather_id_str" expression="ifelse(eq(#day_night_icon,1),'weather_' + #weather_id + '_' + @icon_suffix,'weather_' + #weather_id)" type="string"/>
My wish is to change the dynamic background in the app and linked the night to sunrise and sunset like I did for my dynamic icon (and it works).
It works with weather_ani.zip stored in assets folder (uncompiled apk).
I unzipped it and I discovered a manifest.xml
I tried to deal with and recompile the apk (after a clean uninstallation) to test it but I always fail.
It seems that using
Hello, Night data is connected to 6am and 5pm according to the default theme's manifest. Cloud be great to connect this variable to sunrise and sunset... I do not know how to. Regards,