Fixed new bug where browser wouldn't close on new intent. Fixed potential vuln in downloading code. Formatted some code.
This commit is contained in:
parent
7bba86d963
commit
e707e338ef
@ -992,6 +992,7 @@ public abstract class BrowserActivity extends ThemableBrowserActivity implements
|
||||
mPreferences.setSavedUrl(tabToDelete.getUrl());
|
||||
}
|
||||
final boolean isShown = tabToDelete.isShown();
|
||||
boolean shouldClose = mIsNewIntent && isShown;
|
||||
if (isShown) {
|
||||
mBrowserFrame.setBackgroundColor(mBackgroundColor);
|
||||
}
|
||||
@ -1031,7 +1032,7 @@ public abstract class BrowserActivity extends ThemableBrowserActivity implements
|
||||
}
|
||||
mEventBus.post(new BrowserEvents.TabsChanged());
|
||||
|
||||
if (mIsNewIntent && isShown) {
|
||||
if (shouldClose) {
|
||||
mIsNewIntent = false;
|
||||
closeActivity();
|
||||
}
|
||||
|
@ -7,19 +7,24 @@ import com.squareup.leakcanary.LeakCanary;
|
||||
|
||||
public class BrowserApp extends Application {
|
||||
|
||||
private static Context context;
|
||||
private static Context sContext;
|
||||
private static AppComponent appComponent;
|
||||
|
||||
@Override
|
||||
public void onCreate() {
|
||||
super.onCreate();
|
||||
context = getApplicationContext();
|
||||
LeakCanary.install(this);
|
||||
buildDepencyGraph();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void attachBaseContext(Context base) {
|
||||
super.attachBaseContext(base);
|
||||
sContext = base;
|
||||
}
|
||||
|
||||
public static Context getAppContext() {
|
||||
return context;
|
||||
return sContext;
|
||||
}
|
||||
|
||||
public static AppComponent getAppComponent() {
|
||||
|
@ -10,6 +10,7 @@ import android.content.Intent;
|
||||
import android.content.pm.PackageManager;
|
||||
import android.content.pm.ResolveInfo;
|
||||
import android.net.Uri;
|
||||
import android.os.Build;
|
||||
import android.os.Environment;
|
||||
import android.support.v7.app.AlertDialog;
|
||||
import android.text.TextUtils;
|
||||
@ -63,6 +64,11 @@ public class DownloadHandler {
|
||||
Intent intent = new Intent(Intent.ACTION_VIEW);
|
||||
intent.setDataAndType(Uri.parse(url), mimetype);
|
||||
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
|
||||
intent.addCategory(Intent.CATEGORY_BROWSABLE);
|
||||
intent.setComponent(null);
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.ICE_CREAM_SANDWICH_MR1) {
|
||||
intent.setSelector(null);
|
||||
}
|
||||
ResolveInfo info = context.getPackageManager().resolveActivity(intent,
|
||||
PackageManager.MATCH_DEFAULT_ONLY);
|
||||
if (info != null) {
|
||||
|
@ -26,8 +26,9 @@ public class LightningDownloadListener implements DownloadListener {
|
||||
@Override
|
||||
public void onDownloadStart(final String url, final String userAgent,
|
||||
final String contentDisposition, final String mimetype, long contentLength) {
|
||||
PermissionsManager.getInstance().requestPermissionsIfNecessaryForResult(mActivity, new String[]{Manifest.permission.READ_EXTERNAL_STORAGE,
|
||||
Manifest.permission.WRITE_EXTERNAL_STORAGE}, new PermissionsManager.PermissionResult() {
|
||||
PermissionsManager.getInstance().requestPermissionsIfNecessaryForResult(mActivity,
|
||||
new String[]{Manifest.permission.READ_EXTERNAL_STORAGE, Manifest.permission.WRITE_EXTERNAL_STORAGE},
|
||||
new PermissionsManager.PermissionResult() {
|
||||
@Override
|
||||
public void onGranted() {
|
||||
String fileName = URLUtil.guessFileName(url, contentDisposition, mimetype);
|
||||
@ -61,7 +62,5 @@ public class LightningDownloadListener implements DownloadListener {
|
||||
//TODO show message
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user