Skip to content

Commit

Permalink
Redesign videos page
Browse files Browse the repository at this point in the history
  • Loading branch information
ismartcoding committed May 23, 2024
1 parent f48e672 commit 09c06b8
Show file tree
Hide file tree
Showing 99 changed files with 2,884 additions and 1,750 deletions.
3 changes: 1 addition & 2 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -93,8 +93,7 @@
android:name=".ui.MainActivity"
android:configChanges="uiMode|orientation|screenSize|smallestScreenSize|screenLayout"
android:exported="true"
android:launchMode="singleTop"
android:screenOrientation="sensor"
android:launchMode="singleInstance"
android:supportsPictureInPicture="true"
android:windowSoftInputMode="adjustResize"
tools:ignore="DiscouragedApi,LockedOrientationActivity">
Expand Down
35 changes: 0 additions & 35 deletions app/src/main/java/com/ismartcoding/plain/PAppGlideModule.kt

This file was deleted.

10 changes: 9 additions & 1 deletion app/src/main/java/com/ismartcoding/plain/data/DImage.kt
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package com.ismartcoding.plain.data

import androidx.compose.ui.unit.IntSize
import kotlinx.datetime.Instant
import java.io.Serializable

Expand All @@ -11,9 +12,16 @@ data class DImage(
val size: Long,
val width: Int,
val height: Int,
val rotation: Int,
val bucketId: String,
val takenAt: Instant?,
val createdAt: Instant,
val updatedAt: Instant,
) : IData, Serializable {
fun getRotatedSize(): IntSize {
if (rotation == 90 || rotation == 270) {
return IntSize(height, width)
}

return IntSize(width, height)
}
}
29 changes: 29 additions & 0 deletions app/src/main/java/com/ismartcoding/plain/data/DImageMeta.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
package com.ismartcoding.plain.data

import kotlinx.datetime.Instant

data class DImageMeta(
val make: String,
val model: String,
val width: Int,
val height: Int,
val rotation: Int,
val colorSpace : String,
val apertureValue: Double,
val exposureTime: String,
val focalLength : String,
val isoSpeed: Int,
val contentCreated: Instant?,
val flash: Int,
val fNumber: Double,
val exposureProgram: Int,
val meteringMode: Int,
val whiteBalance: Int,
val creator: String,
val resolutionX: Int,
val resolutionY: Int,
val description: String
) {
val isScreenshot: Boolean
get() = exposureTime.isEmpty()
}
22 changes: 15 additions & 7 deletions app/src/main/java/com/ismartcoding/plain/data/DVideo.kt
Original file line number Diff line number Diff line change
@@ -1,22 +1,30 @@
package com.ismartcoding.plain.data

import android.os.Parcelable
import com.ismartcoding.plain.data.IData
import com.ismartcoding.plain.data.IMedia
import androidx.compose.ui.unit.IntSize
import kotlinx.datetime.Instant
import kotlinx.parcelize.Parcelize
import java.io.Serializable

@Parcelize
@kotlinx.serialization.Serializable
data class DVideo(
override var id: String,
val title: String,
override val path: String,
override val duration: Long,
val size: Long,
val width: Int,
val height: Int,
val rotation: Int,
val bucketId: String,
) : IData, IMedia, Parcelable, Serializable {
companion object {
private const val serialVersionUID = -2797285L
val createdAt: Instant,
val updatedAt: Instant,
) : IData, IMedia, Serializable {

fun getRotatedSize(): IntSize {
if (rotation == 90 || rotation == 270) {
return IntSize(height, width)
}

return IntSize(width, height)
}
}
17 changes: 17 additions & 0 deletions app/src/main/java/com/ismartcoding/plain/data/DVideoMeta.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
package com.ismartcoding.plain.data

data class DVideoMeta(
val width: Int,
val height: Int,
val rotation: Int,
val duration: Long,
val bitrate: Int,
val frameRate: Float,
val title: String,
val artist: String,
val album: String,
val genre: String,
val date: String,
val writer: String,
val composer: String,
)
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,11 @@ object ImageMediaStoreHelper : BaseContentHelper() {
MediaStore.Images.Media.TITLE,
MediaStore.Images.Media.DATA,
MediaStore.Images.Media.SIZE,
MediaStore.Images.Media.DATE_TAKEN,
MediaStore.Images.Media.DATE_ADDED,
MediaStore.Images.Media.DATE_MODIFIED,
MediaStore.Images.Media.WIDTH,
MediaStore.Images.Media.HEIGHT,
MediaStore.Images.Media.ORIENTATION,
MediaStore.Images.Media.BUCKET_ID,
)
}
Expand Down Expand Up @@ -71,14 +71,14 @@ object ImageMediaStoreHelper : BaseContentHelper() {
val id = cursor.getStringValue(MediaStore.Images.Media._ID, cache)
val title = cursor.getStringValue(MediaStore.Images.Media.TITLE, cache)
val size = cursor.getLongValue(MediaStore.Images.Media.SIZE, cache)
val dateTaken = cursor.getTimeMillisecondsValue(MediaStore.Images.Media.DATE_TAKEN, cache)
val createdAt = cursor.getTimeSecondsValue(MediaStore.Images.Media.DATE_ADDED, cache)
val updatedAt = cursor.getTimeSecondsValue(MediaStore.Images.Media.DATE_MODIFIED, cache)
val width = cursor.getIntValue(MediaStore.Images.Media.WIDTH, cache)
val height = cursor.getIntValue(MediaStore.Images.Media.HEIGHT, cache)
val rotation = cursor.getIntValue(MediaStore.Images.Media.ORIENTATION, cache)
val path = cursor.getStringValue(MediaStore.Images.Media.DATA, cache)
val bucketId = cursor.getStringValue(MediaStore.Images.Media.BUCKET_ID, cache)
result.add(DImage(id, title, path, size, width, height, bucketId, dateTaken, createdAt, updatedAt))
result.add(DImage(id, title, path, size, width, height, rotation, bucketId, createdAt, updatedAt))
} while (cursor.moveToNext())
}
return result
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,14 +59,18 @@ object TagHelper {
keys: Set<String>,
type: DataType,
): List<DTagRelation> {
return tagRelationDao.getAllByKeys(keys, type.value)
val items = mutableListOf<DTagRelation>()
keys.chunked(50).forEach { chunk ->
items.addAll(tagRelationDao.getAllByKeys(chunk.toSet(), type.value))
}
return items
}

fun getTagRelationsByKeysMap(
keys: Set<String>,
type: DataType,
): Map<String, List<DTagRelation>> {
return tagRelationDao.getAllByKeys(keys, type.value).groupBy { it.key }
return getTagRelationsByKeys(keys, type).groupBy { it.key }
}

fun getTagRelationsByKey(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,11 @@ import android.content.Context
import android.net.Uri
import android.provider.MediaStore
import com.ismartcoding.lib.content.ContentWhere
import com.ismartcoding.lib.extensions.getIntValue
import com.ismartcoding.lib.extensions.getLongValue
import com.ismartcoding.lib.extensions.getStringValue
import com.ismartcoding.lib.extensions.getTimeMillisecondsValue
import com.ismartcoding.lib.extensions.getTimeSecondsValue
import com.ismartcoding.lib.helpers.FilterField
import com.ismartcoding.lib.isQPlus
import com.ismartcoding.plain.data.DMediaBucket
Expand All @@ -26,6 +29,11 @@ object VideoMediaStoreHelper : BaseContentHelper() {
MediaStore.Video.Media.DATA,
MediaStore.Video.Media.SIZE,
MediaStore.Video.Media.DURATION,
MediaStore.Video.Media.DATE_ADDED,
MediaStore.Video.Media.DATE_MODIFIED,
MediaStore.Video.Media.WIDTH,
MediaStore.Video.Media.HEIGHT,
MediaStore.Video.Media.ORIENTATION,
MediaStore.Video.Media.BUCKET_ID,
)
}
Expand Down Expand Up @@ -67,9 +75,14 @@ object VideoMediaStoreHelper : BaseContentHelper() {
val title = cursor.getStringValue(MediaStore.Video.Media.TITLE, cache)
val size = cursor.getLongValue(MediaStore.Video.Media.SIZE, cache)
val duration = cursor.getLongValue(MediaStore.Video.Media.DURATION, cache) / 1000
val createdAt = cursor.getTimeSecondsValue(MediaStore.Video.Media.DATE_ADDED, cache)
val updatedAt = cursor.getTimeSecondsValue(MediaStore.Video.Media.DATE_MODIFIED, cache)
val width = cursor.getIntValue(MediaStore.Video.Media.WIDTH, cache)
val height = cursor.getIntValue(MediaStore.Video.Media.HEIGHT, cache)
val rotation = cursor.getIntValue(MediaStore.Video.Media.ORIENTATION, cache)
val path = cursor.getStringValue(MediaStore.Video.Media.DATA, cache)
val bucketId = cursor.getStringValue(MediaStore.Video.Media.BUCKET_ID, cache)
result.add(DVideo(id, title, path, duration, size, bucketId))
result.add(DVideo(id, title, path, duration, size, width, height, rotation, bucketId, createdAt, updatedAt))
}
}
return result
Expand Down
Loading

0 comments on commit 09c06b8

Please sign in to comment.