Fixed
Status Update
Comments
il...@google.com <il...@google.com> #2
since these are in public API (:/) we need to do this in 1.2
be...@upactivity.com <be...@upactivity.com> #3
since it is already marked as deprecated, we can probably do it by now.
il...@google.com <il...@google.com> #4
Opening diff shortly
be...@upactivity.com <be...@upactivity.com> #5
Project: platform/frameworks/support
Branch: androidx-master-dev
commit d576cbdc911cba16638a44fd8223391a90a07ef7
Author: Mike Nakhimovich <digitalbuddha@users.noreply.github.com>
Date: Tue Aug 11 09:30:34 2020
[GH] Hide deprecated internal API.
## Proposed Changes
* `RoomDatabase.java` has protected `mCallbacks` field which is leaking in the API docs, we should @Hide it.
## Testing
Test: Ran unit tests locally
## Issues Fixed
Fixes: 76109329
This is an imported pull request fromhttps://github.com/androidx/androidx/pull/61 .
Resolves #61
Github-Pr-Head-Sha: 6440daa3a63752c7f9d5ba2a390248cd85bc634f
GitOrigin-RevId: fe92d8466a59b44b218b6ca3cbd57dcda17992f7
Change-Id: Id599cdf5b02b32bdae0166266fb7da967598fe92
A room/runtime/api/current.ignore
M room/runtime/api/current.txt
M room/runtime/api/public_plus_experimental_current.txt
M room/runtime/api/restricted_current.txt
M room/runtime/src/main/java/androidx/room/RoomDatabase.java
https://android-review.googlesource.com/1396827
Branch: androidx-master-dev
commit d576cbdc911cba16638a44fd8223391a90a07ef7
Author: Mike Nakhimovich <digitalbuddha@users.noreply.github.com>
Date: Tue Aug 11 09:30:34 2020
[GH] Hide deprecated internal API.
## Proposed Changes
* `RoomDatabase.java` has protected `mCallbacks` field which is leaking in the API docs, we should @Hide it.
## Testing
Test: Ran unit tests locally
## Issues Fixed
Fixes: 76109329
This is an imported pull request from
Resolves #61
Github-Pr-Head-Sha: 6440daa3a63752c7f9d5ba2a390248cd85bc634f
GitOrigin-RevId: fe92d8466a59b44b218b6ca3cbd57dcda17992f7
Change-Id: Id599cdf5b02b32bdae0166266fb7da967598fe92
A room/runtime/api/current.ignore
M room/runtime/api/current.txt
M room/runtime/api/public_plus_experimental_current.txt
M room/runtime/api/restricted_current.txt
M room/runtime/src/main/java/androidx/room/RoomDatabase.java
be...@upactivity.com <be...@upactivity.com> #6
> It sounds like what you actually want is a setupToolbarWithNavController() equivalent that you could call in each Fragment?
After giving it more thought, and following your recommendations in the comments, actually maybe this is what I want/have to do.
So basically when setting up the fragment, I link to to the nav controller so that the navigation graph data is populated to the toolbar (home "up" button and title, basically).
The problem is, what is this `setupToolbarWithNavController()` you are referring to? It's not part of `NavigationUI`, is it?
I'm using the -alpha02 dependencies on 3.2 canary 17.
After giving it more thought, and following your recommendations in the comments, actually maybe this is what I want/have to do.
So basically when setting up the fragment, I link to to the nav controller so that the navigation graph data is populated to the toolbar (home "up" button and title, basically).
The problem is, what is this `setupToolbarWithNavController()` you are referring to? It's not part of `NavigationUI`, is it?
I'm using the -alpha02 dependencies on 3.2 canary 17.
il...@google.com <il...@google.com> #7
>So basically if I have a toolbar in each fragment layout, and my activity has a theme without action bar...
I think the proposed solution of having a setupToolbarWithNavController()-like method would do all the things you list, exactly like the setupActionBarWithNavController() does for the ActionBar.
> Not sure about that, see my Google+ example. The drawer is only visible on the main screens (stream, collections, communities, notifications), but it is not when getting deeper (post view, events, contacts, etc)
I'm not saying that Google+ does things correctly. I'm saying that the discussions with the material design team has made it clear that the navigation drawer is a global navigation pattern that should be available everywhere (in that respect, very similar to how the bottom nav bar should always be visible - also not something apps do consistently).
> Actually my question here was more like "how to disable the drawer when getting deeper into the app".
Like how to disable the drawer when opening a post in Google+. Is this something that has to be done by hand, or is it handled by the navigation API?
This isn't something Navigation would do automatically, but you can certainly add an OnNavigatedListener viahttps://developer.android.com/reference/androidx/navigation/NavController#addonnavigatedlistener and take any action you want, including locking the DrawerLayout closed.
I think the proposed solution of having a setupToolbarWithNavController()-like method would do all the things you list, exactly like the setupActionBarWithNavController() does for the ActionBar.
> Not sure about that, see my Google+ example. The drawer is only visible on the main screens (stream, collections, communities, notifications), but it is not when getting deeper (post view, events, contacts, etc)
I'm not saying that Google+ does things correctly. I'm saying that the discussions with the material design team has made it clear that the navigation drawer is a global navigation pattern that should be available everywhere (in that respect, very similar to how the bottom nav bar should always be visible - also not something apps do consistently).
> Actually my question here was more like "how to disable the drawer when getting deeper into the app".
Like how to disable the drawer when opening a post in Google+. Is this something that has to be done by hand, or is it handled by the navigation API?
This isn't something Navigation would do automatically, but you can certainly add an OnNavigatedListener via
il...@google.com <il...@google.com> #8
I'm proposing making this bug into a feature request for adding a setupToolbarWithNavController type of method if you're okay with that.
be...@upactivity.com <be...@upactivity.com> #9
> I'm not saying that Google+ does things correctly. I'm saying that the discussions with the material design team has made it clear that the navigation drawer is a global navigation pattern that should be available everywhere (in that respect, very similar to how the bottom nav bar should always be visible - also not something apps do consistently).
Very interesting. Thanks for the insights.
> This isn't something Navigation would do automatically, but you can certainly add an OnNavigatedListener viahttps://developer.android.com/reference/androidx/navigation/NavController#addonnavigatedlistener and take any action you want, including locking the DrawerLayout closed.
Thanks again. That's what I would have done, I was just wondering if the navigation API had something automatic here. But if the drawer is a global navigation pattern and should always be available, that would be useless.
About these two items, it's weird because none of the apps I have tested quickly today seem to have a global drawer: Inbox, Gmail, Google+, Google Music, Play Store, Messages, Maps, Photos — all of them hide/lock the drawer when opening an item in the app (email, post, track, app, etc).
The only two notable exceptions are docs (spreadsheets etc): they open a new task when opening a document, so that makes sense; and YouTube, they got rid of the drawer altogether.
So that's a bit contradictory with a global navigation pattern, and it doesn't make me want to have a global drawer everywhere.
> I'm proposing making this bug into a feature request for adding a setupToolbarWithNavController type of method if you're okay with that.
That would be awesome. For an activity-managed ActionBar, use `NavigationUI.setupActionBarWithNavController()`; and for a custom Toolbar, use `NavigationUI.setupToolbarWithNavController()`. Both do the same: get information from the navigation graph (label, whether it's the start destination or not, menus, etc).
Is that right?
If so, please convert this to a feature request.
Thanks Ian! (I guess this is you :))
Very interesting. Thanks for the insights.
> This isn't something Navigation would do automatically, but you can certainly add an OnNavigatedListener via
Thanks again. That's what I would have done, I was just wondering if the navigation API had something automatic here. But if the drawer is a global navigation pattern and should always be available, that would be useless.
About these two items, it's weird because none of the apps I have tested quickly today seem to have a global drawer: Inbox, Gmail, Google+, Google Music, Play Store, Messages, Maps, Photos — all of them hide/lock the drawer when opening an item in the app (email, post, track, app, etc).
The only two notable exceptions are docs (spreadsheets etc): they open a new task when opening a document, so that makes sense; and YouTube, they got rid of the drawer altogether.
So that's a bit contradictory with a global navigation pattern, and it doesn't make me want to have a global drawer everywhere.
> I'm proposing making this bug into a feature request for adding a setupToolbarWithNavController type of method if you're okay with that.
That would be awesome. For an activity-managed ActionBar, use `NavigationUI.setupActionBarWithNavController()`; and for a custom Toolbar, use `NavigationUI.setupToolbarWithNavController()`. Both do the same: get information from the navigation graph (label, whether it's the start destination or not, menus, etc).
Is that right?
If so, please convert this to a feature request.
Thanks Ian! (I guess this is you :))
be...@upactivity.com <be...@upactivity.com> #10
Please disregard my remark about the drawer and most apps, I guess I was decaffeinated because I was wrong for almost all of them.
il...@google.com <il...@google.com>
il...@google.com <il...@google.com> #11
A NavigationUI.setupWithNavController(Toolbar, NavController, DrawerLayout) method has been added internally and will be available in alpha03
Description
Version used:1.0.0-alpha02
Devices/Android versions reproduced on: Huawei P10+ Android 8.0
I have a single activity application with several fragments. They don't all have the same toolbar behavior/size/whatever so the main activity layout is a coordinator layout only:
<?xml version="1.0" encoding="utf-8"?>
<android.support.design.widget.CoordinatorLayout
android:id="@+id/main_activity_coordinator_layout"
xmlns:android="
xmlns:app="
xmlns:tools="
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fitsSystemWindows="true"
tools:context=".app.MainActivity">
<fragment
android:id="@+id/main_activity_nav_host"
android:name="androidx.navigation.fragment.NavHostFragment"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:defaultNavHost="true"
app:layout_behavior="@string/appbar_scrolling_view_behavior"
app:navGraph="@navigation/main_activity"/>
</android.support.design.widget.CoordinatorLayout>
Each fragment layout has an app bar layout and a toolbar.
In the main activity onCreate method I have the following:
NavigationUI.setupActionBarWithNavController(this, navController)
navController is a reference to the navigation controller of this activity.
This creates a NPE at ActionBarOnNavigatedListener.onNavigated(NavigationUI.java:284) because there is no action bar yet.
E Caused by: java.lang.NullPointerException: Attempt to invoke virtual method 'void android.support.v7.app.ActionBar.setTitle(java.lang.CharSequence)' on a null object reference
E at androidx.navigation.ui.NavigationUI$ActionBarOnNavigatedListener.onNavigated(NavigationUI.java:284)
E at androidx.navigation.NavController.addOnNavigatedListener(NavController.java:206)
E at androidx.navigation.ui.NavigationUI.setupActionBarWithNavController(NavigationUI.java:152)
E at androidx.navigation.ui.NavigationUI.setupActionBarWithNavController(NavigationUI.java:130)
E at xxx.app.MainActivity.onCreate(MainActivity.kt:161)
E at android.app.Activity.performCreate(Activity.java:7372)
E at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1218)
E at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:3147)
E ... 9 more