-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #3963 from gustamor/bugfix/3756
Fix issue ActivityNotFoundException on Utils#openURL
- Loading branch information
Showing
9 changed files
with
43 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -23,8 +23,12 @@ | |
import java.io.File; | ||
import java.lang.reflect.Field; | ||
import java.util.Collection; | ||
import java.util.List; | ||
import java.util.concurrent.TimeUnit; | ||
|
||
import org.slf4j.Logger; | ||
import org.slf4j.LoggerFactory; | ||
|
||
import com.amaze.filemanager.BuildConfig; | ||
import com.amaze.filemanager.R; | ||
import com.amaze.filemanager.adapters.data.LayoutElementParcelable; | ||
|
@@ -39,13 +43,16 @@ | |
import android.content.Context; | ||
import android.content.Intent; | ||
import android.content.pm.ActivityInfo; | ||
import android.content.pm.PackageManager; | ||
import android.content.pm.ResolveInfo; | ||
import android.content.res.ColorStateList; | ||
import android.content.res.Configuration; | ||
import android.graphics.Color; | ||
import android.graphics.PointF; | ||
import android.graphics.drawable.Drawable; | ||
import android.net.Uri; | ||
import android.os.Build; | ||
import android.os.Handler; | ||
import android.os.storage.StorageVolume; | ||
import android.text.format.DateUtils; | ||
import android.util.DisplayMetrics; | ||
|
@@ -89,6 +96,9 @@ public class Utils { | |
public static final String EMAIL_NOREPLY_REPORTS = "[email protected]"; | ||
public static final String EMAIL_SUPPORT = "[email protected]"; | ||
|
||
private static final Logger log = LoggerFactory.getLogger(Utils.class); | ||
private static boolean isToastShowing = false; | ||
|
||
// methods for fastscroller | ||
public static float clamp(float min, float max, float value) { | ||
float minimum = Math.max(min, value); | ||
|
@@ -378,7 +388,22 @@ public static Snackbar showCutCopySnackBar( | |
public static void openURL(String url, Context context) { | ||
Intent intent = new Intent(Intent.ACTION_VIEW); | ||
intent.setData(Uri.parse(url)); | ||
context.startActivity(intent); | ||
|
||
PackageManager packageManager = context.getPackageManager(); | ||
List<ResolveInfo> webViews = | ||
packageManager.queryIntentActivities(intent, PackageManager.MATCH_DEFAULT_ONLY); | ||
|
||
if (!webViews.isEmpty()) { | ||
context.startActivity(intent); | ||
} else { | ||
log.warn("A browser is not available"); | ||
if (!isToastShowing) { | ||
isToastShowing = true; | ||
Toast.makeText(context, R.string.not_found_enabled_webview, Toast.LENGTH_SHORT).show(); | ||
// Prevents a myriad of duplicates | ||
new Handler().postDelayed(() -> isToastShowing = false, 2200); | ||
} | ||
} | ||
} | ||
|
||
/** Open telegram in browser */ | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters