added new option to enable/disable additional tweet icons

This commit is contained in:
nuclearfog 2022-09-09 12:58:17 +02:00
parent f204537e8b
commit 548a672b1e
No known key found for this signature in database
GPG Key ID: AA0271FBE406DB98
7 changed files with 82 additions and 23 deletions

View File

@ -326,30 +326,35 @@ public class TweetAdapter extends Adapter<ViewHolder> {
} else {
tweetItem.profile.setImageResource(0);
}
if (tweet.getLocationName() != null && !tweet.getLocationName().isEmpty()) {
tweetItem.location.setVisibility(VISIBLE);
} else {
tweetItem.location.setVisibility(GONE);
}
if (tweet.getRepliedTweetId() > 0) {
tweetItem.reply.setVisibility(VISIBLE);
tweetItem.replyIcon.setVisibility(VISIBLE);
tweetItem.replyname.setVisibility(VISIBLE);
tweetItem.replyname.setText(tweet.getReplyName());
} else {
tweetItem.reply.setVisibility(GONE);
tweetItem.replyIcon.setVisibility(GONE);
tweetItem.replyname.setVisibility(GONE);
}
if (tweet.getMediaType() != Tweet.MEDIA_NONE) {
if (tweet.getMediaType() == Tweet.MEDIA_PHOTO) {
tweetItem.media.setImageResource(R.drawable.image);
} else if (tweet.getMediaType() == Tweet.MEDIA_VIDEO) {
tweetItem.media.setImageResource(R.drawable.video);
} else if (tweet.getMediaType() == Tweet.MEDIA_GIF) {
tweetItem.media.setImageResource(R.drawable.gif);
if (settings.tweetIndicatorsEnabled()) {
if (tweet.getLocationName() != null && !tweet.getLocationName().isEmpty()) {
tweetItem.location.setVisibility(VISIBLE);
} else {
tweetItem.location.setVisibility(GONE);
}
if (tweet.getMediaType() != Tweet.MEDIA_NONE) {
if (tweet.getMediaType() == Tweet.MEDIA_PHOTO) {
tweetItem.media.setImageResource(R.drawable.image);
} else if (tweet.getMediaType() == Tweet.MEDIA_VIDEO) {
tweetItem.media.setImageResource(R.drawable.video);
} else if (tweet.getMediaType() == Tweet.MEDIA_GIF) {
tweetItem.media.setImageResource(R.drawable.gif);
}
tweetItem.media.setColorFilter(settings.getIconColor());
tweetItem.media.setVisibility(VISIBLE);
} else {
tweetItem.media.setVisibility(GONE);
}
tweetItem.media.setColorFilter(settings.getIconColor());
tweetItem.media.setVisibility(VISIBLE);
} else {
tweetItem.location.setVisibility(GONE);
tweetItem.media.setVisibility(GONE);
}
}

View File

@ -20,7 +20,7 @@ import org.nuclearfog.twidda.database.GlobalSettings;
*/
public class TweetHolder extends ViewHolder {
public final ImageView profile, rtUser, verifiedIcon, lockedIcon, rtIcon, favIcon, media, location, reply;
public final ImageView profile, rtUser, verifiedIcon, lockedIcon, rtIcon, favIcon, media, location, replyIcon;
public final TextView username, screenname, tweettext, retweet, favorite, retweeter, created, replyname;
/**
@ -39,7 +39,7 @@ public class TweetHolder extends ViewHolder {
favIcon = itemView.findViewById(R.id.item_tweet_favorite_icon);
media = itemView.findViewById(R.id.item_tweet_media);
location = itemView.findViewById(R.id.item_tweet_location);
reply = itemView.findViewById(R.id.item_tweet_reply);
replyIcon = itemView.findViewById(R.id.item_tweet_reply);
username = itemView.findViewById(R.id.item_tweet_author_username);
screenname = itemView.findViewById(R.id.item_tweet_author_screenname);
tweettext = itemView.findViewById(R.id.item_tweet_text);

View File

@ -97,6 +97,7 @@ public class GlobalSettings {
private static final String IMAGE_LOAD = "image_load";
private static final String IMAGE_QUALITY = "image_hq";
private static final String ANSWER_LOAD = "answer_load";
private static final String TWEET_INDICATOR = "tweet_indicator";
private static final String PROFILE_OVERLAP = "profile_toolbar_overlap";
private static final String PROXY_SET = "proxy_enabled";
private static final String AUTH_SET = "proxy_auth_set";
@ -158,6 +159,7 @@ public class GlobalSettings {
private boolean customAPIKey;
private boolean toolbarOverlap;
private boolean linkPreview;
private boolean tweetIndicators;
private boolean filterResults;
private boolean enableLike;
private boolean twitterAlt;
@ -581,6 +583,26 @@ public class GlobalSettings {
edit.apply();
}
/**
* @return true if tweet indicators enabled
*/
public boolean tweetIndicatorsEnabled() {
return tweetIndicators;
}
/**
* enable/disable tweet indicators
*
* @param enable true to enable tweet indicators
*/
public void enableTweetIndicators(boolean enable) {
tweetIndicators = enable;
Editor edit = settings.edit();
edit.putBoolean(TWEET_INDICATOR, enable);
edit.apply();
}
/**
* get selected location information
*
@ -1120,6 +1142,7 @@ public class GlobalSettings {
loggedIn = settings.getBoolean(LOGGED_IN, false);
loadImage = settings.getBoolean(IMAGE_LOAD, true);
loadAnswer = settings.getBoolean(ANSWER_LOAD, false);
tweetIndicators = settings.getBoolean(TWEET_INDICATOR, true);
hqImages = settings.getBoolean(IMAGE_QUALITY, false);
toolbarOverlap = settings.getBoolean(PROFILE_OVERLAP, true);
linkPreview = settings.getBoolean(LINK_PREVIEW, false);

View File

@ -135,6 +135,7 @@ public class SettingsActivity extends AppCompatActivity implements OnClickListen
SwitchButton enablePreview = findViewById(R.id.settings_enable_prev);
SwitchButton enableLike = findViewById(R.id.enable_like);
SwitchButton enableTwitterAlt = findViewById(R.id.settings_enable_twitter_alt);
SwitchButton enableTweetIcons = findViewById(R.id.enable_tweet_indicators);
SeekBar listSizeSelector = findViewById(R.id.settings_list_seek);
Spinner fontSelector = findViewById(R.id.spinner_font);
Spinner scaleSelector = findViewById(R.id.spinner_scale);
@ -224,6 +225,7 @@ public class SettingsActivity extends AppCompatActivity implements OnClickListen
toolbarOverlap.setCheckedImmediately(settings.toolbarOverlapEnabled());
enableLike.setCheckedImmediately(settings.likeEnabled());
enableTwitterAlt.setCheckedImmediately(settings.twitterAltSet());
enableTweetIcons.setCheckedImmediately(settings.tweetIndicatorsEnabled());
enableAPI.setCheckedImmediately(settings.isCustomApiSet());
enableProxy.setCheckedImmediately(settings.isProxyEnabled());
enableAuth.setCheckedImmediately(settings.isProxyAuthSet());
@ -248,6 +250,7 @@ public class SettingsActivity extends AppCompatActivity implements OnClickListen
enableAPI.setOnCheckedChangeListener(this);
enableLike.setOnCheckedChangeListener(this);
enableTwitterAlt.setOnCheckedChangeListener(this);
enableTweetIcons.setOnCheckedChangeListener(this);
enablePreview.setOnCheckedChangeListener(this);
enableProxy.setOnCheckedChangeListener(this);
enableAuth.setOnCheckedChangeListener(this);
@ -520,6 +523,10 @@ public class SettingsActivity extends AppCompatActivity implements OnClickListen
else if (c.getId() == R.id.settings_enable_twitter_alt) {
settings.setTwitterAlt(checked);
}
// enable tweet indicators
else if (c.getId() == R.id.enable_tweet_indicators) {
settings.enableTweetIndicators(checked);
}
// enable link preview
else if (c.getId() == R.id.settings_enable_prev) {
settings.setLinkPreview(checked);

View File

@ -234,7 +234,7 @@
android:layout_marginEnd="@dimen/settings_switch_margin"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/settings_toolbar_ov"
app:layout_constraintBottom_toTopOf="@id/spinner_font"
app:layout_constraintBottom_toTopOf="@id/enable_tweet_indicators"
app:layout_constraintEnd_toStartOf="@id/enable_like_descr" />
<TextView
@ -249,6 +249,29 @@
app:layout_constraintBottom_toBottomOf="@id/enable_like"
app:layout_constraintEnd_toEndOf="parent" />
<com.kyleduo.switchbutton.SwitchButton
android:id="@+id/enable_tweet_indicators"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginBottom="@dimen/settings_column_margin"
android:layout_marginEnd="@dimen/settings_switch_margin"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/enable_like"
app:layout_constraintBottom_toTopOf="@id/spinner_font"
app:layout_constraintEnd_toStartOf="@id/enable_tweet_indicators_descr" />
<TextView
android:id="@+id/enable_tweet_indicators_descr"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:singleLine="true"
android:text="@string/settings_enable_indicators"
android:textSize="@dimen/settings_textsize_small"
app:layout_constraintStart_toEndOf="@id/enable_tweet_indicators"
app:layout_constraintTop_toTopOf="@id/enable_tweet_indicators"
app:layout_constraintBottom_toBottomOf="@id/enable_tweet_indicators"
app:layout_constraintEnd_toEndOf="parent" />
<ImageView
android:id="@+id/settings_fonttype_icon"
android:layout_width="@dimen/settings_icon_size"
@ -258,7 +281,7 @@
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="@id/spinner_font"
app:layout_constraintBottom_toBottomOf="@id/spinner_font"
app:layout_constraintEnd_toEndOf="@id/enable_like"
app:layout_constraintEnd_toEndOf="@id/enable_tweet_indicators"
tools:ignore="ContentDescription" />
<Spinner
@ -266,9 +289,8 @@
android:layout_width="0dp"
android:layout_height="wrap_content"
android:popupBackground="@android:color/transparent"
app:layout_constraintStart_toStartOf="@+id/enable_like_descr"
app:layout_constraintTop_toBottomOf="@id/enable_like"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintStart_toStartOf="@+id/enable_tweet_indicators_descr"
app:layout_constraintTop_toBottomOf="@id/enable_tweet_indicators"
app:layout_constraintEnd_toStartOf="@id/spinner_scale"
app:layout_constraintHorizontal_weight="3" />

View File

@ -247,4 +247,5 @@
<string name="info_tweet_location_copied">Standortkoordinaten kopiert</string>
<string name="title_metrics">Tweet Metriken</string>
<string name="menu_tweet_metrics">Metriken</string>
<string name="settings_enable_indicators">zeige zusätzliche Tweet Informationen an</string>
</resources>

View File

@ -168,6 +168,7 @@
<string name="settings_icon_color">Icons</string>
<string name="settings_color_like">Like</string>
<string name="settings_color_fav">Favorite</string>
<string name="settings_enable_indicators">show additional Tweet information</string>
<string name="highlight">Highlight</string>
<string name="settings_api_info">• changing API Keys requires re-login</string>
<string name="settings_list_size">List size</string>