Skip to content

Commit

Permalink
Merge pull request #225 from jokakilla/master
Browse files Browse the repository at this point in the history
[feat] Allow opening deeplinks with custom schema
  • Loading branch information
coderPaddyS authored Jul 8, 2024
2 parents f443d04 + 8355304 commit 7865cd9
Showing 1 changed file with 8 additions and 16 deletions.
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

0 comments on commit 7865cd9

Please sign in to comment.