Skip to content

Commit

Permalink
Merge branch 'task/purge_stories' into develop
Browse files Browse the repository at this point in the history
  • Loading branch information
MrHadiSatrio authored Jan 5, 2025
2 parents 77be196 + 8080ca1 commit fe06621
Show file tree
Hide file tree
Showing 53 changed files with 424 additions and 1,707 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ class ActivityRoutingEventSink(
val activity = currentActivity.acquire()
when (identifier) {
"view_reflections" -> activity.startViewReflectionsActivity()
"view_story" -> activity.startViewStoryActivity()
"view_moments" -> activity.startViewMomentsActivity()
"view_writing_suggestions" -> activity.startViewWritingSuggestionsActivity()
"add_moment" -> activity.startAddAMomentActivity(event)
"edit_moment" -> activity.startEditAMomentActivity(event)
Expand All @@ -53,9 +53,9 @@ class ActivityRoutingEventSink(
startActivity(intent)
}

private fun Activity.startViewStoryActivity() {
private fun Activity.startViewMomentsActivity() {
val intent = Intent(this, RootActivity::class.java)
intent.setAction("view_story")
intent.setAction("view_moments")
startActivity(intent)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,10 @@ import android.view.View
import androidx.fragment.app.Fragment
import androidx.work.ListenableWorker
import com.hadisatrio.apps.kotlin.journal3.datetime.Timestamp
import com.hadisatrio.apps.kotlin.journal3.moment.EditableMoments
import com.hadisatrio.apps.kotlin.journal3.moment.Moments
import com.hadisatrio.apps.kotlin.journal3.sentiment.SentimentAnalyst
import com.hadisatrio.apps.kotlin.journal3.story.Stories
import com.hadisatrio.apps.kotlin.journal3.story.Story
import com.hadisatrio.libs.android.foundation.activity.CurrentActivity
import com.hadisatrio.libs.kotlin.foundation.Decor
import com.hadisatrio.libs.kotlin.foundation.UseCase
Expand All @@ -45,8 +46,8 @@ abstract class Journal3Application : Application() {
abstract val coordinates: Coordinates
abstract val speed: Speed
abstract val places: Places
abstract val story: Story
abstract val notableStory: Story
abstract val moments: EditableMoments
abstract val notableMoments: Moments
abstract val reflections: Stories
abstract val modalPresenter: Presenter<Modal>
abstract val currentActivity: CurrentActivity
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,27 +27,28 @@ import com.hadisatrio.apps.kotlin.journal3.datetime.FormattedTimestamp
import com.hadisatrio.apps.kotlin.journal3.datetime.LiteralTimestamp
import com.hadisatrio.apps.kotlin.journal3.datetime.Timestamp
import com.hadisatrio.apps.kotlin.journal3.moment.CountLimitingMoments
import com.hadisatrio.apps.kotlin.journal3.moment.EditableMoments
import com.hadisatrio.apps.kotlin.journal3.moment.MergedMemorables
import com.hadisatrio.apps.kotlin.journal3.moment.Moments
import com.hadisatrio.apps.kotlin.journal3.moment.NotabilityFilteringMoments
import com.hadisatrio.apps.kotlin.journal3.moment.OrderRandomizingMoments
import com.hadisatrio.apps.kotlin.journal3.moment.SentimentRangedMoments
import com.hadisatrio.apps.kotlin.journal3.moment.TimeRangedMoments
import com.hadisatrio.apps.kotlin.journal3.moment.VicinityMoments
import com.hadisatrio.apps.kotlin.journal3.moment.filesystem.FilesystemMemorableFiles
import com.hadisatrio.apps.kotlin.journal3.moment.filesystem.FilesystemMemorablePlaces
import com.hadisatrio.apps.kotlin.journal3.moment.filesystem.FilesystemMentionedPeople
import com.hadisatrio.apps.kotlin.journal3.moment.filesystem.FilesystemMoments
import com.hadisatrio.apps.kotlin.journal3.sentiment.InitDeferringSentimentAnalyst
import com.hadisatrio.apps.kotlin.journal3.sentiment.NegativeishSentimentRange
import com.hadisatrio.apps.kotlin.journal3.sentiment.PositiveishSentimentRange
import com.hadisatrio.apps.kotlin.journal3.sentiment.SentimentAnalyst
import com.hadisatrio.apps.kotlin.journal3.sentiment.VeryPositiveSentimentRange
import com.hadisatrio.apps.kotlin.journal3.story.InitDeferringStories
import com.hadisatrio.apps.kotlin.journal3.story.MomentfulStories
import com.hadisatrio.apps.kotlin.journal3.story.NotabilityFilteringStory
import com.hadisatrio.apps.kotlin.journal3.story.Reflection
import com.hadisatrio.apps.kotlin.journal3.story.Stories
import com.hadisatrio.apps.kotlin.journal3.story.Story
import com.hadisatrio.apps.kotlin.journal3.story.fake.FakeStories
import com.hadisatrio.apps.kotlin.journal3.story.filesystem.FilesystemStory
import com.hadisatrio.apps.kotlin.journal3.token.TokenableString
import com.hadisatrio.libs.android.foundation.ExecutorDispatchingUseCase
import com.hadisatrio.libs.android.foundation.activity.CurrentActivity
Expand Down Expand Up @@ -104,16 +105,19 @@ class RealJournal3Application : Journal3Application() {
)
}

override val story: Story by lazy {
FilesystemStory(
override val moments: EditableMoments by lazy {
FilesystemMoments(
fileSystem = FileSystem.SYSTEM,
directory = filesDir.absolutePath.toPath() / "content" / "8ea250bc-b6ef-4ab1-812c-3d7d04b8e14a",
path = filesDir.absolutePath.toPath() / "content" / "moments",
memorables = memorables
)
}

override val notableStory: Story by lazy {
NotabilityFilteringStory(notable = true, story)
override val notableMoments: Moments by lazy {
NotabilityFilteringMoments(
notable = true,
origin = moments
)
}

private val memorables by lazy {
Expand Down Expand Up @@ -150,7 +154,7 @@ class RealJournal3Application : Journal3Application() {
origin = VicinityMoments(
coordinates = coordinates,
distanceLimitInM = 100.0,
origin = notableStory.moments
origin = notableMoments
)
)
)
Expand All @@ -167,7 +171,7 @@ class RealJournal3Application : Journal3Application() {
),
origin = SentimentRangedMoments(
sentimentRange = PositiveishSentimentRange,
origin = notableStory.moments
origin = notableMoments
)
)
)
Expand All @@ -181,7 +185,7 @@ class RealJournal3Application : Journal3Application() {
origin = OrderRandomizingMoments(
origin = SentimentRangedMoments(
sentimentRange = VeryPositiveSentimentRange,
origin = notableStory.moments
origin = notableMoments
)
)
)
Expand All @@ -194,7 +198,7 @@ class RealJournal3Application : Journal3Application() {
origin = OrderRandomizingMoments(
origin = SentimentRangedMoments(
sentimentRange = NegativeishSentimentRange,
origin = notableStory.moments
origin = notableMoments
)
)
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@ import androidx.appcompat.app.AppCompatActivity
import androidx.lifecycle.Lifecycle
import androidx.viewpager2.widget.ViewPager2
import com.google.android.material.navigation.NavigationBarView
import com.hadisatrio.apps.android.journal3.story.MomentsListFragment
import com.hadisatrio.apps.android.journal3.story.ReflectionStoriesListFragment
import com.hadisatrio.apps.android.journal3.story.ViewStoryFragment
import com.hadisatrio.libs.android.foundation.lifecycle.LifecycleTriggeredEventSource
import com.hadisatrio.libs.android.foundation.material.NavigationBarSelectionEventSource
import com.hadisatrio.libs.android.foundation.widget.ViewClickEventSource
Expand Down Expand Up @@ -68,7 +68,7 @@ class RootActivity : AppCompatActivity() {
"action",
when (itemId) {
R.id.view_reflections_menu_item -> "view_reflections"
R.id.view_moments_menu_item -> "view_story"
R.id.view_moments_menu_item -> "view_moments"
else -> throw IllegalArgumentException("Unknown menu ID of \"$itemId\".")
}
)
Expand Down Expand Up @@ -103,15 +103,15 @@ class RootActivity : AppCompatActivity() {
pager.adapter = SimpleFragmentPagerAdapter(
activity = this,
FragmentFactory { ReflectionStoriesListFragment() },
FragmentFactory { ViewStoryFragment() }
FragmentFactory { MomentsListFragment() }
)
}

override fun onNewIntent(intent: Intent?) {
super.onNewIntent(intent)
val (menuId, pagerItem) = when (intent?.action) {
"view_reflections" -> R.id.view_reflections_menu_item to 0
"view_story" -> R.id.view_moments_menu_item to 1
"view_moments" -> R.id.view_moments_menu_item to 1
else -> return
}
if (bottomBar.selectedItemId != menuId) bottomBar.selectedItemId = menuId
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ class InactivityAlertingWork(
val application = context.journal3Application
AlertInactivityUseCase(
threshold = application.inactivityAlertThreshold,
story = application.story,
moments = application.moments,
presenter = application.presenterDecor<Modal>().apply(
NotificationModalPresenter(
context = context,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ class DeleteAMomentActivity : AppCompatActivity() {
journal3Application.useCaseDecor.apply(
DeleteMomentUseCase(
momentId = uuidFrom(intent.getStringExtra("target_id")!!),
story = journal3Application.story,
moments = journal3Application.moments,
presenter = journal3Application.presenterDecor<Modal>().apply(
ExecutorDispatchingPresenter(
executor = journal3Application.foregroundExecutor,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,10 @@ import com.hadisatrio.apps.android.journal3.journal3Application
import com.hadisatrio.apps.kotlin.journal3.event.RefreshRequestEvent
import com.hadisatrio.apps.kotlin.journal3.moment.ClockRespectingMoment
import com.hadisatrio.apps.kotlin.journal3.moment.EditAMomentUseCase
import com.hadisatrio.apps.kotlin.journal3.moment.EditableMomentInMoments
import com.hadisatrio.apps.kotlin.journal3.moment.Moment
import com.hadisatrio.apps.kotlin.journal3.moment.SentimentAnalyzingMoment
import com.hadisatrio.apps.kotlin.journal3.moment.UpdateDeferringMoment
import com.hadisatrio.apps.kotlin.journal3.story.EditableMomentInStory
import com.hadisatrio.libs.android.foundation.activity.ActivityFinishingEventSink
import com.hadisatrio.libs.android.foundation.lifecycle.LifecycleTriggeredEventSource
import com.hadisatrio.libs.android.foundation.material.SliderFloatPresenter
Expand Down Expand Up @@ -192,14 +192,14 @@ class EditAMomentActivity : AppCompatActivity() {
origin = ClockRespectingMoment(
clock = journal3Application.clock,
origin = UpdateDeferringMoment(
origin = EditableMomentInStory(
origin = EditableMomentInMoments(
targetId = intent.getUuidExtra("target_id"),
story = journal3Application.story
moments = journal3Application.moments
)
)
)
),
story = journal3Application.story,
moments = journal3Application.moments,
places = journal3Application.places,
presenter = presenter,
modalPresenter = journal3Application.modalPresenter,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ class MomentCapturingWork(
return Result.failure()
}
CaptureAMomentUseCase(
story = journal3Application.story,
moments = journal3Application.moments,
places = journal3Application.places,
speed = journal3Application.speed,
coordinates = journal3Application.coordinates,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,10 @@ import com.hadisatrio.apps.android.journal3.journal3Application
import com.hadisatrio.apps.android.journal3.sentiment.TextViewColorSentimentPresenter
import com.hadisatrio.apps.kotlin.journal3.event.RefreshRequestEvent
import com.hadisatrio.apps.kotlin.journal3.moment.Moment
import com.hadisatrio.apps.kotlin.journal3.story.NotabilityFilteringStory
import com.hadisatrio.apps.kotlin.journal3.story.ShowStoryUseCase
import com.hadisatrio.apps.kotlin.journal3.story.Story
import com.hadisatrio.apps.kotlin.journal3.story.cache.CachingStoryPresenter
import com.hadisatrio.apps.kotlin.journal3.moment.Moments
import com.hadisatrio.apps.kotlin.journal3.moment.NotabilityFilteringMoments
import com.hadisatrio.apps.kotlin.journal3.moment.ShowMomentsUseCase
import com.hadisatrio.apps.kotlin.journal3.moment.cache.CachingMomentsPresenter
import com.hadisatrio.libs.android.dimensions.dp
import com.hadisatrio.libs.android.foundation.activity.ActivityFinishingEventSink
import com.hadisatrio.libs.android.foundation.lifecycle.LifecycleTriggeredEventSource
Expand Down Expand Up @@ -66,7 +66,7 @@ class ViewWritingSuggestionsActivity : AppCompatActivity() {

class Fragment : BottomSheetDialogFragment() {

private val presenter: Presenter<Story> by lazy {
private val presenter: Presenter<Moments> by lazy {
val momentsViewFactory = ViewFactory { parent, _ ->
val inflater = LayoutInflater.from(parent.context)
val view = inflater.inflate(R.layout.view_moment_horz_card, parent, false)
Expand All @@ -77,8 +77,8 @@ class ViewWritingSuggestionsActivity : AppCompatActivity() {
view.setTag(R.id.presenter_view_tag, sentimentPresenter)
view
}
val momentsPresenter = AdaptingPresenter<Story, Iterable<Moment>>(
adapter = { story -> story.moments },
val momentsPresenter = AdaptingPresenter<Moments, Iterable<Moment>>(
adapter = { moments -> moments },
origin = ListViewPresenter(
recyclerView = requireView().findViewById(R.id.moments_list),
orientation = RecyclerView.VERTICAL,
Expand All @@ -89,8 +89,8 @@ class ViewWritingSuggestionsActivity : AppCompatActivity() {
)
)

journal3Application.presenterDecor<Story>().apply(
CachingStoryPresenter(
journal3Application.presenterDecor<Moments>().apply(
CachingMomentsPresenter(
origin = ExecutorDispatchingPresenter(
executor = journal3Application.foregroundExecutor,
origin = momentsPresenter
Expand Down Expand Up @@ -141,8 +141,11 @@ class ViewWritingSuggestionsActivity : AppCompatActivity() {

private val useCase: UseCase by lazy {
journal3Application.useCaseDecor.apply(
ShowStoryUseCase(
story = NotabilityFilteringStory(notable = false, journal3Application.story),
ShowMomentsUseCase(
moments = NotabilityFilteringMoments(
notable = false,
origin = journal3Application.moments
),
presenter = presenter,
eventSource = eventSource,
eventSink = eventSink
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,10 @@ import com.hadisatrio.apps.android.journal3.moment.MomentItemDiffer
import com.hadisatrio.apps.android.journal3.sentiment.TextViewColorSentimentPresenter
import com.hadisatrio.apps.kotlin.journal3.event.RefreshRequestEvent
import com.hadisatrio.apps.kotlin.journal3.moment.Moment
import com.hadisatrio.apps.kotlin.journal3.story.ShowStoryUseCase
import com.hadisatrio.apps.kotlin.journal3.story.Story
import com.hadisatrio.apps.kotlin.journal3.story.cache.CachingStoryPresenter
import com.hadisatrio.apps.kotlin.journal3.moment.Moments
import com.hadisatrio.apps.kotlin.journal3.moment.NotabilityFilteringMoments
import com.hadisatrio.apps.kotlin.journal3.moment.ShowMomentsUseCase
import com.hadisatrio.apps.kotlin.journal3.moment.cache.CachingMomentsPresenter
import com.hadisatrio.libs.android.dimensions.dp
import com.hadisatrio.libs.android.foundation.activity.ActivityFinishingEventSink
import com.hadisatrio.libs.android.foundation.lifecycle.LifecycleTriggeredEventSource
Expand All @@ -54,9 +55,9 @@ import com.hadisatrio.libs.kotlin.foundation.event.SkippingEventSource
import com.hadisatrio.libs.kotlin.foundation.presentation.AdaptingPresenter
import com.hadisatrio.libs.kotlin.foundation.presentation.Presenter

class ViewStoryFragment : Fragment() {
class MomentsListFragment : Fragment() {

private val presenter: Presenter<Story> by lazy {
private val presenter: Presenter<Moments> by lazy {
val momentsViewFactory = ViewFactory { parent, _ ->
val inflater = LayoutInflater.from(parent.context)
val view = inflater.inflate(R.layout.view_moment_horz_card, parent, false)
Expand All @@ -67,8 +68,8 @@ class ViewStoryFragment : Fragment() {
view.setTag(R.id.presenter_view_tag, sentimentPresenter)
view
}
val momentsPresenter = AdaptingPresenter<Story, Iterable<Moment>>(
adapter = { story -> story.moments },
val momentsPresenter = AdaptingPresenter<Moments, Iterable<Moment>>(
adapter = { moments -> moments },
origin = ListViewPresenter(
recyclerView = requireView().findViewById(R.id.moments_list),
orientation = RecyclerView.VERTICAL,
Expand All @@ -79,8 +80,8 @@ class ViewStoryFragment : Fragment() {
)
)

journal3Application.presenterDecor<Story>().apply(
CachingStoryPresenter(
journal3Application.presenterDecor<Moments>().apply(
CachingMomentsPresenter(
origin = ExecutorDispatchingPresenter(
executor = journal3Application.foregroundExecutor,
origin = momentsPresenter
Expand Down Expand Up @@ -124,8 +125,11 @@ class ViewStoryFragment : Fragment() {

private val useCase: UseCase by lazy {
journal3Application.useCaseDecor.apply(
ShowStoryUseCase(
story = journal3Application.notableStory,
ShowMomentsUseCase(
moments = NotabilityFilteringMoments(
notable = true,
origin = journal3Application.moments
),
presenter = presenter,
eventSource = eventSource,
eventSink = eventSink
Expand All @@ -138,7 +142,7 @@ class ViewStoryFragment : Fragment() {
container: ViewGroup?,
savedInstanceState: Bundle?
): View? {
return inflater.inflate(R.layout.fragment_view_story, container, false)
return inflater.inflate(R.layout.fragment_moments_list, container, false)
}

override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ class PositiveReflectionsWidgetProvider : AppWidgetProvider() {
origin = OrderRandomizingMoments(
origin = SentimentRangedMoments(
sentimentRange = PositiveishSentimentRange,
origin = application.story.moments
origin = application.notableMoments
)
)
)
Expand Down
Loading

0 comments on commit fe06621

Please sign in to comment.