Skip to content

Commit

Permalink
Merge pull request #851 from forrestguice/build
Browse files Browse the repository at this point in the history
remove jitpack.io from build
  • Loading branch information
forrestguice authored Nov 18, 2024
2 parents 88eda3c + c8f0035 commit 7a9424a
Show file tree
Hide file tree
Showing 41 changed files with 3,554 additions and 7 deletions.
7 changes: 2 additions & 5 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -58,13 +58,10 @@ dependencies
implementation 'com.android.support:recyclerview-v7:28.0.0'
implementation 'com.android.support:cardview-v7:28.0.0'
implementation 'com.android.support.constraint:constraint-layout:2.0.4'
implementation 'android.arch.lifecycle:extensions:1.1.1'

implementation 'com.github.forrestguice:sunrisesunsetlib-java:SunriseSunsetCalculator-1.2-p0-fixdst'
implementation 'com.github.caarmen.SunriseSunset:lib-sunrise-sunset:1.1.0'
implementation group: 'net.time4j', name: 'time4j-android', version: '4.8-2021a'

implementation 'com.github.forrestguice:colorpicker:0.0.13post1'
implementation 'android.arch.lifecycle:extensions:1.1.1'
implementation project(path: ":lib-quadflask-colorpicker") //implementation 'com.github.forrestguice:colorpicker:0.0.13post1'

testImplementation 'junit:junit:4.12'
androidTestImplementation 'com.jraska:falcon:2.2.0'
Expand Down
665 changes: 665 additions & 0 deletions app/src/main/java/ca/rmen/sunrisesunset/SunriseSunset.java

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
@@ -0,0 +1,290 @@
/*
* Copyright 2008-2009 Mike Reedell / LuckyCatLabs.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

package com.luckycatlabs.sunrisesunset;

import java.util.Calendar;
import java.util.TimeZone;

import com.luckycatlabs.sunrisesunset.calculator.SolarEventCalculator;
import com.luckycatlabs.sunrisesunset.dto.Location;

/**
* Public interface for getting the various types of sunrise/sunset.
*/
public class SunriseSunsetCalculator {

private Location location;

private SolarEventCalculator calculator;

/**
* Constructs a new <code>SunriseSunsetCalculator</code> with the given <code>Location</code>
*
* @param location
* <code>Location</code> object containing the Latitude/Longitude of the location to compute
* the sunrise/sunset for.
* @param timeZoneIdentifier
* String identifier for the timezone to compute the sunrise/sunset times in. In the form
* "America/New_York". Please see the zi directory under the JDK installation for supported
* time zones.
*/
public SunriseSunsetCalculator(Location location, String timeZoneIdentifier) {
this.location = location;
this.calculator = new SolarEventCalculator(location, timeZoneIdentifier);
}

/**
* Constructs a new <code>SunriseSunsetCalculator</code> with the given <code>Location</code>
*
* @param location
* <code>Location</code> object containing the Latitude/Longitude of the location to compute
* the sunrise/sunset for.
* @param timeZone
* timezone to compute the sunrise/sunset times in.
*/
public SunriseSunsetCalculator(Location location, TimeZone timeZone) {
this.location = location;
this.calculator = new SolarEventCalculator(location, timeZone);
}

/**
* Returns the astronomical (108deg) sunrise for the given date.
*
* @param date
* <code>Calendar</code> object containing the date to compute the astronomical sunrise for.
* @return the astronomical sunrise time in HH:MM (24-hour clock) form.
*/
public String getAstronomicalSunriseForDate(Calendar date) {
return calculator.computeSunriseTime(Zenith.ASTRONOMICAL, date);
}

/**
* Returns the astronomical (108deg) sunrise for the given date.
*
* @param date
* <code>Calendar</code> object containing the date to compute the astronomical sunrise for.
* @return the astronomical sunrise time as a Calendar
*/
public Calendar getAstronomicalSunriseCalendarForDate(Calendar date) {
return calculator.computeSunriseCalendar(Zenith.ASTRONOMICAL, date);
}

/**
* Returns the astronomical (108deg) sunset for the given date.
*
* @param date
* <code>Calendar</code> object containing the date to compute the astronomical sunset for.
* @return the astronomical sunset time in HH:MM (24-hour clock) form.
*/
public String getAstronomicalSunsetForDate(Calendar date) {
return calculator.computeSunsetTime(Zenith.ASTRONOMICAL, date);
}

/**
* Returns the astronomical (108deg) sunset for the given date.
*
* @param date
* <code>Calendar</code> object containing the date to compute the astronomical sunset for.
* @return the astronomical sunset time as a Calendar
*/
public Calendar getAstronomicalSunsetCalendarForDate(Calendar date) {
return calculator.computeSunsetCalendar(Zenith.ASTRONOMICAL, date);
}

/**
* Returns the nautical (102deg) sunrise for the given date.
*
* @param date
* <code>Calendar</code> object containing the date to compute the nautical sunrise for.
* @return the nautical sunrise time in HH:MM (24-hour clock) form.
*/
public String getNauticalSunriseForDate(Calendar date) {
return calculator.computeSunriseTime(Zenith.NAUTICAL, date);
}

/**
* Returns the nautical (102deg) sunrise for the given date.
*
* @param date
* <code>Calendar</code> object containing the date to compute the nautical sunrise for.
* @return the nautical sunrise time as a Calendar
*/
public Calendar getNauticalSunriseCalendarForDate(Calendar date) {
return calculator.computeSunriseCalendar(Zenith.NAUTICAL, date);
}

/**
* Returns the nautical (102deg) sunset for the given date.
*
* @param date
* <code>Calendar</code> object containing the date to compute the nautical sunset for.
* @return the nautical sunset time in HH:MM (24-hour clock) form.
*/
public String getNauticalSunsetForDate(Calendar date) {
return calculator.computeSunsetTime(Zenith.NAUTICAL, date);
}

/**
* Returns the nautical (102deg) sunset for the given date.
*
* @param date
* <code>Calendar</code> object containing the date to compute the nautical sunset for.
* @return the nautical sunset time as a Calendar
*/
public Calendar getNauticalSunsetCalendarForDate(Calendar date) {
return calculator.computeSunsetCalendar(Zenith.NAUTICAL, date);
}

/**
* Returns the civil sunrise (twilight, 96deg) for the given date.
*
* @param date
* <code>Calendar</code> object containing the date to compute the civil sunrise for.
* @return the civil sunrise time in HH:MM (24-hour clock) form.
*/
public String getCivilSunriseForDate(Calendar date) {
return calculator.computeSunriseTime(Zenith.CIVIL, date);
}

/**
* Returns the civil sunrise (twilight, 96deg) for the given date.
*
* @param date
* <code>Calendar</code> object containing the date to compute the civil sunrise for.
* @return the civil sunrise time as a Calendar
*/
public Calendar getCivilSunriseCalendarForDate(Calendar date) {
return calculator.computeSunriseCalendar(Zenith.CIVIL, date);
}

/**
* Returns the civil sunset (twilight, 96deg) for the given date.
*
* @param date
* <code>Calendar</code> object containing the date to compute the civil sunset for.
* @return the civil sunset time in HH:MM (24-hour clock) form.
*/
public String getCivilSunsetForDate(Calendar date) {
return calculator.computeSunsetTime(Zenith.CIVIL, date);
}

/**
* Returns the civil sunset (twilight, 96deg) for the given date.
*
* @param date
* <code>Calendar</code> object containing the date to compute the civil sunset for.
* @return the civil sunset time as a Calendar
*/
public Calendar getCivilSunsetCalendarForDate(Calendar date) {
return calculator.computeSunsetCalendar(Zenith.CIVIL, date);
}

/**
* Returns the official sunrise (90deg 50', 90.8333deg) for the given date.
*
* @param date
* <code>Calendar</code> object containing the date to compute the official sunrise for.
* @return the official sunrise time in HH:MM (24-hour clock) form.
*/
public String getOfficialSunriseForDate(Calendar date) {
return calculator.computeSunriseTime(Zenith.OFFICIAL, date);
}

/**
* Returns the official sunrise (90deg 50', 90.8333deg) for the given date.
*
* @param date
* <code>Calendar</code> object containing the date to compute the official sunrise for.
* @return the official sunrise time as a Calendar
*/
public Calendar getOfficialSunriseCalendarForDate(Calendar date) {
return calculator.computeSunriseCalendar(Zenith.OFFICIAL, date);
}

/**
* Returns the official sunrise (90deg 50', 90.8333deg) for the given date.
*
* @param date
* <code>Calendar</code> object containing the date to compute the official sunset for.
* @return the official sunset time in HH:MM (24-hour clock) form.
*/
public String getOfficialSunsetForDate(Calendar date) {
return calculator.computeSunsetTime(Zenith.OFFICIAL, date);
}

/**
* Returns the official sunrise (90deg 50', 90.8333deg) for the given date.
*
* @param date
* <code>Calendar</code> object containing the date to compute the official sunset for.
* @return the official sunset time as a Calendar
*/
public Calendar getOfficialSunsetCalendarForDate(Calendar date) {
return calculator.computeSunsetCalendar(Zenith.OFFICIAL, date);
}

/**
* Computes the sunrise for an arbitrary declination.
*
* @param latitude
* @param longitude
* Coordinates for the location to compute the sunrise/sunset for.
* @param timeZone
* timezone to compute the sunrise/sunset times in.
* @param date
* <code>Calendar</code> object containing the date to compute the official sunset for.
* @param degrees
* Angle under the horizon for which to compute sunrise. For example, "civil sunrise"
* corresponds to 6 degrees.
* @return the requested sunset time as a <code>Calendar</code> object.
*/

public static Calendar getSunrise(double latitude, double longitude, TimeZone timeZone, Calendar date, double degrees) {
SolarEventCalculator solarEventCalculator = new SolarEventCalculator(new Location(latitude, longitude), timeZone);
return solarEventCalculator.computeSunriseCalendar(new Zenith(90 - degrees), date);
}

/**
* Computes the sunset for an arbitrary declination.
*
* @param latitude
* @param longitude
* Coordinates for the location to compute the sunrise/sunset for.
* @param timeZone
* timezone to compute the sunrise/sunset times in.
* @param date
* <code>Calendar</code> object containing the date to compute the official sunset for.
* @param degrees
* Angle under the horizon for which to compute sunrise. For example, "civil sunset"
* corresponds to 6 degrees.
* @return the requested sunset time as a <code>Calendar</code> object.
*/

public static Calendar getSunset(double latitude, double longitude, TimeZone timeZone, Calendar date, double degrees) {
SolarEventCalculator solarEventCalculator = new SolarEventCalculator(new Location(latitude, longitude), timeZone);
return solarEventCalculator.computeSunsetCalendar(new Zenith(90 - degrees), date);
}

/**
* Returns the location where the sunrise/sunset is calculated for.
*
* @return <code>Location</code> object representing the location of the computed sunrise/sunset.
*/
public Location getLocation() {
return location;
}
}
46 changes: 46 additions & 0 deletions app/src/main/java/com/luckycatlabs/sunrisesunset/Zenith.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
/*
* Copyright 2008-2009 Mike Reedell / LuckyCatLabs.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

package com.luckycatlabs.sunrisesunset;

import java.math.BigDecimal;

/**
* Defines the solar declination used in computing the sunrise/sunset.
*/
public class Zenith {
/** Astronomical sunrise/set is when the sun is 18 degrees below the horizon. */
public static final Zenith ASTRONOMICAL = new Zenith(108);

/** Nautical sunrise/set is when the sun is 12 degrees below the horizon. */
public static final Zenith NAUTICAL = new Zenith(102);

/** Civil sunrise/set (dawn/dusk) is when the sun is 6 degrees below the horizon. */
public static final Zenith CIVIL = new Zenith(96);

/** Official sunrise/set is when the sun is 50' below the horizon. */
public static final Zenith OFFICIAL = new Zenith(90.8333);

private final BigDecimal degrees;

public Zenith(double degrees) {
this.degrees = BigDecimal.valueOf(degrees);
}

public BigDecimal degrees() {
return degrees;
}
}
Loading

0 comments on commit 7a9424a

Please sign in to comment.