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

Reset brightness to system when app closed, instead of waiting 4 hours #10675

Open
6 tasks done
Spok1 opened this issue Dec 22, 2023 · 22 comments
Open
6 tasks done

Reset brightness to system when app closed, instead of waiting 4 hours #10675

Spok1 opened this issue Dec 22, 2023 · 22 comments
Labels
bug Issue is related to a bug GUI Issue is related to the graphical user interface

Comments

@Spok1
Copy link

Spok1 commented Dec 22, 2023

Checklist

  • I am able to reproduce the bug with the latest version given here: CLICK THIS LINK.
  • I made sure that there are no existing issues - open or closed - which I could contribute my information to.
  • I have read the FAQ and my problem isn't listed.
  • I have taken the time to fill in all the required details. I understand that the bug report will be dismissed otherwise.
  • This issue contains only one bug.
  • I have read and understood the contribution guidelines.

Affected version

0.25.2

Steps to reproduce the bug

1.Open some video;
2.Turn down brightness;
3.Quit the application;
4.Unload from RAM or reboot the phone for completeness.
5.Open the application and see that the brightness remained at the level of the previous adjustment, but was restored to the system value, as you stated.

Expected behavior

So that the brightness values ​​are restored to the system default value.

Actual behavior

Brightness does not reset to default after starting a new session.

Screenshots/Screen recordings

Details

8c582cfe-ca1a-4085-a5b6-3d59a7aee1f3.mp4

Logs

No response

Affected Android/Custom ROM version

Android 10

Affected device model

Xiaomi Redmi 7A

Additional information

No response

@Spok1 Spok1 added bug Issue is related to a bug needs triage Issue is not yet ready for PR authors to take up labels Dec 22, 2023
@Pentaphon
Copy link

@Spok1 try using the newest 0.26 first

@Spok1
Copy link
Author

Spok1 commented Dec 22, 2023

Nothing changed! Do you know why? Because no one has reported this before. Therefore, there is nothing to fix.

@Pentaphon
Copy link

This is expected behavior. Why would you want the brightness to keep going back to the system value? I like Newpipe having its own brightness that I set myself.

@Spok1
Copy link
Author

Spok1 commented Dec 22, 2023

Because this behavior is in the video assistant Samsung internet browser And I liked it. Also, on my old tablet the brightness is set to the minimum brightness to save battery, and the brightness in the new pipes will remain the same as I did, for example, and since I have Not the brightness percentage, I can't adjust exactly the same.Therefore, I have to disable the adjustment gesture so as not to accidentally touch the control, otherwise I will never return to the desired value again.

@opusforlife2 opusforlife2 added GUI Issue is related to the graphical user interface and removed needs triage Issue is not yet ready for PR authors to take up labels Dec 22, 2023
@opusforlife2
Copy link
Collaborator

It was normal behaviour for Newpipe to reset to system brightness when swiped away from Recents or closed in another way. This no longer happens. I'm not sure when this behaviour was changed.

@Pentaphon
Copy link

It was normal behaviour for Newpipe to reset to system brightness when swiped away from Recents or closed in another way.

This doesn't make any sense to me because it forces many users to keep changing their brightness every time Newpipe gets closed in some way. It's much more convenient for Newpipe to have its own brightness level so I can set it once and never have to set it again when watching videos. This behavior is welcome by many users and should stay as an option at the very least.

@Spok1
Copy link
Author

Spok1 commented Dec 22, 2023

This behavior is welcome by many users and should stay as an option at the very least.

In this case, a choice is needed, otherwise it can be considered incorrect behavior. It’s easy to swipe left and change the brightness to the desired value.

@Pentaphon
Copy link

In this case, a choice is needed, otherwise it can be considered incorrect behavior.

It's not incorrect if many people like me prefer it. I'd like it to stay as an option. Plenty of people seem to enjoy it as it is, considering you are the only person to file an issue about this behavior being "incorrect" in a long time.

@opusforlife2
Copy link
Collaborator

in a long time

That's simply because the current behaviour is fairly recent.

There was a slightly different but related behaviour in earlier versions where taking the brightness down to zero would actually revert it to system brightness. But this was also seen as a bug of sorts because it was weird to first go down and then up in brightness. So that was changed.

Hmmm. Maybe that change is actually the culprit here. @XiangRongLin what's your opinion?

@Spok1
Copy link
Author

Spok1 commented Dec 23, 2023

@opusforlife2

it was weird to first go down and then up in brightness. So that was changed.

This is not strange, but quite adequate behavior. Similar behavior in Samsung browser. And I think this is true!

@Pentaphon,

considering you are the only person to file an issue about this behavior being "incorrect" in a long time.

I may have been silent and not sent a report in the hope that the developers would fix it, but this did not happen for a long time, so I decided that this was a bug and they were not aware of it, but as it turned out, it was passed off as a feature! Extremely depressing!

@XiangRongLin
Copy link
Collaborator

@opusforlife2

where taking the brightness down to zero would actually revert it to system brightness

I remember this, but I can't find any commit from me related to that.


I found this code block, but the behaviour exists since the preunified player, which was dec 2019

// Restore already saved brightness level
final float brightnessLevel = PlayerHelper.getScreenBrightness(activity);
if (brightnessLevel == lp.screenBrightness) {
return;
}
lp.screenBrightness = brightnessLevel;
activity.getWindow().setAttributes(lp);

Note that the brightness only gets saved for 4 hours. After that i defaults to the system value

public static float getScreenBrightness(@NonNull final Context context) {
final SharedPreferences sp = getPreferences(context);
final long timestamp =
sp.getLong(context.getString(R.string.screen_brightness_timestamp_key), 0);
// Hypothesis: 4h covers a viewing block, e.g. evening.
// External lightning conditions will change in the next
// viewing block so we fall back to the default brightness
if ((System.currentTimeMillis() - timestamp) > TimeUnit.HOURS.toMillis(4)) {
return -1;
} else {
return sp.getFloat(context.getString(R.string.screen_brightness_key), -1);
}
}

@Spok1
Copy link
Author

Spok1 commented Jan 15, 2024

@XiangRongLin

Note that the brightness only gets saved for 4 hours. After that i defaults to the system value

I'll check this statement. However, this does not answer the question, will this be fixed so that the brightness value returns to the default value after exiting the player?

@XiangRongLin
Copy link
Collaborator

will this be fixed so that the brightness value returns to the default value

This assumes that the current behaviour is a bug. There is extra code specifically restoring the previous brightness, so its a feature.
What you are asking for is a feature request and not bug fix

@Spok1
Copy link
Author

Spok1 commented Jan 15, 2024

@XiangRongLin

What you are asking for is a feature request and not bug fix

In fact, you made a function out of it, and I’m just asking you to return it to how it should have been originally. As an example, I give you a browser from Samsung, in which the brightness value is immediately reset to default,Immediately after closing the player, not even when closing the application.

@opusforlife2
Copy link
Collaborator

Note that the brightness only gets saved for 4 hours

Okay that's weird. Do you remember who made that change? I don't remember any discussion around this time threshold.

@XiangRongLin
Copy link
Collaborator

Just look at the git blame. But due to the unified player, all code was move around so you probably can't see the who it was directly
https://github.com/TeamNewPipe/NewPipe/blame/1d8850d1b24a2874f10bafc7e3f2f856edb5a684/app/src/main/java/org/schabi/newpipe/player/helper/PlayerHelper.java#L366

@opusforlife2
Copy link
Collaborator

Thanks! Yeah, let's remove this arbitrary restriction.

@opusforlife2 opusforlife2 changed the title Brightness control Reset brightness to system when app closed, instead of waiting 4 hours Jan 17, 2024
@Pentaphon
Copy link

Thanks! Yeah, let's remove this arbitrary restriction.

I think this behavior should be optional. I much prefer the current behavior of Newpipe brightness because I don't have to keep changing the brightness every time I watch a youtube video and I usually keep my phone at a lower brightness.

@opusforlife2
Copy link
Collaborator

every time I watch a youtube video

It won't be every time you watch a video. The reset will happen after you remove Newpipe from Recents (or it gets killed in another way).

@Pentaphon
Copy link

The reset will happen after you remove Newpipe from Recents (or it gets killed in another way).

That's still too much. Lots of phones kill apps too easily. I'd rather have an option to either reset brightness to system as you describe or the current behavior which I prefer. It's nice to never have to change brightness on newpipe. I wish every video player did it this way.

@opusforlife2
Copy link
Collaborator

Let's wait for a PR on this? If during testing it seems unviable, then we can instead think of a manual button to reset brightness.

BTW the reason why 'reset to system brightness' is attractive is because modern Android (combined with better sensor hardware, of course) is incredibly good at doing minute adjustments to brightness in order to improve visibility based on changes in ambient lighting. For me, personally, it's extremely rare to have to manually increase or decrease brightness, and this is on a 2021 phone.

@Spok1
Copy link
Author

Spok1 commented Jan 17, 2024

@Pentaphon

It's nice to never have to change brightness on newpipe. I wish every video player did it this way.

You apparently read between the lines! At the moment, the brightness for the system level is reset every 4 hours, so it will not be constant. The reset button is also the best option—no need to change it manually.

@opusforlife2

and this is on a 2021 phone.

Well, I’m extremely happy for you, but not everyone has gadgets from 2021 or newer. Not even everyone has models that are 3 years old.

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 GUI Issue is related to the graphical user interface
Projects
None yet
Development

No branches or pull requests

4 participants