mirror of
https://github.com/mgroves/MonodroidStockPortfolio.git
synced 2024-11-14 19:29:26 +00:00
added an 'about' info option to main activity
This commit is contained in:
parent
cbe17a7175
commit
d6eba45a2d
12 changed files with 89 additions and 6 deletions
|
@ -68,6 +68,7 @@
|
|||
<Compile Include="Presenters\EditPosition\EditPositionTests.cs" />
|
||||
<Compile Include="Presenters\EditPosition\When_the_user_tries_to_save_a_position_for_a_ticker_thats_already_being_tracked.cs" />
|
||||
<Compile Include="Presenters\Main\MainPresenterTests.cs" />
|
||||
<Compile Include="Presenters\Main\When_the_user_wants_to_see_About_info.cs" />
|
||||
<Compile Include="Presenters\Portfolio\PortfolioPresenterTests.cs" />
|
||||
<Compile Include="Presenters\Portfolio\When_done_initializing_a_Portfolio_Presenter.cs" />
|
||||
<Compile Include="Presenters\Config\When_initialize_the_config_presenter.cs" />
|
||||
|
|
|
@ -1,13 +1,13 @@
|
|||
using Machine.Specifications;
|
||||
using Telerik.JustMock;
|
||||
|
||||
namespace MonoStockPortfolio.Tests.Presenters
|
||||
namespace MonoStockPortfolio.Tests.Presenters.Main
|
||||
{
|
||||
[Tags("UnitTest")]
|
||||
public class When_the_user_wants_to_exit_the_app : Given_an_initialized_Main_Presenter
|
||||
{
|
||||
Because of = () =>
|
||||
_presenter.ExitApplication();
|
||||
_presenter.ExitApplication();
|
||||
|
||||
It should_tell_the_view_to_start_up_the_config_activity = () =>
|
||||
Mock.Assert(() => _mockView.ExitApplication(), Occurs.Exactly(1));
|
||||
|
|
|
@ -0,0 +1,33 @@
|
|||
using Machine.Specifications;
|
||||
using Telerik.JustMock;
|
||||
|
||||
namespace MonoStockPortfolio.Tests.Presenters.Main
|
||||
{
|
||||
[Tags("UnitTest")]
|
||||
public class When_the_user_wants_to_see_About_info : Given_an_initialized_Main_Presenter
|
||||
{
|
||||
static string _expectedMessage;
|
||||
|
||||
Establish context = () =>
|
||||
{
|
||||
_expectedMessage = "Matthew D. Groves © 2011\n" +
|
||||
"Source code:\n" +
|
||||
"\n" +
|
||||
"http://tinyurl.com/mspSource\n" +
|
||||
"\n" +
|
||||
"Contact me:\n" +
|
||||
"\n" +
|
||||
"http://mgroves.com\n" +
|
||||
"http://twitter.com/mgroves\n" +
|
||||
"webmaster@mgroves.com";
|
||||
};
|
||||
|
||||
Because of = () =>
|
||||
_presenter.GotoAboutInfo();
|
||||
|
||||
It should_tell_the_view_toshow_the_about_info = () =>
|
||||
Mock.Assert(() => _mockView.ShowAboutInfo(Arg.AnyString), Occurs.Exactly(1));
|
||||
It should_pass_the_expected_message_to_the_about_info = () =>
|
||||
Mock.Assert(() => _mockView.ShowAboutInfo(_expectedMessage), Occurs.Exactly(1));
|
||||
}
|
||||
}
|
|
@ -10,5 +10,6 @@
|
|||
void EditPortfolio(int itemId);
|
||||
void GotoConfig();
|
||||
void ExitApplication();
|
||||
void GotoAboutInfo();
|
||||
}
|
||||
}
|
|
@ -11,5 +11,6 @@ namespace MonoStockPortfolio.Activites.MainScreen
|
|||
void StartEditPortfolioActivity(int itemId);
|
||||
void StartConfigActivity();
|
||||
void ExitApplication();
|
||||
void ShowAboutInfo(string message);
|
||||
}
|
||||
}
|
|
@ -4,6 +4,9 @@ using System.Linq;
|
|||
using Android.App;
|
||||
using Android.Content;
|
||||
using Android.OS;
|
||||
using Android.Text;
|
||||
using Android.Text.Method;
|
||||
using Android.Text.Util;
|
||||
using Android.Views;
|
||||
using Android.Widget;
|
||||
using MonoStockPortfolio.Activites.ConfigScreen;
|
||||
|
@ -47,6 +50,22 @@ namespace MonoStockPortfolio.Activites.MainScreen
|
|||
Finish();
|
||||
}
|
||||
|
||||
public void ShowAboutInfo(string message)
|
||||
{
|
||||
var spannable = new SpannableString(message);
|
||||
Linkify.AddLinks(spannable, MatchOptions.All);
|
||||
|
||||
var alertBox = new AlertDialog.Builder(this)
|
||||
.SetNeutralButton("Ok", (x, y) => { })
|
||||
.SetMessage(spannable)
|
||||
.SetTitle("About Mono Stock Portfolio")
|
||||
.Create();
|
||||
|
||||
alertBox.Show();
|
||||
|
||||
((TextView)alertBox.FindViewById(Android.Resource.Id.Message)).MovementMethod = LinkMovementMethod.Instance;
|
||||
}
|
||||
|
||||
public void StartEditPortfolioActivity(int itemId)
|
||||
{
|
||||
var intent = EditPortfolioActivity.EditIntent(this, itemId);
|
||||
|
@ -114,6 +133,8 @@ namespace MonoStockPortfolio.Activites.MainScreen
|
|||
{
|
||||
var configItem = menu.Add(0, 1, 1, "Config".ToJ());
|
||||
configItem.SetIcon(Resource.Drawable.ic_menu_preferences);
|
||||
var aboutItem = menu.Add(0, 1, 1, "About".ToJ());
|
||||
aboutItem.SetIcon(Resource.Drawable.ic_menu_info_details); // IcMenuInfoDetails);
|
||||
var exitItem = menu.Add(0, 1, 1, "Exit".ToJ());
|
||||
exitItem.SetIcon(Resource.Drawable.ic_menu_close_clear_cancel);
|
||||
return true;
|
||||
|
@ -129,6 +150,9 @@ namespace MonoStockPortfolio.Activites.MainScreen
|
|||
case "Exit":
|
||||
_presenter.ExitApplication();
|
||||
return true;
|
||||
case "About":
|
||||
_presenter.GotoAboutInfo();
|
||||
return true;
|
||||
default:
|
||||
return base.OnOptionsItemSelected(item);
|
||||
}
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
using System.Collections.Generic;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using Android.Runtime;
|
||||
using MonoStockPortfolio.Core.PortfolioRepositories;
|
||||
using MonoStockPortfolio.Entities;
|
||||
|
@ -67,5 +68,21 @@ namespace MonoStockPortfolio.Activites.MainScreen
|
|||
{
|
||||
_currentView.ExitApplication();
|
||||
}
|
||||
|
||||
public void GotoAboutInfo()
|
||||
{
|
||||
var message = "Matthew D. Groves © 2011\n" +
|
||||
"Source code:\n" +
|
||||
"\n" +
|
||||
"http://tinyurl.com/mspSource\n" +
|
||||
"\n" +
|
||||
"Contact me:\n" +
|
||||
"\n" +
|
||||
"http://mgroves.com\n" +
|
||||
"http://twitter.com/mgroves\n" +
|
||||
"webmaster@mgroves.com";
|
||||
|
||||
_currentView.ShowAboutInfo(message);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -140,6 +140,9 @@
|
|||
<AndroidResource Include="Resources\drawable-hdpi\ic_menu_close_clear_cancel.png" />
|
||||
<AndroidResource Include="Resources\drawable-ldpi\ic_menu_close_clear_cancel.png" />
|
||||
<AndroidResource Include="Resources\drawable-mdpi\ic_menu_close_clear_cancel.png" />
|
||||
<AndroidResource Include="Resources\drawable-hdpi\ic_menu_info_details.png" />
|
||||
<AndroidResource Include="Resources\drawable-ldpi\ic_menu_info_details.png" />
|
||||
<AndroidResource Include="Resources\drawable-mdpi\ic_menu_info_details.png" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<AndroidResource Include="Resources\drawable-hdpi\ic_menu_refresh.png" />
|
||||
|
|
|
@ -30,13 +30,16 @@ namespace MonoStockPortfolio
|
|||
public const int ic_menu_close_clear_cancel = 2130837504;
|
||||
|
||||
// aapt resource value: 0x7f020001
|
||||
public const int ic_menu_preferences = 2130837505;
|
||||
public const int ic_menu_info_details = 2130837505;
|
||||
|
||||
// aapt resource value: 0x7f020002
|
||||
public const int ic_menu_refresh = 2130837506;
|
||||
public const int ic_menu_preferences = 2130837506;
|
||||
|
||||
// aapt resource value: 0x7f020003
|
||||
public const int icon = 2130837507;
|
||||
public const int ic_menu_refresh = 2130837507;
|
||||
|
||||
// aapt resource value: 0x7f020004
|
||||
public const int icon = 2130837508;
|
||||
|
||||
private Drawable()
|
||||
{
|
||||
|
|
Binary file not shown.
After Width: | Height: | Size: 2.5 KiB |
Binary file not shown.
After Width: | Height: | Size: 1.5 KiB |
Binary file not shown.
After Width: | Height: | Size: 1.8 KiB |
Loading…
Reference in a new issue