Prepare frontend 7 - Add boosts

This commit is contained in:
stom79 2019-01-15 16:36:30 +01:00
parent b5030916c9
commit 3e096aedfb
6 changed files with 84 additions and 16 deletions

View File

@ -885,12 +885,14 @@ public abstract class BaseMainActivity extends BaseActivity
}else if (social == UpdateAccountInfoAsyncTask.SOCIAL.PIXELFED){
TabLayout.Tab pfTabHome = tabLayout.newTab();
TabLayout.Tab pfTabLocal = tabLayout.newTab();
TabLayout.Tab pfTabNotification = tabLayout.newTab();
//TabLayout.Tab pfTabDiscover = tabLayout.newTab();
pfTabHome.setCustomView(R.layout.tab_badge);
pfTabLocal.setCustomView(R.layout.tab_badge);
pfTabNotification.setCustomView(R.layout.tab_badge);
//pfTabDiscover.setCustomView(R.layout.tab_badge);
@ -910,6 +912,10 @@ public abstract class BaseMainActivity extends BaseActivity
iconLocal.setImageResource(R.drawable.ic_people);
@SuppressWarnings("ConstantConditions") @SuppressLint("CutPasteId")
ImageView iconNotif = pfTabNotification.getCustomView().findViewById(R.id.tab_icon);
iconNotif.setImageResource(R.drawable.ic_notifications);
/*@SuppressWarnings("ConstantConditions") @SuppressLint("CutPasteId")
ImageView iconDiscover = pfTabDiscover.getCustomView().findViewById(R.id.tab_icon);
iconDiscover.setImageResource(R.drawable.ic_people);*/
@ -919,22 +925,25 @@ public abstract class BaseMainActivity extends BaseActivity
iconHome.setContentDescription(getString(R.string.home_menu));
// iconDiscover.setContentDescription(getString(R.string.overview));
iconLocal.setContentDescription(getString(R.string.local));
iconNotif.setContentDescription(getString(R.string.notifications));
if (theme == THEME_LIGHT) {
iconHome.setColorFilter(ContextCompat.getColor(getApplicationContext(), R.color.action_light_header), PorterDuff.Mode.SRC_IN);
// iconDiscover.setColorFilter(ContextCompat.getColor(getApplicationContext(), R.color.action_light_header), PorterDuff.Mode.SRC_IN);
iconLocal.setColorFilter(ContextCompat.getColor(getApplicationContext(), R.color.action_light_header), PorterDuff.Mode.SRC_IN);
iconNotif.setColorFilter(ContextCompat.getColor(getApplicationContext(), R.color.action_light_header), PorterDuff.Mode.SRC_IN);
} else {
iconHome.setColorFilter(ContextCompat.getColor(getApplicationContext(), R.color.dark_text), PorterDuff.Mode.SRC_IN);
// iconDiscover.setColorFilter(ContextCompat.getColor(getApplicationContext(), R.color.dark_text), PorterDuff.Mode.SRC_IN);
iconLocal.setColorFilter(ContextCompat.getColor(getApplicationContext(), R.color.dark_text), PorterDuff.Mode.SRC_IN);
iconNotif.setColorFilter(ContextCompat.getColor(getApplicationContext(), R.color.dark_text), PorterDuff.Mode.SRC_IN);
}
toot.setImageResource(R.drawable.ic_cloud_upload);
tabLayout.addTab(pfTabHome);
tabLayout.addTab(pfTabLocal);
tabLayout.addTab(pfTabNotification);
// tabLayout.addTab(pfTabDiscover);
@ -2447,17 +2456,30 @@ public abstract class BaseMainActivity extends BaseActivity
}
//Selection comes from another menu, no action to do
Bundle bundle = new Bundle();
DisplayStatusFragment fragment = new DisplayStatusFragment();
if (position == 0) {
DisplayStatusFragment fragment = new DisplayStatusFragment();
bundle.putSerializable("type", RetrieveFeedsAsyncTask.Type.PF_HOME);
bundle.putString("instanceType","PIXELFED");
fragment.setArguments(bundle);
return fragment;
}else if( position == 1) {
DisplayStatusFragment fragment = new DisplayStatusFragment();
bundle.putSerializable("type", RetrieveFeedsAsyncTask.Type.PF_LOCAL);
}/*else if( position == 2) {
bundle.putString("instanceType","PIXELFED");
fragment.setArguments(bundle);
return fragment;
}else if( position == 2){
DisplayNotificationsFragment fragment = new DisplayNotificationsFragment();
bundle.putSerializable("type", RetrieveFeedsAsyncTask.Type.PF_NOTIFICATION);
fragment.setArguments(bundle);
return fragment;
}
/*else if( position == 3) {
bundle.putSerializable("type", RetrieveFeedsAsyncTask.Type.PF_DISCOVER);
}*/
bundle.putString("instanceType","PIXELFED");
fragment.setArguments(bundle);
return fragment;
return null;
}
return null;
}

View File

@ -89,7 +89,8 @@ public class RetrieveFeedsAsyncTask extends AsyncTask<Void, Void, Void> {
MYVIDEOS,
PF_HOME,
PF_LOCAL,
PF_DISCOVER
PF_DISCOVER,
PF_NOTIFICATION
}

View File

@ -143,8 +143,8 @@ public class PixelfedListAdapter extends RecyclerView.Adapter implements OnPostA
private class ViewHolderPixelfed extends RecyclerView.ViewHolder{
ImageView art_media, pf_pp, pf_comment, pf_share;
SparkButton pf_fav;
ImageView art_media, pf_pp, pf_comment;
SparkButton pf_fav, pf_share;
TextView pf_username, pf_likes, pf_description, pf_date;
CardView pf_cardview;
LinearLayout pf_bottom_container;
@ -293,21 +293,21 @@ public class PixelfedListAdapter extends RecyclerView.Adapter implements OnPostA
if (theme == Helper.THEME_BLACK) {
holder.pf_fav.setInActiveImageTint(R.color.action_black);
holder.pf_share.setInActiveImageTint(R.color.action_black);
changeDrawableColor(context, R.drawable.ic_pixelfed_favorite_border, 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) {
holder.pf_fav.setInActiveImageTint(R.color.action_dark);
holder.pf_share.setInActiveImageTint(R.color.action_dark);
changeDrawableColor(context, holder.pf_comment, R.color.action_dark);
changeDrawableColor(context, R.drawable.ic_pixelfed_favorite_border, R.color.action_dark);
changeDrawableColor(context, holder.pf_share, R.color.action_dark);
holder.pf_cardview.setCardBackgroundColor(ContextCompat.getColor(context, R.color.mastodonC1_));
} else {
holder.pf_fav.setInActiveImageTint(R.color.action_light);
holder.pf_share.setInActiveImageTint(R.color.action_light);
changeDrawableColor(context, holder.pf_comment, R.color.action_light);
changeDrawableColor(context, R.drawable.ic_pixelfed_favorite_border, R.color.action_light);
changeDrawableColor(context, holder.pf_share, R.color.action_light);
holder.pf_cardview.setCardBackgroundColor(ContextCompat.getColor(context, R.color.white));
}
@ -319,6 +319,13 @@ public class PixelfedListAdapter extends RecyclerView.Adapter implements OnPostA
holder.pf_fav.setActiveImageTint(R.color.pixelfed_like);
holder.pf_fav.setColors(R.color.pixelfed_like, R.color.pixelfed_like);
holder.pf_share.pressOnTouch(false);
holder.pf_share.setActiveImage(R.drawable.ic_boost_pixelfed);
holder.pf_share.setInactiveImage(R.drawable.ic_boost_pixelfed);
holder.pf_share.setDisableCircle(true);
holder.pf_share.setActiveImageTint(R.color.boost_icon);
holder.pf_share.setColors(R.color.boost_icon, R.color.boost_icon);
if (!status.isFavAnimated()) {
if (status.isFavourited() || (status.getReblog() != null && status.getReblog().isFavourited())) {
holder.pf_fav.setChecked(true);
@ -331,6 +338,19 @@ public class PixelfedListAdapter extends RecyclerView.Adapter implements OnPostA
holder.pf_fav.setAnimationSpeed(1.0f);
holder.pf_fav.playAnimation();
}
if (!status.isBoostAnimated()) {
if (status.isReblogged() || (status.getReblog() != null && status.getReblog().isReblogged())) {
holder.pf_share.setChecked(true);
} else {
holder.pf_share.setChecked(false);
}
} else {
status.setBoostAnimated(false);
holder.pf_share.setChecked(true);
holder.pf_share.setAnimationSpeed(1.0f);
holder.pf_share.playAnimation();
}
boolean confirmFav = sharedpreferences.getBoolean(Helper.SET_NOTIF_VALIDATION_FAV, false);
holder.pf_fav.setOnClickListener(new View.OnClickListener() {
@Override
@ -344,6 +364,19 @@ public class PixelfedListAdapter extends RecyclerView.Adapter implements OnPostA
CrossActions.doCrossAction(context, type, status, null, (status.isFavourited() || (status.getReblog() != null && status.getReblog().isFavourited())) ? API.StatusAction.UNFAVOURITE : API.StatusAction.FAVOURITE, pixelfedListAdapter, PixelfedListAdapter.this, true);
}
});
boolean confirmBoost = sharedpreferences.getBoolean(Helper.SET_NOTIF_VALIDATION, false);
holder.pf_share.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
if (!status.isReblogged() && confirmBoost)
status.setBoostAnimated(true);
if (!status.isReblogged() && !confirmBoost) {
status.setBoostAnimated(true);
notifyStatusChanged(status);
}
CrossActions.doCrossAction(context, type, status, null, (status.isReblogged() || (status.getReblog() != null && status.getReblog().isReblogged())) ? API.StatusAction.UNREBLOG : API.StatusAction.REBLOG, pixelfedListAdapter, PixelfedListAdapter.this, true);
}
});
}
}

View File

@ -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="M7,7h10v3l4,-4 -4,-4v3L5,5v6h2L7,7zM17,17L7,17v-3l-4,4 4,4v-3h12v-6h-2v4z"/>
</vector>

View File

@ -87,14 +87,16 @@
android:src="@drawable/ic_pixelfed_comment"
android:layout_width="30dp"
android:layout_height="30dp" />
<ImageView
<com.varunest.sparkbutton.SparkButton
android:layout_marginStart="15dp"
android:layout_marginLeft="15dp"
android:id="@+id/pf_share"
android:contentDescription="@string/share_with"
android:src="@drawable/ic_menu_share"
app:sparkbutton_activeImage="@drawable/ic_boost_pixelfed"
app:sparkbutton_inActiveImage="@drawable/ic_boost_pixelfed"
android:contentDescription="@string/share"
android:layout_width="30dp"
android:layout_height="30dp" />
android:layout_height="30dp"
app:sparkbutton_iconSize="30dp"/>
</LinearLayout>
<LinearLayout
android:id="@+id/pf_bottom_container"

View File

@ -826,6 +826,7 @@
<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>
<string name="share">Share</string>
<!-- end languages -->