Merge branch 'android-orientation' of https://github.com/Tryibion/FlaxEngine into Tryibion-android-orientation

This commit is contained in:
Wojtek Figat
2023-12-11 17:34:47 +01:00
3 changed files with 63 additions and 1 deletions

View File

@@ -169,6 +169,30 @@ bool AndroidPlatformTools::OnPostProcess(CookingData& data)
permissions += String::Format(TEXT("\n <uses-permission android:name=\"{0}\" />"), e.Item);
}
// Setup default Android screen orientation
auto defaultOrienation = platformSettings->DefaultOrientation;
String orientation = String("fullSensor");
switch (defaultOrienation)
{
case AndroidPlatformSettings::ScreenOrientation::Portrait:
orientation = String("portrait");
break;
case AndroidPlatformSettings::ScreenOrientation::PortraitReverse:
orientation = String("reversePortrait");
break;
case AndroidPlatformSettings::ScreenOrientation::LandscapeRight:
orientation = String("landscape");
break;
case AndroidPlatformSettings::ScreenOrientation::LandscapeLeft:
orientation = String("reverseLandscape");
break;
case AndroidPlatformSettings::ScreenOrientation::AutoRotation:
orientation = String("fullSensor");
break;
default:
break;
}
// Setup Android application attributes
String attributes;
if (data.Configuration != BuildConfiguration::Release)
@@ -223,6 +247,7 @@ bool AndroidPlatformTools::OnPostProcess(CookingData& data)
EditorUtilities::ReplaceInFile(manifestPath, TEXT("${PackageName}"), packageName);
EditorUtilities::ReplaceInFile(manifestPath, TEXT("${ProjectVersion}"), projectVersion);
EditorUtilities::ReplaceInFile(manifestPath, TEXT("${AndroidPermissions}"), permissions);
EditorUtilities::ReplaceInFile(manifestPath, TEXT("${DefaultOrientation}"), orientation);
EditorUtilities::ReplaceInFile(manifestPath, TEXT("${AndroidAttributes}"), attributes);
const String stringsPath = data.OriginalOutputPath / TEXT("app/src/main/res/values/strings.xml");
EditorUtilities::ReplaceInFile(stringsPath, TEXT("${ProjectName}"), gameSettings->ProductName);

View File

@@ -17,6 +17,37 @@ API_CLASS(sealed, Namespace="FlaxEditor.Content.Settings") class FLAXENGINE_API
DECLARE_SCRIPTING_TYPE_MINIMAL(AndroidPlatformSettings);
API_AUTO_SERIALIZATION();
/// <summary>
/// Android screen orientation options.
/// </summary>
API_ENUM() enum class FLAXENGINE_API ScreenOrientation
{
/// <summary>
/// "portrait" mode
/// </summary>
Portrait,
/// <summary>
/// "reversePortrait" mode
/// </summary>
PortraitReverse,
/// <summary>
/// "landscape" mode
/// </summary>
LandscapeRight,
/// <summary>
/// "reverseLandscape" mode
/// </summary>
LandscapeLeft,
/// <summary>
/// "fullSensor" mode
/// </summary>
AutoRotation,
};
/// <summary>
/// The application package name (eg. com.company.product). Custom tokens: ${PROJECT_NAME}, ${COMPANY_NAME}.
/// </summary>
@@ -29,6 +60,12 @@ API_CLASS(sealed, Namespace="FlaxEditor.Content.Settings") class FLAXENGINE_API
API_FIELD(Attributes="EditorOrder(100), EditorDisplay(\"General\")")
Array<String> Permissions;
/// <summary>
/// The default screen orientation.
/// </summary>
API_FIELD(Attributes = "EditorOrder(110), EditorDisplay(\"General\")")
ScreenOrientation DefaultOrientation = ScreenOrientation::AutoRotation;
/// <summary>
/// Custom icon texture to use for the application (overrides the default one).
/// </summary>

View File

@@ -10,7 +10,7 @@
<activity android:name="com.flaxengine.GameActivity"
android:label="@string/app_name"
android:configChanges="orientation|keyboardHidden|screenSize"
android:screenOrientation="fullSensor">
android:screenOrientation="${DefaultOrientation}">
<meta-data android:name="android.app.lib_name" android:value="FlaxGame" />
<intent-filter>
<action android:name="android.intent.action.MAIN" />