Confirm opening links for web view

This commit is contained in:
M66B 2019-02-03 18:38:56 +00:00
parent 5ae209fc8d
commit 05c6ace389
1 changed files with 34 additions and 31 deletions

View File

@ -1290,7 +1290,7 @@ public class AdapterMessage extends RecyclerView.Adapter<AdapterMessage.ViewHold
webView.setWebViewClient(new WebViewClient() { webView.setWebViewClient(new WebViewClient() {
public boolean shouldOverrideUrlLoading(WebView view, String url) { public boolean shouldOverrideUrlLoading(WebView view, String url) {
Helper.view(context, owner, Uri.parse(url), true); onOpenLink(Uri.parse(url));
return true; return true;
} }
}); });
@ -1585,17 +1585,23 @@ public class AdapterMessage extends RecyclerView.Adapter<AdapterMessage.ViewHold
if (link.length != 0) { if (link.length != 0) {
String url = link[0].getURL(); String url = link[0].getURL();
Uri uri = Uri.parse(url); Uri uri = Uri.parse(url);
onOpenLink(uri);
}
return true;
}
}
private void onOpenLink(Uri uri) {
if (BuildConfig.APPLICATION_ID.equals(uri.getHost()) && "/activate/".equals(uri.getPath())) { if (BuildConfig.APPLICATION_ID.equals(uri.getHost()) && "/activate/".equals(uri.getPath())) {
LocalBroadcastManager lbm = LocalBroadcastManager.getInstance(context); LocalBroadcastManager lbm = LocalBroadcastManager.getInstance(context);
lbm.sendBroadcast( lbm.sendBroadcast(
new Intent(ActivityView.ACTION_ACTIVATE_PRO) new Intent(ActivityView.ACTION_ACTIVATE_PRO)
.putExtra("uri", uri)); .putExtra("uri", uri));
} else { } else {
View view = LayoutInflater.from(context).inflate(R.layout.dialog_link, null); View view = LayoutInflater.from(context).inflate(R.layout.dialog_link, null);
final EditText etLink = view.findViewById(R.id.etLink); final EditText etLink = view.findViewById(R.id.etLink);
etLink.setText(url); etLink.setText(uri.toString());
new DialogBuilderLifecycle(context, owner) new DialogBuilderLifecycle(context, owner)
.setView(view) .setView(view)
.setPositiveButton(R.string.title_yes, new DialogInterface.OnClickListener() { .setPositiveButton(R.string.title_yes, new DialogInterface.OnClickListener() {
@ -1615,10 +1621,7 @@ public class AdapterMessage extends RecyclerView.Adapter<AdapterMessage.ViewHold
.setNegativeButton(R.string.title_no, null) .setNegativeButton(R.string.title_no, null)
.show(); .show();
} }
}
return true;
}
} }
private class ActionData { private class ActionData {