@Override protected void onDialogClosed(boolean positiveResult) { super.onDialogClosed(positiveResult); if (positiveResult) { setEnabled(false); BrowserSettings settings = BrowserSettings.getInstance(); if (PreferenceKeys.PREF_PRIVACY_CLEAR_CACHE.equals(getKey())) { settings.clearCache(); settings.clearDatabases(); } else if (PreferenceKeys.PREF_PRIVACY_CLEAR_COOKIES.equals(getKey())) { settings.clearCookies(); } else if (PreferenceKeys.PREF_PRIVACY_CLEAR_HISTORY.equals(getKey())) { settings.clearHistory(); } else if (PreferenceKeys.PREF_PRIVACY_CLEAR_FORM_DATA.equals(getKey())) { settings.clearFormData(); } else if (PreferenceKeys.PREF_PRIVACY_CLEAR_PASSWORDS.equals(getKey())) { settings.clearPasswords(); } else if (PreferenceKeys.PREF_RESET_DEFAULT_PREFERENCES.equals(getKey())) { settings.resetDefaultPreferences(); setEnabled(true); } else if (PreferenceKeys.PREF_PRIVACY_CLEAR_GEOLOCATION_ACCESS.equals(getKey())) { settings.clearLocationAccess(); } } }
public CatCmdMessage(Parcel in) { mCmdDet = in.readParcelable(null); mTextMsg = in.readParcelable(null); mMenu = in.readParcelable(null); mInput = in.readParcelable(null); mLoadIconFailed = (in.readByte() == 1); switch (getCmdType()) { case LAUNCH_BROWSER: mBrowserSettings = new BrowserSettings(); mBrowserSettings.url = in.readString(); mBrowserSettings.mode = LaunchBrowserMode.values()[in.readInt()]; break; case PLAY_TONE: mToneSettings = in.readParcelable(null); break; case SET_UP_CALL: mCallSettings = new CallSettings(); mCallSettings.confirmMsg = in.readParcelable(null); mCallSettings.callMsg = in.readParcelable(null); break; case SET_UP_EVENT_LIST: mSetupEventListSettings = new SetupEventListSettings(); int length = in.readInt(); mSetupEventListSettings.eventList = new int[length]; for (int i = 0; i < length; i++) { mSetupEventListSettings.eventList[i] = in.readInt(); } break; default: break; } }
CatCmdMessage(CommandParams cmdParams) { mCmdDet = cmdParams.mCmdDet; mLoadIconFailed = cmdParams.mLoadIconFailed; switch (getCmdType()) { case SET_UP_MENU: case SELECT_ITEM: mMenu = ((SelectItemParams) cmdParams).mMenu; break; case DISPLAY_TEXT: case SET_UP_IDLE_MODE_TEXT: case SEND_DTMF: case SEND_SMS: case REFRESH: case SEND_SS: case SEND_USSD: mTextMsg = ((DisplayTextParams) cmdParams).mTextMsg; break; case GET_INPUT: case GET_INKEY: mInput = ((GetInputParams) cmdParams).mInput; break; case LAUNCH_BROWSER: mTextMsg = ((LaunchBrowserParams) cmdParams).mConfirmMsg; mBrowserSettings = new BrowserSettings(); mBrowserSettings.url = ((LaunchBrowserParams) cmdParams).mUrl; mBrowserSettings.mode = ((LaunchBrowserParams) cmdParams).mMode; break; case PLAY_TONE: PlayToneParams params = (PlayToneParams) cmdParams; mToneSettings = params.mSettings; mTextMsg = params.mTextMsg; break; case GET_CHANNEL_STATUS: mTextMsg = ((CallSetupParams) cmdParams).mConfirmMsg; break; case SET_UP_CALL: mCallSettings = new CallSettings(); mCallSettings.confirmMsg = ((CallSetupParams) cmdParams).mConfirmMsg; mCallSettings.callMsg = ((CallSetupParams) cmdParams).mCallMsg; break; case OPEN_CHANNEL: case CLOSE_CHANNEL: case RECEIVE_DATA: case SEND_DATA: BIPClientParams param = (BIPClientParams) cmdParams; mTextMsg = param.mTextMsg; break; case SET_UP_EVENT_LIST: mSetupEventListSettings = new SetupEventListSettings(); mSetupEventListSettings.eventList = ((SetEventListParams) cmdParams).mEventInfo; break; case ACTIVATE: case PROVIDE_LOCAL_INFORMATION: default: break; } }
public static ProxySelectorInterface getThreadProxySelector() { final Thread currentThread = Thread.currentThread(); /** use BrowserSettings from current thread if available */ if (currentThread != null && currentThread instanceof BrowserSettings) { final BrowserSettings settings = (BrowserSettings) currentThread; return settings.getProxySelector(); } return null; }
private void copySettings() { final Thread currentThread = Thread.currentThread(); /** use BrowserSettings from current thread if available */ if (currentThread != null && currentThread instanceof BrowserSettings) { final BrowserSettings settings = (BrowserSettings) currentThread; this.proxySelector = settings.getProxySelector(); this.debug = settings.isDebug(); this.verbose = settings.isVerbose(); this.logger = settings.getLogger(); } }
@Override public boolean onContextItemSelected(MenuItem item) { ContextMenuInfo menuInfo = item.getMenuInfo(); if (menuInfo == null) { return false; } View targetView = getTargetView(menuInfo); if (!(targetView instanceof HistoryItem)) { return false; } HistoryItem historyItem = (HistoryItem) targetView; String url = historyItem.getUrl(); String title = historyItem.getName(); Activity activity = getActivity(); switch (item.getItemId()) { case R.id.open_context_menu_id: mCallback.openUrl(url); return true; case R.id.new_window_context_menu_id: mCallback.openInNewTab(url); return true; case R.id.save_to_bookmarks_menu_id: if (historyItem.isBookmark()) { Bookmarks.removeFromBookmarks(activity, activity.getContentResolver(), url, title); } else { Browser.saveBookmark(activity, title, url); } return true; case R.id.share_link_context_menu_id: Browser.sendString( activity, url, activity.getText(R.string.choosertitle_sharevia).toString()); return true; case R.id.copy_url_context_menu_id: copy(url); return true; case R.id.delete_context_menu_id: Browser.deleteFromHistory(activity.getContentResolver(), url); return true; case R.id.homepage_context_menu_id: BrowserSettings.getInstance().setHomePage(url); BrowserSettings.getInstance().setHomePagePicker(GeneralPreferencesFragment.OTHER); Toast.makeText(activity, R.string.homepage_set, Toast.LENGTH_LONG).show(); return true; default: break; } return super.onContextItemSelected(item); }
protected void initWebViewSettings(WebView w) { w.setScrollbarFadingEnabled(true); w.setScrollBarStyle(View.SCROLLBARS_OUTSIDE_OVERLAY); w.setMapTrackballToArrowKeys(false); // use trackball directly // Enable the built-in zoom w.getSettings().setBuiltInZoomControls(true); /// M: Add to disable overscroll mode w.setOverScrollMode(View.OVER_SCROLL_NEVER); final PackageManager pm = mContext.getPackageManager(); boolean supportsMultiTouch = pm.hasSystemFeature(PackageManager.FEATURE_TOUCHSCREEN_MULTITOUCH) || pm.hasSystemFeature(PackageManager.FEATURE_FAKETOUCH_MULTITOUCH_DISTINCT); w.getSettings().setDisplayZoomControls(!supportsMultiTouch); // Add this WebView to the settings observer list and update the // settings final BrowserSettings s = BrowserSettings.getInstance(); s.startManagingSettings(w.getSettings()); }
// In case a physical keyboard is attached, handle clicks with the menu key // depressed by opening in a new tab boolean handleMenuClick(Tab tab, String url) { if (mController.isMenuDown()) { mController.openTab( url, (tab != null) && tab.isPrivateBrowsingEnabled(), !BrowserSettings.getInstance().openInBackground(), true); mActivity.closeOptionsMenu(); return true; } return false; }
public BaseUi(Activity browser, UiController controller) { mActivity = browser; mUiController = controller; mTabControl = controller.getTabControl(); Resources res = mActivity.getResources(); mInputManager = (InputMethodManager) browser.getSystemService(Activity.INPUT_METHOD_SERVICE); mLockIconSecure = res.getDrawable(R.drawable.ic_secure_holo_dark); mLockIconMixed = res.getDrawable(R.drawable.ic_secure_partial_holo_dark); FrameLayout frameLayout = (FrameLayout) mActivity.getWindow().getDecorView().findViewById(android.R.id.content); LayoutInflater.from(mActivity).inflate(R.layout.custom_screen, frameLayout); mContentView = (FrameLayout) frameLayout.findViewById(R.id.main_content); mCustomViewContainer = (FrameLayout) frameLayout.findViewById(R.id.fullscreen_custom_content); mErrorConsoleContainer = (LinearLayout) frameLayout.findViewById(R.id.error_console); setFullscreen(BrowserSettings.getInstance().useFullscreen()); mGenericFavicon = res.getDrawable(R.drawable.app_web_browser_sm); mTitleBar = new TitleBar(mActivity, mUiController, this, mContentView); mTitleBar.setProgress(100); mNavigationBar = mTitleBar.getNavigationBar(); mUrlBarAutoShowManager = new UrlBarAutoShowManager(this); }
private Vector<Tab> getHalfLeastUsedTabs(Tab current) { Vector<Tab> tabsToGo = new Vector<Tab>(); // Don't do anything if we only have 1 tab or if the current tab is // null. if (getTabCount() == 1 || current == null) { return tabsToGo; } if (mTabQueue.size() == 0) { return tabsToGo; } // Rip through the queue starting at the beginning and tear down half of // available tabs which are not the current tab or the parent of the // current tab. int openTabCount = 0; for (Tab t : mTabQueue) { if (t != null && t.getWebView() != null) { openTabCount++; if (t != current && t != current.getParent()) { tabsToGo.add(t); } } } // mstar android patch start if (!BrowserSettings.getInstance().MEM_OPTIMIZED) { openTabCount /= 2; if (tabsToGo.size() > openTabCount) { tabsToGo.setSize(openTabCount); } } // mstar android patch end return tabsToGo; }
@Override public boolean onContextItemSelected(MenuItem item) { // It is possible that the view has been canceled when we get to // this point as back has a higher priority if (mCanceled) { return true; } AdapterView.AdapterContextMenuInfo i = (AdapterView.AdapterContextMenuInfo) item.getMenuInfo(); // If we have no menu info, we can't tell which item was selected. if (i == null) { return true; } switch (item.getItemId()) { case R.id.new_context_menu_id: saveCurrentPage(); break; case R.id.open_context_menu_id: loadUrl(i.position); break; case R.id.edit_context_menu_id: editBookmark(i.position); break; case R.id.shortcut_context_menu_id: final Intent send = createShortcutIntent(i.position); send.setAction(INSTALL_SHORTCUT); sendBroadcast(send); break; case R.id.delete_context_menu_id: if (mMostVisited) { Browser.deleteFromHistory(getContentResolver(), getUrl(i.position)); refreshList(); } else { displayRemoveBookmarkDialog(i.position); } break; case R.id.new_window_context_menu_id: openInNewWindow(i.position); break; case R.id.share_link_context_menu_id: BrowserActivity.sharePage( BrowserBookmarksPage.this, mBookmarksAdapter.getTitle(i.position), getUrl(i.position), getFavicon(i.position), mBookmarksAdapter.getScreenshot(i.position)); break; case R.id.copy_url_context_menu_id: copy(getUrl(i.position)); break; case R.id.homepage_context_menu_id: BrowserSettings.getInstance().setHomePage(this, getUrl(i.position)); Toast.makeText(this, R.string.homepage_set, Toast.LENGTH_LONG).show(); break; // Only for the Most visited page case R.id.save_to_bookmarks_menu_id: boolean isBookmark; String name; String url; if (mViewMode == BookmarkViewMode.GRID) { isBookmark = mBookmarksAdapter.getIsBookmark(i.position); name = mBookmarksAdapter.getTitle(i.position); url = mBookmarksAdapter.getUrl(i.position); } else { HistoryItem historyItem = ((HistoryItem) i.targetView); isBookmark = historyItem.isBookmark(); name = historyItem.getName(); url = historyItem.getUrl(); } // If the site is bookmarked, the item becomes remove from // bookmarks. if (isBookmark) { Bookmarks.removeFromBookmarks(this, getContentResolver(), url, name); } else { Browser.saveBookmark(this, name, url); } break; default: return super.onContextItemSelected(item); } return true; }