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

Add Dark Mode manual switch in application's settings #2919

Closed
wants to merge 5 commits into from

Conversation

a-pav
Copy link

@a-pav a-pav commented Mar 11, 2024

First of all, thanks for the Dark Mode theme. I like it, although I haven't been able to use it yet!
The Dark Mode theme was added a while ago, but since its introduction, a lot of people (myself included) have been longing for a "manual toggle/switch" in comments and issues:
#2478 (comment) #2478 (comment) #2478 (comment) #2478 (comment)
close #2688, close #2720

This change adds a manual switch for Dark Mode theme. I don't have the environment to build and test this myself, but I tried my best to follow on the footsteps of similar settings and make a correct change. Please tell me if anything needs to be fixed.

@2dust
Copy link
Owner

2dust commented Mar 16, 2024

Thank you for your PR
If there are options for dark mode, there should be three options: follow the system, enable, and disable

@2dust
Copy link
Owner

2dust commented Mar 16, 2024

Please pass the real machine test and then PR

@2dust 2dust closed this Mar 16, 2024
@a-pav
Copy link
Author

a-pav commented Mar 16, 2024

Thank you for your PR If there are options for dark mode, there should be three options: follow the system, enable, and disable

Is a radio option like this OK?

  • Theme:
    • System
    • Light
    • Dark

@a-pav
Copy link
Author

a-pav commented Mar 16, 2024

Please pass the real machine test and then PR

You mean to build, test and confirm that it's working on my own device, right?

@a-pav
Copy link
Author

a-pav commented Mar 16, 2024

I'm not an Android developer. That's why I didn't build it myself. Besides, I figured that the patch is relatively small and fairly simple for a quick review by anyone authorizing its merge.

I might try to actually build v2rayNG myself out of curiosity, so I appreciate any tips on how to build the app for a complete (Android) newbie.

But to anyone reading this, if you're inclined to add this feature, do not wait up on me! Just go ahead and do it, thanks!

@a-pav
Copy link
Author

a-pav commented Apr 4, 2024

@wangwang-code
Thank you! Seems working well. Are you going to make a PR?

@wangwang-code
Copy link

@wangwang-code 谢谢你!看起来运作良好。你打算做 PR 吗?

我仍在测试,我在寻找更好的办法

视频中应该能看出,在重新启动时的一瞬间,它仍然跟随系统,直到执行AppCompatDelegate.setDefaultNightMode


Translated by gpt-3.5-turbo:
I am still testing, I am looking for a better way.

It should be visible in the video that at the moment of restarting, it still follows the system until AppCompatDelegate.setDefaultNightMode is executed.

@wangwang-code
Copy link

@wangwang-code 谢谢你!看起来运作良好。你打算做 PR 吗?

我仍在测试,我在寻找更好的办法

视频中应该能看出,在重新启动时的一瞬间,它仍然跟随系统,直到执行AppCompatDelegate.setDefaultNightMode

Translated by gpt-3.5-turbo: I am still testing, I am looking for a better way.

It should be visible in the video that at the moment of restarting, it still follows the system until AppCompatDelegate.setDefaultNightMode is executed.

我尝试跳过启动的空白,但那样会造成闪烁(重新渲染活动造成的)

@a-pav
Copy link
Author

a-pav commented Apr 4, 2024

Translated by gpt-3.5-turbo: I am still testing, I am looking for a better way.

It should be visible in the video that at the moment of restarting, it still follows the system until AppCompatDelegate.setDefaultNightMode is executed.

I don't see it myself. But you're right, setting night mode in getDarkModeStatus doesn't seem appropriate. Perhaps calling it directly in setupViewModel() is a better option?

@2dust Surely can help you better with this.

@wangwang-code
Copy link

wangwang-code commented Apr 4, 2024

Translated by gpt-3.5-turbo: I am still testing, I am looking for a better way.
It should be visible in the video that at the moment of restarting, it still follows the system until AppCompatDelegate.setDefaultNightMode is executed.

I don't see it myself. But you're right, setting night mode in getDarkModeStatus doesn't seem appropriate. Perhaps calling it directly in setupViewModel() is a better option?

@2dust Surely can help you better with this.

我在尝试用新的API setApplicationNightMode

它需要API等级 > 30 他的好处是持久化,直到用户更改它

@a-pav
Copy link
Author

a-pav commented Apr 4, 2024

我在尝试用新的API setApplicationNightMode

它需要API等级 > 30 他的好处是持久化,直到用户更改它

Yes. I saw the changes you've made on your fork. Forgive me if I'm wrong somehow, I'm not an expert.

I meant that perhaps you can call your Utils.setDaynight() inside setupViewModel() directly, instead of calling it in getDarkModeStatus() function. Can't you do that?

@wangwang-code
Copy link

我在尝试用新的API setApplicationNightMode
它需要API等级 > 30 他的好处是持久化,直到用户更改它

Yes. I saw the changes you've made on your fork. Forgive me if I'm wrong somehow, I'm not an expert.

I meant that perhaps you can call your Utils.setDaynight() inside setupViewModel() directly, instead of calling it in getDarkModeStatus() function. Can't you do that?

抱歉,我还没有看懂setupViewModel,在我本地代码里 Utils.setDaynight()放到了MainActivity类中的onCreate()

目前遇到一个棘手问题 SettingsViewModel没有Context,我需要在其他地方实现立即更新暗黑模式,我正在理解setupViewModel

@wangwang-code
Copy link

@a-pav wangwang-code@86f41be

需要寻找合适地方执行Utils.setDaynight,在选择后

我测试发现setApplicationNightMode会带来闪烁

@wangwang-code
Copy link

@a-pav
https://github.com/wangwang-code/v2rayNG/releases/tag/9999
Personally think the best way(Google Translate)

@a-pav
Copy link
Author

a-pav commented Apr 5, 2024

@wangwang-code Thank you for including me in this. Unfortunately your recent changes go a little above my head, and currently I don't have the time to study them. I hope someone from the core team will come along and help you with this.
Just one question: With this changes, will people with Android 5 devices still be able to install and use the the dark mode?

@wangwang-code
Copy link

@wangwang-code Thank you for including me in this. Unfortunately your recent changes go a little above my head, and currently I don't have the time to study them. I hope someone from the core team will come along and help you with this. Just one question: With this changes, will people with Android 5 devices still be able to install and use the the dark mode?

The documentation says Dark theme is available in Android 10 (API level 29) and higher. I’m not sure if it really doesn’t support devices below Android 10 (Google Translate)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Dark mode theme Please Add a Dark Mode Manual Switch 请加入手动切换夜间模式的开关
3 participants