Prepare frontend 4 - Improves Pixelfed layout
This commit is contained in:
parent
146222eadf
commit
5c2708abef
|
@ -3141,7 +3141,7 @@ public abstract class BaseMainActivity extends BaseActivity
|
|||
DisplayStatusFragment statusFragment;
|
||||
Bundle bundle = new Bundle();
|
||||
statusFragment = new DisplayStatusFragment();
|
||||
bundle.putSerializable("type", RetrieveFeedsAsyncTask.Type.PIXELFED);
|
||||
bundle.putSerializable("type", RetrieveFeedsAsyncTask.Type.REMOTE_INSTANCE);
|
||||
bundle.putString("remote_instance", remoteInstance.getHost());
|
||||
bundle.putString("instanceType", "PIXELFED");
|
||||
statusFragment.setArguments(bundle);
|
||||
|
@ -3209,6 +3209,7 @@ public abstract class BaseMainActivity extends BaseActivity
|
|||
bundle.putString("remote_instance", remoteInstance.getHost());
|
||||
statusFragment.setArguments(bundle);
|
||||
String fragmentTag = "REMOTE_INSTANCE";
|
||||
bundle.putString("instanceType", "PEERTUBE");
|
||||
instance_id = remoteInstance.getDbID();
|
||||
FragmentManager fragmentManager = getSupportFragmentManager();
|
||||
fragmentManager.beginTransaction()
|
||||
|
|
|
@ -173,9 +173,6 @@ public class RetrieveFeedsAsyncTask extends AsyncTask<Void, Void, Void> {
|
|||
case CONVERSATION:
|
||||
apiResponse = api.getConversationTimeline(max_id);
|
||||
break;
|
||||
case PIXELFED:
|
||||
apiResponse = api.getPixelfedTimeline(instanceName, max_id);
|
||||
break;
|
||||
case REMOTE_INSTANCE:
|
||||
if( this.name != null && this.remoteInstance != null){ //For Peertube channels
|
||||
apiResponse = api.getPeertubeChannelVideos(this.remoteInstance, this.name);
|
||||
|
@ -197,7 +194,9 @@ public class RetrieveFeedsAsyncTask extends AsyncTask<Void, Void, Void> {
|
|||
status.setType(action);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
} else if(remoteInstanceObj != null && remoteInstanceObj.size() > 0 && remoteInstanceObj.get(0).getType().equals("PIXELFED") ) {
|
||||
apiResponse = api.getPixelfedTimeline(instanceName, max_id);
|
||||
}else {
|
||||
apiResponse = api.getPeertube(this.instanceName, max_id);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -23,13 +23,13 @@ import android.graphics.Bitmap;
|
|||
import android.os.Bundle;
|
||||
import android.support.annotation.NonNull;
|
||||
import android.support.annotation.Nullable;
|
||||
import android.support.v4.content.ContextCompat;
|
||||
import android.support.v7.widget.CardView;
|
||||
import android.support.v7.widget.RecyclerView;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.LinearLayout;
|
||||
import android.widget.RelativeLayout;
|
||||
import android.widget.TextView;
|
||||
import android.widget.Toast;
|
||||
|
||||
|
@ -68,6 +68,8 @@ import fr.gouv.etalab.mastodon.interfaces.OnRetrieveRepliesInterface;
|
|||
import fr.gouv.etalab.mastodon.sqlite.Sqlite;
|
||||
import fr.gouv.etalab.mastodon.sqlite.StatusCacheDAO;
|
||||
|
||||
import static fr.gouv.etalab.mastodon.helper.Helper.changeDrawableColor;
|
||||
|
||||
|
||||
/**
|
||||
* Created by Thomas on 14/01/2019.
|
||||
|
@ -137,20 +139,21 @@ public class PixelfedListAdapter extends RecyclerView.Adapter implements OnPostA
|
|||
|
||||
|
||||
private class ViewHolderPixelfed extends RecyclerView.ViewHolder{
|
||||
ImageView art_media, art_pp;
|
||||
TextView art_username, art_acct;
|
||||
LinearLayout art_author;
|
||||
RelativeLayout status_show_more;
|
||||
ImageView show_more_button_art;
|
||||
ImageView art_media, pf_pp, pf_fav, pf_comment, pf_share;
|
||||
TextView pf_username, pf_likes, pf_description, pf_date;
|
||||
CardView pf_cardview;
|
||||
ViewHolderPixelfed(View itemView) {
|
||||
super(itemView);
|
||||
art_media = itemView.findViewById(R.id.art_media);
|
||||
art_pp = itemView.findViewById(R.id.art_pp);
|
||||
art_username = itemView.findViewById(R.id.art_username);
|
||||
art_acct = itemView.findViewById(R.id.art_acct);
|
||||
art_author = itemView.findViewById(R.id.art_author);
|
||||
status_show_more = itemView.findViewById(R.id.status_show_more);
|
||||
show_more_button_art = itemView.findViewById(R.id.show_more_button_art);
|
||||
pf_pp = itemView.findViewById(R.id.pf_pp);
|
||||
pf_username = itemView.findViewById(R.id.pf_username);
|
||||
pf_likes = itemView.findViewById(R.id.pf_likes);
|
||||
pf_description = itemView.findViewById(R.id.pf_description);
|
||||
pf_date = itemView.findViewById(R.id.pf_date);
|
||||
pf_fav = itemView.findViewById(R.id.pf_fav);
|
||||
pf_comment = itemView.findViewById(R.id.pf_comment);
|
||||
pf_share = itemView.findViewById(R.id.pf_share);
|
||||
pf_cardview = itemView.findViewById(R.id.pf_cardview);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -175,7 +178,7 @@ public class PixelfedListAdapter extends RecyclerView.Adapter implements OnPostA
|
|||
@NonNull
|
||||
@Override
|
||||
public RecyclerView.ViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
|
||||
if( viewType != DISPLAYED_STATUS)
|
||||
if( viewType == DISPLAYED_STATUS)
|
||||
return new ViewHolderPixelfed(layoutInflater.inflate(R.layout.drawer_pixelfed, parent, false));
|
||||
else
|
||||
return new ViewHolderEmpty(layoutInflater.inflate(R.layout.drawer_empty, parent, false));
|
||||
|
@ -199,8 +202,8 @@ public class PixelfedListAdapter extends RecyclerView.Adapter implements OnPostA
|
|||
if (status.getAccount() != null && status.getAccount().getAvatar() != null)
|
||||
Glide.with(context)
|
||||
.load(status.getAccount().getAvatar())
|
||||
.apply(new RequestOptions().transforms(new FitCenter(), new RoundedCorners(10)))
|
||||
.into(holder.art_pp);
|
||||
.apply(new RequestOptions().transforms(new FitCenter(), new RoundedCorners(270)))
|
||||
.into(holder.pf_pp);
|
||||
|
||||
boolean expand_media = sharedpreferences.getBoolean(Helper.SET_EXPAND_MEDIA, false);
|
||||
if (status.getMedia_attachments() != null && status.getMedia_attachments().size() > 0)
|
||||
|
@ -221,28 +224,9 @@ public class PixelfedListAdapter extends RecyclerView.Adapter implements OnPostA
|
|||
}
|
||||
})
|
||||
.into(holder.art_media);
|
||||
RelativeLayout.LayoutParams rel_btn = new RelativeLayout.LayoutParams(
|
||||
ViewGroup.LayoutParams.MATCH_PARENT, holder.art_media.getHeight());
|
||||
holder.status_show_more.setLayoutParams(rel_btn);
|
||||
if (expand_media || !status.isSensitive()) {
|
||||
status.setAttachmentShown(true);
|
||||
holder.status_show_more.setVisibility(View.GONE);
|
||||
} else {
|
||||
if (!status.isAttachmentShown()) {
|
||||
holder.status_show_more.setVisibility(View.VISIBLE);
|
||||
} else {
|
||||
holder.status_show_more.setVisibility(View.GONE);
|
||||
}
|
||||
}
|
||||
|
||||
holder.show_more_button_art.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
status.setAttachmentShown(true);
|
||||
notifyStatusChanged(status);
|
||||
}
|
||||
});
|
||||
holder.art_pp.setOnClickListener(new View.OnClickListener() {
|
||||
holder.pf_likes.setText(context.getResources().getQuantityString(R.plurals.likes, status.getFavourites_count(), status.getFavourites_count()));
|
||||
holder.pf_pp.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
if (MainActivity.social != UpdateAccountInfoAsyncTask.SOCIAL.PIXELFED) {
|
||||
|
@ -273,7 +257,9 @@ public class PixelfedListAdapter extends RecyclerView.Adapter implements OnPostA
|
|||
context.startActivity(intent);
|
||||
}
|
||||
});
|
||||
holder.art_author.setOnClickListener(new View.OnClickListener() {
|
||||
holder.pf_description.setText(status.getContentSpan(), TextView.BufferType.SPANNABLE);
|
||||
holder.pf_date.setText(Helper.dateToString(status.getCreated_at()));
|
||||
holder.pf_description.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
if (MainActivity.social != UpdateAccountInfoAsyncTask.SOCIAL.PIXELFED) {
|
||||
|
@ -289,11 +275,27 @@ public class PixelfedListAdapter extends RecyclerView.Adapter implements OnPostA
|
|||
});
|
||||
|
||||
if (status.getDisplayNameSpan() != null && status.getDisplayNameSpan().toString().trim().length() > 0)
|
||||
holder.art_username.setText(status.getDisplayNameSpan(), TextView.BufferType.SPANNABLE);
|
||||
holder.pf_username.setText(status.getDisplayNameSpan(), TextView.BufferType.SPANNABLE);
|
||||
else
|
||||
holder.art_username.setText(status.getAccount().getUsername());
|
||||
holder.pf_username.setText(status.getAccount().getUsername());
|
||||
int theme = sharedpreferences.getInt(Helper.SET_THEME, Helper.THEME_DARK);
|
||||
|
||||
holder.art_acct.setText(String.format("@%s", status.getAccount().getAcct()));
|
||||
if (theme == Helper.THEME_BLACK) {
|
||||
changeDrawableColor(context, holder.pf_fav, R.color.action_black);
|
||||
changeDrawableColor(context, holder.pf_comment, R.color.action_black);
|
||||
changeDrawableColor(context, holder.pf_share, R.color.action_black);
|
||||
holder.pf_cardview.setCardBackgroundColor(ContextCompat.getColor(context, R.color.black_3));
|
||||
} else if (theme == Helper.THEME_DARK) {
|
||||
changeDrawableColor(context, holder.pf_fav, R.color.action_dark);
|
||||
changeDrawableColor(context, holder.pf_comment, R.color.action_dark);
|
||||
changeDrawableColor(context, holder.pf_share, R.color.action_dark);
|
||||
holder.pf_cardview.setCardBackgroundColor(ContextCompat.getColor(context, R.color.mastodonC1_));
|
||||
} else {
|
||||
changeDrawableColor(context, holder.pf_fav, R.color.action_light);
|
||||
changeDrawableColor(context, holder.pf_comment, R.color.action_light);
|
||||
changeDrawableColor(context, holder.pf_share, R.color.action_light);
|
||||
holder.pf_cardview.setCardBackgroundColor(ContextCompat.getColor(context, R.color.white));
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -32,6 +32,7 @@ import android.support.v4.content.LocalBroadcastManager;
|
|||
import android.support.v4.widget.SwipeRefreshLayout;
|
||||
import android.support.v7.widget.LinearLayoutManager;
|
||||
import android.support.v7.widget.RecyclerView;
|
||||
import android.util.Log;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
|
@ -212,6 +213,8 @@ public class DisplayStatusFragment extends Fragment implements OnRetrieveFeedsIn
|
|||
peertubeAdapater = new PeertubeAdapter(context, remoteInstance, ownVideos, this.peertubes);
|
||||
lv_status.setAdapter(peertubeAdapater);
|
||||
}else if( instanceType.equals("PIXELFED")){
|
||||
if( remoteInstance != null && MainActivity.social == UpdateAccountInfoAsyncTask.SOCIAL.PIXELFED) //if it's a Peertube account connected
|
||||
remoteInstance = account.getInstance();
|
||||
pixelfedListAdapter = new PixelfedListAdapter(context, this.statuses);
|
||||
lv_status.setAdapter(pixelfedListAdapter);
|
||||
}else if( instanceType.equals("ART")){
|
||||
|
@ -447,7 +450,7 @@ public class DisplayStatusFragment extends Fragment implements OnRetrieveFeedsIn
|
|||
//remove handlers
|
||||
swipeRefreshLayout.setRefreshing(false);
|
||||
if( firstLoad && (apiResponse.getPeertubes() == null || apiResponse.getPeertubes().size() ==0)){
|
||||
textviewNoActionText.setText(R.string.no_video_uploaded);
|
||||
textviewNoActionText.setText(R.string.no_video_to_display);
|
||||
textviewNoAction.setVisibility(View.VISIBLE);
|
||||
}
|
||||
flag_loading = false;
|
||||
|
@ -478,7 +481,6 @@ public class DisplayStatusFragment extends Fragment implements OnRetrieveFeedsIn
|
|||
int previousPosition = this.statuses.size();
|
||||
List<Status> statuses = apiResponse.getStatuses();
|
||||
//At this point all statuses are in "List<Status> statuses"
|
||||
|
||||
//Pagination for Pixelfed
|
||||
if(instanceType.equals("PIXELFED")) {
|
||||
if( max_id == null)
|
||||
|
@ -526,6 +528,7 @@ public class DisplayStatusFragment extends Fragment implements OnRetrieveFeedsIn
|
|||
artListAdapter.notifyItemRangeInserted(previousPosition, statuses.size());
|
||||
}
|
||||
}else if(instanceType.equals("PIXELFED") ) {
|
||||
Log.v(Helper.TAG,"statuses: " + statuses.size());
|
||||
this.statuses.addAll(statuses);
|
||||
pixelfedListAdapter.notifyItemRangeInserted(previousPosition, statuses.size());
|
||||
}
|
||||
|
|
|
@ -0,0 +1,9 @@
|
|||
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:width="24dp"
|
||||
android:height="24dp"
|
||||
android:viewportWidth="24.0"
|
||||
android:viewportHeight="24.0">
|
||||
<path
|
||||
android:fillColor="#FF000000"
|
||||
android:pathData="M20,2L4,2c-1.1,0 -2,0.9 -2,2v18l4,-4h14c1.1,0 2,-0.9 2,-2L22,4c0,-1.1 -0.9,-2 -2,-2zM20,16L6,16l-2,2L4,4h16v12z"/>
|
||||
</vector>
|
|
@ -0,0 +1,9 @@
|
|||
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:width="24dp"
|
||||
android:height="24dp"
|
||||
android:viewportWidth="24.0"
|
||||
android:viewportHeight="24.0">
|
||||
<path
|
||||
android:fillColor="#FF000000"
|
||||
android:pathData="M16.5,3c-1.74,0 -3.41,0.81 -4.5,2.09C10.91,3.81 9.24,3 7.5,3 4.42,3 2,5.42 2,8.5c0,3.78 3.4,6.86 8.55,11.54L12,21.35l1.45,-1.32C18.6,15.36 22,12.28 22,8.5 22,5.42 19.58,3 16.5,3zM12.1,18.55l-0.1,0.1 -0.1,-0.1C7.14,14.24 4,11.39 4,8.5 4,6.5 5.5,5 7.5,5c1.54,0 3.04,0.99 3.57,2.36h1.87C13.46,5.99 14.96,5 16.5,5c2,0 3.5,1.5 3.5,3.5 0,2.89 -3.14,5.74 -7.9,10.05z"/>
|
||||
</vector>
|
|
@ -18,61 +18,99 @@
|
|||
<android.support.v7.widget.CardView
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:layout_width="match_parent"
|
||||
android:id="@+id/pf_cardview"
|
||||
android:layout_marginBottom="20dp"
|
||||
android:layout_height="wrap_content">
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:paddingTop="5dp"
|
||||
android:paddingBottom="5dp"
|
||||
android:paddingLeft="10dp"
|
||||
android:paddingRight="10dp"
|
||||
android:orientation="horizontal">
|
||||
<ImageView
|
||||
android:id="@+id/pf_pp"
|
||||
android:orientation="vertical">
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:paddingTop="5dp"
|
||||
android:layout_gravity="center"
|
||||
android:layout_width="50dp"
|
||||
android:layout_height="50dp" />
|
||||
<TextView
|
||||
android:id="@+id/pf_username"
|
||||
android:textColor="@color/white"
|
||||
android:textSize="16sp"
|
||||
android:textStyle="bold"
|
||||
android:gravity="center"
|
||||
android:paddingBottom="10dp"
|
||||
android:paddingLeft="10dp"
|
||||
android:paddingRight="10dp"
|
||||
android:orientation="horizontal">
|
||||
<ImageView
|
||||
android:id="@+id/pf_pp"
|
||||
android:layout_gravity="center"
|
||||
android:layout_width="40dp"
|
||||
android:layout_height="40dp" />
|
||||
<TextView
|
||||
android:layout_marginLeft="15dp"
|
||||
android:layout_marginStart="15dp"
|
||||
android:id="@+id/pf_username"
|
||||
android:textColor="@color/white"
|
||||
android:textSize="16sp"
|
||||
android:textStyle="bold"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content" />
|
||||
</LinearLayout>
|
||||
<ImageView
|
||||
android:id="@+id/art_media"
|
||||
android:scaleType="fitCenter"
|
||||
android:adjustViewBounds="true"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content" />
|
||||
</LinearLayout>
|
||||
<ImageView
|
||||
android:layout_marginTop="10dp"
|
||||
android:layout_marginBottom="10dp"
|
||||
android:id="@+id/art_media"
|
||||
android:scaleType="fitCenter"
|
||||
android:adjustViewBounds="true"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content" />
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="vertical">
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_width="match_parent"
|
||||
android:paddingLeft="10dp"
|
||||
android:paddingRight="10dp"
|
||||
android:paddingTop="10dp"
|
||||
android:paddingBottom="5dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="horizontal">
|
||||
android:orientation="vertical">
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="horizontal">
|
||||
<ImageView
|
||||
android:id="@+id/pf_fav"
|
||||
android:contentDescription="@string/add_image_to_favorite"
|
||||
android:src="@drawable/ic_pixelfed_favorite_border"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content" />
|
||||
<ImageView
|
||||
android:layout_marginStart="15dp"
|
||||
android:layout_marginLeft="15dp"
|
||||
android:id="@+id/pf_comment"
|
||||
android:contentDescription="@string/leave_a_comment"
|
||||
android:src="@drawable/ic_pixelfed_comment"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content" />
|
||||
<ImageView
|
||||
android:layout_marginStart="15dp"
|
||||
android:layout_marginLeft="15dp"
|
||||
android:id="@+id/pf_share"
|
||||
android:contentDescription="@string/share_with"
|
||||
android:src="@drawable/ic_menu_share"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content" />
|
||||
</LinearLayout>
|
||||
<TextView
|
||||
android:layout_marginTop="5dp"
|
||||
android:textStyle="bold"
|
||||
android:id="@+id/pf_likes"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content" />
|
||||
<TextView
|
||||
android:layout_marginTop="5dp"
|
||||
android:id="@+id/pf_description"
|
||||
android:textIsSelectable="true"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content" />
|
||||
|
||||
<TextView
|
||||
android:layout_marginTop="5dp"
|
||||
android:id="@+id/pf_date"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content" />
|
||||
</LinearLayout>
|
||||
<TextView
|
||||
android:id="@+id/pf_likes"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content" />
|
||||
<TextView
|
||||
android:id="@+id/pf_description"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/pf_date"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content" />
|
||||
</LinearLayout>
|
||||
</android.support.v7.widget.CardView>
|
|
@ -250,6 +250,10 @@
|
|||
<item quantity="one">and another toot to discover</item>
|
||||
<item quantity="other">and %d other toots to discover</item>
|
||||
</plurals>
|
||||
<plurals name="likes">
|
||||
<item quantity="one">%d like</item>
|
||||
<item quantity="other">%d likes</item>
|
||||
</plurals>
|
||||
<string name="delete_notification_ask">Delete a notification?</string>
|
||||
<string name="delete_notification_ask_all">Delete all notifications?</string>
|
||||
<string name="delete_notification">The notification has been deleted!</string>
|
||||
|
@ -819,6 +823,9 @@
|
|||
<string name="no_video_uploaded">No videos uploaded yet!</string>
|
||||
<string name="display_nsfw_videos">Display NSFW videos</string>
|
||||
<string name="default_channel_of">Default %s channel</string>
|
||||
<string name="no_video_to_display">No videos to display!</string>
|
||||
<string name="add_image_to_favorite">Add media to favorites</string>
|
||||
<string name="leave_a_comment">Leave a comment</string>
|
||||
<!-- end languages -->
|
||||
|
||||
|
||||
|
|
Loading…
Reference in New Issue