re-enable mobile media controller

This commit is contained in:
Luke Pulverenti
2014-04-30 11:07:02 -04:00
parent e9fb806478
commit 98c0b28d14
18 changed files with 147 additions and 67 deletions

View File

@@ -70,7 +70,7 @@ namespace MediaBrowser.Server.Implementations.EntryPoints.Notifications
_appHost.ApplicationUpdated += _appHost_ApplicationUpdated;
}
async void _appHost_ApplicationUpdated(object sender, GenericEventArgs<Version> e)
async void _appHost_ApplicationUpdated(object sender, GenericEventArgs<PackageVersionInfo> e)
{
var type = NotificationType.ApplicationUpdateInstalled.ToString();
@@ -79,8 +79,9 @@ namespace MediaBrowser.Server.Implementations.EntryPoints.Notifications
NotificationType = type
};
notification.Variables["Version"] = e.Argument.ToString();
notification.Variables["Version"] = e.Argument.versionStr;
notification.Variables["ReleaseNotes"] = e.Argument.description;
await SendNotification(notification).ConfigureAwait(false);
}
@@ -98,6 +99,7 @@ namespace MediaBrowser.Server.Implementations.EntryPoints.Notifications
notification.Variables["Name"] = installationInfo.Name;
notification.Variables["Version"] = installationInfo.Version.ToString();
notification.Variables["ReleaseNotes"] = e.Argument.Item2.description;
await SendNotification(notification).ConfigureAwait(false);
}
@@ -249,6 +251,7 @@ namespace MediaBrowser.Server.Implementations.EntryPoints.Notifications
};
notification.Variables["Name"] = e.Argument.Name;
notification.Variables["ErrorMessage"] = e.Argument.ErrorMessage;
await SendNotification(notification).ConfigureAwait(false);
}

View File

@@ -605,6 +605,7 @@
"LetterButtonAbbreviation": "A",
"TabNowPlaying": "Now Playing",
"TabNavigation": "Navigation",
"TabControls": "Controls",
"ButtonFullscreen": "Toggle fullscreen",
"ButtonScenes": "Scenes",
"ButtonSubtitles": "Subtitles",
@@ -616,5 +617,8 @@
"ButtonPause": "Pause",
"LabelGroupMoviesIntoCollections": "Group movies into collections",
"LabelGroupMoviesIntoCollectionsHelp": "When displaying movie lists, movies belonging to a collection will be displayed as one grouped item.",
"NotificationOptionPluginError": "Plugin failure"
"NotificationOptionPluginError": "Plugin failure",
"ButtonVolumeUp": "Volume up",
"ButtonVolumeDown": "Volume down",
"ButtonMute": "Mute"
}

View File

@@ -99,7 +99,7 @@ namespace MediaBrowser.Server.Implementations.News
{
if (lastUpdate.HasValue)
{
items = items.Where(i => i.Date.ToUniversalTime() > lastUpdate.Value)
items = items.Where(i => i.Date.ToUniversalTime() >= lastUpdate.Value)
.ToList();
}

View File

@@ -48,8 +48,9 @@ namespace MediaBrowser.Server.Implementations.Notifications
new NotificationTypeInfo
{
Type = NotificationType.PluginError.ToString(),
DefaultTitle = "{Name} has encountered an error: {Message}",
Variables = new List<string>{"Name", "Message"}
DefaultTitle = "{Name} has encountered an error.",
DefaultDescription = "{ErrorMessage}",
Variables = new List<string>{"Name", "ErrorMessage"}
},
new NotificationTypeInfo
@@ -63,7 +64,8 @@ namespace MediaBrowser.Server.Implementations.Notifications
{
Type = NotificationType.PluginUpdateInstalled.ToString(),
DefaultTitle = "{Name} was updated.",
Variables = new List<string>{"Name", "Version"}
DefaultDescription = "{ReleaseNotes}",
Variables = new List<string>{"Name", "ReleaseNotes", "Version"}
},
new NotificationTypeInfo
@@ -76,7 +78,8 @@ namespace MediaBrowser.Server.Implementations.Notifications
{
Type = NotificationType.TaskFailed.ToString(),
DefaultTitle = "{Name} failed.",
Variables = new List<string>{"Name"}
DefaultDescription = "{ErrorMessage}",
Variables = new List<string>{"Name", "ErrorMessage"}
},
new NotificationTypeInfo

View File

@@ -39,13 +39,14 @@ namespace MediaBrowser.Server.Implementations.Notifications
_config.Configuration.NotificationOptions.GetOptions(notificationType);
var users = GetUserIds(request, options)
.Except(request.UserIds)
.Except(request.ExcludeUserIds)
.Select(i => _userManager.GetUserById(new Guid(i)));
var title = GetTitle(request, options);
var description = GetDescription(request, options);
var tasks = _services.Where(i => IsEnabled(i, notificationType))
.Select(i => SendNotification(request, i, users, title, cancellationToken));
.Select(i => SendNotification(request, i, users, description, title, cancellationToken));
return Task.WhenAll(tasks);
}
@@ -54,12 +55,13 @@ namespace MediaBrowser.Server.Implementations.Notifications
INotificationService service,
IEnumerable<User> users,
string title,
string description,
CancellationToken cancellationToken)
{
users = users.Where(i => IsEnabledForUser(service, i))
.ToList();
var tasks = users.Select(i => SendNotification(request, service, title, i, cancellationToken));
var tasks = users.Select(i => SendNotification(request, service, title, description, i, cancellationToken));
return Task.WhenAll(tasks);
@@ -89,19 +91,20 @@ namespace MediaBrowser.Server.Implementations.Notifications
.Select(i => i.Id.ToString("N"));
}
return new List<string>();
return request.UserIds;
}
private async Task SendNotification(NotificationRequest request,
INotificationService service,
string title,
string description,
User user,
CancellationToken cancellationToken)
{
var notification = new UserNotification
{
Date = request.Date,
Description = request.Description,
Description = description,
Level = request.Level,
Name = title,
Url = request.Url,
@@ -162,6 +165,48 @@ namespace MediaBrowser.Server.Implementations.Notifications
return title;
}
private string GetDescription(NotificationRequest request, NotificationOption options)
{
var text = request.Description;
// If empty, grab from options
if (string.IsNullOrEmpty(text))
{
if (!string.IsNullOrEmpty(request.NotificationType))
{
if (options != null)
{
text = options.Title;
}
}
}
// If still empty, grab default
if (string.IsNullOrEmpty(text))
{
if (!string.IsNullOrEmpty(request.NotificationType))
{
var info = GetNotificationTypes().FirstOrDefault(i => string.Equals(i.Type, request.NotificationType, StringComparison.OrdinalIgnoreCase));
if (info != null)
{
text = info.DefaultDescription;
}
}
}
text = text ?? string.Empty;
foreach (var pair in request.Variables)
{
var token = "{" + pair.Key + "}";
text = text.Replace(token, pair.Value, StringComparison.OrdinalIgnoreCase);
}
return text;
}
private bool IsEnabledForUser(INotificationService service, User user)
{
try