LibreShift / red-moon

Android screen filter app for night time phone use.
GNU General Public License v3.0
650 stars 81 forks source link

Suport Android 4.0 too? (API level 15 instead of 17) #152

Closed guillaume-d closed 5 years ago

guillaume-d commented 7 years ago

Would you consider supporting Android 4.0 or is it too much work? Of course then I would "Help test Red Moon" (#146), including debug versions and prereleases.

Else would you accept pull requests for that? (Making no promises there...)

smichel17 commented 7 years ago

Not at a computer right now, so I'm working from a (spotty) memory right now.

I looked into this when I first looked at Red Moon's code. It's not an arbitrary; we are using some api that's only available on 17+. I decided at the time that I'd rather focus on adding features and polish than supporting an older api.

It's been a while and I'm not at a computer to check.. I think it might have been the animation api, for fading the filter on/off. That code used to be fairly integrated with other logic, but is now reasonably separate. It also might need to be refactored as part of #150 (soon), so that would be a good time to look into this.

I'll double cheek when I'm at a computer again.

smichel17 commented 7 years ago

Hmm. I tried lowering the minSdkVersion to 15 and nothing immediately broke at compile time. There are a few xml files that would need left and right attributes added in addition to start and end. This is still low priority to me compared to root mode and a couple other things, but I'll do it eventually, and would happily accept a pull request if you'd like it sooner.

guillaume-d commented 7 years ago

I am a novice in Android UI unfortunately so I would need quite some time to ramp up. If the app has a chance to be usable without the XML changes, I can give it a go if you can provide me a minSdkVersion=15 test APK (even unsigned). After all it might still crash at some point at runtime, so maybe it is worth checking that first.

smichel17 commented 7 years ago

I uploaded a debug version here. It's built from master with that one line changed. I suspect it'll work in LTR locales but not RTL.

If you wanted to learn Android UI, this might be the easiest place to start. Once you have the Android Sdk set up, all you need to do is clone the repo, lower the minSdk, and run ./gradlew build. That'll generate a file, $repo/app/build/reports/lint-results.html. One section of the file will tell you a bunch of places where you need to add attributes to support RTL locales on devices before API 17. The xml attributes are all SomethingSomething[Start/End] (eg, alignStart). You'd need to add (not replace) an additional attribute called SomethingSomething[Left/Right], with the exact same value.

It's pretty rote, most of the work is in testing to verify that it looks right. Probably only 1-2 hours total. I might end up getting to it myself some night when I'm too tired to really program but want to do something productive. I just haven't had very much spare time recently (hopefully more in the next two months) and if I have a spare 2 hours I have some other, higher priorities.

guillaume-d commented 7 years ago

I tested this debug version yesterday evening (English US locale). I think I saw all screens and popups in both portrait and landscape. The only bug I could find in this LTR locale is that the "Color temperature", ""Intensity level" and "Dim level" labels get painted over their respective percentages, because they both are left-aligned at approximately the same height. Is that a 4.0-only bug? (I could not test on another 4,4 device I have access to.)

Given how polished Red Moon's UI is, I am pleasantly suprprised it is also easy to understand! I am not sure I will find the time to setup the whole Android SDK. According to https://android-developers.googleblog.com/2013/03/native-rtl-support-in-android-42.html using the HierarchyViewer (with a 4.1+ device) from the Device Monitor (Installation) might be enough. If I can find the time I might try that or just search and replace the sources and then send you an (untested) PR to get a debug APK back.

In any case I can help with the visual inspection if you provide another debug APK. No problem with your current lack of time, I am in the same situation anyway. Just make sure the project stays fun for you.

smichel17 commented 7 years ago

When I get around to this, I think we might as well go back to API 14, since I don't think we're using anything from API 15, either. We are using PreferenceFragments, from the support library v14, so I have no intention of going lower than that.

Given how polished Red Moon's UI is, I am pleasantly suprprised it is also easy to understand!

Thanks :)

I am not sure I will find the time to setup the whole Android SDK.

It's not that much work, particularly if you are setting up Android Studio, which automates (almost) everything for you. Download, extract, run, click through the wizard.

martin3000 commented 6 years ago

I recompiled it for minSDK=14 because my device required it and it works perfectly. The only thing to pay attention to: android 4 does not understand signature v2, so you have to include signature v1 also.

smichel17 commented 6 years ago

All the filter code will work the same, yeah. The only parts that would break are the layout of the seekbar preferences, especially in RTL locales.

That's probably not a good enough reason to prevent people on those devices from using RM at all; I'll lower the minSdk for the next release and fix specific layout bugs as they are found.