forked from mirror/monocles_chat
Global setting to disable link previews
(cherry picked from commit 116639c6e52d7f995eee7c8a95ffc9845c972fe2)
This commit is contained in:
parent
96eca36620
commit
04b820f1f0
4 changed files with 28 additions and 13 deletions
src/main
java/eu/siacs/conversations
res
|
@ -44,6 +44,7 @@ public class AppSettings {
|
|||
public static final String SEND_CRASH_REPORTS = "send_crash_reports";
|
||||
public static final String COLORFUL_CHAT_BUBBLES = "use_green_background";
|
||||
public static final String LARGE_FONT = "large_font";
|
||||
public static final String SHOW_LINK_PREVIEWS = "show_link_previews";
|
||||
|
||||
private final Context context;
|
||||
|
||||
|
@ -108,6 +109,10 @@ public class AppSettings {
|
|||
return getBooleanPreference(LARGE_FONT, R.bool.large_font);
|
||||
}
|
||||
|
||||
public boolean showLinkPreviews() {
|
||||
return getBooleanPreference(SHOW_LINK_PREVIEWS, R.bool.show_link_previews);
|
||||
}
|
||||
|
||||
public boolean isUseTor() {
|
||||
return getBooleanPreference(USE_TOR, R.bool.use_tor);
|
||||
}
|
||||
|
|
|
@ -164,6 +164,7 @@ public class MessageAdapter extends ArrayAdapter<Message> {
|
|||
private final boolean mForceNames;
|
||||
private final Map<String, WebxdcUpdate> lastWebxdcUpdate = new HashMap<>();
|
||||
private String selectionUuid = null;
|
||||
private final AppSettings appSettings;
|
||||
|
||||
public MessageAdapter(
|
||||
final XmppActivity activity, final List<Message> messages, final boolean forceNames) {
|
||||
|
@ -171,6 +172,7 @@ public class MessageAdapter extends ArrayAdapter<Message> {
|
|||
this.audioPlayer = new AudioPlayer(this);
|
||||
this.activity = activity;
|
||||
metrics = getContext().getResources().getDisplayMetrics();
|
||||
appSettings = new AppSettings(activity);
|
||||
updatePreferences();
|
||||
this.mForceNames = forceNames;
|
||||
}
|
||||
|
@ -1594,18 +1596,20 @@ public class MessageAdapter extends ArrayAdapter<Message> {
|
|||
setTextColor(viewHolder.inReplyTo, bubbleColor);
|
||||
}
|
||||
|
||||
final var descriptions = message.getLinkDescriptions();
|
||||
viewHolder.link_descriptions.setAdapter(new ArrayAdapter<>(activity, 0, descriptions) {
|
||||
@Override
|
||||
public View getView(int position, View view, @NonNull ViewGroup parent) {
|
||||
final LinkDescriptionBinding binding = DataBindingUtil.inflate(LayoutInflater.from(parent.getContext()), R.layout.link_description, parent, false);
|
||||
binding.title.setText(getItem(position).findChildContent("title", "https://ogp.me/ns#"));
|
||||
binding.description.setText(getItem(position).findChildContent("description", "https://ogp.me/ns#"));
|
||||
binding.url.setText(getItem(position).findChildContent("url", "https://ogp.me/ns#"));
|
||||
return binding.getRoot();
|
||||
}
|
||||
});
|
||||
Util.justifyListViewHeightBasedOnChildren(viewHolder.link_descriptions, (int)(metrics.density * 100), true);
|
||||
if (appSettings.showLinkPreviews()) {
|
||||
final var descriptions = message.getLinkDescriptions();
|
||||
viewHolder.link_descriptions.setAdapter(new ArrayAdapter<>(activity, 0, descriptions) {
|
||||
@Override
|
||||
public View getView(int position, View view, @NonNull ViewGroup parent) {
|
||||
final LinkDescriptionBinding binding = DataBindingUtil.inflate(LayoutInflater.from(parent.getContext()), R.layout.link_description, parent, false);
|
||||
binding.title.setText(getItem(position).findChildContent("title", "https://ogp.me/ns#"));
|
||||
binding.description.setText(getItem(position).findChildContent("description", "https://ogp.me/ns#"));
|
||||
binding.url.setText(getItem(position).findChildContent("url", "https://ogp.me/ns#"));
|
||||
return binding.getRoot();
|
||||
}
|
||||
});
|
||||
Util.justifyListViewHeightBasedOnChildren(viewHolder.link_descriptions, (int)(metrics.density * 100), true);
|
||||
}
|
||||
}
|
||||
|
||||
displayStatus(viewHolder, message, type, bubbleColor);
|
||||
|
@ -1679,7 +1683,6 @@ public class MessageAdapter extends ArrayAdapter<Message> {
|
|||
}
|
||||
|
||||
public void updatePreferences() {
|
||||
final AppSettings appSettings = new AppSettings(activity);
|
||||
this.bubbleDesign =
|
||||
new BubbleDesign(appSettings.isColorfulChatBubbles(), appSettings.isLargeFont());
|
||||
}
|
||||
|
|
|
@ -52,6 +52,7 @@
|
|||
<bool name="enable_quiet_hours">false</bool>
|
||||
<bool name="autojoin">true</bool>
|
||||
<bool name="send_link_previews">true</bool>
|
||||
<bool name="show_link_previews">true</bool>
|
||||
<bool name="compose_rich_text">true</bool>
|
||||
<bool name="auto_accept_unmetered">true</bool>
|
||||
<string name="avatar_shape">oval</string>
|
||||
|
|
|
@ -129,6 +129,12 @@
|
|||
android:key="show_dynamic_tags"
|
||||
android:summary="@string/pref_show_dynamic_tags_summary"
|
||||
android:title="@string/pref_show_dynamic_tags" />
|
||||
<SwitchPreferenceCompat
|
||||
android:defaultValue="@bool/show_link_previews"
|
||||
android:icon="@drawable/ic_link_24dp"
|
||||
android:key="show_link_previews"
|
||||
android:summary="When a sender has included link descriptions, show them"
|
||||
android:title="Show Link Previews" />
|
||||
</PreferenceCategory>
|
||||
<PreferenceCategory android:title="@string/pref_category_operating_system">
|
||||
<SwitchPreferenceCompat
|
||||
|
|
Loading…
Add table
Reference in a new issue