WirelessAlien / BhagavadGitaApp

A Simple Open-source Android App for Bhagavad Gita
GNU General Public License v3.0
56 stars 8 forks source link

Theme states are not preserved #15

Closed shubhamnanche closed 11 months ago

shubhamnanche commented 12 months ago

Description When I open the app for the first time after installing it, it opens with the Light Theme as the default theme selected. Although, it is the Light Theme that is displayed in the selection, the actual app theme is the one that is selected in the system-wide android theme mode in the android settings, which shouldn't be the case. Let's say I my device theme is "Dark Theme" (for android 10+), and I am opening the app for the first time, the app opens in dark mode because of this issue, now I change the app theme to Dark Theme, nothing happens as it is already in the dark mode, and I again change it to Light Theme, this time the app changes to light theme. Now, I close the app and remove it from the background (recents menu) as well, and I reopen the app, the expected behavior is the app must open in Light Theme, but instead it follows the android's system-wide theme mode.

To Reproduce Steps to reproduce the behavior:

  1. Install the app fresh (and keep your android's system theme as dark)
  2. Open the app and go to the theme's menu (it shows Light Theme as selected)
  3. Change the theme to Dark Theme and back to Light Theme
  4. Close the app and remove it from the recents menu
  5. Reopen the app and it will show Light Theme, although the app is still displaying in dark mode

Expected behavior The app should always be displayed in the theme that is shown as selected in the theme's alert dialog.

WirelessAlien commented 12 months ago

I am actually aware of the problems with theme change. To apply only light & dark theme easy, but the way the black theme was applied was not a great way. I will have to change the theme change method.

shubhamnanche commented 11 months ago

Your shared preferences tags are cluttered... Have you tried making a single class holding all the sharedpref tags in one place? That way, you'll get the exact string you need to get their values and it'll be more organised. I am trying to correct the way black, light and dark themes were implemented. Let me see what works well.

WirelessAlien commented 11 months ago

Your shared preferences tags are cluttered... Have you tried making a single class holding all the sharedpref tags in one place?

I have not tried only thought about it later (like- If I can manage time maybe I will do it 🙂) That way, you'll get the exact string you need to get their values and it'll be more organised.

Yeah, that's true. I am trying to correct the way black, light and dark themes were implemented. Let me see what works well.

👍

shubhamnanche commented 11 months ago

I have fixed light, dark and black theme modes on your app. I removed the change theme function to be invoked from radio button clicks to the positive button click of the dialog box (dialog fragment). But there are minute errors that I am able to see - the option menu items are not recreated and retain their previous mode's color, meaning let's say you have switched from light to black mode, when the app was in light mode, the menu items color was black, not it should have changed to white, right? But that doesn't happen. Weird behaviour... will have to dig deep into it to find out why that happens.

I'll create a PR once I am convinced with my solution :) Hope that will be accepted by you.