Skip to content

Commit

Permalink
Many more samples :-)
Browse files Browse the repository at this point in the history
  • Loading branch information
Martin Baulig committed Aug 16, 2010
1 parent 8420274 commit 6b3e7a5
Show file tree
Hide file tree
Showing 128 changed files with 5,420 additions and 0 deletions.
34 changes: 34 additions & 0 deletions Button/Button.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
using System;

using Android.App;
using Android.OS;
using Android.Runtime;

namespace Mono.Samples.Button
{
public class ButtonActivity : Activity
{
int count = 0;

public ButtonActivity (IntPtr handle) : base (handle)
{
}

protected override void OnCreate (Bundle bundle)
{
#if MONODROID_TIMING
Logger.Log(LogLevel.Info, "MonoDroid-Timing", "ButtonActivity.OnCreate: time: " + (DateTime.Now - new DateTime (1970, 1, 1)).TotalMilliseconds);
#endif
base.OnCreate (bundle);

// Create your application here
Android.Widget.Button button = new Android.Widget.Button (this);

button.Text = string.Format ("{0} clicks!!", count);
button.Click += delegate { button.Text = string.Format ("{0} clicks!!", ++count); };

SetContentView (button);
}
}
}

55 changes: 55 additions & 0 deletions Button/DroidButton.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProductVersion>8.0.30703</ProductVersion>
<SchemaVersion>2.0</SchemaVersion>
<ProjectGuid>{CB69577F-1797-4ADD-8A24-9079679D8FC3}</ProjectGuid>
<ProjectTypeGuids>{EFBA0AD7-5A72-4C68-AF49-83D382785DCF};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
<OutputType>Library</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>DroidButton</RootNamespace>
<AssemblyName>DroidButton</AssemblyName>
<FileAlignment>512</FileAlignment>
<AndroidResgenFile>R.cs</AndroidResgenFile>
<AndroidManifest>Properties\AndroidManifest.xml</AndroidManifest>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<ItemGroup>
<Reference Include="Mono.Android" />
<Reference Include="System" />
<Reference Include="System.Core" />
<Reference Include="System.Xml.Linq" />
<Reference Include="System.Xml" />
</ItemGroup>
<ItemGroup>
<Compile Include="Button.cs" />
<Compile Include="R.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
</ItemGroup>
<Import Project="$(MSBuildExtensionsPath)\Novell\Novell.MonoDroid.CSharp.targets" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.
<Target Name="BeforeBuild">
</Target>
<Target Name="AfterBuild">
</Target>
-->
</Project>
20 changes: 20 additions & 0 deletions Button/DroidButton.sln
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@

Microsoft Visual Studio Solution File, Format Version 11.00
# Visual Studio 2010
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "DroidButton", "DroidButton.csproj", "{CB69577F-1797-4ADD-8A24-9079679D8FC3}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{CB69577F-1797-4ADD-8A24-9079679D8FC3}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{CB69577F-1797-4ADD-8A24-9079679D8FC3}.Debug|Any CPU.Build.0 = Debug|Any CPU
{CB69577F-1797-4ADD-8A24-9079679D8FC3}.Release|Any CPU.ActiveCfg = Release|Any CPU
{CB69577F-1797-4ADD-8A24-9079679D8FC3}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
EndGlobal
3 changes: 3 additions & 0 deletions Button/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
PROJ=DroidButton.csproj

include ../xbuild.make
3 changes: 3 additions & 0 deletions Button/Properties/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android" package="mono.samples.button">
</manifest>
36 changes: 36 additions & 0 deletions Button/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;

// General Information about an assembly is controlled through the following
// set of attributes. Change these attribute values to modify the information
// associated with an assembly.
[assembly: AssemblyTitle ("DroidButton")]
[assembly: AssemblyDescription ("")]
[assembly: AssemblyConfiguration ("")]
[assembly: AssemblyCompany ("Novell")]
[assembly: AssemblyProduct ("DroidButton")]
[assembly: AssemblyCopyright ("Copyright © Novell 2010")]
[assembly: AssemblyTrademark ("")]
[assembly: AssemblyCulture ("")]

// Setting ComVisible to false makes the types in this assembly not visible
// to COM components. If you need to access a type in this assembly from
// COM, set the ComVisible attribute to true on that type.
[assembly: ComVisible (false)]

// The following GUID is for the ID of the typelib if this project is exposed to COM
[assembly: Guid ("a557ce8c-9dbe-4b93-8fc4-95ffc126cf14")]

// Version information for an assembly consists of the following four values:
//
// Major Version
// Minor Version
// Build Number
// Revision
//
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion ("1.0.0.0")]
[assembly: AssemblyFileVersion ("1.0.0.0")]
Empty file added Button/R.cs
Empty file.
71 changes: 71 additions & 0 deletions Hello/Hello.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
#define CATCH
using System;

using Android.App;
using Android.OS;
using Android.Widget;
using Android.Runtime;
using Android.Views;
using Javax.Net;
using Javax.Microedition.Khronos.Egl;

namespace Mono.Samples.Hello
{
public class HelloActivity : Activity, View.IOnTouchListener
{
TextView textview;

public HelloActivity (IntPtr handle) : base (handle)
{
}

protected override void OnCreate (Bundle bundle)
{
#if MONODROID_TIMING
Logger.Log(LogLevel.Info, "MonoDroid-Timing", "HelloActivity.OnCreate: time: " + (DateTime.Now - new DateTime (1970, 1, 1)).TotalMilliseconds);
#endif
base.OnCreate (bundle);

textview = new TextView (this);
textview.Text = "Hello MonoDroid. Mono loves you.\n\nEmbedded\u0000Nulls";

// Sanity checking to ensure that our binding stays correct.
var v = ServerSocketFactory.Default;
Logger.Log(LogLevel.Info, "HelloApp", "ServerSocketFactory.Default=" + v);
var egl = EGLContext.EGL;
Logger.Log(LogLevel.Info, "HelloApp", "EGLContext.EGL=" + egl);
IEGL10 egl10 = egl.JavaCast<IEGL10>();
Logger.Log(LogLevel.Info, "HelloApp", "(IEGL10) EGLContext.EGL=" + egl10.GetType().FullName);

var list = new Java.Util.ArrayList<string>();
Java.Util.IIterator<string> iterator = list.Iterator ();

#if CATCH
try {
#endif
Logger.Log (LogLevel.Info, "HelloApp", "calling setDefaultKeyMode...");
// NOTE: calling base.SetDefaultKeyMode() causes the app to exit
// unexpectedly when the Home button is pressed.
// this is NOT a MonoDroid bug; the equivalent Java behaves the same.
base.SetDefaultKeyMode (-100);
Logger.Log (LogLevel.Info, "HelloApp", "after setDefaultKeyMode...");
#if CATCH
}
catch (Exception e) {
Logger.Log (LogLevel.Info, "HelloApp", "Yay, exception caught!" + e);
textview.Text += "\n\nEXPECTED EXCEPTION:\n" + e.ToString ();
}
#endif

SetContentView (textview);
textview.SetOnTouchListener (this);
}

public bool OnTouch (View v, MotionEvent e)
{
Logger.Log(LogLevel.Info, "HelloApp", "OnTouchListener.OnTouch: v=" + v + "; e=" + e);
return false;
}
}
}

55 changes: 55 additions & 0 deletions Hello/Hello.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProductVersion>8.0.30703</ProductVersion>
<SchemaVersion>2.0</SchemaVersion>
<ProjectGuid>{73A74ADF-6308-42A0-8BA6-2B5D53238546}</ProjectGuid>
<ProjectTypeGuids>{EFBA0AD7-5A72-4C68-AF49-83D382785DCF};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
<OutputType>Library</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>Hello</RootNamespace>
<AssemblyName>Hello</AssemblyName>
<FileAlignment>512</FileAlignment>
<AndroidResgenFile>R.cs</AndroidResgenFile>
<AndroidManifest>Properties\AndroidManifest.xml</AndroidManifest>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE;MONODROID_TIMING</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE;MONODROID_TIMING</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<ItemGroup>
<Reference Include="Mono.Android" />
<Reference Include="System" />
<Reference Include="System.Core" />
<Reference Include="System.Xml.Linq" />
<Reference Include="System.Xml" />
</ItemGroup>
<ItemGroup>
<Compile Include="Hello.cs" />
<Compile Include="R.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
</ItemGroup>
<Import Project="$(MSBuildExtensionsPath)\Novell\Novell.MonoDroid.CSharp.targets" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.
<Target Name="BeforeBuild">
</Target>
<Target Name="AfterBuild">
</Target>
-->
</Project>
20 changes: 20 additions & 0 deletions Hello/Hello.sln
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@

Microsoft Visual Studio Solution File, Format Version 11.00
# Visual Studio 2010
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Hello", "Hello.csproj", "{73A74ADF-6308-42A0-8BA6-2B5D53238546}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{73A74ADF-6308-42A0-8BA6-2B5D53238546}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{73A74ADF-6308-42A0-8BA6-2B5D53238546}.Debug|Any CPU.Build.0 = Debug|Any CPU
{73A74ADF-6308-42A0-8BA6-2B5D53238546}.Release|Any CPU.ActiveCfg = Release|Any CPU
{73A74ADF-6308-42A0-8BA6-2B5D53238546}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
EndGlobal
3 changes: 3 additions & 0 deletions Hello/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
PROJ=Hello.csproj

include ../xbuild.make
3 changes: 3 additions & 0 deletions Hello/Properties/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android" package="mono.samples.hello">
</manifest>
36 changes: 36 additions & 0 deletions Hello/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;

// General Information about an assembly is controlled through the following
// set of attributes. Change these attribute values to modify the information
// associated with an assembly.
[assembly: AssemblyTitle ("Hello")]
[assembly: AssemblyDescription ("")]
[assembly: AssemblyConfiguration ("")]
[assembly: AssemblyCompany ("Novell")]
[assembly: AssemblyProduct ("Hello")]
[assembly: AssemblyCopyright ("Copyright © Novell 2010")]
[assembly: AssemblyTrademark ("")]
[assembly: AssemblyCulture ("")]

// Setting ComVisible to false makes the types in this assembly not visible
// to COM components. If you need to access a type in this assembly from
// COM, set the ComVisible attribute to true on that type.
[assembly: ComVisible (false)]

// The following GUID is for the ID of the typelib if this project is exposed to COM
[assembly: Guid ("a557ce8c-9dbe-4b93-8fc4-95ffc126cf14")]

// Version information for an assembly consists of the following four values:
//
// Major Version
// Minor Version
// Build Number
// Revision
//
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion ("1.0.0.0")]
[assembly: AssemblyFileVersion ("1.0.0.0")]
Empty file added Hello/R.cs
Empty file.
22 changes: 22 additions & 0 deletions HelloWorld/HelloWorld.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
using System;

using Android.App;
using Android.OS;

namespace Mono.Samples.HelloWorld
{
public class HelloAndroid : Activity
{

public HelloAndroid (IntPtr handle) : base (handle)
{
}

protected override void OnCreate (Bundle savedInstanceState)
{
base.OnCreate (savedInstanceState);

SetContentView (R.layout.main);
}
}
}
Loading

0 comments on commit 6b3e7a5

Please sign in to comment.