Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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<List<ProviderInfo>>(manager.cachedProviders) }
var isLoadingProviders by remember { mutableStateOf(false) }
Expand Down Expand Up @@ -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)
}
Expand All @@ -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(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
8 changes: 8 additions & 0 deletions app/src/main/res/drawable/bg_gif_pack_label_scrim.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- keeps the pack name readable on any cover image -->
<shape xmlns:android="http://schemas.android.com/apk/res/android" android:shape="rectangle">
<gradient
android:angle="90"
android:startColor="#CC000000"
android:endColor="#00000000" />
</shape>
29 changes: 24 additions & 5 deletions app/src/main/res/layout/item_gif_thumb.xml
Original file line number Diff line number Diff line change
Expand Up @@ -34,21 +34,40 @@
android:paddingVertical="1dp"
android:visibility="gone" />

<!-- name and item count of a pack tile -->
<!-- name of a pack tile -->
<TextView
android:id="@+id/packLabel"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="bottom"
android:background="#99000000"
android:paddingHorizontal="4dp"
android:paddingVertical="2dp"
android:background="@drawable/bg_gif_pack_label_scrim"
android:paddingHorizontal="6dp"
android:paddingTop="14dp"
android:paddingBottom="4dp"
android:gravity="center"
android:maxLines="2"
android:ellipsize="end"
android:textSize="10sp"
android:textSize="11sp"
android:textStyle="bold"
android:textColor="#FFFFFF"
android:shadowColor="#99000000"
android:shadowRadius="2"
android:visibility="gone" />

<!-- item count of a pack tile -->
<TextView
android:id="@+id/packCount"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="top|end"
android:layout_margin="4dp"
android:background="@drawable/bg_gif_search_box"
android:backgroundTint="#88000000"
android:textSize="9sp"
android:textStyle="bold"
android:textColor="#FFFFFF"
android:paddingHorizontal="5dp"
android:paddingVertical="1dp"
android:visibility="gone" />

<FrameLayout
Expand Down
Loading