Fixes issue #131 - Users Below Content Warnings
This commit is contained in:
parent
1158936eb8
commit
e8fdd7c977
|
@ -68,6 +68,7 @@ import fr.gouv.etalab.mastodon.client.APIResponse;
|
|||
import fr.gouv.etalab.mastodon.client.Entities.Attachment;
|
||||
import fr.gouv.etalab.mastodon.client.Entities.Emojis;
|
||||
import fr.gouv.etalab.mastodon.client.Entities.Error;
|
||||
import fr.gouv.etalab.mastodon.client.Entities.Mention;
|
||||
import fr.gouv.etalab.mastodon.helper.CrossActions;
|
||||
import fr.gouv.etalab.mastodon.interfaces.OnPostActionInterface;
|
||||
import fr.gouv.etalab.mastodon.interfaces.OnPostNotificationsActionInterface;
|
||||
|
@ -209,6 +210,7 @@ public class NotificationsListAdapter extends RecyclerView.Adapter implements On
|
|||
holder.status_privacy.getLayoutParams().width = (int) Helper.convertDpToPixel((20*iconSizePercent/100), context);
|
||||
holder.status_reply.getLayoutParams().height = (int) Helper.convertDpToPixel((20*iconSizePercent/100), context);
|
||||
holder.status_reply.getLayoutParams().width = (int) Helper.convertDpToPixel((20*iconSizePercent/100), context);
|
||||
holder.status_spoiler.setTextSize(TypedValue.COMPLEX_UNIT_SP, 14*textSizePercent/100);
|
||||
|
||||
holder.notification_status_content.setTextSize(TypedValue.COMPLEX_UNIT_SP, 14*textSizePercent/100);
|
||||
holder.notification_type.setTextSize(TypedValue.COMPLEX_UNIT_SP, 14*textSizePercent/100);
|
||||
|
@ -251,7 +253,7 @@ public class NotificationsListAdapter extends RecyclerView.Adapter implements On
|
|||
if( !status.isEmojiFound())
|
||||
status.makeEmojis(context, NotificationsListAdapter.this);
|
||||
holder.notification_status_content.setText(status.getContentSpan(), TextView.BufferType.SPANNABLE);
|
||||
|
||||
holder.status_spoiler.setText(status.getContentSpanCW(), TextView.BufferType.SPANNABLE);
|
||||
|
||||
holder.notification_status_content.setMovementMethod(null);
|
||||
holder.notification_status_content.setMovementMethod(LinkMovementMethod.getInstance());
|
||||
|
@ -261,6 +263,10 @@ public class NotificationsListAdapter extends RecyclerView.Adapter implements On
|
|||
|
||||
Helper.absoluteDateTimeReveal(context, holder.status_date, status.getCreated_at());
|
||||
|
||||
holder.status_mention_spoiler.setText(Helper.makeMentionsClick(context,status.getMentions()), TextView.BufferType.SPANNABLE);
|
||||
holder.status_mention_spoiler.setMovementMethod(null);
|
||||
holder.status_mention_spoiler.setMovementMethod(LinkMovementMethod.getInstance());
|
||||
|
||||
//Adds attachment -> disabled, to enable them uncomment the line below
|
||||
//loadAttachments(status, holder);
|
||||
holder.notification_status_container.setVisibility(View.VISIBLE);
|
||||
|
@ -321,29 +327,37 @@ public class NotificationsListAdapter extends RecyclerView.Adapter implements On
|
|||
if (status.getSpoiler_text() != null && status.getSpoiler_text().trim().length() > 0 && !status.isSpoilerShown()) {
|
||||
holder.notification_status_container.setVisibility(View.GONE);
|
||||
holder.status_spoiler_container.setVisibility(View.VISIBLE);
|
||||
holder.status_spoiler_mention_container.setVisibility(View.VISIBLE);
|
||||
holder.status_spoiler_button.setVisibility(View.VISIBLE);
|
||||
holder.status_spoiler.setVisibility(View.VISIBLE);
|
||||
} else {
|
||||
holder.status_spoiler_button.setVisibility(View.GONE);
|
||||
holder.notification_status_container.setVisibility(View.VISIBLE);
|
||||
if (status.getSpoiler_text() != null && status.getSpoiler_text().trim().length() > 0)
|
||||
if (status.getSpoiler_text() != null && status.getSpoiler_text().trim().length() > 0) {
|
||||
holder.status_spoiler_container.setVisibility(View.VISIBLE);
|
||||
else
|
||||
holder.status_spoiler_mention_container.setVisibility(View.VISIBLE);
|
||||
}else {
|
||||
holder.status_spoiler_container.setVisibility(View.GONE);
|
||||
holder.status_spoiler_mention_container.setVisibility(View.GONE);
|
||||
}
|
||||
}
|
||||
}else {
|
||||
if (status.getReblog().getSpoiler_text() != null && status.getReblog().getSpoiler_text().trim().length() > 0 && !status.isSpoilerShown()) {
|
||||
holder.notification_status_container.setVisibility(View.GONE);
|
||||
holder.status_spoiler_container.setVisibility(View.VISIBLE);
|
||||
holder.status_spoiler_mention_container.setVisibility(View.VISIBLE);
|
||||
holder.status_spoiler_button.setVisibility(View.VISIBLE);
|
||||
holder.status_spoiler.setVisibility(View.VISIBLE);
|
||||
} else {
|
||||
holder.status_spoiler_button.setVisibility(View.GONE);
|
||||
holder.notification_status_container.setVisibility(View.VISIBLE);
|
||||
if (status.getReblog().getSpoiler_text() != null && status.getReblog().getSpoiler_text().trim().length() > 0)
|
||||
if (status.getReblog().getSpoiler_text() != null && status.getReblog().getSpoiler_text().trim().length() > 0) {
|
||||
holder.status_spoiler_container.setVisibility(View.VISIBLE);
|
||||
else
|
||||
holder.status_spoiler_mention_container.setVisibility(View.VISIBLE);
|
||||
}else {
|
||||
holder.status_spoiler_container.setVisibility(View.GONE);
|
||||
holder.status_spoiler_mention_container.setVisibility(View.GONE);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -988,6 +1002,8 @@ public class NotificationsListAdapter extends RecyclerView.Adapter implements On
|
|||
LinearLayout notification_status_container;
|
||||
RelativeLayout main_container_trans;
|
||||
ImageView status_privacy;
|
||||
LinearLayout status_spoiler_mention_container;
|
||||
TextView status_mention_spoiler;
|
||||
|
||||
public View getView(){
|
||||
return itemView;
|
||||
|
@ -1026,6 +1042,8 @@ public class NotificationsListAdapter extends RecyclerView.Adapter implements On
|
|||
status_spoiler_container = itemView.findViewById(R.id.status_spoiler_container);
|
||||
status_spoiler = itemView.findViewById(R.id.status_spoiler);
|
||||
status_spoiler_button = itemView.findViewById(R.id.status_spoiler_button);
|
||||
status_spoiler_mention_container = itemView.findViewById(R.id.status_spoiler_mention_container);
|
||||
status_mention_spoiler = itemView.findViewById(R.id.status_mention_spoiler);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -84,6 +84,7 @@ import fr.gouv.etalab.mastodon.client.APIResponse;
|
|||
import fr.gouv.etalab.mastodon.client.Entities.Attachment;
|
||||
import fr.gouv.etalab.mastodon.client.Entities.Emojis;
|
||||
import fr.gouv.etalab.mastodon.client.Entities.Error;
|
||||
import fr.gouv.etalab.mastodon.client.Entities.Mention;
|
||||
import fr.gouv.etalab.mastodon.client.Entities.Status;
|
||||
import fr.gouv.etalab.mastodon.fragments.DisplayStatusFragment;
|
||||
import fr.gouv.etalab.mastodon.helper.CrossActions;
|
||||
|
@ -229,6 +230,8 @@ public class StatusListAdapter extends RecyclerView.Adapter implements OnPostAct
|
|||
ProgressBar loader_replies;
|
||||
Button fetch_more;
|
||||
ImageView new_element;
|
||||
LinearLayout status_spoiler_mention_container;
|
||||
TextView status_mention_spoiler;
|
||||
|
||||
public View getView(){
|
||||
return itemView;
|
||||
|
@ -277,6 +280,8 @@ public class StatusListAdapter extends RecyclerView.Adapter implements OnPostAct
|
|||
status_replies_profile_pictures = itemView.findViewById(R.id.status_replies_profile_pictures);
|
||||
new_element = itemView.findViewById(R.id.new_element);
|
||||
status_action_container = itemView.findViewById(R.id.status_action_container);
|
||||
status_spoiler_mention_container = itemView.findViewById(R.id.status_spoiler_mention_container);
|
||||
status_mention_spoiler = itemView.findViewById(R.id.status_mention_spoiler);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -586,6 +591,10 @@ public class StatusListAdapter extends RecyclerView.Adapter implements OnPostAct
|
|||
}
|
||||
});
|
||||
|
||||
holder.status_mention_spoiler.setText(Helper.makeMentionsClick(context,status.getMentions()), TextView.BufferType.SPANNABLE);
|
||||
holder.status_mention_spoiler.setMovementMethod(null);
|
||||
holder.status_mention_spoiler.setMovementMethod(LinkMovementMethod.getInstance());
|
||||
|
||||
if( status.getReblog() == null)
|
||||
holder.status_favorite_count.setText(String.valueOf(status.getFavourites_count()));
|
||||
else
|
||||
|
@ -631,29 +640,37 @@ public class StatusListAdapter extends RecyclerView.Adapter implements OnPostAct
|
|||
if (status.getSpoiler_text() != null && status.getSpoiler_text().trim().length() > 0 && !status.isSpoilerShown()) {
|
||||
holder.status_content_container.setVisibility(View.GONE);
|
||||
holder.status_spoiler_container.setVisibility(View.VISIBLE);
|
||||
holder.status_spoiler_mention_container.setVisibility(View.VISIBLE);
|
||||
holder.status_spoiler_button.setVisibility(View.VISIBLE);
|
||||
holder.status_spoiler.setVisibility(View.VISIBLE);
|
||||
} else {
|
||||
holder.status_spoiler_button.setVisibility(View.GONE);
|
||||
holder.status_content_container.setVisibility(View.VISIBLE);
|
||||
if (status.getSpoiler_text() != null && status.getSpoiler_text().trim().length() > 0)
|
||||
if (status.getSpoiler_text() != null && status.getSpoiler_text().trim().length() > 0) {
|
||||
holder.status_spoiler_container.setVisibility(View.VISIBLE);
|
||||
else
|
||||
holder.status_spoiler_mention_container.setVisibility(View.VISIBLE);
|
||||
}else {
|
||||
holder.status_spoiler_container.setVisibility(View.GONE);
|
||||
holder.status_spoiler_mention_container.setVisibility(View.GONE);
|
||||
}
|
||||
}
|
||||
}else {
|
||||
if (status.getReblog().getSpoiler_text() != null && status.getReblog().getSpoiler_text().trim().length() > 0 && !status.isSpoilerShown()) {
|
||||
holder.status_content_container.setVisibility(View.GONE);
|
||||
holder.status_spoiler_container.setVisibility(View.VISIBLE);
|
||||
holder.status_spoiler_mention_container.setVisibility(View.VISIBLE);
|
||||
holder.status_spoiler_button.setVisibility(View.VISIBLE);
|
||||
holder.status_spoiler.setVisibility(View.VISIBLE);
|
||||
} else {
|
||||
holder.status_spoiler_button.setVisibility(View.GONE);
|
||||
holder.status_content_container.setVisibility(View.VISIBLE);
|
||||
if (status.getReblog().getSpoiler_text() != null && status.getReblog().getSpoiler_text().trim().length() > 0)
|
||||
if (status.getReblog().getSpoiler_text() != null && status.getReblog().getSpoiler_text().trim().length() > 0) {
|
||||
holder.status_spoiler_container.setVisibility(View.VISIBLE);
|
||||
else
|
||||
holder.status_spoiler_mention_container.setVisibility(View.VISIBLE);
|
||||
}else {
|
||||
holder.status_spoiler_container.setVisibility(View.GONE);
|
||||
holder.status_spoiler_mention_container.setVisibility(View.GONE);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -112,6 +112,7 @@ import java.security.NoSuchAlgorithmException;
|
|||
import java.text.DateFormat;
|
||||
import java.text.ParseException;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Calendar;
|
||||
import java.util.Date;
|
||||
import java.util.HashMap;
|
||||
|
@ -133,6 +134,7 @@ import fr.gouv.etalab.mastodon.activities.WebviewActivity;
|
|||
import fr.gouv.etalab.mastodon.asynctasks.RemoveAccountAsyncTask;
|
||||
import fr.gouv.etalab.mastodon.client.API;
|
||||
import fr.gouv.etalab.mastodon.client.Entities.Account;
|
||||
import fr.gouv.etalab.mastodon.client.Entities.Mention;
|
||||
import fr.gouv.etalab.mastodon.client.Entities.Results;
|
||||
import fr.gouv.etalab.mastodon.client.Entities.Status;
|
||||
import fr.gouv.etalab.mastodon.sqlite.AccountDAO;
|
||||
|
@ -1083,6 +1085,43 @@ public class Helper {
|
|||
}
|
||||
|
||||
|
||||
public static SpannableString makeMentionsClick(final Context context, List<Mention> mentions){
|
||||
|
||||
String cw_mention = "";
|
||||
for(Mention mention:mentions){
|
||||
cw_mention = String.format("@%s %s",mention.getAcct(),cw_mention);
|
||||
}
|
||||
SpannableString spannableString = new SpannableString(cw_mention);
|
||||
for (final Mention mention : mentions) {
|
||||
String targetedAccount = "@" + mention.getUsername();
|
||||
if (spannableString.toString().contains(targetedAccount)) {
|
||||
|
||||
//Accounts can be mentioned several times so we have to loop
|
||||
for(int startPosition = -1 ; (startPosition = spannableString.toString().indexOf(targetedAccount, startPosition + 1)) != -1 ; startPosition++){
|
||||
int endPosition = startPosition + targetedAccount.length();
|
||||
spannableString.setSpan(new ClickableSpan() {
|
||||
@Override
|
||||
public void onClick(View textView) {
|
||||
Intent intent = new Intent(context, ShowAccountActivity.class);
|
||||
Bundle b = new Bundle();
|
||||
b.putString("accountId", mention.getId());
|
||||
intent.putExtras(b);
|
||||
context.startActivity(intent);
|
||||
}
|
||||
@Override
|
||||
public void updateDrawState(TextPaint ds) {
|
||||
super.updateDrawState(ds);
|
||||
}
|
||||
},
|
||||
startPosition, endPosition,
|
||||
Spanned.SPAN_INCLUSIVE_EXCLUSIVE);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
return spannableString;
|
||||
}
|
||||
|
||||
/**
|
||||
* Update the header with the new selected account
|
||||
* @param activity Activity
|
||||
|
|
|
@ -15,7 +15,7 @@
|
|||
You should have received a copy of the GNU General Public License along with Mastalab; if not,
|
||||
see <http://www.gnu.org/licenses>.
|
||||
-->
|
||||
<FrameLayout
|
||||
<FrameLayout xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
xmlns:card_view="http://schemas.android.com/tools"
|
||||
|
@ -50,7 +50,7 @@
|
|||
android:gravity="center_horizontal"
|
||||
android:id="@+id/notification_delete"
|
||||
android:layout_gravity="center_horizontal"
|
||||
android:src="@drawable/ic_delete"
|
||||
app:srcCompat="@drawable/ic_delete"
|
||||
android:layout_width="25dp"
|
||||
android:layout_height="25dp"
|
||||
tools:ignore="ContentDescription" />
|
||||
|
@ -151,7 +151,7 @@
|
|||
android:visibility="gone"
|
||||
android:layout_centerInParent="true"
|
||||
android:layout_width="20dp"
|
||||
android:src="@drawable/ic_play_arrow"
|
||||
app:srcCompat="@drawable/ic_play_arrow"
|
||||
android:layout_height="20dp"
|
||||
tools:ignore="ContentDescription" />
|
||||
</RelativeLayout>
|
||||
|
@ -179,7 +179,7 @@
|
|||
android:id="@+id/status_prev2_play"
|
||||
android:layout_centerInParent="true"
|
||||
android:layout_width="20dp"
|
||||
android:src="@drawable/ic_play_arrow"
|
||||
app:srcCompat="@drawable/ic_play_arrow"
|
||||
android:layout_height="20dp"
|
||||
tools:ignore="ContentDescription" />
|
||||
</RelativeLayout>
|
||||
|
@ -206,7 +206,7 @@
|
|||
android:id="@+id/status_prev3_play"
|
||||
android:layout_centerInParent="true"
|
||||
android:layout_width="20dp"
|
||||
android:src="@drawable/ic_play_arrow"
|
||||
app:srcCompat="@drawable/ic_play_arrow"
|
||||
android:visibility="gone"
|
||||
android:layout_height="20dp"
|
||||
tools:ignore="ContentDescription" />
|
||||
|
@ -229,7 +229,7 @@
|
|||
android:layout_centerInParent="true"
|
||||
android:visibility="gone"
|
||||
android:layout_width="20dp"
|
||||
android:src="@drawable/ic_play_arrow"
|
||||
app:srcCompat="@drawable/ic_play_arrow"
|
||||
android:layout_height="20dp"
|
||||
tools:ignore="ContentDescription" />
|
||||
</RelativeLayout>
|
||||
|
@ -255,6 +255,19 @@
|
|||
android:layout_height="wrap_content"
|
||||
android:text="@string/load_attachment" />
|
||||
</LinearLayout>
|
||||
<LinearLayout
|
||||
android:id="@+id/status_spoiler_mention_container"
|
||||
android:layout_width="match_parent"
|
||||
android:orientation="vertical"
|
||||
android:visibility="gone"
|
||||
android:layout_height="wrap_content">
|
||||
<TextView
|
||||
android:id="@+id/status_mention_spoiler"
|
||||
android:layout_marginTop="10dp"
|
||||
android:autoLink="web"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content" />
|
||||
</LinearLayout>
|
||||
</LinearLayout>
|
||||
</LinearLayout>
|
||||
<LinearLayout
|
||||
|
@ -274,7 +287,7 @@
|
|||
android:layout_gravity="center_vertical"
|
||||
android:layout_width="20dp"
|
||||
android:layout_height="20dp"
|
||||
android:src="@drawable/ic_reply"
|
||||
app:srcCompat="@drawable/ic_reply"
|
||||
tools:ignore="ContentDescription" />
|
||||
<TextView
|
||||
android:layout_marginLeft="20dp"
|
||||
|
@ -295,7 +308,6 @@
|
|||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content" />
|
||||
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="0dp"
|
||||
android:layout_weight="1"
|
||||
|
@ -318,7 +330,7 @@
|
|||
android:id="@+id/status_more"
|
||||
android:layout_width="25dp"
|
||||
android:layout_height="25dp"
|
||||
android:src="@drawable/ic_more_horiz"
|
||||
app:srcCompat="@drawable/ic_more_horiz"
|
||||
tools:ignore="ContentDescription" />
|
||||
</LinearLayout>
|
||||
</LinearLayout>
|
||||
|
|
|
@ -77,7 +77,7 @@
|
|||
android:layout_marginTop="5dp"
|
||||
android:id="@+id/new_element"
|
||||
android:visibility="gone"
|
||||
android:src="@drawable/ic_fiber_new"
|
||||
app:srcCompat="@drawable/ic_fiber_new"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
tools:ignore="ContentDescription" />
|
||||
|
@ -217,7 +217,7 @@
|
|||
android:visibility="gone"
|
||||
android:layout_centerInParent="true"
|
||||
android:layout_width="20dp"
|
||||
android:src="@drawable/ic_play_arrow"
|
||||
app:srcCompat="@drawable/ic_play_arrow"
|
||||
android:layout_height="20dp"
|
||||
tools:ignore="ContentDescription" />
|
||||
</RelativeLayout>
|
||||
|
@ -245,7 +245,7 @@
|
|||
android:id="@+id/status_prev2_play"
|
||||
android:layout_centerInParent="true"
|
||||
android:layout_width="20dp"
|
||||
android:src="@drawable/ic_play_arrow"
|
||||
app:srcCompat="@drawable/ic_play_arrow"
|
||||
android:layout_height="20dp"
|
||||
tools:ignore="ContentDescription" />
|
||||
</RelativeLayout>
|
||||
|
@ -272,7 +272,7 @@
|
|||
android:id="@+id/status_prev3_play"
|
||||
android:layout_centerInParent="true"
|
||||
android:layout_width="20dp"
|
||||
android:src="@drawable/ic_play_arrow"
|
||||
app:srcCompat="@drawable/ic_play_arrow"
|
||||
android:visibility="gone"
|
||||
android:layout_height="20dp"
|
||||
tools:ignore="ContentDescription" />
|
||||
|
@ -295,7 +295,7 @@
|
|||
android:layout_centerInParent="true"
|
||||
android:visibility="gone"
|
||||
android:layout_width="20dp"
|
||||
android:src="@drawable/ic_play_arrow"
|
||||
app:srcCompat="@drawable/ic_play_arrow"
|
||||
android:layout_height="20dp"
|
||||
tools:ignore="ContentDescription" />
|
||||
</RelativeLayout>
|
||||
|
@ -323,9 +323,22 @@
|
|||
style="@style/Base.Widget.AppCompat.Button.Borderless"
|
||||
android:text="@string/load_attachment" />
|
||||
</LinearLayout>
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/status_spoiler_mention_container"
|
||||
android:layout_width="match_parent"
|
||||
android:orientation="vertical"
|
||||
android:visibility="gone"
|
||||
android:layout_height="wrap_content">
|
||||
<TextView
|
||||
android:id="@+id/status_mention_spoiler"
|
||||
android:layout_marginTop="10dp"
|
||||
android:autoLink="web"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content" />
|
||||
</LinearLayout>
|
||||
</LinearLayout>
|
||||
|
||||
</LinearLayout>
|
||||
<LinearLayout
|
||||
android:id="@+id/status_action_container"
|
||||
android:layout_width="match_parent"
|
||||
|
@ -387,7 +400,7 @@
|
|||
android:layout_gravity="center_vertical"
|
||||
android:layout_width="20dp"
|
||||
android:layout_height="20dp"
|
||||
android:src="@drawable/ic_pin_drop"/>
|
||||
app:srcCompat="@drawable/ic_pin_drop"/>
|
||||
<LinearLayout
|
||||
android:layout_width="0dp"
|
||||
android:layout_weight="1"
|
||||
|
@ -410,7 +423,7 @@
|
|||
android:id="@+id/status_more"
|
||||
android:layout_width="25dp"
|
||||
android:layout_height="25dp"
|
||||
android:src="@drawable/ic_more_horiz"
|
||||
app:srcCompat="@drawable/ic_more_horiz"
|
||||
tools:ignore="ContentDescription" />
|
||||
</LinearLayout>
|
||||
</LinearLayout>
|
||||
|
|
Loading…
Reference in New Issue