diff --git a/app/src/main/java/helium314/keyboard/latin/gif/GifPickerView.kt b/app/src/main/java/helium314/keyboard/latin/gif/GifPickerView.kt index 9725de60b..4d0b59d09 100644 --- a/app/src/main/java/helium314/keyboard/latin/gif/GifPickerView.kt +++ b/app/src/main/java/helium314/keyboard/latin/gif/GifPickerView.kt @@ -1208,6 +1208,7 @@ class GifPickerView @JvmOverloads constructor( val imageView: ImageView = itemView.findViewById(R.id.gifThumbImage) val liveBadge: TextView = itemView.findViewById(R.id.liveBadge) val packLabel: TextView = itemView.findViewById(R.id.packLabel) + val packCount: TextView = itemView.findViewById(R.id.packCount) val insertOverlay: View = itemView.findViewById(R.id.insertOverlay) var autoplayUri: Uri? = null var autoplayJob: Job? = null @@ -1290,14 +1291,18 @@ class GifPickerView @JvmOverloads constructor( val h = context.resources.getDimensionPixelSize(R.dimen.gif_thumb_height) lp.height = h val computedWidth = (h * item.width.toFloat() / item.height.coerceAtLeast(1)).toInt() - lp.width = computedWidth.coerceIn((h * 0.5f).toInt(), (h * 2.0f).toInt()) + // pack tiles are square, so a narrow cover image doesn't squeeze the pack name + lp.width = if (item.isPack) h else computedWidth.coerceIn((h * 0.5f).toInt(), (h * 2.0f).toInt()) holder.itemView.layoutParams = lp if (item.isPack) { - holder.packLabel.text = context.getString(R.string.gif_pack_label, item.attribution.orEmpty(), item.extra.orEmpty()) + holder.packLabel.text = item.attribution.orEmpty() holder.packLabel.visibility = View.VISIBLE + holder.packCount.text = item.extra.orEmpty() + holder.packCount.visibility = if (item.extra.isNullOrEmpty()) View.GONE else View.VISIBLE } else { holder.packLabel.visibility = View.GONE + holder.packCount.visibility = View.GONE } stopAutoplay(holder) diff --git a/app/src/main/java/helium314/keyboard/settings/screens/GifSettingsScreen.kt b/app/src/main/java/helium314/keyboard/settings/screens/GifSettingsScreen.kt index 52290f016..6f3a669f3 100644 --- a/app/src/main/java/helium314/keyboard/settings/screens/GifSettingsScreen.kt +++ b/app/src/main/java/helium314/keyboard/settings/screens/GifSettingsScreen.kt @@ -79,6 +79,10 @@ fun GifSettingsScreen( } val connectionState by manager.state.collectAsState() + // The plugin is unbound while no client uses it, so opening this screen reconnects: show a trusted installed + // plugin as active meanwhile instead of flashing Disconnected / Connecting (same as the plugins hub) + val statusState = if (connectionState == GifPluginManager.State.DISCONNECTED || connectionState == GifPluginManager.State.CONNECTING) + GifPluginManager.State.CONNECTED else connectionState var providers by remember { mutableStateOf>(manager.cachedProviders) } var isLoadingProviders by remember { mutableStateOf(false) } @@ -169,15 +173,15 @@ fun GifSettingsScreen( } } ) { - val message = when (connectionState) { + val message = when (statusState) { GifPluginManager.State.NOT_INSTALLED -> stringResource(R.string.gif_plugin_not_installed_desc) GifPluginManager.State.UNTRUSTED_PLUGIN -> stringResource(R.string.gif_plugin_untrusted_desc) GifPluginManager.State.CONNECTED -> stringResource(R.string.libraries_status_active) - GifPluginManager.State.CONNECTING -> stringResource(R.string.gif_connecting) + GifPluginManager.State.CONNECTING, GifPluginManager.State.DISCONNECTED -> stringResource(R.string.gif_connecting) GifPluginManager.State.UNAVAILABLE -> stringResource(R.string.gif_plugin_unavailable_desc) GifPluginManager.State.PLUGIN_TOO_OLD -> stringResource(R.string.gif_error_plugin_too_old) GifPluginManager.State.HOST_TOO_OLD -> stringResource(R.string.gif_error_host_too_old) - else -> connectionState.name + else -> statusState.name } Text(message) } @@ -204,15 +208,15 @@ fun GifSettingsScreen( Column { PreferenceCategory(stringResource(R.string.gif_plugin_status_title)) - val gifPluginSummary = when (connectionState) { + val gifPluginSummary = when (statusState) { GifPluginManager.State.CONNECTED -> stringResource(R.string.libraries_status_active) - GifPluginManager.State.CONNECTING -> stringResource(R.string.gif_connecting) + GifPluginManager.State.CONNECTING, GifPluginManager.State.DISCONNECTED -> stringResource(R.string.gif_connecting) GifPluginManager.State.NOT_INSTALLED -> stringResource(R.string.libraries_status_not_installed) GifPluginManager.State.UNTRUSTED_PLUGIN -> stringResource(R.string.gif_error_untrusted) GifPluginManager.State.PLUGIN_TOO_OLD -> stringResource(R.string.gif_error_plugin_too_old) GifPluginManager.State.HOST_TOO_OLD -> stringResource(R.string.gif_error_host_too_old) GifPluginManager.State.UNAVAILABLE -> stringResource(R.string.gif_error_unavailable) - else -> connectionState.name + else -> statusState.name } Preference( diff --git a/app/src/main/java/helium314/keyboard/settings/screens/LibrariesHubScreen.kt b/app/src/main/java/helium314/keyboard/settings/screens/LibrariesHubScreen.kt index f6cee3fbe..7d62736cd 100644 --- a/app/src/main/java/helium314/keyboard/settings/screens/LibrariesHubScreen.kt +++ b/app/src/main/java/helium314/keyboard/settings/screens/LibrariesHubScreen.kt @@ -198,7 +198,10 @@ fun LibrariesHubScreen( val gifManager = remember { helium314.keyboard.latin.gif.GifPluginManager.get(context) } val gifState = gifManager.state.collectAsState() val gifSummary = when (gifState.value) { - helium314.keyboard.latin.gif.GifPluginManager.State.CONNECTED -> stringResource(R.string.libraries_status_active) + // unbound while unused, so disconnected / connecting is the normal idle state of a trusted plugin + helium314.keyboard.latin.gif.GifPluginManager.State.CONNECTED, + helium314.keyboard.latin.gif.GifPluginManager.State.CONNECTING, + helium314.keyboard.latin.gif.GifPluginManager.State.DISCONNECTED -> stringResource(R.string.libraries_status_active) helium314.keyboard.latin.gif.GifPluginManager.State.UNTRUSTED_PLUGIN -> stringResource(R.string.gif_error_untrusted) helium314.keyboard.latin.gif.GifPluginManager.State.NOT_INSTALLED -> stringResource(R.string.libraries_status_not_installed) else -> stringResource(R.string.installed) diff --git a/app/src/main/res/drawable/bg_gif_pack_label_scrim.xml b/app/src/main/res/drawable/bg_gif_pack_label_scrim.xml new file mode 100644 index 000000000..81ec0acdf --- /dev/null +++ b/app/src/main/res/drawable/bg_gif_pack_label_scrim.xml @@ -0,0 +1,8 @@ + + + + + diff --git a/app/src/main/res/layout/item_gif_thumb.xml b/app/src/main/res/layout/item_gif_thumb.xml index 6e3c3f9d1..c65a99c34 100644 --- a/app/src/main/res/layout/item_gif_thumb.xml +++ b/app/src/main/res/layout/item_gif_thumb.xml @@ -34,21 +34,40 @@ android:paddingVertical="1dp" android:visibility="gone" /> - + + + +