Android Open Source - EBrowser Controller






From Project

Back to project page EBrowser.

License

The source code is released under:

GNU General Public License

If you think the Android project EBrowser listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.

Java Source Code

/*
 * Zirco Browser for Android/*  w  w w  .  ja v  a  2s .c o m*/
 * 
 * Copyright (C) 2010 J. Devauchelle and contributors.
 *
 * This program is free software; you can redistribute it and/or
 * modify it under the terms of the GNU General Public License
 * version 3 as published by the Free Software Foundation.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 */

package org.zirco.controllers;

import java.util.ArrayList;
import java.util.List;

import org.zirco.model.DbAdapter;
import org.zirco.model.items.DownloadItem;
import org.zirco.ui.components.CustomWebView;

import android.content.Context;
import android.content.SharedPreferences;

/**
 * Controller implementation.
 */
public final class Controller {
  
  private SharedPreferences mPreferences;

  private List<CustomWebView> mWebViewList;
  private List<DownloadItem> mDownloadList;
  private List<String> mAdBlockWhiteList = null;
  private List<String> mMobileViewUrlList = null;
  
  /**
   * Holder for singleton implementation.
   */
  private static final class ControllerHolder {
    private static final Controller INSTANCE = new Controller();
    /**
     * Private Constructor.
     */
    private ControllerHolder() { }
  }
  
  /**
   * Get the unique instance of the Controller.
   * @return The instance of the Controller
   */
  public static Controller getInstance() {
    return ControllerHolder.INSTANCE;
  }
  
  /**
   * Private Constructor.
   */
  private Controller() {
    mDownloadList = new ArrayList<DownloadItem>();
  }
    
  /**
   * Get the list of current WebViews.
   * @return The list of current WebViews.
   */
  public List<CustomWebView> getWebViewList() {
    return mWebViewList;
  }
  
  /**
   * Set the list of current WebViews.
   * @param list The list of current WebViews.
   */
  public void setWebViewList(List<CustomWebView> list) {
    mWebViewList = list;
  }
  
  /**
   * Get a SharedPreferences instance.
   * @return The SharedPreferences instance.
   */
  public SharedPreferences getPreferences() {
    return mPreferences;
  }

  /**
   * Set the SharedPreferences instance.
   * @param preferences The SharedPreferences instance.
   */
  public void setPreferences(SharedPreferences preferences) {
    this.mPreferences = preferences;
  }
  
  /**
   * Get the current download list.
   * @return The current download list.
   */
  public List<DownloadItem> getDownloadList() {
    return mDownloadList;
  }
  
  /**
   * Add an item to the download list.
   * @param item The new item.
   */
  public void addToDownload(DownloadItem item) {
    mDownloadList.add(item);
  }
  
  public synchronized void clearCompletedDownloads() {
    List<DownloadItem> newList = new ArrayList<DownloadItem>();
    
    for (DownloadItem item : mDownloadList) {
      if (!item.isFinished()) {
        newList.add(item);
      }
    }
    
    mDownloadList.clear();
    mDownloadList = newList;
  }
  
  /**
   * Get the list of white-listed url for the AdBlocker.
   * @param context The current context.
   * @return A list of String url.
   */  
  public List<String> getAdBlockWhiteList(Context context) {
    if (mAdBlockWhiteList == null) {
      DbAdapter db = new DbAdapter(context);
      db.open();
      mAdBlockWhiteList = db.getWhiteList();
      db.close();
    }
    return mAdBlockWhiteList;
  }
  
  /**
   * Reset the AdBlock white list, so that it will be reloaded.
   */
  public void resetAdBlockWhiteList() {
    mAdBlockWhiteList = null;
  }  
  
  /**
   * Get the list of mobile view urls.
   * @param context The current context.
   * @return A list of String url.
   */
  public List<String> getMobileViewUrlList(Context context) {
    if (mMobileViewUrlList == null) {
      DbAdapter db = new DbAdapter(context);
      db.open();
      mMobileViewUrlList = db.getMobileViewUrlList();
      db.close();
    }
    return mMobileViewUrlList;
  }
  
  /**
   * Reset the mobile view url list, so that it will be reloaded.
   */
  public void resetMobileViewUrlList() {
    mMobileViewUrlList = null;
  }
  
}




Java Source Code List

org.emergent.android.weave.client.Base32.java
org.emergent.android.weave.client.Base64Encoder.java
org.emergent.android.weave.client.Base64.java
org.emergent.android.weave.client.BulkKeyCouplet.java
org.emergent.android.weave.client.Dbg.java
org.emergent.android.weave.client.HexEncoder.java
org.emergent.android.weave.client.Hex.java
org.emergent.android.weave.client.QueryParams.java
org.emergent.android.weave.client.QueryResult.java
org.emergent.android.weave.client.UserWeave.java
org.emergent.android.weave.client.WeaveAccountInfo.java
org.emergent.android.weave.client.WeaveBasicObject.java
org.emergent.android.weave.client.WeaveConstants.java
org.emergent.android.weave.client.WeaveCryptoUtil.java
org.emergent.android.weave.client.WeaveException.java
org.emergent.android.weave.client.WeaveFactory.java
org.emergent.android.weave.client.WeaveHeader.java
org.emergent.android.weave.client.WeaveResponse.java
org.emergent.android.weave.client.WeaveSSLSocketFactory.java
org.emergent.android.weave.client.WeaveTransport.java
org.emergent.android.weave.client.WeaveUtil.java
org.greendroid.QuickActionGrid.java
org.greendroid.QuickActionWidget.java
org.greendroid.QuickAction.java
org.zirco.controllers.Controller.java
org.zirco.events.EventConstants.java
org.zirco.events.EventController.java
org.zirco.events.IDownloadEventsListener.java
org.zirco.model.DbAdapter.java
org.zirco.model.UrlSuggestionItemComparator.java
org.zirco.model.adapters.BookmarksCursorAdapter.java
org.zirco.model.adapters.DownloadListAdapter.java
org.zirco.model.adapters.HistoryExpandableListAdapter.java
org.zirco.model.adapters.UrlSuggestionCursorAdapter.java
org.zirco.model.adapters.WeaveBookmarksCursorAdapter.java
org.zirco.model.items.BookmarkItem.java
org.zirco.model.items.DownloadItem.java
org.zirco.model.items.HistoryItem.java
org.zirco.model.items.UrlSuggestionItem.java
org.zirco.model.items.WeaveBookmarkItem.java
org.zirco.providers.BookmarksProviderWrapper.java
org.zirco.providers.WeaveColumns.java
org.zirco.providers.WeaveContentProvider.java
org.zirco.providers.ZircoBookmarksContentProvider.java
org.zirco.sync.ISyncListener.java
org.zirco.sync.WeaveSyncTask.java
org.zirco.ui.activities.AboutActivity.java
org.zirco.ui.activities.AdBlockerWhiteListActivity.java
org.zirco.ui.activities.BookmarksHistoryActivity.java
org.zirco.ui.activities.BookmarksListActivity.java
org.zirco.ui.activities.ChangelogActivity.java
org.zirco.ui.activities.DownloadsListActivity.java
org.zirco.ui.activities.EditBookmarkActivity.java
org.zirco.ui.activities.HistoryListActivity.java
org.zirco.ui.activities.IToolbarsContainer.java
org.zirco.ui.activities.MainActivity.java
org.zirco.ui.activities.MobileViewListActivity.java
org.zirco.ui.activities.WeaveBookmarksListActivity.java
org.zirco.ui.activities.preferences.BaseSpinnerCustomPreferenceActivity.java
org.zirco.ui.activities.preferences.HomepagePreferenceActivity.java
org.zirco.ui.activities.preferences.PreferencesActivity.java
org.zirco.ui.activities.preferences.SearchUrlPreferenceActivity.java
org.zirco.ui.activities.preferences.UserAgentPreferenceActivity.java
org.zirco.ui.activities.preferences.WeavePreferencesActivity.java
org.zirco.ui.activities.preferences.WeaveServerPreferenceActivity.java
org.zirco.ui.components.CustomWebViewClient.java
org.zirco.ui.components.CustomWebView.java
org.zirco.ui.runnables.DownloadRunnable.java
org.zirco.ui.runnables.FaviconUpdaterRunnable.java
org.zirco.ui.runnables.HideToolbarsRunnable.java
org.zirco.ui.runnables.HistoryUpdater.java
org.zirco.ui.runnables.XmlHistoryBookmarksExporter.java
org.zirco.ui.runnables.XmlHistoryBookmarksImporter.java
org.zirco.utils.AnimationManager.java
org.zirco.utils.ApplicationUtils.java
org.zirco.utils.Constants.java
org.zirco.utils.DateUtils.java
org.zirco.utils.IOUtils.java
org.zirco.utils.ProxyChangeReceiver.java
org.zirco.utils.ProxySettings.java
org.zirco.utils.UrlUtils.java