Skip to content

Fix toolbar icon and text color in white theme#3482

Closed
IAmSSH wants to merge 14 commits intoTeamNewPipe:devfrom
IAmSSH:improve-toolbar-design
Closed

Fix toolbar icon and text color in white theme#3482
IAmSSH wants to merge 14 commits intoTeamNewPipe:devfrom
IAmSSH:improve-toolbar-design

Conversation

@IAmSSH
Copy link

@IAmSSH IAmSSH commented Apr 25, 2020

What is it?

  • Bug fix (user facing)
  • Feature (user facing)
  • Code base improvement (dev facing)
  • Meta improvement to the project (dev facing)

Description of the changes in your PR

  • Create a new theme ToolbarTheme in styles.xml to set it on the toolbar to get the desired color and icons.
  • Modify Tab.java and KioskTranslator.java to always return icons having white color.

Fixes the following issue(s)

Testing apk

NewPipe.zip

Agreement

@IAmSSH
Copy link
Author

IAmSSH commented Apr 25, 2020

@Stypox
Request your review please.
Thanks.

Copy link
Member

@Stypox Stypox left a comment

Choose a reason for hiding this comment

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

What you did seems correct, I only pointed out one thing that could be improved. Thank you :-D

@IAmSSH
Copy link
Author

IAmSSH commented May 1, 2020

I know its not good practice, I tried doing that, but there's a problem.
If we inherit DarkTheme, we essentially also inherit its parent the Theme.AppCompat.NoActionBar. There are some styles in Theme.AppCompat.NoActionBar that make the text in the spinner that is used to select the quality of a video (in video detail fragment) appear black along with its background, so it becomes unreadable.
I tried overriding some styles but it didn't work out.
I'll try some more and let you know.

@wb9688 wb9688 added this to the 0.19.4 milestone May 1, 2020
@IAmSSH
Copy link
Author

IAmSSH commented May 4, 2020

I changed the spinner items to always be of red colour, irrespective of the theme selected.

@Stypox
Copy link
Member

Stypox commented May 4, 2020

I just realized one thing: maybe there is no need to create a new style in styles.xml just for icons, but it is enough to force the white drawables (instead of using ?attr/) in all menus, since there is only one global style for toolbars. Anyway, the new code looks better, and if my above assumption can't be implemented it is good to go after some testing ;-)
Thank you for the patience ;-D

@Stypox Stypox self-assigned this May 4, 2020
@IAmSSH
Copy link
Author

IAmSSH commented May 6, 2020

I think the hamburger icon's colour cannot be changed without using the DrawerArrowStyle style, since it does not belong to our set of style icons (defined in Dark and Light themes), but is preset. So, it might be necessary to keep the style.

@Stypox
Copy link
Member

Stypox commented May 6, 2020

Ok, then this is correct approach.

I found some issues (tested on an emulator with Android 4.4 API 19):

  • The background color of the toolbar does not change according to the service (i.e. try with soundcloud). It should have the same background color as the tab selector in the main page.
  • The background color of the stream selector in the video detail activity should not be red, but should follow the chosen app theme (i.e. dark if dark theme, white if light theme, etc.), just like three-dot menus do.
  • The color of the ______ line under the currently selected tab in the main page should always be white, but instead it changes color when changing theme.
  • In download activity the color of the "List" toolbar button is black, while it should be white.
  • The toolbar of the about activity still has black icons and text when using white theme.

@IAmSSH
Copy link
Author

IAmSSH commented May 7, 2020

Okay, I'll look into it

@IAmSSH
Copy link
Author

IAmSSH commented May 8, 2020

Regarding the last comment:

The background color of the stream selector in the video detail activity should not be red, but should follow the chosen app theme (i.e. dark if dark theme, white if light theme, etc.), just like three-dot menus do.

You mean
1

The menu to select stream quality is red but it should be like the colour of dot menu popup, i.e
2

The dot menu popup is always of the colour as shoown in the image irrespective of the stream or the theme, so should I make it similar to that (gray background and white text), or you meant something else?

@Stypox
Copy link
Member

Stypox commented May 8, 2020

Oh, that's another issue. Both menus should have dark background with the dark theme and light background with the light theme. I guess you need to do something similar to what you did with DrawerArrowStyle

@IAmSSH
Copy link
Author

IAmSSH commented May 10, 2020

The app is working fine now. All issues are resolved.
The only thing remaining is the colour of the spinner in video detail fragment. It does not change according to Light and Dark themes, but is consistent with the colours of different services.
I think it appears fine like this. If you want it to be changed do let me know.

@Stypox
Copy link
Member

Stypox commented May 10, 2020

Thank you for fixing the issues! I have found some more things to improve ;-)

  • The "save playlist" toolbar button in the playlist fragment is black in white theme, while it should always be white
  • The download dialog (opened from the video detail fragment) has two issues: the stream selector has a red background color, while its background should follow the theme, and the back button (top left) is black in white theme, while it should always be white
  • The toolbar in background/popup player activities still has black icons and title in white theme, while they should be white

These two issues you posted screenshots above are still not solved:

  • The three-dot menu has a dark background independently of the theme, while it should follow the theme
  • The stream selector in video detail fragment has a red background, while it should follow the theme

@IAmSSH
Copy link
Author

IAmSSH commented May 12, 2020

There were some problems with the current approach. Since the Toolbar had the DarkTheme as the parent, so the styles of DarkTheme were getting applied to it statically and they were not changing with the Themes or the Services and it created problems everywhere.

So I had to revert back to the earlier approach that involved copying icons in the ToolbarTheme, it solved all the problems.

@Stypox Stypox self-requested a review May 13, 2020 08:33
@B0pol B0pol added the bug Issue is related to a bug label May 17, 2020
@IAmSSH
Copy link
Author

IAmSSH commented May 25, 2020

Hey,
I removed the dead code.
Is there anything else that is remaining?

@wb9688
Copy link
Member

wb9688 commented May 25, 2020

@IAmSSH: #3271 changed the names of some icons, so you have to change your PR accordingly.

PS: Please stay longer on IRC until we've seen your question and answered, or use e.g. Matrix.

@IAmSSH
Copy link
Author

IAmSSH commented May 28, 2020

The required changes are done.

PS: @wb9688 Sorry about the IRC. I was really having a hard time figuring out how to work with it. I have set up Matrix now.

Copy link
Member

@Stypox Stypox left a comment

Choose a reason for hiding this comment

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

All of these problems refer to the app when the white theme is active.

  • The subtitle in subscription groups "What's New" toolbar is dark grey, while it should be light gray.
  • The search bar description/hint is dark grey, while it should be light gray. The flashing indicator is black instead of white.

Other than this, everything seems good. I tested on Android 4.4 API 19 and on Android 7.0

}

setSupportActionBar(findViewById(R.id.toolbar));
Toolbar toolbar = findViewById(R.id.toolbar);
Copy link
Member

Choose a reason for hiding this comment

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

Add final here, or revert this change

Comment on lines 227 to 235
boolean isLight = ThemeHelper.isLightThemeSelected(mContext);
int icon;

if (mLinear)
icon = R.drawable.ic_apps_white_24dp;
else
icon = R.drawable.ic_list_white_24dp;

mSwitch.setIcon(icon);
Copy link
Member

Choose a reason for hiding this comment

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

I prefer the ?: syntax, also I think isLight is a leftover from the merge, because it is not needed

Suggested change
boolean isLight = ThemeHelper.isLightThemeSelected(mContext);
int icon;
if (mLinear)
icon = R.drawable.ic_apps_white_24dp;
else
icon = R.drawable.ic_list_white_24dp;
mSwitch.setIcon(icon);
mSwitch.setIcon(mLinear ? R.drawable.ic_apps_white_24dp : R.drawable.ic_list_white_24dp);

android:textAlignment="center"
android:textAllCaps="true"
android:textAppearance="@style/TextAppearance.AppCompat.Body1"
android:background="?attr/colorPrimary"
Copy link
Member

Choose a reason for hiding this comment

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

Why was this added? Isn't the @style/ServiceColoredButton added by @B0pol enough?

Comment on lines 143 to 147
toolbar.setPopupTheme(
ThemeHelper.isLightThemeSelected(this)
? R.style.PopupThemeLight
: R.style.PopupThemeDark
);
Copy link
Member

Choose a reason for hiding this comment

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

Why not use R.style.ToolbarTheme here, too?

Comment on lines +746 to +748
RelativeLayout r = (RelativeLayout) parent.getChildAt(0);
((TextView) r.getChildAt(1)).setTextColor(getResources().getColor(R.color.white));
((TextView) r.getChildAt(2)).setTextColor(getResources().getColor(R.color.white));
Copy link
Member

Choose a reason for hiding this comment

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

Isn't there any other way to do this? It seems to be a workaround to me, though if there is no other way then ok, I guess the toolbar inflated layout is always the same.

Copy link
Author

Choose a reason for hiding this comment

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

I couldn't find any direct way of styling just the first element of a spinner, so had to use this approach.

Comment on lines 479 to 480
playlistBookmarkButton.setIcon(iconAttr);
playlistBookmarkButton.setTitle(titleRes);
Copy link
Member

Choose a reason for hiding this comment

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

While you are at it, you could move the variables above directly here:

Suggested change
playlistBookmarkButton.setIcon(iconAttr);
playlistBookmarkButton.setTitle(titleRes);
playlistBookmarkButton.setIcon(playlistEntity == null
? R.drawable.ic_playlist_add_white_24dp
: R.drawable.ic_playlist_add_check_white_24dp);
playlistBookmarkButton.setTitle(playlistEntity == null
? R.string.bookmark_playlist
: R.string.unbookmark_playlist);

Comment on lines 227 to 235
boolean isLight = ThemeHelper.isLightThemeSelected(mContext);
int icon;

if (mLinear)
icon = R.drawable.ic_grid_white_24dp;
else
icon = R.drawable.ic_list_white_24dp;

mSwitch.setIcon(icon);
Copy link
Member

Choose a reason for hiding this comment

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

Here, too. Also, isLight is unused.

Suggested change
boolean isLight = ThemeHelper.isLightThemeSelected(mContext);
int icon;
if (mLinear)
icon = R.drawable.ic_grid_white_24dp;
else
icon = R.drawable.ic_list_white_24dp;
mSwitch.setIcon(icon);
mSwitch.setIcon(mLinear
? R.drawable.ic_grid_white_24dp
: R.drawable.ic_list_white_24dp);

@Stypox Stypox modified the milestones: 0.19.4, 0.19.5 May 28, 2020
@IAmSSH
Copy link
Author

IAmSSH commented Jun 1, 2020

Done @Stypox

Copy link
Member

@Stypox Stypox left a comment

Choose a reason for hiding this comment

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

Code looks good! Thank you for the patience. I ran a thorough test this time, hopefully I haven't missed anything, so these are the problematic things I could find while using white theme:

  • Black title of "Settings -> Download -> Video/Audio download folder"
  • Black "Restore defaults" toolbar icon, item icons (also in the "Choose tab" dialog) and + FAB of "Settings -> Content -> Content of main page"
  • Black "Restore defaults" toolbar icon and + FAB of "Settings -> Content -> PeertTube instances"
  • Black title of "Settings -> Content -> Import/Export database"
  • Black cursor pointer in the search bar (it appears when moving the cursor along the text, or when selecting something)
  • Black selection in the search bar (dark grey instead of light grey)
  • White unselected item circles in the three-dot menu to choose the search filters (they should be dark dark gray, like in e.g. the download dialog)
  • The spinner arrow-down icon flashes black when the spinner is clicked on (then turns back to white in the flash of an eye). Even though the flashing behaviour apparently exists in old versions of android (4.4, but not on my 7.0 phone), I think it should just stay white even when clicked on, as this is also what happens when the dark theme is active.
  • When the device is in landscape mode popup/background queue toolbars have black title and icons
  • Black title of "Subscriptions -> Import from -> Previous export"
  • Black title of "Subscriptions -> Export to -> File"

@wb9688
Copy link
Member

wb9688 commented Jun 27, 2020

@TobiGr: Should we move this to v0.20.0 seeing how @IAmSSH hasn't replied for 25 days and it not being a bug fix (so not really worth it fixing it ourself imho)?

@TobiGr TobiGr modified the milestones: 0.19.6, 0.20.0 Jun 27, 2020
@wb9688 wb9688 modified the milestones: 0.20.0, 0.20.1 Jul 29, 2020
@Stypox Stypox changed the title fix toolbar UI Fix toolbar icon and text color in white theme Oct 4, 2020
@Stypox Stypox modified the milestones: 0.20.1, 0.20.2 Oct 4, 2020
@TobiGr TobiGr force-pushed the dev branch 2 times, most recently from 679bc75 to 2aeccc0 Compare March 16, 2021 08:24
@AudricV
Copy link
Member

AudricV commented Mar 28, 2021

Closing in favor of #5927.

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

Labels

bug Issue is related to a bug

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Polish white theme: make app bar text and icons white

6 participants