mirror of
https://github.com/mozilla/gecko-dev.git
synced 2025-01-13 15:34:01 +00:00
Bug 766940 - Notify MENU_UPDATED TabEvent when menu items change. r=mbrubeck
Also fixes bug 767959.
This commit is contained in:
parent
0614ceffe9
commit
4bdc1be50a
@ -62,11 +62,10 @@ abstract public class BrowserApp extends GeckoApp
|
||||
maybeCancelFaviconLoad(tab);
|
||||
}
|
||||
break;
|
||||
case LOAD_ERROR:
|
||||
case START:
|
||||
if (Tabs.getInstance().isSelectedTab(tab)) {
|
||||
invalidateOptionsMenu();
|
||||
}
|
||||
case STOP:
|
||||
case MENU_UPDATED:
|
||||
if (Tabs.getInstance().isSelectedTab(tab)) {
|
||||
invalidateOptionsMenu();
|
||||
}
|
||||
|
@ -169,14 +169,6 @@ abstract public class GeckoApp
|
||||
updatePopups(tab);
|
||||
invalidateOptionsMenu();
|
||||
break;
|
||||
|
||||
case LOAD_ERROR:
|
||||
case START:
|
||||
case STOP:
|
||||
// The options menu only applies to the selected tab.
|
||||
if (Tabs.getInstance().isSelectedTab(tab))
|
||||
invalidateOptionsMenu();
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -101,7 +101,6 @@ public final class Tab {
|
||||
mContentObserver = new ContentObserver(GeckoAppShell.getHandler()) {
|
||||
public void onChange(boolean selfChange) {
|
||||
updateBookmark();
|
||||
updateReadingListItem();
|
||||
}
|
||||
};
|
||||
BrowserDB.registerBookmarkObserver(mContentResolver, mContentObserver);
|
||||
@ -248,7 +247,6 @@ public final class Tab {
|
||||
mUrl = url;
|
||||
Log.i(LOGTAG, "Updated url: " + url + " for tab with id: " + mId);
|
||||
updateBookmark();
|
||||
updateReadingListItem();
|
||||
updateHistory(mUrl, mTitle);
|
||||
}
|
||||
}
|
||||
@ -379,6 +377,11 @@ public final class Tab {
|
||||
|
||||
public void setReaderEnabled(boolean readerEnabled) {
|
||||
mReaderEnabled = readerEnabled;
|
||||
GeckoAppShell.getMainHandler().post(new Runnable() {
|
||||
public void run() {
|
||||
Tabs.getInstance().notifyListeners(Tab.this, Tabs.TabEvents.MENU_UPDATED);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private void updateBookmark() {
|
||||
@ -386,29 +389,21 @@ public final class Tab {
|
||||
if (url == null)
|
||||
return;
|
||||
|
||||
GeckoBackgroundThread.getHandler().post(new Runnable() {
|
||||
public void run() {
|
||||
boolean bookmark = BrowserDB.isBookmark(mContentResolver, url);
|
||||
(new GeckoAsyncTask<Void, Void, Void>() {
|
||||
@Override
|
||||
public Void doInBackground(Void... params) {
|
||||
if (url.equals(getURL())) {
|
||||
mBookmark = bookmark;
|
||||
mBookmark = BrowserDB.isBookmark(mContentResolver, url);
|
||||
mReadingListItem = BrowserDB.isReadingListItem(mContentResolver, url);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private void updateReadingListItem() {
|
||||
final String url = getURL();
|
||||
if (url == null)
|
||||
return;
|
||||
|
||||
GeckoBackgroundThread.getHandler().post(new Runnable() {
|
||||
public void run() {
|
||||
boolean readingListItem = BrowserDB.isReadingListItem(mContentResolver, url);
|
||||
if (url.equals(getURL())) {
|
||||
mReadingListItem = readingListItem;
|
||||
}
|
||||
@Override
|
||||
public void onPostExecute(Void result) {
|
||||
Tabs.getInstance().notifyListeners(Tab.this, Tabs.TabEvents.MENU_UPDATED);
|
||||
}
|
||||
});
|
||||
}).execute();
|
||||
}
|
||||
|
||||
public void addBookmark() {
|
||||
|
@ -350,7 +350,8 @@ public class Tabs implements GeckoEventListener {
|
||||
UNSELECTED,
|
||||
ADDED,
|
||||
RESTORED,
|
||||
LOCATION_CHANGE
|
||||
LOCATION_CHANGE,
|
||||
MENU_UPDATED
|
||||
}
|
||||
|
||||
public void notifyListeners(Tab tab, TabEvents msg) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user