1. Fix for saf access

2. Fix virtual keyboard
This commit is contained in:
zhiyang7 2023-04-10 14:31:10 +08:00
parent d9440155ca
commit 4ebf03ee48
5 changed files with 20 additions and 23 deletions

View File

@ -33,8 +33,8 @@
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<AndroidUseSharedRuntime>false</AndroidUseSharedRuntime>
<AndroidLinkMode>SdkOnly</AndroidLinkMode>
<AndroidUseSharedRuntime>true</AndroidUseSharedRuntime>
<AndroidLinkMode>None</AndroidLinkMode>
<EmbedAssembliesIntoApk>True</EmbedAssembliesIntoApk>
<AndroidManagedSymbols>false</AndroidManagedSymbols>
<AndroidUseAapt2>true</AndroidUseAapt2>

View File

@ -50,7 +50,7 @@ namespace StardewModdingAPI.Mods.VirtualKeyboard
private bool ShouldTrigger(Vector2 screenPixels, SButton button)
{
if (this.ButtonRectangle.Contains(screenPixels.X * Game1.options.zoomLevel, screenPixels.Y * Game1.options.zoomLevel) && !this.Hidden && button == SButton.MouseLeft)
if (this.ButtonRectangle.Contains(screenPixels.X, screenPixels.Y) && !this.Hidden && button == SButton.MouseLeft)
{
if (!this.Hidden)
Toolbar.toolbarPressed = true;

View File

@ -1,14 +1,8 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using StardewModdingAPI;
namespace StardewModdingAPI.Mods.VirtualKeyboard
{
class ModEntry : Mod
{
public static float ZoomScale;
public override void Entry(IModHelper helper)
{
new VirtualToggle(helper, this.Monitor);

View File

@ -40,7 +40,7 @@ namespace StardewModdingAPI.Mods.VirtualKeyboard
this.IsDefault = false;
this.AutoHidden = this.ModConfig.vToggle.autoHidden;
this.VirtualToggleButton = new ClickableTextureComponent(new Rectangle(Game1.toolbarPaddingX + 64, 12, 128, 128), this.Texture, new Rectangle(0, 0, 16, 16), 5.75f, false);
this.VirtualToggleButton = new ClickableTextureComponent(new Rectangle(Game1.toolbarPaddingX + 64, 12, 128, 128), this.Texture, new Rectangle(0, 0, 16, 16), 4f, false);
helper.WriteConfig(this.ModConfig);
this.Helper.Events.Display.Rendered += this.OnRendered;
@ -126,7 +126,7 @@ namespace StardewModdingAPI.Mods.VirtualKeyboard
{
return false;
}
if (this.VirtualToggleButton.containsPoint((int)(screenPixels.X * Game1.options.zoomLevel), (int)(screenPixels.Y * Game1.options.zoomLevel)))
if (this.VirtualToggleButton.containsPoint((int)screenPixels.X, (int)screenPixels.Y))
{
this.LastPressTick = tick;
Toolbar.toolbarPressed = true;

View File

@ -18,6 +18,7 @@ using File = Java.IO.File;
using Newtonsoft.Json;
using Java.Lang;
using Java.Util;
using StardewModdingAPI.Mobile;
using Bundle = Android.OS.Bundle;
using Exception = System.Exception;
using Thread = System.Threading.Thread;
@ -31,7 +32,7 @@ namespace StardewModdingAPI
public static SMainActivity Instance;
private System.Action _callback;
private Action _callback;
private static bool ErrorDetected;
private static bool Migrating = false;
@ -39,12 +40,14 @@ namespace StardewModdingAPI
protected override void OnCreate(Bundle bundle)
{
MainActivity.instance = this;
base.RequestWindowFeature(WindowFeatures.NoTitle);
this.RequestWindowFeature(WindowFeatures.NoTitle);
if (Build.VERSION.SdkInt >= BuildVersionCodes.P) this.Window.Attributes.LayoutInDisplayCutoutMode = LayoutInDisplayCutoutMode.ShortEdges;
this.Window.SetFlags(WindowManagerFlags.Fullscreen, WindowManagerFlags.Fullscreen);
this.Window.SetFlags(WindowManagerFlags.KeepScreenOn, WindowManagerFlags.KeepScreenOn);
// FarmMigrationPatch.Apply();
SMainActivity.Instance = this;
try
{
@ -101,10 +104,10 @@ namespace StardewModdingAPI
if (string.IsNullOrWhiteSpace(modPath)) modPath = "Mods";
this.core = new SCore(System.IO.Path.Combine(EarlyConstants.StardewValleyBasePath, modPath), false, false);
this.core = new SCore(Path.Combine(EarlyConstants.StardewValleyBasePath, modPath), false, false);
this.core.RunInteractively();
Type.GetType("StardewValley.Mobile.MobileDisplay")?.GetMethod("SetupDisplaySettings", BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic)?.Invoke(null, Array.Empty<object>());
typeof(MailActivity).Assembly.GetType("StardewValley.Mobile.MobileDisplay")?.GetMethod("SetupDisplaySettings", BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic)?.Invoke(null, Array.Empty<object>());
typeof(MainActivity).GetMethod("SetZoomScaleAndMenuButtonScale", BindingFlags.Instance | BindingFlags.NonPublic)?.Invoke(this, Array.Empty<object>());
this.SetPaddingForMenus();
@ -140,11 +143,11 @@ namespace StardewModdingAPI
public bool CheckSMAPIMigration()
{
string storagePath = this.GetExternalFilesDir(null).AbsolutePath;
if (Migrating) return false;
if (SMainActivity.Migrating) return false;
if (Directory.Exists(storagePath + "/smapi-internal"))
return true;
Migrating = true;
SMainActivity.Migrating = true;
SAlertDialogUtil.AlertMessage($"SMAPI needs to locate StardewValley folder's content to continue", "Confirm",
callback: type => { this.ShowMigrationPicker(); });
return false;
@ -155,7 +158,7 @@ namespace StardewModdingAPI
base.OnActivityResult(requestCode, resultCode, data);
if (requestCode != 1235)
return;
this.RunOnUiThread((System.Action)(() =>
this.RunOnUiThread((Action)(() =>
{
if (resultCode == Result.Ok)
this.CopySMAPIData(data.Data);
@ -173,7 +176,7 @@ namespace StardewModdingAPI
Android.Content.Context context = Application.Context;
string storagePath = context.GetExternalFilesDir(null).AbsolutePath;
this.Window.SetFlags(WindowManagerFlags.NotTouchable, WindowManagerFlags.NotTouchable);
System.Action ContinueGame = () =>
Action ContinueGame = () =>
{
this.Window.ClearFlags(WindowManagerFlags.NotTouchable);
this.IsDoingStorageMigration = false;
@ -205,7 +208,7 @@ namespace StardewModdingAPI
}
}
}
catch (System.Exception ex)
catch (Exception ex)
{
string exMessage = ex.Message;
}
@ -227,7 +230,7 @@ namespace StardewModdingAPI
{
string str = Path.Combine(dest, listFile.Name);
if (!System.IO.File.Exists(str))
DirectoryCopy(listFile, str);
SMainActivity.DirectoryCopy(listFile, str);
}
}
else
@ -243,7 +246,7 @@ namespace StardewModdingAPI
}
}
public new void PromptForPermissionsIfNecessary(System.Action callback = null)
public new void PromptForPermissionsIfNecessary(Action callback = null)
{
if (this.HasPermissions)
{