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

Set My site fragment title to 'My site' instead of using site title #11691

Merged
merged 4 commits into from
Apr 17, 2020
Merged
Show file tree
Hide file tree
Changes from 3 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
1 change: 1 addition & 0 deletions RELEASE-NOTES.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
* Block editor: Fix a bug which caused to show URL settings modal randomly when changing the device orientation multiple times during the time Starter Page Template Preview is open
* Block editor: "Choose media from device" now opens our built-in media picker instead of the OS default media picker.
* Added user Gravatar to the Me menu in My Site.
* Updated site details screen title to "My site", to avoid duplicating the title of the current site which is displayed in the screen's header area.

14.6
-----
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -377,7 +377,7 @@ public View onCreateView(@NonNull LayoutInflater inflater, ViewGroup container,
setupClickListeners(rootView);

mToolbar = rootView.findViewById(R.id.toolbar_main);
mToolbar.setTitle(mToolbarTitle);
mToolbar.setTitle(R.string.my_site_section_screen_title);

mToolbar.inflateMenu(R.menu.my_site_menu);

Expand Down Expand Up @@ -955,9 +955,6 @@ private void refreshSelectedSiteDetails(SiteModel site) {
} else {
mQuickActionButtonsContainer.setWeightSum(75f);
}

// Refresh the title
setTitle(site.getName());
}

private void toggleAdminVisibility(@Nullable final SiteModel site) {
Expand Down Expand Up @@ -1009,12 +1006,9 @@ public void onStart() {

@Override
public void setTitle(@NonNull final String title) {
if (isAdded()) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Did you remove the isAdded check because we no longer need context when setting the title?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I removed the isAdded check because I simplified this implementation using the Me fragment as reference – I have no idea whether it's necessary, so happy to take your lead here.

Copy link
Contributor

Choose a reason for hiding this comment

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

I think it isn't necessary :-).

mToolbarTitle = (title.isEmpty()) ? getString(R.string.wordpress) : title;

if (mToolbar != null) {
mToolbar.setTitle(mToolbarTitle);
}
mToolbarTitle = title;
Copy link
Contributor

@planarvoid planarvoid Apr 17, 2020

Choose a reason for hiding this comment

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

Out of scope of this PR: I'm actually wondering if we need the body of this method at all since the toolbar title is a constant and we set it in the onCreate method

if (mToolbar != null) {
mToolbar.setTitle(title);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -808,17 +808,9 @@ public void handleNewPostAction(PagePostCreationSourcesDetail source) {
ActivityLauncher.addNewPostForResult(this, getSelectedSite(), false, source);
}

private void updateTitle() {
updateTitle(mBottomNav.getCurrentSelectedPage());
}

private void updateTitle(PageType pageType) {
Copy link
Contributor

Choose a reason for hiding this comment

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

the updateTitle() method is no longer used so you can remove it

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Isn't it still used from onPageChanged()?

Copy link
Contributor

Choose a reason for hiding this comment

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

I meant the one above this one, without parameters. I couldn't comment there :-)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done 👍

if (pageType == PageType.MY_SITE && mSelectedSite != null) {
((MainToolbarFragment) mBottomNav.getActiveFragment()).setTitle(mSelectedSite.getName());
} else {
((MainToolbarFragment) mBottomNav.getActiveFragment())
.setTitle(mBottomNav.getTitleForPageType(pageType).toString());
}
((MainToolbarFragment) mBottomNav.getActiveFragment())
.setTitle(mBottomNav.getTitleForPageType(pageType).toString());
Copy link
Contributor

Choose a reason for hiding this comment

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

It's out of scope of this PR but this whole logic is strange (and wrong). We don't actually need to update the title anywhere else than in the Bottom nav component since this is a callback triggered by the bottom nav. What we do here is that the bottom nav tells us that a tab was selected and we react to it by asking bottom nav for the active fragment and setting its title from the bottom nav.

}

private void trackLastVisiblePage(PageType pageType, boolean trackAnalytics) {
Expand Down Expand Up @@ -1192,8 +1184,6 @@ public void setSelectedSite(@Nullable SiteModel selectedSite) {
// Make selected site visible
selectedSite.setIsVisible(true);
AppPrefs.setSelectedSite(selectedSite.getId());

updateTitle();
}

/**
Expand All @@ -1209,7 +1199,6 @@ public void initSelectedSite() {
mSelectedSite = mSiteStore.getSiteByLocalId(siteLocalId);
// If saved site exist, then return, else (site has been removed?) try to select another site
if (mSelectedSite != null) {
updateTitle();
return;
}
}
Expand Down