Merge pull request #2496 from deltachat/adb/improve-qr-show

set background image for QrShowFragment
This commit is contained in:
Asiel Díaz Benítez 2023-03-14 13:44:06 -04:00 committed by GitHub
commit 33db24b41f
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 25 additions and 6 deletions

View file

@ -1,14 +1,21 @@
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent" android:layout_height="match_parent">
android:orientation="vertical">
<org.thoughtcrime.securesms.components.ScaleStableImageView
android:id="@+id/background"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:ignore="ContentDescription"
android:scaleType="centerCrop" />
<com.caverock.androidsvg.SVGImageView <com.caverock.androidsvg.SVGImageView
android:id="@+id/qrImage" android:id="@+id/qrImage"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="0dp" android:layout_height="match_parent"
android:layout_weight="1" android:layout_gravity="center"
android:contentDescription="@string/qrscan_title" /> android:contentDescription="@string/qrscan_title" />
</LinearLayout> </RelativeLayout>

View file

@ -4,6 +4,7 @@ import android.content.Context;
import android.content.Intent; import android.content.Intent;
import android.graphics.Bitmap; import android.graphics.Bitmap;
import android.graphics.Canvas; import android.graphics.Canvas;
import android.graphics.drawable.Drawable;
import android.net.Uri; import android.net.Uri;
import android.os.Bundle; import android.os.Bundle;
import android.util.Log; import android.util.Log;
@ -24,8 +25,10 @@ import com.caverock.androidsvg.SVG;
import com.caverock.androidsvg.SVGParseException; import com.caverock.androidsvg.SVGParseException;
import org.thoughtcrime.securesms.R; import org.thoughtcrime.securesms.R;
import org.thoughtcrime.securesms.components.ScaleStableImageView;
import org.thoughtcrime.securesms.connect.DcEventCenter; import org.thoughtcrime.securesms.connect.DcEventCenter;
import org.thoughtcrime.securesms.connect.DcHelper; import org.thoughtcrime.securesms.connect.DcHelper;
import org.thoughtcrime.securesms.util.DynamicTheme;
import org.thoughtcrime.securesms.util.FileProviderUtil; import org.thoughtcrime.securesms.util.FileProviderUtil;
import org.thoughtcrime.securesms.util.Util; import org.thoughtcrime.securesms.util.Util;
@ -72,6 +75,15 @@ public class QrShowFragment extends Fragment implements DcEventCenter.DcEventDel
numJoiners = 0; numJoiners = 0;
ScaleStableImageView backgroundView = view.findViewById(R.id.background);
Drawable drawable;
if(DynamicTheme.isDarkTheme(getActivity())) {
drawable = getActivity().getResources().getDrawable(R.drawable.background_hd_dark);
} else {
drawable = getActivity().getResources().getDrawable(R.drawable.background_hd);
}
backgroundView.setImageDrawable(drawable);
SVGImageView imageView = view.findViewById(R.id.qrImage); SVGImageView imageView = view.findViewById(R.id.qrImage);
try { try {
String svg_txt = dcContext.getSecurejoinQrSvg(chatId); String svg_txt = dcContext.getSecurejoinQrSvg(chatId);