Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Xamarin.Android.Build.Tasks] Add 'transition' and 'array' support #2014

Merged
merged 3 commits into from
Jul 31, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@ static Resource()
public partial class Animator
{

// aapt resource value: 0x7F030002
public const int slide_in_bottom = 2130903042;
// aapt resource value: 0x7F040002
public const int slide_in_bottom = 2130968578;

static Animator()
{
Expand All @@ -40,11 +40,27 @@ private Animator()
}
}

public partial class Array
{

// aapt resource value: 0x7F110002
public const int widths_array = 2131820546;

static Array()
{
global::Android.Runtime.ResourceIdManager.UpdateIdValues();
}

private Array()
{
}
}

public partial class Dimension
{

// aapt resource value: 0x7F090002
public const int main_text_item_size = 2131296258;
// aapt resource value: 0x7F100002
public const int main_text_item_size = 2131755010;

static Dimension()
{
Expand All @@ -59,8 +75,8 @@ private Dimension()
public partial class Drawable
{

// aapt resource value: 0x7F040002
public const int ic_menu_preferences = 2130968578;
// aapt resource value: 0x7F050002
public const int ic_menu_preferences = 2131034114;

static Drawable()
{
Expand All @@ -75,8 +91,8 @@ private Drawable()
public partial class Font
{

// aapt resource value: 0x7F050002
public const int arial = 2131034114;
// aapt resource value: 0x7F060002
public const int arial = 2131099650;

static Font()
{
Expand All @@ -91,8 +107,8 @@ private Font()
public partial class Id
{

// aapt resource value: 0x7F060002
public const int menu_settings = 2131099650;
// aapt resource value: 0x7F070002
public const int menu_settings = 2131165186;

static Id()
{
Expand All @@ -107,8 +123,8 @@ private Id()
public partial class Menu
{

// aapt resource value: 0x7F070002
public const int Options = 2131165186;
// aapt resource value: 0x7F080002
public const int Options = 2131230722;

static Menu()
{
Expand All @@ -123,8 +139,8 @@ private Menu()
public partial class Mipmap
{

// aapt resource value: 0x7F080002
public const int icon = 2131230722;
// aapt resource value: 0x7F090002
public const int icon = 2131296258;

static Mipmap()
{
Expand All @@ -139,8 +155,8 @@ private Mipmap()
public partial class Plurals
{

// aapt resource value: 0x7F020002
public const int num_locations_reported = 2130837506;
// aapt resource value: 0x7F030002
public const int num_locations_reported = 2130903042;

static Plurals()
{
Expand All @@ -155,17 +171,17 @@ private Plurals()
public partial class String
{

// aapt resource value: 0x7F010003
public const int app_name = 2130771971;
// aapt resource value: 0x7F020003
public const int app_name = 2130837507;

// aapt resource value: 0x7F010005
public const int foo = 2130771973;
// aapt resource value: 0x7F020005
public const int foo = 2130837509;

// aapt resource value: 0x7F010002
public const int hello = 2130771970;
// aapt resource value: 0x7F020002
public const int hello = 2130837506;

// aapt resource value: 0x7F010004
public const int menu_settings = 2130771972;
// aapt resource value: 0x7F020004
public const int menu_settings = 2130837508;

static String()
{
Expand All @@ -176,6 +192,22 @@ private String()
{
}
}

public partial class Transition
{

// aapt resource value: 0x7F010002
public const int transition = 2130771970;

static Transition()
{
global::Android.Runtime.ResourceIdManager.UpdateIdValues();
}

private Transition()
{
}
}
}
}
#pragma warning restore 1591
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,13 @@ public class ManagedResourceParserTests : BaseTest {
const string StringsXml2 = @"<?xml version=""1.0"" encoding=""utf-8""?>
<resources>
<string name = ""foo"" > Hello World, Click Me!</string>
<string-array name=""widths_array"">
<item>Thin</item>
<item>Thinish</item>
<item>Medium</item>
<item>Thickish</item>
<item>Thick</item>
</string-array>
</resources>
";
const string Menu = @"<menu xmlns:android=""http://schemas.android.com/apk/res/android"">
Expand All @@ -54,13 +61,22 @@ public class ManagedResourceParserTests : BaseTest {
<dimen name=""main_text_item_size"">17dp</dimen>
</resources>";

const string Transition = @"<?xml version=""1.0"" encoding=""utf-8""?>
<changeBounds
xmlns:android=""http://schemas.android.com/apk/res/android""
android:duration=""5000""
android:interpolator=""@android:anim/overshoot_interpolator"" />
";

[Test]
public void GenerateDesignerFile ()
{
var path = Path.Combine ("temp", TestName);
Directory.CreateDirectory (Path.Combine (Root, path, "res", "values"));
Directory.CreateDirectory (Path.Combine (Root, path, "res", "transition"));

File.WriteAllText (Path.Combine (Root, path, "res", "values", "strings.xml"), StringsXml);
File.WriteAllText (Path.Combine (Root, path, "res", "transition", "transition.xml"), Transition);

Directory.CreateDirectory (Path.Combine (Root, path, "lp", "res", "animator"));
Directory.CreateDirectory (Path.Combine (Root, path, "lp", "res", "font"));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ namespace Xamarin.Android.Tasks
class ManagedResourceParser : ResourceParser
{
CodeTypeDeclaration resources;
CodeTypeDeclaration layout, ids, drawable, strings, colors, dimension, raw, animator, animation, attrib, boolean, font, ints, interpolators, menu, mipmaps, plurals, styleable, style, arrays, xml;
CodeTypeDeclaration layout, ids, drawable, strings, colors, dimension, raw, animator, animation, attrib, boolean, font, ints, interpolators, menu, mipmaps, plurals, styleable, style, arrays, xml, transition;
Dictionary<string, string> map;
bool app;
List<CodeTypeDeclaration> declarationIds = new List<CodeTypeDeclaration> ();
Expand Down Expand Up @@ -56,6 +56,7 @@ public CodeTypeDeclaration Parse (string resourceDirectory, IEnumerable<string>
plurals = CreateClass ("Plurals");
styleable = CreateClass ("Styleable");
style = CreateClass ("Style");
transition = CreateClass ("Transition");
xml = CreateClass ("Xml");

// This top most R.txt will contain EVERYTHING we need. including library resources since it represents
Expand Down Expand Up @@ -103,6 +104,7 @@ public CodeTypeDeclaration Parse (string resourceDirectory, IEnumerable<string>
SortMembers (strings);
SortMembers (style);
SortMembers (styleable);
SortMembers (transition);
SortMembers (xml);


Expand Down Expand Up @@ -146,6 +148,8 @@ public CodeTypeDeclaration Parse (string resourceDirectory, IEnumerable<string>
resources.Members.Add (style);
if (styleable.Members.Count > 1)
resources.Members.Add (styleable);
if (transition.Members.Count > 1)
resources.Members.Add (transition);
if (xml.Members.Count > 1)
resources.Members.Add (xml);

Expand All @@ -169,6 +173,9 @@ void ProcessRtxtFile (string file)
case "attr":
CreateIntField (attrib, itemName, value);
break;
case "array":
CreateIntField (arrays, itemName, value);
break;
case "bool":
CreateIntField (boolean, itemName, value);
break;
Expand Down Expand Up @@ -225,6 +232,9 @@ void ProcessRtxtFile (string file)
break;
}
break;
case "transition":
CreateIntField (transition, itemName, value);
break;
case "xml":
CreateIntField (xml, itemName, value);
break;
Expand Down Expand Up @@ -429,6 +439,9 @@ void CreateResourceField (string root, string fieldName, XmlReader element = nul
case "style":
CreateIntField (style, fieldName.Replace (".", "_"));
break;
case "transition":
CreateIntField (transition, fieldName);
break;
case "xml":
CreateIntField (xml, fieldName);
break;
Expand Down