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

[Android] Fix NavigationPage.BarTextColorProperty on API 21+ with FormsApplicationActivity #631

Merged
merged 1 commit into from Mar 3, 2017

Conversation

Projects
None yet
5 participants
@jimmgarrido
Collaborator

jimmgarrido commented Dec 9, 2016

Description of Change

On Lollipop and above NavigationPage.BarTextColorProperty was not working when using FormsApplicationActivity because getting a reference to the title TextView with the action_bar_title resource Id returns null. Instead you have to get a reference to the view indirectly via the Toolbar.

Bugs Fixed

API Changes

None

Behavioral Changes

None

PR Checklist

  • Has tests (if omitted, state reason in description)
  • Rebased on top of master at time of PR
  • Changes adhere to coding standard
  • Consolidate commits as makes sense

@rmarinho rmarinho requested a review from samhouts Feb 6, 2017

@rmarinho rmarinho merged commit 5d4fdd5 into xamarin:master Mar 3, 2017

6 checks passed

Android-UITests-C8 Finished TeamCity Build Xamarin.Forms :: Debug :: Cycle 8 :: UI Tests :: OSX Test Cloud Package - Run Android 6.0.1 : Tests passed: 350, i…
Details
OSX-Debug-C8 Finished TeamCity Build Xamarin.Forms :: Debug :: Cycle 8 :: OSX Debug : Running
Details
Windows-Debug-C8 Finished TeamCity Build Xamarin.Forms :: Debug :: Cycle 8 :: Windows Debug : Tests passed: 3679, ignored: 10
Details
iOS10-UITests-C8 Finished TeamCity Build Xamarin.Forms :: Debug :: Cycle 8 :: UI Tests :: OSX Test Cloud Package - Run iOS Unified iOS10 : Tests passed: 34…
Details
iOS8-UITests-C8 Finished TeamCity Build Xamarin.Forms :: Debug :: Cycle 8 :: UI Tests :: OSX Test Cloud Package - Run iOS Unified IOS8 : Tests passed: 344…
Details
iOS9-UITests-C8 Finished TeamCity Build Xamarin.Forms :: Debug :: Cycle 8 :: UI Tests :: OSX Test Cloud Package - Run iOS Unified iOS9 : Tests passed: 346…
Details
@BradChase2011

This comment has been minimized.

Show comment
Hide comment
@BradChase2011

BradChase2011 Mar 15, 2017

Contributor

@jimmgarrido Jimmy, this is still broken in master. The code is here:

if(Forms.IsLollipopOrNewer) { int actionbarId = _context.Resources.GetIdentifier("action_bar", "id", "android"); if(actionbarId > 0) { var toolbar = (Toolbar)((Activity)_context).FindViewById(actionbarId); actionBarTitleTextView = (TextView)toolbar.GetChildAt(0); } } else { int actionBarTitleId = _context.Resources.GetIdentifier("action_bar_title", "id", "android"); if (actionBarTitleId > 0) actionBarTitleTextView = ((Activity)_context).FindViewById<TextView>(actionBarTitleId); }

This is an image for me:
actionBarTitleTextView = (TextView)toolbar.GetChildAt(0);

So it is an invalid cast. I have temporarily put in a test to make sure it is a TextView before casting it. Can you take a look at it for me?

Contributor

BradChase2011 commented Mar 15, 2017

@jimmgarrido Jimmy, this is still broken in master. The code is here:

if(Forms.IsLollipopOrNewer) { int actionbarId = _context.Resources.GetIdentifier("action_bar", "id", "android"); if(actionbarId > 0) { var toolbar = (Toolbar)((Activity)_context).FindViewById(actionbarId); actionBarTitleTextView = (TextView)toolbar.GetChildAt(0); } } else { int actionBarTitleId = _context.Resources.GetIdentifier("action_bar_title", "id", "android"); if (actionBarTitleId > 0) actionBarTitleTextView = ((Activity)_context).FindViewById<TextView>(actionBarTitleId); }

This is an image for me:
actionBarTitleTextView = (TextView)toolbar.GetChildAt(0);

So it is an invalid cast. I have temporarily put in a test to make sure it is a TextView before casting it. Can you take a look at it for me?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment