Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow opening deeplinks with custom schema #225

Merged
merged 2 commits into from
Jul 8, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
import java.util.regex.Pattern;

public class URLResultFragment extends ResultFragment {
private static final String VALID_RFC3986_PROTOCOL_SCHEME = "^[a-zA-Z][a-zA-Z0-9+.-]*:.*$";

URIParsedResult result;

Expand Down Expand Up @@ -95,23 +96,14 @@ public void onProceedPressed(Context context) {
if (!checked) {
Toast.makeText(context, R.string.conform_url, Toast.LENGTH_LONG).show();
} else {
String caption;
String qrurl3;
final String lowercase_qrurl = qrurl.toLowerCase();
if (!lowercase_qrurl.startsWith("http://") && !lowercase_qrurl.startsWith("https://")) {
qrurl3 = "http://" + qrurl;

Intent url = new Intent(Intent.ACTION_VIEW);/// !!!!
url.setData(Uri.parse(qrurl3));
caption = getResources().getStringArray(R.array.url_array)[0];
startActivity(Intent.createChooser(url, caption));
} else {
Intent url = new Intent(Intent.ACTION_VIEW);/// !!!!
url.setData(Uri.parse(qrurl).normalizeScheme());
caption = getResources().getStringArray(R.array.url_array)[0];
startActivity(Intent.createChooser(url, caption));

String urlForIntentData = qrurl;
if (!qrurl.matches(VALID_RFC3986_PROTOCOL_SCHEME)) {
urlForIntentData = "http://" + qrurl;
}
Intent url = new Intent(Intent.ACTION_VIEW);/// !!!!
url.setData(Uri.parse(urlForIntentData).normalizeScheme());
String caption = getResources().getStringArray(R.array.url_array)[0];
startActivity(Intent.createChooser(url, caption));
}
}

Expand Down