diff --git a/app/src/androidTest/java/com/owncloud/android/ui/fragment/OCFileListFragmentStaticServerIT.kt b/app/src/androidTest/java/com/owncloud/android/ui/fragment/OCFileListFragmentStaticServerIT.kt index 36df6af4366b..cbacb56a4b71 100644 --- a/app/src/androidTest/java/com/owncloud/android/ui/fragment/OCFileListFragmentStaticServerIT.kt +++ b/app/src/androidTest/java/com/owncloud/android/ui/fragment/OCFileListFragmentStaticServerIT.kt @@ -15,6 +15,7 @@ import com.owncloud.android.AbstractIT import com.owncloud.android.datamodel.OCFile import com.owncloud.android.lib.resources.shares.ShareType import com.owncloud.android.lib.resources.shares.ShareeUser +import com.owncloud.android.lib.resources.tags.Tag import com.owncloud.android.utils.MimeType import com.owncloud.android.utils.ScreenshotTest import org.junit.Assert @@ -50,7 +51,7 @@ class OCFileListFragmentStaticServerIT : AbstractIT() { fileLength = 3072000 modificationTimestamp = 746443755000 parentId = sut.storageManager.getFileByEncryptedRemotePath("/").fileId - tags = listOf("Top secret") + tags = listOf(Tag("", "Top secret", null)) sut.storageManager.saveFile(this) } @@ -72,7 +73,7 @@ class OCFileListFragmentStaticServerIT : AbstractIT() { fileLength = 12092000 modificationTimestamp = 746143952000 parentId = sut.storageManager.getFileByEncryptedRemotePath("/").fileId - tags = listOf("Confidential", "+5") + tags = listOf(Tag("", "Confidential", null), Tag("", "+5", null)) sut.storageManager.saveFile(this) } diff --git a/app/src/main/java/com/owncloud/android/datamodel/FileDataStorageManager.java b/app/src/main/java/com/owncloud/android/datamodel/FileDataStorageManager.java index ac14c91c8cd2..791aff566519 100644 --- a/app/src/main/java/com/owncloud/android/datamodel/FileDataStorageManager.java +++ b/app/src/main/java/com/owncloud/android/datamodel/FileDataStorageManager.java @@ -62,6 +62,7 @@ import com.owncloud.android.lib.resources.status.CapabilityBooleanType; import com.owncloud.android.lib.resources.status.E2EVersion; import com.owncloud.android.lib.resources.status.OCCapability; +import com.owncloud.android.lib.resources.tags.Tag; import com.owncloud.android.operations.RemoteOperationFailedException; import com.owncloud.android.utils.FileStorageUtils; import com.owncloud.android.utils.MimeType; @@ -1283,7 +1284,7 @@ private OCFile createFileInstance(FileEntity fileEntity) { ocFile.setTags(new ArrayList<>()); } else { try { - String[] tagsArray = gson.fromJson(tags, String[].class); + Tag[] tagsArray = gson.fromJson(tags, Tag[].class); ocFile.setTags(new ArrayList<>(Arrays.asList(tagsArray))); } catch (JsonSyntaxException e) { // ignore saved value due to api change diff --git a/app/src/main/java/com/owncloud/android/datamodel/OCFile.java b/app/src/main/java/com/owncloud/android/datamodel/OCFile.java index 479a59e130af..92bf6bd55645 100644 --- a/app/src/main/java/com/owncloud/android/datamodel/OCFile.java +++ b/app/src/main/java/com/owncloud/android/datamodel/OCFile.java @@ -30,6 +30,7 @@ import com.owncloud.android.lib.resources.files.model.ImageDimension; import com.owncloud.android.lib.resources.files.model.ServerFileInterface; import com.owncloud.android.lib.resources.shares.ShareeUser; +import com.owncloud.android.lib.resources.tags.Tag; import com.owncloud.android.utils.MimeType; import java.io.File; @@ -117,7 +118,7 @@ public class OCFile implements Parcelable, Comparable, ServerFileInterfa private long e2eCounter = -1; @Nullable private GeoLocation geolocation; - private List tags = new ArrayList<>(); + private List tags = new ArrayList<>(); private Long internalFolderSyncTimestamp = -1L; private String internalFolderSyncResult = ""; @@ -1047,11 +1048,11 @@ public GeoLocation getGeoLocation() { return geolocation; } - public List getTags() { + public List getTags() { return tags; } - public void setTags(List tags) { + public void setTags(List tags) { this.tags = tags; } diff --git a/app/src/main/java/com/owncloud/android/ui/adapter/OCFileListAdapter.java b/app/src/main/java/com/owncloud/android/ui/adapter/OCFileListAdapter.java index 4e9bc9bd1dec..a4930a9cae3a 100644 --- a/app/src/main/java/com/owncloud/android/ui/adapter/OCFileListAdapter.java +++ b/app/src/main/java/com/owncloud/android/ui/adapter/OCFileListAdapter.java @@ -15,6 +15,7 @@ import android.annotation.SuppressLint; import android.app.Activity; import android.content.ContentValues; +import android.content.res.ColorStateList; import android.content.res.Resources; import android.graphics.Bitmap; import android.graphics.Color; @@ -30,6 +31,7 @@ import android.widget.LinearLayout; import com.elyeproj.loaderviewlibrary.LoaderImageView; +import com.google.android.material.chip.Chip; import com.nextcloud.android.common.ui.theme.utils.ColorRole; import com.nextcloud.client.account.User; import com.nextcloud.client.database.entity.OfflineOperationEntity; @@ -62,6 +64,7 @@ import com.owncloud.android.lib.resources.shares.OCShare; import com.owncloud.android.lib.resources.shares.ShareType; import com.owncloud.android.lib.resources.shares.ShareeUser; +import com.owncloud.android.lib.resources.tags.Tag; import com.owncloud.android.operations.RefreshFolderOperation; import com.owncloud.android.operations.RemoteOperationFailedException; import com.owncloud.android.ui.activity.ComponentsGetter; @@ -580,12 +583,11 @@ private void bindListItemViewHolder(ListItemViewHolder holder, OCFile file) { holder.getSecondTag().setVisibility(View.GONE); holder.getTagMore().setVisibility(View.GONE); - holder.getFirstTag().setText(file.getTags().get(0)); + applyChipVisuals(holder.getFirstTag(), file.getTags().get(0)); if (file.getTags().size() > 1) { - viewThemeUtils.material.themeChipSuggestion(holder.getSecondTag()); holder.getSecondTag().setVisibility(View.VISIBLE); - holder.getSecondTag().setText(file.getTags().get(1)); + applyChipVisuals(holder.getSecondTag(), file.getTags().get(1)); } if (file.getTags().size() > 2) { @@ -649,6 +651,23 @@ private void bindListItemViewHolder(ListItemViewHolder holder, OCFile file) { configureThumbnail(holder, file); } + private void applyChipVisuals(Chip chip, Tag tag) { + viewThemeUtils.material.themeChipSuggestion(chip); + chip.setText(tag.getName()); + String tagColor = tag.getColor(); + if (TextUtils.isEmpty(tagColor)) { + return; + } + + try { + int color = Color.parseColor(tagColor); + chip.setChipStrokeColor(ColorStateList.valueOf(color)); + chip.setTextColor(color); + } catch (IllegalArgumentException e) { + Log_OC.d(TAG, "Exception applyChipVisuals: " + e); + } + } + private void prepareFileSize(ListItemViewHolder holder, OCFile file, long size) { holder.getFileSize().setVisibility(View.VISIBLE); String fileSizeText = getFileSizeText(file, size); diff --git a/app/src/main/java/com/owncloud/android/ui/fragment/FileDetailFragment.java b/app/src/main/java/com/owncloud/android/ui/fragment/FileDetailFragment.java index 7c4e38a35677..327ae698bfde 100644 --- a/app/src/main/java/com/owncloud/android/ui/fragment/FileDetailFragment.java +++ b/app/src/main/java/com/owncloud/android/ui/fragment/FileDetailFragment.java @@ -12,6 +12,7 @@ import android.content.Context; import android.content.res.ColorStateList; import android.graphics.Bitmap; +import android.graphics.Color; import android.os.Bundle; import android.view.LayoutInflater; import android.view.Menu; @@ -50,6 +51,7 @@ import com.owncloud.android.lib.resources.files.ToggleFavoriteRemoteOperation; import com.owncloud.android.lib.resources.shares.OCShare; import com.owncloud.android.lib.resources.shares.ShareType; +import com.owncloud.android.lib.resources.tags.Tag; import com.owncloud.android.ui.activity.DrawerActivity; import com.owncloud.android.ui.activity.FileDisplayActivity; import com.owncloud.android.ui.activity.ToolbarActivity; @@ -241,9 +243,9 @@ public View onCreateView(@NonNull LayoutInflater inflater, ViewGroup container, if (getFile().getTags().isEmpty()) { binding.tagsGroup.setVisibility(View.GONE); } else { - for (String tag : getFile().getTags()) { + for (Tag tag : getFile().getTags()) { Chip chip = new Chip(context); - chip.setText(tag); + chip.setText(tag.getName()); chip.setChipBackgroundColor(ColorStateList.valueOf(getResources().getColor(R.color.bg_default, context.getTheme()))); chip.setShapeAppearanceModel(chip.getShapeAppearanceModel().toBuilder().setAllCornerSizes((100.0f)) @@ -251,6 +253,13 @@ public View onCreateView(@NonNull LayoutInflater inflater, ViewGroup container, chip.setEnsureMinTouchTargetSize(false); chip.setClickable(false); viewThemeUtils.material.themeChipSuggestion(chip); + + if (tag.getColor() != null) { + int color = Color.parseColor(tag.getColor()); + chip.setChipStrokeColor(ColorStateList.valueOf(color)); + chip.setTextColor(color); + } + binding.tagsGroup.addView(chip); } } diff --git a/build.gradle b/build.gradle index cb7e0f4943b5..a451158c520b 100644 --- a/build.gradle +++ b/build.gradle @@ -10,7 +10,7 @@ */ buildscript { ext { - androidLibraryVersion ="4c07e6a69e8a8bab43ca9406ea546613e90d934b" + androidLibraryVersion ="40fea7dfa5" androidPluginVersion = '8.8.0' androidxMediaVersion = '1.5.1' androidxTestVersion = "1.6.1" diff --git a/gradle/verification-metadata.xml b/gradle/verification-metadata.xml index fe9d7e0cc79a..1e5c421323bf 100644 --- a/gradle/verification-metadata.xml +++ b/gradle/verification-metadata.xml @@ -9082,6 +9082,14 @@ + + + + + + + + @@ -9098,6 +9106,22 @@ + + + + + + + + + + + + + + + + @@ -9170,6 +9194,14 @@ + + + + + + + +