Browse Source

Add live photo field usage

Signed-off-by: alperozturk <alper_ozturk@proton.me>
alperozturk 1 year ago
parent
commit
a923d577ba

+ 4 - 2
app/src/main/java/com/owncloud/android/datamodel/FileDataStorageManager.java

@@ -37,6 +37,7 @@ import android.os.Build;
 import android.os.RemoteException;
 import android.provider.MediaStore;
 import android.text.TextUtils;
+import android.util.Log;
 
 import com.google.gson.Gson;
 import com.google.gson.JsonSyntaxException;
@@ -510,7 +511,7 @@ public class FileDataStorageManager {
         cv.put(ProviderTableMeta.FILE_MODIFIED, file.getModificationTimestamp());
         cv.put(ProviderTableMeta.FILE_METADATA_SIZE, gson.toJson(file.getImageDimension()));
         cv.put(ProviderTableMeta.FILE_METADATA_GPS, gson.toJson(file.getGeoLocation()));
-        cv.put(ProviderTableMeta.FILE_METADATA_LIVE_PHOTO, gson.toJson(file.isLivePhoto()));
+        cv.put(ProviderTableMeta.FILE_METADATA_LIVE_PHOTO, gson.toJson(file.getLivePhoto()));
 
         return cv;
     }
@@ -932,6 +933,7 @@ public class FileDataStorageManager {
         ocFile.setNote(fileEntity.getNote());
         ocFile.setRichWorkspace(fileEntity.getRichWorkspace());
         ocFile.setLocked(nullToZero(fileEntity.getLocked()) == 1);
+
         final int lockTypeInt = nullToZero(fileEntity.getLockType()); // TODO - what value should be used for NULL???
         ocFile.setLockType(lockTypeInt != -1 ? FileLockType.fromValue(lockTypeInt) : null);
         ocFile.setLockOwnerId(fileEntity.getLockOwner());
@@ -940,7 +942,7 @@ public class FileDataStorageManager {
         ocFile.setLockTimestamp(nullToZero(fileEntity.getLockTimestamp()));
         ocFile.setLockTimeout(nullToZero(fileEntity.getLockTimeout()));
         ocFile.setLockToken(fileEntity.getLockToken());
-        ocFile.setLivePhotoAvailable(fileEntity.getMetadataLivePhoto() == "TODO");
+        ocFile.setLivePhoto(fileEntity.getMetadataLivePhoto());
 
         String sharees = fileEntity.getSharees();
         // Surprisingly JSON deserialization causes significant overhead.

+ 6 - 5
app/src/main/java/com/owncloud/android/datamodel/OCFile.java

@@ -28,6 +28,7 @@ import android.net.Uri;
 import android.os.Parcel;
 import android.os.Parcelable;
 import android.text.TextUtils;
+import android.util.Log;
 
 import com.owncloud.android.R;
 import com.owncloud.android.lib.common.network.WebdavEntry;
@@ -83,7 +84,7 @@ public class OCFile implements Parcelable, Comparable<OCFile>, ServerFileInterfa
     private long lastSyncDateForProperties;
     private long lastSyncDateForData;
     private boolean previewAvailable;
-    private boolean livePhotoAvailable;
+    private String livePhoto;
     private String etag;
     private String etagOnServer;
     private boolean sharedViaLink;
@@ -243,8 +244,8 @@ public class OCFile implements Parcelable, Comparable<OCFile>, ServerFileInterfa
         // TODO add live photo availability
     }
 
-    public Boolean isLivePhoto() {
-        return livePhotoAvailable;
+    public String getLivePhoto() {
+        return livePhoto;
     }
 
     public void setDecryptedRemotePath(String path) {
@@ -918,8 +919,8 @@ public class OCFile implements Parcelable, Comparable<OCFile>, ServerFileInterfa
         this.note = note;
     }
 
-    public void setLivePhotoAvailable(Boolean livePhotoAvailable) {
-        this.livePhotoAvailable = livePhotoAvailable;
+    public void setLivePhoto(String livePhoto) {
+        this.livePhoto = livePhoto;
     }
 
     public void setSharees(List<ShareeUser> sharees) {

+ 1 - 1
app/src/main/java/com/owncloud/android/db/ProviderMeta.java

@@ -35,7 +35,7 @@ import java.util.List;
  */
 public class ProviderMeta {
     public static final String DB_NAME = "filelist";
-    public static final int DB_VERSION = 73;
+    public static final int DB_VERSION = 75;
 
     private ProviderMeta() {
         // No instance

+ 3 - 2
app/src/main/java/com/owncloud/android/ui/adapter/OCFileListAdapter.java

@@ -389,11 +389,12 @@ public class OCFileListAdapter extends RecyclerView.Adapter<RecyclerView.ViewHol
     }
 
     private void checkLivePhotoAvailability(ListGridImageViewHolder holder, OCFile file) {
-        holder.getLivePhotoIndicator().setVisibility((file.isLivePhoto()) ? (View.VISIBLE) : (View.GONE));
+        boolean isLivePhoto = file.getLivePhoto() != null;
+        holder.getLivePhotoIndicator().setVisibility(isLivePhoto ? (View.VISIBLE) : (View.GONE));
 
         // FIXME Interface segregation principle violation
         // Not needed for Grid mode unfortunately ListGridImageViewHolder interface used for List and Grid mode
-        holder.getLivePhotoIndicatorSeparator().setVisibility((file.isLivePhoto()) ? (View.VISIBLE) : (View.GONE));
+        holder.getLivePhotoIndicatorSeparator().setVisibility(isLivePhoto ? (View.VISIBLE) : (View.GONE));
     }
 
     private void bindListItemViewHolder(ListItemViewHolder holder, OCFile file) {

+ 1 - 1
app/src/main/java/com/owncloud/android/ui/preview/PreviewImageFragment.java

@@ -198,7 +198,7 @@ public class PreviewImageFragment extends FileFragment implements Injectable {
 
         binding.image.setOnClickListener(v -> togglePreviewImageFullScreen());
 
-        if (getFile().isLivePhoto()) {
+        if (getFile().getLivePhoto() != null) {
             binding.image.setOnLongClickListener(v -> {
                 playLivePhoto();
                 return true;

+ 1 - 1
build.gradle

@@ -1,6 +1,6 @@
 buildscript {
     ext {
-        androidPluginVersion = '8.1.1'
+        androidPluginVersion = '8.1.2'
         appCompatVersion = '1.6.1'
         jacoco_version = '0.8.10'
         kotlin_version = '1.8.22'