From e3df2f21d91f5f155a8830b1b01cd0b43f76f53c Mon Sep 17 00:00:00 2001 From: Bnyro <bnyro@tutanota.com> Date: Tue, 9 Apr 2024 22:02:16 +0200 Subject: [PATCH] feat: show more information in image details sheet --- .../ui/components/ImageInfoDialog.kt | 30 --------- .../ui/components/WallpaperInfoItem.kt | 46 +++++++++++++ .../infosheet/WallpaperInfoSheet.kt | 66 ++++++++----------- app/src/main/res/values-ar/strings.xml | 1 - app/src/main/res/values-be/strings.xml | 1 - app/src/main/res/values-cs/strings.xml | 1 - app/src/main/res/values-es/strings.xml | 1 - app/src/main/res/values-et/strings.xml | 1 - app/src/main/res/values-fa/strings.xml | 1 - app/src/main/res/values-hi/strings.xml | 1 - app/src/main/res/values-ia/strings.xml | 1 - app/src/main/res/values-id/strings.xml | 1 - app/src/main/res/values-pl/strings.xml | 1 - app/src/main/res/values-pt-rBR/strings.xml | 1 - app/src/main/res/values-ru/strings.xml | 1 - app/src/main/res/values-sr/strings.xml | 1 - app/src/main/res/values-tr/strings.xml | 1 - app/src/main/res/values-uk/strings.xml | 1 - app/src/main/res/values-zh-rCN/strings.xml | 1 - app/src/main/res/values/strings.xml | 2 +- 20 files changed, 74 insertions(+), 86 deletions(-) delete mode 100644 app/src/main/java/com/bnyro/wallpaper/ui/components/ImageInfoDialog.kt create mode 100644 app/src/main/java/com/bnyro/wallpaper/ui/components/WallpaperInfoItem.kt diff --git a/app/src/main/java/com/bnyro/wallpaper/ui/components/ImageInfoDialog.kt b/app/src/main/java/com/bnyro/wallpaper/ui/components/ImageInfoDialog.kt deleted file mode 100644 index 0a67b451..00000000 --- a/app/src/main/java/com/bnyro/wallpaper/ui/components/ImageInfoDialog.kt +++ /dev/null @@ -1,30 +0,0 @@ -package com.bnyro.wallpaper.ui.components - -import androidx.compose.runtime.Composable -import androidx.compose.ui.res.stringResource -import com.bnyro.wallpaper.R -import com.bnyro.wallpaper.db.obj.Wallpaper -import com.bnyro.wallpaper.ext.formatBinarySize -import com.bnyro.wallpaper.ui.components.dialogs.InfoDialog - -@Composable -fun ImageInfoDialog( - wallpaper: Wallpaper, - onDismissRequest: () -> Unit -) { - val items = mapOf( - stringResource(R.string.category) to wallpaper.category, - stringResource(R.string.author) to wallpaper.author, - stringResource(R.string.resolution) to wallpaper.resolution, - stringResource(R.string.fileSize) to wallpaper.fileSize?.formatBinarySize(), - stringResource(R.string.creationDate) to wallpaper.creationDate, - stringResource(R.string.source) to wallpaper.url - ) - - InfoDialog( - title = stringResource(R.string.info), - items = items - ) { - onDismissRequest.invoke() - } -} diff --git a/app/src/main/java/com/bnyro/wallpaper/ui/components/WallpaperInfoItem.kt b/app/src/main/java/com/bnyro/wallpaper/ui/components/WallpaperInfoItem.kt new file mode 100644 index 00000000..51f479bc --- /dev/null +++ b/app/src/main/java/com/bnyro/wallpaper/ui/components/WallpaperInfoItem.kt @@ -0,0 +1,46 @@ +package com.bnyro.wallpaper.ui.components + +import androidx.annotation.StringRes +import androidx.compose.foundation.clickable +import androidx.compose.foundation.shape.RoundedCornerShape +import androidx.compose.foundation.text.selection.SelectionContainer +import androidx.compose.material3.Icon +import androidx.compose.material3.ListItem +import androidx.compose.material3.Text +import androidx.compose.runtime.Composable +import androidx.compose.ui.Modifier +import androidx.compose.ui.draw.clip +import androidx.compose.ui.graphics.vector.ImageVector +import androidx.compose.ui.platform.LocalUriHandler +import androidx.compose.ui.res.stringResource +import androidx.compose.ui.unit.dp + +@Composable +fun WallpaperInfoItem( + icon: ImageVector, + @StringRes title: Int, + value: String, + isUrl: Boolean = false +) { + val uriHandler = LocalUriHandler.current + + ListItem( + modifier = Modifier + .clip(RoundedCornerShape(12.dp)) + .clickable(enabled = isUrl) { + uriHandler.openUri(value) + }, + headlineContent = { Text(text = stringResource(title)) }, + leadingContent = { + Icon( + imageVector = icon, + contentDescription = null + ) + }, + supportingContent = { + SelectionContainer { + Text(text = value) + } + } + ) +} \ No newline at end of file diff --git a/app/src/main/java/com/bnyro/wallpaper/ui/components/infosheet/WallpaperInfoSheet.kt b/app/src/main/java/com/bnyro/wallpaper/ui/components/infosheet/WallpaperInfoSheet.kt index 6e5ec78b..926106ca 100644 --- a/app/src/main/java/com/bnyro/wallpaper/ui/components/infosheet/WallpaperInfoSheet.kt +++ b/app/src/main/java/com/bnyro/wallpaper/ui/components/infosheet/WallpaperInfoSheet.kt @@ -7,13 +7,16 @@ import androidx.compose.foundation.layout.fillMaxWidth import androidx.compose.foundation.layout.height import androidx.compose.foundation.layout.padding import androidx.compose.material.icons.Icons -import androidx.compose.material.icons.rounded.Image -import androidx.compose.material.icons.rounded.Label -import androidx.compose.material.icons.rounded.Storage +import androidx.compose.material.icons.filled.AccessTime +import androidx.compose.material.icons.filled.Category +import androidx.compose.material.icons.filled.Image +import androidx.compose.material.icons.filled.Label +import androidx.compose.material.icons.filled.Person +import androidx.compose.material.icons.filled.PhotoSizeSelectLarge +import androidx.compose.material.icons.filled.Storage +import androidx.compose.material.icons.filled.Web import androidx.compose.material3.Divider import androidx.compose.material3.ExperimentalMaterial3Api -import androidx.compose.material3.Icon -import androidx.compose.material3.ListItem import androidx.compose.material3.MaterialTheme import androidx.compose.material3.ModalBottomSheet import androidx.compose.material3.Text @@ -25,11 +28,14 @@ import androidx.compose.ui.res.stringResource import androidx.compose.ui.unit.dp import com.bnyro.wallpaper.R import com.bnyro.wallpaper.db.obj.Wallpaper +import com.bnyro.wallpaper.ui.components.WallpaperInfoItem @OptIn(ExperimentalMaterial3Api::class) @Composable fun WallpaperInfoSheet(onDismissRequest: () -> Unit, wallpaper: Wallpaper) { + val context = LocalContext.current val state = rememberModalBottomSheetState(skipPartiallyExpanded = true) + ModalBottomSheet(onDismissRequest, sheetState = state) { Column(Modifier.padding(horizontal = 16.dp, vertical = 8.dp)) { Text( @@ -48,45 +54,27 @@ fun WallpaperInfoSheet(onDismissRequest: () -> Unit, wallpaper: Wallpaper) { style = MaterialTheme.typography.titleLarge ) wallpaper.title?.let { - ListItem( - headlineContent = { Text(text = stringResource(R.string.label)) }, - leadingContent = { - Icon( - imageVector = Icons.Rounded.Label, - contentDescription = null - ) - }, - supportingContent = { - Text(text = it) - }) + WallpaperInfoItem(Icons.Default.Label, R.string.label, it) + } + wallpaper.author?.let { + WallpaperInfoItem(Icons.Default.Person, R.string.author, it) + } + wallpaper.category?.let { + WallpaperInfoItem(Icons.Default.Category, R.string.category, it) } wallpaper.resolution?.let { - ListItem( - headlineContent = { Text(text = stringResource(id = R.string.resolution)) }, - leadingContent = { - Icon( - imageVector = Icons.Rounded.Image, - contentDescription = null - ) - }, - supportingContent = { - Text(text = it) - }) + WallpaperInfoItem(Icons.Default.PhotoSizeSelectLarge, R.string.resolution, it) } wallpaper.fileSize?.let { - val context = LocalContext.current - ListItem( - headlineContent = { Text(text = stringResource(R.string.file_size)) }, - leadingContent = { - Icon( - imageVector = Icons.Rounded.Storage, - contentDescription = null - ) - }, - supportingContent = { - Text(text = Formatter.formatFileSize(context, it)) - }) + WallpaperInfoItem(Icons.Default.Storage, R.string.fileSize, Formatter.formatFileSize(context, it)) + } + wallpaper.creationDate?.let { + WallpaperInfoItem(Icons.Default.AccessTime, R.string.creationDate, it) + } + wallpaper.url?.let { + WallpaperInfoItem(Icons.Default.Web, R.string.source, it, true) } + WallpaperInfoItem(Icons.Default.Image, R.string.image_url, wallpaper.imgSrc, true) } } } \ No newline at end of file diff --git a/app/src/main/res/values-ar/strings.xml b/app/src/main/res/values-ar/strings.xml index 8dfac434..76b7780c 100644 --- a/app/src/main/res/values-ar/strings.xml +++ b/app/src/main/res/values-ar/strings.xml @@ -69,7 +69,6 @@ <string name="colors">الألوان</string> <string name="details">التفاصيل</string> <string name="label">التسمية</string> - <string name="file_size">حجم الملف</string> <string name="error">خطأ</string> <string name="done">إنتهى</string> <string name="save">حفظ</string> diff --git a/app/src/main/res/values-be/strings.xml b/app/src/main/res/values-be/strings.xml index 2d81232b..85a533d0 100644 --- a/app/src/main/res/values-be/strings.xml +++ b/app/src/main/res/values-be/strings.xml @@ -52,7 +52,6 @@ <string name="invert_wallpaper_by_theme_summary">Перавярніце шпалеры, каб яны былі цёмнымі на цёмных тэмах і светлымі на светлых тэмах.</string> <string name="set_as">Ўсталяваць як</string> <string name="apply">Ужыць</string> - <string name="file_size">Памер файла</string> <string name="edit">Рэдагаваць</string> <string name="directories">Каталогі</string> <string name="import_favorites">Імпарт абранага</string> diff --git a/app/src/main/res/values-cs/strings.xml b/app/src/main/res/values-cs/strings.xml index dbc78c3b..fa6543bc 100644 --- a/app/src/main/res/values-cs/strings.xml +++ b/app/src/main/res/values-cs/strings.xml @@ -71,7 +71,6 @@ <string name="colors">Barvy</string> <string name="details">Podrobnosti</string> <string name="label">Štítek</string> - <string name="file_size">Velikost souboru</string> <string name="error">Chyba</string> <string name="done">Hotovo</string> <string name="save">Uložit</string> diff --git a/app/src/main/res/values-es/strings.xml b/app/src/main/res/values-es/strings.xml index ce6d9e7b..c1762049 100644 --- a/app/src/main/res/values-es/strings.xml +++ b/app/src/main/res/values-es/strings.xml @@ -80,7 +80,6 @@ <string name="colors">Colores</string> <string name="details">Detalles</string> <string name="label">Etiqueta</string> - <string name="file_size">Tamaño del archivo</string> <string name="error">Error</string> <string name="done">Hecho</string> <string name="save">Guardar</string> diff --git a/app/src/main/res/values-et/strings.xml b/app/src/main/res/values-et/strings.xml index a1ce1434..8e48fbed 100644 --- a/app/src/main/res/values-et/strings.xml +++ b/app/src/main/res/values-et/strings.xml @@ -67,7 +67,6 @@ <string name="favorite">Lemmik</string> <string name="save">Salvesta</string> <string name="done">Valmis</string> - <string name="file_size">Faili suurus</string> <string name="error">Viga</string> <string name="colors">Värvid</string> <string name="details">Üksikasjad</string> diff --git a/app/src/main/res/values-fa/strings.xml b/app/src/main/res/values-fa/strings.xml index a3935cc9..6568c0c5 100644 --- a/app/src/main/res/values-fa/strings.xml +++ b/app/src/main/res/values-fa/strings.xml @@ -55,7 +55,6 @@ <string name="preview_invert_effect">پیشنمایش جلوه وارونگی</string> <string name="colors">رنگ ها</string> <string name="details">ریزگان</string> - <string name="file_size">حجم پرونده</string> <string name="error">خطا</string> <string name="done">انجام شد</string> <string name="edit">ویرایش</string> diff --git a/app/src/main/res/values-hi/strings.xml b/app/src/main/res/values-hi/strings.xml index f8eb68ca..8a0781d9 100644 --- a/app/src/main/res/values-hi/strings.xml +++ b/app/src/main/res/values-hi/strings.xml @@ -69,7 +69,6 @@ <string name="image_info">छवि जानकारी</string> <string name="dismiss">खारिज</string> <string name="preview_invert_effect">पूर्वावलोकन उलटा प्रभाव</string> - <string name="file_size">फाइल का साइज़</string> <string name="applying_wallpaper">वॉलपेपर लगाया जा रहा है</string> <string name="zoom">ज़ूम (पहलू अनुपात रखता है)</string> <string name="fit_height">ऊंचाई पर फिट</string> diff --git a/app/src/main/res/values-ia/strings.xml b/app/src/main/res/values-ia/strings.xml index 4b3f3db7..b80ec997 100644 --- a/app/src/main/res/values-ia/strings.xml +++ b/app/src/main/res/values-ia/strings.xml @@ -65,7 +65,6 @@ <string name="wallpaper">Fundo de schermo</string> <string name="details">Detalios</string> <string name="label">Etiquetta</string> - <string name="file_size">Dimension del file</string> <string name="error">Error</string> <string name="set_with">Definir con...</string> <string name="apply">Applicar</string> diff --git a/app/src/main/res/values-id/strings.xml b/app/src/main/res/values-id/strings.xml index 65e70045..eb136baf 100644 --- a/app/src/main/res/values-id/strings.xml +++ b/app/src/main/res/values-id/strings.xml @@ -79,7 +79,6 @@ <string name="preview_invert_effect">Pratinjau Efek Penyesuaian Warna</string> <string name="details">Detail</string> <string name="label">Label</string> - <string name="file_size">Ukuran berkas</string> <string name="error">Kesalahan</string> <string name="favorite">Favorit</string> <string name="go_back">Kembali</string> diff --git a/app/src/main/res/values-pl/strings.xml b/app/src/main/res/values-pl/strings.xml index 5d3ca392..c6f02f07 100644 --- a/app/src/main/res/values-pl/strings.xml +++ b/app/src/main/res/values-pl/strings.xml @@ -67,7 +67,6 @@ <string name="colors">Kolory</string> <string name="details">Szczegóły</string> <string name="label">Etykieta</string> - <string name="file_size">Rozmiar pliku</string> <string name="error">Błąd</string> <string name="done">Gotowe</string> <string name="edit">Edytuj</string> diff --git a/app/src/main/res/values-pt-rBR/strings.xml b/app/src/main/res/values-pt-rBR/strings.xml index 54d3d80f..ee2b008e 100644 --- a/app/src/main/res/values-pt-rBR/strings.xml +++ b/app/src/main/res/values-pt-rBR/strings.xml @@ -69,7 +69,6 @@ <string name="apply">Aplicar</string> <string name="preview_invert_effect">Pré-visualizar o efeito invertido</string> <string name="colors">Cores</string> - <string name="file_size">Tamanho do arquivo</string> <string name="error">Erro</string> <string name="done">Feito</string> <string name="save">Salvar</string> diff --git a/app/src/main/res/values-ru/strings.xml b/app/src/main/res/values-ru/strings.xml index bbac3cb7..2adfe3ea 100644 --- a/app/src/main/res/values-ru/strings.xml +++ b/app/src/main/res/values-ru/strings.xml @@ -84,7 +84,6 @@ <string name="colors">Цвета</string> <string name="details">Подробности</string> <string name="label">Метка</string> - <string name="file_size">Размер файла</string> <string name="error">Ошибка</string> <string name="edit">Редактировать</string> <string name="favorite">Добавить в избранное</string> diff --git a/app/src/main/res/values-sr/strings.xml b/app/src/main/res/values-sr/strings.xml index 4a16c3cf..a06d9e4e 100644 --- a/app/src/main/res/values-sr/strings.xml +++ b/app/src/main/res/values-sr/strings.xml @@ -84,7 +84,6 @@ <string name="details">Детаљи</string> <string name="image_info">Информације о слици</string> <string name="label">Ознака</string> - <string name="file_size">Величина фајла</string> <string name="done">Готово</string> <string name="error">Грешка</string> <string name="save">Сачувај</string> diff --git a/app/src/main/res/values-tr/strings.xml b/app/src/main/res/values-tr/strings.xml index d20989d7..7f932b32 100644 --- a/app/src/main/res/values-tr/strings.xml +++ b/app/src/main/res/values-tr/strings.xml @@ -64,7 +64,6 @@ <string name="wallpaper">Duvar Kağıdı</string> <string name="apply">Uygula</string> <string name="preview_invert_effect">Değiştirme Efektini Ön İzle</string> - <string name="file_size">Dosya Boyutu</string> <string name="favorite">Sık Kullanılan</string> <string name="go_back">Geri Dön</string> <string name="image_info">Resim Bilgileri</string> diff --git a/app/src/main/res/values-uk/strings.xml b/app/src/main/res/values-uk/strings.xml index 190e2384..4c9eb107 100644 --- a/app/src/main/res/values-uk/strings.xml +++ b/app/src/main/res/values-uk/strings.xml @@ -78,7 +78,6 @@ <string name="set_with">Встановити з...</string> <string name="set_as">Встановити як</string> <string name="preview_invert_effect">Передперегляд ефекта інверсії</string> - <string name="file_size">Розмір файла</string> <string name="error">Помилка</string> <string name="done">Готово</string> <string name="colors">Кольори</string> diff --git a/app/src/main/res/values-zh-rCN/strings.xml b/app/src/main/res/values-zh-rCN/strings.xml index a9ccd3fd..d8dea3ba 100644 --- a/app/src/main/res/values-zh-rCN/strings.xml +++ b/app/src/main/res/values-zh-rCN/strings.xml @@ -81,7 +81,6 @@ <string name="colors">色彩</string> <string name="details">细节</string> <string name="label">标签</string> - <string name="file_size">文件大小</string> <string name="error">错误</string> <string name="done">已完成</string> <string name="save">保存</string> diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 730e9d64..31a95166 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -28,6 +28,7 @@ <string name="fileSize">File size</string> <string name="source">Source</string> <string name="creationDate">Creation date</string> + <string name="image_url">Image URL</string> <!-- Set Wallpaper --> <string name="both">Both</string> <string name="home">Home screen</string> @@ -96,7 +97,6 @@ <string name="colors">Colors</string> <string name="details">Details</string> <string name="label">Label</string> - <string name="file_size">File Size</string> <string name="error">Error</string> <string name="done">Done</string> <string name="save">Save</string>