Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
45 commits
Select commit Hold shift + click to select a range
c8b22b9
Move all UI to MainView; NuGet update; Avalonia Shell init
Mateusz-Nejman Nov 28, 2024
a6fbcb7
Move to ReactiveUI
Mateusz-Nejman Nov 28, 2024
487118f
Working modal opening; Weird navbar bug
Mateusz-Nejman Nov 28, 2024
671b94c
SideMenu hide
Mateusz-Nejman Nov 28, 2024
791610c
PixedWindow for sub windows base
Mateusz-Nejman Nov 28, 2024
2832cd0
AboutWindow as PixedWindow
Mateusz-Nejman Nov 29, 2024
4dbefad
PixedWindow now can return values; GridSettingsWindow is extending Pi…
Mateusz-Nejman Nov 29, 2024
1ad35e3
Reimplement Windows to use PixedWindow
Mateusz-Nejman Nov 29, 2024
d7513ec
WIP Android project; IPlatformFolder for getting pixed folder; Move D…
Mateusz-Nejman Dec 1, 2024
64aa367
IApplicationLifecycle now for closing app; Set default platform folder
Mateusz-Nejman Dec 2, 2024
a21f7d4
VS Cleanup
Mateusz-Nejman Dec 2, 2024
9664484
Working android project; Absolute folder path for C# IO operations an…
Mateusz-Nejman Dec 2, 2024
155cee3
Zoom to PaintCanvas size on resize
Mateusz-Nejman Dec 3, 2024
45f411e
Move routing to separate namespace; Route class
Mateusz-Nejman Dec 6, 2024
ece1afb
MenuItem builder for cross platform
Mateusz-Nejman Dec 6, 2024
f08ddab
MainView as root for non windows platforms; old MainView renamed to M…
Mateusz-Nejman Dec 6, 2024
a3cd7fe
Android Icon
Mateusz-Nejman Dec 6, 2024
4a5ec96
QuitCommand fix for Android
Mateusz-Nejman Dec 6, 2024
f8bb799
Version getting fix for android
Mateusz-Nejman Dec 6, 2024
a07adfa
Android settings
Mateusz-Nejman Dec 6, 2024
ccc2bef
Styles cleanup
Mateusz-Nejman Dec 6, 2024
54e28f5
Modern splash screen
Mateusz-Nejman Dec 6, 2024
39e29bf
Splash screen fix
Mateusz-Nejman Dec 6, 2024
dfb1291
StreamBase for fixing android stream using
Mateusz-Nejman Dec 6, 2024
121c07e
Disable recent files for android
Mateusz-Nejman Dec 7, 2024
96b3093
Tool icons in Menu
Mateusz-Nejman Dec 7, 2024
789b8d2
Fullscreen only for Windows; Id, Name defined in BaseTool; Menu icons
Mateusz-Nejman Dec 8, 2024
9f5fde9
VS Cleanup
Mateusz-Nejman Dec 8, 2024
152847e
Saving file with extension on Android
Mateusz-Nejman Dec 8, 2024
374fb74
Save file dialog can have only one format if SingleExtensionSaveDialo…
Mateusz-Nejman Dec 9, 2024
5adbbcb
Rename IApplicationLifecycle to IPlatformSettings; Adapt implementati…
Mateusz-Nejman Dec 9, 2024
a499e9b
TODO Fixes
Mateusz-Nejman Dec 10, 2024
e6b7455
Remove single format save dialog functionalities
Mateusz-Nejman Dec 11, 2024
8587b01
Merge branch '164-android-version' of https://github.com/Mateusz-Nejm…
Mateusz-Nejman Dec 11, 2024
c353ede
Cleanup
Mateusz-Nejman Dec 11, 2024
6487c9c
Force SKColorType for generating SKBitmap from array
Mateusz-Nejman Dec 11, 2024
687e483
Navigation methods for common modals
Mateusz-Nejman Dec 14, 2024
3dc10fd
Restore HandleNewInstance for desktop
Mateusz-Nejman Dec 14, 2024
8ddbe9a
Message modal
Mateusz-Nejman Dec 14, 2024
7324736
Palette files as AbstractPaletteSerializer; Loading palettes cleanup
Mateusz-Nejman Dec 15, 2024
7e8d6a9
Internal storage IO unified
Mateusz-Nejman Dec 15, 2024
6ff6185
Transparent background fix
Mateusz-Nejman Dec 16, 2024
dbfd19b
Overlay render don't render on smaller zoom; Transparent background s…
Mateusz-Nejman Dec 17, 2024
7ebe629
Code cleanup
Mateusz-Nejman Dec 17, 2024
0f24249
Nuget update
Mateusz-Nejman Dec 17, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Directory.Build.props
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<Project>
<PropertyGroup>
<Nullable>enable</Nullable>
<AvaloniaVersion>11.1.3</AvaloniaVersion>
<AvaloniaVersion>11.1.0</AvaloniaVersion>
</PropertyGroup>
</Project>
95 changes: 95 additions & 0 deletions Pixed.Android/AndroidStream.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,95 @@
using Pixed.Application.IO;
using System;
using System.IO;

namespace Pixed.Android;
internal class AndroidStreamWrite(Stream stream) : StreamBase(stream)
{
private readonly MemoryStream _internalStream = new();
public override bool CanRead => _internalStream.CanRead;

public override bool CanSeek => _internalStream.CanSeek;

public override bool CanWrite => _internalStream.CanWrite;

public override long Length => _internalStream.Length;

public override long Position { get => _internalStream.Position; set => _internalStream.Position = value; }

public override void Flush()
{
_internalStream.Flush();
_stream.Flush();
}

public override int Read(byte[] buffer, int offset, int count)
{
return _internalStream.Read(buffer, offset, count);
}

public override long Seek(long offset, SeekOrigin origin)
{
return _internalStream.Seek(offset, origin);
}

public override void SetLength(long value)
{
_internalStream.SetLength(value);
}

public override void Write(byte[] buffer, int offset, int count)
{
_internalStream.Write(buffer, offset, count);
}

protected override void Dispose(bool disposing)
{
var buffer = _internalStream.ToArray();
_stream.Write(buffer, 0, buffer.Length);
_internalStream.Dispose();
}
}

internal class AndroidStreamRead(Stream stream) : StreamBase(stream)
{
public override bool CanRead => _stream.CanRead;

public override bool CanSeek => _stream.CanSeek;

public override bool CanWrite => _stream.CanWrite;

public override long Length => _stream.Length;

public override long Position { get => _stream.Position; set => _stream.Position = value; }

public override void Flush()
{
_stream.Flush();
}

public override int Read(byte[] buffer, int offset, int count)
{
return _stream.Read(buffer, offset, count);
}

public override long Seek(long offset, SeekOrigin origin)
{
return _stream.Seek(offset, origin);
}

public override void SetLength(long value)
{
_stream.SetLength(value);
}

public override void Write(byte[] buffer, int offset, int count)
{
throw new NotImplementedException();
}

protected override void Dispose(bool disposing)
{
_stream.Dispose();
}
}

Binary file added Pixed.Android/Icon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
71 changes: 71 additions & 0 deletions Pixed.Android/MainActivity.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
using Android.App;
using Android.Content.PM;
using Android.OS;
using Avalonia;
using Avalonia.Android;
using Avalonia.ReactiveUI;
using AvaloniaInside.Shell;
using Pixed.Application;
using Pixed.Application.IO;
using Pixed.Application.Platform;
using Pixed.Application.Utils;
using System.Threading.Tasks;
using Xamarin.Essentials;

namespace Pixed.Android;

[Activity(
Label = "Pixed - Pixelart Editor",
Icon = "@mipmap/pixed_icon",
MainLauncher = true,
ConfigurationChanges = ConfigChanges.Orientation | ConfigChanges.ScreenSize | ConfigChanges.UiMode)]
public class MainActivity : AvaloniaMainActivity<App>
{
protected override async void OnCreate(Bundle? savedInstanceState)
{
AndroidX.Core.SplashScreen.SplashScreen.InstallSplashScreen(this);
PlatformSettings.MainActivity = this;
PlatformFolder.Context = this;
StreamBase.StreamReadImpl = typeof(AndroidStreamRead);
StreamBase.StreamWriteImpl = typeof(AndroidStreamWrite);
base.OnCreate(savedInstanceState);
Platform.Init(this, savedInstanceState);
var permissions = await CheckPermissions();

if (permissions != PermissionStatus.Granted)
{
FinishAffinity();
}
}
protected override AppBuilder CustomizeAppBuilder(AppBuilder builder)
{
return base.CustomizeAppBuilder(builder)
.LogToTrace()
.UseReactiveUI()
.UseShell()
.SetPlatformFolder(new PlatformFolder())
.SetSettings(new PlatformSettings());
}

private async Task<PermissionStatus> CheckPermissions()
{
var storageRead = await Permissions.CheckStatusAsync<Permissions.StorageRead>();
var storageWrite = await Permissions.CheckStatusAsync<Permissions.StorageWrite>();

if (storageRead == PermissionStatus.Granted && storageWrite == PermissionStatus.Granted)
{
return PermissionStatus.Granted;
}

storageRead = await Permissions.RequestAsync<Permissions.StorageRead>();
storageWrite = await Permissions.RequestAsync<Permissions.StorageWrite>();

if (storageRead != PermissionStatus.Granted || storageWrite != PermissionStatus.Granted)
{
return PermissionStatus.Denied;
}

return PermissionStatus.Granted;
}
}

29 changes: 29 additions & 0 deletions Pixed.Android/Pixed.Android.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net8.0-android34.0</TargetFramework>
<SupportedOSPlatformVersion>26.0</SupportedOSPlatformVersion>
<Nullable>enable</Nullable>
<ApplicationId>com.CompanyName.AvaloniaTest</ApplicationId>
<ApplicationVersion>1</ApplicationVersion>
<ApplicationDisplayVersion>1.0</ApplicationDisplayVersion>
<AndroidPackageFormat>apk</AndroidPackageFormat>
<AndroidEnableProfiledAot>False</AndroidEnableProfiledAot>
</PropertyGroup>

<ItemGroup>
<AndroidResource Include="Icon.png">
<Link>Resources\drawable\Icon.png</Link>
</AndroidResource>
</ItemGroup>

<ItemGroup>
<PackageReference Include="Avalonia.Android" Version="11.2.2" />
<PackageReference Include="Xamarin.AndroidX.Core.SplashScreen" Version="1.0.1.13" />
<PackageReference Include="Xamarin.Essentials" Version="1.8.1" />
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\Pixed.Application\Pixed.Application.csproj" />
</ItemGroup>
</Project>
62 changes: 62 additions & 0 deletions Pixed.Android/PlatformFolder.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
using Android.Content;
using Avalonia.Platform.Storage;
using Pixed.Application.IO;
using Pixed.Application.Platform;
using System.Collections.Generic;
using System.IO;
using System.Threading.Tasks;

namespace Pixed.Android;
internal class PlatformFolder : IPlatformFolder
{
public static Context Context { get; set; }

public IStorageContainerFile Convert(IStorageFile value)
{
return new PlatformStorageContainerFile(value);
}

public async IAsyncEnumerable<IStorageContainerFile> GetFiles(FolderType folder)
{
string[] dirs = Directory.GetFiles(GetFolderPath(folder));

foreach (string dir in dirs)
{
yield return new PlatformStorageContainerFile(dir);
}
}

public Task<IStorageContainerFile> GetFile(string filename, FolderType folderType)
{
return Task.FromResult((IStorageContainerFile)new PlatformStorageContainerFile(Path.Combine(GetFolderPath(folderType), filename)));
}

public void Initialize(IStorageProvider storageProvider)
{
//Unused
}

private static string GetFolderPath(FolderType type)
{
return type switch
{
FolderType.Root => GetPixedFolder(),
FolderType.Palettes => GetPalettesFolder(),
_ => string.Empty,
};
}
private static string GetPalettesFolder()
{
return GetFolderAbsolute("Palettes");
}

private static string GetPixedFolder()
{
return GetFolderAbsolute("Pixed");
}

private static string GetFolderAbsolute(string folderName)
{
return Context.GetDir(folderName, FileCreationMode.Private).AbsolutePath;
}
}
22 changes: 22 additions & 0 deletions Pixed.Android/PlatformSettings.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
using Android.App;
using Avalonia.Controls.ApplicationLifetimes;
using Pixed.Application.Platform;
namespace Pixed.Android;
internal class PlatformSettings : IPlatformSettings
{
public static Activity MainActivity { get; internal set; }
public IApplicationLifetime ApplicationLifetime { get; set; }
public bool ExtensionsEnabled => false;
public bool RecentFilesEnabled => false;
public bool ExtensionsOnSave => true;

public void Close()
{
MainActivity?.FinishAffinity();
}

public string GetVersion()
{
return Xamarin.Essentials.VersionTracking.CurrentVersion;
}
}
29 changes: 29 additions & 0 deletions Pixed.Android/PlatformStorageContainerFile.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
using Avalonia.Platform.Storage;
using Pixed.Application.IO;
using System.IO;
using System.Threading.Tasks;

namespace Pixed.Android;
internal class PlatformStorageContainerFile(string file) : IStorageContainerFile
{
private readonly FileInfo _info = new(file);

public string Name => _info.Name;

public string Path => _info.FullName;
public string Extension => _info.Extension;

public PlatformStorageContainerFile(IStorageFile file) : this(file.Path.AbsolutePath)
{
}

public Task<StreamBase> OpenRead()
{
return Task.FromResult(StreamBase.CreateRead(_info.OpenRead()));
}

public Task<StreamBase> OpenWrite()
{
return Task.FromResult(StreamBase.CreateWrite(_info.OpenWrite()));
}
}
8 changes: 8 additions & 0 deletions Pixed.Android/Properties/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android" android:installLocation="auto" package="com.nejman.pixed" android:versionCode="17" android:versionName="1.7">
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.MANAGE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<application android:label="Pixed" android:icon="@mipmap/pixed_icon" android:theme="@style/Theme.Splash" />
</manifest>
13 changes: 13 additions & 0 deletions Pixed.Android/Resources/drawable/splash_screen.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">

<item>
<color android:color="@color/splash_background"/>
</item>

<item android:drawable="@drawable/icon"
android:width="120dp"
android:height="120dp"
android:gravity="center" />

</layer-list>
5 changes: 5 additions & 0 deletions Pixed.Android/Resources/mipmap-anydpi-v26/pixed_icon.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<adaptive-icon xmlns:android="http://schemas.android.com/apk/res/android">
<background android:drawable="@color/pixed_icon_background"/>
<foreground android:drawable="@mipmap/pixed_icon_foreground"/>
</adaptive-icon>
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<adaptive-icon xmlns:android="http://schemas.android.com/apk/res/android">
<background android:drawable="@color/pixed_icon_background"/>
<foreground android:drawable="@mipmap/pixed_icon_foreground"/>
</adaptive-icon>
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 4 additions & 0 deletions Pixed.Android/Resources/values/colors.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<color name="splash_background">#1D1D1D</color>
</resources>
4 changes: 4 additions & 0 deletions Pixed.Android/Resources/values/pixed_icon_background.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<color name="pixed_icon_background">#01579B</color>
</resources>
15 changes: 15 additions & 0 deletions Pixed.Android/Resources/values/styles.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<?xml version="1.0" encoding="utf-8" ?>
<resources xmlns:tools="http://schemas.android.com/tools">
<style name="Theme.Main" parent="@style/Theme.AppCompat.DayNight.NoActionBar">
<item name="android:windowActionBar">false</item>
<item name="android:windowBackground">@drawable/splash_screen</item>
<item name="android:windowNoTitle">true</item>
</style>
<style name="Theme.Splash" parent="Theme.SplashScreen">
<item name="windowSplashScreenBackground">@color/splash_background</item>
<item name="windowSplashScreenAnimatedIcon">@mipmap/pixed_icon</item>
<item name="windowSplashScreenAnimationDuration">100</item>
<item name="postSplashScreenTheme">@style/Theme.Main</item>
<item name="android:windowSplashScreenBehavior" tools:targetApi="33">icon_preferred</item>
</style>
</resources>
1 change: 1 addition & 0 deletions Pixed.Application/App.axaml
Original file line number Diff line number Diff line change
Expand Up @@ -21,5 +21,6 @@
<FluentTheme />
<StyleInclude Source="avares://AvaloniaProgressRing/Styles/ProgressRing.xaml"/>
<StyleInclude Source="/Styles.axaml"/>
<StyleInclude Source="avares://AvaloniaInside.Shell/Default.axaml"></StyleInclude>
</Application.Styles>
</Application>
Loading
Loading