From 20ca7047f3b479531f8c2abad99e5f9c2c4ca6d1 Mon Sep 17 00:00:00 2001 From: DF1E Date: Sat, 3 Jun 2017 10:54:16 +0200 Subject: [PATCH] minor changes --- .../acr/browser/lightning/constant/Constants.java | 2 -- .../database/downloads/DownloadItem.java | 1 + .../database/downloads/DownloadsModel.java | 2 +- .../lightning/dialog/LightningDialogBuilder.java | 15 +++++++++++---- .../lightning/view/LightningWebClient.java | 5 ++--- 5 files changed, 15 insertions(+), 10 deletions(-) diff --git a/app/src/main/java/acr/browser/lightning/constant/Constants.java b/app/src/main/java/acr/browser/lightning/constant/Constants.java index 2e76e78..731d4a5 100644 --- a/app/src/main/java/acr/browser/lightning/constant/Constants.java +++ b/app/src/main/java/acr/browser/lightning/constant/Constants.java @@ -8,8 +8,6 @@ import android.support.annotation.IntDef; import java.lang.annotation.Retention; import java.lang.annotation.RetentionPolicy; -import acr.browser.lightning.BuildConfig; - public final class Constants { private Constants() { diff --git a/app/src/main/java/acr/browser/lightning/database/downloads/DownloadItem.java b/app/src/main/java/acr/browser/lightning/database/downloads/DownloadItem.java index 884e052..90025ba 100644 --- a/app/src/main/java/acr/browser/lightning/database/downloads/DownloadItem.java +++ b/app/src/main/java/acr/browser/lightning/database/downloads/DownloadItem.java @@ -25,6 +25,7 @@ public class DownloadItem implements Comparable { public DownloadItem(@NonNull String url, @NonNull String title, @NonNull String size) { Preconditions.checkNonNull(url); Preconditions.checkNonNull(title); + Preconditions.checkNonNull(size); this.mUrl = url; this.mTitle = title; this.mContentSize = size; diff --git a/app/src/main/java/acr/browser/lightning/database/downloads/DownloadsModel.java b/app/src/main/java/acr/browser/lightning/database/downloads/DownloadsModel.java index d8dc67e..a5545ef 100644 --- a/app/src/main/java/acr/browser/lightning/database/downloads/DownloadsModel.java +++ b/app/src/main/java/acr/browser/lightning/database/downloads/DownloadsModel.java @@ -12,7 +12,7 @@ import java.util.List; * The interface that should be used to * communicate with the download database. *

- * Created by anthonycr on 5/6/17. + * Created by df1e on 29/5/17. */ public interface DownloadsModel { diff --git a/app/src/main/java/acr/browser/lightning/dialog/LightningDialogBuilder.java b/app/src/main/java/acr/browser/lightning/dialog/LightningDialogBuilder.java index 706e7f4..9763383 100644 --- a/app/src/main/java/acr/browser/lightning/dialog/LightningDialogBuilder.java +++ b/app/src/main/java/acr/browser/lightning/dialog/LightningDialogBuilder.java @@ -16,6 +16,7 @@ import android.widget.AutoCompleteTextView; import android.widget.EditText; import com.anthonycr.bonsai.CompletableOnSubscribe; +import com.anthonycr.bonsai.CompletableSubscriber; import com.anthonycr.bonsai.Schedulers; import com.anthonycr.bonsai.SingleOnSubscribe; @@ -39,14 +40,13 @@ import acr.browser.lightning.utils.IntentUtils; import acr.browser.lightning.utils.Preconditions; import acr.browser.lightning.utils.Utils; -import static android.content.ContentValues.TAG; - /** * TODO Rename this class it doesn't build dialogs only for bookmarks *

* Created by Stefano Pacifici on 02/09/15, based on Anthony C. Restaino's code. */ public class LightningDialogBuilder { + public static final String TAG = "LightningDialogBuilder"; public enum NewTab { FOREGROUND, @@ -173,8 +173,15 @@ public class LightningDialogBuilder { new BrowserDialog.Item(R.string.dialog_delete_all_downloads) { @Override public void onClick() { - mDownloadsModel.deleteAllDownloads().subscribeOn(Schedulers.io()).subscribe(); - uiController.handleDownloadDeleted(); + mDownloadsModel.deleteAllDownloads() + .subscribeOn(Schedulers.io()) + .observeOn(Schedulers.main()) + .subscribe(new CompletableOnSubscribe() { + @Override + public void onComplete() { + uiController.handleDownloadDeleted(); + } + }); } }); } diff --git a/app/src/main/java/acr/browser/lightning/view/LightningWebClient.java b/app/src/main/java/acr/browser/lightning/view/LightningWebClient.java index 62cdbda..8e3f4bb 100644 --- a/app/src/main/java/acr/browser/lightning/view/LightningWebClient.java +++ b/app/src/main/java/acr/browser/lightning/view/LightningWebClient.java @@ -22,7 +22,6 @@ import android.view.View; import android.webkit.HttpAuthHandler; import android.webkit.MimeTypeMap; import android.webkit.SslErrorHandler; -import android.webkit.URLUtil; import android.webkit.ValueCallback; import android.webkit.WebResourceRequest; import android.webkit.WebResourceResponse; @@ -360,8 +359,8 @@ public class LightningWebClient extends WebViewClient { } return true; } - } else if (url.startsWith("file://")) { - File file = new File(url.replace("file://", "")); + } else if (url.startsWith(Constants.FILE)) { + File file = new File(url.replace(Constants.FILE, "")); if (file.exists()) { String newMimeType = MimeTypeMap.getSingleton()