Skip to content

Commit

Permalink
Handle failed downloads gracefully and disable UWP location code for now
Browse files Browse the repository at this point in the history
  • Loading branch information
t1m0thyj committed Aug 22, 2018
1 parent 6cc68cf commit aadda1b
Show file tree
Hide file tree
Showing 8 changed files with 32 additions and 39 deletions.
13 changes: 7 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ Port of macOS Mojave Dynamic Desktop feature to Windows 10, available for downlo

## Getting Started

The first time you run WinDynamicDesktop, it will automatically download the macOS Mojave wallpapers from [here](https://files.rb.gd/mojave_dynamic.zip) and extract them to your disk. I have not included the files directly in this repository for copyright reasons. If you want to select a different set of images, see the section below for how to do so.
The first time you run WinDynamicDesktop, it will automatically download the macOS Mojave wallpapers from [here](https://files.rb.gd/mojave_dynamic.zip) and [here](https://onedrive.live.com/download?cid=CC2E3BD0360C1775&resid=CC2E3BD0360C1775%21721&authkey=AK4kktXlvN1KJzQ) and extract them to your disk. I have not included the files directly in this repository for copyright reasons. If you want to select a different set of images, see the section below for how to do so.

You will also need to input your location when running the program for the first time. This location is not used for any purpose other than to determine the times of sunrise and sunset where you live.

Expand All @@ -31,15 +31,16 @@ If you want to run the app silently with no icon in the system tray, you can do

### How can I customize the images?

By default WinDynamicDesktop uses the Mojave wallpapers, but if you create an `images.conf` file in the same folder as the EXE you can customize the images that are used. The default `images.conf` can be found [here](src/images.conf). It is formatted in JSON and must contain the following values:
By default WinDynamicDesktop uses the Mojave wallpapers, but you can add your own themes and customize the images that are used by creating JSON files in the *themes* folder. Sample theme JSON files can be found [here](src/themes).

The name of the file should be the name of the theme, with any spaces replaced by underscores, plus the `.json` extension (e.g., `Mojave_Desert.json`). Theme files are formatted in JSON and must contain the following values:

* `themeName` - String which is the name of the wallpaper theme (e.g., "Mojave Default")
* `imagesZipUri` - String containing URL to download images.zip file from, or *null* if the content in the images subfolder is provided by the user
* `imageFilename` - String containing the filename of each wallpaper image, with `{0}` substituted for the image number
* `imageFilename` - String containing the filename of each wallpaper image, with `*` (an asterisk) substituted for the image number
* `dayImageList` - Array of numbers listing the image numbers to display throughout the day (between sunrise and sunset)
* `nightImageList` - Array of numbers listing the image numbers to display throughout the night (between sunset and sunrise)

## Legal and Privacy Stuff
I do not own the Mojave wallpaper pictures used by WinDynamicDesktop, they belong to Apple. The icon used in this program was made by [Roundicons](https://www.flaticon.com/authors/roundicons) from [flaticon.com](https://www.flaticon.com/) and is licensed by [CC 3.0 BY](http://creativecommons.org/licenses/by/3.0/).
I do not own the wallpaper images used by WinDynamicDesktop, they belong to Apple. The icon used in this program was made by [Roundicons](https://www.flaticon.com/authors/roundicons) from [flaticon.com](https://www.flaticon.com/) and is licensed by [CC 3.0 BY](http://creativecommons.org/licenses/by/3.0/).

When you enter your location, WinDynamicDesktop uses the [LocationIQ service](https://locationiq.org/) to convert your location to latitude and longitude. Your location info is never sent anywhere without your consent.
When you enter your location, WinDynamicDesktop uses the [LocationIQ service](https://locationiq.org/) to convert it to latitude and longitude. Your location info is never sent anywhere without your consent.
19 changes: 10 additions & 9 deletions src/AppContext.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ class AppContext : ApplicationContext
public AppContext()
{
EnforceSingleInstance();
UwpDesktop.RequestLocationAccess();
//UwpDesktop.RequestLocationAccess();

JsonConfig.LoadConfig();
ThemeManager.Initialize();
Expand Down Expand Up @@ -69,23 +69,24 @@ private void InitializeGui()

public static void RunInBackground()
{
if (!JsonConfig.firstRun || !LocationManager.isReady || !ThemeManager.isReady)
if (!LocationManager.isReady || !ThemeManager.isReady)
{
return;
}

if (ThemeManager.currentTheme == null)
{
ThemeManager.SelectTheme();
return;
}
else if (JsonConfig.firstRun)
{
notifyIcon.BalloonTipTitle = "WinDynamicDesktop";
notifyIcon.BalloonTipText = "The app is still running in the background. " +
"You can access it at any time by right-clicking on this icon.";
notifyIcon.ShowBalloonTip(10000);

notifyIcon.BalloonTipTitle = "WinDynamicDesktop";
notifyIcon.BalloonTipText = "The app is still running in the background. " +
"You can access it at any time by right-clicking on this icon.";
notifyIcon.ShowBalloonTip(10000);

JsonConfig.firstRun = false; // Don't show this message again
JsonConfig.firstRun = false; // Don't show this message again
}
}

private void OnNotifyIconMouseUp(object sender, MouseEventArgs e)
Expand Down
12 changes: 0 additions & 12 deletions src/LocationManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,18 +22,6 @@ public static void Initialize()
{
UpdateLocation();
}
else
{
try
{
UwpLocation.UnsafeUpdateGeoposition();
isReady = true;
}
catch
{
UpdateLocation();
}
}
}

public static void UpdateLocation()
Expand Down
8 changes: 6 additions & 2 deletions src/ProgressDialog.cs
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ public void DownloadNext()
{
ThemeConfig theme = downloadQueue.Peek();
client.DownloadFileAsync(new Uri(theme.imagesZipUri),
theme.themeName + "_images.zip", theme.themeName);
theme.themeName + "_images.zip");
}
else
{
Expand All @@ -53,7 +53,11 @@ public void OnDownloadProgressChanged(object sender, DownloadProgressChangedEven
public async void OnDownloadFileCompleted(object sender, AsyncCompletedEventArgs e)
{
ThemeConfig theme = downloadQueue.Dequeue();
await Task.Run(() => ThemeManager.ExtractTheme(theme.themeName));

if (e.Error == null)
{
await Task.Run(() => ThemeManager.ExtractTheme(theme.themeName));
}

DownloadNext();
}
Expand Down
2 changes: 1 addition & 1 deletion src/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -32,5 +32,5 @@
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.4.1")]
[assembly: AssemblyVersion("2.0.0")]
//[assembly: AssemblyFileVersion("1.0.0.0")]
9 changes: 7 additions & 2 deletions src/UwpLocation.cs
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,13 @@ public static async void RequestAccess()

public static async void UnsafeUpdateGeoposition()
{
var geolocator = new Windows.Devices.Geolocation.Geolocator { DesiredAccuracyInMeters = 0 };
var pos = await geolocator.GetGeopositionAsync();
var geolocator = new Windows.Devices.Geolocation.Geolocator
{
DesiredAccuracyInMeters = 0
};

var pos = await geolocator.GetGeopositionAsync(maximumAge: TimeSpan.FromMinutes(5),
timeout: TimeSpan.FromSeconds(10));

JsonConfig.settings.latitude = pos.Coordinate.Point.Position.Latitude.ToString();
JsonConfig.settings.longitude = pos.Coordinate.Point.Position.Longitude.ToString();
Expand Down
5 changes: 0 additions & 5 deletions src/WallpaperChangeScheduler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -119,11 +119,6 @@ public void RunScheduler(bool forceRefresh = false)

wallpaperTimer.Stop();

if (UwpDesktop.hasLocationAccess)
{
UwpLocation.UpdateGeoposition();
}

string currentDate = GetDateString();
todaysData = GetWeatherData(currentDate);

Expand Down
3 changes: 1 addition & 2 deletions uwp/Package.appxmanifest
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<Package xmlns="http://schemas.microsoft.com/appx/manifest/foundation/windows10" xmlns:mp="http://schemas.microsoft.com/appx/2014/phone/manifest" xmlns:uap="http://schemas.microsoft.com/appx/manifest/uap/windows10" xmlns:rescap="http://schemas.microsoft.com/appx/manifest/foundation/windows10/restrictedcapabilities" xmlns:desktop="http://schemas.microsoft.com/appx/manifest/desktop/windows10" IgnorableNamespaces="uap mp rescap desktop">
<Identity Name="38719TimothyJohnson.WinDynamicDesktop" Publisher="CN=3C822DA5-D64C-40A9-A84A-5502C3EDD8CD" Version="1.4.1.0" />
<Identity Name="38719TimothyJohnson.WinDynamicDesktop" Publisher="CN=3C822DA5-D64C-40A9-A84A-5502C3EDD8CD" Version="2.0.0.0" />
<Properties>
<DisplayName>WinDynamicDesktop</DisplayName>
<PublisherDisplayName>Timothy Johnson</PublisherDisplayName>
Expand Down Expand Up @@ -30,6 +30,5 @@
<Capabilities>
<Capability Name="internetClient" />
<rescap:Capability Name="runFullTrust" />
<DeviceCapability Name="location" />
</Capabilities>
</Package>

0 comments on commit aadda1b

Please sign in to comment.