зеркало из https://github.com/mozilla/gecko-dev.git
Backed out changeset 1260d241f84f (bug 944533) for bustage on android and windows builds on a CLOSED TREE
This commit is contained in:
Родитель
0afffcc7c8
Коммит
be1a15264c
|
@ -316,7 +316,6 @@ gbjar.sources += [
|
|||
'toolbar/ToolbarDisplayLayout.java',
|
||||
'toolbar/ToolbarEditLayout.java',
|
||||
'toolbar/ToolbarEditText.java',
|
||||
'toolbar/ToolbarTitlePrefs.java',
|
||||
'TouchEventInterceptor.java',
|
||||
'updater/UpdateService.java',
|
||||
'updater/UpdateServiceHelper.java',
|
||||
|
|
|
@ -20,6 +20,7 @@ import org.mozilla.gecko.animation.PropertyAnimator.PropertyAnimationListener;
|
|||
import org.mozilla.gecko.animation.ViewHelper;
|
||||
import org.mozilla.gecko.menu.GeckoMenu;
|
||||
import org.mozilla.gecko.menu.MenuPopup;
|
||||
import org.mozilla.gecko.PrefsHelper;
|
||||
import org.mozilla.gecko.toolbar.ToolbarDisplayLayout.OnStopListener;
|
||||
import org.mozilla.gecko.toolbar.ToolbarDisplayLayout.UpdateFlags;
|
||||
import org.mozilla.gecko.util.Clipboard;
|
||||
|
@ -72,6 +73,8 @@ public class BrowserToolbar extends GeckoRelativeLayout
|
|||
GeckoMenu.ActionItemBarPresenter,
|
||||
GeckoEventListener {
|
||||
private static final String LOGTAG = "GeckoToolbar";
|
||||
public static final String PREF_TITLEBAR_MODE = "browser.chrome.titlebarMode";
|
||||
public static final String PREF_TRIM_URLS = "browser.urlbar.trimURLs";
|
||||
|
||||
public interface OnActivateListener {
|
||||
public void onActivate();
|
||||
|
@ -134,8 +137,6 @@ public class BrowserToolbar extends GeckoRelativeLayout
|
|||
private int mUrlBarViewOffset;
|
||||
private int mDefaultForwardMargin;
|
||||
|
||||
private ToolbarTitlePrefs mTitlePrefs;
|
||||
|
||||
private static final Interpolator sButtonsInterpolator = new AccelerateInterpolator();
|
||||
|
||||
private static final int FORWARD_ANIMATION_DURATION = 450;
|
||||
|
@ -146,6 +147,11 @@ public class BrowserToolbar extends GeckoRelativeLayout
|
|||
|
||||
private final LightweightTheme mTheme;
|
||||
|
||||
private boolean mShowUrl;
|
||||
private boolean mTrimURLs;
|
||||
|
||||
private Integer mPrefObserverId;
|
||||
|
||||
public BrowserToolbar(Context context) {
|
||||
this(context, null);
|
||||
}
|
||||
|
@ -162,9 +168,58 @@ public class BrowserToolbar extends GeckoRelativeLayout
|
|||
|
||||
Tabs.registerOnTabsChangedListener(this);
|
||||
mSwitchingTabs = true;
|
||||
mAnimatingEntry = false;
|
||||
|
||||
mTitlePrefs = new ToolbarTitlePrefs();
|
||||
mAnimatingEntry = false;
|
||||
mShowUrl = false;
|
||||
mTrimURLs = true;
|
||||
|
||||
final String[] prefs = {
|
||||
PREF_TITLEBAR_MODE,
|
||||
PREF_TRIM_URLS
|
||||
};
|
||||
// listen to the title bar pref.
|
||||
mPrefObserverId = PrefsHelper.getPrefs(prefs, new PrefsHelper.PrefHandlerBase() {
|
||||
@Override
|
||||
public void prefValue(String pref, String str) {
|
||||
// Handles PREF_TITLEBAR_MODE, which is always a string.
|
||||
int value = Integer.parseInt(str);
|
||||
boolean shouldShowUrl = (value == 1);
|
||||
|
||||
if (shouldShowUrl == mShowUrl) {
|
||||
return;
|
||||
}
|
||||
mShowUrl = shouldShowUrl;
|
||||
|
||||
triggerTitleUpdate();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void prefValue(String pref, boolean value) {
|
||||
// Handles PREF_TRIM_URLS, which should usually be a boolean.
|
||||
if (value == mTrimURLs) {
|
||||
return;
|
||||
}
|
||||
mTrimURLs = value;
|
||||
|
||||
triggerTitleUpdate();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isObserver() {
|
||||
// We want to be notified of changes to be able to switch mode
|
||||
// without restarting.
|
||||
return true;
|
||||
}
|
||||
|
||||
private void triggerTitleUpdate() {
|
||||
ThreadUtils.postToUiThread(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
updateTitle();
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
Resources res = getResources();
|
||||
mUrlColor = new ForegroundColorSpan(res.getColor(R.color.url_bar_urltext));
|
||||
|
@ -660,8 +715,7 @@ public class BrowserToolbar extends GeckoRelativeLayout
|
|||
setContentDescription(contentDescription);
|
||||
}
|
||||
|
||||
// Sets the toolbar title according to the selected tab, obeying the
|
||||
// ToolbarTitlePrefs.shouldShowUrl() preference.
|
||||
// Sets the toolbar title according to the selected tab, obeying the mShowUrl preference.
|
||||
private void updateTitle() {
|
||||
final Tab tab = Tabs.getInstance().getSelectedTab();
|
||||
// Keep the title unchanged if there's no selected tab, or if the tab is entering reader mode.
|
||||
|
@ -691,13 +745,13 @@ public class BrowserToolbar extends GeckoRelativeLayout
|
|||
}
|
||||
|
||||
// If the pref to show the URL isn't set, just use the tab's display title.
|
||||
if (!mTitlePrefs.shouldShowUrl() || url == null) {
|
||||
if (!mShowUrl || url == null) {
|
||||
setTitle(tab.getDisplayTitle());
|
||||
return;
|
||||
}
|
||||
|
||||
CharSequence title = url;
|
||||
if (mTitlePrefs.shouldTrimUrls()) {
|
||||
if (mTrimURLs) {
|
||||
title = StringUtils.stripCommonSubdomains(StringUtils.stripScheme(url));
|
||||
}
|
||||
|
||||
|
@ -1278,7 +1332,10 @@ public class BrowserToolbar extends GeckoRelativeLayout
|
|||
}
|
||||
|
||||
public void onDestroy() {
|
||||
mTitlePrefs.close();
|
||||
if (mPrefObserverId != null) {
|
||||
PrefsHelper.removeObserver(mPrefObserverId);
|
||||
mPrefObserverId = null;
|
||||
}
|
||||
Tabs.unregisterOnTabsChangedListener(this);
|
||||
|
||||
unregisterEventListener("Reader:Click");
|
||||
|
|
|
@ -1,99 +0,0 @@
|
|||
/* -*- Mode: Java; c-basic-offset: 4; tab-width: 20; indent-tabs-mode: nil; -*-
|
||||
* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
package org.mozilla.gecko.toolbar;
|
||||
|
||||
import org.mozilla.gecko.PrefsHelper;
|
||||
import org.mozilla.gecko.Tab;
|
||||
import org.mozilla.gecko.Tabs;
|
||||
import org.mozilla.gecko.util.ThreadUtils;
|
||||
|
||||
class ToolbarTitlePrefs {
|
||||
public static final String PREF_TITLEBAR_MODE = "browser.chrome.titlebarMode";
|
||||
public static final String PREF_TRIM_URLS = "browser.urlbar.trimURLs";
|
||||
|
||||
interface OnChangeListener {
|
||||
public void onChange();
|
||||
}
|
||||
|
||||
final String[] prefs = {
|
||||
PREF_TITLEBAR_MODE,
|
||||
PREF_TRIM_URLS
|
||||
};
|
||||
|
||||
private boolean mShowUrl;
|
||||
private boolean mTrimUrls;
|
||||
|
||||
private Integer mPrefObserverId;
|
||||
|
||||
ToolbarTitlePrefs() {
|
||||
mShowUrl = false;
|
||||
mTrimUrls = true;
|
||||
|
||||
mPrefObserverId = PrefsHelper.getPrefs(prefs, new TitlePrefsHandler());
|
||||
}
|
||||
|
||||
boolean shouldShowUrl() {
|
||||
return mShowUrl;
|
||||
}
|
||||
|
||||
boolean shouldTrimUrls() {
|
||||
return mTrimUrls;
|
||||
}
|
||||
|
||||
void close() {
|
||||
if (mPrefObserverId != null) {
|
||||
PrefsHelper.removeObserver(mPrefObserverId);
|
||||
mPrefObserverId = null;
|
||||
}
|
||||
}
|
||||
|
||||
private class TitlePrefsHandler extends PrefsHelper.PrefHandlerBase {
|
||||
@Override
|
||||
public void prefValue(String pref, String str) {
|
||||
// Handles PREF_TITLEBAR_MODE, which is always a string.
|
||||
int value = Integer.parseInt(str);
|
||||
boolean shouldShowUrl = (value == 1);
|
||||
|
||||
if (shouldShowUrl == mShowUrl) {
|
||||
return;
|
||||
}
|
||||
mShowUrl = shouldShowUrl;
|
||||
|
||||
triggerChangeListener();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void prefValue(String pref, boolean value) {
|
||||
// Handles PREF_TRIM_URLS, which should usually be a boolean.
|
||||
if (value == mTrimUrls) {
|
||||
return;
|
||||
}
|
||||
mTrimUrls = value;
|
||||
|
||||
triggerChangeListener();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isObserver() {
|
||||
// We want to be notified of changes to be able to switch mode
|
||||
// without restarting.
|
||||
return true;
|
||||
}
|
||||
|
||||
private void triggerChangeListener() {
|
||||
ThreadUtils.postToUiThread(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
final Tabs tabs = Tabs.getInstance();
|
||||
final Tab tab = tabs.getSelectedTab();
|
||||
if (tab != null) {
|
||||
tabs.notifyListeners(tab, Tabs.TabEvents.TITLE);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
Загрузка…
Ссылка в новой задаче