Note: For a comprehensive explanation of everything in the library (including entry points and the library's API), please read the project's wiki here.
git clone git@github.com:Automattic/stories-android.git
in the folder of your preference.cd stories-android
to enter the working directory.cp gradle.properties-example gradle.properties
to set up the sample app properties file. Specifically, you can use stories.use.cameraX = true
to use the CameraX underlying implementation, or false
to use the Camera2 implementation (we recommend using CameraX and our plans are to eventually only stick to CameraX once it's stable)local.properties
with the SDK location.In order to integrate the stories library, you must include the following in your project:
implementation project(path: ':photoeditor')
implementation project(path: ':stories')
Implement these:
SnackbarProvider
call setSnackbarProvider()
as in the example Stories demo app.
MediaPickerProvider
call setMediaPickerProvider()
as in the example Stories demo app.
remember to override setupRequestCodes()
and set the right request codes as per the host app so it works seamlessly and media can be fed into the Composer by the externally provided MediaPicker.
The ComposeLoopFrameActivity super class will attempt to capture different Activity entry points such as onCreate()
(which is handled in the onLoadFromIntent()
override) or onActivityResult()
. As such, you'll be able to use the behavior by passing requestCode requestCodes.PHOTO_PICKER
and a combination of one of the following extras to trigger each of the modes the composer can be presented in:
providerHandlesMediaPickerResult()
returns false, these extra will consist of a list of media Uris that will be added each one as a new Story slide to the composer.In the Loop demo app, we initially trigger the camera capture mode for a new Story (you can try this by tapping on the FAB), and then rely on the PhotoPicker implementation to allow the user to keep adding pictures (note they can also trigger the capture mode from there as well). For an example of a using a different entry point for its initial state, you can check WordPress Android's StoryComposerActivity's handleMediaPickerIntentData()
method, given in this case the Media picker is presented first, and the Story composer is initialized later with the selected background media constituting one Story slide each.
Our code style guidelines are based on the Android Code Style Guidelines for Contributors. We only changed a few rules:
On top of the Android linter rules (best run for this project using ./gradlew lintRelease
), we use two linters: Checkstyle (for Java and some language-independent custom project rules), and ktlint (for Kotlin).
You can run checkstyle via a gradle command:
$ ./gradlew checkstyle
It generates an HTML report in app/build/reports/checkstyle/checkstyle.html
.
You can also view errors and warnings in realtime with the Checkstyle plugin. When importing the project into Android Studio, Checkstyle should be set up automatically. If it is not, follow the steps below.
You can install the CheckStyle-IDEA plugin in Android Studio here:
Android Studio > Preferences... > Plugins > CheckStyle-IDEA
Once installed, you can configure the plugin here:
Android Studio > Preferences... > Other Settings > Checkstyle
From there, add and enable the custom configuration file, located at config/checkstyle.xml.
You can run ktlint using ./gradlew ktlint
, and you can also run ./gradlew ktlintFormat
for auto-formatting. There is no IDEA plugin (like Checkstyle's) at this time.
The stories module and the Loop concept app are Open Source projects covered by the GNU General Public License version 2. Note: code in the mp4compose and photoeditor directories are covered by the MIT license.