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

Add support for images & galleries #173

Merged
merged 18 commits into from
Mar 5, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
8 changes: 8 additions & 0 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,14 @@
android:name=".MovieActivity"
android:exported="false"
android:theme="@style/NoTitleTheme" />
<activity
android:name=".ImageActivity"
android:exported="false"
android:theme="@style/NoTitleTheme" />
<activity
android:name=".GalleryActivity"
android:exported="false"
android:theme="@style/NoTitleTheme" />
<activity
android:name=".SearchForActivity"
android:exported="false"
Expand Down
52 changes: 52 additions & 0 deletions app/src/main/graphql/FindGalleries.graphql
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
query FindGalleries($filter: FindFilterType, $gallery_filter: GalleryFilterType) {
findGalleries(filter: $filter, gallery_filter: $gallery_filter) {
count
galleries {
...GalleryData
}
}
}

query FindGallery($id: ID!) {
findGallery(id: $id) {
...GalleryData
}
}

fragment GalleryData on Gallery {
id
title
image_count
date
details
rating100
files {
path
}
folder {
path
}
performers {
id
name
}
tags {
id
name
}
studio {
id
name
}
scenes {
id
}
cover {
id
paths {
thumbnail
image
preview
}
}
}
63 changes: 63 additions & 0 deletions app/src/main/graphql/FindImages.graphql
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
query FindImages($filter: FindFilterType, $image_filter: ImageFilterType) {
findImages(filter: $filter, image_filter: $image_filter) {
count
images {
...ImageData
}
}
}

query FindImage($id: ID) {
findImage(id: $id) {
...ImageData
}
}

fragment ImageData on Image {
id
title
code
rating100
date
details
photographer
o_counter
paths {
thumbnail
preview
image
}
performers{
...PerformerData
}
studio {
...StudioData
}
tags {
...TagData
}
galleries {
id
}
visual_files {
... on BaseFile{
id
path
size
__typename
}
... on ImageFile {
width
height

}
... on VideoFile{
width
height
format
video_codec
audio_codec
duration
}
}
}
2 changes: 2 additions & 0 deletions app/src/main/graphql/Fragments.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,6 @@ fragment TagData on Tag {
performer_count
scene_marker_count
image_path
image_count
gallery_count
}
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,9 @@ import com.github.damontecres.stashapp.api.fragment.TagData
import com.github.damontecres.stashapp.api.type.CriterionModifier
import com.github.damontecres.stashapp.api.type.FilterMode
import com.github.damontecres.stashapp.api.type.FindFilterType
import com.github.damontecres.stashapp.api.type.GalleryFilterType
import com.github.damontecres.stashapp.api.type.HierarchicalMultiCriterionInput
import com.github.damontecres.stashapp.api.type.ImageFilterType
import com.github.damontecres.stashapp.api.type.SceneMarkerFilterType
import com.github.damontecres.stashapp.api.type.SortDirectionEnum
import com.github.damontecres.stashapp.data.DataType
Expand All @@ -33,13 +35,17 @@ import com.github.damontecres.stashapp.presenters.PerformerPresenter
import com.github.damontecres.stashapp.presenters.ScenePresenter
import com.github.damontecres.stashapp.presenters.StashPresenter
import com.github.damontecres.stashapp.presenters.TagPresenter
import com.github.damontecres.stashapp.suppliers.GalleryDataSupplier
import com.github.damontecres.stashapp.suppliers.ImageDataSupplier
import com.github.damontecres.stashapp.suppliers.MarkerDataSupplier
import com.github.damontecres.stashapp.suppliers.MovieDataSupplier
import com.github.damontecres.stashapp.suppliers.PerformerDataSupplier
import com.github.damontecres.stashapp.suppliers.SceneDataSupplier
import com.github.damontecres.stashapp.suppliers.StudioDataSupplier
import com.github.damontecres.stashapp.suppliers.TagDataSupplier
import com.github.damontecres.stashapp.util.FilterParser
import com.github.damontecres.stashapp.util.GalleryComparator
import com.github.damontecres.stashapp.util.ImageComparator
import com.github.damontecres.stashapp.util.MarkerComparator
import com.github.damontecres.stashapp.util.MovieComparator
import com.github.damontecres.stashapp.util.PerformerComparator
Expand Down Expand Up @@ -357,6 +363,36 @@ class FilterListActivity : FragmentActivity() {
name,
)
}

DataType.IMAGE -> {
val imageFilter =
if (objectFilter is ImageFilterType) {
objectFilter
} else {
FilterParser.instance.convertImageObjectFilter(objectFilter)
}
StashGridFragment(
ImageComparator,
ImageDataSupplier(findFilter, imageFilter),
null,
name,
)
}

DataType.GALLERY -> {
val galleryFilter =
if (objectFilter is GalleryFilterType) {
objectFilter
} else {
FilterParser.instance.convertGalleryObjectFilter(objectFilter)
}
StashGridFragment(
GalleryComparator,
GalleryDataSupplier(findFilter, galleryFilter),
null,
name,
)
}
}
}

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
package com.github.damontecres.stashapp

import android.os.Bundle
import android.widget.TextView
import androidx.fragment.app.FragmentActivity
import com.apollographql.apollo3.api.Optional
import com.github.damontecres.stashapp.api.type.CriterionModifier
import com.github.damontecres.stashapp.api.type.FindFilterType
import com.github.damontecres.stashapp.api.type.ImageFilterType
import com.github.damontecres.stashapp.api.type.MultiCriterionInput
import com.github.damontecres.stashapp.api.type.SortDirectionEnum
import com.github.damontecres.stashapp.suppliers.ImageDataSupplier
import com.github.damontecres.stashapp.util.ImageComparator

class GalleryActivity : FragmentActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.grid_view)
if (savedInstanceState == null) {
val galleryId = intent.getStringExtra(INTENT_GALLERY_ID)!!
val galleryName = intent.getStringExtra(INTENT_GALLERY_NAME)
findViewById<TextView>(R.id.grid_title).text = galleryName
supportFragmentManager.beginTransaction()
.replace(
R.id.grid_fragment,
StashGridFragment(
ImageComparator,
ImageDataSupplier(
FindFilterType(
sort = Optional.present("path"),
direction = Optional.present(SortDirectionEnum.ASC),
),
ImageFilterType(
galleries =
Optional.present(
MultiCriterionInput(
value = Optional.present(listOf(galleryId)),
modifier = CriterionModifier.INCLUDES,
),
),
),
),
),
).commitNow()
}
}

companion object {
const val INTENT_GALLERY_ID = "gallery.id"
const val INTENT_GALLERY_NAME = "gallery.name"
}
}
Loading
Loading