diff --git a/app/src/main/java/acr/browser/lightning/activity/BrowserActivity.java b/app/src/main/java/acr/browser/lightning/activity/BrowserActivity.java index 176c140..97ab0b3 100644 --- a/app/src/main/java/acr/browser/lightning/activity/BrowserActivity.java +++ b/app/src/main/java/acr/browser/lightning/activity/BrowserActivity.java @@ -141,7 +141,6 @@ public abstract class BrowserActivity extends ThemableBrowserActivity implements @BindView(R.id.progress_view) AnimatedProgressBar mProgressBar; @BindView(R.id.search_bar) RelativeLayout mSearchBar; - // Toolbar Views @BindView(R.id.toolbar) Toolbar mToolbar; private View mSearchBackground; @@ -214,6 +213,7 @@ public abstract class BrowserActivity extends ThemableBrowserActivity implements public abstract void updateHistory(@Nullable final String title, @NonNull final String url); + @NonNull abstract Completable updateCookiePreference(); @Override @@ -433,6 +433,14 @@ public abstract class BrowserActivity extends ThemableBrowserActivity implements } } + /** + * Determines if an intent is originating + * from a panic trigger. + * + * @param intent the intent to check. + * @return true if the panic trigger sent + * the intent, false otherwise. + */ static boolean isPanicTrigger(@Nullable Intent intent) { return intent != null && INTENT_PANIC_TRIGGER.equals(intent.getAction()); } @@ -442,7 +450,7 @@ public abstract class BrowserActivity extends ThemableBrowserActivity implements mTabsManager.newTab(this, "", false); mTabsManager.switchToTab(0); mTabsManager.clearSavedState(); - new HistoryPage().deleteHistoryPage().subscribe(); + HistoryPage.deleteHistoryPage(getApplication()).subscribe(); closeBrowser(); // System exit needed in the case of receiving // the panic intent since finish() isn't completely diff --git a/app/src/main/java/acr/browser/lightning/activity/MainActivity.java b/app/src/main/java/acr/browser/lightning/activity/MainActivity.java index 3220d65..0580859 100644 --- a/app/src/main/java/acr/browser/lightning/activity/MainActivity.java +++ b/app/src/main/java/acr/browser/lightning/activity/MainActivity.java @@ -34,7 +34,7 @@ public class MainActivity extends BrowserActivity { } @Override - public boolean onCreateOptionsMenu(Menu menu) { + public boolean onCreateOptionsMenu(@NonNull Menu menu) { getMenuInflater().inflate(R.menu.main, menu); return super.onCreateOptionsMenu(menu); } diff --git a/app/src/main/java/acr/browser/lightning/constant/HistoryPage.java b/app/src/main/java/acr/browser/lightning/constant/HistoryPage.java index 6c179c6..323c190 100644 --- a/app/src/main/java/acr/browser/lightning/constant/HistoryPage.java +++ b/app/src/main/java/acr/browser/lightning/constant/HistoryPage.java @@ -68,41 +68,41 @@ public class HistoryPage { final StringBuilder historyBuilder = new StringBuilder(HEADING_1 + mTitle + HEADING_2); HistoryModel.lastHundredVisitedHistoryItems() - .subscribe(new SingleOnSubscribe>() { - @Override - public void onItem(@Nullable List item) { - - Preconditions.checkNonNull(item); - Iterator it = item.iterator(); - HistoryItem helper; - while (it.hasNext()) { - helper = it.next(); - historyBuilder.append(PART1); - historyBuilder.append(helper.getUrl()); - historyBuilder.append(PART2); - historyBuilder.append(helper.getTitle()); - historyBuilder.append(PART3); - historyBuilder.append(helper.getUrl()); - historyBuilder.append(PART4); - } - - historyBuilder.append(END); - File historyWebPage = new File(mApp.getFilesDir(), FILENAME); - FileWriter historyWriter = null; - try { - //noinspection IOResourceOpenedButNotSafelyClosed - historyWriter = new FileWriter(historyWebPage, false); - historyWriter.write(historyBuilder.toString()); - } catch (IOException e) { - Log.e(TAG, "Unable to write history page to disk", e); - } finally { - Utils.close(historyWriter); - } - - subscriber.onItem(Constants.FILE + historyWebPage); - subscriber.onComplete(); + .subscribe(new SingleOnSubscribe>() { + @Override + public void onItem(@Nullable List item) { + + Preconditions.checkNonNull(item); + Iterator it = item.iterator(); + HistoryItem helper; + while (it.hasNext()) { + helper = it.next(); + historyBuilder.append(PART1); + historyBuilder.append(helper.getUrl()); + historyBuilder.append(PART2); + historyBuilder.append(helper.getTitle()); + historyBuilder.append(PART3); + historyBuilder.append(helper.getUrl()); + historyBuilder.append(PART4); } - }); + + historyBuilder.append(END); + File historyWebPage = new File(mApp.getFilesDir(), FILENAME); + FileWriter historyWriter = null; + try { + //noinspection IOResourceOpenedButNotSafelyClosed + historyWriter = new FileWriter(historyWebPage, false); + historyWriter.write(historyBuilder.toString()); + } catch (IOException e) { + Log.e(TAG, "Unable to write history page to disk", e); + } finally { + Utils.close(historyWriter); + } + + subscriber.onItem(Constants.FILE + historyWebPage); + subscriber.onComplete(); + } + }); } }); } @@ -116,11 +116,11 @@ public class HistoryPage { * when subscribed. */ @NonNull - public Completable deleteHistoryPage() { + public static Completable deleteHistoryPage(@NonNull final Application application) { return Completable.create(new CompletableAction() { @Override public void onSubscribe(@NonNull CompletableSubscriber subscriber) { - File historyWebPage = new File(mApp.getFilesDir(), FILENAME); + File historyWebPage = new File(application.getFilesDir(), FILENAME); if (historyWebPage.exists()) { historyWebPage.delete(); }