Handle barcode scanner when user selects "back".
Previously, it would receive a valid response, but the resulting content of the scan was null.
This commit is contained in:
parent
4857ed2d45
commit
b0586384f8
@ -13,7 +13,7 @@ import java.util.Locale;
|
|||||||
public class NewRepoConfig {
|
public class NewRepoConfig {
|
||||||
|
|
||||||
private String errorMessage;
|
private String errorMessage;
|
||||||
private boolean isValidRepo;
|
private boolean isValidRepo = false;
|
||||||
|
|
||||||
private String uriString;
|
private String uriString;
|
||||||
private Uri uri;
|
private Uri uri;
|
||||||
@ -26,7 +26,7 @@ public class NewRepoConfig {
|
|||||||
private boolean fromSwap;
|
private boolean fromSwap;
|
||||||
|
|
||||||
public NewRepoConfig(Context context, String uri) {
|
public NewRepoConfig(Context context, String uri) {
|
||||||
init(context, Uri.parse(uri));
|
init(context, uri != null ? Uri.parse(uri) : null);
|
||||||
}
|
}
|
||||||
|
|
||||||
public NewRepoConfig(Context context, Intent intent) {
|
public NewRepoConfig(Context context, Intent intent) {
|
||||||
|
@ -69,11 +69,13 @@ public class WifiQrFragment extends Fragment {
|
|||||||
public void onActivityResult(int requestCode, int resultCode, Intent intent) {
|
public void onActivityResult(int requestCode, int resultCode, Intent intent) {
|
||||||
IntentResult scanResult = IntentIntegrator.parseActivityResult(requestCode, resultCode, intent);
|
IntentResult scanResult = IntentIntegrator.parseActivityResult(requestCode, resultCode, intent);
|
||||||
if (scanResult != null) {
|
if (scanResult != null) {
|
||||||
NewRepoConfig repoConfig = new NewRepoConfig(getActivity(), scanResult.getContents());
|
if (scanResult.getContents() != null) {
|
||||||
if (repoConfig.isValidRepo()) {
|
NewRepoConfig repoConfig = new NewRepoConfig(getActivity(), scanResult.getContents());
|
||||||
startActivityForResult(new Intent(FDroid.ACTION_ADD_REPO, Uri.parse(scanResult.getContents()), getActivity(), ConnectSwapActivity.class), CONNECT_TO_SWAP);
|
if (repoConfig.isValidRepo()) {
|
||||||
} else {
|
startActivityForResult(new Intent(FDroid.ACTION_ADD_REPO, Uri.parse(scanResult.getContents()), getActivity(), ConnectSwapActivity.class), CONNECT_TO_SWAP);
|
||||||
Toast.makeText(getActivity(), "The QR code you scanned doesn't look like a swap code.", Toast.LENGTH_SHORT).show();
|
} else {
|
||||||
|
Toast.makeText(getActivity(), "The QR code you scanned doesn't look like a swap code.", Toast.LENGTH_SHORT).show();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
} else if (requestCode == CONNECT_TO_SWAP && resultCode == Activity.RESULT_OK) {
|
} else if (requestCode == CONNECT_TO_SWAP && resultCode == Activity.RESULT_OK) {
|
||||||
getActivity().finish();
|
getActivity().finish();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user