Compare commits

..

1 Commits

Author SHA1 Message Date
Sylvia van Os
0431803336 Load thumbnails on main screen asynchronously
Decoding a bitmap can be slow. On slow devices, loading all the images
as soon as the card should be shown can lead to UI freezes.

By loading the thumbnail asynchronously, scrolling quickly remains
smooth even on slow devices.
2024-06-27 18:28:27 +02:00
10 changed files with 51 additions and 55 deletions

View File

@@ -1,9 +1,5 @@
# Changelog
## Unreleased - 137
- Allow long store names in preview to split over multiple lines
## v2.30.0 - 136 (2024-06-18)
- Support for creating a card when sharing plain text

View File

@@ -6,6 +6,8 @@ import android.database.Cursor;
import android.graphics.Bitmap;
import android.graphics.Color;
import android.graphics.drawable.Drawable;
import android.os.Handler;
import android.os.Looper;
import android.util.SparseBooleanArray;
import android.util.TypedValue;
import android.view.HapticFeedbackConstants;
@@ -88,9 +90,29 @@ public class LoyaltyCardCursorAdapter extends BaseCursorAdapter<LoyaltyCardCurso
inputHolder.mDivider.setVisibility(View.GONE);
LoyaltyCard loyaltyCard = LoyaltyCard.toLoyaltyCard(inputCursor);
Bitmap icon = Utils.retrieveCardImage(mContext, loyaltyCard.id, ImageLocationType.icon);
if (mLoyaltyCardListDisplayOptions.showingNameBelowThumbnail() && icon != null) {
inputHolder.mCardIcon.setContentDescription(loyaltyCard.store);
// Default header at first, real icon will be retrieved asynchronously if it exists to ensure
// smooth scrolling even on slower devices
Utils.setIconOrTextWithBackground(mContext, loyaltyCard, null, inputHolder.mCardIcon, inputHolder.mCardText);
inputHolder.toggleCardStateIcon(loyaltyCard.starStatus != 0, loyaltyCard.archiveStatus != 0, itemSelected(inputCursor.getPosition()));
boolean hasIcon = Utils.retrieveCardImageAsFile(mContext, loyaltyCard.id, ImageLocationType.icon).exists();
if (hasIcon) {
new Thread() {
@Override
public void run() {
Bitmap icon = Utils.retrieveCardImage(mContext, loyaltyCard.id, ImageLocationType.icon);
new Handler(Looper.getMainLooper()).post(() -> {
inputHolder.mIconBackgroundColor = Utils.setIconOrTextWithBackground(mContext, loyaltyCard, icon, inputHolder.mCardIcon, inputHolder.mCardText);
inputHolder.toggleCardStateIcon(loyaltyCard.starStatus != 0, loyaltyCard.archiveStatus != 0, itemSelected(inputHolder.getAdapterPosition()));
});
}
}.start();
}
if (mLoyaltyCardListDisplayOptions.showingNameBelowThumbnail() && hasIcon) {
showDivider = true;
inputHolder.setStoreField(loyaltyCard.store);
} else {
@@ -122,11 +144,6 @@ public class LoyaltyCardCursorAdapter extends BaseCursorAdapter<LoyaltyCardCurso
inputHolder.setExtraField(inputHolder.mExpiryField, null, null, false);
}
inputHolder.mCardIcon.setContentDescription(loyaltyCard.store);
inputHolder.mIconBackgroundColor = Utils.setIconOrTextWithBackground(mContext, loyaltyCard, icon, inputHolder.mCardIcon, inputHolder.mCardText);
inputHolder.toggleCardStateIcon(loyaltyCard.starStatus != 0, loyaltyCard.archiveStatus != 0, itemSelected(inputCursor.getPosition()));
inputHolder.itemView.setActivated(mSelectedItems.get(inputCursor.getPosition(), false));
applyIconAnimation(inputHolder, inputCursor.getPosition());
applyClickEvents(inputHolder, inputCursor.getPosition());

View File

@@ -39,7 +39,6 @@ import androidx.appcompat.app.AppCompatDelegate;
import androidx.core.graphics.ColorUtils;
import androidx.core.os.LocaleListCompat;
import androidx.core.view.WindowInsetsControllerCompat;
import androidx.core.widget.TextViewCompat;
import androidx.exifinterface.media.ExifInterface;
import androidx.palette.graphics.Palette;
@@ -942,22 +941,6 @@ public class Utils {
if (icon != null) {
textWhenNoImage.setVisibility(View.GONE);
} else {
// Manually calculate how many lines will be needed
// This is necessary because Android's auto sizing will split over lines way before reaching the minimum font size and store names split over multiple lines are harder to scan with a quick glance so we should try to prevent it
// Because we have to write the text before we can actually know the exact laid out size (trying to delay this causes bugs where the autosize fails) we have to take some... weird shortcuts
// At this point textWhenNoImage.getWidth() still returns 0, so we cheat by calculating the whole width of the screen and then dividing it by the amount of columns
int textviewWidth = Resources.getSystem().getDisplayMetrics().widthPixels / context.getResources().getInteger(R.integer.main_view_card_columns);
// Calculate how wide a character is and calculate how many characters fit in a line
int characterWidth = TextViewCompat.getAutoSizeMinTextSize(textWhenNoImage);
int maxWidthPerLine = textviewWidth - textWhenNoImage.getPaddingStart() - textWhenNoImage.getPaddingEnd();
// Set amount of lines based on what could fit at most
int maxLines = ((loyaltyCard.store.length() * characterWidth) / maxWidthPerLine) + 1;
textWhenNoImage.setMaxLines(maxLines);
// Actually set the text and colour
textWhenNoImage.setVisibility(View.VISIBLE);
textWhenNoImage.setText(loyaltyCard.store);
textWhenNoImage.setTextColor(Utils.needsDarkForeground(headerColor) ? Color.BLACK : Color.WHITE);

View File

@@ -29,7 +29,6 @@
android:layout_height="match_parent"
android:contentDescription="@string/thumbnailDescription"
android:scaleType="fitCenter"
android:src="@mipmap/ic_launcher"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
@@ -42,8 +41,12 @@
android:layout_height="match_parent"
android:textStyle="bold"
app:autoSizeTextType="uniform"
app:autoSizeMinTextSize="12sp"
app:autoSizeMaxTextSize="100sp"
app:autoSizeStepGranularity="2sp"
android:gravity="center"
android:padding="20dp" />
android:maxLines="1"
android:layout_margin="20dp" />
<ImageView
android:importantForAccessibility="no"

View File

@@ -7,8 +7,8 @@ Heimen Stoffels
Oğuz Ersen
FC (Fay) Stegerman
Katharine Chui
StoyanDimitrov
SlavekB
StoyanDimitrov
mondstern
IllusiveMan196
Altonss
@@ -28,25 +28,25 @@ Scrambled777
Giovanni Donisi
Jiri Grönroos
Samantaz Fox
arno-github
Cliff Heraldo
Sergio Paredes
Ankit Tiwari
Milo Ivir
Milan Šalka
arno-github
mdvhimself
Milan Šalka
Milo Ivir
Balázs Meskó
Skrripy
huuhaa
Jose Delvani
waffshappen
ngocanhtve
ikanakova
Projjal Moitra
Quentin PAGÈS
ikanakova
ngocanhtve
waffshappen
Ziad OUALHADJ
Robin Liu
Denis Shilin
Jose Delvani
Robin Liu
Ziad OUALHADJ
しいたけ
Alexander Ivanov
Viet Nguyen Hoang

View File

@@ -295,5 +295,4 @@
<string name="errorReadingFile">Файлът не може да бъде прочетен</string>
<string name="failedLaunchingFileManager">Не е намерено приложение за управление на файлове</string>
<string name="multipleBarcodesFoundPleaseChooseOne">Кой от намерените щрихкодове желаете да бъде използван?</string>
<string name="noCameraFoundGuideText">Изглежда, устройството няма камера. Ако има опитайте да рестартирате. В противен случай използвайте бутона „Още“, за да добавите шрихкод по друг начин.</string>
</resources>

View File

@@ -98,7 +98,7 @@
<string name="setFrontImage">Definir imagem frontal</string>
<string name="setBackImage">Definir imagem traseira</string>
<string name="removeImage">Remover imagem</string>
<string name="takePhoto">Tirar uma foto</string>
<string name="takePhoto">Tirar uma photo</string>
<string name="updateBarcodeQuestionTitle">Atualizar valor do código de barras?</string>
<string name="exportPasswordHint">Insira sua senha</string>
<string name="passwordRequired">Por favor, insira a senha</string>

View File

@@ -2,11 +2,11 @@
Copylefted libre software (GPLv3+) card management app.
[![GitHub Version](https://img.shields.io/github/v/release/CatimaLoyalty/Android.svg?logo=github&label=GitHub)](https://github.com/CatimaLoyalty/Android/releases)
[![GitHub Version](https://img.shields.io/github/v/release/TheLastProject/Catima.svg?logo=github&label=GitHub)](https://github.com/TheLastProject/Catima/releases)
[![IzzyOnDroid Version](https://img.shields.io/endpoint?url=https://apt.izzysoft.de/fdroid/api/v1/shield/me.hackerchick.catima)](https://apt.izzysoft.de/fdroid/index/apk/me.hackerchick.catima)
[![Google Play Store Version](https://img.shields.io/endpoint?color=blue&logo=google-play&url=https%3A%2F%2Fplay.cuzi.workers.dev%2Fplay%3Fi%3Dme.hackerchick.catima%26l%3DGoogle%2520Play%26m%3D%24version)](https://play.google.com/store/apps/details?id=me.hackerchick.catima)
![Android CI](https://github.com/CatimaLoyalty/Android/workflows/Android%20CI/badge.svg)
![Android CI](https://github.com/TheLastProject/Catima/workflows/Android%20CI/badge.svg)
[![Translation status](https://hosted.weblate.org/widgets/catima/-/svg-badge.svg)](https://hosted.weblate.org/engage/catima/)
[![Matrix](https://img.shields.io/matrix/catima%3Amatrix.org)](https://matrix.to/#/%23catima:matrix.org)
@@ -17,7 +17,7 @@ Copylefted libre software (GPLv3+) card management app.
<a href="https://play.google.com/store/apps/details?id=me.hackerchick.catima" target="_blank">
<img src="https://play.google.com/intl/en_us/badges/images/generic/en-play-badge.png" alt="Get it on Google Play" height="90"/></a>
[![Feature graphic](https://github.com/CatimaLoyalty/Android/raw/main/fastlane/metadata/android/en-US/images/featureGraphic.png)](https://catima.app/)
[![Feature graphic](https://github.com/TheLastProject/Catima/raw/main/fastlane/metadata/android/en-US/images/featureGraphic.png)](https://catima.app/)
*Logo by [Rose (TangentFoxy)](https://github.com/TangentFoxy), feature graphic by [Ziad OUALHADJ](https://github.com/ziadOUA)*
@@ -41,14 +41,14 @@ Supported barcodes:
# Screenshots
[<img src="https://github.com/CatimaLoyalty/Android/raw/main/fastlane/metadata/android/en-US/images/phoneScreenshots/screenshot-01.png" width=250>](https://github.com/CatimaLoyalty/Android/raw/main/fastlane/metadata/android/en-US/images/phoneScreenshots/screenshot-01.png)
[<img src="https://github.com/CatimaLoyalty/Android/raw/main/fastlane/metadata/android/en-US/images/phoneScreenshots/screenshot-02.png" width=250>](https://github.com/CatimaLoyalty/Android/raw/main/fastlane/metadata/android/en-US/images/phoneScreenshots/screenshot-02.png)
[<img src="https://github.com/CatimaLoyalty/Android/raw/main/fastlane/metadata/android/en-US/images/phoneScreenshots/screenshot-03.png" width=250>](https://github.com/CatimaLoyalty/Android/raw/main/fastlane/metadata/android/en-US/images/phoneScreenshots/screenshot-03.png)
[<img src="https://github.com/CatimaLoyalty/Android/raw/main/fastlane/metadata/android/en-US/images/phoneScreenshots/screenshot-04.png" width=250>](https://github.com/CatimaLoyalty/Android/raw/main/fastlane/metadata/android/en-US/images/phoneScreenshots/screenshot-04.png)
[<img src="https://github.com/CatimaLoyalty/Android/raw/main/fastlane/metadata/android/en-US/images/phoneScreenshots/screenshot-05.png" width=250>](https://github.com/CatimaLoyalty/Android/raw/main/fastlane/metadata/android/en-US/images/phoneScreenshots/screenshot-05.png)
[<img src="https://github.com/CatimaLoyalty/Android/raw/main/fastlane/metadata/android/en-US/images/phoneScreenshots/screenshot-06.png" width=250>](https://github.com/CatimaLoyalty/Android/raw/main/fastlane/metadata/android/en-US/images/phoneScreenshots/screenshot-06.png)
[<img src="https://github.com/CatimaLoyalty/Android/raw/main/fastlane/metadata/android/en-US/images/phoneScreenshots/screenshot-07.png" width=250>](https://github.com/CatimaLoyalty/Android/raw/main/fastlane/metadata/android/en-US/images/phoneScreenshots/screenshot-07.png)
[<img src="https://github.com/CatimaLoyalty/Android/raw/main/fastlane/metadata/android/en-US/images/phoneScreenshots/screenshot-08.png" width=250>](https://github.com/CatimaLoyalty/Android/raw/main/fastlane/metadata/android/en-US/images/phoneScreenshots/screenshot-08.png)
[<img src="https://github.com/TheLastProject/Catima/raw/main/fastlane/metadata/android/en-US/images/phoneScreenshots/screenshot-01.png" width=250>](https://github.com/TheLastProject/Catima/raw/main/fastlane/metadata/android/en-US/images/phoneScreenshots/screenshot-01.png)
[<img src="https://github.com/TheLastProject/Catima/raw/main/fastlane/metadata/android/en-US/images/phoneScreenshots/screenshot-02.png" width=250>](https://github.com/TheLastProject/Catima/raw/main/fastlane/metadata/android/en-US/images/phoneScreenshots/screenshot-02.png)
[<img src="https://github.com/TheLastProject/Catima/raw/main/fastlane/metadata/android/en-US/images/phoneScreenshots/screenshot-03.png" width=250>](https://github.com/TheLastProject/Catima/raw/main/fastlane/metadata/android/en-US/images/phoneScreenshots/screenshot-03.png)
[<img src="https://github.com/TheLastProject/Catima/raw/main/fastlane/metadata/android/en-US/images/phoneScreenshots/screenshot-04.png" width=250>](https://github.com/TheLastProject/Catima/raw/main/fastlane/metadata/android/en-US/images/phoneScreenshots/screenshot-04.png)
[<img src="https://github.com/TheLastProject/Catima/raw/main/fastlane/metadata/android/en-US/images/phoneScreenshots/screenshot-05.png" width=250>](https://github.com/TheLastProject/Catima/raw/main/fastlane/metadata/android/en-US/images/phoneScreenshots/screenshot-05.png)
[<img src="https://github.com/TheLastProject/Catima/raw/main/fastlane/metadata/android/en-US/images/phoneScreenshots/screenshot-06.png" width=250>](https://github.com/TheLastProject/Catima/raw/main/fastlane/metadata/android/en-US/images/phoneScreenshots/screenshot-06.png)
[<img src="https://github.com/TheLastProject/Catima/raw/main/fastlane/metadata/android/en-US/images/phoneScreenshots/screenshot-07.png" width=250>](https://github.com/TheLastProject/Catima/raw/main/fastlane/metadata/android/en-US/images/phoneScreenshots/screenshot-07.png)
[<img src="https://github.com/TheLastProject/Catima/raw/main/fastlane/metadata/android/en-US/images/phoneScreenshots/screenshot-08.png" width=250>](https://github.com/TheLastProject/Catima/raw/main/fastlane/metadata/android/en-US/images/phoneScreenshots/screenshot-08.png)
# Moving data from other apps

View File

@@ -1 +0,0 @@
- Allow long store names in preview to split over multiple lines

View File

@@ -1 +0,0 @@
Para seus códigos de barras, assinaturas, programas de fidelidade, cupons e ingressos.