]> git.tdb.fi Git - builder.git/commitdiff
Add support for the orientation tag in Android manifest
authorMikko Rasa <tdb@tdb.fi>
Sun, 9 Feb 2020 20:30:54 +0000 (22:30 +0200)
committerMikko Rasa <tdb@tdb.fi>
Sun, 9 Feb 2020 20:30:54 +0000 (22:30 +0200)
source/androidapplicationcomponent.cpp
source/androidapplicationcomponent.h
source/androidmanifestfile.cpp
source/androidmanifestfile.h
source/androidmanifestgenerator.cpp

index 85873d4024ab46b14f51c6e05196354eb7fed4ff..99f14408d8e05ebe6d6c50e9348c3a956433a5c8 100644 (file)
@@ -29,6 +29,7 @@ void AndroidApplicationComponent::create_targets() const
                                contents.push_back(inst->get_real_target());
 
        AndroidManifestFile *manifest = new AndroidManifestFile(builder, *this);
+       manifest->set_orientation(orientation);
        for(set<string>::const_iterator i=permissions.begin(); i!=permissions.end(); ++i)
                manifest->add_permission(*i);
 
@@ -84,6 +85,7 @@ void AndroidApplicationComponent::create_targets() const
 AndroidApplicationComponent::Loader::Loader(AndroidApplicationComponent &c):
        DataFile::DerivedObjectLoader<AndroidApplicationComponent, Component::Loader>(c)
 {
+       add("orientation", &AndroidApplicationComponent::orientation);
        add("permission", &Loader::permission);
 }
 
index 35984ea31f809e48d807634f449b0f41b0c72c8e..af465e50cabc2ece4f9ad4f43ceeaa37abfddcb8 100644 (file)
@@ -17,6 +17,7 @@ public:
        };
 
 private:
+       std::string orientation;
        std::set<std::string> permissions;
 
 public:
index 1653e0a2afda80b8b1152f3cfa1f2bb10b33043d..d20be983167cd7e6e492e786c67443e2e542a86f 100644 (file)
@@ -20,6 +20,11 @@ void AndroidManifestFile::set_native_library(SharedLibrary *lib)
        native_lib = lib;
 }
 
+void AndroidManifestFile::set_orientation(const string &ori)
+{
+       orientation = ori;
+}
+
 void AndroidManifestFile::add_permission(const string &perm)
 {
        permissions.insert(perm);
index 0dc77926ceeb76393b5e147fb3335477b2c1a912..8bd5fe3803f7468894ae6229b82b70e502ded002 100644 (file)
@@ -15,6 +15,7 @@ class AndroidManifestFile: public FileTarget
 private:
        SharedLibrary *native_lib;
        std::set<std::string> permissions;
+       std::string orientation;
 
 public:
        AndroidManifestFile(Builder &, const AndroidApplicationComponent &);
@@ -25,7 +26,9 @@ public:
        SharedLibrary *get_native_library() const { return native_lib; }
 
        void add_permission(const std::string &);
+       void set_orientation(const std::string &);
        const std::set<std::string> &get_permissions() const { return permissions; }
+       const std::string &get_orientation() const { return orientation; }
 };
 
 #endif
index 156dfb35fd9abcdbca33710c5ce4f70b2edf71a0..a7cda0428dea4ce95954fbccd1cb2ca6ea347358 100644 (file)
@@ -47,7 +47,11 @@ void AndroidManifestGenerator::Worker::main()
        IO::print(out, "\t<application android:icon=\"@drawable/icon\" android:label=\"%s\" android:hasCode=\"false\" android:debuggable=\"%s\">\n", pkg.get_label(), debuggable);
        if(SharedLibrary *native_lib = manifest.get_native_library())
        {
-               out.write("\t\t<activity android:name=\"android.app.NativeActivity\">\n");
+               out.write("\t\t<activity android:name=\"android.app.NativeActivity\"");
+               const string &orientation = manifest.get_orientation();
+               if(!orientation.empty())
+                       IO::print(out, " android:screenOrientation=\"%s\"", orientation);
+               out.write(">\n");
                IO::print(out, "\t\t\t<meta-data android:name=\"android.app.lib_name\" android:value=\"%s\" />\n", native_lib->get_libname());
                out.write("\t\t\t<intent-filter>\n");
                out.write("\t\t\t\t<action android:name=\"android.intent.action.MAIN\" />\n");