Don't create a stack of QR code fragments.

This commit is contained in:
akwizgran
2018-03-20 11:43:44 +00:00
parent fcabf697d6
commit 3361922834
2 changed files with 11 additions and 6 deletions

View File

@@ -9,6 +9,7 @@ import android.content.IntentFilter;
import android.os.Bundle; import android.os.Bundle;
import android.support.annotation.UiThread; import android.support.annotation.UiThread;
import android.support.v4.app.ActivityCompat; import android.support.v4.app.ActivityCompat;
import android.support.v4.app.FragmentManager;
import android.support.v4.content.ContextCompat; import android.support.v4.content.ContextCompat;
import android.support.v7.app.AlertDialog.Builder; import android.support.v7.app.AlertDialog.Builder;
import android.support.v7.widget.Toolbar; import android.support.v7.widget.Toolbar;
@@ -206,12 +207,15 @@ public class KeyAgreementActivity extends BriarActivity implements
private void showQrCodeFragment() { private void showQrCodeFragment() {
// FIXME #824 // FIXME #824
FragmentManager fm = getSupportFragmentManager();
if (fm.findFragmentByTag(ShowQrCodeFragment.TAG) == null) {
BaseFragment f = ShowQrCodeFragment.newInstance(); BaseFragment f = ShowQrCodeFragment.newInstance();
getSupportFragmentManager().beginTransaction() fm.beginTransaction()
.replace(R.id.fragmentContainer, f, f.getUniqueTag()) .replace(R.id.fragmentContainer, f, f.getUniqueTag())
.addToBackStack(f.getUniqueTag()) .addToBackStack(f.getUniqueTag())
.commit(); .commit();
} }
}
private boolean checkPermissions() { private boolean checkPermissions() {
if (ContextCompat.checkSelfPermission(this, CAMERA) != if (ContextCompat.checkSelfPermission(this, CAMERA) !=

View File

@@ -61,7 +61,8 @@ import static java.util.logging.Level.WARNING;
public class ShowQrCodeFragment extends BaseEventFragment public class ShowQrCodeFragment extends BaseEventFragment
implements QrCodeDecoder.ResultCallback { implements QrCodeDecoder.ResultCallback {
private static final String TAG = ShowQrCodeFragment.class.getName(); static final String TAG = ShowQrCodeFragment.class.getName();
private static final Logger LOG = Logger.getLogger(TAG); private static final Logger LOG = Logger.getLogger(TAG);
private static final Charset ISO_8859_1 = Charset.forName("ISO-8859-1"); private static final Charset ISO_8859_1 = Charset.forName("ISO-8859-1");