Skip to content
This repository has been archived by the owner on Jun 1, 2024. It is now read-only.

Commit

Permalink
Merge pull request #2837 from PiwwowPants/bugfix/fix-crash-on-open-ex…
Browse files Browse the repository at this point in the history
…ternally

Set FLAG_ACTIVITY_NEW_TASK on external link intents
  • Loading branch information
ccrama authored Aug 14, 2018
2 parents 3837ca4 + 79f504e commit ed9abf6
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 49 deletions.
40 changes: 9 additions & 31 deletions app/src/main/java/me/ccrama/redditslide/Activities/Website.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,43 +4,23 @@
import android.net.Uri;
import android.os.Bundle;
import android.support.v7.widget.Toolbar;
import android.view.Menu;
import android.view.MenuInflater;
import android.view.MenuItem;
import android.view.View;
import android.view.ViewGroup;
import android.view.WindowManager;
import android.webkit.CookieManager;
import android.webkit.CookieSyncManager;
import android.webkit.DownloadListener;
import android.webkit.ValueCallback;
import android.webkit.WebChromeClient;
import android.webkit.WebResourceResponse;
import android.webkit.WebSettings;
import android.webkit.WebView;
import android.webkit.WebViewClient;
import android.view.*;
import android.webkit.*;
import android.widget.FrameLayout;
import android.widget.ProgressBar;
import me.ccrama.redditslide.*;
import me.ccrama.redditslide.Fragments.SubmissionsView;
import me.ccrama.redditslide.Visuals.Palette;
import me.ccrama.redditslide.util.AdBlocker;
import me.ccrama.redditslide.util.LinkUtil;
import me.ccrama.redditslide.util.LogUtil;

import java.net.URI;
import java.net.URISyntaxException;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Map;

import me.ccrama.redditslide.ColorPreferences;
import me.ccrama.redditslide.ContentType;
import me.ccrama.redditslide.Fragments.SubmissionsView;
import me.ccrama.redditslide.OpenRedditLink;
import me.ccrama.redditslide.PostMatch;
import me.ccrama.redditslide.R;
import me.ccrama.redditslide.Reddit;
import me.ccrama.redditslide.SettingValues;
import me.ccrama.redditslide.Visuals.Palette;
import me.ccrama.redditslide.util.AdBlocker;
import me.ccrama.redditslide.util.LinkUtil;
import me.ccrama.redditslide.util.LogUtil;

public class Website extends BaseActivityAnim {

WebView v;
Expand Down Expand Up @@ -144,9 +124,7 @@ public void onReceiveValue(String html) {
});
return true;
case R.id.chrome:
Intent browserIntent = new Intent(Intent.ACTION_VIEW, Uri.parse(v.getUrl()));
LinkUtil.overridePackage(browserIntent);
startActivity(Intent.createChooser(browserIntent, getDomainName(v.getUrl())));
LinkUtil.openExternally(v.getUrl());
return true;
case R.id.share:
Reddit.defaultShareText(v.getTitle(), v.getUrl(), Website.this);
Expand Down
26 changes: 8 additions & 18 deletions app/src/main/java/me/ccrama/redditslide/util/LinkUtil.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,7 @@

import android.app.Activity;
import android.app.PendingIntent;
import android.content.ActivityNotFoundException;
import android.content.ClipData;
import android.content.ClipboardManager;
import android.content.Context;
import android.content.Intent;
import android.content.*;
import android.content.pm.PackageManager;
import android.graphics.Bitmap;
import android.graphics.Canvas;
Expand All @@ -17,23 +13,11 @@
import android.os.Bundle;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import android.support.customtabs.CustomTabsCallback;
import android.support.customtabs.CustomTabsClient;
import android.support.customtabs.CustomTabsIntent;
import android.support.customtabs.CustomTabsServiceConnection;
import android.support.customtabs.CustomTabsSession;
import android.support.customtabs.*;
import android.support.v4.content.ContextCompat;
import android.text.Html;
import android.util.Log;
import android.widget.Toast;

import net.dean.jraw.models.Submission;

import org.apache.commons.text.StringEscapeUtils;

import java.io.UnsupportedEncodingException;
import java.net.URLDecoder;

import me.ccrama.redditslide.Activities.Crosspost;
import me.ccrama.redditslide.Activities.MakeExternal;
import me.ccrama.redditslide.Activities.ReaderMode;
Expand All @@ -42,6 +26,11 @@
import me.ccrama.redditslide.Reddit;
import me.ccrama.redditslide.SettingValues;
import me.ccrama.redditslide.SubmissionViews.PopulateSubmissionViewHolder;
import net.dean.jraw.models.Submission;
import org.apache.commons.text.StringEscapeUtils;

import java.io.UnsupportedEncodingException;
import java.net.URLDecoder;

import static me.ccrama.redditslide.Fragments.SettingsHandlingFragment.LinkHandlingMode;

Expand Down Expand Up @@ -216,6 +205,7 @@ public static void openExternally(String url) {
Uri uri = formatURL(url);

final Intent intent = new Intent(Intent.ACTION_VIEW, uri);
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
overridePackage(intent);
Reddit.getAppContext().startActivity(intent);
}
Expand Down

0 comments on commit ed9abf6

Please sign in to comment.