Skip to content

Commit

Permalink
Add Feedback button in About dialog
Browse files Browse the repository at this point in the history
- The user shall have an easy way to provide feedback.
- A second icon (thumbs up) has been added to the about button to symbolize feedback possibility.
  • Loading branch information
thomas694 committed Oct 17, 2021
1 parent fec12aa commit 1f056db
Show file tree
Hide file tree
Showing 23 changed files with 385 additions and 10 deletions.
4 changes: 2 additions & 2 deletions src/TumblThree/SharedAssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,5 @@

[assembly: ComVisible(false)]
[assembly: NeutralResourcesLanguage("en-US", UltimateResourceFallbackLocation.MainAssembly)]
[assembly: AssemblyVersion("2.3.0.0")]
[assembly: AssemblyFileVersion("2.3.0.0")]
[assembly: AssemblyVersion("2.4.0.0")]
[assembly: AssemblyFileVersion("2.4.0.0")]

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -373,4 +373,7 @@ Möchten Sie es jetzt herunterladen?</value>
<data name="CollectionNameInvalidChars" xml:space="preserve">
<value>Der angegebene Name enthält ungültige Pfadnamenzeichen!</value>
</data>
<data name="SendFeedbackError" xml:space="preserve">
<value>Beim Senden des Feedbacks ist ein Fehler aufgetreten. Bitte versuchen Sie es später erneut.</value>
</data>
</root>
Original file line number Diff line number Diff line change
Expand Up @@ -373,4 +373,7 @@
<data name="CollectionNameInvalidChars" xml:space="preserve">
<value>¡El nombre especificado contiene caracteres de nombre de ruta no válidos!</value>
</data>
<data name="SendFeedbackError" xml:space="preserve">
<value>Se produjo un error al enviar los comentarios. Inténtelo de nuevo más tarde.</value>
</data>
</root>
Original file line number Diff line number Diff line change
Expand Up @@ -373,4 +373,7 @@ Voulez-vous le télécharger maintenant?</value>
<data name="CollectionNameInvalidChars" xml:space="preserve">
<value>Le nom spécifié contient des caractères de nom de chemin non valides!</value>
</data>
<data name="SendFeedbackError" xml:space="preserve">
<value>Une erreur s'est produite lors de l'envoi du commentaire. Veuillez réessayer plus tard.</value>
</data>
</root>
Original file line number Diff line number Diff line change
Expand Up @@ -414,4 +414,7 @@ Do you want to download it now?</value>
<data name="CollectionNameInvalidChars" xml:space="preserve">
<value>The specified name contains invalid path name characters!</value>
</data>
<data name="SendFeedbackError" xml:space="preserve">
<value>An error occurred while sending the feedback. Please try it again later.</value>
</data>
</root>
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
using System;
using System.Collections.Generic;
using System.ComponentModel.Composition;
using System.Linq;
using System.Net;
using System.Runtime.Serialization.Json;
using System.Text;
using System.Threading.Tasks;
using System.Waf.Applications;
using System.Web;
using System.Xml;
using System.Xml.Linq;
using TumblThree.Domain;
Expand Down Expand Up @@ -94,5 +96,34 @@ public Uri GetDownloadUri()

return new Uri(downloadLink);
}

public async Task<bool> SendFeedback(string name, string email, string message)
{
try
{
HttpWebRequest request = webRequestFactory.CreatePostRequest("https://9332a1f6dcab0d2f3fdafd51eaed07ca.m.pipedream.net");
request.ContentType = "application/x-www-form-urlencoded; charset=UTF-8";
var p = new Dictionary<string, string>();
p.Add("name", name);
p.Add("email", email);
p.Add("title", "App Feedback");
p.Add("message", message);
p.Add("url", "");
var fields = string.Join("&", p.Select(kvp => string.Format("{0}={1}", kvp.Key, HttpUtility.UrlEncode(kvp.Value))));
p = new Dictionary<string, string>() { { "form", fields }, { "other", "" } };
await webRequestFactory.PerformPostRequestAsync(request, p);
using (var response = await request.GetResponseAsync() as HttpWebResponse)
{
if (response.StatusCode != HttpStatusCode.OK)
throw new ApplicationException(string.Format("endpoint returned: {0} {1}", response.StatusCode, response.StatusDescription));
}
return true;
}
catch (Exception exception)
{
Logger.Error(exception.ToString());
throw;
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,7 @@ public interface IApplicationUpdateService
string GetNewAvailableVersion();

Uri GetDownloadUri();

Task<bool> SendFeedback(string name, string email, string message);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -261,6 +261,7 @@
<Compile Include="ViewModels\DetailsViewModels\DetailsTumblrTagSearchViewModel.cs" />
<Compile Include="ViewModels\DetailsViewModels\DetailsTwitterBlogViewModel.cs" />
<Compile Include="ViewModels\ExceptionWindowViewModel.cs" />
<Compile Include="ViewModels\FeedbackViewModel.cs" />
<Compile Include="ViewModels\FullScreenMediaViewModel.cs" />
<Compile Include="ViewModels\AboutViewModel.cs" />
<Compile Include="ViewModels\CrawlerViewModel.cs" />
Expand All @@ -274,6 +275,7 @@
<Compile Include="ViewModels\SettingsViewModel.cs" />
<Compile Include="ViewModels\ShellViewModel.cs" />
<Compile Include="Views\IExceptionWindowView.cs" />
<Compile Include="Views\IFeedbackView.cs" />
<Compile Include="Views\IFullScreenMediaView.cs" />
<Compile Include="Views\IAboutView.cs" />
<Compile Include="Views\ICrawlerView.cs" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,20 +19,24 @@ public class AboutViewModel : ViewModel<IAboutView>
private readonly AsyncDelegateCommand _checkForUpdatesCommand;
private readonly DelegateCommand _downloadCommand;
private readonly DelegateCommand _showWebsiteCommand;
private readonly DelegateCommand _feedbackCommand;

private readonly ExportFactory<FeedbackViewModel> _feedbackViewModelFactory;
private readonly IApplicationUpdateService _applicationUpdateService;
private bool _isCheckInProgress;
private bool _isLatestVersionAvailable;
private string _updateText;

[ImportingConstructor]
public AboutViewModel(IAboutView view, IApplicationUpdateService applicationUpdateService)
public AboutViewModel(IAboutView view, IApplicationUpdateService applicationUpdateService, ExportFactory<FeedbackViewModel> feedbackViewModelFactory)
: base(view)
{
_showWebsiteCommand = new DelegateCommand(ShowWebsite);
_checkForUpdatesCommand = new AsyncDelegateCommand(CheckForUpdates);
_downloadCommand = new DelegateCommand(DownloadNewVersion);
_feedbackCommand = new DelegateCommand(Feedback);
_applicationUpdateService = applicationUpdateService;
_feedbackViewModelFactory = feedbackViewModelFactory;
}

public ICommand ShowWebsiteCommand => _showWebsiteCommand;
Expand All @@ -41,6 +45,8 @@ public AboutViewModel(IAboutView view, IApplicationUpdateService applicationUpda

public ICommand DownloadCommand => _downloadCommand;

public ICommand FeedbackCommand => _feedbackCommand;

#pragma warning disable CA1822
public string ProductName => ApplicationInfo.ProductName;

Expand Down Expand Up @@ -101,6 +107,12 @@ private async Task CheckForUpdates()
await CheckForUpdatesComplete(_applicationUpdateService.GetLatestReleaseFromServer());
}

private void Feedback()
{
FeedbackViewModel feedbackViewModel = _feedbackViewModelFactory.CreateExport().Value;
feedbackViewModel.ShowDialog(this);
}

private async Task CheckForUpdatesComplete(Task<string> task)
{
IsCheckInProgress = false;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
using System;
using System.ComponentModel;
using System.ComponentModel.Composition;
using System.Threading.Tasks;
using System.Waf.Applications;
using System.Windows;
using System.Windows.Input;
using TumblThree.Applications.Properties;
using TumblThree.Applications.Services;
using TumblThree.Applications.Views;
using TumblThree.Domain;

namespace TumblThree.Applications.ViewModels
{
[Export]
public class FeedbackViewModel : ViewModel<IFeedbackView>
{
private readonly AsyncDelegateCommand _sendCommand;
private readonly IApplicationUpdateService _applicationUpdateService;

private string _message;

[ImportingConstructor]
public FeedbackViewModel(IFeedbackView view, IShellService shellService, IApplicationUpdateService applicationUpdateService)
: base(view)
{
ShellService = shellService;
_sendCommand = new AsyncDelegateCommand(Send);
_applicationUpdateService = applicationUpdateService;
}

public string Name { get; set; }

public string Email { get; set; }

public string Message { get; set; }

public ICommand SendCommand => _sendCommand;

public IShellService ShellService { get; }

public void ShowDialog(object owner) => ViewCore.ShowDialog(owner);

private async Task Send()
{
try
{
var result = await _applicationUpdateService.SendFeedback(Name, Email, Message);
if (result)
ViewCore.Close();
}
catch (Exception ex)
{
Logger.Error($"FeedbackViewModel:Send: {ex}");
MessageBox.Show(Resources.SendFeedbackError, Resources.Warning);
}
finally
{
await Task.CompletedTask;
}
}
}
}
11 changes: 11 additions & 0 deletions src/TumblThree/TumblThree.Applications/Views/IFeedbackView.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
using System.Waf.Applications;

namespace TumblThree.Applications.Views
{
public interface IFeedbackView : IView
{
void ShowDialog(object owner);

void Close();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ namespace TumblThree.Presentation.DesignData
public class SampleAboutViewModel : AboutViewModel
{
public SampleAboutViewModel()
: base(new MockAboutView(), null)
: base(new MockAboutView(), null, null)
{
}

Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -867,4 +867,19 @@ Alle Indexdateien in diesem Unterordner können bei Aktivierung für die globale
<data name="CollectionsHint" xml:space="preserve">
<value>Der Speicherort wird nur für neu erstellte Blogs unter dieser Sammlung verwendet. Wenn eine Sammlung gelöscht wird, werden die zugewiesenen Blogs unter der Standardsammlung angezeigt.</value>
</data>
<data name="Feedback" xml:space="preserve">
<value>Feedback</value>
</data>
<data name="FeedbackIntroduction" xml:space="preserve">
<value>Wir freuen uns sehr über Ihr Feedback!
Sagen Sie uns, was Ihnen an TumblThree gefällt oder nicht gefällt.
Bitte schreiben Sie Ihre Nachricht auf Englisch.
Alternativ können Sie uns auch über den Bereich {Issues} auf unserer Projektseite kontaktieren.</value>
</data>
<data name="Send" xml:space="preserve">
<value>Senden</value>
</data>
<data name="Email" xml:space="preserve">
<value>E-Mail (wird nicht veröffentlicht; für eine mögliche Antwort)</value>
</data>
</root>
Original file line number Diff line number Diff line change
Expand Up @@ -864,4 +864,19 @@ Todos los archivos de índice dentro de esta subcarpeta se pueden usar para la v
<data name="CollectionsHint" xml:space="preserve">
<value>La ubicación de descarga solo se usa para blogs recién creados en esa colección. Si se elimina una colección, los blogs asignados se mostrarán en la colección predeterminada.</value>
</data>
<data name="Feedback" xml:space="preserve">
<value>Feedback</value>
</data>
<data name="FeedbackIntroduction" xml:space="preserve">
<value>¡Apreciamos mucho sus comentarios!
Díganos lo que le gusta y lo que no le gusta de TumblThree.
Por favor escriba su mensaje en inglés.
Alternativamente, puede utilizar la {sección Problemas} en el sitio de nuestro proyecto para ponerse en contacto con nosotros.</value>
</data>
<data name="Send" xml:space="preserve">
<value>Enviar</value>
</data>
<data name="Email" xml:space="preserve">
<value>Correo electrónico (no se publicará; para una posible respuesta)</value>
</data>
</root>
Loading

0 comments on commit 1f056db

Please sign in to comment.