Animations for media

This commit is contained in:
Thomas 2020-07-06 11:48:59 +02:00
parent 3d3dfc0351
commit 7ce524e09f
8 changed files with 77 additions and 7 deletions

View File

@ -14,6 +14,7 @@
* see <http://www.gnu.org/licenses>. */
package app.fedilab.android.activities;
import android.app.Activity;
import android.content.ClipData;
import android.content.ClipboardManager;
import android.content.Intent;
@ -48,6 +49,7 @@ import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.appcompat.app.AlertDialog;
import androidx.appcompat.widget.PopupMenu;
import androidx.core.app.ActivityOptionsCompat;
import androidx.core.content.ContextCompat;
import androidx.fragment.app.Fragment;
import androidx.fragment.app.FragmentManager;
@ -739,7 +741,15 @@ public class ShowAccountActivity extends BaseActivity implements OnPostActionInt
b.putInt("position", 1);
b.putInt("bgcolor", getResources().getColor(R.color.cyanea_primary_dark));
intent.putExtras(b);
if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.LOLLIPOP) {
ActivityOptionsCompat options = ActivityOptionsCompat
.makeSceneTransitionAnimation(ShowAccountActivity.this, account_pp, attachment.getUrl());
// start the new activity
startActivity(intent, options.toBundle());
}else{
// start the new activity
startActivity(intent);
}
});
//Follow button
String target = account.getId();

View File

@ -15,6 +15,7 @@ package app.fedilab.android.drawers;
* see <http://www.gnu.org/licenses>. */
import android.annotation.SuppressLint;
import android.app.Activity;
import android.content.Context;
import android.content.Intent;
import android.content.SharedPreferences;
@ -30,6 +31,7 @@ import android.widget.TextView;
import android.widget.Toast;
import androidx.annotation.NonNull;
import androidx.core.app.ActivityOptionsCompat;
import androidx.recyclerview.widget.RecyclerView;
import com.bumptech.glide.Glide;
@ -177,7 +179,16 @@ public class ArtListAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder
b.putInt("bgcolor", context.getResources().getColor(R.color.cyanea_primary_dark));
b.putInt("position", 1);
intent.putExtras(b);
if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.LOLLIPOP) {
ActivityOptionsCompat options = ActivityOptionsCompat
.makeSceneTransitionAnimation((Activity)context, holder.art_media, status.getMedia_attachments().get(0).getUrl());
// start the new activity
context.startActivity(intent, options.toBundle());
}else{
// start the new activity
context.startActivity(intent);
}
});
holder.art_author.setOnClickListener(v -> {
Intent intent = new Intent(context, ShowConversationActivity.class);

View File

@ -14,6 +14,7 @@ package app.fedilab.android.drawers;
* You should have received a copy of the GNU General Public License along with Fedilab; if not,
* see <http://www.gnu.org/licenses>. */
import android.app.Activity;
import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
@ -23,6 +24,7 @@ import android.view.ViewGroup;
import android.widget.ImageView;
import androidx.annotation.NonNull;
import androidx.core.app.ActivityOptionsCompat;
import androidx.recyclerview.widget.RecyclerView;
import com.bumptech.glide.Glide;
@ -86,7 +88,15 @@ public class ImageAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder>
b.putInt("position", (viewHolder.getAdapterPosition() + 1));
b.putInt("bgcolor", context.getResources().getColor(R.color.cyanea_primary_dark));
intent.putExtras(b);
if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.LOLLIPOP) {
ActivityOptionsCompat options = ActivityOptionsCompat
.makeSceneTransitionAnimation((Activity)context, holder.imageView, attachmentsTmp.get((viewHolder.getAdapterPosition())).getUrl());
// start the new activity
context.startActivity(intent, options.toBundle());
}else{
// start the new activity
context.startActivity(intent);
}
});
holder.imageView.setOnLongClickListener(v -> {
Intent intent = new Intent(context, ShowConversationActivity.class);

View File

@ -53,6 +53,7 @@ import androidx.annotation.NonNull;
import androidx.appcompat.app.AlertDialog;
import androidx.appcompat.widget.PopupMenu;
import androidx.constraintlayout.widget.ConstraintLayout;
import androidx.core.app.ActivityOptionsCompat;
import androidx.core.content.ContextCompat;
import androidx.core.graphics.drawable.DrawableCompat;
import androidx.preference.PreferenceManager;
@ -1192,7 +1193,15 @@ public class NotificationsListAdapter extends RecyclerView.Adapter<RecyclerView.
b.putInt("position", finalPosition);
b.putInt("bgcolor", context.getResources().getColor(R.color.cyanea_primary_dark));
intent.putExtras(b);
if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.LOLLIPOP) {
ActivityOptionsCompat options = ActivityOptionsCompat
.makeSceneTransitionAnimation((Activity)context, imageView, notification.getStatus().getMedia_attachments().get(finalPosition-1).getUrl());
// start the new activity
context.startActivity(intent, options.toBundle());
}else{
// start the new activity
context.startActivity(intent);
}
});
i++;
position++;

View File

@ -47,6 +47,7 @@ import androidx.appcompat.app.AlertDialog;
import androidx.appcompat.widget.PopupMenu;
import androidx.cardview.widget.CardView;
import androidx.constraintlayout.widget.ConstraintLayout;
import androidx.core.app.ActivityOptionsCompat;
import androidx.preference.PreferenceManager;
import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;
@ -399,7 +400,15 @@ public class PixelfedListAdapter extends RecyclerView.Adapter<RecyclerView.ViewH
b.putInt("position", 1);
b.putInt("bgcolor", context.getResources().getColor(R.color.cyanea_primary_dark));
intent.putExtras(b);
if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.LOLLIPOP) {
ActivityOptionsCompat options = ActivityOptionsCompat
.makeSceneTransitionAnimation((Activity)context, holder.art_media, status.getMedia_attachments().get(0).getUrl());
// start the new activity
context.startActivity(intent, options.toBundle());
}else{
// start the new activity
context.startActivity(intent);
}
});
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context);

View File

@ -28,6 +28,7 @@ import android.widget.TextView;
import androidx.annotation.NonNull;
import androidx.cardview.widget.CardView;
import androidx.core.app.ActivityOptionsCompat;
import androidx.core.content.ContextCompat;
import androidx.recyclerview.widget.RecyclerView;
@ -136,7 +137,15 @@ public class PixelfedStoriesListAdapter extends RecyclerView.Adapter<RecyclerVie
b.putInt("position", 1);
b.putInt("bgcolor", context.getResources().getColor(R.color.cyanea_primary_dark));
intent.putExtras(b);
if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.LOLLIPOP) {
ActivityOptionsCompat options = ActivityOptionsCompat
.makeSceneTransitionAnimation((Activity)context, holder.art_media, attachments.get(0).getUrl());
// start the new activity
context.startActivity(intent, options.toBundle());
}else{
// start the new activity
context.startActivity(intent);
}
});

View File

@ -36,6 +36,7 @@ import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.annotation.RequiresApi;
import androidx.appcompat.app.AlertDialog;
import androidx.core.app.ActivityOptionsCompat;
import com.bumptech.glide.Glide;
import com.bumptech.glide.request.target.CustomTarget;
@ -109,7 +110,15 @@ public class SliderAdapter extends SliderViewAdapter<SliderAdapter.SliderAdapter
b.putInt("position", (position + 1));
b.putInt("bgcolor", contextWeakReference.get().getResources().getColor(R.color.cyanea_primary_dark));
intent.putExtras(b);
if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.LOLLIPOP) {
ActivityOptionsCompat options = ActivityOptionsCompat
.makeSceneTransitionAnimation((Activity)contextWeakReference.get(), viewHolder.imageViewBackground, attachments.get((position)).getUrl());
// start the new activity
contextWeakReference.get().startActivity(intent, options.toBundle());
}else{
// start the new activity
contextWeakReference.get().startActivity(intent);
}
});
} else {
viewHolder.imageViewBackground.setOnClickListener(v -> showAddDescription(attachments.get(position)));

View File

@ -204,6 +204,7 @@ public class MediaSliderFragment extends Fragment implements MediaPlayer.OnCompl
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
imageView.setTransitionName(attachment.getUrl());
scheduleStartPostponedTransition(imageView);
imageView.invalidate();
}
if (bgColor != -1) {
media_fragment_container.setBackgroundColor(bgColor);
@ -245,6 +246,7 @@ public class MediaSliderFragment extends Fragment implements MediaPlayer.OnCompl
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
imageView.setTransitionName(attachment.getUrl());
scheduleStartPostponedTransition(imageView);
imageView.invalidate();
}
}
}
@ -254,6 +256,7 @@ public class MediaSliderFragment extends Fragment implements MediaPlayer.OnCompl
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
imageView.setTransitionName(attachment.getUrl());
scheduleStartPostponedTransition(imageView);
imageView.invalidate();
}
}