Skip to content

Commit

Permalink
Merge pull request #747 from vb2ae/Update_Setup_Projects
Browse files Browse the repository at this point in the history
Update setup projects
  • Loading branch information
nigel-sampson authored Apr 23, 2021
2 parents 4b03903 + d082b25 commit d7fe18a
Show file tree
Hide file tree
Showing 156 changed files with 22,167 additions and 9,611 deletions.

Large diffs are not rendered by default.

13 changes: 7 additions & 6 deletions samples/setup/Setup.Android/Activities/HomeActivity.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
using System;
using System.Net.Mime;
using Android.App;
using Android.Widget;
using Caliburn.Micro;
using Setup.Android.ViewModels;

Expand All @@ -9,7 +11,6 @@ namespace Setup.Android.Activities
public class HomeActivity : Activity
{
private readonly HomeViewModel viewModel;

public HomeActivity()
{
viewModel = IoC.Get<HomeViewModel>();
Expand All @@ -19,18 +20,18 @@ public HomeActivity()
viewAware.AttachView(this);
}

protected override void OnResume()
protected override async void OnResume()
{
base.OnResume();

ScreenExtensions.TryActivate(viewModel);
await ScreenExtensions.TryActivateAsync(viewModel);
}

protected override void OnPause()
protected override async void OnPause()
{
base.OnPause();

ScreenExtensions.TryDeactivate(viewModel, false);
await ScreenExtensions.TryDeactivateAsync(viewModel, false);
}
}
}
}
27 changes: 21 additions & 6 deletions samples/setup/Setup.Android/Resources/Resource.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 8 additions & 1 deletion samples/setup/Setup.Android/Resources/layout/Main.axml
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,11 @@
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent" />
android:layout_height="fill_parent" >
<TextView
android:id="@+id/SubmittedMessage"
android:layout_marginBottom="10dp"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:gravity="center" />
</LinearLayout>
18 changes: 8 additions & 10 deletions samples/setup/Setup.Android/Setup.Android.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -40,24 +40,22 @@
<AndroidLinkMode>SdkOnly</AndroidLinkMode>
</PropertyGroup>
<ItemGroup>
<Reference Include="Caliburn.Micro, Version=3.0.3.0, Culture=neutral, PublicKeyToken=8e5891231f2ed21f, processorArchitecture=MSIL">
<HintPath>..\packages\Caliburn.Micro.Core.3.0.3\lib\portable-net45+win8+wp8+wpa81+MonoAndroid10+Xamarin.iOS10+MonoTouch10+uap10.0\Caliburn.Micro.dll</HintPath>
<Private>True</Private>
<Reference Include="Caliburn.Micro.Core, Version=4.0.0.0, Culture=neutral, PublicKeyToken=8e5891231f2ed21f, processorArchitecture=MSIL">
<HintPath>..\packages\vb2ae.Caliburn.Micro.Core.4.0.169-g30e441eef5\lib\netstandard2.0\Caliburn.Micro.Core.dll</HintPath>
</Reference>
<Reference Include="Caliburn.Micro.Platform, Version=3.0.3.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\Caliburn.Micro.3.0.3\lib\MonoAndroid10\Caliburn.Micro.Platform.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="Caliburn.Micro.Platform.Core, Version=3.0.3.0, Culture=neutral, PublicKeyToken=8e5891231f2ed21f, processorArchitecture=MSIL">
<HintPath>..\packages\Caliburn.Micro.3.0.3\lib\MonoAndroid10\Caliburn.Micro.Platform.Core.dll</HintPath>
<Private>True</Private>
<Reference Include="Caliburn.Micro.Platform, Version=4.0.0.0, Culture=neutral, PublicKeyToken=8e5891231f2ed21f, processorArchitecture=MSIL">
<HintPath>..\packages\vb2ae.Caliburn.Micro.4.0.169-g30e441eef5\lib\monoandroid80\Caliburn.Micro.Platform.dll</HintPath>
</Reference>
<Reference Include="Java.Interop" />
<Reference Include="Mono.Android" />
<Reference Include="mscorlib" />
<Reference Include="System" />
<Reference Include="System.Core" />
<Reference Include="System.Xml.Linq" />
<Reference Include="System.Xml" />
<Reference Include="vb2ae.Caliburn.Micro.Platform.Core, Version=4.0.0.0, Culture=neutral, PublicKeyToken=8e5891231f2ed21f, processorArchitecture=MSIL">
<HintPath>..\packages\vb2ae.Caliburn.Micro.4.0.169-g30e441eef5\lib\monoandroid80\vb2ae.Caliburn.Micro.Platform.Core.dll</HintPath>
</Reference>
</ItemGroup>
<ItemGroup>
<Compile Include="Activities\HomeActivity.cs" />
Expand Down
18 changes: 17 additions & 1 deletion samples/setup/Setup.Android/ViewModels/HomeViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,21 @@ namespace Setup.Android.ViewModels
{
public class HomeViewModel : Screen
{
private string _title;

public string Title
{
get => _title;
set
{
_title = value;
NotifyOfPropertyChange("Title");
}
}

public HomeViewModel()
{
Title = "Welcome to Caliburn Micro in Xamarin.Android";
}
}
}
}
5 changes: 3 additions & 2 deletions samples/setup/Setup.Android/packages.config
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="Caliburn.Micro" version="3.0.3" targetFramework="monoandroid60" />
<package id="Caliburn.Micro.Core" version="3.0.3" targetFramework="monoandroid60" />
<package id="System.Runtime.Serialization.Primitives" version="4.3.0" targetFramework="monoandroid90" />
<package id="vb2ae.Caliburn.Micro" version="4.0.169-g30e441eef5" targetFramework="monoandroid90" />
<package id="vb2ae.Caliburn.Micro.Core" version="4.0.169-g30e441eef5" targetFramework="monoandroid90" />
</packages>

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Reflection;
using System.Text;

using Android.App;
using Android.Content;
using Android.OS;
using Android.Runtime;
using Android.Views;
using Android.Widget;
using Caliburn.Micro;
using Setup.Forms5.ViewModels;

namespace Setup.Forms5.Droid
{
[Application]
public class Application : CaliburnApplication
{
private SimpleContainer container;

public Application(IntPtr javaReference, JniHandleOwnership transfer)
: base(javaReference, transfer)
{

}

public override void OnCreate()
{
base.OnCreate();

Initialize();
}

protected override void Configure()
{
container = new SimpleContainer();
container.Instance(container);
container.Singleton<App>();
}

protected override IEnumerable<Assembly> SelectAssemblies()
{
return new[]
{
GetType().Assembly,
typeof (HomeViewModel).Assembly
};
}

protected override void BuildUp(object instance)
{
container.BuildUp(instance);
}

protected override IEnumerable<object> GetAllInstances(Type service)
{
return container.GetAllInstances(service);
}

protected override object GetInstance(Type service, string key)
{
return container.GetInstance(service, key);
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
Any raw assets you want to be deployed with your application can be placed in
this directory (and child directories) and given a Build Action of "AndroidAsset".

These files will be deployed with your package and will be accessible using Android's
AssetManager, like this:

public class ReadAsset : Activity
{
protected override void OnCreate (Bundle bundle)
{
base.OnCreate (bundle);

InputStream input = Assets.Open ("my_asset.txt");
}
}

Additionally, some Android functions will automatically load asset files:

Typeface tf = Typeface.CreateFromAsset (Context.Assets, "fonts/samplefont.ttf");
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
using System;

using Android.App;
using Android.Content.PM;
using Android.Runtime;
using Android.OS;
using Caliburn.Micro;
using Setup.Forms5;

namespace Setup.Forms5.Droid
{
[Activity(Label = "Setup.Forms5", Icon = "@mipmap/icon", Theme = "@style/MainTheme", MainLauncher = true, ConfigurationChanges = ConfigChanges.ScreenSize | ConfigChanges.Orientation | ConfigChanges.UiMode | ConfigChanges.ScreenLayout | ConfigChanges.SmallestScreenSize )]
public class MainActivity : global::Xamarin.Forms.Platform.Android.FormsAppCompatActivity
{
protected override void OnCreate(Bundle savedInstanceState)
{
base.OnCreate(savedInstanceState);

Xamarin.Essentials.Platform.Init(this, savedInstanceState);
global::Xamarin.Forms.Forms.Init(this, savedInstanceState);
LoadApplication(IoC.Get<Setup.Forms5.App>());
}
public override void OnRequestPermissionsResult(int requestCode, string[] permissions, [GeneratedEnum] Android.Content.PM.Permission[] grantResults)
{
Xamarin.Essentials.Platform.OnRequestPermissionsResult(requestCode, permissions, grantResults);

base.OnRequestPermissionsResult(requestCode, permissions, grantResults);
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android" android:versionCode="1" android:versionName="1.0" package="com.companyname.setup.forms5" android:installLocation="auto">
<uses-sdk android:minSdkVersion="24" android:targetSdkVersion="30" />
<application android:label="Setup.Forms5.Android" android:theme="@style/MainTheme"></application>
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
</manifest>
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using Android.App;

// 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("Setup.Forms5.Android")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("Setup.Forms5.Android")]
[assembly: AssemblyCopyright("Copyright © 2014")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]
[assembly: ComVisible(false)]

// Version information for an assembly consists of the following four values:
//
// Major Version
// Minor Version
// Build Number
// Revision
[assembly: AssemblyVersion("1.0.0.0")]
[assembly: AssemblyFileVersion("1.0.0.0")]

// Add some common permissions, these can be removed if not needed
[assembly: UsesPermission(Android.Manifest.Permission.Internet)]
[assembly: UsesPermission(Android.Manifest.Permission.WriteExternalStorage)]
Loading

0 comments on commit d7fe18a

Please sign in to comment.