mirror of
https://code.briarproject.org/briar/briar.git
synced 2026-02-11 18:29:05 +01:00
Add a scene transition animation when reblogging a blog post
This commit is contained in:
@@ -11,6 +11,12 @@
|
||||
android:layout_height="wrap_content"
|
||||
android:padding="@dimen/margin_small">
|
||||
|
||||
<include
|
||||
android:id="@+id/postLayout"
|
||||
layout="@layout/list_item_blog_post"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"/>
|
||||
|
||||
<ProgressBar
|
||||
android:id="@+id/progressBar"
|
||||
style="?android:attr/progressBarStyleLarge"
|
||||
@@ -18,12 +24,6 @@
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_centerInParent="true"/>
|
||||
|
||||
<include
|
||||
android:id="@+id/postLayout"
|
||||
layout="@layout/list_item_blog_post"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"/>
|
||||
|
||||
<EditText
|
||||
android:id="@+id/inputText"
|
||||
android:layout_width="match_parent"
|
||||
@@ -1,9 +1,11 @@
|
||||
package org.briarproject.android.blogs;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.support.v4.app.ActivityCompat;
|
||||
import android.support.v4.app.ActivityOptionsCompat;
|
||||
import android.support.v4.content.ContextCompat;
|
||||
import android.support.v4.view.ViewCompat;
|
||||
import android.support.v7.widget.RecyclerView;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
@@ -17,8 +19,9 @@ import org.briarproject.android.util.AuthorView;
|
||||
import org.briarproject.api.blogs.BlogCommentHeader;
|
||||
import org.briarproject.api.blogs.BlogPostHeader;
|
||||
import org.briarproject.api.identity.Author;
|
||||
import org.briarproject.api.sync.MessageId;
|
||||
|
||||
import static android.support.v4.app.ActivityOptionsCompat.makeCustomAnimation;
|
||||
import static android.support.v4.app.ActivityOptionsCompat.makeSceneTransitionAnimation;
|
||||
import static android.view.View.GONE;
|
||||
import static android.view.View.VISIBLE;
|
||||
import static org.briarproject.android.BriarActivity.GROUP_ID;
|
||||
@@ -62,7 +65,25 @@ public class BlogPostViewHolder extends RecyclerView.ViewHolder {
|
||||
reblogButton.setVisibility(GONE);
|
||||
}
|
||||
|
||||
void setTransitionName(MessageId id) {
|
||||
ViewCompat.setTransitionName(layout, getTransitionName(id));
|
||||
}
|
||||
|
||||
private String getTransitionName(MessageId id) {
|
||||
return "blogPost" + id.hashCode();
|
||||
}
|
||||
|
||||
void bindItem(final BlogPostItem item) {
|
||||
setTransitionName(item.getId());
|
||||
layout.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
if (listener != null) {
|
||||
listener.onBlogPostClick(item);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
// author and date
|
||||
BlogPostHeader post = item.getPostHeader();
|
||||
Author a = post.getAuthor();
|
||||
@@ -86,11 +107,12 @@ public class BlogPostViewHolder extends RecyclerView.ViewHolder {
|
||||
Intent i = new Intent(ctx, ReblogActivity.class);
|
||||
i.putExtra(GROUP_ID, item.getGroupId().getBytes());
|
||||
i.putExtra(POST_ID, item.getId().getBytes());
|
||||
|
||||
ActivityOptionsCompat options =
|
||||
makeCustomAnimation(ctx, android.R.anim.slide_in_left,
|
||||
android.R.anim.slide_out_right);
|
||||
Intent[] intents = { i };
|
||||
ContextCompat.startActivities(ctx, intents, options.toBundle());
|
||||
makeSceneTransitionAnimation((Activity) ctx, layout,
|
||||
getTransitionName(item.getId()));
|
||||
ActivityCompat
|
||||
.startActivity((Activity) ctx, i, options.toBundle());
|
||||
}
|
||||
});
|
||||
|
||||
@@ -101,15 +123,6 @@ public class BlogPostViewHolder extends RecyclerView.ViewHolder {
|
||||
} else {
|
||||
reblogger.setVisibility(GONE);
|
||||
}
|
||||
|
||||
layout.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
if (listener != null) {
|
||||
listener.onBlogPostClick(item);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private void onBindComment(final BlogCommentItem item) {
|
||||
|
||||
@@ -1,7 +1,10 @@
|
||||
package org.briarproject.android.blogs;
|
||||
|
||||
import android.annotation.TargetApi;
|
||||
import android.content.Intent;
|
||||
import android.os.Bundle;
|
||||
import android.transition.Fade;
|
||||
import android.transition.Transition;
|
||||
import android.view.MenuItem;
|
||||
|
||||
import org.briarproject.R;
|
||||
@@ -11,6 +14,8 @@ import org.briarproject.android.fragment.BaseFragment.BaseFragmentListener;
|
||||
import org.briarproject.api.sync.GroupId;
|
||||
import org.briarproject.api.sync.MessageId;
|
||||
|
||||
import static android.os.Build.VERSION.SDK_INT;
|
||||
import static android.os.Build.VERSION_CODES.LOLLIPOP;
|
||||
import static org.briarproject.android.blogs.BlogActivity.POST_ID;
|
||||
|
||||
public class ReblogActivity extends BriarActivity implements
|
||||
@@ -20,6 +25,10 @@ public class ReblogActivity extends BriarActivity implements
|
||||
public void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
|
||||
if (SDK_INT >= LOLLIPOP) {
|
||||
setTransition();
|
||||
}
|
||||
|
||||
Intent intent = getIntent();
|
||||
byte[] groupId = intent.getByteArrayExtra(GROUP_ID);
|
||||
if (groupId == null)
|
||||
@@ -70,4 +79,14 @@ public class ReblogActivity extends BriarActivity implements
|
||||
public void onFragmentCreated(String tag) {
|
||||
|
||||
}
|
||||
|
||||
@TargetApi(LOLLIPOP)
|
||||
private void setTransition() {
|
||||
Transition fade = new Fade();
|
||||
fade.excludeTarget(android.R.id.statusBarBackground, true);
|
||||
fade.excludeTarget(R.id.action_bar_container, true);
|
||||
fade.excludeTarget(android.R.id.navigationBarBackground, true);
|
||||
getWindow().setExitTransition(fade);
|
||||
getWindow().setEnterTransition(fade);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -85,9 +85,10 @@ public class ReblogFragment extends BaseFragment {
|
||||
blogId = new GroupId(args.getByteArray(GROUP_ID));
|
||||
postId = new MessageId(args.getByteArray(POST_ID));
|
||||
|
||||
View v = inflater.inflate(R.layout.fragment_reblog_dialog, container,
|
||||
View v = inflater.inflate(R.layout.fragment_reblog, container,
|
||||
false);
|
||||
ui = new ViewHolder(v);
|
||||
ui.post.setTransitionName(postId);
|
||||
showProgressBar();
|
||||
|
||||
return v;
|
||||
@@ -137,7 +138,6 @@ public class ReblogFragment extends BaseFragment {
|
||||
ui.scrollView.post(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
//ui.scrollView.scrollTo(0, ui.scrollView.getBottom());
|
||||
ui.scrollView.fullScroll(FOCUS_DOWN);
|
||||
}
|
||||
});
|
||||
@@ -166,14 +166,12 @@ public class ReblogFragment extends BaseFragment {
|
||||
|
||||
private void showProgressBar() {
|
||||
ui.progressBar.setVisibility(VISIBLE);
|
||||
ui.post.setVisibility(GONE);
|
||||
ui.input.setVisibility(GONE);
|
||||
ui.publish.setVisibility(GONE);
|
||||
}
|
||||
|
||||
private void hideProgressBar() {
|
||||
ui.progressBar.setVisibility(INVISIBLE);
|
||||
ui.post.setVisibility(VISIBLE);
|
||||
ui.input.setVisibility(VISIBLE);
|
||||
ui.publish.setVisibility(VISIBLE);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user