예제 #1
0
        protected override void OnTabsGUI(int tabIndex)
        {
            if (tabIndex == 3)
            {
                base.OnTabsGUI(tabIndex);
                return;
            }

            AMM_Template manifest = AMM_Manager.GetManifest();

            if (manifest == null)
            {
                EditorGUILayout.HelpBox("The selected build platform DOESN'T support AndroidManifest.xml file", MessageType.Info);
                return;
            }

            base.OnTabsGUI(tabIndex);
            EditorGUILayout.Space();
            if (GUILayout.Button("Save Manifest", GUILayout.Height(22.0f)))
            {
                AMM_Manager.SaveManifest();
            }
        }
예제 #2
0
        private void Values()
        {
            AMM_Template manifest = AMM_Manager.GetManifest();

            foreach (string key in manifest.ApplicationTemplate.Values.Keys)
            {
                EditorGUILayout.BeginHorizontal();

                EditorGUILayout.LabelField(key);

                string input = AMM_Manager.GetManifest().ApplicationTemplate.Values[key];
                EditorGUI.BeginChangeCheck();
                input = EditorGUILayout.TextField(AMM_Manager.GetManifest().ApplicationTemplate.Values[key]);
                if (EditorGUI.EndChangeCheck())
                {
                    AMM_Manager.GetManifest().ApplicationTemplate.SetValue(key, input);
                    return;
                }

                if (GUILayout.Button("X", EditorStyles.miniButton, GUILayout.Width(20.0f)))
                {
                    AMM_Manager.GetManifest().ApplicationTemplate.RemoveValue(key);
                    return;
                }

                EditorGUILayout.EndHorizontal();
            }

            EditorGUILayout.BeginHorizontal();
            EditorGUILayout.Space();
            if (GUILayout.Button("Add Value", GUILayout.Width(100.0f)))
            {
                AMM_SettingsWindow.AddValueDialog(AMM_Manager.GetManifest().ApplicationTemplate);
            }
            EditorGUILayout.EndHorizontal();
        }
        public override void OnGUI()
        {
            AMM_Template manifest = AMM_Manager.GetManifest();

            using (new SA_WindowBlockWithIndent(new GUIContent("Values"))) {
                foreach (string key in manifest.Values.Keys)
                {
                    using (new SA_GuiBeginHorizontal()) {
                        EditorGUILayout.LabelField(key);
                        if (key.Equals("xmlns:android") ||
                            key.Equals("android:installLocation") ||
                            key.Equals("package") ||
                            key.Equals("android:versionName") ||
                            key.Equals("android:versionCode") ||
                            key.Equals("android:theme"))
                        {
                            GUI.enabled = false;
                            EditorGUILayout.TextField(AMM_Manager.GetManifest().Values[key]);
                        }
                        else
                        {
                            GUI.enabled = true;

                            string input = AMM_Manager.GetManifest().Values[key];
                            EditorGUI.BeginChangeCheck();
                            input = GUILayout.TextField(AMM_Manager.GetManifest().Values[key]);
                            if (EditorGUI.EndChangeCheck())
                            {
                                AMM_Manager.GetManifest().SetValue(key, input);
                                return;
                            }

                            if (GUILayout.Button("X", GUILayout.Width(20.0f)))
                            {
                                AMM_Manager.GetManifest().RemoveValue(key);
                                return;
                            }
                        }
                    }
                    GUI.enabled = true;
                }


                EditorGUILayout.BeginHorizontal();
                EditorGUILayout.Space();
                if (GUILayout.Button("Add Value", GUILayout.Width(100.0f)))
                {
                    AMM_SettingsWindow.AddValueDialog(AMM_Manager.GetManifest());
                }
                EditorGUILayout.EndHorizontal();
                EditorGUILayout.Space();
            }



            using (new SA_WindowBlockWithIndent(new GUIContent("Properties"))) {
                AMM_SettingsWindow.DrawProperties(AMM_Manager.GetManifest());
                EditorGUILayout.BeginHorizontal();
                EditorGUILayout.Space();
                if (GUILayout.Button("Add Property", GUILayout.Width(100.0f)))
                {
                    AMM_SettingsWindow.AddPropertyDialog(AMM_Manager.GetManifest());
                }
                EditorGUILayout.EndHorizontal();
                EditorGUILayout.Space();
            }
            EditorGUILayout.Space();
        }
예제 #4
0
        private void ReadManifest(string manifestPath)
        {
            m_template = new AMM_Template();


            if (!SA_AssetDatabase.IsFileExists(manifestPath))
            {
                return;
            }

#if !(UNITY_WP8 || UNITY_METRO)
            //Read XML file
            XmlDocument doc = new XmlDocument();
            doc.Load(SA_PathUtil.ConvertRelativeToAbsolutePath(manifestPath));
            XmlNode rootNode = doc.DocumentElement;

            foreach (XmlAttribute attr in rootNode.Attributes)
            {
                m_template.SetValue(attr.Name, attr.Value);
            }

            foreach (XmlNode childNode in rootNode.ChildNodes)
            {
                if (!childNode.Name.Equals("application") &&
                    !childNode.Name.Equals("uses-permission") &&
                    !childNode.Name.Equals("#comment"))
                {
                    m_template.AddProperty(childNode.Name, AMM_Manager.ParseProperty(childNode));
                }
            }

            XmlNode applicationNode = null;
            foreach (XmlNode childNode in rootNode.ChildNodes)
            {
                if (childNode.Name.Equals("application"))
                {
                    applicationNode = childNode;
                    break;
                }
            }

            foreach (XmlAttribute attr in applicationNode.Attributes)
            {
                m_template.ApplicationTemplate.SetValue(attr.Name, attr.Value);
            }
            foreach (XmlNode childNode in applicationNode.ChildNodes)
            {
                if (!childNode.Name.Equals("#comment") &&
                    !childNode.Name.Equals("activity"))
                {
                    m_template.ApplicationTemplate.AddProperty(childNode.Name, AMM_Manager.ParseProperty(childNode));
                }
            }

            foreach (XmlNode childNode in applicationNode.ChildNodes)
            {
                if (childNode.Name.Equals("activity") &&
                    !childNode.Name.Equals("#comment"))
                {
                    string activityName = "";
                    if (childNode.Attributes["android:name"] != null)
                    {
                        activityName = childNode.Attributes["android:name"].Value;
                    }
                    else
                    {
                        Debug.LogWarning("Android Manifest contains activity tag without android:name attribute.");
                    }

                    XmlNode launcher   = null;
                    bool    isLauncher = false;
                    foreach (XmlNode actNode in childNode.ChildNodes)
                    {
                        if (actNode.Name.Equals("intent-filter"))
                        {
                            foreach (XmlNode intentNode in actNode.ChildNodes)
                            {
                                if (intentNode.Name.Equals("category"))
                                {
                                    if (intentNode.Attributes["android:name"].Value.Equals("android.intent.category.LAUNCHER"))
                                    {
                                        isLauncher = true;
                                        launcher   = actNode;
                                    }
                                }
                            }
                        }
                    }

                    AMM_ActivityTemplate activity = new AMM_ActivityTemplate(isLauncher, activityName);
                    foreach (XmlAttribute attr in childNode.Attributes)
                    {
                        activity.SetValue(attr.Name, attr.Value);
                    }

                    foreach (XmlNode actNode in childNode.ChildNodes)
                    {
                        if (!actNode.Name.Equals("#comment"))
                        {
                            if (actNode != launcher)
                            {
                                activity.AddProperty(actNode.Name, AMM_Manager.ParseProperty(actNode));
                            }
                        }
                    }

                    m_template.ApplicationTemplate.AddActivity(activity);
                }
            }

            //Load Manifest Permissions
            foreach (XmlNode node in rootNode.ChildNodes)
            {
                if (node.Name.Equals("uses-permission"))
                {
                    AMM_PropertyTemplate permission = new AMM_PropertyTemplate("uses-permission");
                    permission.SetValue("android:name", node.Attributes["android:name"].Value);
                    m_template.AddPermission(permission);
                }
            }
#endif
        }