Making history page method static

This commit is contained in:
anthony restaino 2017-05-06 21:59:29 -04:00
parent 6f4e4115d8
commit efe3375389
3 changed files with 46 additions and 38 deletions

View File

@ -141,7 +141,6 @@ public abstract class BrowserActivity extends ThemableBrowserActivity implements
@BindView(R.id.progress_view) AnimatedProgressBar mProgressBar; @BindView(R.id.progress_view) AnimatedProgressBar mProgressBar;
@BindView(R.id.search_bar) RelativeLayout mSearchBar; @BindView(R.id.search_bar) RelativeLayout mSearchBar;
// Toolbar Views // Toolbar Views
@BindView(R.id.toolbar) Toolbar mToolbar; @BindView(R.id.toolbar) Toolbar mToolbar;
private View mSearchBackground; 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); public abstract void updateHistory(@Nullable final String title, @NonNull final String url);
@NonNull
abstract Completable updateCookiePreference(); abstract Completable updateCookiePreference();
@Override @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) { static boolean isPanicTrigger(@Nullable Intent intent) {
return intent != null && INTENT_PANIC_TRIGGER.equals(intent.getAction()); 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.newTab(this, "", false);
mTabsManager.switchToTab(0); mTabsManager.switchToTab(0);
mTabsManager.clearSavedState(); mTabsManager.clearSavedState();
new HistoryPage().deleteHistoryPage().subscribe(); HistoryPage.deleteHistoryPage(getApplication()).subscribe();
closeBrowser(); closeBrowser();
// System exit needed in the case of receiving // System exit needed in the case of receiving
// the panic intent since finish() isn't completely // the panic intent since finish() isn't completely

View File

@ -34,7 +34,7 @@ public class MainActivity extends BrowserActivity {
} }
@Override @Override
public boolean onCreateOptionsMenu(Menu menu) { public boolean onCreateOptionsMenu(@NonNull Menu menu) {
getMenuInflater().inflate(R.menu.main, menu); getMenuInflater().inflate(R.menu.main, menu);
return super.onCreateOptionsMenu(menu); return super.onCreateOptionsMenu(menu);
} }

View File

@ -116,11 +116,11 @@ public class HistoryPage {
* when subscribed. * when subscribed.
*/ */
@NonNull @NonNull
public Completable deleteHistoryPage() { public static Completable deleteHistoryPage(@NonNull final Application application) {
return Completable.create(new CompletableAction() { return Completable.create(new CompletableAction() {
@Override @Override
public void onSubscribe(@NonNull CompletableSubscriber subscriber) { public void onSubscribe(@NonNull CompletableSubscriber subscriber) {
File historyWebPage = new File(mApp.getFilesDir(), FILENAME); File historyWebPage = new File(application.getFilesDir(), FILENAME);
if (historyWebPage.exists()) { if (historyWebPage.exists()) {
historyWebPage.delete(); historyWebPage.delete();
} }