Skip to content

Commit

Permalink
Merge pull request leonlatsch#319 from leonlatsch/release/1.7.1
Browse files Browse the repository at this point in the history
Release: 1.7.1
  • Loading branch information
leonlatsch authored Jun 1, 2024
2 parents 28a47c5 + 6316172 commit 114f209
Show file tree
Hide file tree
Showing 38 changed files with 430 additions and 182 deletions.
1 change: 1 addition & 0 deletions .github/FUNDING.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,4 @@ community_bridge: # Replace with a single Community Bridge project-name e.g., cl
liberapay: leonlatsch
issuehunt: # Replace with a single IssueHunt username
otechie: # Replace with a single Otechie username
custom: bc1qd4enyt30w02vty8xt3fm5uesunzxpnz3w4agf4
4 changes: 2 additions & 2 deletions .github/PULL_REQUEST_TEMPLATE.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,5 @@


**Tasks:**
- [ ] Build CI Runs
- [ ] Code Analysis up to standards
*add your tasks if needed*
- [ ] ...
14 changes: 7 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,14 +38,14 @@ Also available at **[IzzyOnDroid (F-Droid)](https://apt.izzysoft.de/fdroid/index
## Translations
<!-- BEGIN-TRANSLATIONS -->
![English](https://img.shields.io/badge/English-100%25-brightgreen)
![Arabic](https://img.shields.io/badge/Arabic-85%25-yellow)
![Chinese (China)](https://img.shields.io/badge/Chinese%20(China)-85%25-yellow)
![Dutch](https://img.shields.io/badge/Dutch-85%25-yellow)
![French](https://img.shields.io/badge/French-84%25-yellow)
![Arabic](https://img.shields.io/badge/Arabic-84%25-yellow)
![Chinese (China)](https://img.shields.io/badge/Chinese%20(China)-84%25-yellow)
![Dutch](https://img.shields.io/badge/Dutch-84%25-yellow)
![French](https://img.shields.io/badge/French-83%25-yellow)
![German](https://img.shields.io/badge/German-100%25-brightgreen)
![Portuguese (Brazil)](https://img.shields.io/badge/Portuguese%20(Brazil)-83%25-yellow)
![Russian](https://img.shields.io/badge/Russian-85%25-yellow)
![Spanish](https://img.shields.io/badge/Spanish-83%25-yellow)
![Portuguese (Brazil)](https://img.shields.io/badge/Portuguese%20(Brazil)-81%25-yellow)
![Russian](https://img.shields.io/badge/Russian-84%25-yellow)
![Spanish](https://img.shields.io/badge/Spanish-81%25-yellow)
<!-- END-TRANSLATIONS -->

LICENSE
Expand Down
6 changes: 3 additions & 3 deletions app/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -139,9 +139,6 @@ dependencies {
// jBCrypt for Password Hashing
implementation("org.mindrot", "jbcrypt", "0.4")

// MikeOritz/TouchImageView - Zoomable Image View
implementation("com.github.MikeOrtiz:TouchImageView:3.6")

// Gson
implementation("com.google.code.gson", "gson", "2.8.6")

Expand All @@ -154,6 +151,9 @@ dependencies {
// Glide
implementation("com.github.bumptech.glide:glide:4.16.0")

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

// Coil
implementation("io.coil-kt:coil-compose:2.6.0")

Expand Down
2 changes: 2 additions & 0 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@
<uses-permission android:name="android.permission.READ_MEDIA_VIDEO" />
<uses-permission android:name="android.permission.READ_MEDIA_IMAGES" />

<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" tools:node="remove"/>

<application
android:name=".BaseApplication"
android:allowBackup="false"
Expand Down
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 @@ -44,6 +44,11 @@ class AlbumRepositoryImpl @Inject constructor(
.map { it.toDomain() }
.map { album -> album.sortPhotos() }

override suspend fun getAlbumWithPhotos(uuid: String): Album =
albumDao.getAlbumWithPhotos(uuid)
.toDomain()
.sortPhotos()

override suspend fun createAlbum(album: Album): Result<Album> =
when (albumDao.insert(album.toData())) {
-1L -> Result.failure(IOException())
Expand All @@ -56,6 +61,10 @@ class AlbumRepositoryImpl @Inject constructor(
else -> Result.success(Unit)
}

override suspend fun deleteAll() {
albumDao.deleteAll()
}

override suspend fun link(photoUUIDs: List<String>, albumUUID: String) {
albumDao.link(photoUUIDs, albumUUID)
}
Expand All @@ -74,8 +83,12 @@ class AlbumRepositoryImpl @Inject constructor(
albumDao.unlink(photoUUIDs, uuid)
}

override suspend fun getAllPhotoIdsFor(albumUUID: String): List<String> {
return albumDao.getAllPhotoIdsFor(albumUUID)
override suspend fun unlinkAll() {
albumDao.unlinkAll()
}

override suspend fun rename(albumUUID: String, newName: String) {
albumDao.renameAlbum(albumUUID = albumUUID, newName = newName)
}

override suspend fun getAllAlbumPhotoLinks(): List<AlbumPhotoRef> =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,4 +25,5 @@ sealed interface AlbumDetailUiEvent {
data class RemoveFromAlbum(val items: List<String>) : AlbumDetailUiEvent
data object DeleteAlbum : AlbumDetailUiEvent
data class OnImport(val albumUUID: String?) : AlbumDetailUiEvent
data class RenameAlbum(val newName: String) : AlbumDetailUiEvent
}
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ import dev.leonlatsch.photok.gallery.albums.domain.AlbumRepository
import dev.leonlatsch.photok.gallery.albums.domain.model.Album
import dev.leonlatsch.photok.gallery.ui.components.PhotoTile
import dev.leonlatsch.photok.gallery.ui.navigation.PhotoAction
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.channels.Channel
import kotlinx.coroutines.flow.SharingStarted
import kotlinx.coroutines.flow.map
Expand Down Expand Up @@ -115,6 +116,17 @@ class AlbumDetailViewModel @AssistedInject constructor(
)
}
}

is AlbumDetailUiEvent.RenameAlbum -> renameAlbum(event.newName)
}
}

private fun renameAlbum(newName: String) {
viewModelScope.launch(Dispatchers.IO) {
albumsRepository.rename(
albumUUID = albumFlow.value.uuid,
newName = newName,
)
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ import androidx.navigation.NavController
import dev.leonlatsch.photok.R
import dev.leonlatsch.photok.gallery.albums.detail.ui.AlbumDetailUiEvent
import dev.leonlatsch.photok.gallery.albums.detail.ui.AlbumDetailViewModel
import dev.leonlatsch.photok.gallery.albums.ui.compose.RenameAlbumDialog
import dev.leonlatsch.photok.ui.components.ConfirmationDialog
import dev.leonlatsch.photok.ui.theme.AppTheme

Expand All @@ -52,6 +53,7 @@ fun AlbumDetailScreen(viewModel: AlbumDetailViewModel, navController: NavControl
val scrollBehavior = TopAppBarDefaults.exitUntilCollapsedScrollBehavior()

var showConfirmDeleteDialog by remember { mutableStateOf(false) }
var showRenameDialog by remember { mutableStateOf(false) }

AppTheme {
Scaffold(
Expand Down Expand Up @@ -97,6 +99,20 @@ fun AlbumDetailScreen(viewModel: AlbumDetailViewModel, navController: NavControl
)
}
)

DropdownMenuItem(
text = { Text(stringResource(R.string.common_rename)) },
onClick = {
showMore = false
showRenameDialog = true
},
leadingIcon = {
Icon(
painter = painterResource(R.drawable.ic_edit),
contentDescription = stringResource(R.string.common_rename),
)
}
)
}
}
)
Expand All @@ -116,6 +132,15 @@ fun AlbumDetailScreen(viewModel: AlbumDetailViewModel, navController: NavControl
text = stringResource(R.string.common_are_you_sure),
onConfirm = { viewModel.handleUiEvent(AlbumDetailUiEvent.DeleteAlbum) }
)

RenameAlbumDialog(
show = showRenameDialog,
onDismiss = { showRenameDialog = false },
currentName = uiState.albumName,
onRename = { newName ->
viewModel.handleUiEvent(AlbumDetailUiEvent.RenameAlbum(newName))
}
)
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,15 @@ interface AlbumRepository {
fun observeAlbumsWithPhotos(): Flow<List<Album>>
suspend fun getAlbums(): List<Album>
fun observeAlbumWithPhotos(uuid: String): Flow<Album>
suspend fun getAlbumWithPhotos(uuid: String): Album
suspend fun createAlbum(album: Album): Result<Album>
suspend fun deleteAlbum(album: Album): Result<Unit>
suspend fun deleteAll()

suspend fun link(photoUUIDs: List<String>, albumUUID: String)
suspend fun link(ref: AlbumPhotoRef)
suspend fun unlink(photoUUIDs: List<String>, uuid: String)
suspend fun getAllPhotoIdsFor(albumUUID: String): List<String>
suspend fun unlinkAll()
suspend fun rename(albumUUID: String, newName: String)
suspend fun getAllAlbumPhotoLinks(): List<AlbumPhotoRef>
}
Original file line number Diff line number Diff line change
Expand Up @@ -28,12 +28,15 @@ import androidx.compose.material3.OutlinedTextField
import androidx.compose.material3.Text
import androidx.compose.material3.TextButton
import androidx.compose.runtime.Composable
import androidx.compose.runtime.LaunchedEffect
import androidx.compose.runtime.getValue
import androidx.compose.runtime.mutableStateOf
import androidx.compose.runtime.remember
import androidx.compose.runtime.setValue
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.focus.FocusRequester
import androidx.compose.ui.focus.focusRequester
import androidx.compose.ui.res.stringResource
import androidx.compose.ui.tooling.preview.Preview
import androidx.compose.ui.unit.dp
Expand All @@ -44,7 +47,15 @@ import dev.leonlatsch.photok.ui.theme.AppTheme

@Composable
fun CreateAlbumDialog(uiState: AlbumsUiState, handleUiEvent: (AlbumsUiEvent) -> Unit) {
val focusRequester = remember {
FocusRequester()
}

if (uiState.showCreateDialog) {
LaunchedEffect(Unit) {
focusRequester.requestFocus()
}

Dialog(onDismissRequest = { handleUiEvent(AlbumsUiEvent.HideCreateDialog) }) {
Card {
Column(
Expand All @@ -63,6 +74,7 @@ fun CreateAlbumDialog(uiState: AlbumsUiState, handleUiEvent: (AlbumsUiEvent) ->
value = albumName,
onValueChange = { albumName = it },
placeholder = { Text(stringResource(R.string.gallery_albums_create_placeholder)) },
modifier = Modifier.focusRequester(focusRequester)
)

Row(
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,118 @@
/*
* 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.gallery.albums.ui.compose

import androidx.compose.foundation.layout.Arrangement
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.Row
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.padding
import androidx.compose.material3.Button
import androidx.compose.material3.Card
import androidx.compose.material3.MaterialTheme
import androidx.compose.material3.OutlinedTextField
import androidx.compose.material3.Text
import androidx.compose.material3.TextButton
import androidx.compose.runtime.Composable
import androidx.compose.runtime.LaunchedEffect
import androidx.compose.runtime.getValue
import androidx.compose.runtime.mutableStateOf
import androidx.compose.runtime.remember
import androidx.compose.runtime.setValue
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.focus.FocusRequester
import androidx.compose.ui.focus.focusRequester
import androidx.compose.ui.res.stringResource
import androidx.compose.ui.tooling.preview.Preview
import androidx.compose.ui.unit.dp
import androidx.compose.ui.window.Dialog
import dev.leonlatsch.photok.R
import dev.leonlatsch.photok.ui.theme.AppTheme

@Composable
fun RenameAlbumDialog(
show: Boolean,
onDismiss: () -> Unit,
currentName: String,
onRename: (String) -> Unit,
) {
val focusRequester = remember {
FocusRequester()
}

if (show) {
LaunchedEffect(Unit) {
focusRequester.requestFocus()
}

Dialog(onDismissRequest = onDismiss) {
Card {
Column(
horizontalAlignment = Alignment.CenterHorizontally,
verticalArrangement = Arrangement.spacedBy(12.dp),
modifier = Modifier.padding(16.dp)
) {
var albumName by remember { mutableStateOf(currentName) }

Text(
stringResource(R.string.gallery_albums_rename_title),
style = MaterialTheme.typography.headlineSmall
)

OutlinedTextField(
value = albumName,
onValueChange = { albumName = it },
placeholder = { Text(stringResource(R.string.gallery_albums_create_placeholder)) },
modifier = Modifier.focusRequester(focusRequester)
)

Row(
modifier = Modifier.fillMaxWidth(),
horizontalArrangement = Arrangement.SpaceBetween,
) {
TextButton(onClick = onDismiss) {
Text(stringResource(R.string.common_cancel))
}
Button(
onClick = {
onDismiss()
onRename(albumName)
},
enabled = albumName.isNotEmpty()
) {
Text(stringResource(R.string.common_rename))
}
}
}
}
}
}
}

@Preview
@Composable
private fun RenameAlbumDialogPreview() {
AppTheme {
RenameAlbumDialog(
show = true,
onDismiss = {},
currentName = "previous name",
onRename = {}
)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,13 @@ class GalleryUiStateFactory @Inject constructor() {
GalleryUiState.Empty
} else {
GalleryUiState.Content(
photos = photos.map { PhotoTile(it.fileName, it.type, it.uuid) },
photos = photos.map {
PhotoTile(
fileName = it.fileName,
type = it.type,
uuid = it.uuid
)
},
showAlbumSelectionDialog = showAlbumSelectionDialog,
)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -266,8 +266,8 @@ private fun GalleryPhotoTile(
} else {
val requestData = remember(photoTile) {
EncryptedImageRequestData(
photoTile.internalThumbnailFileName,
photoTile.type.mimeType
internalFileName = photoTile.internalThumbnailFileName,
mimeType = photoTile.type.mimeType
)
}

Expand Down
Loading

0 comments on commit 114f209

Please sign in to comment.