~singpolyma/cheogram-android

005f85e6f0f565565e5992cf75d915ff9a99affc — Stephen Paul Weber 6 months ago 51e5399
Get more SVGs to fill their area properly
M src/main/java/eu/siacs/conversations/entities/Conversation.java => src/main/java/eu/siacs/conversations/entities/Conversation.java +17 -2
@@ 61,6 61,7 @@ import androidx.recyclerview.widget.GridLayoutManager;
import androidx.viewpager.widget.ViewPager;

import com.caverock.androidsvg.SVG;
import com.caverock.androidsvg.SVGParseException;

import com.cheogram.android.ConversationPage;
import com.cheogram.android.Util;


@@ 2175,9 2176,16 @@ public class Conversation extends AbstractEntity implements Blockable, Comparabl

                            final SVG icon = getItem(position).getIcon();
                            if (icon != null) {
                                 synchronized (CommandSession.this) {
                                     waitingForRefresh = true;
                                 }
                                 v.post(() -> {
                                     if (v.getHeight() == 0) return;
                                     icon.setDocumentPreserveAspectRatio(com.caverock.androidsvg.PreserveAspectRatio.TOP);
                                     icon.setDocumentPreserveAspectRatio(com.caverock.androidsvg.PreserveAspectRatio.LETTERBOX);
                                     try {
                                         icon.setDocumentWidth("100%");
                                         icon.setDocumentHeight("100%");
                                     } catch (final SVGParseException e) { }
                                     Bitmap bitmap = Bitmap.createBitmap(v.getHeight(), v.getHeight(), Bitmap.Config.ARGB_8888);
                                     Canvas bmcanvas = new Canvas(bitmap);
                                     icon.renderToCanvas(bmcanvas);


@@ 2266,7 2274,14 @@ public class Conversation extends AbstractEntity implements Blockable, Comparabl

                        final SVG defaultIcon = defaultOption.getIcon();
                        if (defaultIcon != null) {
                             defaultIcon.setDocumentPreserveAspectRatio(com.caverock.androidsvg.PreserveAspectRatio.TOP);
                             synchronized (CommandSession.this) {
                                 waitingForRefresh = true;
                             }
                             defaultIcon.setDocumentPreserveAspectRatio(com.caverock.androidsvg.PreserveAspectRatio.LETTERBOX);
                             try {
                                 defaultIcon.setDocumentWidth("100%");
                                 defaultIcon.setDocumentHeight("100%");
                             } catch (final SVGParseException e) { }
                             DisplayMetrics display = mPager.getContext().getResources().getDisplayMetrics();
                             Bitmap bitmap = Bitmap.createBitmap((int)(display.heightPixels*display.density/4), (int)(display.heightPixels*display.density/4), Bitmap.Config.ARGB_8888);
                             bitmap.setDensity(display.densityDpi);

M src/main/java/eu/siacs/conversations/persistance/FileBackend.java => src/main/java/eu/siacs/conversations/persistance/FileBackend.java +1 -1
@@ 2168,7 2168,7 @@ public class FileBackend {
    public Drawable getSVG(File file, int size) {
        try {
            SVG svg = SVG.getFromInputStream(new FileInputStream(file));
            svg.setDocumentPreserveAspectRatio(com.caverock.androidsvg.PreserveAspectRatio.TOP);
            svg.setDocumentPreserveAspectRatio(com.caverock.androidsvg.PreserveAspectRatio.LETTERBOX);

            float w = svg.getDocumentWidth();
            float h = svg.getDocumentHeight();