mirror of
https://github.com/nuclearfog/Shitter.git
synced 2025-01-31 11:25:03 +01:00
added status text blur, added spoiler warning
This commit is contained in:
parent
2c41bb8a3d
commit
c11ef57f80
@ -98,6 +98,7 @@ public class GlobalSettings {
|
||||
private static final String ENABLE_TWITTER_ALT = "twitter_alt_set";
|
||||
private static final String FILTER_RESULTS = "filter_results";
|
||||
private static final String MASTODON_LOCAL_TIMELINE = "mastodon_local_timeline";
|
||||
private static final String HIDE_SENSITIVE = "hide_sensitive";
|
||||
|
||||
// current login preferences
|
||||
private static final String LOGGED_IN = "login";
|
||||
@ -148,6 +149,7 @@ public class GlobalSettings {
|
||||
private boolean enableLike;
|
||||
private boolean twitterAlt;
|
||||
private boolean localOnly;
|
||||
private boolean hideSensitive;
|
||||
private int background_color;
|
||||
private int font_color;
|
||||
private int highlight_color;
|
||||
@ -526,6 +528,26 @@ public class GlobalSettings {
|
||||
edit.apply();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return true to hide sensitivee/spoiler content by default
|
||||
*/
|
||||
public boolean hideSensitiveEnabled() {
|
||||
return hideSensitive;
|
||||
}
|
||||
|
||||
/**
|
||||
* enable hiding sensitive/spoiler content by default
|
||||
*
|
||||
* @param enable true to hide sensitivee/spoiler content by default
|
||||
*/
|
||||
public void hideSensitive(boolean enable) {
|
||||
hideSensitive = enable;
|
||||
|
||||
Editor edit = settings.edit();
|
||||
edit.putBoolean(HIDE_SENSITIVE, enable);
|
||||
edit.apply();
|
||||
}
|
||||
|
||||
/**
|
||||
* get selected location information
|
||||
*
|
||||
@ -996,6 +1018,7 @@ public class GlobalSettings {
|
||||
enableLike = settings.getBoolean(ENABLE_LIKE, false);
|
||||
twitterAlt = settings.getBoolean(ENABLE_TWITTER_ALT, false);
|
||||
localOnly = settings.getBoolean(MASTODON_LOCAL_TIMELINE, false);
|
||||
hideSensitive = settings.getBoolean(HIDE_SENSITIVE, true);
|
||||
proxyHost = settings.getString(PROXY_ADDR, "");
|
||||
proxyPort = settings.getString(PROXY_PORT, "");
|
||||
proxyUser = settings.getString(PROXY_USER, "");
|
||||
|
@ -17,6 +17,7 @@ import android.content.ClipData;
|
||||
import android.content.ClipboardManager;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.graphics.BlurMaskFilter;
|
||||
import android.net.Uri;
|
||||
import android.os.Bundle;
|
||||
import android.text.Spannable;
|
||||
@ -198,7 +199,7 @@ public class StatusActivity extends AppCompatActivity implements OnClickListener
|
||||
|
||||
private NestedScrollView container;
|
||||
private ViewGroup root, body;
|
||||
private TextView statusApi, createdAt, statusText, screenName, userName, locationName, sensitive_media;
|
||||
private TextView statusApi, createdAt, statusText, screenName, userName, locationName, sensitive, spoiler, spoilerHint;
|
||||
private Button replyButton, repostButton, likeButton, replyName, locationButton, repostNameButton;
|
||||
private ImageView profileImage;
|
||||
private RecyclerView cardList;
|
||||
@ -237,8 +238,10 @@ public class StatusActivity extends AppCompatActivity implements OnClickListener
|
||||
statusApi = findViewById(R.id.page_status_api);
|
||||
locationName = findViewById(R.id.page_status_location_name);
|
||||
locationButton = findViewById(R.id.page_status_location_coordinates);
|
||||
sensitive_media = findViewById(R.id.page_status_sensitive);
|
||||
sensitive = findViewById(R.id.page_status_sensitive);
|
||||
spoiler = findViewById(R.id.page_status_spoiler);
|
||||
repostNameButton = findViewById(R.id.page_status_reposter_reference);
|
||||
spoilerHint = findViewById(R.id.page_status_text_sensitive_hint);
|
||||
cardList = findViewById(R.id.page_status_cards);
|
||||
|
||||
statusAsync = new StatusAction(this);
|
||||
@ -252,7 +255,8 @@ public class StatusActivity extends AppCompatActivity implements OnClickListener
|
||||
replyButton.setCompoundDrawablesWithIntrinsicBounds(R.drawable.answer, 0, 0, 0);
|
||||
repostButton.setCompoundDrawablesWithIntrinsicBounds(R.drawable.repost, 0, 0, 0);
|
||||
locationButton.setCompoundDrawablesWithIntrinsicBounds(R.drawable.location, 0, 0, 0);
|
||||
sensitive_media.setCompoundDrawablesWithIntrinsicBounds(R.drawable.sensitive, 0, 0, 0);
|
||||
sensitive.setCompoundDrawablesWithIntrinsicBounds(R.drawable.sensitive, 0, 0, 0);
|
||||
spoiler.setCompoundDrawablesWithIntrinsicBounds(R.drawable.exclamation, 0, 0, 0);
|
||||
replyName.setCompoundDrawablesWithIntrinsicBounds(R.drawable.back, 0, 0, 0);
|
||||
repostNameButton.setCompoundDrawablesWithIntrinsicBounds(R.drawable.repost, 0, 0, 0);
|
||||
statusText.setMovementMethod(LinkAndScrollMovement.getInstance());
|
||||
@ -336,6 +340,7 @@ public class StatusActivity extends AppCompatActivity implements OnClickListener
|
||||
likeButton.setOnLongClickListener(this);
|
||||
repostNameButton.setOnLongClickListener(this);
|
||||
locationButton.setOnLongClickListener(this);
|
||||
statusText.setOnClickListener(this);
|
||||
}
|
||||
|
||||
|
||||
@ -581,6 +586,14 @@ public class StatusActivity extends AppCompatActivity implements OnClickListener
|
||||
intent.putExtra(ProfileActivity.KEY_PROFILE_USER, this.status.getAuthor());
|
||||
startActivity(intent);
|
||||
}
|
||||
// unblur text on click
|
||||
else if (v.getId() == R.id.page_status_text) {
|
||||
// remove blur if any
|
||||
if (statusText.getPaint().getMaskFilter() != null) {
|
||||
statusText.getPaint().setMaskFilter(null);
|
||||
spoilerHint.setVisibility(View.INVISIBLE);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -832,9 +845,23 @@ public class StatusActivity extends AppCompatActivity implements OnClickListener
|
||||
replyName.setVisibility(View.GONE);
|
||||
}
|
||||
if (status.isSensitive()) {
|
||||
sensitive_media.setVisibility(View.VISIBLE);
|
||||
sensitive.setVisibility(View.VISIBLE);
|
||||
} else {
|
||||
sensitive_media.setVisibility(View.GONE);
|
||||
sensitive.setVisibility(View.GONE);
|
||||
}
|
||||
if (status.isSpoiler()) {
|
||||
spoiler.setVisibility(View.VISIBLE);
|
||||
if (settings.hideSensitiveEnabled() && statusText.getPaint().getMaskFilter() == null) {
|
||||
spoilerHint.setVisibility(View.VISIBLE);
|
||||
statusText.setLayerType(View.LAYER_TYPE_SOFTWARE, null);
|
||||
float radius = statusText.getTextSize() / 3;
|
||||
BlurMaskFilter filter = new BlurMaskFilter(radius, BlurMaskFilter.Blur.NORMAL);
|
||||
statusText.getPaint().setMaskFilter(filter);
|
||||
} else {
|
||||
spoilerHint.setVisibility(View.INVISIBLE);
|
||||
}
|
||||
} else {
|
||||
spoiler.setVisibility(View.GONE);
|
||||
}
|
||||
String profileImageUrl = author.getProfileImageThumbnailUrl();
|
||||
if (settings.imagesEnabled() && !profileImageUrl.isEmpty()) {
|
||||
|
@ -4,6 +4,7 @@ import static androidx.recyclerview.widget.RecyclerView.HORIZONTAL;
|
||||
import static androidx.recyclerview.widget.RecyclerView.NO_POSITION;
|
||||
|
||||
import android.content.res.Resources;
|
||||
import android.graphics.BlurMaskFilter;
|
||||
import android.graphics.Color;
|
||||
import android.text.Spanned;
|
||||
import android.view.LayoutInflater;
|
||||
@ -143,6 +144,14 @@ public class StatusHolder extends ViewHolder implements OnClickListener {
|
||||
} else {
|
||||
text.setVisibility(View.GONE);
|
||||
}
|
||||
if (settings.hideSensitiveEnabled() && status.isSpoiler()) {
|
||||
text.setLayerType(View.LAYER_TYPE_SOFTWARE, null);
|
||||
float radius = text.getTextSize() / 3;
|
||||
BlurMaskFilter filter = new BlurMaskFilter(radius, BlurMaskFilter.Blur.NORMAL);
|
||||
text.getPaint().setMaskFilter(filter);
|
||||
} else {
|
||||
text.getPaint().setMaskFilter(null);
|
||||
}
|
||||
if (status.isReposted()) {
|
||||
repostIcon.setColorFilter(settings.getRepostIconColor());
|
||||
} else {
|
||||
|
8
app/src/main/res/drawable/exclamation.xml
Normal file
8
app/src/main/res/drawable/exclamation.xml
Normal file
@ -0,0 +1,8 @@
|
||||
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:height="16dp" android:width="16dp"
|
||||
android:viewportWidth="24" android:viewportHeight="24">
|
||||
<path android:fillColor="#00000000"
|
||||
android:pathData="M12,9v4m0,3v0.01M5.313,20h13.374c1.505,0 2.471,-1.6 1.77,-2.931L13.77,4.363c-0.75,-1.425 -2.79,-1.425 -3.54,0L3.543,17.068C2.842,18.4 3.808,20 5.313,20Z"
|
||||
android:strokeColor="#FFFFFF" android:strokeLineCap="round"
|
||||
android:strokeLineJoin="round" android:strokeWidth="2"/>
|
||||
</vector>
|
@ -151,6 +151,19 @@
|
||||
app:layout_constraintTop_toBottomOf="@id/page_status_text_barrier"
|
||||
app:layout_constraintEnd_toEndOf="parent" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/page_status_text_sensitive_hint"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:visibility="invisible"
|
||||
android:text="@string/status_spoiler_hint"
|
||||
android:lines="1"
|
||||
android:textSize="@dimen/page_status_textsize"
|
||||
app:layout_constraintStart_toStartOf="@id/page_status_text"
|
||||
app:layout_constraintTop_toTopOf="@id/page_status_text"
|
||||
app:layout_constraintBottom_toBottomOf="@id/page_status_text"
|
||||
app:layout_constraintEnd_toEndOf="@id/page_status_text"/>
|
||||
|
||||
<androidx.recyclerview.widget.RecyclerView
|
||||
android:id="@+id/page_status_cards"
|
||||
android:layout_width="wrap_content"
|
||||
@ -174,8 +187,26 @@
|
||||
android:textSize="@dimen/page_status_textsize_small"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@id/page_status_cards"
|
||||
app:layout_constraintEnd_toStartOf="@id/page_status_spoiler"
|
||||
app:layout_constraintHorizontal_bias="0.0"
|
||||
app:layout_constraintHorizontal_chainStyle="packed"/>
|
||||
|
||||
<TextView
|
||||
android:id="@+id/page_status_spoiler"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:visibility="invisible"
|
||||
android:drawablePadding="@dimen/page_status_padding_drawable"
|
||||
android:layout_marginStart="@dimen/page_status_textview_margin"
|
||||
android:layout_marginTop="@dimen/page_status_textview_margin"
|
||||
android:layout_marginEnd="@dimen/page_status_textview_margin"
|
||||
android:lines="1"
|
||||
android:text="@string/status_contains_spoiler"
|
||||
android:textSize="@dimen/page_status_textsize_small"
|
||||
app:layout_constraintStart_toEndOf="@id/page_status_sensitive"
|
||||
app:layout_constraintTop_toBottomOf="@id/page_status_cards"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintHorizontal_bias="0.0" />
|
||||
app:layout_constraintHorizontal_bias="0.0"/>
|
||||
|
||||
<TextView
|
||||
android:id="@+id/page_status_location_name"
|
||||
|
@ -131,6 +131,7 @@
|
||||
<string name="error_wrong_connection_settings">Falsche Proxykonfiguration! Änderung verwerfen?</string>
|
||||
<string name="error_open_link">Link konnte nicht geöffnet werden!</string>
|
||||
<string name="status_sensitive_media">Sensible Inhalte</string>
|
||||
<string name="status_spoiler_hint">Zum Anzeigen tippen</string>
|
||||
<string name="login_info">4 Schritte zum Login</string>
|
||||
<string name="info_open_twitter_login">öffne Twitter login Seite. Bitte warten</string>
|
||||
<string name="info_login_to_twitter">In Twitter einloggen</string>
|
||||
@ -291,4 +292,5 @@
|
||||
<string name="dialog_status_sensitive">Inhalt als sensibel markieren</string>
|
||||
<string name="dialog_status_spoiler">Inhalt als Spoiler markieren</string>
|
||||
<string name="dialog_status_visibility">Sichtbarkeit</string>
|
||||
<string name="status_contains_spoiler">Spoiler!</string>
|
||||
</resources>
|
@ -266,6 +266,8 @@
|
||||
<string name="settings_enable_proxy">enable proxy</string>
|
||||
<string name="settings_enable_proxy_auth">enable proxy authentication</string>
|
||||
<string name="status_sensitive_media">sensitive content</string>
|
||||
<string name="status_contains_spoiler">Spoiler!</string>
|
||||
<string name="status_spoiler_hint">Tap to view</string>
|
||||
<string name="login_info">4 steps to login</string>
|
||||
<string name="login_first_opt" translatable="false">1.</string>
|
||||
<string name="login_sec_opt" translatable="false">2.</string>
|
||||
|
Loading…
x
Reference in New Issue
Block a user