Menu

Keep Screen On Implemented.

2022-12-16
2022-12-21
  • Andrew Williams

    Andrew Williams - 2022-12-16

    I've implemented WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON for keeping the screen turned on and bright.

    Works great on my phone (Android 9), requires testing but I don't foresee any problems as its a pretty simple thing.
    Looking forward to you feedback.

    Github

     
  • Ramiro  Prieto Alvarez

    Well, in fact in a previous post I planned to tell you that this option has already been implemented in AI2Offline, several versions ago.
    Anyway, thanks, and greetings from Mexico.

     
    • Andrew Williams

      Andrew Williams - 2022-12-17

      Wow, I did not notice that one. It's all good it all gets me more familiar with the code base.
      BTW, I just put the cleartextTrafficPermitted toggle in there this evening.

       
  • Ramiro  Prieto Alvarez

    I have this simple project, and it doesn't matter if the option is checked or not, the result is the same.

     
    • Andrew Williams

      Andrew Williams - 2022-12-17

      Ugh, Fixed and pushed typo. My brain camelCased clearText.

       
  • Ramiro  Prieto Alvarez

    hi andrew, there is an error in cleartext when compiling the companion, it is being set to false instead of true.

     
    • Andrew Williams

      Andrew Williams - 2022-12-21

      The problem as I'm seeing it is that cleartext is not a runtime option it can't be toggled at its an AndroidManifest.xml thing. Why its always false for the companion is because companion is just an AI2 app and what it does is actually make the method calls associated with whatever that component is (Form.class aka Screen1). So because the companion does not have the cleartextTrafficPermitted=true in its own properties file so at build time buildserver packages it with false.

      A quick fix would be to add the line: cleartextTrafficPermitted=True
      to appinventor-sources/appinventor/aiplayapp/youngandroidproject/project.properties run ant again to rebuild the companion app.

      However this is an option that will never be toggled with companion it just sets up the network_security_config.xml so I would just make sure companion gets built true and call it a day.
      I suppose I could put an isForCompanion check around it in the code. I'll do whichever

      Cheers!

       

      Last edit: Andrew Williams 2022-12-21

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.