Skip to content
This repository has been archived by the owner on May 1, 2024. It is now read-only.

Embed templates #9225

Merged
merged 6 commits into from Jan 23, 2020
Merged

Embed templates #9225

merged 6 commits into from Jan 23, 2020

Conversation

PureWeen
Copy link
Contributor

@PureWeen PureWeen commented Jan 15, 2020

Description of Change

Account for edge cases where the android head project has zero transitive support library references but is still utilizing the defaults forms layouts

Testing Procedure

Create a Xamarin.Forms application from the template

  • install this nuget
  • Update Android to target MonoAndroid 10.0 and deploy (no crash?)
  • Remove Essentials - no crash and a helpful warning about updating your templates
  • just delete the tablayout and tabbar from the template - no crash

PR Checklist

  • Targets the correct branch
  • Tests are passing (or failures are unrelated)

AToolbar bar = null;

#if __ANDROID_29__
if (ToolbarResource == 0)
Copy link
Contributor Author

@PureWeen PureWeen Jan 15, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If you're using API 29 and these Ids are zero then just set them using the internal layout ids.

The one breaking change from this will be if

  • users update to androidx
  • have no transitive libraries
  • they've customized the head project layouts to be different than the forms templates
  • In which case they should get the error message below

ie.Message == "Binary XML file line #1: Error inflating class android.support.v7.widget.Toolbar" &&
this.TargetSdkVersion() >= 29)
{
Internals.Log.Warning(nameof(FormsAppCompatActivity),
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If inflation fails and all the above criteria then output a message explaining how to upgrade the templates to Android X or just inform the user that they can delete the layouts all together


if (ToolbarResource == 0)
{
ToolbarResource = Resource.Layout.FallbackToolbarDoNotUse;
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fall back to some AndroidX templates that haven't been replaced by the project head

@PureWeen PureWeen marked this pull request as ready for review January 15, 2020 22:42
@PureWeen PureWeen added the DO-NOT-MERGE-!!! 🛑 This is in progress and needs to be updated before it can be merged. label Jan 16, 2020
@PureWeen PureWeen removed the DO-NOT-MERGE-!!! 🛑 This is in progress and needs to be updated before it can be merged. label Jan 16, 2020
@samhouts samhouts self-assigned this Jan 21, 2020
@PureWeen PureWeen added the blocker Issue blocks next stable release. Prioritize fixing and reviewing this issue. label Jan 22, 2020
@PureWeen PureWeen added this to the 4.5.0 milestone Jan 22, 2020
@PureWeen PureWeen added this to To do in v4.5.0 via automation Jan 22, 2020
Copy link
Member

@rmarinho rmarinho left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tested API 28 and API29 with and without the TabBar resources

@rmarinho rmarinho merged commit 555a662 into 4.5.0 Jan 23, 2020
v4.5.0 automation moved this from To do to Done Jan 23, 2020
@samhouts samhouts added the approved Has two approvals, no pending reviews, and no changes requested label Jan 24, 2020
@PureWeen PureWeen deleted the embed_templates branch February 5, 2020 18:42
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
approved Has two approvals, no pending reviews, and no changes requested blocker Issue blocks next stable release. Prioritize fixing and reviewing this issue. p/Android
Projects
No open projects
v4.5.0
  
Done
Development

Successfully merging this pull request may close these issues.

None yet

3 participants