mirror of
https://code.briarproject.org/briar/briar.git
synced 2026-02-18 13:49:53 +01:00
[android] Fix enter transition to fullscreen ImageActivity
This commit is contained in:
@@ -82,7 +82,7 @@ public class ImageActivity extends BriarActivity
|
|||||||
super.onCreate(state);
|
super.onCreate(state);
|
||||||
|
|
||||||
// Transitions
|
// Transitions
|
||||||
supportPostponeEnterTransition();
|
if (state == null) supportPostponeEnterTransition();
|
||||||
Window window = getWindow();
|
Window window = getWindow();
|
||||||
if (SDK_INT >= 21) {
|
if (SDK_INT >= 21) {
|
||||||
Transition transition = new Fade();
|
Transition transition = new Fade();
|
||||||
@@ -298,13 +298,18 @@ public class ImageActivity extends BriarActivity
|
|||||||
|
|
||||||
private class ImagePagerAdapter extends FragmentStatePagerAdapter {
|
private class ImagePagerAdapter extends FragmentStatePagerAdapter {
|
||||||
|
|
||||||
|
private boolean isFirst = true;
|
||||||
|
|
||||||
private ImagePagerAdapter(FragmentManager fm) {
|
private ImagePagerAdapter(FragmentManager fm) {
|
||||||
super(fm);
|
super(fm);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Fragment getItem(int position) {
|
public Fragment getItem(int position) {
|
||||||
return ImageFragment.newInstance(attachments.get(position));
|
Fragment f = ImageFragment
|
||||||
|
.newInstance(attachments.get(position), isFirst);
|
||||||
|
isFirst = false;
|
||||||
|
return f;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@@ -35,17 +35,21 @@ import static org.briarproject.briar.android.conversation.ImageActivity.ATTACHME
|
|||||||
@ParametersAreNonnullByDefault
|
@ParametersAreNonnullByDefault
|
||||||
public class ImageFragment extends Fragment {
|
public class ImageFragment extends Fragment {
|
||||||
|
|
||||||
|
private final static String IS_FIRST = "isFirst";
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
ViewModelProvider.Factory viewModelFactory;
|
ViewModelProvider.Factory viewModelFactory;
|
||||||
|
|
||||||
private AttachmentItem attachment;
|
private AttachmentItem attachment;
|
||||||
|
private boolean isFirst;
|
||||||
private ImageViewModel viewModel;
|
private ImageViewModel viewModel;
|
||||||
private PhotoView photoView;
|
private PhotoView photoView;
|
||||||
|
|
||||||
static ImageFragment newInstance(AttachmentItem a) {
|
static ImageFragment newInstance(AttachmentItem a, boolean isFirst) {
|
||||||
ImageFragment f = new ImageFragment();
|
ImageFragment f = new ImageFragment();
|
||||||
Bundle args = new Bundle();
|
Bundle args = new Bundle();
|
||||||
args.putParcelable(ATTACHMENT_POSITION, a);
|
args.putParcelable(ATTACHMENT_POSITION, a);
|
||||||
|
args.putBoolean(IS_FIRST, isFirst);
|
||||||
f.setArguments(args);
|
f.setArguments(args);
|
||||||
return f;
|
return f;
|
||||||
}
|
}
|
||||||
@@ -63,6 +67,7 @@ public class ImageFragment extends Fragment {
|
|||||||
|
|
||||||
Bundle args = requireNonNull(getArguments());
|
Bundle args = requireNonNull(getArguments());
|
||||||
attachment = requireNonNull(args.getParcelable(ATTACHMENT_POSITION));
|
attachment = requireNonNull(args.getParcelable(ATTACHMENT_POSITION));
|
||||||
|
isFirst = args.getBoolean(IS_FIRST);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Nullable
|
@Nullable
|
||||||
@@ -85,7 +90,7 @@ public class ImageFragment extends Fragment {
|
|||||||
public boolean onLoadFailed(@Nullable GlideException e,
|
public boolean onLoadFailed(@Nullable GlideException e,
|
||||||
Object model, Target<Drawable> target,
|
Object model, Target<Drawable> target,
|
||||||
boolean isFirstResource) {
|
boolean isFirstResource) {
|
||||||
if (getActivity() != null)
|
if (getActivity() != null && isFirst)
|
||||||
getActivity().supportStartPostponedEnterTransition();
|
getActivity().supportStartPostponedEnterTransition();
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@@ -104,8 +109,9 @@ public class ImageFragment extends Fragment {
|
|||||||
if (viewModel.isOverlappingToolbar(photoView, resource)) {
|
if (viewModel.isOverlappingToolbar(photoView, resource)) {
|
||||||
photoView.setScaleType(FIT_START);
|
photoView.setScaleType(FIT_START);
|
||||||
}
|
}
|
||||||
if (getActivity() != null)
|
if (getActivity() != null && isFirst) {
|
||||||
getActivity().supportStartPostponedEnterTransition();
|
getActivity().supportStartPostponedEnterTransition();
|
||||||
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -15,6 +15,7 @@ import org.briarproject.briar.android.conversation.glide.BriarImageTransformatio
|
|||||||
import org.briarproject.briar.android.conversation.glide.GlideApp;
|
import org.briarproject.briar.android.conversation.glide.GlideApp;
|
||||||
import org.briarproject.briar.android.conversation.glide.Radii;
|
import org.briarproject.briar.android.conversation.glide.Radii;
|
||||||
|
|
||||||
|
import static android.os.Build.VERSION.SDK_INT;
|
||||||
import static com.bumptech.glide.load.engine.DiskCacheStrategy.NONE;
|
import static com.bumptech.glide.load.engine.DiskCacheStrategy.NONE;
|
||||||
import static com.bumptech.glide.load.resource.drawable.DrawableTransitionOptions.withCrossFade;
|
import static com.bumptech.glide.load.resource.drawable.DrawableTransitionOptions.withCrossFade;
|
||||||
|
|
||||||
@@ -42,6 +43,9 @@ class ImageViewHolder extends ViewHolder {
|
|||||||
} else {
|
} else {
|
||||||
setImageViewDimensions(attachment, single, needsStretch);
|
setImageViewDimensions(attachment, single, needsStretch);
|
||||||
loadImage(attachment, r);
|
loadImage(attachment, r);
|
||||||
|
if (SDK_INT >= 21) {
|
||||||
|
imageView.setTransitionName(attachment.getTransitionName());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user