Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Serialization part 1: implement kotlinx-serializable, use serialized AddedViews #414

Merged
merged 24 commits into from
Jul 19, 2020
Merged
Changes from 1 commit
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
2500285
setup kotlinx serialization plugin
mzorz Jul 2, 2020
c25f9cd
added @Serializable annotations, changed AddedViewList constructor to…
mzorz Jul 2, 2020
b855ea6
implemented serializer/deserializer and added AddedViewInfo structure…
mzorz Jul 3, 2020
9687731
Merge branch 'feature/wp-stories/alpha1-cut' into issue/393-keep-state
mzorz Jul 4, 2020
ce53d6a
added update() method to update AddedViewInfo when it's saved
mzorz Jul 4, 2020
9af1b21
removed custom serializer, fixed bad import preventing View from bein…
mzorz Jul 5, 2020
5531659
using ArrayListSerializer for AddedViewList
mzorz Jul 6, 2020
9d4867c
made changes so added views can be either referenced (rememberd) or r…
mzorz Jul 6, 2020
8065985
added AddedViewTextInfo class to hold information inherent to TextVie…
mzorz Jul 6, 2020
f76a380
fixed lint warnings
mzorz Jul 6, 2020
97cf627
removed commented code line
mzorz Jul 6, 2020
5c8a3d8
clarified comment
mzorz Jul 6, 2020
a12891c
only trigger the texteditor if view is a new addition (not a re-add f…
mzorz Jul 6, 2020
e557194
using the actual calculated value in px for fontSize
mzorz Jul 6, 2020
f98e5bd
modified test log comment
mzorz Jul 6, 2020
402b9ba
renamed method
mzorz Jul 6, 2020
ef642bb
updated proguard rules to keep serializer classes
mzorz Jul 7, 2020
6ee2f54
removed test code
mzorz Jul 7, 2020
53c04cf
removed unused imports
mzorz Jul 7, 2020
3713a9b
renamed param
mzorz Jul 8, 2020
aed3634
renamed variable
mzorz Jul 17, 2020
8e84597
simplified fun expression with assignment
mzorz Jul 17, 2020
4492f53
renamed iterator temporal variable name for clarity
mzorz Jul 17, 2020
7a65da2
returning assignment in when statement itself
mzorz Jul 17, 2020
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
added @serializable annotations, changed AddedViewList constructor to…
… make it Serializable
mzorz committed Jul 2, 2020
commit c25f9cd92eba646978a82d0c61de61e73e2d38bc
Original file line number Diff line number Diff line change
@@ -3,12 +3,15 @@ package com.automattic.photoeditor.views.added
import android.view.View
import com.automattic.photoeditor.views.ViewType
import java.util.ArrayList
import kotlinx.serialization.Serializable

class AddedViewList(addedViewList: AddedViewList? = null) : ArrayList<AddedView>() {
init {
addedViewList?.let {
@Serializable
class AddedViewList : ArrayList<AddedView>() {
fun copyOf(addedViewList: AddedViewList): AddedViewList {
addedViewList.let {
addAll(it)
}
return this
}

fun containsView(element: View): Boolean {
Original file line number Diff line number Diff line change
@@ -1059,7 +1059,7 @@ abstract class ComposeLoopFrameActivity : AppCompatActivity(), OnStoryFrameSelec
}

// set addedViews on the current frame (copy array so we don't share the same one with PhotoEditor)
currentStoryFrameItem?.addedViews = AddedViewList(photoEditor.getViewsAdded())
currentStoryFrameItem?.addedViews = AddedViewList().copyOf(photoEditor.getViewsAdded())
}

private fun showMediaPicker() {
Original file line number Diff line number Diff line change
@@ -24,6 +24,7 @@ class StorySaveEvents {
@Parcelize
data class FrameSaveResult(val frameIndex: FrameIndex, val resultReason: SaveResultReason) : Parcelable

@kotlinx.serialization.Serializable
sealed class SaveResultReason : Parcelable {
@Parcelize
object SaveSuccess : SaveResultReason()
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
package com.wordpress.stories.compose.story

import kotlinx.serialization.Serializable

@Serializable
data class Story(val frames: ArrayList<StoryFrameItem>, var title: String? = null)
Original file line number Diff line number Diff line change
@@ -5,15 +5,20 @@ import com.automattic.photoeditor.views.added.AddedViewList
import com.wordpress.stories.compose.frame.StorySaveEvents.SaveResultReason
import com.wordpress.stories.compose.frame.StorySaveEvents.SaveResultReason.SaveSuccess
import com.wordpress.stories.compose.story.StoryFrameItemType.IMAGE
import kotlinx.serialization.ContextualSerialization
import kotlinx.serialization.Serializable
import java.io.File

@Serializable
data class StoryFrameItem(
val source: BackgroundSource,
val frameItemType: StoryFrameItemType = IMAGE,
var addedViews: AddedViewList = AddedViewList(),
var saveResultReason: SaveResultReason = SaveSuccess,
@ContextualSerialization
var composedFrameFile: File? = null
) {
@Serializable
sealed class BackgroundSource {
data class UriBackgroundSource(var contentUri: Uri? = null) : BackgroundSource()
data class FileBackgroundSource(var file: File? = null) : BackgroundSource()
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
package com.wordpress.stories.compose.story

import kotlinx.serialization.Serializable

@Serializable
sealed class StoryFrameItemType {
fun isSameType(second: StoryFrameItemType): Boolean {
return this::class == second::class