Proteus


Source link: https://github.com/flipkart-incubator/proteus

: Android Layout Engine

Proteus is meant to be a drop-in replacement for Android’s LayoutInflater; but unlike the compiled XML layouts bundled in the APK, Proteus inflates layouts at runtime. With Proteus, you can control your Apps layout from the backend (no WebViews). Forget the boilerplate code to findViewById, cast it to a TextView, and then setText(). Proteus has runtime data bindings and formatters. Plugin in your own custom views and attributes and functions.

Getting Started

gradle

// Add it in your root build.gradle at the end of repositories: allprojects {
  repositories {

...
maven {
 url "https://jitpack.io" 
}
  
}
 
}
  // Add the dependency dependencies {
         compile 'com.github.flipkart-incubator:proteus-core:5.0.0-rc11@aar'         compile 'com.github.flipkart-incubator:gson-adapter:5.0.0-rc11@aar' 
}

include as a module

  • Clone the proteus in the project folder
git clone https://github.com/flipkart-incubator/proteus.git
  • Include the a project in you apps build.gradle file
dependencies {

compile project('proteus:proteus-core')
compile project('proteus:gson-adapter') 
}

How it works

Instead of writing layouts in XML, in proteus layouts are described in JSON, which can be used to inflate native Android UI at runtime. The JSON layouts can be hosted anywhere (on the device, on servers, etc.).

The Layout defines the the view heirarchy, just like XML.

The Data (optional) defines data bindings. These data bindings are similar to Android's Data Binding library.

Give the layout and data to ProteusLayoutInflater and get back a native view hierarchy.

Watch this video to see it in action.

Sample layout

{

"type": "LinearLayout",
"orientation": "vertical",
"padding": "16dp",
"children": [{

  "layout_width": "200dp",
  "gravity": "center",
  "type": "TextView",
  "text": "@{
user.profile.name
}
"

}
, {

  "type": "HorizontalProgressBar",
  "layout_width": "200dp",
  "layout_marginTop": "8dp",
  "max": 6000,
  "progress": "@{
user.profile.experience
}
"

}
] 
}

Sample data

{

"user": {

  "profile": {

 "name": "John Doe",

 "experience": 4192
  
}

}
 
}

Sample Java code

ProteusView view = proteusLayoutInflater.inflate(<layout>, <data>);
 container.addView(view.getAsView());

Output

Setting up the Demo App

The demo app will let you play around with proteus as well as help you understand the internals better.

  • Install NodeJS here
  • open a terminal
  • cd into the project directory
  • run npm start
  • Start an AVD emulator
  • Install the Demo App

Ready to tinker

  • Tinker around with the layout and data
  • Hit the FAB to refresh the app.

Resources

Contributing

How?

The easiest way to contribute is by forking the repo, making your changes and creating a pull request.

What?

  • Adding new Views and Attribute Proccessors.
  • Adding new Functions.
  • Adding JavaDoc and Wiki.
  • Completing TODOs
  • Writing unit tests.
  • Finding bugs and issues. (submit here)
  • Fixing bugs and issues.
  • Implement performance/benchmarking tools.

License

Apache v2.0

If you are using proteus check out the can, cannot and must

Contributors

You can check out the contributors here, but if you wish to contact us; just drop in a mail.

StackOverflow

Find us on StackOverflow at proteus.

Plugins

One click XML to JSON conversion plugin

Download this plugin (in beta) for Android Studio. Once enabled, you can select any android XML resource file and go to Tools > Proteus > Convert XML to JSON

Resources

JUniversal makes Java truly cross platform

Writing the same code from scratch for every platform is a pain & inefficient. There must be a better way. JUniversal lets you write code in Java (like you probably already do if you develop for Android) and take that code to places you never thought it could go. It’s primarily targeted to sharing code across mobile apps, but the technology can extend to non-mobile scenarios as well.

View for locking and unlocking.

This library provide syncing of SharedPreferences between handheld and wearable.

An Android View widget for displaying GIF animations.

socialize-sdk-android is an Android social sharing SDK for native apps.

Official site: www.getsocialize.com

RushOrm replaces the need for SQL by mapping java classes to SQL tables.

Core features:

  • Custom fields - easily implement custom fields so that any object can be serialized to the database
  • Relationships:
    • One to one
    • One to many, save lists of children
    • Saving a parent object automatically saves it children
  • Files - easily store long text, JSON and bitmaps
  • Upgrading - database upgrading is supported through annotations removing the need for upgrade scripts

Topics


2D Engines   3D Engines   9-Patch   Action Bars   Activities   ADB   Advertisements   Analytics   Animations   ANR   AOP   API   APK   APT   Architecture   Audio   Autocomplete   Background Processing   Backward Compatibility   Badges   Bar Codes   Benchmarking   Bitmaps   Bluetooth   Blur Effects   Bread Crumbs   BRMS   Browser Extensions   Build Systems   Bundles   Buttons   Caching   Camera   Canvas   Cards   Carousels   Changelog   Checkboxes   Cloud Storages   Color Analysis   Color Pickers   Colors   Comet/Push   Compass Sensors   Conferences   Content Providers   Continuous Integration   Crash Reports   Credit Cards   Credits   CSV   Curl/Flip   Data Binding   Data Generators   Data Structures   Database   Database Browsers   Date &   Debugging   Decompilers   Deep Links   Dependency Injections   Design   Design Patterns   Dex   Dialogs   Distributed Computing   Distribution Platforms   Download Managers   Drawables   Emoji   Emulators   EPUB   Equalizers &   Event Buses   Exception Handling   Face Recognition   Feedback &   File System   File/Directory   Fingerprint   Floating Action   Fonts   Forms   Fragments   FRP   FSM   Functional Programming   Gamepads   Games   Geocaching   Gestures   GIF   Glow Pad   Gradle Plugins   Graphics   Grid Views   Highlighting   HTML   HTTP Mocking   Icons   IDE   IDE Plugins   Image Croppers   Image Loaders   Image Pickers   Image Processing   Image Views   Instrumentation   Intents   Job Schedulers   JSON   Keyboard   Kotlin   Layouts   Library Demos   List View   List Views   Localization   Location   Lock Patterns   Logcat   Logging   Mails   Maps   Markdown   Mathematics   Maven Plugins   MBaaS   Media   Menus   Messaging   MIME   Mobile Web   Native Image   Navigation   NDK   Networking   NFC   NoSQL   Number Pickers   OAuth   Object Mocking   OCR Engines   OpenGL   ORM   Other Pickers   Parallax List   Parcelables   Particle Systems   Password Inputs   PDF   Permissions   Physics Engines   Platforms   Plugin Frameworks   Preferences   Progress Indicators   ProGuard   Properties   Protocol Buffer   Pull To   Purchases   Push/Pull   QR Codes   Quick Return   Radio Buttons   Range Bars   Ratings   Recycler Views   Resources   REST   Ripple Effects   RSS   Screenshots   Scripting   Scroll Views   SDK   Search Inputs   Security   Sensors   Services   Showcase Views   Signatures   Sliding Panels   Snackbars   SOAP   Social Networks   Spannable   Spinners   Splash Screens   SSH   Static Analysis   Status Bars   Styling   SVG   System   Tags   Task Managers   TDD &   Template Engines   Testing   Testing Tools   Text Formatting   Text Views   Text Watchers   Text-to   Toasts   Toolkits For   Tools   Tooltips   Trainings   TV   Twitter   Updaters   USB   User Stories   Utils   Validation   Video   View Adapters   View Pagers   Views   Watch Face   Wearable Data   Wearables   Weather   Web Tools   Web Views   WebRTC   WebSockets   Wheel Widgets   Wi-Fi   Widgets   Windows   Wizards   XML   XMPP   YAML   ZIP Codes