Skip to main content

File injection tool for Android developers using MotionLayout. Use scenemerge to reuse ConstraintSet/KeyFrameSet/etc definitions in multiple MotionScenes via a templating system.

Project description

scenemerge

File injection tool to allow reuse of ConstraintSet/KeyFrameSet/etc definitions in multiple MotionScenes.

In your environment:

git clone https://github.com/motionscene-merger
python setup install

scenemerge .

Creating merge instructions

In your Android project res/xml directory:

  • Create a MotionScene file with content that you want to inject into some other file. The filename must start with _ e.g. res/xml/_my_injectable_motionscene.xml
  • Create a template for your parent MotionScene. Again, the filename must start with _ e.g. res/xml/_my_parent_motionscene.xml
    • add a line in this file with <inject src="source_filename"/> e.g:

          <?xml version="1.0" encoding="utf-8"?>
          <MotionScene
              xmlns:android="http://schemas.android.com/apk/res/android"
              xmlns:motion="http://schemas.android.com/apk/res-auto">
      
              <!-- Any other content here -->
      
              <inject src="my_injectable_motionscene"/>
      
              <!-- Any other content here -->
      
          </MotionScene>
      

Now when you run scenemerge the content from the MotionScene in _my_injectable_motionscene.xml will be copied in place into a new MotionScene file called my_parent_motionscene.xml in your res/xml directory. The <MotionScene...></MotionScene> tags will not be copied - only the content between them.

Please check the files in test/example_root_dir/res/inject for example source files.

Android Studio File Watcher

  • Install the File Watcher plugin for Android Studio via Settings -> Plugins.
  • Restart and open Settings -> Tools -> File Watchers, then click the + to create a new Watcher.
  • Set File type to XML.
  • Create a Scope with a pattern like file[app]:src/**/res/xml/_*.xml
  • Set Program to scenemerge in your environment. e.g. env/Scripts/scenemerge
  • Set Arguments to .
  • Set Working directoryto your app root.
  • OK

Now scenemerge should run automatically whenever you edit a res/xml/_YOUR_FILENAME.xml file, creating/updating the merged MotionScene file res/xml/YOUR_FILENAME.xml.

This project was written on a Sunday evening. It is unlikely to have any major updates but feel free to make pull requests or whatever. Hopefully MotionScene will someday have some kind built-in include/merge functionality and make this obsolete but this will have to do for now...

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

motionscene-merger-2.4.tar.gz (7.8 kB view details)

Uploaded Source

Built Distribution

motionscene_merger-2.4-py3-none-any.whl (19.2 kB view details)

Uploaded Python 3

File details

Details for the file motionscene-merger-2.4.tar.gz.

File metadata

  • Download URL: motionscene-merger-2.4.tar.gz
  • Upload date:
  • Size: 7.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/41.2.0 requests-toolbelt/0.9.1 tqdm/4.48.2 CPython/3.8.1

File hashes

Hashes for motionscene-merger-2.4.tar.gz
Algorithm Hash digest
SHA256 665ac460367021cd1bc74dd05605ef4c70a6a72950348bce0138790237bba2db
MD5 39c2704afee34873b1ed3e8e153ffb18
BLAKE2b-256 8603ae550d91b89764920e99f8ad01804f9211ac7af009c66b4e62147654091c

See more details on using hashes here.

Provenance

File details

Details for the file motionscene_merger-2.4-py3-none-any.whl.

File metadata

  • Download URL: motionscene_merger-2.4-py3-none-any.whl
  • Upload date:
  • Size: 19.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/41.2.0 requests-toolbelt/0.9.1 tqdm/4.48.2 CPython/3.8.1

File hashes

Hashes for motionscene_merger-2.4-py3-none-any.whl
Algorithm Hash digest
SHA256 31e4206d529bebe2704257080bdd071dda2ac8393c407f525f96d4536f00d923
MD5 fbb0dafe83ddc41358b9c92e8c457238
BLAKE2b-256 de5733e623eaae47d656676492a6197f45cc304fc7635957d12352855fd66cce

See more details on using hashes here.

Provenance

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page