Replace generic ErrorFragment with specific one

when key agreement protocol doesn't match
This commit is contained in:
Torsten Grote
2018-08-15 11:57:58 -03:00
parent 656ca8d67a
commit d9e9741112
3 changed files with 6 additions and 7 deletions

View File

@@ -2,7 +2,6 @@ package org.briarproject.briar.android.keyagreement;
import android.os.Bundle; import android.os.Bundle;
import android.support.annotation.Nullable; import android.support.annotation.Nullable;
import android.support.annotation.StringRes;
import android.view.LayoutInflater; import android.view.LayoutInflater;
import android.view.View; import android.view.View;
import android.view.ViewGroup; import android.view.ViewGroup;
@@ -29,10 +28,10 @@ public class ContactExchangeErrorFragment extends BaseFragment {
ContactExchangeErrorFragment.class.getName(); ContactExchangeErrorFragment.class.getName();
private static final String ERROR_MSG = "errorMessage"; private static final String ERROR_MSG = "errorMessage";
public static ContactExchangeErrorFragment newInstance(@StringRes int res) { public static ContactExchangeErrorFragment newInstance(String errorMsg) {
ContactExchangeErrorFragment f = new ContactExchangeErrorFragment(); ContactExchangeErrorFragment f = new ContactExchangeErrorFragment();
Bundle args = new Bundle(); Bundle args = new Bundle();
args.putInt(ERROR_MSG, res); args.putString(ERROR_MSG, errorMsg);
f.setArguments(args); f.setArguments(args);
return f; return f;
} }
@@ -60,7 +59,7 @@ public class ContactExchangeErrorFragment extends BaseFragment {
if (args == null) { if (args == null) {
throw new IllegalArgumentException("Use newInstance()"); throw new IllegalArgumentException("Use newInstance()");
} }
explanation.setText(args.getInt(ERROR_MSG)); explanation.setText(args.getString(ERROR_MSG));
// make feedback link clickable // make feedback link clickable
TextView sendFeedback = v.findViewById(R.id.sendFeedback); TextView sendFeedback = v.findViewById(R.id.sendFeedback);

View File

@@ -188,7 +188,8 @@ public abstract class KeyAgreementActivity extends BriarActivity implements
} }
protected void showErrorFragment(@StringRes int errorResId) { protected void showErrorFragment(@StringRes int errorResId) {
BaseFragment f = ContactExchangeErrorFragment.newInstance(errorResId); String errorMsg = getString(errorResId);
BaseFragment f = ContactExchangeErrorFragment.newInstance(errorMsg);
showNextFragment(f); showNextFragment(f);
} }

View File

@@ -36,7 +36,6 @@ import org.briarproject.bramble.api.nullsafety.ParametersNotNullByDefault;
import org.briarproject.briar.R; import org.briarproject.briar.R;
import org.briarproject.briar.android.activity.ActivityComponent; import org.briarproject.briar.android.activity.ActivityComponent;
import org.briarproject.briar.android.fragment.BaseEventFragment; import org.briarproject.briar.android.fragment.BaseEventFragment;
import org.briarproject.briar.android.fragment.ErrorFragment;
import org.briarproject.briar.android.view.QrCodeView; import org.briarproject.briar.android.view.QrCodeView;
import java.io.IOException; import java.io.IOException;
@@ -247,7 +246,7 @@ public class KeyAgreementFragment extends BaseEventFragment
reset(); reset();
String msg = getString(R.string.qr_code_unsupported, String msg = getString(R.string.qr_code_unsupported,
getString(R.string.app_name)); getString(R.string.app_name));
showNextFragment(ErrorFragment.newInstance(msg)); showNextFragment(ContactExchangeErrorFragment.newInstance(msg));
} catch (CameraException e) { } catch (CameraException e) {
logCameraExceptionAndFinish(e); logCameraExceptionAndFinish(e);
} catch (IOException | IllegalArgumentException e) { } catch (IOException | IllegalArgumentException e) {