Skip to content

Commit 5de0c50

Browse files
Charles Petzoldolegoid
Charles Petzold
authored andcommitted
BugSweeper: Several bug fixes
Bugzilla ids 42216, 42217, 42218, 41120; Issue #89.
1 parent 1d5ca3d commit 5de0c50

File tree

10 files changed

+276
-298
lines changed

10 files changed

+276
-298
lines changed

BugSweeper/BugSweeper.sln

+4-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11

22
Microsoft Visual Studio Solution File, Format Version 12.00
33
# Visual Studio 14
4-
VisualStudioVersion = 14.0.23107.0
4+
VisualStudioVersion = 14.0.25402.0
55
MinimumVisualStudioVersion = 10.0.40219.1
66
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "BugSweeper", "BugSweeper\BugSweeper\BugSweeper.csproj", "{853D3300-5056-4005-9E71-E5D933889581}"
77
EndProject
@@ -72,13 +72,16 @@ Global
7272
{853D3300-5056-4005-9E71-E5D933889581}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
7373
{853D3300-5056-4005-9E71-E5D933889581}.Debug|Any CPU.Build.0 = Debug|Any CPU
7474
{853D3300-5056-4005-9E71-E5D933889581}.Debug|ARM.ActiveCfg = Debug|Any CPU
75+
{853D3300-5056-4005-9E71-E5D933889581}.Debug|ARM.Build.0 = Debug|Any CPU
7576
{853D3300-5056-4005-9E71-E5D933889581}.Debug|iPhone.ActiveCfg = Debug|Any CPU
7677
{853D3300-5056-4005-9E71-E5D933889581}.Debug|iPhoneSimulator.ActiveCfg = Debug|Any CPU
78+
{853D3300-5056-4005-9E71-E5D933889581}.Debug|iPhoneSimulator.Build.0 = Debug|Any CPU
7779
{853D3300-5056-4005-9E71-E5D933889581}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU
7880
{853D3300-5056-4005-9E71-E5D933889581}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU
7981
{853D3300-5056-4005-9E71-E5D933889581}.Debug|x64.ActiveCfg = Debug|Any CPU
8082
{853D3300-5056-4005-9E71-E5D933889581}.Debug|x64.Build.0 = Debug|Any CPU
8183
{853D3300-5056-4005-9E71-E5D933889581}.Debug|x86.ActiveCfg = Debug|Any CPU
84+
{853D3300-5056-4005-9E71-E5D933889581}.Debug|x86.Build.0 = Debug|Any CPU
8285
{853D3300-5056-4005-9E71-E5D933889581}.Release|Any CPU.ActiveCfg = Release|Any CPU
8386
{853D3300-5056-4005-9E71-E5D933889581}.Release|Any CPU.Build.0 = Release|Any CPU
8487
{853D3300-5056-4005-9E71-E5D933889581}.Release|ARM.ActiveCfg = Release|Any CPU

BugSweeper/BugSweeper/BugSweeper.Android/BugSweeper.Android.csproj

+10-2
Original file line numberDiff line numberDiff line change
@@ -18,19 +18,27 @@
1818
<AndroidSupportedAbis>armeabi,armeabi-v7a,x86</AndroidSupportedAbis>
1919
<AndroidStoreUncompressedFileExtensions />
2020
<MandroidI18n />
21-
<JavaMaximumHeapSize></JavaMaximumHeapSize>
21+
<JavaMaximumHeapSize>
22+
</JavaMaximumHeapSize>
2223
<JavaOptions />
2324
<NuGetPackageImportStamp>42f058a4</NuGetPackageImportStamp>
2425
</PropertyGroup>
2526
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
26-
<DebugSymbols>true</DebugSymbols>
27+
<DebugSymbols>True</DebugSymbols>
2728
<DebugType>full</DebugType>
2829
<Optimize>false</Optimize>
2930
<OutputPath>bin\Debug\</OutputPath>
3031
<DefineConstants>DEBUG;TRACE</DefineConstants>
3132
<ErrorReport>prompt</ErrorReport>
3233
<WarningLevel>4</WarningLevel>
3334
<AndroidLinkMode>None</AndroidLinkMode>
35+
<AndroidUseSharedRuntime>True</AndroidUseSharedRuntime>
36+
<EmbedAssembliesIntoApk>False</EmbedAssembliesIntoApk>
37+
<BundleAssemblies>False</BundleAssemblies>
38+
<AndroidCreatePackagePerAbi>False</AndroidCreatePackagePerAbi>
39+
<JavaMaximumHeapSize>1G</JavaMaximumHeapSize>
40+
<Debugger>Xamarin</Debugger>
41+
<AndroidEnableMultiDex>False</AndroidEnableMultiDex>
3442
</PropertyGroup>
3543
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
3644
<DebugType>pdbonly</DebugType>
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
1-
<?xml version="1.0" encoding="utf-8"?>
1+
<?xml version="1.0" encoding="utf-8"?>
22
<manifest xmlns:android="http://schemas.android.com/apk/res/android">
33
<uses-sdk android:minSdkVersion="15" android:targetSdkVersion="23" />
4-
<application android:icon="@drawable/icon">
5-
</application>
6-
</manifest>
4+
<application android:icon="@drawable/icon"></application>
5+
</manifest>

BugSweeper/BugSweeper/BugSweeper.UWP/project.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
{
1+
{
22
"dependencies": {
33
"Microsoft.ApplicationInsights": "1.0.0",
44
"Microsoft.ApplicationInsights.PersistenceChannel": "1.0.0",

BugSweeper/BugSweeper/BugSweeper.iOS/AppDelegate.cs

+2-2
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,8 @@ public partial class AppDelegate : FormsApplicationDelegate
2626
public override bool FinishedLaunching(UIApplication app, NSDictionary options)
2727
{
2828
Forms.Init();
29-
LoadApplication (new App ());
30-
return base.FinishedLaunching(app,options);
29+
LoadApplication (new App ());
30+
return base.FinishedLaunching(app,options);
3131
}
3232
}
3333
}

BugSweeper/BugSweeper/BugSweeper.iOS/BugSweeper.iOS.csproj

+9-9
Original file line numberDiff line numberDiff line change
@@ -23,11 +23,9 @@
2323
<ConsolePause>false</ConsolePause>
2424
<MtouchLink>None</MtouchLink>
2525
<MtouchDebug>True</MtouchDebug>
26-
<MtouchSdkVersion>8.0</MtouchSdkVersion>
27-
<MtouchExtraArgs></MtouchExtraArgs>
28-
<MtouchArch>Default, ARMv7</MtouchArch>
26+
<MtouchArch>i386, x86_64</MtouchArch>
2927
<MtouchOptimizePNGs>True</MtouchOptimizePNGs>
30-
<MtouchI18n></MtouchI18n>
28+
<CodesignEntitlements />
3129
</PropertyGroup>
3230
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|iPhoneSimulator' ">
3331
<DebugType>none</DebugType>
@@ -37,6 +35,7 @@
3735
<WarningLevel>4</WarningLevel>
3836
<ConsolePause>false</ConsolePause>
3937
<MtouchLink>None</MtouchLink>
38+
<CodesignEntitlements />
4039
</PropertyGroup>
4140
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|iPhone' ">
4241
<DebugSymbols>true</DebugSymbols>
@@ -81,7 +80,9 @@
8180
<ItemGroup>
8281
<Compile Include="Main.cs" />
8382
<Compile Include="AppDelegate.cs" />
84-
<None Include="Info.plist" />
83+
<None Include="Info.plist">
84+
<SubType>Designer</SubType>
85+
</None>
8586
<Compile Include="Properties\AssemblyInfo.cs" />
8687
<None Include="packages.config" />
8788
</ItemGroup>
@@ -91,7 +92,8 @@
9192
<Project>{853D3300-5056-4005-9E71-E5D933889581}</Project>
9293
</ProjectReference>
9394
</ItemGroup>
94-
<ItemGroup></ItemGroup>
95+
<ItemGroup>
96+
</ItemGroup>
9597
<ItemGroup>
9698
<Reference Include="System" />
9799
<Reference Include="System.Xml" />
@@ -111,9 +113,7 @@
111113
<Reference Include="Xamarin.iOS" />
112114
</ItemGroup>
113115
<Import Project="$(MSBuildExtensionsPath)\Xamarin\iOS\Xamarin.iOS.CSharp.targets" />
114-
<ItemGroup>
115-
<Folder Include="Resources\" />
116-
</ItemGroup>
116+
<ItemGroup />
117117
<ItemGroup>
118118
<BundleResource Include="Resources\Default-568h%402x.png" />
119119
<BundleResource Include="Resources\Default.png" />

BugSweeper/BugSweeper/BugSweeper/Board.cs

-1
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@ class Board : AbsoluteLayout
2222

2323
public Board()
2424
{
25-
2625
for (int row = 0; row < ROWS; row++)
2726
for (int col = 0; col < COLS; col++)
2827
{
Original file line numberDiff line numberDiff line change
@@ -1,77 +1,78 @@
11
<?xml version="1.0" encoding="utf-8"?>
2-
<ContentPage xmlns="http://xamarin.com/schemas/2014/forms" xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml" xmlns:local="clr-namespace:BugSweeper;assembly=BugSweeper" x:Class="BugSweeper.BugSweeperPage" Title="BugSweeper">
3-
<ContentPage.Padding>
4-
<OnPlatform x:TypeArguments="Thickness" iOS="0, 20, 0, 0" Android="0, 0, 0, 0" WinPhone="0, 0, 0, 0" />
5-
</ContentPage.Padding>
6-
<ContentView SizeChanged="OnMainContentViewSizeChanged">
7-
<Grid x:Name="mainGrid">
8-
<Grid.RowDefinitions>
9-
<RowDefinition Height="7*" />
10-
<RowDefinition Height="4*" />
11-
</Grid.RowDefinitions>
12-
<Grid.ColumnDefinitions>
13-
<ColumnDefinition Width="0" />
14-
<ColumnDefinition Width="*" />
15-
</Grid.ColumnDefinitions>
16-
<StackLayout x:Name="textStack" Grid.Row="0" Grid.Column="1" Spacing="0">
17-
<StackLayout HorizontalOptions="Center" Spacing="0">
18-
<Label Text="BugSweeper" Font="Bold, Large" TextColor="Accent" />
19-
<BoxView Color="Accent" HeightRequest="3" />
20-
</StackLayout>
21-
<Label Text="Tap to flag/unflag a potential bug." VerticalOptions="CenterAndExpand" HorizontalTextAlignment="Center" />
22-
<Label Text="Double-tap if you're sure it's not a bug.&#xA;The first double-tap is always safe!" VerticalOptions="CenterAndExpand" HorizontalTextAlignment="Center" />
23-
<StackLayout Orientation="Horizontal" Spacing="0" VerticalOptions="CenterAndExpand" HorizontalOptions="Center">
24-
<Label BindingContext="{x:Reference board}" Text="{Binding FlaggedTileCount, StringFormat='Flagged {0} '}" />
25-
<Label BindingContext="{x:Reference board}" Text="{Binding BugCount, StringFormat=' out of {0} bugs.'}" />
26-
</StackLayout>
27-
<!-- Make this a binding??? -->
28-
<Label x:Name="timeLabel" Text="0:00" VerticalOptions="CenterAndExpand" HorizontalTextAlignment="Center" />
29-
</StackLayout>
30-
<ContentView Grid.Row="1" Grid.Column="1" SizeChanged="OnBoardContentViewSizeChanged">
31-
<!-- Single-cell Grid for Board and overlays. -->
32-
<Grid>
33-
<Grid.RowDefinitions>
34-
<RowDefinition Height="*" />
35-
</Grid.RowDefinitions>
36-
<Grid.ColumnDefinitions>
37-
<ColumnDefinition Width="*" />
38-
</Grid.ColumnDefinitions>
39-
<local:Board x:Name="board" />
40-
<StackLayout x:Name="congratulationsText" Orientation="Horizontal" HorizontalOptions="Center" VerticalOptions="Center" Spacing="0">
41-
<Label Text="C" TextColor="Red" />
42-
<Label Text="O" TextColor="Red" />
43-
<Label Text="N" TextColor="Red" />
44-
<Label Text="G" TextColor="Red" />
45-
<Label Text="R" TextColor="Red" />
46-
<Label Text="A" TextColor="Red" />
47-
<Label Text="T" TextColor="Red" />
48-
<Label Text="U" TextColor="Red" />
49-
<Label Text="L" TextColor="Red" />
50-
<Label Text="A" TextColor="Red" />
51-
<Label Text="T" TextColor="Red" />
52-
<Label Text="I" TextColor="Red" />
53-
<Label Text="O" TextColor="Red" />
54-
<Label Text="N" TextColor="Red" />
55-
<Label Text="S" TextColor="Red" />
56-
<Label Text="!" TextColor="Red" />
57-
</StackLayout>
58-
<StackLayout x:Name="consolationText" Orientation="Horizontal" Spacing="0" HorizontalOptions="Center" VerticalOptions="Center">
59-
<Label Text="T" TextColor="Red" />
60-
<Label Text="O" TextColor="Red" />
61-
<Label Text="O" TextColor="Red" />
62-
<Label Text=" " TextColor="Red" />
63-
<Label Text="B" TextColor="Red" />
64-
<Label Text="A" TextColor="Red" />
65-
<Label Text="D" TextColor="Red" />
66-
<Label Text="!" TextColor="Red" />
67-
</StackLayout>
68-
<Button x:Name="playAgainButton" Text="Play Another Game" HorizontalOptions="Center" VerticalOptions="Center" Clicked="OnplayAgainButtonClicked">
69-
<Button.BackgroundColor>
70-
<OnPlatform x:TypeArguments="Color" iOS="#C0FFFFFF" Android="Default" WinPhone="#C0808080" />
71-
</Button.BackgroundColor>
72-
</Button>
73-
</Grid>
74-
</ContentView>
75-
</Grid>
76-
</ContentView>
2+
<ContentPage xmlns="http://xamarin.com/schemas/2014/forms"
3+
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
4+
xmlns:local="clr-namespace:BugSweeper;assembly=BugSweeper"
5+
x:Class="BugSweeper.BugSweeperPage"
6+
Title="BugSweeper">
7+
<ContentPage.Padding>
8+
<OnPlatform x:TypeArguments="Thickness" iOS="0, 20, 0, 0" Android="0, 0, 0, 0" WinPhone="0, 0, 0, 0" />
9+
</ContentPage.Padding>
10+
<ContentView SizeChanged="OnMainContentViewSizeChanged">
11+
<Grid x:Name="mainGrid" ColumnSpacing="0" RowSpacing="0">
12+
<Grid.RowDefinitions>
13+
<RowDefinition Height="7*" />
14+
<RowDefinition Height="4*" />
15+
</Grid.RowDefinitions>
16+
<Grid.ColumnDefinitions>
17+
<ColumnDefinition Width="0" />
18+
<ColumnDefinition Width="*" />
19+
</Grid.ColumnDefinitions>
20+
<StackLayout x:Name="textStack" Grid.Row="0" Grid.Column="1" Spacing="0">
21+
<StackLayout HorizontalOptions="Center" Spacing="0">
22+
<Label Text="BugSweeper" Font="Bold, Large" TextColor="Accent" />
23+
<BoxView Color="Accent" HeightRequest="3" />
24+
</StackLayout>
25+
<Label Text="Tap to flag/unflag a potential bug." VerticalOptions="CenterAndExpand" HorizontalTextAlignment="Center" />
26+
<Label Text="Double-tap if you're sure it's not a bug.&#xA;The first double-tap is always safe!" VerticalOptions="CenterAndExpand" HorizontalTextAlignment="Center" />
27+
<StackLayout Orientation="Horizontal" Spacing="0" VerticalOptions="CenterAndExpand" HorizontalOptions="Center">
28+
<Label BindingContext="{x:Reference board}" Text="{Binding FlaggedTileCount, StringFormat='Flagged {0} '}" />
29+
<Label BindingContext="{x:Reference board}" Text="{Binding BugCount, StringFormat=' out of {0} bugs.'}" />
30+
</StackLayout>
31+
<!-- Make this a binding??? -->
32+
<Label x:Name="timeLabel" Text="0:00" VerticalOptions="CenterAndExpand" HorizontalTextAlignment="Center" />
33+
</StackLayout>
34+
<ContentView Grid.Row="1" Grid.Column="1" SizeChanged="OnBoardContentViewSizeChanged">
35+
<!-- Single-cell Grid for Board and overlays. -->
36+
<Grid>
37+
<Grid.RowDefinitions>
38+
<RowDefinition Height="*" />
39+
</Grid.RowDefinitions>
40+
<Grid.ColumnDefinitions>
41+
<ColumnDefinition Width="*" />
42+
</Grid.ColumnDefinitions>
43+
<local:Board x:Name="board" />
44+
<StackLayout x:Name="congratulationsText" Orientation="Horizontal" HorizontalOptions="Center" VerticalOptions="Center" Spacing="0">
45+
<Label Text="C" TextColor="Red" />
46+
<Label Text="O" TextColor="Red" />
47+
<Label Text="N" TextColor="Red" />
48+
<Label Text="G" TextColor="Red" />
49+
<Label Text="R" TextColor="Red" />
50+
<Label Text="A" TextColor="Red" />
51+
<Label Text="T" TextColor="Red" />
52+
<Label Text="U" TextColor="Red" />
53+
<Label Text="L" TextColor="Red" />
54+
<Label Text="A" TextColor="Red" />
55+
<Label Text="T" TextColor="Red" />
56+
<Label Text="I" TextColor="Red" />
57+
<Label Text="O" TextColor="Red" />
58+
<Label Text="N" TextColor="Red" />
59+
<Label Text="S" TextColor="Red" />
60+
<Label Text="!" TextColor="Red" />
61+
</StackLayout>
62+
<StackLayout x:Name="consolationText" Orientation="Horizontal" Spacing="0" HorizontalOptions="Center" VerticalOptions="Center">
63+
<Label Text="T" TextColor="Red" />
64+
<Label Text="O" TextColor="Red" />
65+
<Label Text="O" TextColor="Red" />
66+
<Label Text=" " TextColor="Red" />
67+
<Label Text="B" TextColor="Red" />
68+
<Label Text="A" TextColor="Red" />
69+
<Label Text="D" TextColor="Red" />
70+
<Label Text="!" TextColor="Red" />
71+
</StackLayout>
72+
<Button x:Name="playAgainButton" Text=" Play Another Game? " HorizontalOptions="Center" VerticalOptions="Center" Clicked="OnplayAgainButtonClicked"
73+
BorderColor="Black" BorderWidth="2" BackgroundColor="White" TextColor="Black" />
74+
</Grid>
75+
</ContentView>
76+
</Grid>
77+
</ContentView>
7778
</ContentPage>

BugSweeper/BugSweeper/BugSweeper/BugSweeperPage.xaml.cs

+12-44
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
1-
#define FIX_ANDROID_ANCHORS // Android AnchorX and AnchorY must be set to 0.5
2-
// but can't be set exactly to 0.5
3-
#define FIX_WINPHONE_BUTTON // IsEnabled = false doesn't disable button
1+
#define FIX_WINPHONE_BUTTON // IsEnabled = false doesn't disable button
42

53
#pragma warning disable 4014 // for non-await'ed async call
64

@@ -11,7 +9,7 @@
119

1210
namespace BugSweeper
1311
{
14-
public partial class BugSweeperPage
12+
public partial class BugSweeperPage : ContentPage
1513
{
1614
const string timeFormat = @"%m\:ss";
1715

@@ -113,35 +111,18 @@ async void DisplayWonAnimation()
113111
congratulationsText.Scale = 0;
114112
congratulationsText.IsVisible = true;
115113

116-
#if FIX_ANDROID_ANCHORS
117-
118-
if (Device.OS == TargetPlatform.Android)
119-
{
120-
congratulationsText.AnchorX = 0.49;
121-
congratulationsText.AnchorY = 0.49;
122-
}
123-
124-
#endif
114+
// Because IsVisible has been false, the text might not have a size yet,
115+
// in which case Measure will return a size.
116+
double congratulationsTextWidth = congratulationsText.Measure(Double.PositiveInfinity, Double.PositiveInfinity).Request.Width;
125117

126118
congratulationsText.Rotation = 0;
127119
congratulationsText.RotateTo(3 * 360, 1000, Easing.CubicOut);
128120

129-
double maxScale = 0.9 * board.Width / congratulationsText.Width;
121+
double maxScale = 0.9 * board.Width / congratulationsTextWidth;
130122
await congratulationsText.ScaleTo(maxScale, 1000);
131123

132124
foreach (View view in congratulationsText.Children)
133125
{
134-
135-
#if FIX_ANDROID_ANCHORS
136-
137-
if (Device.OS == TargetPlatform.Android)
138-
{
139-
view.AnchorX = 0.49;
140-
view.AnchorY = 0.49;
141-
}
142-
143-
#endif
144-
145126
view.Rotation = 0;
146127
view.RotateTo(180);
147128
await view.ScaleTo(3, 100);
@@ -157,16 +138,10 @@ async void DisplayLostAnimation()
157138
consolationText.Scale = 0;
158139
consolationText.IsVisible = true;
159140

160-
#if FIX_ANDROID_ANCHORS
141+
// (See above for rationale)
142+
double consolationTextWidth = consolationText.Measure(Double.PositiveInfinity, Double.PositiveInfinity).Request.Width;
161143

162-
if (Device.OS == TargetPlatform.Android)
163-
{
164-
consolationText.AnchorX = 0.49;
165-
consolationText.AnchorY = 0.49;
166-
}
167-
168-
#endif
169-
double maxScale = 0.9 * board.Width / consolationText.Width;
144+
double maxScale = 0.9 * board.Width / consolationTextWidth;
170145
await consolationText.ScaleTo(maxScale, 1000);
171146
await Task.Delay(1000);
172147
await DisplayPlayAgainButton();
@@ -178,17 +153,10 @@ async Task DisplayPlayAgainButton()
178153
playAgainButton.IsVisible = true;
179154
playAgainButton.IsEnabled = true;
180155

181-
#if FIX_ANDROID_ANCHORS
182-
183-
if (Device.OS == TargetPlatform.Android)
184-
{
185-
playAgainButton.AnchorX = 0.49;
186-
playAgainButton.AnchorY = 0.49;
187-
}
188-
189-
#endif
156+
// (See above for rationale)
157+
double playAgainButtonWidth = playAgainButton.Measure(Double.PositiveInfinity, Double.PositiveInfinity).Request.Width;
190158

191-
double maxScale = board.Width / playAgainButton.Width;
159+
double maxScale = board.Width / playAgainButtonWidth;
192160
await playAgainButton.ScaleTo(maxScale, 1000, Easing.SpringOut);
193161
}
194162

0 commit comments

Comments
 (0)