private void OnAddPermissionClick(string permission)
        {
            AMM_PropertyTemplate property = new AMM_PropertyTemplate("uses-permission");

            property.SetValue("android:name", permission);
            AMM_Manager.GetManifest().AddPermission(property);
        }
        private void SelectPermission(object data)
        {
            AMM_PropertyTemplate newPermission = new AMM_PropertyTemplate("uses-permission");

            newPermission.SetValue("android:name", data.ToString());
            AMM_Manager.GetManifest().AddPermission(newPermission);
        }
Esempio n. 3
0
        private void OnAddActivityClick(string activityName)
        {
            AMM_ActivityTemplate newActivity = new AMM_ActivityTemplate(false, activityName);

            newActivity.SetValue("android:name", activityName);
            newActivity.IsOpen = true;
            AMM_Manager.GetManifest().ApplicationTemplate.AddActivity(newActivity);
        }
 private void PermissionsList()
 {
     foreach (AMM_PropertyTemplate permission in AMM_Manager.GetManifest().Permissions)
     {
         EditorGUILayout.BeginHorizontal(GUI.skin.box);
         EditorGUILayout.LabelField(permission.Values["android:name"]);
         if (GUILayout.Button("X", EditorStyles.miniButton, GUILayout.Width(20.0f)))
         {
             AMM_Manager.GetManifest().RemovePermission(permission);
             return;
         }
         EditorGUILayout.EndHorizontal();
     }
 }
Esempio n. 5
0
        private void Properties()
        {
            AMM_SettingsWindow.DrawProperties(AMM_Manager.GetManifest().ApplicationTemplate);

            EditorGUILayout.BeginHorizontal();
            EditorGUILayout.Space();
            if (GUILayout.Button("Add Property", GUILayout.Width(100.0f)))
            {
                AMM_SettingsWindow.AddPropertyDialog(AMM_Manager.GetManifest().ApplicationTemplate);
            }

            EditorGUILayout.EndHorizontal();

            EditorGUILayout.Space();
        }
        public override void OnGUI()
        {
            if (AMM_Manager.GetManifest().Permissions.Count > 0)
            {
                using (new SA_WindowBlockWithSpace(new GUIContent("Permissions"))) {
                    PermissionsList();
                    EditorGUILayout.Space();
                }
            }



            using (new SA_WindowBlockWithSpace(new GUIContent("Actions"))) {
                Actions();
                EditorGUILayout.Space();
            }
        }
Esempio n. 7
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();
            }
        }
Esempio n. 8
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();
        }
Esempio n. 10
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
        }
Esempio n. 11
0
        private void Activities()
        {
            int launcherActivities = 0;

            foreach (int id in AMM_Manager.GetManifest().ApplicationTemplate.Activities.Keys)
            {
                AMM_ActivityTemplate activity = AMM_Manager.GetManifest().ApplicationTemplate.Activities[id];

                if (activity.IsLauncher)
                {
                    launcherActivities++;
                }

                EditorGUILayout.BeginVertical(GUI.skin.box);
                EditorGUILayout.BeginHorizontal();
                activity.IsOpen = EditorGUILayout.Foldout(activity.IsOpen, activity.Name);
                if (GUILayout.Button("X", EditorStyles.miniButton, GUILayout.Width(20.0f)))
                {
                    AMM_Manager.GetManifest().ApplicationTemplate.RemoveActivity(activity);
                    return;
                }
                EditorGUILayout.EndHorizontal();

                if (activity.IsOpen)
                {
                    EditorGUILayout.BeginVertical();

                    bool isLauncher = activity.IsLauncher;
                    EditorGUI.BeginChangeCheck();
                    isLauncher = EditorGUILayout.Toggle("Is Launcher", activity.IsLauncher);
                    if (EditorGUI.EndChangeCheck())
                    {
                        activity.SetAsLauncher(isLauncher);
                    }

                    foreach (string k in activity.Values.Keys)
                    {
                        EditorGUILayout.BeginHorizontal();

                        EditorGUILayout.LabelField(k);
                        EditorGUILayout.Space();

                        string input = activity.Values[k];
                        EditorGUI.BeginChangeCheck();

                        if (k.Equals("android:name"))
                        {
                            input = EditorGUILayout.TextField(activity.Values[k]);
                        }
                        else
                        {
                            input = EditorGUILayout.TextField(activity.Values[k]);
                        }

                        if (EditorGUI.EndChangeCheck())
                        {
                            activity.SetValue(k, input);
                            return;
                        }

                        if (!k.Equals("android:name"))
                        {
                            if (GUILayout.Button("X", EditorStyles.miniButton, GUILayout.Width(20.0f)))
                            {
                                activity.RemoveValue(k);
                                return;
                            }
                        }

                        EditorGUILayout.EndHorizontal();
                        EditorGUILayout.Space();
                    }

                    AMM_SettingsWindow.DrawProperties(activity);

                    EditorGUILayout.BeginHorizontal();
                    EditorGUILayout.Space();
                    if (GUILayout.Button("Add Value", GUILayout.Width(100.0f)))
                    {
                        AMM_SettingsWindow.AddValueDialog(activity);
                    }
                    if (GUILayout.Button("Add Property", GUILayout.Width(100.0f)))
                    {
                        AMM_SettingsWindow.AddPropertyDialog(activity);
                    }

                    EditorGUILayout.EndHorizontal();
                    EditorGUILayout.Space();

                    EditorGUILayout.EndVertical();
                }
                EditorGUILayout.EndVertical();
            }

            EditorGUILayout.BeginHorizontal();
            EditorGUILayout.Space();
            if (GUILayout.Button("Add Activity", GUILayout.Width(100.0f)))
            {
                AMM_AddPermissionDialog dlg = EditorWindow.CreateInstance <AMM_AddPermissionDialog>();
                dlg.onAddClick += OnAddActivityClick;

                dlg.titleContent.text = "Add Activity";
                dlg.ShowAuxWindow();
            }
            EditorGUILayout.EndHorizontal();

            if (launcherActivities > 1)
            {
                EditorGUILayout.HelpBox("There is MORE THAN ONE Launcher Activity in Manifest", MessageType.Warning);
            }
            else if (launcherActivities < 1)
            {
                EditorGUILayout.HelpBox("There is NO Launcher Activities in Manifest", MessageType.Warning);
            }
        }