• Stars
    star
    672
  • Rank 67,180 (Top 2 %)
  • Language
    Kotlin
  • License
    Apache License 2.0
  • Created about 4 years ago
  • Updated over 1 year ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

recompose is a tool for converting Android layouts in XML to Kotlin code using Jetpack Compose.

recompose

recompose is a tool for converting Android layouts in XML to Kotlin code using Jetpack Compose. It can be used on the command line, as IntelliJ / Android Studio plugin or as a library in custom code.

Running

IntelliJ / Android Studio plugin

The plugin does not get published yet. If you want to try them then you'll have to build them from code. Use the Gradle task runIde to run a test IDE with the plugin installed or create an installable plugin with the buildPlugin task. The plugin zip will be placed in recompose-idea/build/distributions/. To learn how to install it, read the Install plugin from disk section in the IntelliJ docs.

Command-line interface (CLI)

Like the plugin, the command-line interface does not get published yet. You can run it directly from Gradle via ./gradlew recompose-cli:run --args="list file paths..". Alternatively you can run the assembleDist which will place a zip/tar containing a binary into recompose-cli/build/distributions/.

Usage: recompose [OPTIONS] INPUT...

Options:
  -o, --output PATH  Output directory for Kotlin code
  -h, --help         Show this message and exit

Arguments:
  INPUT  Layout XML files to convert to Kotlin

Building

Either import the project into IntelliJ IDEA or use Gradle on the command line (via the provided gradlew wrapper).

Modules

  • recompose-ast: Contains the data classes for the Abstract Syntax Tree (AST) representing a parsed XML layout.
  • recompose-cli: A command-line interface (CLI) for running recompose in a shell.
  • recompose-composer: Responsible for taking an AST and transforming it into the equivalent Composable Kotlin code.
  • recompose-idea: An IntelliJ IDEA / Android Studio plugin that allows copying XML layouts and pasting as Composable Kotlin code.
  • recompose-test: Contains test data and helpers for unit tests.

Important gradle tasks

  • clean: Deletes the build directories.
  • test: Runs all unit tests in all modules.
  • runIde: Runs IntelliJ IDEA with the plugin installed.
  • buildPlugin: Builds the IntelliJ / Android Studio plugin and makes it available in recompose-idea/build/distributions.

How does this work?

The Parser (recompose-parser) takes the input XML and transforms it into an Abstract Syntax Tree (recompose-ast). The Composer (recompose-composer) takes the AST and translates it into Kotlin code calling Composables.

The IntelliJ / Android Studio plugin (recompose-idea) uses that to perform the translation when pasting copied XML code. And the CLI (recompose-cli) uses it to translate files.

Can I contribute?

Yes, absolutely. There are a ton of Views and attributes to support. The list of issues labeled with good first issue are a good place to start. An issue from the list labeled with help wanted may be a good follow-up. Just comment on any issue that interests you.

License

Copyright 2020 Sebastian Kaspari

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.

More Repositories

1

Android-Network-Intents

Android Network Intents (ANI) is a library to send Android Intent objects to listening apps/devices via multicast (UDP).
Java
422
star
2

Yaaic

Yaaic (Yet Another Android IRC Client) is as the name already says an Internet Relay Chat (IRC) client for Android devices.
Java
327
star
3

SensorDashboard

A sensor dashboard for Android plotting all sensor data of your Android wearable.
Java
237
star
4

Python-Brainfuck

Just a small Brainfuck interpreter written in Python
Python
197
star
5

Instant-Mustache

Instant Mustache is a fun app that utilizes the face tracking feature of Android 4.x to add mustaches to all detected faces currently visible to the camera. Users are able to take funny pictures and share them with their friends on social networks or other apps.
Java
90
star
6

DashWatch

DashClock extensions for your Android wear device
Java
20
star
7

AndroidSDKSearchExtension-Firefox

A Firefox port of the Chrome extension that adds an 'ad' Awesome Bar command and view source links for the Android SDK.
JavaScript
19
star
8

iceant

Ice Ant is an Android browser that we code live on Twitch!
Kotlin
17
star
9

Ruby-Brainfuck

Just a small and hopefully fast Brainfuck interpreter written in Ruby
Ruby
13
star
10

AndEngine-ParticleSystem-Demos

Demo of the AndEngine particle system.
Java
10
star
11

Graylog-Android

Android client for Graylog (a rsyslog web interface) - This client is for Graylog 1 which is discontinued but it still may be a simple example for an Android client using a REST API.
Java
9
star
12

Android-Zeitgeist-Samples

Various sample code related to articles published on Android Zeitgeist.
Java
8
star
13

Just-Open-My-Browser

Just-Open-My-Browser is an Android app that pretends to implement custom tabs but actually just opens your favorite browser.
Java
6
star
14

MaterialFennecPrototype

Prototyping a Fennec version with a more "Material" look&feel
Java
5
star
15

scopeport-web-interface

The ScopePort Web Interface
Ruby
4
star
16

Spring-o-Bot

The Spring-o-Bot Framework is a Java Framework to control iRobot Create robots via the Open Interface.
Java
4
star
17

Graylog1-Backup

A rsyslog web interface based on Ruby On Rails - This is the old Graylog1. You probably want Graylog2 from graylog2.org.
Ruby
4
star
18

KeyCode

A simple Android application to show the KeyCode of the pressed keys.
Java
3
star
19

Featurizer

An Android library for extracting features (title, icon, image, ...) from a website / URL.
HTML
3
star
20

AdventOfCode2021

My solutions to the Advent of Code 2021 puzzles - in Kotlin. You can follow along on YouTube.
Kotlin
2
star
21

GGame

GGame is an IRC-Game where you have to get the most google search results
Java
2
star
22

Fennec-DLC-Catalog

Script for creating and updating the catalog of Fennec's downloadable content (DLC) in Kinto
Python
2
star
23

scopeport-server-backup

Backup of the ScopePort server
C++
2
star
24

WebCards

Cards. Cards everywhere.
Java
2
star
25

Addon-Switchboard-Experiments

Firefox for Android add-on to add a panel to your home screen listing switchboard experiments you are enrolled in.
JavaScript
2
star
26

BrowserPartner

A sample/test application with a PartnerBookmarksProvider and PartnerBrowserCustomizationsProvider implementation with test data.
Java
1
star
27

pocmo-configs

My config files for vim, bash, ..
Vim Script
1
star
28

CCMusic

Downloader for free and creative commons music (Using Ruby and MongoDB)
Ruby
1
star
29

fennec-graveyard

A backup of the mobile Firefox code (Fennec) before we started ripping it out of mozilla-central
Java
1
star
30

my-mozilla-patches

I do not updates this anymore - This is just a repository of my Mozilla patches for keeping track of them
1
star
31

Dummy-Android

A dummy Android project for testing third-party tooling and services
Kotlin
1
star
32

jekyll-github-playground

Playground for testing GitHub hosting and Jekyll
1
star
33

Rust-Brainfuck

A brainfuck interpreter written in Rust.
Rust
1
star