Skip to content
This repository was archived by the owner on Apr 29, 2024. It is now read-only.

Commit a65f298

Browse files
authored
Merge pull request #561 from xamarin/jusjohns-localdb-updates
Jusjohns localdb updates
2 parents 620414f + 65acbb2 commit a65f298

22 files changed

+382
-482
lines changed

Todo/Todo.Android/MainActivity.cs

100755100644
-3
Original file line numberDiff line numberDiff line change
@@ -8,15 +8,12 @@ namespace Todo
88
ConfigurationChanges = ConfigChanges.ScreenSize | ConfigChanges.Orientation)]
99
public class MainActivity : global::Xamarin.Forms.Platform.Android.FormsAppCompatActivity
1010
{
11-
internal static MainActivity Instance { get; private set; }
12-
1311
protected override void OnCreate(Bundle bundle)
1412
{
1513
TabLayoutResource = Resource.Layout.Tabbar;
1614
ToolbarResource = Resource.Layout.Toolbar;
1715

1816
base.OnCreate(bundle);
19-
Instance = this;
2017
global::Xamarin.Forms.Forms.Init(this, bundle);
2118
LoadApplication(new App());
2219
}

Todo/Todo.Android/TextToSpeech_Android.cs

-38
This file was deleted.

Todo/Todo.Android/Todo.Android.csproj

-1
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,6 @@
5757
<Compile Include="MainActivity.cs" />
5858
<Compile Include="Resources\Resource.designer.cs" />
5959
<Compile Include="Properties\AssemblyInfo.cs" />
60-
<Compile Include="TextToSpeech_Android.cs" />
6160
</ItemGroup>
6261
<ItemGroup>
6362
<None Include="Resources\AboutResources.txt" />

Todo/Todo.UWP/TextToSpeech_UWP.cs

-31
This file was deleted.

Todo/Todo.UWP/Todo.UWP.csproj

-1
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,6 @@
101101
<DependentUpon>MainPage.xaml</DependentUpon>
102102
</Compile>
103103
<Compile Include="Properties\AssemblyInfo.cs" />
104-
<Compile Include="TextToSpeech_UWP.cs" />
105104
</ItemGroup>
106105
<ItemGroup>
107106
<AppxManifest Include="Package.appxmanifest">

Todo/Todo.iOS/TextToSpeech_iOS.cs

-34
This file was deleted.

Todo/Todo.iOS/Todo.iOS.csproj

-1
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,6 @@
135135
<ItemGroup>
136136
<Compile Include="Main.cs" />
137137
<Compile Include="AppDelegate.cs" />
138-
<Compile Include="TextToSpeech_iOS.cs" />
139138
</ItemGroup>
140139
<Import Project="$(MSBuildExtensionsPath)\Xamarin\iOS\Xamarin.iOS.CSharp.targets" />
141140
<ItemGroup>

Todo/Todo/App.cs

-98
This file was deleted.

Todo/Todo/App.xaml

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<Application xmlns="http://xamarin.com/schemas/2014/forms"
3+
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
4+
x:Class="Todo.App">
5+
<Application.Resources>
6+
<ResourceDictionary>
7+
<Color x:Key="primaryGreen">#91CA47</Color>
8+
<Color x:Key="primaryDarkGreen">#6FA22E</Color>
9+
</ResourceDictionary>
10+
</Application.Resources>
11+
</Application>

Todo/Todo/App.xaml.cs

+50
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
using Xamarin.Forms;
2+
using Xamarin.Forms.Xaml;
3+
4+
[assembly: XamlCompilation(XamlCompilationOptions.Compile)]
5+
namespace Todo
6+
{
7+
public partial class App : Application
8+
{
9+
static TodoItemDatabase database;
10+
11+
public App()
12+
{
13+
InitializeComponent();
14+
15+
var nav = new NavigationPage(new TodoListPage());
16+
nav.BarBackgroundColor = (Color)App.Current.Resources["primaryGreen"];
17+
nav.BarTextColor = Color.White;
18+
19+
MainPage = nav;
20+
}
21+
22+
public static TodoItemDatabase Database
23+
{
24+
get
25+
{
26+
if (database == null)
27+
{
28+
database = new TodoItemDatabase();
29+
}
30+
return database;
31+
}
32+
}
33+
34+
protected override void OnStart()
35+
{
36+
37+
}
38+
39+
protected override void OnSleep()
40+
{
41+
42+
}
43+
44+
protected override void OnResume()
45+
{
46+
47+
}
48+
}
49+
}
50+

Todo/Todo/Constants.cs

+27
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
using System;
2+
using System.IO;
3+
4+
namespace Todo
5+
{
6+
public static class Constants
7+
{
8+
public const string DatabaseFilename = "TodoSQLite.db3";
9+
10+
public const SQLite.SQLiteOpenFlags Flags =
11+
// open the database in read/write mode
12+
SQLite.SQLiteOpenFlags.ReadWrite |
13+
// create the database if it doesn't exist
14+
SQLite.SQLiteOpenFlags.Create |
15+
// enable multi-threaded database access
16+
SQLite.SQLiteOpenFlags.SharedCache;
17+
18+
public static string DatabasePath
19+
{
20+
get
21+
{
22+
var basePath = Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData);
23+
return Path.Combine(basePath, DatabaseFilename);
24+
}
25+
}
26+
}
27+
}

0 commit comments

Comments
 (0)