Пример #1
0
        public list_level_1()
            : base()
        {
            SortedDictionary <string, string> dict = new SortedDictionary <string, string>();

            value_string stringValue        = value_string.Instance;
            XmlDocument  androidManifestDoc = androidManifest.Instance;

            XmlElement  nodeApplication = androidManifestDoc.GetElementsByTagName("application")[0] as XmlElement;
            XmlNodeList t = nodeApplication.GetElementsByTagName("meta-data", nodeApplication.NamespaceURI);

            XmlElement childOfApplicaiton = nodeApplication.FirstChild as XmlElement;

            while (childOfApplicaiton != null)
            {
                if (childOfApplicaiton.Name == "meta-data")
                {
                    string title = childOfApplicaiton.Attributes["android:name"].Value;
                    //remove _desc postfix
                    int index_desc = title.LastIndexOf("_desc");
                    if (-1 != index_desc)
                    {
                        title = title.Substring(0, index_desc);
                    }
                    //replace '_' in title with ' '
                    title = title.Replace('_', ' ');

                    string desc = childOfApplicaiton.Attributes["android:resource"].Value;
                    //got the real string value from strings.xml
                    if (desc.StartsWith("@string"))
                    {
                        int index_backslash = desc.LastIndexOf('/');
                        if (-1 != index_backslash)
                        {
                            desc = stringValue.getString(desc.Substring(index_backslash + 1));
                        }
                    }

                    dict.Add(title, desc);
                }
                childOfApplicaiton = childOfApplicaiton.NextSibling as XmlElement;
            }

            SortedDictionary <string, string> .Enumerator enumerator = dict.GetEnumerator();
            while (enumerator.MoveNext())
            {
                Add(new listItem(enumerator.Current.Key, enumerator.Current.Value));
            }
        }
Пример #2
0
        private void init(string clazz)
        {
            SortedDictionary <string, string> dict = new SortedDictionary <string, string>();
            value_string stringValue        = value_string.Instance;
            XmlDocument  androidManifestDoc = androidManifest.Instance;

            XmlElement  nodeApplication = androidManifestDoc.GetElementsByTagName("application")[0] as XmlElement;
            XmlNodeList t = nodeApplication.GetElementsByTagName("meta-data", nodeApplication.NamespaceURI);

            XmlElement childOfApplicaiton = nodeApplication.FirstChild as XmlElement;

            while (childOfApplicaiton != null)
            {
                if (childOfApplicaiton.Name == "activity")
                {
                    if (childOfApplicaiton.GetElementsByTagName("intent-filter").Count == 0)
                    {
                        childOfApplicaiton = childOfApplicaiton.NextSibling as XmlElement;
                        continue;
                    }

                    // test if it is a qualified 2nd entry
                    XmlElement intent_filter = childOfApplicaiton.GetElementsByTagName("intent-filter")[0] as XmlElement;
                    if (childOfApplicaiton.GetElementsByTagName("category").Count == 0)
                    {
                        childOfApplicaiton = childOfApplicaiton.NextSibling as XmlElement;
                        continue;
                    }

                    XmlElement category       = intent_filter.GetElementsByTagName("category")[0] as XmlElement;
                    string     category_value = category.Attributes["android:name"].Value;
                    if (category_value.CompareTo("android.intent.category.TEST") == 0)
                    {
                        // get which class it belongs and the title value
                        string label           = childOfApplicaiton.Attributes["android:label"].Value;
                        string title           = label;
                        int    index_backslash = label.IndexOf('/');
                        if (-1 != index_backslash)
                        {
                            string claz = label.Substring(0, index_backslash);
                            if (clazz.CompareTo(claz) != 0)
                            {
                                childOfApplicaiton = childOfApplicaiton.NextSibling as XmlElement;
                                continue;
                            }
                            title = label.Substring(index_backslash + 1);
                        }

                        // get the description
                        string      desc       = null;
                        XmlNodeList meta_datas = childOfApplicaiton.GetElementsByTagName("meta-data");
                        if (meta_datas.Count == 0)
                        {
                            desc = " ";
                        }
                        else
                        {
                            XmlElement meta_data = meta_datas[0] as XmlElement;
                            desc = meta_data.Attributes["android:resource"].Value;
                            //got the real string value from strings.xml
                            if (desc.StartsWith("@string"))
                            {
                                index_backslash = desc.LastIndexOf('/');
                                if (-1 != index_backslash)
                                {
                                    desc = stringValue.getString(desc.Substring(index_backslash + 1));
                                }
                            }
                        }

                        dict.Add(title, desc);
                    }
                }
                childOfApplicaiton = childOfApplicaiton.NextSibling as XmlElement;
            }

            SortedDictionary <string, string> .Enumerator enumerator = dict.GetEnumerator();
            while (enumerator.MoveNext())
            {
                Add(new listItem(enumerator.Current.Key, enumerator.Current.Value));
            }
        }