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 { | ||||
| 
 | ||||
|     private String errorMessage; | ||||
|     private boolean isValidRepo; | ||||
|     private boolean isValidRepo = false; | ||||
| 
 | ||||
|     private String uriString; | ||||
|     private Uri uri; | ||||
| @ -26,7 +26,7 @@ public class NewRepoConfig { | ||||
|     private boolean fromSwap; | ||||
| 
 | ||||
|     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) { | ||||
|  | ||||
| @ -69,11 +69,13 @@ public class WifiQrFragment extends Fragment { | ||||
|     public void onActivityResult(int requestCode, int resultCode, Intent intent) { | ||||
|         IntentResult scanResult = IntentIntegrator.parseActivityResult(requestCode, resultCode, intent); | ||||
|         if (scanResult != null) { | ||||
|             NewRepoConfig repoConfig = new NewRepoConfig(getActivity(), scanResult.getContents()); | ||||
|             if (repoConfig.isValidRepo()) { | ||||
|                 startActivityForResult(new Intent(FDroid.ACTION_ADD_REPO, Uri.parse(scanResult.getContents()), getActivity(), ConnectSwapActivity.class), CONNECT_TO_SWAP); | ||||
|             } else { | ||||
|                 Toast.makeText(getActivity(), "The QR code you scanned doesn't look like a swap code.", Toast.LENGTH_SHORT).show(); | ||||
|             if (scanResult.getContents() != null) { | ||||
|                 NewRepoConfig repoConfig = new NewRepoConfig(getActivity(), scanResult.getContents()); | ||||
|                 if (repoConfig.isValidRepo()) { | ||||
|                     startActivityForResult(new Intent(FDroid.ACTION_ADD_REPO, Uri.parse(scanResult.getContents()), getActivity(), ConnectSwapActivity.class), CONNECT_TO_SWAP); | ||||
|                 } 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) { | ||||
|             getActivity().finish(); | ||||
|  | ||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user
	 Peter Serwylo
						Peter Serwylo