2013-09-06 00:41:52 -04:00
|
|
|
using System;
|
|
|
|
using System.Collections.Generic;
|
|
|
|
using System.Linq;
|
|
|
|
using System.Text;
|
|
|
|
|
|
|
|
using Android.App;
|
|
|
|
using Android.Content;
|
2014-12-30 00:20:16 -05:00
|
|
|
using Android.Content.PM;
|
2013-09-06 00:41:52 -04:00
|
|
|
using Android.Content.Res;
|
2014-12-30 00:20:16 -05:00
|
|
|
using Android.Graphics;
|
2013-09-06 00:41:52 -04:00
|
|
|
using Android.OS;
|
|
|
|
using Android.Runtime;
|
|
|
|
using Android.Text;
|
|
|
|
using Android.Text.Method;
|
2014-12-30 00:20:16 -05:00
|
|
|
using Android.Text.Util;
|
2013-09-06 00:41:52 -04:00
|
|
|
using Android.Views;
|
2014-12-30 00:20:16 -05:00
|
|
|
using Android.Webkit;
|
2013-09-06 00:41:52 -04:00
|
|
|
using Android.Widget;
|
|
|
|
|
|
|
|
namespace keepass2android
|
|
|
|
{
|
|
|
|
public static class ChangeLog
|
|
|
|
{
|
|
|
|
public static void ShowChangeLog(Context ctx, Action onDismiss)
|
|
|
|
{
|
2014-12-30 00:20:16 -05:00
|
|
|
AlertDialog.Builder builder = new AlertDialog.Builder(new ContextThemeWrapper(ctx, Android.Resource.Style.ThemeHoloLightDialog));
|
2013-09-06 00:41:52 -04:00
|
|
|
builder.SetTitle(ctx.GetString(Resource.String.ChangeLog_title));
|
2014-12-30 00:20:16 -05:00
|
|
|
List<string> changeLog = new List<string>{
|
2015-06-23 15:19:11 -04:00
|
|
|
ctx.GetString(Resource.String.ChangeLog_0_9_8),
|
2015-05-20 23:45:49 -04:00
|
|
|
#if !NoNet
|
|
|
|
//0.9.7b fixes were already included in 0.9.7 offline
|
|
|
|
ctx.GetString(Resource.String.ChangeLog_0_9_7b),
|
|
|
|
#endif
|
2015-02-19 14:30:26 -05:00
|
|
|
ctx.GetString(Resource.String.ChangeLog_0_9_7),
|
2014-12-30 00:20:16 -05:00
|
|
|
ctx.GetString(Resource.String.ChangeLog_0_9_6),
|
2014-12-03 00:40:17 -05:00
|
|
|
ctx.GetString(Resource.String.ChangeLog_0_9_5),
|
2014-06-01 01:00:35 -04:00
|
|
|
ctx.GetString(Resource.String.ChangeLog_0_9_4),
|
2014-04-01 01:26:50 -04:00
|
|
|
ctx.GetString(Resource.String.ChangeLog_0_9_3_r5),
|
2013-12-31 03:46:57 -05:00
|
|
|
ctx.GetString(Resource.String.ChangeLog_0_9_3),
|
2013-11-12 23:18:48 -05:00
|
|
|
ctx.GetString(Resource.String.ChangeLog_0_9_2),
|
2013-11-06 14:11:01 -05:00
|
|
|
ctx.GetString(Resource.String.ChangeLog_0_9_1),
|
2013-10-07 00:28:06 -04:00
|
|
|
ctx.GetString(Resource.String.ChangeLog_0_9),
|
2013-09-06 16:56:29 -04:00
|
|
|
ctx.GetString(Resource.String.ChangeLog_0_8_6),
|
2013-09-06 00:41:52 -04:00
|
|
|
ctx.GetString(Resource.String.ChangeLog_0_8_5),
|
|
|
|
ctx.GetString(Resource.String.ChangeLog_0_8_4),
|
|
|
|
ctx.GetString(Resource.String.ChangeLog_0_8_3),
|
|
|
|
ctx.GetString(Resource.String.ChangeLog_0_8_2),
|
|
|
|
ctx.GetString(Resource.String.ChangeLog_0_8_1),
|
|
|
|
ctx.GetString(Resource.String.ChangeLog_0_8),
|
|
|
|
ctx.GetString(Resource.String.ChangeLog_0_7),
|
|
|
|
ctx.GetString(Resource.String.ChangeLog)
|
|
|
|
};
|
|
|
|
|
2014-12-30 00:20:16 -05:00
|
|
|
String version;
|
|
|
|
try {
|
|
|
|
PackageInfo packageInfo = ctx.PackageManager.GetPackageInfo(ctx.PackageName, 0);
|
|
|
|
version = packageInfo.VersionName;
|
|
|
|
|
|
|
|
} catch (PackageManager.NameNotFoundException) {
|
|
|
|
version = "";
|
|
|
|
}
|
|
|
|
|
|
|
|
string warning = "";
|
|
|
|
if (version.Contains("pre"))
|
|
|
|
{
|
|
|
|
warning = ctx.GetString(Resource.String.PreviewWarning);
|
|
|
|
}
|
|
|
|
|
2014-05-16 11:15:43 -04:00
|
|
|
builder.SetPositiveButton(Android.Resource.String.Ok, (dlgSender, dlgEvt) => {((AlertDialog)dlgSender).Dismiss(); });
|
2014-05-09 07:06:47 -04:00
|
|
|
builder.SetCancelable(false);
|
2013-09-06 00:41:52 -04:00
|
|
|
|
2014-12-30 00:20:16 -05:00
|
|
|
WebView wv = new WebView(ctx);
|
|
|
|
|
|
|
|
wv.SetBackgroundColor(Color.White);
|
2015-01-08 00:31:09 -05:00
|
|
|
wv.LoadDataWithBaseURL(null, GetLog(changeLog, warning, ctx), "text/html", "UTF-8", null);
|
2014-12-30 00:20:16 -05:00
|
|
|
|
|
|
|
|
|
|
|
//builder.SetMessage("");
|
|
|
|
builder.SetView(wv);
|
2013-09-06 00:41:52 -04:00
|
|
|
Dialog dialog = builder.Create();
|
|
|
|
dialog.DismissEvent += (sender, e) =>
|
|
|
|
{
|
|
|
|
onDismiss();
|
|
|
|
};
|
|
|
|
dialog.Show();
|
2014-12-30 00:20:16 -05:00
|
|
|
/*TextView message = (TextView)dialog.FindViewById(Android.Resource.Id.Message);
|
2013-09-06 00:41:52 -04:00
|
|
|
|
2014-12-30 00:20:16 -05:00
|
|
|
|
|
|
|
message.TextFormatted = Html.FromHtml(ConcatChangeLog(ctx, changeLog.ToArray()));
|
|
|
|
message.AutoLinkMask=MatchOptions.WebUrls;*/
|
2013-09-06 00:41:52 -04:00
|
|
|
|
|
|
|
}
|
|
|
|
|
2014-12-30 00:20:16 -05:00
|
|
|
private const string HtmlStart = @"<html>
|
|
|
|
<head>
|
|
|
|
<style type='text/css'>
|
|
|
|
a { color:#000000 }
|
|
|
|
div.title {
|
|
|
|
color:287AA9;
|
|
|
|
font-size:1.2em;
|
|
|
|
font-weight:bold;
|
|
|
|
margin-top:1em;
|
|
|
|
margin-bottom:0.5em;
|
|
|
|
text-align:center }
|
|
|
|
div.subtitle {
|
|
|
|
color:287AA9;
|
|
|
|
font-size:0.8em;
|
|
|
|
margin-bottom:1em;
|
|
|
|
text-align:center }
|
|
|
|
div.freetext { color:#000000 }
|
|
|
|
div.list { color:#000000 }
|
|
|
|
</style>
|
|
|
|
</head>
|
|
|
|
<body>";
|
|
|
|
private const string HtmlEnd = @"</body>
|
|
|
|
</html>";
|
2015-01-08 00:31:09 -05:00
|
|
|
private static string GetLog(List<string> changeLog, string warning, Context ctx)
|
2014-12-30 00:20:16 -05:00
|
|
|
{
|
|
|
|
StringBuilder sb = new StringBuilder(HtmlStart);
|
|
|
|
if (!string.IsNullOrEmpty(warning))
|
|
|
|
{
|
|
|
|
sb.Append(warning);
|
|
|
|
}
|
|
|
|
bool inList = false;
|
2015-01-08 00:31:09 -05:00
|
|
|
bool isFirst = true;
|
2014-12-30 00:20:16 -05:00
|
|
|
foreach (string versionLog in changeLog)
|
|
|
|
{
|
2015-01-08 00:31:09 -05:00
|
|
|
string versionLog2 = versionLog;
|
2014-12-30 00:20:16 -05:00
|
|
|
bool title = true;
|
2015-01-08 00:31:09 -05:00
|
|
|
if (isFirst)
|
|
|
|
{
|
|
|
|
if (versionLog2.EndsWith("\n") == false)
|
|
|
|
versionLog2 += "\n";
|
|
|
|
string donateUrl = ctx.GetString(Resource.String.donate_url,
|
|
|
|
new Java.Lang.Object[]{ctx.Resources.Configuration.Locale.Language,
|
|
|
|
ctx.PackageName
|
|
|
|
});
|
|
|
|
versionLog2 += " * <a href=\"" + donateUrl
|
|
|
|
+ "\">" +
|
|
|
|
ctx.GetString(Resource.String.ChangeLog_keptDonate)
|
|
|
|
+ "<a/>";
|
|
|
|
isFirst = false;
|
|
|
|
}
|
|
|
|
foreach (string line in versionLog2.Split('\n'))
|
2014-12-30 00:20:16 -05:00
|
|
|
{
|
|
|
|
string w = line.Trim();
|
|
|
|
if (title)
|
|
|
|
{
|
|
|
|
if (inList)
|
|
|
|
{
|
|
|
|
sb.Append("</ul></div>\n");
|
|
|
|
inList = false;
|
|
|
|
}
|
|
|
|
w = w.Replace("<b>","");
|
|
|
|
w = w.Replace("</b>", "");
|
|
|
|
w = w.Replace("\\n", "");
|
|
|
|
sb.Append("<div class='title'>"
|
|
|
|
+ w.Trim() + "</div>\n");
|
|
|
|
title = false;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
w = w.Replace("\\n", "<br />");
|
|
|
|
if (w.StartsWith("*"))
|
|
|
|
{
|
|
|
|
if (!inList)
|
|
|
|
{
|
|
|
|
sb.Append("<div class='list'><ul>\n");
|
|
|
|
inList = true;
|
|
|
|
}
|
|
|
|
sb.Append("<li>");
|
|
|
|
sb.Append(w.Substring(1).Trim());
|
|
|
|
sb.Append("</li>\n");
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if (inList)
|
|
|
|
{
|
|
|
|
sb.Append("</ul></div>\n");
|
|
|
|
inList = false;
|
|
|
|
}
|
|
|
|
sb.Append(w);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
sb.Append(HtmlEnd);
|
|
|
|
return sb.ToString();
|
|
|
|
}
|
2013-09-06 00:41:52 -04:00
|
|
|
}
|
|
|
|
}
|