Skip to content

Commit

Permalink
Update README.md
Browse files Browse the repository at this point in the history
  • Loading branch information
mzorz authored May 14, 2021
1 parent 8866392 commit 417afd8
Showing 1 changed file with 37 additions and 36 deletions.
73 changes: 37 additions & 36 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,41 @@
# stories-android
Stories concept app

WordPress stories library
## The Stories library

**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](https://github.com/Automattic/stories-android/wiki).

## Build Instructions ##

1. Make sure you've installed [Android Studio](https://developer.android.com/studio/index.html).
1. `git clone [email protected]:Automattic/stories-android.git` in the folder of your preference.
1. `cd stories-android` to enter the working directory.
1. `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)
1. In Android Studio, open the project from the local repository. This will auto-generate `local.properties` with the SDK location.
1. Go to Tools → AVD Manager and create an emulated device.
1. Run.


### Getting started
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.

### Entry points
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:
- EXTRA_MEDIA_URIS: if `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.
- EXTRA_LAUNCH_WPSTORIES_CAMERA_REQUESTED: if the previous extra is not present and this extra is passed, then the camera capture mode will be presented, and the user will then have the ability to capture a still image or a video, which will be added to their Story as a new slide.

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](https://github.com/wordpress-mobile/WordPress-Android/blob/develop/WordPress/src/main/java/org/wordpress/android/ui/stories/StoryComposerActivity.kt)'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.


# Code style

Expand Down Expand Up @@ -38,39 +72,6 @@ From there, add and enable the custom configuration file, located at [config/che

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 library

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.

### Entry points
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:
- EXTRA_MEDIA_URIS: if `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.
- EXTRA_LAUNCH_WPSTORIES_CAMERA_REQUESTED: if the previous extra is not present and this extra is passed, then the camera capture mode will be presented, and the user will then have the ability to capture a still image or a video, which will be added to their Story as a new slide.

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](https://github.com/wordpress-mobile/WordPress-Android/blob/develop/WordPress/src/main/java/org/wordpress/android/ui/stories/StoryComposerActivity.kt)'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.

## Build Instructions ##

1. Make sure you've installed [Android Studio](https://developer.android.com/studio/index.html).
1. `git clone [email protected]:Automattic/stories-android.git` in the folder of your preference.
1. `cd stories-android` to enter the working directory.
1. `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
1. In Android Studio, open the project from the local repository. This will auto-generate `local.properties` with the SDK location.
1. Go to Tools → AVD Manager and create an emulated device.
1. Run.

## License ##

The stories module and the Loop concept app are Open Source projects covered by the
Expand Down

0 comments on commit 417afd8

Please sign in to comment.