mplekunov / CalculatorApp

GNU General Public License v3.0
1 stars 0 forks source link

Settings Menu #36

Open mplekunov opened 2 years ago

mplekunov commented 2 years ago

As title suggests.... I need a settings Menu.

Things I want to see in Settings:

Input: (Preference Category)

Output: (Same as in Input)

(For both states... When enabled and when disabled) (Preference Category) (Same as for Input/Output Color)

Editing Mode: (Preference Category) (Same as for Input/Output Color)

mplekunov commented 2 years ago

Wrote settings layout, configured navcontroller/toolbar, created color picker layout....

mplekunov commented 2 years ago

All works EXCEPT COLOR PICKER... Literally spent 4 hours trying to google my way through but I CAN"T FIGURE OUT WHY IT"S NOT BEING INFLATED..... I'm tired... that's it for today.

mplekunov commented 2 years ago

NVM... It looks like IT IS BEING INFLATED

mplekunov commented 2 years ago

BUT.... It's not showing for some reason...

mplekunov commented 2 years ago

Tomorrow me... good luck with that

mplekunov commented 2 years ago

Should have slept more yesterday.... I forgot to return root of inflated view from the onCreateView of the fragment I wanted to inflate....

mplekunov commented 2 years ago

So... So far I'm on the right way. I can write/read to/from preference instance.

Next thing would be to change hard coded values in clickable and etc to values that I would receive from preference

mplekunov commented 2 years ago

Long story short... I changed some stuff... Everything worked.. I was already ready to push it but I wanted to clean up my code a bit... and I broke something and nothing works anymore...

I can't save preferences for some reason....

In fact, it saves them.... HOWEVER, when I try to access them I get the default value... The log.d shows as it was saved....

mplekunov commented 2 years ago

I think I now what the problem is... getSharedPreferance takes name as one of it's argument.... And the thing is, that is the name of the preference not of the preference key...

mplekunov commented 2 years ago

New problem... I want to have a custom preference so I would be able to change the color of the button depending on the color stored in the preference... For that I would need to update the foreground of the button when the PreferenceFragmentCompat's view are generated...

The Problem: I can't do that... There is simply no access to the button UNTIL everything was generated... It can't be done in "onCreate, onCreateView, onViewCreate, onSetPreferences, onStart, onResume".... The problem is that it generates button somewhere else... and I can't have an access to the method where it's being generated.... I can setup listeners to preferences and stuff... but I can't access their widgets (unless I call them inside of listeners)...

The Solution: The common workaround is to create a custom Preference and use it instead... However, I simply can't wrap my head around how to do that... Documentation says that I have to have 3 views -> widget_frame, title, summary inside of my custom xml... and I have to call setLayoutResources on that xml inside of my custom Preference class so it would "inflate" it... StackOverflow says the same thing... However I can't make it work.... I can't figure out what exactly is wrong but it's not rendering in preview of android studio and it is not being inflated when u open settings....

That's literally the last thing I have to implement to complete my settings... Everything else works... I can change colors inside of settings... Problem with PreferenceManager is solved.... ONLY THIS THING DOESN"T WORK NO MATTER WHAT I DO...

Very annoyed... I've been being in this stalemate for about 4h now... no idea what to do... I SHOULD be able to create my custom Preference....

mplekunov commented 2 years ago

I got covid... Development will take longer time than expected. Version 3.0 is incoming. Will support color change - Oled Black theme in night mode. Both Night/Day Themes. Custom Toolbar. Rewritten logic for Editing Mode and stuff like that

mplekunov commented 2 years ago

Still alive... brain doesn't really want to work so it will take a while... Have to push an update by the end of the week