Skip to content

Commit

Permalink
Merge pull request #364 from leonlatsch/release/1.7.4
Browse files Browse the repository at this point in the history
Release: 1.7.4
  • Loading branch information
leonlatsch authored Aug 22, 2024
2 parents 34ce8ee + f9a641f commit b806690
Show file tree
Hide file tree
Showing 17 changed files with 313 additions and 130 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ Also available at **[IzzyOnDroid (F-Droid)](https://apt.izzysoft.de/fdroid/index
![French](https://img.shields.io/badge/French-100%25-brightgreen)
![German](https://img.shields.io/badge/German-100%25-brightgreen)
![Portuguese (Brazil)](https://img.shields.io/badge/Portuguese%20(Brazil)-81%25-yellow)
![Russian](https://img.shields.io/badge/Russian-84%25-yellow)
![Russian](https://img.shields.io/badge/Russian-100%25-brightgreen)
![Spanish](https://img.shields.io/badge/Spanish-100%25-brightgreen)
![Turkish](https://img.shields.io/badge/Turkish-100%25-brightgreen)
<!-- END-TRANSLATIONS -->
Expand Down
22 changes: 10 additions & 12 deletions app/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -72,12 +72,12 @@ licenseReport {
dependencies {
val roomVersion = "2.6.1"
val coroutinesVersion = "1.8.1"
val pagingVersion = "3.3.0"
val pagingVersion = "3.3.1"
val daggerVersion = "2.51.1"

// Architectural Components
implementation("androidx.lifecycle:lifecycle-viewmodel-ktx:2.8.2")
implementation("androidx.lifecycle:lifecycle-runtime-ktx:2.8.2")
implementation("androidx.lifecycle:lifecycle-viewmodel-ktx:2.8.4")
implementation("androidx.lifecycle:lifecycle-runtime-ktx:2.8.4")
implementation("androidx.lifecycle:lifecycle-extensions:2.2.0")

// Room
Expand All @@ -96,8 +96,8 @@ dependencies {
implementation("org.jetbrains.kotlinx:kotlinx-coroutines-android:$coroutinesVersion")

// Coroutine Lifecycle Scopes
implementation("androidx.lifecycle:lifecycle-viewmodel-ktx:2.8.2")
implementation("androidx.lifecycle:lifecycle-runtime-ktx:2.8.2")
implementation("androidx.lifecycle:lifecycle-viewmodel-ktx:2.8.4")
implementation("androidx.lifecycle:lifecycle-runtime-ktx:2.8.4")

// Navigation Components
implementation("androidx.navigation:navigation-fragment-ktx:2.7.7")
Expand All @@ -120,7 +120,7 @@ dependencies {
kapt("androidx.hilt:hilt-compiler:1.2.0")

// Activity KTX for viewModels()
implementation("androidx.activity:activity-ktx:1.9.0")
implementation("androidx.activity:activity-ktx:1.9.1")

// Compose
implementation(platform("androidx.compose:compose-bom:2024.06.00"))
Expand All @@ -143,16 +143,14 @@ dependencies {
// Display OSS Licenses
implementation("com.github.leonlatsch:OssLicenseView:1.1.0")

// Glide
implementation("com.github.bumptech.glide:glide:4.16.0")

// Telephoto
implementation("me.saket.telephoto:zoomable-image-coil:0.11.2")
implementation("me.saket.telephoto:zoomable-image-coil:0.12.1")

// Coil
val coilVersion = "2.6.0"
val coilVersion = "2.7.0"
implementation("io.coil-kt:coil-compose:$coilVersion")
implementation("io.coil-kt:coil-gif:$coilVersion")
implementation("io.coil-kt:coil-video:$coilVersion")

// Exoplayer
implementation("com.google.android.exoplayer:exoplayer-core:2.19.1")
Expand All @@ -164,7 +162,7 @@ dependencies {
implementation("androidx.core:core-ktx:1.13.1")
implementation("androidx.appcompat:appcompat:1.7.0")
implementation("androidx.constraintlayout:constraintlayout:2.1.4")
implementation("androidx.activity:activity:1.9.0")
implementation("androidx.activity:activity:1.9.1")
implementation("androidx.preference:preference-ktx:1.2.1")

testImplementation("junit:junit:4.13.2")
Expand Down
5 changes: 3 additions & 2 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@
-->

<manifest xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools">
xmlns:tools="http://schemas.android.com/tools"
android:installLocation="auto">

<!-- Legacy Permission -->
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" android:maxSdkVersion="32" />
Expand Down Expand Up @@ -112,4 +113,4 @@
</receiver>
</application>

</manifest>
</manifest>
6 changes: 6 additions & 0 deletions app/src/main/assets/contributors.json
Original file line number Diff line number Diff line change
Expand Up @@ -46,5 +46,11 @@
"name": "f1refa11",
"contact": "firekonstantin@mail.ru",
"website": "https://github.com/f1refa11"
},
{
"contribution": "Russian translation",
"name": "Maxim Syomochkin",
"contact": "maksim77ster@gmail.com",
"website": "https://mak-sim.ru"
}
]
2 changes: 1 addition & 1 deletion app/src/main/assets/open_source_licenses.json

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ package dev.leonlatsch.photok.backup.domain
import dev.leonlatsch.photok.backup.data.BackupMetaData
import dev.leonlatsch.photok.backup.data.toDomain
import dev.leonlatsch.photok.model.database.entity.internalFileName
import dev.leonlatsch.photok.model.io.CreateThumbnailsUseCase
import dev.leonlatsch.photok.model.repositories.PhotoRepository
import dev.leonlatsch.photok.security.EncryptionManager
import java.io.ByteArrayInputStream
Expand All @@ -30,6 +31,7 @@ import kotlin.coroutines.suspendCoroutine
class RestoreBackupV1 @Inject constructor(
private val encryptionManager: EncryptionManager,
private val photoRepository: PhotoRepository,
private val createThumbnails: CreateThumbnailsUseCase,
) : RestoreBackupStrategy {
override suspend fun restore(
metaData: BackupMetaData,
Expand Down Expand Up @@ -66,8 +68,9 @@ class RestoreBackupV1 @Inject constructor(
photoRepository.createPhotoFile(newPhoto, photoBytesInputStream) != -1L

if (photoFileCreated) {
photoRepository.createThumbnail(newPhoto, photoBytes)
photoRepository.insert(newPhoto)
createThumbnails(newPhoto, photoBytes).onSuccess {
photoRepository.insert(newPhoto)
}
}

ze = stream.nextEntry
Expand Down
3 changes: 2 additions & 1 deletion app/src/main/java/dev/leonlatsch/photok/di/AppModule.kt
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
package dev.leonlatsch.photok.di

import android.content.Context
import android.content.res.Resources
import androidx.room.Room
import com.google.gson.Gson
import com.google.gson.GsonBuilder
Expand Down Expand Up @@ -71,7 +72,7 @@ object AppModule {
fun provideSharedUrisStore() = SharedUrisStore()

@Provides
fun provideResources(@ApplicationContext context: Context) = context.resources
fun provideResources(@ApplicationContext context: Context): Resources = context.resources

@Provides
fun provideGson(): Gson = GsonBuilder()
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
/*
* Copyright 2020-2024 Leon Latsch
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

package dev.leonlatsch.photok.imageloading.data

import androidx.core.graphics.drawable.toBitmap
import coil.ImageLoader
import coil.request.ErrorResult
import coil.request.ImageRequest
import coil.request.SuccessResult
import dev.leonlatsch.photok.imageloading.domain.ImageStorage
import dev.leonlatsch.photok.other.extensions.writeTo
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.withContext
import java.io.OutputStream
import javax.inject.Inject
import kotlin.coroutines.resume
import kotlin.coroutines.suspendCoroutine

class ImageStorageImpl @Inject constructor(
private val imageLoader: ImageLoader,
) : ImageStorage {

/**
* Executes an [imageRequest] and writes its result to the desired [outputStream].
*/
override suspend fun execAndWrite(
imageRequest: ImageRequest,
outputStream: OutputStream?,
): Result<Unit> = withContext(Dispatchers.IO) {
outputStream ?: return@withContext Result.failure(Exception("stream is null"))

when (val imageResult = imageLoader.execute(imageRequest)) {
is SuccessResult -> suspendCoroutine { continuation ->
try {
outputStream.use { out ->
imageResult.drawable.toBitmap().writeTo(out)
}

continuation.resume(Result.success(Unit))
} catch (e: Exception) {
continuation.resume(Result.failure(e))
}
}
is ErrorResult -> Result.failure(imageResult.throwable)
}
}
}

Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,17 @@ package dev.leonlatsch.photok.imageloading.di

import android.content.Context
import coil.ImageLoader
import coil.decode.VideoFrameDecoder
import coil.request.CachePolicy
import dagger.Binds
import dagger.Module
import dagger.Provides
import dagger.hilt.InstallIn
import dagger.hilt.android.qualifiers.ApplicationContext
import dagger.hilt.components.SingletonComponent
import dev.leonlatsch.photok.imageloading.compose.EncryptedImageFetcherFactory
import dev.leonlatsch.photok.imageloading.data.ImageStorageImpl
import dev.leonlatsch.photok.imageloading.domain.ImageStorage

@Module
@InstallIn(SingletonComponent::class)
Expand All @@ -44,4 +48,24 @@ object ImageLoadingModule {
.memoryCachePolicy(CachePolicy.DISABLED)
.memoryCache(null)
.build()

@Provides
fun provideDefaultImageLoader(
@ApplicationContext context: Context,
): ImageLoader = ImageLoader.Builder(context)
.components { add(VideoFrameDecoder.Factory()) }
.diskCachePolicy(CachePolicy.DISABLED)
.diskCache(null)
.memoryCachePolicy(CachePolicy.DISABLED)
.memoryCache(null)
.build()
}

@Module
@InstallIn(SingletonComponent::class)
interface ImageLoadingBindingModule {
@Binds
fun bindImageStorage(
impl: ImageStorageImpl
): ImageStorage
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
/*
* Copyright 2020-2024 Leon Latsch
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

package dev.leonlatsch.photok.imageloading.domain

import coil.request.ImageRequest
import java.io.OutputStream

interface ImageStorage {
suspend fun execAndWrite(
imageRequest: ImageRequest,
outputStream: OutputStream?,
): Result<Unit>
}
Original file line number Diff line number Diff line change
Expand Up @@ -34,11 +34,12 @@ enum class PhotoType(
JPEG(2, "image/jpeg"),
GIF(3, "image/gif"),
MP4(4, "video/mp4"),
MPEG(5, "video/mpeg");
MPEG(5, "video/mpeg"),
WEBM(6, "video/webm");

val isVideo: Boolean
get() = when (value) {
4, 5 -> true
4, 5, 6 -> true
else -> false
}

Expand Down
Loading

0 comments on commit b806690

Please sign in to comment.