Commit 9e0fef6f authored by 0xd9a's avatar 0xd9a
Browse files

Improve link preview preference (fix #728)

parent e4f677df
Loading
Loading
Loading
Loading
+13 −0
Original line number Diff line number Diff line
@@ -1146,6 +1146,19 @@ public abstract class BaseMainActivity extends BaseActivity implements NetworkSt
                    .apply();
        }

        if (sharedpreferences.getString(getString(R.string.SET_LINK_PREVIEWS), null) == null) {
            boolean oldDisplayCardValue = sharedpreferences.getBoolean(getString(R.string.SET_DISPLAY_CARD), false);
            String[] linkPreviewsEntryValues = getResources().getStringArray(R.array.set_link_previews_entry_values);
            String newLinkPreviewsValue;
            if (oldDisplayCardValue)
                newLinkPreviewsValue = linkPreviewsEntryValues[0];
            else
                newLinkPreviewsValue = linkPreviewsEntryValues[1];
            sharedpreferences.edit()
                    .putString(getString(R.string.SET_LINK_PREVIEWS), newLinkPreviewsValue)
                    .apply();
        }

        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.TIRAMISU) {
            ActivityResultLauncher<String> permissionLauncher = registerForActivityResult(new ActivityResultContracts.RequestPermission(), isGranted -> {
                if (!isGranted) {
+4 −1
Original line number Diff line number Diff line
@@ -572,7 +572,8 @@ public class StatusAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder>


        boolean expand_cw = sharedpreferences.getBoolean(context.getString(R.string.SET_EXPAND_CW), false);
        boolean display_card = sharedpreferences.getBoolean(context.getString(R.string.SET_DISPLAY_CARD), false);
        String linkPreviews = sharedpreferences.getString(context.getString(R.string.SET_LINK_PREVIEWS), "hide_when_media");
        String[] linkPreviewsEntryValues = context.getResources().getStringArray(R.array.set_link_previews_entry_values);
        boolean share_details = sharedpreferences.getBoolean(context.getString(R.string.SET_SHARE_DETAILS), true);
        boolean confirmFav = sharedpreferences.getBoolean(context.getString(R.string.SET_NOTIF_VALIDATION_FAV), false);
        boolean confirmBoost = sharedpreferences.getBoolean(context.getString(R.string.SET_NOTIF_VALIDATION), true);
@@ -1018,6 +1019,8 @@ public class StatusAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder>
            }
        }

        boolean display_card = linkPreviews.equals(linkPreviewsEntryValues[0]) || (linkPreviews.equals(linkPreviewsEntryValues[1]) && (statusToDeal.media_attachments.isEmpty() || (hideSingleMediaWithCard && statusToDeal.media_attachments.size() == 1)));

        if (statusToDeal.card != null && (display_card || statusToDeal.isFocused) && statusToDeal.quote_id == null) {
            if (statusToDeal.card.width > statusToDeal.card.height) {
                holder.binding.cardImageHorizontal.setVisibility(View.VISIBLE);
+13 −0
Original line number Diff line number Diff line
@@ -789,6 +789,17 @@
        <item>hide</item>
    </string-array>

    <string-array name="set_link_previews_entries">
        <item>Always show</item>
        <item>Hide in posts with media</item>
        <item>Always hide</item>
    </string-array>
    <string-array name="set_link_previews_entry_values" translatable="false">
        <item>show</item>
        <item>hide_when_media</item>
        <item>hide</item>
    </string-array>

    <string-array name="set_thread_message_value">
        <item>Ask</item>
        <item>Disable</item>
@@ -1049,6 +1060,7 @@


    <string name="SET_DISPLAY_CARD" translatable="false">SET_DISPLAY_CARD</string>
    <string name="SET_LINK_PREVIEWS" translatable="false">SET_LINK_PREVIEWS</string>
    <string name="SET_DISPLAY_VIDEO_PREVIEWS" translatable="false">SET_DISPLAY_VIDEO_PREVIEWS</string>
    <string name="SET_NOTIFICATION_ACTION" translatable="false">SET_NOTIFICATION_ACTION</string>
    <string name="SET_FEATURED_TAGS" translatable="false">SET_FEATURED_TAGS</string>
@@ -1418,6 +1430,7 @@
    <string name="set_display_bookmark_indication">Always display bookmark button</string>
    <string name="set_display_translate_indication">Always display translate button</string>
    <string name="set_translate_button">Translate button</string>
    <string name="set_link_previews">Link previews</string>
    <string name="display">Display</string>
    <string name="bottom_menu">Bottom menu</string>
    <string name="top_menu">Top bar menu</string>
+8 −0
Original line number Diff line number Diff line
@@ -297,6 +297,14 @@
        app:singleLineTitle="false"
        app:title="@string/set_display_card" />

    <ListPreference
        android:entries="@array/set_link_previews_entries"
        android:entryValues="@array/set_link_previews_entry_values"
        android:title="@string/set_link_previews"
        app:iconSpaceReserved="false"
        app:key="@string/SET_LINK_PREVIEWS"
        app:useSimpleSummaryProvider="true" />

    <androidx.preference.SeekBarPreference
        android:defaultValue="40"
        app:min="10"