Skip to content

Commit

Permalink
README: Update most important code blocks in kotlin
Browse files Browse the repository at this point in the history
  • Loading branch information
benju69 authored and burhanrashid52 committed Jul 23, 2024
1 parent 3f6fb17 commit 3527722
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 17 deletions.
28 changes: 13 additions & 15 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -68,29 +68,27 @@ First we need to add `PhotoEditorView` in our xml layout
We can define our drawable or color resource directly using `app:photo_src`

We can set the image programmatically by getting source from `PhotoEditorView` which will return a `ImageView` so that we can load image from resources,file or (Picasso/Glide)
```java
PhotoEditorView mPhotoEditorView = findViewById(R.id.photoEditorView);
```kotlin
mPhotoEditorView = findViewById(R.id.photoEditorView)

mPhotoEditorView.getSource().setImageResource(R.drawable.got);
mPhotoEditorView.source.setImageResource(R.drawable.paris_tower)
```

## Building a PhotoEditor
To use the image editing feature we need to build a PhotoEditor which requires a Context and PhotoEditorView which we have to setup in our xml layout


```java
```Kotlin
//Use custom font using latest support library
Typeface mTextRobotoTf = ResourcesCompat.getFont(this, R.font.roboto_medium);

val mTextRobotoTf = ResourcesCompat.getFont(this, R.font.roboto_medium)
//loading font from asset
Typeface mEmojiTypeFace = Typeface.createFromAsset(getAssets(), "emojione-android.ttf");

mPhotoEditor = new PhotoEditor.Builder(this, mPhotoEditorView)
.setPinchTextScalable(true)
.setClipSourceImage(true)
.setDefaultTextTypeface(mTextRobotoTf)
.setDefaultEmojiTypeface(mEmojiTypeFace)
.build();
val mEmojiTypeFace = Typeface.createFromAsset(getAssets(), "emojione-android.ttf")

mPhotoEditor = PhotoEditor.Builder(this, mPhotoEditorView)
.setPinchTextScalable(pinchTextScalable) // set flag to make text scalable when pinch
.setDefaultTextTypeface(mTextRobotoTf)
.setDefaultEmojiTypeface(mEmojiTypeFace)
.build() // build photo editor sdk
```
We can customize the properties in the PhotoEditor as per our requirement

Expand Down Expand Up @@ -139,7 +137,7 @@ For more details check [ShapeBuilder](https://github.com/burhanrashid52/PhotoEdi
## Filter Effect
We can apply inbuild filter to the source images using

`mPhotoEditor.setFilterEffect(PhotoFilter.BRIGHTNESS);`
`mPhotoEditor.setFilterEffect(PhotoFilter.BRIGHTNESS)`

![](https://i.imgur.com/xXTGcVC.gif)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -110,8 +110,8 @@ class EditImageActivity : BaseActivity(), OnPhotoEditorListener, View.OnClickLis
// NOTE(lucianocheng): Used to set integration testing parameters to PhotoEditor
val pinchTextScalable = intent.getBooleanExtra(PINCH_TEXT_SCALABLE_INTENT_KEY, true)

//Typeface mTextRobotoTf = ResourcesCompat.getFont(this, R.font.roboto_medium);
//Typeface mEmojiTypeFace = Typeface.createFromAsset(getAssets(), "emojione-android.ttf");
// val mTextRobotoTf = ResourcesCompat.getFont(this, R.font.roboto_medium)
// val mEmojiTypeFace = Typeface.createFromAsset(getAssets(), "emojione-android.ttf")

mPhotoEditor = PhotoEditor.Builder(this, mPhotoEditorView)
.setPinchTextScalable(pinchTextScalable) // set flag to make text scalable when pinch
Expand Down

0 comments on commit 3527722

Please sign in to comment.