Merge branch 'feature/cw-above-text' into fork

This commit is contained in:
sk 2022-11-17 00:56:08 +01:00
commit 7bcfd8939e
7 changed files with 67 additions and 10 deletions

View File

@ -11,6 +11,7 @@ public class GlobalUserPreferences{
public static boolean showBoosts;
public static boolean loadNewPosts;
public static boolean showInteractionCounts;
public static boolean alwaysExpandContentWarnings;
public static ThemePreference theme;
private static SharedPreferences getPrefs(){
@ -26,6 +27,7 @@ public class GlobalUserPreferences{
showBoosts=prefs.getBoolean("showBoosts", true);
loadNewPosts=prefs.getBoolean("loadNewPosts", true);
showInteractionCounts=prefs.getBoolean("showInteractionCounts", false);
alwaysExpandContentWarnings=prefs.getBoolean("alwaysExpandContentWarnings", false);
theme=ThemePreference.values()[prefs.getInt("theme", 0)];
}
@ -38,6 +40,7 @@ public class GlobalUserPreferences{
.putBoolean("loadNewPosts", loadNewPosts)
.putBoolean("trueBlackTheme", trueBlackTheme)
.putBoolean("showInteractionCounts", showInteractionCounts)
.putBoolean("alwaysExpandContentWarnings", alwaysExpandContentWarnings)
.putInt("theme", theme.ordinal())
.apply();
}

View File

@ -108,6 +108,10 @@ public class SettingsFragment extends MastodonToolbarFragment{
GlobalUserPreferences.showInteractionCounts=i.checked;
GlobalUserPreferences.save();
}));
items.add(new SwitchItem(R.string.settings_always_reveal_content_warnings, R.drawable.ic_fluent_chat_warning_24_regular, GlobalUserPreferences.alwaysExpandContentWarnings, i->{
GlobalUserPreferences.alwaysExpandContentWarnings=i.checked;
GlobalUserPreferences.save();
}));
items.add(new HeaderItem(R.string.home_timeline));
items.add(new SwitchItem(R.string.settings_show_replies, R.drawable.ic_fluent_chat_multiple_24_regular, GlobalUserPreferences.showReplies, i->{

View File

@ -1,5 +1,6 @@
package org.joinmastodon.android.model;
import org.joinmastodon.android.GlobalUserPreferences;
import org.joinmastodon.android.api.ObjectValidationException;
import org.joinmastodon.android.api.RequiredField;
import org.joinmastodon.android.events.StatusCountersUpdatedEvent;
@ -78,7 +79,7 @@ public class Status extends BaseModel implements DisplayItemsParent{
if(reblog!=null)
reblog.postprocess();
spoilerRevealed=!sensitive;
spoilerRevealed=GlobalUserPreferences.alwaysExpandContentWarnings || !sensitive;
}
@Override

View File

@ -3,6 +3,7 @@ package org.joinmastodon.android.ui.displayitems;
import android.app.Activity;
import android.graphics.drawable.Animatable;
import android.graphics.drawable.Drawable;
import android.graphics.drawable.LayerDrawable;
import android.text.TextUtils;
import android.view.View;
import android.view.ViewGroup;
@ -11,6 +12,7 @@ import android.widget.TextView;
import org.joinmastodon.android.R;
import org.joinmastodon.android.fragments.BaseStatusListFragment;
import org.joinmastodon.android.model.Status;
import org.joinmastodon.android.ui.drawables.SpoilerStripesDrawable;
import org.joinmastodon.android.ui.text.HtmlParser;
import org.joinmastodon.android.ui.utils.CustomEmojiHelper;
import org.joinmastodon.android.ui.views.LinkedTextView;
@ -59,13 +61,16 @@ public class TextStatusDisplayItem extends StatusDisplayItem{
public static class Holder extends StatusDisplayItem.Holder<TextStatusDisplayItem> implements ImageLoaderViewHolder{
private final LinkedTextView text;
private final TextView spoilerTitle;
private final View spoilerOverlay;
private final TextView spoilerTitle, spoilerTitleInline;
private final View spoilerOverlay, content, spoilerHeader;
public Holder(Activity activity, ViewGroup parent){
super(activity, R.layout.display_item_text, parent);
text=findViewById(R.id.text);
spoilerTitle=findViewById(R.id.spoiler_title);
spoilerTitleInline=findViewById(R.id.spoiler_title_inline);
content=findViewById(R.id.content);
spoilerHeader=findViewById(R.id.spoiler_header);
spoilerOverlay=findViewById(R.id.spoiler_overlay);
itemView.setOnClickListener(v->item.parentFragment.onRevealSpoilerClick(this));
}
@ -77,17 +82,21 @@ public class TextStatusDisplayItem extends StatusDisplayItem{
text.setInvalidateOnEveryFrame(false);
if(!TextUtils.isEmpty(item.status.spoilerText)){
spoilerTitle.setText(item.parsedSpoilerText);
spoilerTitleInline.setText(item.parsedSpoilerText);
if(item.status.spoilerRevealed){
spoilerOverlay.setVisibility(View.GONE);
spoilerHeader.setVisibility(View.VISIBLE);
text.setVisibility(View.VISIBLE);
itemView.setClickable(false);
}else{
spoilerOverlay.setVisibility(View.VISIBLE);
spoilerHeader.setVisibility(View.GONE);
text.setVisibility(View.GONE);
itemView.setClickable(true);
}
}else{
spoilerOverlay.setVisibility(View.GONE);
spoilerHeader.setVisibility(View.GONE);
text.setVisibility(View.VISIBLE);
itemView.setClickable(false);
}

View File

@ -3,23 +3,61 @@
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingLeft="16dp"
android:paddingRight="16dp"
android:paddingTop="10dp"
android:paddingBottom="12dp">
<org.joinmastodon.android.ui.views.LinkedTextView
android:id="@+id/text"
<LinearLayout
android:id="@+id/content"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textSize="16sp"
android:textAppearance="@style/m3_body_large"/>
android:layout_height="wrap_content">
<LinearLayout
android:id="@+id/spoiler_header"
android:orientation="vertical"
android:layout_width="wrap_content"
android:layout_height="wrap_content">
<View
android:layout_width="match_parent"
android:layout_height="0.5dp"
android:background="?attr/colorPollVoted"/>
<TextView
android:id="@+id/spoiler_title_inline"
android:paddingHorizontal="16dp"
android:paddingVertical="12dp"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="0dp"
android:textAppearance="@style/m3_title_medium"
android:background="?colorBackgroundLight"
tools:text="CW title"/>
<View
android:layout_width="match_parent"
android:layout_height="0.5dp"
android:layout_marginBottom="12dp"
android:background="?attr/colorPollVoted"/>
</LinearLayout>
<org.joinmastodon.android.ui.views.LinkedTextView
android:id="@+id/text"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingHorizontal="16dp"
android:textSize="16sp"
android:textAppearance="@style/m3_body_large"
tools:text="setting up my mstdn"/>
</LinearLayout>
<LinearLayout
android:visibility="gone"
android:id="@+id/spoiler_overlay"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:paddingHorizontal="16dp"
android:orientation="vertical">
<TextView

View File

@ -412,4 +412,5 @@
<string name="privacy_policy_title">Mastodon und Ihre Privatsphäre</string>
<string name="privacy_policy_subtitle">Obwohl die Mastodon-App keine Daten sammelt, kann der Server, über den Sie sich anmelden, eine andere Richtlinie haben. Nehmen Sie sich eine Minute Zeit, um die Mastodon-Datenschutzrichtlinien und die Datenschutzrichtlinien Ihres Servers zu lesen und zu akzeptieren.</string>
<string name="i_agree">Ich stimme zu</string>
<string name="settings_always_reveal_content_warnings">Inhaltswarnungen immer ausklappen</string>
</resources>

View File

@ -420,4 +420,5 @@
<string name="reject_follow_request">Reject follow request</string>
<string name="lists_with_user">Lists with %s</string>
<string name="empty_list">This list is empty</string>
<string name="settings_always_reveal_content_warnings">Always reveal content warnings</string>
</resources>