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

Update Android Status Bar Text / Icon color based on theme/night mode #1442

Open
stuartmscott opened this issue Oct 22, 2020 · 9 comments
Open
Labels
Hacktoberfest help wanted Extra attention is needed OS:Android Tickets affecting only Android devices

Comments

@stuartmscott
Copy link
Member

Android Apps can draw below the status and navigation bars, however if the App background is white the elements inside the status and navigation become invisible as they are also white. Android will switch the elements to black if it is aware of the App's background colour, therefore Fyne needs to communicate the current theme's colour scheme to Android.

@s77rt
Copy link
Contributor

s77rt commented Mar 18, 2021

Any update on this?

@andydotxyz
Copy link
Member

We generally post updates when there are changes, we are still planning to work on this for the release tagged.

@andydotxyz
Copy link
Member

the PR #2230 fixes the action bar, but for some reason the status bar still has a problem, it will not switch into dark text (light mode)... Looking for anyone who can help on this.

@andydotxyz andydotxyz added help wanted Extra attention is needed and removed Design Requires some visual design process labels May 10, 2021
@andydotxyz andydotxyz changed the title Update Android Status and Navigation Bar Colour based on App Background Colour Update Android Status Bar Text / Icon color based on theme/night mode May 10, 2021
@yebowhatsay
Copy link

yebowhatsay commented Oct 9, 2021

This can be done programmatically in Kotlin/Java.
change color of status bar

Can't find anything similar implemented by gomobile.

However, until we can do it programmatically, a way to hide this shortcoming is by simply hiding the status bar.

This can be done by adding the following android:theme attribute in the activity tag on AndroidManifest.xml


<activity android:name="org.golang.app.GoNativeActivity"
    android:theme="@android:style/Theme.NoTitleBar.Fullscreen"
</activity>

@andydotxyz
Copy link
Member

Thanks @yebowhatsay - if it can be done in Java then we can call that from our code. Looks like the key in that article is:

if (Build.VERSION.SDK_INT >= 21) {
            Window window = this.getWindow();
            window.addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS);
            window.clearFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS);
            window.setStatusBarColor(this.getResources().getColor(R.color.colorPrimaryDark));
 }

However we will need to convert our colours into Android ones. I had hoped we could just tell android "use light theme bar" like on iOS, but this may work instead.

Let's not hide the status bar, it is a useful feature of the platform.

@yebowhatsay
Copy link

Would have loved to help port this to Fyne, but really don't know where to get started.
Thanks, @andydotxyz !!!

@andydotxyz
Copy link
Member

Would have loved to help port this to Fyne, but really don't know where to get started.

You can see some of our other Android bridge code in the android.c files (there are 2) as we are in the middle of refactoring the mobile driver.

@yebowhatsay
Copy link

Thanks @andydotxyz . I am having a go at cgo and studying the c/java code in the project.

@sanguohot
Copy link

sanguohot commented Apr 16, 2022

however if the App background is white the elements inside the status and navigation become invisible as they are also white

The same problem. I have changed the background color to fix it. Thanks for reminding.

func (*CustomTheme) Color(n fyne.ThemeColorName, v fyne.ThemeVariant) color.Color {
	switch n {
	case theme.ColorNameBackground:
		return &color.NRGBA{R: 204, G: 232, B: 207, A: 255}
	default:
		return theme.DefaultTheme().Color(n, v)
	}
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Hacktoberfest help wanted Extra attention is needed OS:Android Tickets affecting only Android devices
Projects
None yet
Development

No branches or pull requests

5 participants