Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Live Photo #12139

Merged
merged 118 commits into from
Dec 8, 2023
Merged
Show file tree
Hide file tree
Changes from 10 commits
Commits
Show all changes
118 commits
Select commit Hold shift + click to select a range
50567dd
Add indicator word and icon
alperozturk96 Nov 6, 2023
3f0a049
Add indicator in list_item
alperozturk96 Nov 6, 2023
3abb630
Add live photo indicator for grid view
alperozturk96 Nov 6, 2023
cc03aa9
Update ViewHolders for live photo indicator
alperozturk96 Nov 6, 2023
e925ce9
Update OCFile for live photo ability
alperozturk96 Nov 6, 2023
eb0aa90
Add missing live photo indicator for grid
alperozturk96 Nov 6, 2023
0ff650d
Update oc file adapter for live photo indicator
alperozturk96 Nov 6, 2023
c45e786
Fix alignment in grid mode
alperozturk96 Nov 6, 2023
cf71e59
Add long click listener for live photo
alperozturk96 Nov 6, 2023
eae0947
Change icon with sf symbol
alperozturk96 Nov 6, 2023
4807c17
Fix hitboxes for accesibilty
alperozturk96 Nov 6, 2023
c1c9d94
Add playLivePhoto functionality to image fragment
alperozturk96 Nov 6, 2023
2c499ef
Add new property
alperozturk96 Nov 6, 2023
c350d4f
Check LivePhotoIndicatorSeparator
alperozturk96 Nov 7, 2023
38b9548
Add live photo field usage
alperozturk96 Nov 7, 2023
b4d9ab0
Add live photo field to OCFile
alperozturk96 Nov 7, 2023
bef81ea
Fix live photo field usage
alperozturk96 Nov 7, 2023
0c2eaf4
Merge remote-tracking branch 'origin/feature/live-photo' into feature…
alperozturk96 Nov 7, 2023
9765324
Fix live photo indicator visibility for gridview
alperozturk96 Nov 7, 2023
904c931
Add live photo playback to Preview Fragment
alperozturk96 Nov 7, 2023
2fac132
Remove unnecessary todo comment
alperozturk96 Nov 7, 2023
2566c5b
Update live indicator icon
alperozturk96 Nov 7, 2023
8cbd178
Increase performance for addVideoOCFileOfLivePhoto
alperozturk96 Nov 7, 2023
eddbc78
Add auto play functionality
alperozturk96 Nov 7, 2023
8de87ca
Add fixme comment
alperozturk96 Nov 7, 2023
225cca0
Prevent unnecessary calls for addVideoOCFileOfLivePhoto
alperozturk96 Nov 8, 2023
0eaeccb
Fix live photo indicator background ratio
alperozturk96 Nov 8, 2023
dfbd790
Add toggle functionality for action bar
alperozturk96 Nov 8, 2023
2a37bd8
draft commit
alperozturk96 Nov 8, 2023
d381bbd
Improve UX, toggle actionbar, disable auto play
alperozturk96 Nov 8, 2023
b41c200
Add tooltip to live photo indicator
alperozturk96 Nov 8, 2023
e577ddd
Deduct live photo count from list
alperozturk96 Nov 8, 2023
cb9dd8e
Remove long press action trigger live photo preview via tap
alperozturk96 Nov 8, 2023
8efa8f9
Replace live photo image
alperozturk96 Nov 8, 2023
5376561
Fix scroll problem with huge list with different file types
alperozturk96 Nov 8, 2023
5847afe
Change interface for different needs
alperozturk96 Nov 8, 2023
46d2e42
Fix live photo visibility for grid mode
alperozturk96 Nov 8, 2023
75169fb
Add background tint for indicators
alperozturk96 Nov 8, 2023
18c7a4a
Include local android lib (It will then be disabled as a comment.)
alperozturk96 Nov 8, 2023
0ad0d9b
Remove unnecassary hiding logic and merge ocfiles for live photo
alperozturk96 Nov 13, 2023
0cb4d3b
move merge live photos up, so that mFilesAll is same as mFiles
tobiasKaminsky Nov 14, 2023
93afd5a
Add hidden field
alperozturk96 Nov 14, 2023
6c71a29
Merge master
alperozturk96 Nov 14, 2023
cdda5fb
Fix db version number
alperozturk96 Nov 14, 2023
8f83da0
Update fields
alperozturk96 Nov 16, 2023
56a93e1
Merge master
alperozturk96 Nov 16, 2023
f16509d
Add indicator word and icon
alperozturk96 Nov 6, 2023
ff3ad76
Add indicator in list_item
alperozturk96 Nov 6, 2023
75ddb32
Add live photo indicator for grid view
alperozturk96 Nov 6, 2023
28ce0e0
Update ViewHolders for live photo indicator
alperozturk96 Nov 6, 2023
ad4b3cb
Update OCFile for live photo ability
alperozturk96 Nov 6, 2023
01c39ec
Add missing live photo indicator for grid
alperozturk96 Nov 6, 2023
87a420f
Update oc file adapter for live photo indicator
alperozturk96 Nov 6, 2023
5256b62
Fix alignment in grid mode
alperozturk96 Nov 6, 2023
0ce03a3
Add long click listener for live photo
alperozturk96 Nov 6, 2023
fd4096f
Change icon with sf symbol
alperozturk96 Nov 6, 2023
56945a8
Fix hitboxes for accesibilty
alperozturk96 Nov 6, 2023
cab9abe
Add playLivePhoto functionality to image fragment
alperozturk96 Nov 6, 2023
6a34f81
Add new property
alperozturk96 Nov 6, 2023
7ca84b6
Check LivePhotoIndicatorSeparator
alperozturk96 Nov 7, 2023
a923d57
Add live photo field usage
alperozturk96 Nov 7, 2023
56a8653
Fix live photo field usage
alperozturk96 Nov 7, 2023
43bce94
Fix live photo indicator visibility for gridview
alperozturk96 Nov 7, 2023
df4c531
Add live photo playback to Preview Fragment
alperozturk96 Nov 7, 2023
47a4fbb
Remove unnecessary todo comment
alperozturk96 Nov 7, 2023
429c892
Update live indicator icon
alperozturk96 Nov 7, 2023
fdd10c2
Increase performance for addVideoOCFileOfLivePhoto
alperozturk96 Nov 7, 2023
ef60fce
Add auto play functionality
alperozturk96 Nov 7, 2023
7fd6224
Add fixme comment
alperozturk96 Nov 7, 2023
7030329
Prevent unnecessary calls for addVideoOCFileOfLivePhoto
alperozturk96 Nov 8, 2023
4930d6c
Fix live photo indicator background ratio
alperozturk96 Nov 8, 2023
7959a1d
Add toggle functionality for action bar
alperozturk96 Nov 8, 2023
d2a8005
draft commit
alperozturk96 Nov 8, 2023
7617658
Improve UX, toggle actionbar, disable auto play
alperozturk96 Nov 8, 2023
d2d7865
Add tooltip to live photo indicator
alperozturk96 Nov 8, 2023
5f18c86
Deduct live photo count from list
alperozturk96 Nov 8, 2023
85504a6
Remove long press action trigger live photo preview via tap
alperozturk96 Nov 8, 2023
8211109
Replace live photo image
alperozturk96 Nov 8, 2023
03715a9
Fix scroll problem with huge list with different file types
alperozturk96 Nov 8, 2023
af5ede7
Change interface for different needs
alperozturk96 Nov 8, 2023
8a7f482
Fix live photo visibility for grid mode
alperozturk96 Nov 8, 2023
6f8624f
Add background tint for indicators
alperozturk96 Nov 8, 2023
8b8314e
Include local android lib (It will then be disabled as a comment.)
alperozturk96 Nov 8, 2023
bed3c8d
Remove unnecassary hiding logic and merge ocfiles for live photo
alperozturk96 Nov 13, 2023
c14754f
move merge live photos up, so that mFilesAll is same as mFiles
tobiasKaminsky Nov 14, 2023
739a6cc
Add hidden field
alperozturk96 Nov 14, 2023
20c6fbb
Fix db version number
alperozturk96 Nov 14, 2023
3538e8b
Update fields
alperozturk96 Nov 16, 2023
a82ec04
Merge master
alperozturk96 Nov 16, 2023
400ed06
Merge remote-tracking branch 'origin/feature/live-photo' into feature…
alperozturk96 Nov 16, 2023
488462b
Rebase master
alperozturk96 Nov 16, 2023
8ae13ea
Update lib
alperozturk96 Nov 16, 2023
4cf339e
Fix hidden flag
alperozturk96 Nov 16, 2023
0106ba3
Hide hidden files in search
alperozturk96 Nov 16, 2023
82526e0
Code cleanup
alperozturk96 Nov 17, 2023
cecbaef
Update plugin version
alperozturk96 Dec 1, 2023
f642926
Merge master
alperozturk96 Dec 1, 2023
fc022c5
Change db version
alperozturk96 Dec 4, 2023
291b914
Add auto migration
alperozturk96 Dec 4, 2023
66e244e
Add correct 73 version json
alperozturk96 Dec 4, 2023
d18cf20
Merge master
alperozturk96 Dec 4, 2023
f6ee552
Code analytic fixes
alperozturk96 Dec 4, 2023
314a28f
Reduce spotbugs
alperozturk96 Dec 4, 2023
689ddea
Analysis: update lint results to reflect reduced error/warning count
invalid-email-address Dec 4, 2023
fd9d807
Trigger pipeline
alperozturk96 Dec 4, 2023
04bce45
fix tests
tobiasKaminsky Dec 6, 2023
a47ed56
add test
tobiasKaminsky Dec 6, 2023
2f1e3ea
Fix merge conflict
alperozturk96 Dec 6, 2023
2eb8245
Analysis: update lint results to reflect reduced error/warning count
invalid-email-address Dec 6, 2023
b493c67
Fix crashes
alperozturk96 Dec 6, 2023
d6657c9
Merge remote-tracking branch 'origin/feature/live-photo' into feature…
alperozturk96 Dec 6, 2023
2077bf9
Fix text color for live photo indicator
alperozturk96 Dec 6, 2023
0028d8e
Merge master
alperozturk96 Dec 7, 2023
7f70b1c
Solve git conflicts
alperozturk96 Dec 7, 2023
6f1b62f
Analysis: update lint results to reflect reduced error/warning count
invalid-email-address Dec 7, 2023
b48c027
Use file id for merging live photos
alperozturk96 Dec 8, 2023
7719b2e
Use file id for merging live photos
alperozturk96 Dec 8, 2023
633f458
Fix tests
alperozturk96 Dec 8, 2023
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
6 changes: 6 additions & 0 deletions app/src/main/java/com/owncloud/android/datamodel/OCFile.java
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@ public class OCFile implements Parcelable, Comparable<OCFile>, ServerFileInterfa
private long lastSyncDateForProperties;
private long lastSyncDateForData;
private boolean previewAvailable;
private boolean livePhotoAvailable;
private String etag;
private String etagOnServer;
private boolean sharedViaLink;
Expand Down Expand Up @@ -239,6 +240,11 @@ public void writeToParcel(Parcel dest, int flags) {
dest.writeLong(lockTimestamp);
dest.writeLong(lockTimeout);
dest.writeString(lockToken);
// TODO add live photo availability
}

public Boolean isLivePhoto() {
return livePhotoAvailable;
}

public void setDecryptedRemotePath(String path) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ package com.owncloud.android.ui.adapter

import android.view.View
import android.widget.ImageView
import android.widget.TextView
import com.elyeproj.loaderviewlibrary.LoaderImageView

interface ListGridImageViewHolder {
Expand All @@ -35,4 +36,5 @@ interface ListGridImageViewHolder {
val checkbox: ImageView
val itemLayout: View
val unreadComments: ImageView
val livePhotoIndicator: TextView
}
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@
import android.widget.ImageView;

import com.elyeproj.loaderviewlibrary.LoaderImageView;
import com.nextcloud.android.common.ui.theme.utils.ColorRole;
import com.nextcloud.client.account.User;
import com.nextcloud.client.preferences.AppPreferences;
import com.owncloud.android.MainApp;
Expand Down Expand Up @@ -356,14 +357,12 @@ public RecyclerView.ViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int
@Override
@SuppressFBWarnings("ITC_INHERITANCE_TYPE_CHECKING")
public void onBindViewHolder(@NonNull RecyclerView.ViewHolder holder, int position) {
if (holder instanceof OCFileListFooterViewHolder) {
OCFileListFooterViewHolder footerViewHolder = (OCFileListFooterViewHolder) holder;
if (holder instanceof OCFileListFooterViewHolder footerViewHolder) {
footerViewHolder.getFooterText().setText(getFooterText());
viewThemeUtils.platform.colorCircularProgressBar(footerViewHolder.getLoadingProgressBar());
viewThemeUtils.platform.colorCircularProgressBar(footerViewHolder.getLoadingProgressBar(), ColorRole.ON_SURFACE_VARIANT);
footerViewHolder.getLoadingProgressBar().setVisibility(
ocFileListFragmentInterface.isLoading() ? View.VISIBLE : View.GONE);
} else if (holder instanceof OCFileListHeaderViewHolder) {
OCFileListHeaderViewHolder headerViewHolder = (OCFileListHeaderViewHolder) holder;
} else if (holder instanceof OCFileListHeaderViewHolder headerViewHolder) {
String text = currentDirectory.getRichWorkspace();

PreviewTextFragment.setText(headerViewHolder.getHeaderText(), text, null, activity, true, true, viewThemeUtils);
Expand All @@ -389,7 +388,13 @@ public void onBindViewHolder(@NonNull RecyclerView.ViewHolder holder, int positi
}
}

private void checkLivePhotoAvailability(ListGridImageViewHolder holder, OCFile file) {
holder.getLivePhotoIndicator().setVisibility((file.isLivePhoto()) ? (View.VISIBLE) : (View.GONE));
}

private void bindListItemViewHolder(ListItemViewHolder holder, OCFile file) {
checkLivePhotoAvailability(holder, file);

if ((file.isSharedWithMe() || file.isSharedWithSharee()) && !isMultiSelect() && !gridView &&
!hideItemOptions) {
holder.getSharedAvatars().setVisibility(View.VISIBLE);
Expand Down Expand Up @@ -431,7 +436,7 @@ private void bindListItemViewHolder(ListItemViewHolder holder, OCFile file) {
holder.getTagMore().setVisibility(View.GONE);

holder.getFirstTag().setText(file.getTags().get(0));

if (file.getTags().size() > 1) {
viewThemeUtils.material.themeChipSuggestion(holder.getSecondTag());
holder.getSecondTag().setVisibility(View.VISIBLE);
Expand Down Expand Up @@ -486,7 +491,6 @@ private void bindListItemViewHolder(ListItemViewHolder holder, OCFile file) {
holder.getLastModification().setVisibility(View.GONE);
}


if (isMultiSelect() || gridView || hideItemOptions) {
holder.getOverflowMenu().setVisibility(View.GONE);
} else {
Expand All @@ -503,6 +507,7 @@ private void bindListItemViewHolder(ListItemViewHolder holder, OCFile file) {
}

private void bindListGridItemViewHolder(ListGridItemViewHolder holder, OCFile file) {
checkLivePhotoAvailability(holder, file);
holder.getFileName().setText(file.getDecryptedFileName());

boolean gridImage = MimeTypeUtil.isImage(file) || MimeTypeUtil.isVideo(file);
Expand Down Expand Up @@ -847,11 +852,11 @@ private void parseVirtuals(List<Object> objects, SearchType searchType) {
contentValues.add(cv);
} catch (
RemoteOperationFailedException |
OperationCanceledException |
AuthenticatorException |
IOException |
AccountUtils.AccountNotFoundException |
IllegalStateException e) {
OperationCanceledException |
AuthenticatorException |
IOException |
AccountUtils.AccountNotFoundException |
IllegalStateException e) {
Log_OC.e(TAG, "Error saving file with parent" + e.getMessage(), e);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ package com.owncloud.android.ui.adapter

import android.view.View
import android.widget.ImageView
import android.widget.TextView
import androidx.recyclerview.widget.RecyclerView
import com.elyeproj.loaderviewlibrary.LoaderImageView
import com.owncloud.android.databinding.GridImageBinding
Expand Down Expand Up @@ -53,6 +54,8 @@ internal class OCFileListGridImageViewHolder(var binding: GridImageBinding) :
get() = binding.ListItemLayout
override val unreadComments: ImageView
get() = binding.unreadComments
override val livePhotoIndicator: TextView
get() = binding.livePhotoIndicator

init {
binding.favoriteAction.drawable.mutate()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,8 @@ internal class OCFileListGridItemViewHolder(var binding: GridItemBinding) :
get() = binding.ListItemLayout
override val unreadComments: ImageView
get() = binding.unreadComments
override val livePhotoIndicator: TextView
get() = binding.livePhotoIndicator

init {
binding.favoriteAction.drawable.mutate()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,8 @@ internal class OCFileListItemViewHolder(private var binding: ListItemBinding) :
binding.root
),
ListItemViewHolder {
override val livePhotoIndicator: TextView
get() = binding.livePhotoIndicator
override val fileSize: TextView
get() = binding.fileSize
override val fileSizeSeparator: View
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -94,12 +94,10 @@

/**
* This fragment shows a preview of a downloaded image.
*
* Trying to get an instance with a NULL {@link OCFile} will produce an
* {@link IllegalStateException}.
*
* If the {@link OCFile} passed is not downloaded, an {@link IllegalStateException} is generated on
* instantiation too.
* <p>
* Trying to get an instance with a NULL {@link OCFile} will produce an {@link IllegalStateException}.
* <p>
* If the {@link OCFile} passed is not downloaded, an {@link IllegalStateException} is generated on instantiation too.
*/
public class PreviewImageFragment extends FileFragment implements Injectable {

Expand Down Expand Up @@ -132,17 +130,15 @@ public class PreviewImageFragment extends FileFragment implements Injectable {

/**
* Public factory method to create a new fragment that previews an image.
*
* Android strongly recommends keep the empty constructor of fragments as the only public
* constructor, and
* use {@link #setArguments(Bundle)} to set the needed arguments.
*
* <p>
* Android strongly recommends keep the empty constructor of fragments as the only public constructor, and use
* {@link #setArguments(Bundle)} to set the needed arguments.
* <p>
* This method hides to client objects the need of doing the construction in two steps.
*
* @param imageFile An {@link OCFile} to preview as an image in the fragment
* @param ignoreFirstSavedState Flag to work around an unexpected behaviour of
* {@link FragmentStatePagerAdapter}
* ; TODO better solution
* @param ignoreFirstSavedState Flag to work around an unexpected behaviour of {@link FragmentStatePagerAdapter} ;
* TODO better solution
*/
public static PreviewImageFragment newInstance(@NonNull OCFile imageFile,
boolean ignoreFirstSavedState,
Expand All @@ -159,12 +155,11 @@ public static PreviewImageFragment newInstance(@NonNull OCFile imageFile,

/**
* Creates an empty fragment for image previews.
*
* MUST BE KEPT: the system uses it when tries to re-instantiate a fragment automatically
* (for instance, when the device is turned a aside).
*
* DO NOT CALL IT: an {@link OCFile} and {@link User} must be provided for a successful
* construction
* <p>
* MUST BE KEPT: the system uses it when tries to re-instantiate a fragment automatically (for instance, when the
* device is turned a aside).
* <p>
* DO NOT CALL IT: an {@link OCFile} and {@link User} must be provided for a successful construction
*/
public PreviewImageFragment() {
ignoreFirstSavedState = false;
Expand Down Expand Up @@ -201,11 +196,23 @@ public View onCreateView(@NonNull LayoutInflater inflater, ViewGroup container,

binding.image.setOnClickListener(v -> togglePreviewImageFullScreen());

if (getFile().isLivePhoto()) {
binding.image.setOnLongClickListener(v -> {
playLivePhoto();
return true;
});
}

setMultiListLoadingMessage();

return view;
}

private void playLivePhoto() {
// TODO play video

}

/**
* {@inheritDoc}
*/
Expand Down Expand Up @@ -395,11 +402,7 @@ private void showFileActions(OCFile file) {
public void onFileActionChosen(final int itemId) {
if (itemId == R.id.action_send_share_file) {
if (getFile().isSharedWithMe() && !getFile().canReshare()) {
Snackbar.make(requireView(),
R.string.resharing_is_not_allowed,
Snackbar.LENGTH_LONG
)
.show();
Snackbar.make(requireView(), R.string.resharing_is_not_allowed, Snackbar.LENGTH_LONG).show();
} else {
containerActivity.getFileOperationsHelper().sendShareFile(getFile());
}
Expand Down Expand Up @@ -455,9 +458,9 @@ private class LoadBitmapTask extends AsyncTask<OCFile, Void, LoadImage> {

/**
* Weak reference to the target {@link ImageView} where the bitmap will be loaded into.
*
* Using a weak reference will avoid memory leaks if the target ImageView is retired from
* memory before the load finishes.
* <p>
* Using a weak reference will avoid memory leaks if the target ImageView is retired from memory before the load
* finishes.
*/
private final WeakReference<PhotoView> imageViewRef;
private final WeakReference<LinearLayout> infoViewRef;
Expand Down Expand Up @@ -524,7 +527,7 @@ protected LoadImage doInBackground(OCFile... params) {

try {
bitmapResult = BitmapUtils.decodeSampledBitmapFromFile(storagePath, minWidth,
minHeight);
minHeight);

if (isCancelled()) {
return new LoadImage(bitmapResult, null, ocFile);
Expand Down Expand Up @@ -562,7 +565,7 @@ protected LoadImage doInBackground(OCFile... params) {
} catch (NoSuchFieldError e) {
mErrorMessageId = R.string.common_error_unknown;
Log_OC.e(TAG, "Error from access to non-existing field despite protection; file "
+ storagePath, e);
+ storagePath, e);

} catch (Throwable t) {
mErrorMessageId = R.string.common_error_unknown;
Expand Down Expand Up @@ -601,7 +604,7 @@ private void showLoadedImage(LoadImage result) {
if (imageView != null) {
if (bitmap != null) {
Log_OC.d(TAG, "Showing image with resolution " + bitmap.getWidth() + "x" +
bitmap.getHeight());
bitmap.getHeight());

if (MIME_TYPE_PNG.equalsIgnoreCase(result.ocFile.getMimeType()) ||
MIME_TYPE_GIF.equalsIgnoreCase(result.ocFile.getMimeType())) {
Expand Down Expand Up @@ -716,7 +719,7 @@ public void setErrorPreviewMessage() {
Snackbar.LENGTH_INDEFINITE).show();
}
}
).show();
).show();
}
} catch (IllegalArgumentException e) {
Log_OC.d(TAG, e.getMessage());
Expand All @@ -732,8 +735,7 @@ public void setNoConnectionErrorMessage() {
}

/**
* Helper method to test if an {@link OCFile} can be passed to a {@link PreviewImageFragment}
* to be previewed.
* Helper method to test if an {@link OCFile} can be passed to a {@link PreviewImageFragment} to be previewed.
*
* @param file File to test if can be previewed.
* @return 'True' if the file can be handled by the fragment.
Expand Down
Loading