Fix IAE crash in link device transition.

fork-5.53.8
Cody Henthorne 2022-05-27 09:51:20 -04:00
rodzic 60b6a9ff3f
commit d69d1c8967
4 zmienionych plików z 20 dodań i 7 usunięć

Wyświetl plik

@ -14,12 +14,16 @@ import android.widget.ImageView;
import android.widget.LinearLayout;
import androidx.annotation.NonNull;
import androidx.core.view.ViewCompat;
import org.signal.qr.QrScannerView;
import org.signal.qr.kitkat.ScanListener;
import org.thoughtcrime.securesms.util.LifecycleDisposable;
import org.thoughtcrime.securesms.util.ViewUtil;
import io.reactivex.rxjava3.android.schedulers.AndroidSchedulers;
import io.reactivex.rxjava3.disposables.Disposable;
public class DeviceAddFragment extends LoggingFragment {
private final LifecycleDisposable lifecycleDisposable = new LifecycleDisposable();
@ -34,6 +38,7 @@ public class DeviceAddFragment extends LoggingFragment {
this.overlay = container.findViewById(R.id.overlay);
QrScannerView scannerView = container.findViewById(R.id.scanner);
this.devicesImage = container.findViewById(R.id.devices);
ViewCompat.setTransitionName(devicesImage, "devices");
if (getResources().getConfiguration().orientation == Configuration.ORIENTATION_LANDSCAPE) {
this.overlay.setOrientation(LinearLayout.HORIZONTAL);
@ -61,11 +66,18 @@ public class DeviceAddFragment extends LoggingFragment {
scannerView.start(getViewLifecycleOwner());
lifecycleDisposable.bindTo(getViewLifecycleOwner());
lifecycleDisposable.add(scannerView.getQrData().subscribe(qrData -> {
if (scanListener != null) {
scanListener.onQrDataFound(qrData);
}
}));
Disposable qrDisposable = scannerView
.getQrData()
.distinctUntilChanged()
.observeOn(AndroidSchedulers.mainThread())
.subscribe(qrData -> {
if (scanListener != null) {
scanListener.onQrDataFound(qrData);
}
});
lifecycleDisposable.add(qrDisposable);
return container;
}

Wyświetl plik

@ -9,6 +9,7 @@ import android.view.ViewGroup;
import android.widget.LinearLayout;
import androidx.annotation.NonNull;
import androidx.core.view.ViewCompat;
import androidx.fragment.app.Fragment;
public class DeviceLinkFragment extends Fragment implements View.OnClickListener {
@ -21,6 +22,7 @@ public class DeviceLinkFragment extends Fragment implements View.OnClickListener
public View onCreateView(@NonNull LayoutInflater inflater, ViewGroup viewGroup, Bundle bundle) {
this.container = (LinearLayout) inflater.inflate(R.layout.device_link_fragment, container, false);
this.container.findViewById(R.id.link_device).setOnClickListener(this);
ViewCompat.setTransitionName(container.findViewById(R.id.devices), "devices");
if (getResources().getConfiguration().orientation == Configuration.ORIENTATION_LANDSCAPE) {
container.setOrientation(LinearLayout.HORIZONTAL);

Wyświetl plik

@ -22,7 +22,6 @@
android:layout_height="match_parent"
android:layout_weight="1" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
@ -48,7 +47,6 @@
android:text="@string/device_add_fragment__scan_the_qr_code_displayed_on_the_device_to_link"
android:textColor="?android:textColorSecondary" />
</LinearLayout>
</LinearLayout>

Wyświetl plik

@ -6,6 +6,7 @@
android:gravity="center">
<androidx.appcompat.widget.AppCompatImageView
android:id="@+id/devices"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/ic_devices_white"