https://kotlinlang.org logo
#compose
Title
# compose
o

orangy

06/04/2021, 11:25 PM
I’ve got Sony TV which runs Google TV (which is still Android TV afaik), so is it possible to run Compose on it? :) or may be #compose-desktop fits better? Did anyone try it already?
a

Adam Powell

06/04/2021, 11:26 PM
shouldn't be anything stopping it 🙂 I've got what I think is a 2015 Bravia in the other room that I haven't tried running compose stuff on yet
the biggest hurdle is that some of the 5-way focus traversal stuff has been landing fairly recently
I think a bunch of that should be there in beta08?
o

orangy

06/04/2021, 11:28 PM
I have whole weekend ahead of me :) gonna try it :)
But I still have to deal with Android views and such, right? Can’t have just Window as in desktop compose?
a

Adam Powell

06/04/2021, 11:33 PM
I am very interested to hear how it goes 😄 I think if I started playing with the living room TV too much I'd risk the ire of my wife and kids
😂 2
should be able to start with
ComponentActivity.setContent {}
1
so just about as analogous as it gets to starting from Window
o

orangy

06/04/2021, 11:35 PM
Never did anything Android, sorry :)) will Google it tomorrow
a

Adam Powell

06/04/2021, 11:35 PM
Copy code
class MyTvActivity : ComponentActivity() {
  override fun onCreate(savedInstanceState: Bundle?) {
    super.onCreate(savedInstanceState)
    setContent {
      ComposeStuff()
    }
  }
}
that's about it
the android studio new project wizard with compose for the Arctic Fox beta or newer should generate that plus some other theming stuff you'll likely discard for you
o

orangy

06/04/2021, 11:36 PM
Thanks! Will report back here in thread on how it goes
👍 1
I doubt there is ready-made wizard for compose and TV :)
c

Colton Idle

06/04/2021, 11:38 PM
Ooooh 5 point directional stuff landed in beta08? Gotta try to find those commits. I didn't think that was coming in 1.0
o

orangy

06/04/2021, 11:42 PM
Any ideas on what I could build for TV? Besides weather :)
a

Adam Powell

06/04/2021, 11:43 PM
@Colton Idle don't quote me on that, I know it's been coming in but I'm not sure which side of that build cut it landed on
c

Colton Idle

06/04/2021, 11:43 PM
#compose-desktop had a few games that you could pretty easily pretty I would think.
@Adam Powell any way to find out? Maybe I'll search issue tracker.
o

orangy

06/04/2021, 11:44 PM
Oh, right. Tetris using remote :))
a

Adam Powell

06/04/2021, 11:45 PM
@orangy last time I wrote a hobby android tv app I used leanback to write a snes emulator frontend; a bunch of the emulators on play store are pretty good at accepting
ACTION_VIEW
intents pointing at roms on shared storage 🙂
o

orangy

06/04/2021, 11:46 PM
Adam, it doesn’t sound like a weekend project :)
😄 2
a

Arkadii Ivanov

06/04/2021, 11:57 PM
Try porting CompoSnake https://github.com/arkivanov/CompoSnake 🤭
🆗 2
☝️ 4
o

orangy

06/05/2021, 11:56 AM
❤️ 3
👍 2
K 5
It plays just nice with a remote d-pad 🙂
a

Arkadii Ivanov

06/05/2021, 12:04 PM
This is super cool! Originally I wrote CompoSnake for desktop, then it was ported to web (https://github.com/Foso/compose-snake-web) by @Foso, and now it is running on TV! Are you going to open source it?
o

orangy

06/05/2021, 12:06 PM
There is nothing to open source 🙂 I made only a single bit of change – replaced Window main with ComponentActivity, as @Adam Powell wrote above. It just works out of the box 🙂
🦜 2
K 2
c

Colton Idle

06/05/2021, 2:02 PM
I'm surprised it just works. I thought d-pad wouldn't work.
o

orangy

06/05/2021, 2:07 PM
Note, that this particular game doesn’t have any focusable controls, so it is just handling
KEYCODE_DPAD_LEFT
to control the snake. I will try more “traditional” app later today or tomorrow
👍 2
7 Views