mirror of
https://code.briarproject.org/briar/briar.git
synced 2026-02-17 13:19:52 +01:00
Handle returned Uri being null
This commit is contained in:
@@ -48,9 +48,10 @@ public class HotspotHelpFragment extends Fragment {
|
|||||||
|
|
||||||
private HotspotViewModel viewModel;
|
private HotspotViewModel viewModel;
|
||||||
private final ActivityResultLauncher<String> launcher =
|
private final ActivityResultLauncher<String> launcher =
|
||||||
registerForActivityResult(new CreateDocument(), uri ->
|
registerForActivityResult(new CreateDocument(), uri -> {
|
||||||
viewModel.exportApk(uri)
|
showButton();
|
||||||
);
|
if (uri != null) viewModel.exportApk(uri);
|
||||||
|
});
|
||||||
private Button button;
|
private Button button;
|
||||||
private ProgressBar progressBar;
|
private ProgressBar progressBar;
|
||||||
|
|
||||||
@@ -77,7 +78,7 @@ public class HotspotHelpFragment extends Fragment {
|
|||||||
button = v.findViewById(R.id.fallbackButton);
|
button = v.findViewById(R.id.fallbackButton);
|
||||||
progressBar = v.findViewById(R.id.progressBar);
|
progressBar = v.findViewById(R.id.progressBar);
|
||||||
button.setOnClickListener(view -> {
|
button.setOnClickListener(view -> {
|
||||||
beginDelayedTransition((ViewGroup) requireView());
|
beginDelayedTransition((ViewGroup) v);
|
||||||
button.setVisibility(INVISIBLE);
|
button.setVisibility(INVISIBLE);
|
||||||
progressBar.setVisibility(VISIBLE);
|
progressBar.setVisibility(VISIBLE);
|
||||||
|
|
||||||
@@ -88,13 +89,9 @@ public class HotspotHelpFragment extends Fragment {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void shareUri(Uri uri) {
|
private void shareUri(Uri uri) {
|
||||||
beginDelayedTransition((ViewGroup) requireView());
|
|
||||||
button.setVisibility(VISIBLE);
|
|
||||||
progressBar.setVisibility(INVISIBLE);
|
|
||||||
|
|
||||||
Intent i = new Intent(ACTION_SEND);
|
Intent i = new Intent(ACTION_SEND);
|
||||||
i.putExtra(EXTRA_STREAM, uri);
|
i.putExtra(EXTRA_STREAM, uri);
|
||||||
i.setType("application/zip");
|
i.setType("*/*"); // gives us all sharing options
|
||||||
i.addFlags(FLAG_GRANT_READ_URI_PERMISSION);
|
i.addFlags(FLAG_GRANT_READ_URI_PERMISSION);
|
||||||
Context ctx = requireContext();
|
Context ctx = requireContext();
|
||||||
if (SDK_INT <= 19) {
|
if (SDK_INT <= 19) {
|
||||||
@@ -111,4 +108,10 @@ public class HotspotHelpFragment extends Fragment {
|
|||||||
startActivity(Intent.createChooser(i, null));
|
startActivity(Intent.createChooser(i, null));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void showButton() {
|
||||||
|
beginDelayedTransition((ViewGroup) requireView());
|
||||||
|
button.setVisibility(VISIBLE);
|
||||||
|
progressBar.setVisibility(INVISIBLE);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user