mirror of
https://github.com/ArcaneChat/android.git
synced 2026-07-03 14:05:24 +02:00
Merge pull request #3535 from deltachat/adb/issue-3534
fix IntentUtils.showBrowserIntent() and use it everywhere
This commit is contained in:
@@ -54,6 +54,7 @@ import org.thoughtcrime.securesms.profiles.ProfileMediaConstraints;
|
||||
import org.thoughtcrime.securesms.proxy.ProxySettingsActivity;
|
||||
import org.thoughtcrime.securesms.qr.RegistrationQrActivity;
|
||||
import org.thoughtcrime.securesms.scribbles.ScribbleActivity;
|
||||
import org.thoughtcrime.securesms.util.IntentUtils;
|
||||
import org.thoughtcrime.securesms.util.Prefs;
|
||||
import org.thoughtcrime.securesms.util.Util;
|
||||
import org.thoughtcrime.securesms.util.views.ProgressDialog;
|
||||
@@ -331,7 +332,7 @@ public class InstantOnboardingActivity extends BaseActionBarActivity implements
|
||||
|
||||
privacyPolicyBtn.setOnClickListener(view -> {
|
||||
if (!isDcLogin) {
|
||||
WebViewActivity.openUrlInBrowser(this, "https://" + providerHost + "/privacy.html");
|
||||
IntentUtils.showInBrowser(this, "https://" + providerHost + "/privacy.html");
|
||||
}
|
||||
});
|
||||
|
||||
@@ -350,7 +351,7 @@ public class InstantOnboardingActivity extends BaseActionBarActivity implements
|
||||
.create();
|
||||
|
||||
view.findViewById(R.id.use_other_server).setOnClickListener((v) -> {
|
||||
WebViewActivity.openUrlInBrowser(this, INSTANCES_URL);
|
||||
IntentUtils.showInBrowser(this, INSTANCES_URL);
|
||||
signUpDialog.dismiss();
|
||||
});
|
||||
view.findViewById(R.id.login_button).setOnClickListener((v) -> {
|
||||
|
||||
@@ -16,7 +16,6 @@ import static org.thoughtcrime.securesms.connect.DcHelper.CONFIG_PROXY_ENABLED;
|
||||
import static org.thoughtcrime.securesms.connect.DcHelper.getContext;
|
||||
import static org.thoughtcrime.securesms.service.IPCAddAccountsService.ACCOUNT_DATA;
|
||||
|
||||
import android.content.ActivityNotFoundException;
|
||||
import android.content.DialogInterface;
|
||||
import android.content.Intent;
|
||||
import android.content.res.Resources;
|
||||
@@ -438,7 +437,7 @@ public class RegistrationActivity extends BaseActionBarActivity implements DcEve
|
||||
.setPositiveButton(R.string.perm_continue, (dialog, which)-> {
|
||||
// pass control to browser, we'll be back in business at (**)
|
||||
activity.oauth2Requested = System.currentTimeMillis();
|
||||
IntentUtils.showBrowserIntent(activity, oauth2url);
|
||||
IntentUtils.showInBrowser(activity, oauth2url);
|
||||
oauth2started.set(true);
|
||||
})
|
||||
.setCancelable(false)
|
||||
@@ -493,11 +492,7 @@ public class RegistrationActivity extends BaseActionBarActivity implements DcEve
|
||||
if (provider!=null) {
|
||||
String url = provider.getOverviewPage();
|
||||
if(!url.isEmpty()) {
|
||||
try {
|
||||
startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse(url)));
|
||||
} catch (ActivityNotFoundException e) {
|
||||
Toast.makeText(this, R.string.no_browser_installed, Toast.LENGTH_LONG).show();
|
||||
}
|
||||
IntentUtils.showInBrowser(this, url);
|
||||
} else {
|
||||
// this should normally not happen
|
||||
Toast.makeText(this, "ErrProviderWithoutUrl", Toast.LENGTH_LONG).show();
|
||||
|
||||
@@ -26,6 +26,7 @@ import androidx.webkit.ProxyController;
|
||||
import androidx.webkit.ProxyConfig;
|
||||
|
||||
import org.thoughtcrime.securesms.util.DynamicTheme;
|
||||
import org.thoughtcrime.securesms.util.IntentUtils;
|
||||
|
||||
public class WebViewActivity extends PassphraseRequiredActionBarActivity
|
||||
implements SearchView.OnQueryTextListener,
|
||||
@@ -278,16 +279,8 @@ public class WebViewActivity extends PassphraseRequiredActionBarActivity
|
||||
// onBackPressed() can be overwritten by derived classes as needed.
|
||||
// the default behavior (close the activity) is just fine eg. for Webxdc, Connectivity, HTML-mails
|
||||
|
||||
public static void openUrlInBrowser(Context context, String url) {
|
||||
try {
|
||||
context.startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse(url)));
|
||||
} catch (ActivityNotFoundException e) {
|
||||
Toast.makeText(context, R.string.no_browser_installed, Toast.LENGTH_LONG).show();
|
||||
}
|
||||
}
|
||||
|
||||
protected boolean openOnlineUrl(String url) {
|
||||
openUrlInBrowser(this, url);
|
||||
IntentUtils.showInBrowser(this, url);
|
||||
// returning `true` causes the WebView to abort loading
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -8,7 +8,6 @@ import android.graphics.Bitmap;
|
||||
import android.graphics.drawable.BitmapDrawable;
|
||||
import android.graphics.drawable.Drawable;
|
||||
import android.net.Uri;
|
||||
import android.os.Build;
|
||||
import android.os.Bundle;
|
||||
import android.text.TextUtils;
|
||||
import android.util.Base64;
|
||||
@@ -45,6 +44,7 @@ import org.json.JSONObject;
|
||||
import org.thoughtcrime.securesms.connect.AccountManager;
|
||||
import org.thoughtcrime.securesms.connect.DcEventCenter;
|
||||
import org.thoughtcrime.securesms.connect.DcHelper;
|
||||
import org.thoughtcrime.securesms.util.IntentUtils;
|
||||
import org.thoughtcrime.securesms.util.JsonUtils;
|
||||
import org.thoughtcrime.securesms.util.MediaUtil;
|
||||
import org.thoughtcrime.securesms.util.Prefs;
|
||||
@@ -290,7 +290,7 @@ public class WebxdcActivity extends WebViewActivity implements DcEventCenter.DcE
|
||||
addToHomeScreen(this, dcAppMsg.getId());
|
||||
return true;
|
||||
case R.id.source_code:
|
||||
openUrlInBrowser(this, sourceCodeUrl);
|
||||
IntentUtils.showInBrowser(this, sourceCodeUrl);
|
||||
return true;
|
||||
case R.id.show_in_chat:
|
||||
showInChat();
|
||||
|
||||
@@ -23,6 +23,7 @@ import com.b44t.messenger.rpc.RpcException;
|
||||
|
||||
import org.thoughtcrime.securesms.connect.DcHelper;
|
||||
import org.thoughtcrime.securesms.providers.PersistentBlobProvider;
|
||||
import org.thoughtcrime.securesms.util.IntentUtils;
|
||||
import org.thoughtcrime.securesms.util.MediaUtil;
|
||||
import org.thoughtcrime.securesms.util.Prefs;
|
||||
import org.thoughtcrime.securesms.util.Util;
|
||||
@@ -68,7 +69,7 @@ public class WebxdcStoreActivity extends PassphraseRequiredActionBarActivity {
|
||||
}
|
||||
});
|
||||
} else {
|
||||
WebViewActivity.openUrlInBrowser(WebxdcStoreActivity.this, url);
|
||||
IntentUtils.showInBrowser(WebxdcStoreActivity.this, url);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -99,7 +99,7 @@ public class QrCodeHandler {
|
||||
showDoneToast(activity);
|
||||
});
|
||||
if (rawString.toLowerCase().startsWith("http")) {
|
||||
builder.setNeutralButton(R.string.open, (d, b) -> IntentUtils.showBrowserIntent(activity, rawString));
|
||||
builder.setNeutralButton(R.string.open, (d, b) -> IntentUtils.showInBrowser(activity, rawString));
|
||||
}
|
||||
builder.setNegativeButton(R.string.cancel, null);
|
||||
builder.setCancelable(false);
|
||||
@@ -182,7 +182,7 @@ public class QrCodeHandler {
|
||||
final String url = qrParsed.getText1();
|
||||
String msg = String.format(activity.getString(R.string.qrscan_contains_url), url);
|
||||
builder.setMessage(msg);
|
||||
builder.setPositiveButton(R.string.open, (dialog, which) -> IntentUtils.showBrowserIntent(activity, url));
|
||||
builder.setPositiveButton(R.string.open, (dialog, which) -> IntentUtils.showInBrowser(activity, url));
|
||||
builder.setNegativeButton(android.R.string.cancel, null);
|
||||
builder.setNeutralButton(R.string.menu_copy_to_clipboard, (dialog, which) -> {
|
||||
Util.writeTextToClipboard(activity, url);
|
||||
|
||||
@@ -2,14 +2,18 @@ package org.thoughtcrime.securesms.util;
|
||||
|
||||
|
||||
import android.app.PendingIntent;
|
||||
import android.content.ActivityNotFoundException;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.content.pm.ResolveInfo;
|
||||
import android.net.Uri;
|
||||
import android.os.Build;
|
||||
import android.widget.Toast;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
|
||||
import org.thoughtcrime.securesms.R;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class IntentUtils {
|
||||
@@ -19,9 +23,13 @@ public class IntentUtils {
|
||||
return resolveInfoList != null && resolveInfoList.size() > 1;
|
||||
}
|
||||
|
||||
public static void showBrowserIntent(Context context, String url) {
|
||||
public static void showInBrowser(Context context, String url) {
|
||||
Intent browserIntent = new Intent(Intent.ACTION_VIEW, Uri.parse(url));
|
||||
context.startActivity(browserIntent);
|
||||
try {
|
||||
context.startActivity(browserIntent);
|
||||
} catch (ActivityNotFoundException e) {
|
||||
Toast.makeText(context, R.string.no_browser_installed, Toast.LENGTH_LONG).show();
|
||||
}
|
||||
}
|
||||
|
||||
public static int FLAG_MUTABLE() {
|
||||
|
||||
@@ -87,7 +87,7 @@ public class LongClickCopySpan extends ClickableSpan {
|
||||
QrCodeHandler qrCodeHandler = new QrCodeHandler(activity);
|
||||
qrCodeHandler.handleQrData(url);
|
||||
} else {
|
||||
IntentUtils.showBrowserIntent(widget.getContext(), url);
|
||||
IntentUtils.showInBrowser(widget.getContext(), url);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -35,7 +35,7 @@ public class VideochatUtil {
|
||||
DcContext dcContext = DcHelper.getContext(activity);
|
||||
DcMsg dcMsg = dcContext.getMsg(msgId);
|
||||
String videochatUrl = dcMsg.getVideochatUrl();
|
||||
IntentUtils.showBrowserIntent(activity, videochatUrl);
|
||||
IntentUtils.showInBrowser(activity, videochatUrl);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user